Skip to content

Commit

Permalink
Merge pull request Azure#44 from gcheng/locatorupdate
Browse files Browse the repository at this point in the history
update locator
  • Loading branch information
Albert Cheng committed Nov 28, 2012
2 parents 45f7de0 + 04e6b9d commit 3c0f31d
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public class LocatorRestType implements MediaServiceDTO {
@XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS)
protected Date startTime;

/** The base uri. */
@XmlElement(name = "BaseUri", namespace = Constants.ODATA_DATA_NS)
private String baseUri;

/** The content access component. */
@XmlElement(name = "ContentAccessComponent", namespace = Constants.ODATA_DATA_NS)
private String contentAccessComponent;

/**
* Gets the id.
*
Expand Down Expand Up @@ -119,15 +127,6 @@ public LocatorRestType setType(int type) {
return this;
}

/**
* Gets the path.
*
* @return the path
*/
public String getPath() {
return this.path;
}

/**
* Gets the access policy id.
*
Expand Down Expand Up @@ -191,6 +190,15 @@ public LocatorRestType setStartTime(Date startTime) {
return this;
}

/**
* Gets the path.
*
* @return the path
*/
public String getPath() {
return this.path;
}

/**
* Sets the path.
*
Expand All @@ -202,4 +210,46 @@ public LocatorRestType setPath(String path) {
this.path = path;
return this;
}

/**
* Gets the base uri.
*
* @return the base uri
*/
public String getBaseUri() {
return this.baseUri;
}

/**
* Sets the base uri.
*
* @param baseUri
* the base uri
* @return the locator rest type
*/
public LocatorRestType setBaseUri(String baseUri) {
this.baseUri = baseUri;
return this;
}

/**
* Gets the content access component.
*
* @return the content access component
*/
public String getContentAccessComponent() {
return this.contentAccessComponent;
}

/**
* Sets the content access component.
*
* @param contentAccessComponent
* the content access component
* @return the locator rest type
*/
public LocatorRestType setContentAccessComponent(String contentAccessComponent) {
this.contentAccessComponent = contentAccessComponent;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,23 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation;
import com.sun.jersey.api.client.GenericType;

// TODO: Auto-generated Javadoc
/**
* Implementation of Locator entity
*
* Implementation of Locator entity.
*/
public class Locator {

/** The Constant ENTITY_SET. */
private final static String ENTITY_SET = "Locators";

/**
* Instantiates a new locator.
*/
private Locator() {
}

/**
* Create an operation to create a new locator entity
* Create an operation to create a new locator entity.
*
* @param accessPolicyId
* id of access policy for locator
Expand All @@ -57,30 +61,90 @@ public static Creator create(String accessPolicyId, String assetId, LocatorType
return new Creator(accessPolicyId, assetId, locatorType);
}

/**
* The Class Creator.
*/
public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements
EntityCreationOperation<LocatorInfo> {

/** The access policy id. */
private final String accessPolicyId;

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

/** The base uri. */
private String baseUri;

/** The content access token. */
private String contentAccessComponent;

/** The expiration date time. */
private Date expirationDateTime;

/** The locator type. */
private final LocatorType locatorType;

/** The path. */
private String path;

/** The start date time. */
private Date startDateTime;
private Date expirationDateTime;

/**
* Instantiates a new creator.
*
* @param accessPolicyId
* the access policy id
* @param assetId
* the asset id
* @param locatorType
* the locator type
*/
protected Creator(String accessPolicyId, String assetId, LocatorType locatorType) {
super(ENTITY_SET, LocatorInfo.class);
this.accessPolicyId = accessPolicyId;
this.assetId = assetId;
this.locatorType = locatorType;
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents()
*/
@Override
public Object getRequestContents() {
return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId)
.setStartTime(startDateTime).setExpirationDateTime(expirationDateTime)
.setType(locatorType.getCode());
.setType(locatorType.getCode()).setBaseUri(baseUri)
.setContentAccessComponent(contentAccessComponent).setPath(path);
}

/**
* Set the date and time for when the locator starts to be available
* Sets the base uri.
*
* @param baseUri
* the base uri
* @return the creator
*/
public Creator setBaseUri(String baseUri) {
this.baseUri = baseUri;
return this;
}

/**
* Sets the path.
*
* @param path
* the path
* @return the creator
*/
public Creator setPath(String path) {
this.path = path;
return this;
}

/**
* Set the date and time for when the locator starts to be available.
*
* @param startDateTime
* The date/time
Expand All @@ -92,7 +156,7 @@ public Creator setStartDateTime(Date startDateTime) {
}

/**
* Set the date and time at which the locator will expire
* Set the date and time at which the locator will expire.
*
* @param expirationDateTime
* Expiration date and time
Expand All @@ -102,10 +166,21 @@ public Creator setExpirationDateTime(Date expirationDateTime) {
this.expirationDateTime = expirationDateTime;
return this;
}

/**
* Sets the content access component.
*
* @param contentAccessComponent
* @return The creator instance
*/
public Creator setContentAccessComponent(String contentAccessComponent) {
this.contentAccessComponent = contentAccessComponent;
return this;
}
}

/**
* Create an operation to get the given locator
* Create an operation to get the given locator.
*
* @param locatorId
* id of locator to retrieve
Expand All @@ -116,7 +191,7 @@ public static EntityGetOperation<LocatorInfo> get(String locatorId) {
}

/**
* Create an operation to list all locators
* Create an operation to list all locators.
*
* @return the list operation
*/
Expand All @@ -126,7 +201,7 @@ public static EntityListOperation<LocatorInfo> list() {
}

/**
* Create an operation to list all locators matching the given query parameters
* Create an operation to list all locators matching the given query parameters.
*
* @param queryParameters
* query parameters to send with the request
Expand All @@ -138,7 +213,7 @@ public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, Strin
}

/**
* Create an operation to update the given locator
* Create an operation to update the given locator.
*
* @param locatorId
* id of locator to update
Expand All @@ -148,21 +223,37 @@ public static Updater update(String locatorId) {
return new Updater(locatorId);
}

/**
* The Class Updater.
*/
public static class Updater extends EntityOperationBase implements EntityUpdateOperation {

/** The start date time. */
private Date startDateTime;

/** The expiration date time. */
private Date expirationDateTime;

/**
* Instantiates a new updater.
*
* @param locatorId
* the locator id
*/
public Updater(String locatorId) {
super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId));
}

/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents()
*/
@Override
public Object getRequestContents() {
return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime);
}

