Skip to content

Commit

Permalink
Merge pull request #211 from jcookems/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jcookems committed Jan 23, 2013
2 parents 8cf7681 + c3a60fb commit 64b3938
Show file tree
Hide file tree
Showing 31 changed files with 113 additions and 114 deletions.
6 changes: 5 additions & 1 deletion microsoft-azure-api/src/config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@

<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MagicNumber">
<!-- Updated on 01/23/2013: -->
<!-- Added ignore list, to keep enums from triggering violations -->
<property name="ignoreNumbers" value="0, 1, 2, 3, 4, 5, 6, 7, 8"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>LeaseState</code> object.
*/
public void setLeaseState(final LeaseState leaseState) {
Expand All @@ -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 <code>LeaseDuration</code> object.
*/
public void setLeaseDuration(final LeaseDuration leaseDuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>LeaseState</code> object.
*/
public void setLeaseState(final LeaseState leaseState) {
Expand All @@ -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 <code>LeaseDuration</code> object.
*/
public void setLeaseDuration(final LeaseDuration leaseDuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1468,10 +1468,6 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
* signature.
* @param groupPolicyIdentifier
* A <code>String</code> 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 <code>String</code> that represents the shared access signature.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}.
* <p>
* See the <a href="http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx">Put Blob</a> documentation on
* MSDN for details of the underlying Blob Service REST API operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
public class MediaConfiguration {

private MediaConfiguration() {
}

/**
* Defines the media service configuration URI constant.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface EntityContract {
* the service exception
* The created entity
*/
public abstract <T> T create(EntityCreateOperation<T> creator) throws ServiceException;
<T> T create(EntityCreateOperation<T> creator) throws ServiceException;

/**
* Retrieve an existing entity by id.
Expand All @@ -51,7 +51,7 @@ public interface EntityContract {
* @throws ServiceException
* the service exception
*/
public abstract <T> T get(EntityGetOperation<T> getter) throws ServiceException;
<T> T get(EntityGetOperation<T> getter) throws ServiceException;

/**
* Retrieve a list of entities.
Expand All @@ -64,7 +64,7 @@ public interface EntityContract {
* @throws ServiceException
* the service exception
*/
public abstract <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException;
<T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException;

/**
* Update an existing entity.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -107,6 +107,6 @@ public interface EntityContract {
* @throws ServiceException
* the service exception
*/
public abstract <T> T action(EntityTypeActionOperation<T> entityActionOperation) throws ServiceException;
<T> T action(EntityTypeActionOperation<T> entityActionOperation) throws ServiceException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@ 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.
*
* @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.
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public interface EntityOperationSingleResult<T> extends EntityOperation {
*
* @return Class object for response.
*/
public abstract Class<T> getResponseClass();
Class<T> getResponseClass();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityBatchOperation> entityBatchOperations;

Expand Down Expand Up @@ -138,7 +142,7 @@ private List<DataSource> createRequestBody() throws JAXBException {
*/
private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int contentId) throws JAXBException {
int jobContentId = contentId;
ValidateJobOperation();
validateJobOperation();

for (EntityBatchOperation entityBatchOperation : entityBatchOperations) {
DataSource bodyPartContent = null;
Expand All @@ -157,7 +161,7 @@ private int addJobPart(List<DataSource> 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) {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,8 +55,7 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati

@Override
public T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException,
WebApplicationException {
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
throw new UnsupportedOperationException();
}

Expand All @@ -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<String, Object> httpHeaders, OutputStream entityStream) throws IOException,
WebApplicationException {
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
try {
marshaller.marshalEntry(t, entityStream);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 64b3938

Please sign in to comment.