Skip to content

Commit

Permalink
Merge pull request #93 from justinyu/IaaS1
Browse files Browse the repository at this point in the history
IaaS change
  • Loading branch information
mohitsriv committed Jun 12, 2012
2 parents 959985d + 7da0b19 commit 3f94f2d
Show file tree
Hide file tree
Showing 56 changed files with 7,209 additions and 1,303 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* Copyright 2011 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.blob.client;

import java.io.InputStream;
import java.text.ParseException;

import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import com.microsoft.windowsazure.services.core.storage.AccessPolicyResponseBase;
import com.microsoft.windowsazure.services.core.storage.Constants;
import com.microsoft.windowsazure.services.core.storage.utils.Utility;

/**
* RESERVED FOR INTERNAL USE. A class used to parse SharedAccessPolicies from an input stream.
*/
final class BlobAccessPolicyResponse extends AccessPolicyResponseBase<SharedAccessBlobPolicy> {

/**
* Initializes the AccessPolicyResponse object
*
* @param stream
* the input stream to read error details from.
*/
public BlobAccessPolicyResponse(final InputStream stream) {
super(stream);
}

/**
* Populates the object from the XMLStreamReader, reader must be at Start element of AccessPolicy.
*
* @param xmlr
* the XMLStreamReader object
* @throws XMLStreamException
* if there is a parsing exception
* @throws ParseException
* if a date value is not correctly encoded
*/
@Override
protected SharedAccessBlobPolicy readPolicyFromXML(final XMLStreamReader xmlr) throws XMLStreamException,
ParseException {
int eventType = xmlr.getEventType();

xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.ACCESS_POLICY);
final SharedAccessBlobPolicy retPolicy = new SharedAccessBlobPolicy();

while (xmlr.hasNext()) {
eventType = xmlr.next();

if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) {
final String name = xmlr.getName().toString();

if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PERMISSION)) {
retPolicy.setPermissions(SharedAccessBlobPolicy.permissionsFromString(Utility
.readElementFromXMLReader(xmlr, Constants.PERMISSION)));
}
else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.START)) {
final String tempString = Utility.readElementFromXMLReader(xmlr, Constants.START);
retPolicy.setSharedAccessStartTime(Utility.parseISO8061LongDateFromString(tempString));
}
else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.EXPIRY)) {
final String tempString = Utility.readElementFromXMLReader(xmlr, Constants.EXPIRY);
retPolicy.setSharedAccessExpiryTime(Utility.parseISO8061LongDateFromString(tempString));
}
else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(Constants.ACCESS_POLICY)) {
break;
}
}
}

xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ACCESS_POLICY);
return retPolicy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ final class BlobAttributes {
*/
private HashMap<String, String> metadata;

/**
* Represents the state of the most recent or pending copy operation.
*/
private CopyState copyState;

/**
* Holds the properties of the blob.
*/
Expand Down Expand Up @@ -55,6 +60,10 @@ public HashMap<String, String> getMetadata() {
return this.metadata;
}

public CopyState getCopyState() {
return this.copyState;
}

public BlobProperties getProperties() {
return this.properties;
}
Expand All @@ -66,4 +75,8 @@ protected void setMetadata(final HashMap<String, String> metadata) {
protected void setProperties(final BlobProperties properties) {
this.properties = properties;
}

public void setCopyState(final CopyState copyState) {
this.copyState = copyState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,6 @@
* Holds the Constants used for the Queue Service.
*/
final class BlobConstants {
/**
* Defines constants for use with query strings.
*/
public static class QueryConstants {
/**
* The query component for the SAS signature.
*/
public static final String SIGNATURE = "sig";

/**
* The query component for the signed SAS expiry time.
*/
public static final String SIGNED_EXPIRY = "se";

/**
* The query component for the signed SAS identifier.
*/
public static final String SIGNED_IDENTIFIER = "si";

/**
* The query component for the signed SAS permissions.
*/
public static final String SIGNED_PERMISSIONS = "sp";

/**
* The query component for the signed SAS resource.
*/
public static final String SIGNED_RESOURCE = "sr";

/**
* The query component for the signed SAS start time.
*/
public static final String SIGNED_START = "st";

/**
* The query component for the signed SAS version.
*/
public static final String SIGNED_VERSION = "sv";

/**
* The query component for snapshot time.
*/
public static final String SNAPSHOT = "snapshot";
}

/**
* XML element for an access policy.
*/
public static final String ACCESS_POLICY = "AccessPolicy";

/**
* XML element for authentication error details.
*/
Expand Down Expand Up @@ -204,11 +154,6 @@ public static class QueryConstants {
*/
public static final int DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB;

/**
* XML element for the end time of an access policy.
*/
public static final String EXPIRY = "Expiry";

/**
* Specifies snapshots are to be included.
*/
Expand All @@ -219,11 +164,6 @@ public static class QueryConstants {
*/
public static final String LATEST_ELEMENT = "Latest";

/**
* Maximum number of shared access policy identifiers supported by server.
*/
public static final int MAX_SHARED_ACCESS_POLICY_IDENTIFIERS = 5;

/**
* The maximum size, in bytes, of a blob before it must be separated into blocks
*/
Expand Down Expand Up @@ -261,11 +201,6 @@ public static class QueryConstants {
public static final String PAGE_WRITE = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "page-write";

/**
* XML element for the permission of an access policy.
*/
public static final String PERMISSION = "Permission";

/**
* XML element for properties.
*/
Expand All @@ -277,16 +212,6 @@ public static class QueryConstants {
public static final String SEQUENCE_NUMBER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER
+ "blob-sequence-number";

/**
* XML element for a signed identifier.
*/
public static final String SIGNED_IDENTIFIER_ELEMENT = "SignedIdentifier";

/**
* XML element for signed identifiers.
*/
public static final String SIGNED_IDENTIFIERS_ELEMENT = "SignedIdentifiers";

/**
* The header for the blob content length.
*/
Expand Down Expand Up @@ -319,11 +244,6 @@ public static class QueryConstants {
*/
public static final String SNAPSHOTS_ONLY_VALUE = "only";

/**
* XML element for the start time of an access policy.
*/
public static final String START = "Start";

/**
* XML element for page range start elements.
*/
Expand All @@ -339,6 +259,16 @@ public static class QueryConstants {
*/
public static final String UNCOMMITTED_ELEMENT = "Uncommitted";

/**
* The default timeout of a copy operation.
*/
public static final int DEFAULT_COPY_TIMEOUT_IN_SECONDS = 3600;

/**
* The default polling interval of a copy operation.
*/
public static final int DEFAULT_POLLING_INTERVAL_IN_SECONDS = 30;

/**
* Private Default Ctor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public final class BlobContainerPermissions {
/**
* Gets the set of shared access policies for the container.
*/
private HashMap<String, SharedAccessPolicy> sharedAccessPolicies;
private HashMap<String, SharedAccessBlobPolicy> sharedAccessPolicies;

/**
* Creates an instance of the <code>BlobContainerPermissions</code> class.
*/
public BlobContainerPermissions() {
this.setPublicAccess(BlobContainerPublicAccessType.OFF);
this.sharedAccessPolicies = new HashMap<String, SharedAccessPolicy>();
this.sharedAccessPolicies = new HashMap<String, SharedAccessBlobPolicy>();
}

/**
Expand All @@ -75,10 +75,10 @@ public BlobContainerPublicAccessType getPublicAccess() {
/**
* Returns the set of shared access policies for the container.
*
* @return A <code>HashMap</code> object of {@link SharedAccessPolicy} objects that represent the set of shared
* @return A <code>HashMap</code> object of {@link SharedAccessBlobPolicy} objects that represent the set of shared
* access policies for the container.
*/
public HashMap<String, SharedAccessPolicy> getSharedAccessPolicies() {
public HashMap<String, SharedAccessBlobPolicy> getSharedAccessPolicies() {
return this.sharedAccessPolicies;
}

Expand All @@ -94,7 +94,7 @@ public void setPublicAccess(final BlobContainerPublicAccessType publicAccess) {
* @param sharedAccessPolicies
* the sharedAccessPolicies to set
*/
public void setSharedAccessPolicies(final HashMap<String, SharedAccessPolicy> sharedAccessPolicies) {
public void setSharedAccessPolicies(final HashMap<String, SharedAccessBlobPolicy> sharedAccessPolicies) {
this.sharedAccessPolicies = sharedAccessPolicies;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import java.util.Date;

import com.microsoft.windowsazure.services.core.storage.AccessCondition;
import com.microsoft.windowsazure.services.core.storage.LeaseDuration;
import com.microsoft.windowsazure.services.core.storage.LeaseState;
import com.microsoft.windowsazure.services.core.storage.LeaseStatus;

/**
* Represents the system properties for a container.
Expand All @@ -39,6 +42,21 @@ public final class BlobContainerProperties {
*/
private Date lastModified;

/**
* Represents the container's lease status.
*/
private LeaseStatus leaseStatus;

/**
* Represents the container's lease state.
*/
private LeaseState leaseState;

/**
* Represents the container's lease duration.
*/
private LeaseDuration leaseDuration;

/**
* @return the etag
*/
Expand All @@ -53,6 +71,27 @@ public Date getLastModified() {
return this.lastModified;
}

/**
* @return the leaseStatus
*/
public LeaseStatus getLeaseStatus() {
return this.leaseStatus;
}

/**
* @return the leaseState
*/
public LeaseState getLeaseState() {
return this.leaseState;
}

/**
* @return the leaseDuration
*/
public LeaseDuration getLeaseDuration() {
return this.leaseDuration;
}

/**
* @param etag
* the etag to set
Expand All @@ -68,4 +107,34 @@ public void setEtag(final String etag) {
public void setLastModified(final Date lastModified) {
this.lastModified = lastModified;
}

/**
* Reserved for internal use.
*
* @param leaseStatus
* the leaseStatus to set
*/
public void setLeaseStatus(final LeaseStatus leaseStatus) {
this.leaseStatus = leaseStatus;
}

/**
* Reserved for internal use.
*
* @param LeaseState
* the LeaseState to set
*/
public void setLeaseState(final LeaseState leaseState) {
this.leaseState = leaseState;
}

/**
* Reserved for internal use.
*
* @param LeaseDuration
* the LeaseDuration to set
*/
public void setLeaseDuration(final LeaseDuration leaseDuration) {
this.leaseDuration = leaseDuration;
}
}
Loading

0 comments on commit 3f94f2d

Please sign in to comment.