use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSRequestMessageBuilder method build.
public RequestMessage build() {
Map<String, String> sentHeaders = new HashMap<String, String>(this.headers);
sentHeaders.put(OSSHeaders.DATE, DateUtil.formatRfc822Date(new Date()));
Map<String, String> sentParameters = new LinkedHashMap<String, String>(this.parameters);
RequestMessage request = new RequestMessage(this.originalRequest, this.bucket, this.key);
ClientConfiguration clientCofig = this.innerClient.getClientConfiguration();
request.setBucket(bucket);
request.setKey(key);
request.setEndpoint(determineFinalEndpoint(this.endpoint, this.bucket, clientCofig));
request.setResourcePath(determineResourcePath(this.bucket, this.key, clientCofig.isSLDEnabled()));
request.setHeaders(sentHeaders);
request.setParameters(sentParameters);
request.setMethod(this.method);
request.setContent(this.inputStream);
request.setContentLength(this.inputSize);
request.setUseChunkEncoding(this.inputSize == -1 ? true : this.useChunkEncoding);
return request;
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSUdfOperation method deleteUdfApplication.
public void deleteUdfApplication(UdfGenericRequest genericRequest) throws OSSException, ClientException {
assertParameterNotNull(genericRequest, "genericRequest");
String udfName = genericRequest.getName();
assertParameterNotNull(udfName, "udfName");
ensureBucketNameValid(udfName);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_UDF_APPLICATION, null);
params.put(RequestParameters.SUBRESOURCE_UDF_NAME, udfName);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.DELETE).setParameters(params).setOriginalRequest(genericRequest).build();
doOperation(request, emptyResponseParser, null, null, true);
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSUdfOperation method uploadUdfImage.
/**
* UDF Image
*/
public void uploadUdfImage(UploadUdfImageRequest uploadUdfImageRequest) throws OSSException, ClientException {
assertParameterNotNull(uploadUdfImageRequest, "uploadUdfImageRequest");
assertParameterNotNull(uploadUdfImageRequest.getUdfImage(), "udfImage");
assertParameterNotNull(uploadUdfImageRequest.getName(), "udfImage");
ensureBucketNameValid(uploadUdfImageRequest.getName());
InputStream repeatableInputStream = null;
try {
repeatableInputStream = newRepeatableInputStream(uploadUdfImageRequest.getUdfImage());
} catch (IOException ex) {
logException("Cannot wrap to repeatable input stream: ", ex);
throw new ClientException("Cannot wrap to repeatable input stream: ", ex);
}
Map<String, String> headers = new HashMap<String, String>();
Map<String, String> params = new LinkedHashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_UDF_IMAGE, null);
params.put(RequestParameters.SUBRESOURCE_UDF_NAME, uploadUdfImageRequest.getName());
if (uploadUdfImageRequest.getUdfImageDesc() != null) {
params.put(RequestParameters.SUBRESOURCE_UDF_IMAGE_DESC, uploadUdfImageRequest.getUdfImageDesc());
}
RequestMessage httpRequest = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.POST).setHeaders(headers).setParameters(params).setInputStream(repeatableInputStream).setInputSize(determineInputStreamLength(repeatableInputStream, 0)).setOriginalRequest(uploadUdfImageRequest).build();
ProgressListener listener = uploadUdfImageRequest.getProgressListener();
try {
publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
doOperation(httpRequest, emptyResponseParser, null, null, true);
publishProgress(listener, ProgressEventType.TRANSFER_COMPLETED_EVENT);
} catch (RuntimeException e) {
publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
throw e;
}
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSUdfOperation method createUdf.
/**
* UDF
*/
public void createUdf(CreateUdfRequest createUdfRequest) throws OSSException, ClientException {
assertParameterNotNull(createUdfRequest, "createUdfRequest");
assertParameterNotNull(createUdfRequest.getName(), "createUdfRequest.name");
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_UDF, null);
byte[] rawContent = RequestMarshallers.createUdfRequestMarshaller.marshall(createUdfRequest);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.POST).setParameters(params).setInputSize(rawContent.length).setInputStream(new ByteArrayInputStream(rawContent)).setOriginalRequest(createUdfRequest).build();
doOperation(request, emptyResponseParser, null, null);
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSUdfOperation method getUdfInfo.
public UdfInfo getUdfInfo(UdfGenericRequest genericRequest) throws OSSException, ClientException {
assertParameterNotNull(genericRequest, "genericRequest");
String udfName = genericRequest.getName();
assertParameterNotNull(udfName, "udfName");
ensureBucketNameValid(udfName);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_UDF, null);
params.put(RequestParameters.SUBRESOURCE_UDF_NAME, udfName);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setParameters(params).setOriginalRequest(genericRequest).build();
return doOperation(request, ResponseParsers.getUdfInfoResponseParser, null, null, true);
}
Aggregations