|
44 | 44 | import org.apache.commons.logging.Log;
|
45 | 45 | import org.apache.commons.logging.LogFactory;
|
46 | 46 | import org.cloudfoundry.client.lib.ApplicationLogListener;
|
| 47 | +import org.cloudfoundry.client.lib.ClientHttpResponseCallback; |
47 | 48 | import org.cloudfoundry.client.lib.CloudCredentials;
|
48 | 49 | import org.cloudfoundry.client.lib.CloudFoundryException;
|
49 | 50 | import org.cloudfoundry.client.lib.CloudOperationException;
|
@@ -250,6 +251,13 @@ public String getFile(String appName, int instanceIndex, String filePath, int st
|
250 | 251 | return doGetFile(urlPath, appId, instanceIndex, filePath, startPosition, endPosition);
|
251 | 252 | }
|
252 | 253 |
|
| 254 | + |
| 255 | + public void openFile(String appName, int instanceIndex, String filePath, ClientHttpResponseCallback callback) { |
| 256 | + String urlPath = getFileUrlPath(); |
| 257 | + Object appId = getFileAppId(appName); |
| 258 | + doOpenFile(urlPath, appId, instanceIndex, filePath, callback); |
| 259 | + } |
| 260 | + |
253 | 261 | public void registerRestLogListener(RestLogCallback callBack) {
|
254 | 262 | if (getRestTemplate() instanceof LoggingRestTemplate) {
|
255 | 263 | ((LoggingRestTemplate)getRestTemplate()).registerRestLogListener(callBack);
|
@@ -424,6 +432,13 @@ protected Map<String, String> doGetLogs(String urlPath, String appName, String i
|
424 | 432 | return logs;
|
425 | 433 | }
|
426 | 434 |
|
| 435 | + @SuppressWarnings("unchecked") |
| 436 | + protected void doOpenFile(String urlPath, Object app, int instanceIndex, String filePath, |
| 437 | + ClientHttpResponseCallback callback) { |
| 438 | + getRestTemplate().execute(getUrl(urlPath), HttpMethod.GET, null, new ResponseExtractorWrapper(callback), app, |
| 439 | + String.valueOf(instanceIndex), filePath); |
| 440 | + } |
| 441 | + |
427 | 442 | protected String doGetFile(String urlPath, Object app, int instanceIndex, String filePath, int startPosition, int endPosition) {
|
428 | 443 | return doGetFile(urlPath, app, String.valueOf(instanceIndex), filePath, startPosition, endPosition);
|
429 | 444 | }
|
@@ -1740,4 +1755,18 @@ private boolean hasEmbeddedResource(Map<String, Object> resource, String resourc
|
1740 | 1755 | return entity.containsKey(resourceKey) || entity.containsKey(resourceKey + "_url");
|
1741 | 1756 | }
|
1742 | 1757 |
|
| 1758 | + private static class ResponseExtractorWrapper implements ResponseExtractor { |
| 1759 | + |
| 1760 | + private ClientHttpResponseCallback callback; |
| 1761 | + |
| 1762 | + public ResponseExtractorWrapper(ClientHttpResponseCallback callback) { |
| 1763 | + this.callback = callback; |
| 1764 | + } |
| 1765 | + |
| 1766 | + public Object extractData(ClientHttpResponse clientHttpResponse) throws IOException { |
| 1767 | + callback.onClientHttpResponse(clientHttpResponse); |
| 1768 | + return null; |
| 1769 | + } |
| 1770 | + |
| 1771 | + } |
1743 | 1772 | }
|
0 commit comments