/**
* Set when the locator will become available
* Set when the locator will become available.
*
* @param startDateTime
* the date & time
Expand All @@ -174,7 +265,7 @@ public Updater setStartDateTime(Date startDateTime) {
}

/**
* Set when the locator will expire
* Set when the locator will expire.
*
* @param expirationDateTime
* the expiration date & time
Expand All @@ -188,7 +279,7 @@ public Updater setExpirationDateTime(Date expirationDateTime) {
}

/**
* Create an operation to delete the given locator
* Create an operation to delete the given locator.
*
* @param locatorId
* id of locator to delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,46 @@ public Date getStartTime() {
return getContent().getStartTime();
}

/**
* Gets the base uri.
*
* @return the base uri
*/
public String getBaseUri() {
return getContent().getBaseUri();
}

/**
* Sets the base uri.
*
* @param baseUri
* the base uri
* @return the locator info
*/
public LocatorInfo setBaseUri(String baseUri) {
this.getContent().setBaseUri(baseUri);
return this;
}

/**
* Sets the content access component.
*
* @param contentAccessComponent
* the content access component
* @return the locator info
*/
public LocatorInfo setContentAccessComponent(String contentAccessComponent) {
this.getContent().setContentAccessComponent(contentAccessComponent);
return this;
}

/**
* Gets the content access token.
*
* @return the content access token
*/
public String getContentAccessToken() {
return this.getContent().getContentAccessComponent();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public enum LocatorType {
SAS(1),
/** The Origin. */
Origin(2),
/** The Windows azure cdn. */
WindowsAzureCDN(3);
/** The third party locator. */
ThirdParty(3);

/** The locator type code. */
private int locatorTypeCode;
Expand Down Expand Up @@ -69,7 +69,7 @@ public static LocatorType fromCode(int type) {
case 2:
return LocatorType.Origin;
case 3:
return LocatorType.WindowsAzureCDN;
return LocatorType.ThirdParty;
default:
throw new InvalidParameterException("type");
}
Expand Down
Loading

0 comments on commit 3c0f31d

Please sign in to comment.