Permalink
Browse files

Merge pull request #584 from gcheng/dev

Dev
  • Loading branch information...
2 parents 5878861 + b392324 commit be903950584881db1285eafc475ec705ef136b0a Albert Cheng committed Jan 7, 2013
@@ -18,6 +18,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
+import com.microsoft.windowsazure.services.core.ServiceException;
import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.core.util.MultivaluedMapImpl;
@@ -164,4 +165,9 @@ public String getVerb() {
public Object getRequestContents() {
return null;
}
+
+ @Override
+ public Object processResponse(Object rawResponse) throws ServiceException {
+ return rawResponse;
+ }
}
@@ -17,6 +17,7 @@
import javax.ws.rs.core.MultivaluedMap;
+import com.microsoft.windowsazure.services.core.ServiceException;
import com.microsoft.windowsazure.services.media.models.ListResult;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.core.util.MultivaluedMapImpl;
@@ -94,4 +95,12 @@ public DefaultListOperation(String entityUri, GenericType<ListResult<T>> respons
public GenericType<ListResult<T>> getResponseGenericType() {
return responseType;
}
+
+ /* (non-Javadoc)
+ * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#processResponse(java.lang.Object)
+ */
+ @Override
+ public Object processResponse(Object rawResponse) throws ServiceException {
+ return rawResponse;
+ }
}
@@ -35,14 +35,4 @@
*/
Object getRequestContents() throws ServiceException;
- /**
- * Post response process.
- *
- * @param rawResponse
- * the raw response
- * @return the object
- * @throws ServiceException
- * the service exception
- */
- Object processResponse(Object rawResponse) throws ServiceException;
}
@@ -48,4 +48,15 @@
* Get the MIME type that we're expecting the server to send back.
*/
public abstract MediaType getAcceptType();
+
+ /**
+ * Process response process.
+ *
+ * @param rawResponse
+ * the raw response
+ * @return the object
+ * @throws ServiceException
+ * the service exception
+ */
+ public abstract Object processResponse(Object rawResponse) throws ServiceException;
}
@@ -21,17 +21,26 @@
import javax.ws.rs.core.MediaType;
+import com.microsoft.windowsazure.services.core.ServiceException;
+
/**
* Default implementation of EntityOperation<T> to provide
* default values for common methods.
*
*/
public abstract class EntityOperationBase implements EntityOperation {
+
+ /** The uri builder. */
private final EntityUriBuilder uriBuilder;
+
+ /** The proxy data. */
private EntityProxyData proxyData;
/**
+ * Instantiates a new entity operation base.
*
+ * @param uri
+ * the uri
*/
protected EntityOperationBase(final String uri) {
this.uriBuilder = new EntityUriBuilder() {
@@ -42,6 +51,12 @@ public String getUri() {
};
}
+ /**
+ * Instantiates a new entity operation base.
+ *
+ * @param uriBuilder
+ * the uri builder
+ */
protected EntityOperationBase(EntityUriBuilder uriBuilder) {
this.uriBuilder = uriBuilder;
}
@@ -55,7 +70,7 @@ public void setProxyData(EntityProxyData proxyData) {
}
/**
- * Get the currently set proxy data
+ * Get the currently set proxy data.
*
* @return the proxy data
*/
@@ -87,14 +102,46 @@ public MediaType getAcceptType() {
return MediaType.APPLICATION_ATOM_XML_TYPE;
}
+ /* (non-Javadoc)
+ * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object)
+ */
+ @Override
+ public Object processResponse(Object rawResponse) throws ServiceException {
+ return rawResponse;
+ }
+
+ /**
+ * The Interface EntityUriBuilder.
+ */
public interface EntityUriBuilder {
+
+ /**
+ * Gets the uri.
+ *
+ * @return the uri
+ */
String getUri();
}
+ /**
+ * The Class EntityIdUriBuilder.
+ */
public static class EntityIdUriBuilder implements EntityUriBuilder {
+
+ /** The entity type. */
private final String entityType;
+
+ /** The entity id. */
private final String entityId;
+ /**
+ * Instantiates a new entity id uri builder.
+ *
+ * @param entityName
+ * the entity name
+ * @param entityId
+ * the entity id
+ */
public EntityIdUriBuilder(String entityName, String entityId) {
super();
this.entityType = entityName;
@@ -99,8 +99,7 @@ private WebResource getResource(String entityName) {
* @throws ServiceException
*/
private Builder getResource(EntityOperation operation) throws ServiceException {
- return getResource(operation.getUri()).type(operation.getContentType()).accept(
- operation.getAcceptType());
+ return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType());
}
/* (non-Javadoc)
@@ -110,30 +109,35 @@ private Builder getResource(EntityOperation operation) throws ServiceException {
@Override
public <T> T create(EntityCreateOperation<T> creator) throws ServiceException {
creator.setProxyData(createProxyData());
- Object rawResponse = getResource(creator).post(creator.getResponseClass(),
- creator.getRequestContents());
+ Object rawResponse = getResource(creator).post(creator.getResponseClass(), creator.getRequestContents());
Object processedResponse = creator.processResponse(rawResponse);
return (T) processedResponse;
}
/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation)
*/
+ @SuppressWarnings("unchecked")
@Override
public <T> T get(EntityGetOperation<T> getter) throws ServiceException {
getter.setProxyData(createProxyData());
- return getResource(getter).get(getter.getResponseClass());
+ Object rawResponse = getResource(getter).get(getter.getResponseClass());
+ Object processedResponse = getter.processResponse(rawResponse);
+ return (T) processedResponse;
}
/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation)
*/
+ @SuppressWarnings("unchecked")
@Override
public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException {
lister.setProxyData(createProxyData());
- return getResource(lister.getUri()).queryParams(lister.getQueryParameters())
- .type(lister.getContentType()).accept(lister.getAcceptType())
- .get(lister.getResponseGenericType());
+ Object rawResponse = getResource(lister.getUri()).queryParams(lister.getQueryParameters())
+ .type(lister.getContentType()).accept(lister.getAcceptType()).get(lister.getResponseGenericType());
+ Object processedResponse = lister.processResponse(rawResponse);
+ return (ListResult<T>) processedResponse;
+
}
/* (non-Javadoc)
@@ -142,10 +146,10 @@ private Builder getResource(EntityOperation operation) throws ServiceException {
@Override
public void update(EntityUpdateOperation updater) throws ServiceException {
updater.setProxyData(createProxyData());
- ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(
- ClientResponse.class, updater.getRequestContents());
-
- PipelineHelpers.ThrowIfNotSuccess(response);
+ Object rawResponse = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class,
+ updater.getRequestContents());
+ PipelineHelpers.ThrowIfNotSuccess((ClientResponse) rawResponse);
+ updater.processResponse(rawResponse);
}
/* (non-Javadoc)
@@ -165,8 +169,8 @@ public Object action(EntityActionOperation entityActionOperation) throws Service
entityActionOperation.setProxyData(createProxyData());
Builder webResource = getResource(entityActionOperation.getUri())
- .queryParams(entityActionOperation.getQueryParameters())
- .accept(entityActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE)
+ .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType())
+ .accept(MediaType.APPLICATION_XML_TYPE)
.entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE);
ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class);
return entityActionOperation.processResponse(clientResponse);
@@ -301,8 +301,8 @@ public static EntityDeleteOperation delete(String assetId) {
*
* @param assetId
* the asset id
- * @param contentKeyUri
- * the content key uri
+ * @param contentKeyId
+ * the content key id
* @return the entity action operation
*/
public static EntityLinkOperation linkContentKey(String assetId, String contentKeyId) {
@@ -57,7 +57,7 @@ public String getName() {
*
* @return the content file size
*/
- public Long getContentFileSize() {
+ public long getContentFileSize() {
return this.getContent().getContentFileSize();
}
@@ -93,7 +93,7 @@ public String getEncryptionScheme() {
*
* @return the checks if is encrypted
*/
- public Boolean getIsEncrypted() {
+ public boolean getIsEncrypted() {
return this.getContent().getIsEncrypted();
}
@@ -120,7 +120,7 @@ public String getInitializationVector() {
*
* @return the checks if is primary
*/
- public Boolean getIsPrimary() {
+ public boolean getIsPrimary() {
return this.getContent().getIsPrimary();
}
@@ -89,7 +89,7 @@ public Date getEndTime() {
*
* @return the priority
*/
- public Integer getPriority() {
+ public int getPriority() {
return getContent().getPriority();
}
@@ -98,7 +98,7 @@ public Integer getPriority() {
*
* @return the running duration
*/
- public Double getRunningDuration() {
+ public double getRunningDuration() {
return getContent().getRunningDuration();
}
@@ -45,8 +45,6 @@ private Task() {
* the media processor id
* @param taskBody
* the task body
- * @param options
- * the options
* @return the creates the batch operation
*/
public static CreateBatchOperation create(String mediaProcessorId, String taskBody) {
@@ -102,8 +100,6 @@ public static CreateBatchOperation create(String mediaProcessorId, String taskBo
* the media processor id
* @param taskBody
* the task body
- * @param options
- * the options
*/
public CreateBatchOperation(String mediaProcessorId, String taskBody) {
this.verb = "POST";
@@ -118,7 +118,7 @@ public String getPerfMessage() {
*
* @return the priority
*/
- public Integer getPriority() {
+ public int getPriority() {
return getContent().getPriority();
}
@@ -127,7 +127,7 @@ public Integer getPriority() {
*
* @return the progress
*/
- public Double getProgress() {
+ public double getProgress() {
return getContent().getProgress();
}
@@ -46,7 +46,8 @@ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual
expected.getStartTime(), expected.getEndTime(), actual);
}
- private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration,
+ @SuppressWarnings("deprecation")
+ private void verifyJobProperties(String message, String testName, Integer priority, double runningDuration,
JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime,
JobInfo actualJob) {
assertNotNull(message, actualJob);
Oops, something went wrong.

0 comments on commit be90395

Please sign in to comment.