diff --git a/microsoft-azure-api/src/config/checkstyle.xml b/microsoft-azure-api/src/config/checkstyle.xml index 287b61490dd39..58a40f4ac43a8 100644 --- a/microsoft-azure-api/src/config/checkstyle.xml +++ b/microsoft-azure-api/src/config/checkstyle.xml @@ -195,7 +195,11 @@ - + + + + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java index 2b781912d584b..516183818f699 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java @@ -131,7 +131,7 @@ public void setLeaseStatus(final LeaseStatus leaseStatus) { /** * Sets the lease status on the container. Reserved for internal use. * - * @param LeaseState + * @param leaseState * The lease state to set, as a LeaseState object. */ public void setLeaseState(final LeaseState leaseState) { @@ -141,7 +141,7 @@ public void setLeaseState(final LeaseState leaseState) { /** * Sets the lease duration on the container. Reserved for internal use. * - * @param LeaseDuration + * @param leaseDuration * The lease duration to set, as a LeaseDuration object. */ public void setLeaseDuration(final LeaseDuration leaseDuration) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java index 9fc4475b052da..0eaff8e5789a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -334,7 +334,7 @@ public void setLeaseStatus(final LeaseStatus leaseStatus) { /** * Sets the lease state for the blob. Reserved for internal use. * - * @param LeaseState + * @param leaseState * The lease state to set, represented by a LeaseState object. */ public void setLeaseState(final LeaseState leaseState) { @@ -344,7 +344,7 @@ public void setLeaseState(final LeaseState leaseState) { /** * Sets the lease duration for the blob. Reserved for internal use. * - * @param LeaseDuration + * @param leaseDuration * The lease duration value to set, represented by a LeaseDuration object. */ public void setLeaseDuration(final LeaseDuration leaseDuration) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 49ae8c7366fa7..585c5cb8da14d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -1247,7 +1247,7 @@ public final void downloadRange(final long offset, final int length, final byte[ * the number of bytes to read * @param buffer * the byte buffer to write to. - * @param bufferOffet + * @param bufferOffset * the offset in the byte buffer to begin writing. * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the blob. @@ -1468,10 +1468,6 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { * signature. * @param groupPolicyIdentifier * A String that represents the container-level access policy. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. * * @return A String that represents the shared access signature. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java index 9be65bdcb88f6..f798b48382329 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java @@ -149,10 +149,6 @@ public static UriQueryBuilder generateSharedAccessSignature(final SharedAccessQu /** * Get the complete query builder for creating the Shared Access Signature query. * - * @param policy - * The shared access policy to hash. - * @param groupPolicyIdentifier - * An optional identifier for the policy. * @param signature * The signature to use. * @return The finished query builder @@ -285,7 +281,7 @@ public static String generateSharedAccessSignatureHash(final SharedAccessBlobPol * * @param policy * The shared access policy to hash. - * @param groupPolicyIdentifier + * @param accessPolicyIdentifier * An optional identifier for the policy. * @param resourceName * the resource name. @@ -356,7 +352,7 @@ public static String generateSharedAccessSignatureHash(final String permissions, * * @param policy * The shared access policy to hash. - * @param groupPolicyIdentifier + * @param accessPolicyIdentifier * An optional identifier for the policy. * @param resourceName * the resource name. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java index 644f5e7b4718f..44e3e63090b45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java @@ -20,7 +20,7 @@ /** * Represents the options that may be set on a - * {@link BlobContract#createPageBlob(String, String, int, CreateBlobOptions) createPageBlob} or + * {@link BlobContract#createPageBlob(String, String, long, CreateBlobOptions) createPageBlob} or * {@link BlobContract#createBlockBlob(String, String, java.io.InputStream, CreateBlobOptions) createBlockBlob} request. * These options include an optional server timeout for the operation, the MIME content type and content encoding for * the blob, the content language, the MD5 hash, a cache control value, blob metadata, a blob lease ID, a sequence diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java index 6181e7c7278f7..57a4c0faebce1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java @@ -21,7 +21,7 @@ /** * A wrapper class for the response returned from a Blob Service REST API Create Blob operation. This is returned by * calls to implementations of {@link BlobContract#createPageBlob(String, String, long, CreateBlobOptions)} and - * {@link BlobContract#createBlockBlob(String, String, long, CreateBlobOptions)}. + * {@link BlobContract#createBlockBlob(String, String, java.io.InputStream, CreateBlobOptions)}. *

* See the Put Blob documentation on * MSDN for details of the underlying Blob Service REST API operation. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index f25537df87f46..e85fd9803b60c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -22,6 +22,9 @@ */ public class MediaConfiguration { + private MediaConfiguration() { + } + /** * Defines the media service configuration URI constant. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java index d42fcdc14d30a..67c539bfe63ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java @@ -38,7 +38,7 @@ public interface EntityContract { * the service exception * The created entity */ - public abstract T create(EntityCreateOperation creator) throws ServiceException; + T create(EntityCreateOperation creator) throws ServiceException; /** * Retrieve an existing entity by id. @@ -51,7 +51,7 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract T get(EntityGetOperation getter) throws ServiceException; + T get(EntityGetOperation getter) throws ServiceException; /** * Retrieve a list of entities. @@ -64,7 +64,7 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract ListResult list(EntityListOperation lister) throws ServiceException; + ListResult list(EntityListOperation lister) throws ServiceException; /** * Update an existing entity. @@ -74,7 +74,7 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract void update(EntityUpdateOperation updater) throws ServiceException; + void update(EntityUpdateOperation updater) throws ServiceException; /** * Delete an entity. @@ -84,7 +84,7 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract void delete(EntityDeleteOperation deleter) throws ServiceException; + void delete(EntityDeleteOperation deleter) throws ServiceException; /** * Perform an action on an entity. @@ -94,7 +94,7 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract void action(EntityActionOperation action) throws ServiceException; + void action(EntityActionOperation action) throws ServiceException; /** * Action. @@ -107,6 +107,6 @@ public interface EntityContract { * @throws ServiceException * the service exception */ - public abstract T action(EntityTypeActionOperation entityActionOperation) throws ServiceException; + T action(EntityTypeActionOperation entityActionOperation) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java index 6ac4b38c6f08f..4317bd39f08d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java @@ -25,16 +25,15 @@ public interface EntityOperation { * Supplies the current proxy information to the action. * * @param proxyData - * @return */ - public void setProxyData(EntityProxyData proxyData); + void setProxyData(EntityProxyData proxyData); /** * Get the URI the creation request should be sent to. * * @return The uri */ - public abstract String getUri(); + String getUri(); /** * Get the MIME type for the content that's being sent to the server. @@ -42,12 +41,12 @@ public interface EntityOperation { * @return The MIME type * @throws ServiceException */ - public abstract MediaType getContentType(); + MediaType getContentType(); /** * Get the MIME type that we're expecting the server to send back. */ - public abstract MediaType getAcceptType(); + MediaType getAcceptType(); /** * Process response process. @@ -58,5 +57,5 @@ public interface EntityOperation { * @throws ServiceException * the service exception */ - public abstract Object processResponse(Object rawResponse) throws ServiceException; + Object processResponse(Object rawResponse) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java index f3eeb0141d637..67586641b5f8b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java @@ -22,5 +22,5 @@ public interface EntityOperationSingleResult extends EntityOperation { * * @return Class object for response. */ - public abstract Class getResponseClass(); + Class getResponseClass(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 85a9dce36971b..f3798aed41e2b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -61,6 +61,10 @@ */ public class MediaBatchOperations { + private static final int BUFFER_SIZE = 1024; + + private static final int HTTP_ERROR = 400; + /** The operations. */ private final List entityBatchOperations; @@ -138,7 +142,7 @@ private List createRequestBody() throws JAXBException { */ private int addJobPart(List bodyPartContents, URI jobURI, int contentId) throws JAXBException { int jobContentId = contentId; - ValidateJobOperation(); + validateJobOperation(); for (EntityBatchOperation entityBatchOperation : entityBatchOperations) { DataSource bodyPartContent = null; @@ -157,7 +161,7 @@ private int addJobPart(List bodyPartContents, URI jobURI, int conten return jobContentId; } - private void ValidateJobOperation() { + private void validateJobOperation() { int jobCount = 0; for (EntityBatchOperation entityBatchOperation : entityBatchOperations) { if (entityBatchOperation instanceof Job.CreateBatchOperation) { @@ -324,7 +328,7 @@ public void parseBatchResult(ClientResponse response) throws IOException, Servic InternetHeaders headers = parseHeaders(ds); InputStream content = parseEntity(ds); - if (status.getStatus() >= 400) { + if (status.getStatus() >= HTTP_ERROR) { InBoundHeaders inBoundHeaders = new InBoundHeaders(); @SuppressWarnings("unchecked") @@ -520,11 +524,12 @@ private void appendHeaders(OutputStream outputStream, InternetHeaders internetHe */ private void appendEntity(OutputStream outputStream, ByteArrayInputStream byteArrayInputStream) { try { - byte[] buffer = new byte[1024]; + byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int bytesRead = byteArrayInputStream.read(buffer); - if (bytesRead <= 0) + if (bytesRead <= 0) { break; + } outputStream.write(buffer, 0, bytesRead); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java index 9e04edf56d038..eae063529e67d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -21,7 +21,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; @@ -56,8 +55,7 @@ public boolean isReadable(Class type, Type genericType, Annotation[] annotati @Override public T readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, - WebApplicationException { + MultivaluedMap httpHeaders, InputStream entityStream) throws IOException { throw new UnsupportedOperationException(); } @@ -68,8 +66,7 @@ public boolean isWriteable(Class type, Type genericType, Annotation[] annotat @Override public void writeTo(T t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException, - WebApplicationException { + MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException { try { marshaller.marshalEntry(t, entityStream); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java index ef2982aa2c170..603e9b0caeb11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java @@ -38,7 +38,7 @@ public interface OAuthContract { * @return OAuthTokenResponse * @throws ServiceException */ - public OAuthTokenResponse getAccessToken(URI oAuthUri, String clientId, String clientSecret, String scope) + OAuthTokenResponse getAccessToken(URI oAuthUri, String clientId, String clientSecret, String scope) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index 81d50e6a6bfc4..dff2e042c7714 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -41,7 +41,7 @@ public OAuthFilter(OAuthTokenManager oAuthTokenManager) { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */@Override - public ClientResponse doHandle(ClientRequest clientRequest) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest clientRequest) { String accessToken; try { accessToken = oAuthTokenManager.getAccessToken(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index ecf179072bc59..be98df7af3807 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -41,7 +41,7 @@ public class OAuthRestProxy implements OAuthContract { Client channel; - private final String _grantType = "client_credentials"; + private final String grantType = "client_credentials"; static Log log = LogFactory.getLog(OAuthContract.class); @@ -76,7 +76,7 @@ public OAuthTokenResponse getAccessToken(URI oAuthUri, String clientId, String c ClientResponse clientResponse; String responseJson; - requestForm.add("grant_type", _grantType); + requestForm.add("grant_type", grantType); requestForm.add("client_id", clientId); requestForm.add("client_secret", clientSecret); requestForm.add("scope", scope); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index bc8d3622e0688..1a124d4dd6626 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -23,10 +23,10 @@ */ public class OAuthTokenResponse { - private String _accessToken; - private String _scope; - private String _tokenType; - private long _expiresIn; + private String accessToken; + private String scope; + private String tokenType; + private long expiresIn; /** * Sets the token type. @@ -35,41 +35,41 @@ public class OAuthTokenResponse { */ @JsonProperty("token_type") public void setTokenType(String tokenType) { - _tokenType = tokenType; + this.tokenType = tokenType; } @JsonProperty("token_type") public String getTokenType() { - return _tokenType; + return tokenType; } @JsonProperty("expires_in") public long getExpiresIn() { - return _expiresIn; + return expiresIn; } @JsonProperty("expires_in") public void setExpiresIn(long expiresIn) { - _expiresIn = expiresIn; + this.expiresIn = expiresIn; } @JsonProperty("access_token") public String getAccessToken() { - return _accessToken; + return accessToken; } @JsonProperty("access_token") public void setAccessToken(String accessToken) { - _accessToken = accessToken; + this.accessToken = accessToken; } @JsonProperty("scope") public String getScope() { - return _scope; + return scope; } @JsonProperty("scope") public void setScope(String scope) { - _scope = scope; + this.scope = scope; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java index c09aa98d873dc..a23d7a712ddac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java @@ -30,14 +30,14 @@ */ public class ODataDateAdapter extends XmlAdapter { - private final static Pattern hasTimezoneRegex; - private final static TimeZone utc; + private static final Pattern HAS_TIMEZONE_REGEX; + private static final TimeZone UTC; static { - hasTimezoneRegex = Pattern.compile("^.*(\\+|-)\\d\\d:\\d\\d$"); + HAS_TIMEZONE_REGEX = Pattern.compile("^.*(\\+|-)\\d\\d:\\d\\d$"); - utc = TimeZone.getDefault(); - utc.setRawOffset(0); + UTC = TimeZone.getDefault(); + UTC.setRawOffset(0); } @Override @@ -53,11 +53,11 @@ public Date unmarshal(String dateString) throws Exception { public String marshal(Date date) throws Exception { Calendar dateToMarshal = Calendar.getInstance(); dateToMarshal.setTime(date); - dateToMarshal.setTimeZone(utc); + dateToMarshal.setTimeZone(UTC); return DatatypeConverter.printDateTime(dateToMarshal); } private boolean hasTimezone(String dateString) { - return dateString.endsWith("Z") || hasTimezoneRegex.matcher(dateString).matches(); + return dateString.endsWith("Z") || HAS_TIMEZONE_REGEX.matcher(dateString).matches(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index c89f3453c89d8..65765129905bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -89,7 +89,7 @@ public boolean hasLink(String rel) { public > LinkInfo getLink(String rel) { for (Object child : entry.getEntryChildren()) { - LinkType link = LinkFromChild(child); + LinkType link = linkFromChild(child); if (link != null && link.getRel().equals(rel)) { return new LinkInfo(link); } @@ -109,14 +109,14 @@ public > LinkInfo getRelationLink(String relationNam } @SuppressWarnings("rawtypes") - private static LinkType LinkFromChild(Object child) { + private static LinkType linkFromChild(Object child) { if (child instanceof JAXBElement) { - return LinkFromElement((JAXBElement) child); + return linkFromElement((JAXBElement) child); } return null; } - private static LinkType LinkFromElement(@SuppressWarnings("rawtypes") JAXBElement element) { + private static LinkType linkFromElement(@SuppressWarnings("rawtypes") JAXBElement element) { if (element.getDeclaredType() == LinkType.class) { return (LinkType) element.getValue(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java index 5b04e13ce4e77..1a63e2f3c99e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -21,7 +21,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; @@ -50,7 +49,7 @@ public boolean isReadable(Class type, Type genericType, Annotation[] annotati @Override public ListResult> readFrom(Class>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, - InputStream entityStream) throws IOException, WebApplicationException { + InputStream entityStream) throws IOException { String responseType = mediaType.getParameters().get("type"); try { @@ -89,7 +88,7 @@ public boolean isWriteable(Class type, Type genericType, Annotation[] annotat @Override public void writeTo(ListResult> t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) - throws IOException, WebApplicationException { + throws IOException { throw new UnsupportedOperationException(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 0a21506085605..c879f1e5ee947 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -22,7 +22,6 @@ import java.lang.reflect.Type; import java.util.List; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; @@ -57,7 +56,7 @@ public boolean isReadable(Class type, Type genericType, Annotation[] annotati @Override public ODataEntity readFrom(Class> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { + throws IOException { ODataEntity result = null; String responseType = mediaType.getParameters().get("type"); @@ -97,7 +96,7 @@ public boolean isWriteable(Class type, Type genericType, Annotation[] annotat @Override public void writeTo(ODataEntity t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) - throws IOException, WebApplicationException { + throws IOException { throw new UnsupportedOperationException(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 433e5ec7e6e89..6efebe7453d9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -34,7 +34,7 @@ public RedirectFilter(ResourceLocationManager locationManager) { * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */ @Override - public ClientResponse doHandle(ClientRequest request) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest request) { if (request == null) { throw new IllegalArgumentException("Request should not be null"); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index f5c3ef493a686..400b304a07d6c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -15,12 +15,9 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.net.URISyntaxException; - import javax.ws.rs.core.UriBuilder; import com.microsoft.windowsazure.services.core.IdempotentClientFilter; -import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -37,7 +34,6 @@ public class SASTokenFilter extends IdempotentClientFilter { * * @param sasUrl * URL containing authentication information - * @throws URISyntaxException */ public SASTokenFilter(String sasToken) { this.sasToken = sasToken; @@ -47,7 +43,7 @@ public SASTokenFilter(String sasToken) { * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */ @Override - public ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest cr) { UriBuilder newUri = UriBuilder.fromUri(cr.getURI()); String currentQuery = cr.getURI().getRawQuery(); if (currentQuery == null) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index d3fabaa0c4606..70be929297edc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -24,6 +24,7 @@ import com.sun.mail.util.LineInputStream; public class StatusLine { + private static final int DELIMITER = -1; private int status; private String reason; @@ -37,7 +38,7 @@ public static StatusLine create(DataSource dataSource) { expect(lineReader, "HTTP/1.1"); expect(lineReader, " "); String statusString = extractInput(lineReader, ' '); - String reason = extractInput(lineReader, -1); + String reason = extractInput(lineReader, DELIMITER); return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); } @@ -72,8 +73,9 @@ private static String extractInput(Reader reader, int delimiter) { StringBuilder sb = new StringBuilder(); while (true) { int ch = reader.read(); - if (ch == -1 || ch == delimiter) + if (ch == DELIMITER || ch == delimiter) { break; + } sb.append((char) ch); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index d21e3852162c4..84b1a670a763a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -18,7 +18,6 @@ import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.core.IdempotentClientFilter; -import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -33,7 +32,7 @@ public class VersionHeadersFilter extends IdempotentClientFilter { * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */ @Override - public ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest cr) { MultivaluedMap headers = cr.getHeaders(); headers.add("DataServiceVersion", "3.0"); headers.add("MaxDataServiceVersion", "3.0"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java index b713aedf0961d..a6e75b29512a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java @@ -23,7 +23,11 @@ * media services entities. */ -public class Constants { +public final class Constants { + + private Constants() { + } + /** * XML Namespace for Atom syndication format, as defined by IETF RFC 4287 */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 4d93a5e773567..fea8d2ba62e2b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -172,7 +172,7 @@ public Creator setProtectionKeyType(ProtectionKeyType protectionKeyType) { /** * Create an operation that will retrieve the given content key. * - * @param ContentKeyId + * @param contentKeyId * id of content key to retrieve * @return the operation */ @@ -205,7 +205,7 @@ public static DefaultListOperation list(LinkInfo /** * Create an operation to delete the given content key. * - * @param ContentKeyId + * @param contentKeyId * id of content key to delete * @return the delete operation */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index 7b9a6bb15d1c5..5ec69e13bf6aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -37,6 +37,9 @@ */ public class ProtectionKey { + private ProtectionKey() { + } + /** * Gets the protection key id. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java index cd6b9085b4de7..77ffca21efd7b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java @@ -75,7 +75,7 @@ public static EnumSet permissionsFromString(final * A {@link SharedAccessQueuePermissions} object that represents the shared access permissions. * * @return A String that represents the shared access permissions in the "rwdl" format, which is - * described at {@link SharedAccessQueuePermissions#permissionsFromString}. + * described at {@link SharedAccessQueuePolicy#permissionsFromString(String)}. */ public static String permissionsToString(final EnumSet permissions) { if (permissions == null) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java index fbeb55dae5be7..4bca919332cac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java @@ -75,7 +75,7 @@ public static EnumSet permissionsFromString(final * A set of {@link SharedAccessTablePermissions} objects that represent the shared access permissions. * * @return A String that represents the shared access permissions in the "rwdl" format, which is - * described at {@link SharedAccessTablePermissions#permissionsFromString}. + * described at {@link SharedAccessTablePolicy#permissionsFromString(String)}. */ public static String permissionsToString(final EnumSet permissions) { if (permissions == null) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java index 485c239890a33..bef37b00a2733 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java @@ -48,6 +48,8 @@ import com.microsoft.windowsazure.services.table.models.QueryTablesResult; import com.microsoft.windowsazure.services.table.models.ServiceProperties; import com.microsoft.windowsazure.services.table.models.TableEntry; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; public class TableServiceIntegrationTest extends IntegrationTestBase { private static final String testTablesPrefix = "sdktest"; @@ -74,13 +76,14 @@ public static void setup() throws Exception { // Setup container names array (list of container names used by // integration tests) testTables = new String[10]; + int uniqueId = (new java.util.Random()).nextInt(100000); for (int i = 0; i < testTables.length; i++) { - testTables[i] = String.format("%s%d", testTablesPrefix, i + 1); + testTables[i] = String.format("%s%d%d", testTablesPrefix, uniqueId, i + 1); } creatableTables = new String[10]; for (int i = 0; i < creatableTables.length; i++) { - creatableTables[i] = String.format("%s%d", createableTablesPrefix, i + 1); + creatableTables[i] = String.format("%s%d%d", createableTablesPrefix, uniqueId, i + 1); } TEST_TABLE_1 = testTables[0]; @@ -100,8 +103,6 @@ public static void setup() throws Exception { Configuration config = createConfiguration(); TableContract service = TableService.create(config); - deleteAllTables(service, testTables); - deleteAllTables(service, creatableTables); createTables(service, testTablesPrefix, testTables); } @@ -135,17 +136,6 @@ private static void deleteTables(TableContract service, String prefix, String[] } } - private static void deleteAllTables(TableContract service, String[] list) throws Exception { - for (String item : list) { - try { - service.deleteTable(item); - } - catch (ServiceException e) { - // Ignore - } - } - } - private static Set queryTables(TableContract service, String prefix) throws Exception { HashSet result = new HashSet(); QueryTablesResult list = service.queryTables(new QueryTablesOptions().setPrefix(prefix)); @@ -1201,16 +1191,23 @@ public void settingTimeoutPrefixedFromConfigWorks() throws Exception { TableContract service = TableService.create("testprefix", config); - try { - service.queryTables(); - fail("Exception should have been thrown"); - } - catch (ServiceTimeoutException ex) { - // No need to assert, test is if correct assertion type is thrown. - } - catch (Exception ex) { - fail("unexpected exception was thrown"); + // Use reflection to pull the state out of the service. + Client channel = (Client) readField(service, "service", "channel"); + Integer connTimeout = (Integer) channel.getProperties().get(ClientConfig.PROPERTY_CONNECT_TIMEOUT); + Integer readTimeout = (Integer) channel.getProperties().get(ClientConfig.PROPERTY_READ_TIMEOUT); + + assertEquals(3, connTimeout.intValue()); + assertEquals(7, readTimeout.intValue()); + } + + private Object readField(Object target, String... fieldNames) throws NoSuchFieldException, IllegalAccessException { + Object value = target; + for (String fieldName : fieldNames) { + java.lang.reflect.Field field = value.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + value = field.get(value); } + return value; } @Test