Skip to content

Commit

Permalink
Merge pull request Azure#51 from gcheng/protectionkey
Browse files Browse the repository at this point in the history
Implement get protection key id and get protection key
  • Loading branch information
Albert Cheng committed Dec 8, 2012
2 parents 580c4b4 + 0847833 commit 56132c7
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException {
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation)
*/
@Override
public void action(EntityActionOperation action) throws ServiceException {
public Object action(EntityActionOperation action) throws ServiceException {
try {
service.action(action);
return service.action(action);
}
catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import com.sun.jersey.api.client.Client;

/**
*
*
* The Class MediaRestProxy.
*/
public class MediaRestProxy extends EntityRestProxy implements MediaContract {
/** The log. */
static Log log = LogFactory.getLog(MediaContract.class);

/** The redirect filter. */
private RedirectFilter redirectFilter;

/**
Expand Down Expand Up @@ -84,6 +84,9 @@ public MediaContract withFilter(ServiceFilter filter) {
return new MediaRestProxy(getChannel(), newFilters);
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.MediaContract#getRestServiceUri()
*/
@Override
public URI getRestServiceUri() {
return this.redirectFilter.getBaseURI();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright 2012 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.media.implementation.content;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;

/**
* This type maps the XML returned in the odata ATOM serialization
* for Asset entities.
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "GetProtectionKeyId", namespace = Constants.ODATA_DATA_NS)
public class ProtectionKeyIdType implements MediaServiceDTO {
@XmlValue
String protectionKeyId;

/**
* @return the protection key id
*/
public String getProtectionKeyId() {
return protectionKeyId;
}

/**
* @param protection
* key id
* the protection key id to set
*/
public void setProtectionKeyId(String protectionKeyId) {
this.protectionKeyId = protectionKeyId;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2012 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.media.implementation.content;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;

/**
* This type maps the XML returned in protection key.
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "GetProtectionKey", namespace = Constants.ODATA_DATA_NS)
public class ProtectionKeyRestType implements MediaServiceDTO {
@XmlValue
String protectionKey;

/**
* @return the protection key
*/
public String getProtectionKey() {
return protectionKey;
}

/**
* @param protection
* key id
* the protection key id to set
*/
public void setProtectionKey(String protectionKey) {
this.protectionKey = protectionKey;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public class DefaultActionOperation implements EntityActionOperation {
/** The name. */
private final String name;

/** The content type. */
private MediaType contentType = MediaType.APPLICATION_ATOM_XML_TYPE;

/** The accept type. */
private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE;

/** The query parameters. */
private final MultivaluedMap<String, String> queryParameters;

Expand Down Expand Up @@ -64,7 +70,7 @@ public MultivaluedMap<String, String> getQueryParameters() {
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String)
*/
@Override
public EntityActionOperation addQueryParameter(String key, String value) {
public DefaultActionOperation addQueryParameter(String key, String value) {
this.queryParameters.add(key, value);
return this;
}
Expand All @@ -74,22 +80,48 @@ public EntityActionOperation addQueryParameter(String key, String value) {
*/
@Override
public MediaType getContentType() {
return MediaType.APPLICATION_ATOM_XML_TYPE;
return this.contentType;
}

/**
* Sets the content type.
*
* @param contentType
* the content type
* @return the default action operation
*/
public DefaultActionOperation setContentType(MediaType contentType) {
this.contentType = contentType;
return this;
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType()
*/
@Override
public MediaType getAcceptType() {
return MediaType.APPLICATION_ATOM_XML_TYPE;
return this.acceptType;
}

/**
* Sets the accept type.
*
* @param acceptType
* the accept type
* @return the default action operation
*/
public DefaultActionOperation setAcceptType(MediaType acceptType) {
this.acceptType = acceptType;
return this;
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse)
*/
@Override
public void processResponse(ClientResponse clientResponse) {
public Object processResponse(ClientResponse clientResponse) {
PipelineHelpers.ThrowIfNotSuccess(clientResponse);
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface EntityActionOperation extends EntityOperation {
*
* @param clientResponse
* the client response
* @return
*/
void processResponse(ClientResponse clientResponse);
Object processResponse(ClientResponse clientResponse);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public interface EntityContract {
*
* @param action
* Object providing details of the action
* @return
* @throws ServiceException
*/
public abstract void action(EntityActionOperation action) throws ServiceException;
public abstract Object action(EntityActionOperation action) throws ServiceException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException {
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation)
*/
@Override
public void action(EntityActionOperation entityActionOperation) throws ServiceException {
ClientResponse clientResponse = getResource(entityActionOperation.getUri()).queryParams(
entityActionOperation.getQueryParameters()).get(ClientResponse.class);
entityActionOperation.processResponse(clientResponse);
public Object action(EntityActionOperation entityActionOperation) throws ServiceException {
ClientResponse clientResponse = getResource(entityActionOperation.getUri())
.queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType())
.get(ClientResponse.class);
return entityActionOperation.processResponse(clientResponse);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn
EntityCreationOperation<ContentKeyInfo> {

/** The id. */
private String id;
private final String id;

/** The content key type. */
private ContentKeyType contentKeyType;
private final ContentKeyType contentKeyType;

/** The encrypted content key. */
private String encryptedContentKey;
private final String encryptedContentKey;

/** The name. */
private String name;
Expand Down Expand Up @@ -182,4 +182,5 @@ public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, St
public static EntityDeleteOperation delete(String ContentKeyId) {
return new DefaultDeleteOperation(ENTITY_SET, ContentKeyId);
}

}
Loading

0 comments on commit 56132c7

Please sign in to comment.