Search in sources :

Example 1 with GetUdfApplicationLogResponseParser

use of com.aliyun.oss.internal.ResponseParsers.GetUdfApplicationLogResponseParser in project aliyun-oss-java-sdk by aliyun.

the class OSSUdfOperation method getUdfApplicationLog.

public UdfApplicationLog getUdfApplicationLog(GetUdfApplicationLogRequest getUdfApplicationLogRequest) throws OSSException, ClientException {
    assertParameterNotNull(getUdfApplicationLogRequest, "resizeUdfApplicationRequest");
    String udfName = getUdfApplicationLogRequest.getName();
    assertParameterNotNull(udfName, "udfName");
    ensureBucketNameValid(udfName);
    Map<String, String> params = new HashMap<String, String>();
    populateGetUdfApplicationLogParameters(params, getUdfApplicationLogRequest);
    RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setParameters(params).setOriginalRequest(getUdfApplicationLogRequest).build();
    ProgressListener listener = getUdfApplicationLogRequest.getProgressListener();
    UdfApplicationLog udfApplicationLog = null;
    try {
        publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
        udfApplicationLog = doOperation(request, new GetUdfApplicationLogResponseParser(udfName), null, null, true);
        InputStream instream = udfApplicationLog.getLogContent();
        ProgressInputStream progressInputStream = new ProgressInputStream(instream, listener) {

            @Override
            protected void onEOF() {
                publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
            }
        };
        CRC64 crc = new CRC64();
        CheckedInputStream checkedInputstream = new CheckedInputStream(progressInputStream, crc);
        udfApplicationLog.setLogContent(checkedInputstream);
    } catch (RuntimeException e) {
        publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
        throw e;
    }
    return udfApplicationLog;
}
Also used : GetUdfApplicationLogResponseParser(com.aliyun.oss.internal.ResponseParsers.GetUdfApplicationLogResponseParser) CRC64(com.aliyun.oss.common.utils.CRC64) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ProgressInputStream(com.aliyun.oss.event.ProgressInputStream) CheckedInputStream(java.util.zip.CheckedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ProgressInputStream(com.aliyun.oss.event.ProgressInputStream) IOUtils.newRepeatableInputStream(com.aliyun.oss.common.utils.IOUtils.newRepeatableInputStream) InputStream(java.io.InputStream) CheckedInputStream(java.util.zip.CheckedInputStream) UdfApplicationLog(com.aliyun.oss.model.UdfApplicationLog) ProgressListener(com.aliyun.oss.event.ProgressListener) RequestMessage(com.aliyun.oss.common.comm.RequestMessage)

Aggregations

RequestMessage (com.aliyun.oss.common.comm.RequestMessage)1 CRC64 (com.aliyun.oss.common.utils.CRC64)1 IOUtils.newRepeatableInputStream (com.aliyun.oss.common.utils.IOUtils.newRepeatableInputStream)1 ProgressInputStream (com.aliyun.oss.event.ProgressInputStream)1 ProgressListener (com.aliyun.oss.event.ProgressListener)1 GetUdfApplicationLogResponseParser (com.aliyun.oss.internal.ResponseParsers.GetUdfApplicationLogResponseParser)1 UdfApplicationLog (com.aliyun.oss.model.UdfApplicationLog)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 CheckedInputStream (java.util.zip.CheckedInputStream)1