private boolean isCorrectLogType(ListBlobItem current) {
        HashMap<String, String> metadata = ((CloudBlob) current).getMetadata();
        String logType = metadata.get("LogType");

        if (logType == null) {
            return true;
        }

        if (this.operations.contains(LoggingOperations.READ) && logType.contains("read")) {
            return true;
        }

        if (this.operations.contains(LoggingOperations.WRITE) && logType.contains("write")) {
            return true;
        }

        if (this.operations.contains(LoggingOperations.DELETE) && logType.contains("delete")) {
            return true;
        }

        return false;
    }

private boolean isCorrectLogType ( ListBlobItem current ) { HashMap < String , String > metadata = ( ( CloudBlob ) current ) . getMetadata ( ) ; String logType = metadata . get ( "LogType" ) ; if ( logType == null ) { return true ; } if ( this . operations . contains ( LoggingOperations . READ ) && logType . contains ( "read" ) ) { return true ; } if ( this . operations . contains ( LoggingOperations . WRITE ) && logType . contains ( "write" ) ) { return true ; } if ( this . operations . contains ( LoggingOperations . DELETE ) && logType . contains ( "delete" ) ) { return true ; } return false ; }

Validates that the log given is of the correct log type.

@param current
the current log
@return whether or not the log is of the correct type.

Validates that the log given is of the correct log type .


private void updateIterator() throws StorageException, URISyntaxException {
        if (this.currentPrefixTime != null && this.currentPrefixTime.isEmpty()) {
            // If we've already called listBlobs() with an empty prefix, don't do so again.
            this.isExpired = true;
            return;
        }

        GregorianCalendar now = new GregorianCalendar();
        now.add(GregorianCalendar.HOUR_OF_DAY, 1);
        now.setTimeZone(TimeZone.getTimeZone("GMT"));
        updatePrefix();
        if ((this.startDate == null || this.startDate.compareTo(now) <= 0)
                && (this.endDate == null || ((this.logDirectory.getPrefix() + this.currentPrefixTime)
                        .compareTo(this.endPrefix) <= 0))) {
            // Only make the next call if the prefix is still possible
            this.currentIterator = this.logDirectory.listBlobs(this.currentPrefixTime, true, this.details,
                    this.options, this.opContext).iterator();
        }
        else {
            // We are in the future.
            this.isExpired = true;
        }
    }

Makes the next listBlob call if necessary and updates the currentIterator.

@throws StorageException
@throws URISyntaxException

Makes the next listBlob call if necessary and updates the currentIterator .


@DoesServiceRequest
    public final String startCopy(final CloudBlob sourceBlob) throws StorageException, URISyntaxException {
        return this.startCopy(sourceBlob, null /* sourceAccessCondition */,
                null /* destinationAccessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
final
String
startCopy
(
final
CloudBlob
sourceBlob
)
throws
StorageException
,
URISyntaxException
{
return
this
.
startCopy
(
sourceBlob
,
/* sourceAccessCondition */
,
/* destinationAccessCondition */
,
/* options */
,
/* opContext */
)
;
}

Requests the service to start copying a blob's contents, properties, and metadata to a new file.

@param sourceBlob
A CloudBlob object that represents the source blob to copy.

@return A String which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying a blob s contents properties and metadata to a new file .


@DoesServiceRequest
    public final String startCopy(final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition,
            final AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext)
            throws StorageException, URISyntaxException {
        Utility.assertNotNull("sourceBlob", sourceBlob);

        URI source = sourceBlob.getSnapshotQualifiedUri();
        if (sourceBlob.getServiceClient() != null && sourceBlob.getServiceClient().getCredentials() != null)
        {
            source = sourceBlob.getServiceClient().getCredentials().transformUri(sourceBlob.getSnapshotQualifiedUri());
        }

        return this.startCopy(source, sourceAccessCondition, destinationAccessCondition, options, opContext);
    }

@ DoesServiceRequest public final String startCopy ( final CloudBlob sourceBlob , final AccessCondition sourceAccessCondition , final AccessCondition destinationAccessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { Utility . assertNotNull ( "sourceBlob" , sourceBlob ) ; URI source = sourceBlob . getSnapshotQualifiedUri ( ) ; if ( sourceBlob . getServiceClient ( ) != null && sourceBlob . getServiceClient ( ) . getCredentials ( ) != null ) { source = sourceBlob . getServiceClient ( ) . getCredentials ( ) . transformUri ( sourceBlob . getSnapshotQualifiedUri ( ) ) ; } return this . startCopy ( source , sourceAccessCondition , destinationAccessCondition , options , opContext ) ; }

Requests the service to start copying a file's contents, properties, and metadata to a new file,
using the specified access conditions, lease ID, request options, and operation context.

@param sourceBlob
A CloudBlob object that represents the source blob to copy.
@param sourceAccessCondition
An {@link AccessCondition} object that represents the access conditions for the source blob.
@param destinationAccessCondition
An {@link AccessCondition} object that represents the access conditions for the destination file.
@param options
A {@link BlobRequestOptions} object that specifies any additional options for the request.
Specifying null will use the default request options from the associated
service client ({@link CloudBlobClient}).
@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 which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying a file s contents properties and metadata to a new file using the specified access conditions lease ID request options and operation context .


@DoesServiceRequest
    public final String startCopy(final CloudFile sourceFile) throws StorageException, URISyntaxException {
        return this.startCopy(sourceFile, null /* sourceAccessCondition */,
                null /* destinationAccessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
final
String
startCopy
(
final
CloudFile
sourceFile
)
throws
StorageException
,
URISyntaxException
{
return
this
.
startCopy
(
sourceFile
,
/* sourceAccessCondition */
,
/* destinationAccessCondition */
,
/* options */
,
/* opContext */
)
;
}

Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File.

@param sourceFile
A CloudFile object that represents the source Azure File to copy.

@return A String which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying an Azure File s contents properties and metadata to a new Azure File .


@DoesServiceRequest
    public final String startCopy(final CloudFile sourceFile, final AccessCondition sourceAccessCondition,
            final AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext)
            throws StorageException, URISyntaxException {
        Utility.assertNotNull("sourceFile", sourceFile);
        return this.startCopy(sourceFile.getTransformedAddress(opContext).getPrimaryUri(),
                sourceAccessCondition, destinationAccessCondition, options, opContext);

    }

@ DoesServiceRequest public final String startCopy ( final CloudFile sourceFile , final AccessCondition sourceAccessCondition , final AccessCondition destinationAccessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { Utility . assertNotNull ( "sourceFile" , sourceFile ) ; return this . startCopy ( sourceFile . getTransformedAddress ( opContext ) . getPrimaryUri ( ) , sourceAccessCondition , destinationAccessCondition , options , opContext ) ; }

Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File,
using the specified access conditions, lease ID, request options, and operation context.

@param sourceFile
A CloudFile object that represents the source file to copy.
@param sourceAccessCondition
An {@link AccessCondition} object that represents the access conditions for the source.
@param destinationAccessCondition
An {@link AccessCondition} object that represents the access conditions for the destination.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request.
Specifying null will use the default request options from the associated
service client ({@link CloudFileClient}).
@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 which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying an Azure File s contents properties and metadata to a new Azure File using the specified access conditions lease ID request options and operation context .


@DoesServiceRequest
    public final String startCopy(final URI source) throws StorageException, URISyntaxException {
        return this.startCopy(source, null /* sourceAccessCondition */,
                null /* destinationAccessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
final
String
startCopy
(
final
URI
source
)
throws
StorageException
,
URISyntaxException
{
return
this
.
startCopy
(
source
,
/* sourceAccessCondition */
,
/* destinationAccessCondition */
,
/* options */
,
/* opContext */
)
;
}

Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File.

@param source
The source's java.net.URI.

@return A String which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying a URI s contents properties and metadata to a new Azure File .


@DoesServiceRequest
    public final String startCopy(final URI source, final AccessCondition sourceAccessCondition,
            final AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext)
            throws StorageException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        opContext.initialize();
        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        return ExecutionEngine.executeWithRetry(this.fileServiceClient, this,
                this.startCopyImpl(source, sourceAccessCondition, destinationAccessCondition, options),
                options.getRetryPolicyFactory(), opContext);
    }

@ DoesServiceRequest public final String startCopy ( final URI source , final AccessCondition sourceAccessCondition , final AccessCondition destinationAccessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } this . getShare ( ) . assertNoSnapshot ( ) ; opContext . initialize ( ) ; options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; return ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , this . startCopyImpl ( source , sourceAccessCondition , destinationAccessCondition , options ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File,
using the specified access conditions, lease ID, request options, and operation context.

@param source
The source's java.net.URI.
@param sourceAccessCondition
An {@link AccessCondition} object that represents the access conditions for the source.
@param destinationAccessCondition
An {@link AccessCondition} object that represents the access conditions for the destination.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request.
Specifying null will use the default request options from the associated
service client ({@link CloudFileClient}).
@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 which represents the copy ID associated with the copy operation.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Requests the service to start copying a URI s contents properties and metadata to a new Azure File using the specified access conditions lease ID request options and operation context .


@DoesServiceRequest
    public void create(final long size) throws StorageException, URISyntaxException {
        this.create(size, null /* accessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
void
create
(
final
long
size
)
throws
StorageException
,
URISyntaxException
{
this
.
create
(
size
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Creates a file. If the file already exists, this will replace it.

@param size
A long which represents the size, in bytes, of the file.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Creates a file . If the file already exists this will replace it .


@DoesServiceRequest
    public void create(final long size, final AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException, URISyntaxException {

        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        ExecutionEngine.executeWithRetry(this.fileServiceClient, this, this.createImpl(size, accessCondition, options),
                options.getRetryPolicyFactory(), opContext);
    }

@ DoesServiceRequest public void create ( final long size , final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } this . getShare ( ) . assertNoSnapshot ( ) ; options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , this . createImpl ( size , accessCondition , options ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Creates a file using the specified access condition, request options and operation context. If the file already
exists, this will replace it.

@param size
A long which represents the size, in bytes, of the file.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Creates a file using the specified access condition request options and operation context . If the file already exists this will replace it .


private void deleteEmptyFileOnException(OutputStream outputStream, String path) {
        try {
            outputStream.close();
            File fileToDelete = new File(path);
            fileToDelete.delete();
        }
        catch (Exception e) {
            // Best effort delete.
        }
    }

private
void
deleteEmptyFileOnException
(
OutputStream
outputStream
,
String
path
)
{
try
{
outputStream
.
close
(
)
;
File
fileToDelete
=
new
File
(
path
)
;
fileToDelete
.
delete
(
)
;
}
catch
(
Exception
e
)
{
// Best effort delete.
}
}

Helper to delete an empty file in the case of an exception

@param outputStream
@param path
@throws IOException


public String downloadText(final String charsetName, final AccessCondition accessCondition,
            FileRequestOptions options, OperationContext opContext) throws StorageException, IOException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        this.download(baos, accessCondition, options, opContext);
        return charsetName == null ? baos.toString() : baos.toString(charsetName);
    }

public String downloadText ( final String charsetName , final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; this . download ( baos , accessCondition , options , opContext ) ; return charsetName == null ? baos . toString ( ) : baos . toString ( charsetName ) ; }

Downloads a file to a string using the specified encoding.

@param charsetName
A String which represents the name of the charset to use to encode the content.
If null, the platform's default encoding is used.
@param accessCondition
An {@link AccessCondition} object that represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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 which represents the file's contents.

@throws StorageException
If a storage service error occurred.
@throws IOException

Downloads a file to a string using the specified encoding .


@DoesServiceRequest
    public ArrayList<FileRange> downloadFileRanges(final AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        return ExecutionEngine.executeWithRetry(this.fileServiceClient, this,
                this.downloadFileRangesImpl(accessCondition, options), options.getRetryPolicyFactory(), opContext);
    }

@ DoesServiceRequest public ArrayList < FileRange > downloadFileRanges ( final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; return ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , this . downloadFileRangesImpl ( accessCondition , options ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Returns a collection of file ranges and their starting and ending byte offsets using the specified request
options and operation context.

@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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 An ArrayList object which represents the set of file ranges and their starting
and ending byte offsets.

@throws StorageException
If a storage service error occurred.

Returns a collection of file ranges and their starting and ending byte offsets using the specified request options and operation context .


@DoesServiceRequest
    public FileOutputStream openWriteExisting() throws StorageException, URISyntaxException {
        return this
                .openOutputStreamInternal(null /* length */, null /* accessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
FileOutputStream
openWriteExisting
(
)
throws
StorageException
,
URISyntaxException
{
return
this
.
openOutputStreamInternal
(
/* length */
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Opens an output stream object to write data to the file. The file must already exist and any existing data may
be overwritten.

@return A {@link FileOutputStream} object used to write data to the file.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Opens an output stream object to write data to the file . The file must already exist and any existing data may be overwritten .


@DoesServiceRequest
    public FileOutputStream openWriteExisting(AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException, URISyntaxException {
        return this.openOutputStreamInternal(null /* length */, accessCondition, options, opContext);
    }

@
DoesServiceRequest
public
FileOutputStream
openWriteExisting
(
AccessCondition
accessCondition
,
FileRequestOptions
options
,
OperationContext
opContext
)
throws
StorageException
,
URISyntaxException
{
return
this
.
openOutputStreamInternal
(
/* length */
,
accessCondition
,
options
,
opContext
)
;
}

Opens an output stream object to write data to the file, using specified request options and
operation context. The file must already exist and any existing data may be overwritten.

@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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 {@link FileOutputStream} object used to write data to the file.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Opens an output stream object to write data to the file using specified request options and operation context . The file must already exist and any existing data may be overwritten .


private FileOutputStream openOutputStreamInternal(Long length, AccessCondition accessCondition,
            FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient, false /* setStartTime */);

        if (length != null) {
            this.create(length, accessCondition, options, opContext);
        }
        else {
            if (options.getStoreFileContentMD5()) {
                throw new IllegalArgumentException(SR.FILE_MD5_NOT_POSSIBLE);
            }

            this.downloadAttributes(accessCondition, options, opContext);
            length = this.getProperties().getLength();
        }

        if (accessCondition != null) {
            accessCondition = AccessCondition.generateLeaseCondition(accessCondition.getLeaseID());
        }

        return new FileOutputStream(this, length, accessCondition, options, opContext);
    }

private
FileOutputStream
openOutputStreamInternal
(
Long
length
,
AccessCondition
accessCondition
,
FileRequestOptions
options
,
OperationContext
opContext
)
throws
StorageException
,
URISyntaxException
{
if
(
opContext
==
)
{
opContext
=
new
OperationContext
(
)
;
}
this
.
getShare
(
)
.
assertNoSnapshot
(
)
;
options
=
FileRequestOptions
.
populateAndApplyDefaults
(
options
,
this
.
fileServiceClient
,
false
/* setStartTime */
)
;
if
(
length
!=
)
{
this
.
create
(
length
,
accessCondition
,
options
,
opContext
)
;
}
else
{
if
(
options
.
getStoreFileContentMD5
(
)
)
{
throw
new
IllegalArgumentException
(
SR
.
FILE_MD5_NOT_POSSIBLE
)
;
}
this
.
downloadAttributes
(
accessCondition
,
options
,
opContext
)
;
length
=
this
.
getProperties
(
)
.
getLength
(
)
;
}
if
(
accessCondition
!=
)
{
accessCondition
=
AccessCondition
.
generateLeaseCondition
(
accessCondition
.
getLeaseID
(
)
)
;
}
return
new
FileOutputStream
(
this
,
length
,
accessCondition
,
options
,
opContext
)
;
}

Opens an output stream object to write data to the file, using the specified lease ID, request options and
operation context. If the length is specified, a new file will be created with the length specified.
Otherwise, the file must already exist and a stream of its current length will be opened.

@param length
A long which represents the length, in bytes, of the stream to create. This value must be
null if the file already exists.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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 {@link FileOutputStream} object used to write data to the file.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Opens an output stream object to write data to the file using the specified lease ID request options and operation context . If the length is specified a new file will be created with the length specified . Otherwise the file must already exist and a stream of its current length will be opened .


public void uploadFromFile(final String path) throws StorageException, IOException, URISyntaxException {
        uploadFromFile(path, null /* accessCondition */, null /* options */, null /* opContext */);
    }

public
void
uploadFromFile
(
final
String
path
)
throws
StorageException
,
IOException
,
URISyntaxException
{
uploadFromFile
(
path
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Uploads a local file. If the file already exists on the service, it will be overwritten.

@param path
A String which represents the path to the file to be uploaded.

@throws StorageException
If a storage service error occurred.
@throws IOException
@throws URISyntaxException

Uploads a local file . If the file already exists on the service it will be overwritten .


public void uploadFromFile(final String path, final AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException, IOException, URISyntaxException {
        File file = new File(path);
        long fileLength = file.length();
        InputStream inputStream = new BufferedInputStream(new java.io.FileInputStream(file));
        this.upload(inputStream, fileLength, accessCondition, options, opContext);
        inputStream.close();
    }

public void uploadFromFile ( final String path , final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , IOException , URISyntaxException { File file = new File ( path ) ; long fileLength = file . length ( ) ; InputStream inputStream = new BufferedInputStream ( new java . io . FileInputStream ( file ) ) ; this . upload ( inputStream , fileLength , accessCondition , options , opContext ) ; inputStream . close ( ) ; }

Uploads a file from a local file. If the file already exists on the service, it will be overwritten.

@param path
A String which represents the path to the file to be uploaded.
@param accessCondition
An {@link AccessCondition} object that represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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.

@throws StorageException
If a storage service error occurred.
@throws IOException
@throws URISyntaxException

Uploads a file from a local file . If the file already exists on the service it will be overwritten .


public void uploadText(final String content) throws StorageException, IOException, URISyntaxException {
        this.uploadText(content, null /* charsetName */, null /* accessCondition */, null /* options */, null /* opContext */);
    }

public
void
uploadText
(
final
String
content
)
throws
StorageException
,
IOException
,
URISyntaxException
{
this
.
uploadText
(
content
,
/* charsetName */
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Uploads a file from a string using the platform's default encoding. If the file already exists on the service, it
will be overwritten.

@param content
A String which represents the content that will be uploaded to the file.

@throws StorageException
If a storage service error occurred.
@throws IOException
@throws URISyntaxException

Uploads a file from a string using the platform s default encoding . If the file already exists on the service it will be overwritten .


public void uploadText(final String content, final String charsetName, final AccessCondition accessCondition,
            FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException {
        byte[] bytes = (charsetName == null) ? content.getBytes() : content.getBytes(charsetName);
        this.uploadFromByteArray(bytes, 0, bytes.length, accessCondition, options, opContext);
    }

public void uploadText ( final String content , final String charsetName , final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , IOException , URISyntaxException { byte [ ] bytes = ( charsetName == null ) ? content . getBytes ( ) : content . getBytes ( charsetName ) ; this . uploadFromByteArray ( bytes , 0 , bytes . length , accessCondition , options , opContext ) ; }

Uploads a file from a string using the specified encoding. If the file already exists on the service, it will be
overwritten.

@param content
A String which represents the content that will be uploaded to the file.
@param charsetName
A String which represents the name of the charset to use to encode the content.
If null, the platform's default encoding is used.
@param accessCondition
An {@link AccessCondition} object that represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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.

@throws StorageException
If a storage service error occurred.
@throws IOException
@throws URISyntaxException

Uploads a file from a string using the specified encoding . If the file already exists on the service it will be overwritten .


@DoesServiceRequest
    public void uploadRange(final InputStream sourceStream, final long offset, final long length)
            throws StorageException, IOException, URISyntaxException {
        this.uploadRange(sourceStream, offset, length, null /* accessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
void
uploadRange
(
final
InputStream
sourceStream
,
final
long
offset
,
final
long
length
)
throws
StorageException
,
IOException
,
URISyntaxException
{
this
.
uploadRange
(
sourceStream
,
offset
,
length
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Uploads a range to a file.

@param sourceStream
An {@link InputStream} object which represents the input stream to write to the file.
@param offset
A long which represents the offset, in number of bytes, at which to begin writing the
data.
@param length
A long which represents the length, in bytes, of the data to write.

@throws IOException
If an I/O exception occurred.
@throws StorageException
If a storage service error occurred.
@throws URISyntaxException


@DoesServiceRequest
    public void uploadRange(final InputStream sourceStream, final long offset, final long length,
            final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
            throws StorageException, IOException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        final FileRange range = new FileRange(offset, offset + length - 1);
        final byte[] data = new byte[(int) length];
        String md5 = null;

        int count = 0;
        int total = 0;
        while (total < length) {
            count = sourceStream.read(data, total, (int) Math.min(length - total, Integer.MAX_VALUE));
            total += count;
        }

        if (options.getUseTransactionalContentMD5()) {
            try {
                final MessageDigest digest = MessageDigest.getInstance("MD5");
                digest.update(data, 0, data.length);
                md5 = Base64.encode(digest.digest());
            }
            catch (final NoSuchAlgorithmException e) {
                // This wont happen, throw fatal.
                throw Utility.generateNewUnexpectedStorageException(e);
            }
        }

        this.putRangeInternal(range, FileRangeOperationType.UPDATE, data, length, md5, accessCondition, options,
                opContext);
    }

@
DoesServiceRequest
public
void
uploadRange
(
final
InputStream
sourceStream
,
final
long
offset
,
final
long
length
,
final
AccessCondition
accessCondition
,
FileRequestOptions
options
,
OperationContext
opContext
)
throws
StorageException
,
IOException
,
URISyntaxException
{
if
(
opContext
==
)
{
opContext
=
new
OperationContext
(
)
;
}
this
.
getShare
(
)
.
assertNoSnapshot
(
)
;
options
=
FileRequestOptions
.
populateAndApplyDefaults
(
options
,
this
.
fileServiceClient
)
;
final
FileRange
range
=
new
FileRange
(
offset
,
offset
+
length
1
)
;
final
byte
[
]
data
=
new
byte
[
(
int
)
length
]
;
String
md5
=
;
int
count
=
0
;
int
total
=
0
;
while
(
total
<
length
)
{
count
=
sourceStream
.
read
(
data
,
total
,
(
int
)
Math
.
min
(
length
total
,
Integer
.
MAX_VALUE
)
)
;
total
+=
count
;
}
if
(
options
.
getUseTransactionalContentMD5
(
)
)
{
try
{
final
MessageDigest
digest
=
MessageDigest
.
getInstance
(
"MD5"
)
;
digest
.
update
(
data
,
0
,
data
.
length
)
;
md5
=
Base64
.
encode
(
digest
.
digest
(
)
)
;
}
catch
(
final
NoSuchAlgorithmException
e
)
{
// This wont happen, throw fatal.
throw
Utility
.
generateNewUnexpectedStorageException
(
e
)
;
}
}
this
.
putRangeInternal
(
range
,
FileRangeOperationType
.
UPDATE
,
data
,
length
,
md5
,
accessCondition
,
options
,
opContext
)
;
}

Uploads a range to a file using the specified lease ID, request options, and operation context.

@param sourceStream
An {@link InputStream} object which represents the input stream to write to the file.
@param offset
A long which represents the offset, in number of bytes, at which to begin writing the
data.
@param length
A long which represents the length, in bytes, of the data to write.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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.

@throws IOException
If an I/O exception occurred.
@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Uploads a range to a file using the specified lease ID request options and operation context .


@DoesServiceRequest
    private void putRangeInternal(final FileRange range, final FileRangeOperationType operationType, final byte[] data,
            final long length, final String md5, final AccessCondition accessCondition,
            final FileRequestOptions options, final OperationContext opContext) throws StorageException {
        ExecutionEngine.executeWithRetry(this.fileServiceClient, this,
                putRangeImpl(range, operationType, data, length, md5, accessCondition, options, opContext),
                options.getRetryPolicyFactory(), opContext);
    }

@ DoesServiceRequest private void putRangeInternal ( final FileRange range , final FileRangeOperationType operationType , final byte [ ] data , final long length , final String md5 , final AccessCondition accessCondition , final FileRequestOptions options , final OperationContext opContext ) throws StorageException { ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , putRangeImpl ( range , operationType , data , length , md5 , accessCondition , options , opContext ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Used for both uploadRange and clearRange.

@param range
A {@link FileRange} object that specifies the file range.
@param operationType
A {@link FileRangeOperationType} enumeration value that specifies the operation type.
@param data
A byte array which represents the data to write.
@param length
A long which represents the number of bytes to write.
@param md5
A String which represents the MD5 hash for the data.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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.

@throws StorageException
If a storage service error occurred.

Used for both uploadRange and clearRange .


public void resize(long size, AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        opContext.initialize();
        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        ExecutionEngine.executeWithRetry(this.fileServiceClient, this, this.resizeImpl(size, accessCondition, options),
                options.getRetryPolicyFactory(), opContext);
    }

public void resize ( long size , AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } this . getShare ( ) . assertNoSnapshot ( ) ; opContext . initialize ( ) ; options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , this . resizeImpl ( size , accessCondition , options ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Resizes the file to the specified size.

@param size
A long which represents the size of the file, in bytes.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Resizes the file to the specified size .


@DoesServiceRequest
    public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException, URISyntaxException {
        this.upload(sourceStream, length, null /* accessCondition */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
void
upload
(
final
InputStream
sourceStream
,
final
long
length
)
throws
StorageException
,
IOException
,
URISyntaxException
{
this
.
upload
(
sourceStream
,
length
,
/* accessCondition */
,
/* options */
,
/* opContext */
)
;
}

Uploads the source stream data to the file. If the file already exists on the service, it will be overwritten.

@param sourceStream
An {@link InputStream} object to read from.
@param length
A long which represents the length, in bytes, of the stream data. Must be non zero.

@throws IOException
If an I/O exception occurred.
@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Uploads the source stream data to the file . If the file already exists on the service it will be overwritten .


@DoesServiceRequest
    public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition,
            FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        if (length < 0) {
            throw new IllegalArgumentException(SR.INVALID_FILE_LENGTH);
        }

        if (sourceStream.markSupported()) {
            // Mark sourceStream for current position.
            sourceStream.mark(Constants.MAX_MARK_LENGTH);
        }

        final FileOutputStream streamRef = this.openWriteNew(length, accessCondition, options, opContext);
        try {
            streamRef.write(sourceStream, length);
        }
        finally {
            streamRef.close();
        }
    }

Uploads the source stream data to the file using the specified access condition, request options, and operation
context. If the file already exists on the service, it will be overwritten.

@param sourceStream
An {@link InputStream} object to read from.
@param length
A long which represents the length, in bytes, of the stream data. This must be greater than
or equal to zero.
@param accessCondition
An {@link AccessCondition} object which represents the access conditions for the file.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@param opContext
An {@link OperationContext} object which 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.

@throws IOException
If an I/O exception occurred.
@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Uploads the source stream data to the file using the specified access condition request options and operation context . If the file already exists on the service it will be overwritten .


protected static String getParentNameFromURI(final StorageUri resourceAddress, final CloudFileShare share)
            throws URISyntaxException {
        Utility.assertNotNull("resourceAddress", resourceAddress);
        Utility.assertNotNull("share", share);

        String delimiter = "/";
        String shareName = share.getName() + delimiter;

        String relativeURIString = Utility.safeRelativize(share.getStorageUri().getPrimaryUri(),
                resourceAddress.getPrimaryUri());

        if (relativeURIString.endsWith(delimiter)) {
            relativeURIString = relativeURIString.substring(0, relativeURIString.length() - delimiter.length());
        }

        String parentName;

        if (Utility.isNullOrEmpty(relativeURIString)) {
            // Case 1 /<ShareName>[Delimiter]*? => /<ShareName>
            // Parent of share is share itself
            parentName = null;
        }
        else {
            final int lastDelimiterDex = relativeURIString.lastIndexOf(delimiter);

            if (lastDelimiterDex < 0) {
                // Case 2 /<Share>/<Directory>
                // Parent of a Directory is Share
                parentName = "";
            }
            else {
                // Case 3 /<Share>/<Directory>/[<subDirectory>/]*<FileName>
                // Parent of CloudFile is CloudFileDirectory
                parentName = relativeURIString.substring(0, lastDelimiterDex);
                if (parentName != null && parentName.equals(shareName)) {
                    parentName = "";
                }
            }
        }

        return parentName;
    }

Retrieves the parent name for a file URI.

@param resourceAddress
A {@link StorageUri} object which represents the resource URI.
@param delimiter
A String which specifies the directory delimiter to use.
@param usePathStyleUris
A Boolean which specifies whether path style URIs are used.
@param share
A {@link CloudFileShare} object which represents the file share.

@return A String which represents the parent address for a file URI.

@throws URISyntaxException

Retrieves the parent name for a file URI .


@Override
    public final CloudFileShare getShare() throws StorageException, URISyntaxException {
        if (this.share == null) {
            final StorageUri shareUri = PathUtility.getShareURI(this.getStorageUri(),
                    this.fileServiceClient.isUsePathStyleUris());
            this.share = new CloudFileShare(shareUri, this.fileServiceClient.getCredentials());
        }

        return this.share;
    }

@ Override public final CloudFileShare getShare ( ) throws StorageException , URISyntaxException { if ( this . share == null ) { final StorageUri shareUri = PathUtility . getShareURI ( this . getStorageUri ( ) , this . fileServiceClient . isUsePathStyleUris ( ) ) ; this . share = new CloudFileShare ( shareUri , this . fileServiceClient . getCredentials ( ) ) ; } return this . share ; }

Returns the file's share.

@return A {@link CloudFileShare} object that represents the share of the file.
@throws StorageException
If a storage service error occurred.
@throws URISyntaxException
If the resource URI is invalid.


public static URI appendPathToSingleUri(final URI uri, final String relativeUri, final String separator)
            throws URISyntaxException {

        if (uri == null) {
            return null;
        }

        if (relativeUri == null || relativeUri.isEmpty()) {
            return uri;
        }

        if (uri.getPath().length() == 0 && relativeUri.startsWith(separator)) {
            return new URI(uri.getScheme(), uri.getAuthority(), relativeUri, uri.getRawQuery(), uri.getRawFragment());
        }

        final StringBuilder pathString = new StringBuilder(uri.getPath());
        if (uri.getPath().endsWith(separator)) {
            pathString.append(relativeUri);
        }
        else {
            pathString.append(separator);
            pathString.append(relativeUri);
        }

        return new URI(uri.getScheme(), uri.getAuthority(), pathString.toString(), uri.getQuery(), uri.getFragment());
    }

public static URI appendPathToSingleUri ( final URI uri , final String relativeUri , final String separator ) throws URISyntaxException { if ( uri == null ) { return null ; } if ( relativeUri == null || relativeUri . isEmpty ( ) ) { return uri ; } if ( uri . getPath ( ) . length ( ) == 0 && relativeUri . startsWith ( separator ) ) { return new URI ( uri . getScheme ( ) , uri . getAuthority ( ) , relativeUri , uri . getRawQuery ( ) , uri . getRawFragment ( ) ) ; } final StringBuilder pathString = new StringBuilder ( uri . getPath ( ) ) ; if ( uri . getPath ( ) . endsWith ( separator ) ) { pathString . append ( relativeUri ) ; } else { pathString . append ( separator ) ; pathString . append ( relativeUri ) ; } return new URI ( uri . getScheme ( ) , uri . getAuthority ( ) , pathString . toString ( ) , uri . getQuery ( ) , uri . getFragment ( ) ) ; }

Appends a path to a URI correctly using the given separator.

@param uri
The base Uri.
@param relativeUri
The relative URI.
@param separator
the separator to use.
@return The appended Uri.
@throws URISyntaxException
a valid Uri cannot be constructed

Appends a path to a URI correctly using the given separator .


public static String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris) throws URISyntaxException {
        return Utility.safeRelativize(new URI(getContainerURI(new StorageUri(inURI), usePathStyleUris).getPrimaryUri()
                .toString().concat("/")), inURI);
    }

public static String getBlobNameFromURI ( final URI inURI , final boolean usePathStyleUris ) throws URISyntaxException { return Utility . safeRelativize ( new URI ( getContainerURI ( new StorageUri ( inURI ) , usePathStyleUris ) . getPrimaryUri ( ) . toString ( ) . concat ( "/" ) ) , inURI ) ; }

Gets the blob name from the URI.

@param inURI
the resource address
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return the blobs name
@throws URISyntaxException


public static String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath) {
        final String account = credentials.getAccountName();

        if (account == null) {
            final String errorMessage = SR.CANNOT_CREATE_SAS_FOR_GIVEN_CREDENTIALS;
            throw new IllegalArgumentException(errorMessage);
        }
        final StringBuilder builder = new StringBuilder("/");
        builder.append(account);
        builder.append(absolutePath);
        return builder.toString();
    }

public static String getCanonicalPathFromCredentials ( final StorageCredentials credentials , final String absolutePath ) { final String account = credentials . getAccountName ( ) ; if ( account == null ) { final String errorMessage = SR . CANNOT_CREATE_SAS_FOR_GIVEN_CREDENTIALS ; throw new IllegalArgumentException ( errorMessage ) ; } final StringBuilder builder = new StringBuilder ( "/" ) ; builder . append ( account ) ; builder . append ( absolutePath ) ; return builder . toString ( ) ; }

Gets the canonical path for an object from the credentials.

@param credentials
the credentials to use.
@param absolutePath
the Absolute path of the object.
@return the canonical path for an object from the credentials

Gets the canonical path for an object from the credentials .


public static String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) {
        return getResourceNameFromUri(resourceAddress, usePathStyleUris,
                String.format("Invalid blob address '%s', missing container information", resourceAddress));
    }

Get the container name from address from the URI.

@param resourceAddress
The container Uri.
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return container name from address from the URI.
@throws IllegalArgumentException

Get the container name from address from the URI .


public static String getFileNameFromURI(final URI resourceAddress, final boolean usePathStyleUris) {
        // generate an array of the different levels of the path
        final String[] pathSegments = resourceAddress.getRawPath().split("/");

        // usePathStyleUris ? baseuri/accountname/sharename/objectname : accountname.baseuri/sharename/objectname
        final int shareIndex = usePathStyleUris ? 2 : 1;

        if (pathSegments.length - 1 <= shareIndex) {
            // legal file addresses cannot end with or before the sharename
            throw new IllegalArgumentException(String.format("Invalid file address '%s'.", resourceAddress));
        }
        else {
            // in a legal file address the lowest level is the filename
            return pathSegments[pathSegments.length - 1];
        }
    }

Gets the file name from the URI.

@param resourceAddress
the file URI
@param usePathStyleUris
a value indicating if the address is a path style URI
@return the file's name


public static String getShareNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) {
        return getResourceNameFromUri(resourceAddress, usePathStyleUris,
                String.format("Invalid file address '%s', missing share information", resourceAddress));
    }

Get the share name from address from the URI.

@param resourceAddress
The share Uri.
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return share name from address from the URI.
@throws IllegalArgumentException

Get the share name from address from the URI .


public static String getTableNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) {
        return getResourceNameFromUri(resourceAddress, usePathStyleUris,
                String.format("Invalid table address '%s', missing table information", resourceAddress));
    }

Get the table name from address from the URI.

@param resourceAddress
The table Uri.
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return table name from address from the URI.
@throws IllegalArgumentException

Get the table name from address from the URI .


private static String getResourceNameFromUri(final URI resourceAddress, final boolean usePathStyleUris,
            final String error) {
        Utility.assertNotNull("resourceAddress", resourceAddress);

        final String[] pathSegments = resourceAddress.getRawPath().split("/");

        final int expectedPartsLength = usePathStyleUris ? 3 : 2;

        if (pathSegments.length < expectedPartsLength) {
            throw new IllegalArgumentException(error);
        }

        final String resourceName = usePathStyleUris ? pathSegments[2] : pathSegments[1];

        return Utility.trimEnd(resourceName, '/');
    }

private static String getResourceNameFromUri ( final URI resourceAddress , final boolean usePathStyleUris , final String error ) { Utility . assertNotNull ( "resourceAddress" , resourceAddress ) ; final String [ ] pathSegments = resourceAddress . getRawPath ( ) . split ( "/" ) ; final int expectedPartsLength = usePathStyleUris ? 3 : 2 ; if ( pathSegments . length < expectedPartsLength ) { throw new IllegalArgumentException ( error ) ; } final String resourceName = usePathStyleUris ? pathSegments [ 2 ] : pathSegments [ 1 ] ; return Utility . trimEnd ( resourceName , ' ' ) ; }

Get the container, queue or table name from address from the URI.

@param resourceAddress
The queue Uri.
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return container name from address from the URI.
@throws IllegalArgumentException

Get the container queue or table name from address from the URI .


public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris)
            throws URISyntaxException {
        final String containerName = getContainerNameFromUri(blobAddress.getPrimaryUri(), usePathStyleUris);

        final StorageUri containerUri = appendPathToUri(getServiceClientBaseAddress(blobAddress, usePathStyleUris),
                containerName);
        return containerUri;
    }

public static StorageUri getContainerURI ( final StorageUri blobAddress , final boolean usePathStyleUris ) throws URISyntaxException { final String containerName = getContainerNameFromUri ( blobAddress . getPrimaryUri ( ) , usePathStyleUris ) ; final StorageUri containerUri = appendPathToUri ( getServiceClientBaseAddress ( blobAddress , usePathStyleUris ) , containerName ) ; return containerUri ; }

Gets the container URI from a blob address

@param blobAddress
the blob address
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return the container URI from a blob address
@throws URISyntaxException


public static StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris)
            throws URISyntaxException {
        final String shareName = getShareNameFromUri(fileAddress.getPrimaryUri(), usePathStyleUris);

        final StorageUri shareUri = appendPathToUri(getServiceClientBaseAddress(fileAddress, usePathStyleUris),
                shareName);
        return shareUri;
    }

public static StorageUri getShareURI ( final StorageUri fileAddress , final boolean usePathStyleUris ) throws URISyntaxException { final String shareName = getShareNameFromUri ( fileAddress . getPrimaryUri ( ) , usePathStyleUris ) ; final StorageUri shareUri = appendPathToUri ( getServiceClientBaseAddress ( fileAddress , usePathStyleUris ) , shareName ) ; return shareUri ; }

Gets the share URI from a file address

@param fileAddress
the file address
@param usePathStyleUris
a value indicating if the address is a path style uri.
@return the share URI from a file address
@throws URISyntaxException


public static HashMap<String, String[]> parseQueryString(String parseString) throws StorageException {
        final HashMap<String, String[]> retVals = new HashMap<String, String[]>();
        if (Utility.isNullOrEmpty(parseString)) {
            return retVals;
        }

        // 1. Remove ? if present
        final int queryDex = parseString.indexOf("?");
        if (queryDex >= 0 && parseString.length() > 0) {
            parseString = parseString.substring(queryDex + 1);
        }

        // 2. split name value pairs by splitting on the 'c&' character
        final String[] valuePairs = parseString.contains("&") ? parseString.split("&") : parseString.split(";");

        // 3. for each field value pair parse into appropriate map entries
        for (int m = 0; m < valuePairs.length; m++) {
            final int equalDex = valuePairs[m].indexOf("=");

            if (equalDex < 0 || equalDex == valuePairs[m].length() - 1) {
                continue;
            }

            String key = valuePairs[m].substring(0, equalDex);
            String value = valuePairs[m].substring(equalDex + 1);

            key = Utility.safeDecode(key);
            value = Utility.safeDecode(value);

            // 3.1 add to map
            String[] values = retVals.get(key);

            if (values == null) {
                values = new String[] { value };
                if (!value.equals(Constants.EMPTY_STRING)) {
                    retVals.put(key, values);
                }
            }
            else if (!value.equals(Constants.EMPTY_STRING)) {
                final String[] newValues = new String[values.length + 1];
                for (int j = 0; j < values.length; j++) {
                    newValues[j] = values[j];
                }

                newValues[newValues.length] = value;
            }
        }

        return retVals;
    }

Parses a query string into a one to many hashmap.

@param parseString
the string to parse
@return a HashMap<String, String[]> of the key values.
@throws StorageException

Parses a query string into a one to many hashmap .


public static String generateSharedAccessSignatureHashForBlobAndFile(final SharedAccessPolicy policy,
            SharedAccessHeaders headers, final String accessPolicyIdentifier, final String resourceName,
            final IPRange ipRange, final SharedAccessProtocols protocols, final ServiceClient client)
            throws InvalidKeyException, StorageException {

        String stringToSign = generateSharedAccessSignatureStringToSign(
                policy, resourceName, ipRange, protocols, accessPolicyIdentifier);

        String cacheControl = null;
        String contentDisposition = null;
        String contentEncoding = null;
        String contentLanguage = null;
        String contentType = null;
        if (headers != null) {
            cacheControl = headers.getCacheControl();
            contentDisposition = headers.getContentDisposition();
            contentEncoding = headers.getContentEncoding();
            contentLanguage = headers.getContentLanguage();
            contentType = headers.getContentType();
        }

        stringToSign = String.format("%s\n%s\n%s\n%s\n%s\n%s", stringToSign,
                cacheControl == null ? Constants.EMPTY_STRING : cacheControl,
                contentDisposition == null ? Constants.EMPTY_STRING : contentDisposition,
                contentEncoding == null ? Constants.EMPTY_STRING : contentEncoding,
                contentLanguage == null ? Constants.EMPTY_STRING : contentLanguage,
                contentType == null ? Constants.EMPTY_STRING : contentType);

        return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
    }

Get the signature hash embedded inside the Shared Access Signature for the blob or file service.

@param policy
The shared access policy to hash.
@param headers
The optional header values to set for a blob or file accessed with this shared access signature.
@param accessPolicyIdentifier
An optional identifier for the policy.
@param resourceName
The resource name.
@param ipRange
The range of IP addresses to hash.
@param protocols
The Internet protocols to hash.
@param client
The ServiceClient associated with the object.

@return The signature hash embedded inside the Shared Access Signature.
@throws InvalidKeyException
@throws StorageException

Get the signature hash embedded inside the Shared Access Signature for the blob or file service .


public static String generateSharedAccessSignatureHashForQueue(
            final SharedAccessQueuePolicy policy, final String accessPolicyIdentifier, final String resourceName,
            final IPRange ipRange, final SharedAccessProtocols protocols, final ServiceClient client)
            throws InvalidKeyException, StorageException {

        final String stringToSign = generateSharedAccessSignatureStringToSign(
                policy, resourceName, ipRange, protocols, accessPolicyIdentifier);

        return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
    }

Get the signature hash embedded inside the Shared Access Signature for queue service.

@param policy
The shared access policy to hash.
@param accessPolicyIdentifier
An optional identifier for the policy.
@param resourceName
The resource name.
@param ipRange
The range of IP addresses to hash.
@param protocols
The Internet protocols to hash.
@param client
The ServiceClient associated with the object.

@return The signature hash embedded inside the Shared Access Signature.
@throws InvalidKeyException
@throws StorageException

Get the signature hash embedded inside the Shared Access Signature for queue service .


public static String generateSharedAccessSignatureHashForTable(
            final SharedAccessTablePolicy policy, final String accessPolicyIdentifier, final String resourceName,
            final IPRange ipRange, final SharedAccessProtocols protocols, final String startPartitionKey,
            final String startRowKey, final String endPartitionKey, final String endRowKey, final ServiceClient client)
            throws InvalidKeyException, StorageException {

        String stringToSign = generateSharedAccessSignatureStringToSign(
                policy, resourceName, ipRange, protocols, accessPolicyIdentifier);

        stringToSign = String.format("%s\n%s\n%s\n%s\n%s", stringToSign,
                startPartitionKey == null ? Constants.EMPTY_STRING : startPartitionKey,
                startRowKey == null ? Constants.EMPTY_STRING : startRowKey,
                endPartitionKey == null ? Constants.EMPTY_STRING : endPartitionKey,
                endRowKey == null ? Constants.EMPTY_STRING : endRowKey);

        return generateSharedAccessSignatureHashHelper(stringToSign, client.getCredentials());
    }

Get the signature hash embedded inside the Shared Access Signature for the table service.

@param policy
The shared access policy to hash.
@param accessPolicyIdentifier
An optional identifier for the policy.
@param resourceName
The resource name.
@param ipRange
The range of IP addresses to hash.
@param protocols
The Internet protocols to hash.
@param startPartitionKey
An optional restriction of the beginning of the range of partition keys to hash.
@param startRowKey
An optional restriction of the beginning of the range of row keys to hash.
@param endPartitionKey
An optional restriction of the end of the range of partition keys to hash.
@param endRowKey
An optional restriction of the end of the range of row keys to hash.
@param client
The ServiceClient associated with the object.

@return The signature hash embedded inside the Shared Access Signature.
@throws InvalidKeyException
@throws StorageException

Get the signature hash embedded inside the Shared Access Signature for the table service .


@DoesServiceRequest
    public void create(FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
        if (opContext == null) {
            opContext = new OperationContext();
        }

        this.getShare().assertNoSnapshot();

        opContext.initialize();
        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        ExecutionEngine.executeWithRetry(this.fileServiceClient, this, createDirectoryImpl(options),
                options.getRetryPolicyFactory(), opContext);
    }

@ DoesServiceRequest public void create ( FileRequestOptions options , OperationContext opContext ) throws StorageException , URISyntaxException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } this . getShare ( ) . assertNoSnapshot ( ) ; opContext . initialize ( ) ; options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; ExecutionEngine . executeWithRetry ( this . fileServiceClient , this , createDirectoryImpl ( options ) , options . getRetryPolicyFactory ( ) , opContext ) ; }

Creates the directory using the specified options and operation context.

@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Creates the directory using the specified options and operation context .


@DoesServiceRequest
    public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException {
        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        this.getShare().assertNoSnapshot();

        boolean exists = this.exists(true /* primaryOnly */, null /* accessCondition */, options, opContext);
        if (exists) {
            return false;
        }
        else {
            try {
                this.create(options, opContext);
                return true;
            }
            catch (StorageException e) {
                if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
                        && StorageErrorCodeStrings.RESOURCE_ALREADY_EXISTS.equals(e.getErrorCode())) {
                    return false;
                }
                else {
                    throw e;
                }
            }
        }
    }

@
DoesServiceRequest
public
boolean
createIfNotExists
(
FileRequestOptions
options
,
OperationContext
opContext
)
throws
StorageException
,
URISyntaxException
{
options
=
FileRequestOptions
.
populateAndApplyDefaults
(
options
,
this
.
fileServiceClient
)
;
this
.
getShare
(
)
.
assertNoSnapshot
(
)
;
boolean
exists
=
this
.
exists
(
true
/* primaryOnly */
,
/* accessCondition */
,
options
,
opContext
)
;
if
(
exists
)
{
return
false
;
}
else
{
try
{
this
.
create
(
options
,
opContext
)
;
return
true
;
}
catch
(
StorageException
e
)
{
if
(
e
.
getHttpStatusCode
(
)
==
HttpURLConnection
.
HTTP_CONFLICT
&&
StorageErrorCodeStrings
.
RESOURCE_ALREADY_EXISTS
.
equals
(
e
.
getErrorCode
(
)
)
)
{
return
false
;
}
else
{
throw
e
;
}
}
}
}

Creates the directory if it does not exist, using the specified request options and operation context.

@param options
A {@link FileRequestOptions} object that specifies any additional options for the request.
Specifying null will use the default request options from the associated service client
({@link CloudFileClient}).
@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 true if the directory did not already exist and was created; otherwise, false.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Creates the directory if it does not exist using the specified request options and operation context .


@DoesServiceRequest
    public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options,
            OperationContext opContext) throws StorageException, URISyntaxException {
        options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);

        boolean exists = this.exists(true /* primaryOnly */, accessCondition, options, opContext);
        if (exists) {
            try {
                this.delete(accessCondition, options, opContext);
                return true;
            }
            catch (StorageException e) {
                if (e.getHttpStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
                        && StorageErrorCodeStrings.RESOURCE_NOT_FOUND.equals(e.getErrorCode())) {
                    return false;
                }
                else {
                    throw e;
                }
            }
        }
        else {
            return false;
        }
    }

@
DoesServiceRequest
public
boolean
deleteIfExists
(
AccessCondition
accessCondition
,
FileRequestOptions
options
,
OperationContext
opContext
)
throws
StorageException
,
URISyntaxException
{
options
=
FileRequestOptions
.
populateAndApplyDefaults
(
options
,
this
.
fileServiceClient
)
;
boolean
exists
=
this
.
exists
(
true
/* primaryOnly */
,
accessCondition
,
options
,
opContext
)
;
if
(
exists
)
{
try
{
this
.
delete
(
accessCondition
,
options
,
opContext
)
;
return
true
;
}
catch
(
StorageException
e
)
{
if
(
e
.
getHttpStatusCode
(
)
==
HttpURLConnection
.
HTTP_NOT_FOUND
&&
StorageErrorCodeStrings
.
RESOURCE_NOT_FOUND
.
equals
(
e
.
getErrorCode
(
)
)
)
{
return
false
;
}
else
{
throw
e
;
}
}
}
else
{
return
false
;
}
}

Deletes the directory if it exists using the specified request options and operation context.

@param accessCondition
An {@link AccessCondition} object that represents the access conditions for the directory.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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 true if the directory existed and was deleted; otherwise, false.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException

Deletes the directory if it exists using the specified request options and operation context .


@DoesServiceRequest
    public boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
            throws StorageException {
        return this.exists(false, accessCondition, options, opContext);
    }

@ DoesServiceRequest public boolean exists ( final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException { return this . exists ( false , accessCondition , options , opContext ) ; }

Returns a value that indicates whether the directory exists, using the specified request options and operation
context.

@param accessCondition
An {@link AccessCondition} object that represents the access conditions for the share.
@param options
A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
null will use the default request options from the associated service client (
{@link CloudFileClient}).
@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 true if the directory exists, otherwise false.

@throws StorageException
If a storage service error occurred.

Returns a value that indicates whether the directory exists using the specified request options and operation context .


@DoesServiceRequest
    public ResultSegment<ListFileItem> listFilesAndDirectoriesSegmented() throws StorageException {
        return this.listFilesAndDirectoriesSegmented(null /* prefix */, null /* maxResults */,
                null /* continuationToken */, null /* options */, null /* opContext */);
    }

@
DoesServiceRequest
public
ResultSegment
<
ListFileItem
>
listFilesAndDirectoriesSegmented
(
)
throws
StorageException
{
return
this
.
listFilesAndDirectoriesSegmented
(
/* prefix */
,
/* maxResults */
,
/* continuationToken */
,
/* options */
,
/* opContext */
)
;
}

Returns a result segment of an enumerable collection of files and directories for this File service client.

@return A {@link ResultSegment} object that contains a segment of the enumerable collection of
{@link ListFileItem} objects that represent the files and directories.
@throws StorageException

Returns a result segment of an enumerable collection of files and directories for this File service client .


@Override
    public CloudFileShare getShare() throws StorageException, URISyntaxException {
        if (this.share == null) {
            this.share = this.fileServiceClient.getShareReference(PathUtility.getShareNameFromUri(this.getUri(),
                    this.fileServiceClient.isUsePathStyleUris()));
        }
        return this.share;
    }

@ Override public CloudFileShare getShare ( ) throws StorageException , URISyntaxException { if ( this . share == null ) { this . share = this . fileServiceClient . getShareReference ( PathUtility . getShareNameFromUri ( this . getUri ( ) , this . fileServiceClient . isUsePathStyleUris ( ) ) ) ; } return this . share ; }

Returns the share for this directory.

@return A {@link CloudFileShare} that represents the share for this directory.

@throws StorageException
If a storage service error occurred.
@throws URISyntaxException
If the resource URI is invalid.


public static HttpURLConnection clearMessages(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext) throws URISyntaxException, IOException, StorageException {
        return BaseRequest.delete(uri, queueOptions, null, opContext);
    }

public static HttpURLConnection clearMessages ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext ) throws URISyntaxException , IOException , StorageException { return BaseRequest . delete ( uri , queueOptions , null , opContext ) ; }

Constructs a web request to clear all the messages in the queue. Sign the
web request with a length of -1L.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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 An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to clear all the messages in the queue . Sign the web request with a length of - 1L .


public static HttpURLConnection deleteMessage(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext, final String popReceipt) throws URISyntaxException, IOException,
            StorageException {

        final UriQueryBuilder builder = new UriQueryBuilder();
        builder.add(POP_RECEIPT, popReceipt);

        final HttpURLConnection request = BaseRequest.delete(uri, queueOptions, builder, opContext);

        return request;
    }

public static HttpURLConnection deleteMessage ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext , final String popReceipt ) throws URISyntaxException , IOException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( POP_RECEIPT , popReceipt ) ; final HttpURLConnection request = BaseRequest . delete ( uri , queueOptions , builder , opContext ) ; return request ; }

Constructs a web request to delete a message from the queue. Sign the web
request with a length of -1L.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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.
@param popReceipt
A String that contains the pop receipt value
returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to
delete.
@return An HttpURLConnection configured for the specified
operation.

@throws URISyntaxException
If the URI is not valid.
@throws IOException
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to delete a message from the queue . Sign the web request with a length of - 1L .


public static HttpURLConnection downloadAttributes(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
        UriQueryBuilder builder = new UriQueryBuilder();

        builder.add(Constants.QueryConstants.COMPONENT, METADATA);
        final HttpURLConnection retConnection = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        retConnection.setRequestMethod(Constants.HTTP_HEAD);

        return retConnection;
    }

public static HttpURLConnection downloadAttributes ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( Constants . QueryConstants . COMPONENT , METADATA ) ; final HttpURLConnection retConnection = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; retConnection . setRequestMethod ( Constants . HTTP_HEAD ) ; return retConnection ; }

Constructs a web request to download user-defined metadata and the
approximate message count for the queue. Sign the web request with a
length of -1L.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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 An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to download user - defined metadata and the approximate message count for the queue . Sign the web request with a length of - 1L .


public static HttpURLConnection list(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext, final ListingContext listingContext,
            final QueueListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {
        final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext);

        if (detailsIncluded == QueueListingDetails.ALL || detailsIncluded == QueueListingDetails.METADATA) {
            builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
        }

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setRequestMethod(Constants.HTTP_GET);

        return request;
    }

public static HttpURLConnection list ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext , final ListingContext listingContext , final QueueListingDetails detailsIncluded ) throws URISyntaxException , IOException , StorageException { final UriQueryBuilder builder = BaseRequest . getListUriQueryBuilder ( listingContext ) ; if ( detailsIncluded == QueueListingDetails . ALL || detailsIncluded == QueueListingDetails . METADATA ) { builder . add ( Constants . QueryConstants . INCLUDE , Constants . QueryConstants . METADATA ) ; } final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setRequestMethod ( Constants . HTTP_GET ) ; return request ; }

Constructs a web request to return a listing of all queues in this
storage account. Sign the web request with a length of -1L.

@param uri
A URI object that specifies the absolute URI to
the storage account.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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.
@param listingContext
A {@link ListingContext} object that specifies parameters for
the listing operation, if any. May be null.
@param detailsIncluded
A {@link QueueListingDetails} object that specifies additional
details to return with the listing, if any. May be null.
@return An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to return a listing of all queues in this storage account . Sign the web request with a length of - 1L .


public static HttpURLConnection peekMessages(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext, final int numberOfMessages) throws URISyntaxException, IOException,
            StorageException {

        final UriQueryBuilder builder = new UriQueryBuilder();
        builder.add(PEEK_ONLY, "true");

        if (numberOfMessages != 0) {
            builder.add(NUMBER_OF_MESSAGES, Integer.toString(numberOfMessages));
        }

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setRequestMethod(Constants.HTTP_GET);

        return request;
    }

public static HttpURLConnection peekMessages ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext , final int numberOfMessages ) throws URISyntaxException , IOException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( PEEK_ONLY , "true" ) ; if ( numberOfMessages != 0 ) { builder . add ( NUMBER_OF_MESSAGES , Integer . toString ( numberOfMessages ) ) ; } final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setRequestMethod ( Constants . HTTP_GET ) ; return request ; }

Constructs a web request to retrieve a specified number of messages from
the front of the queue without changing their visibility. Sign the web
request with a length of -1L.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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.
@param numberOfMessages
A nonzero value that specifies the number of messages to
retrieve from the queue, up to a maximum of 32.
@return An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to retrieve a specified number of messages from the front of the queue without changing their visibility . Sign the web request with a length of - 1L .


public static HttpURLConnection retrieveMessages(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext, final int numberOfMessages, final int visibilityTimeoutInSeconds)
            throws URISyntaxException, IOException, StorageException {

        final UriQueryBuilder builder = new UriQueryBuilder();

        if (numberOfMessages != 0) {
            builder.add(NUMBER_OF_MESSAGES, Integer.toString(numberOfMessages));
        }

        builder.add(VISIBILITY_TIMEOUT, Integer.toString(visibilityTimeoutInSeconds));

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setRequestMethod("GET");

        return request;
    }

public static HttpURLConnection retrieveMessages ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext , final int numberOfMessages , final int visibilityTimeoutInSeconds ) throws URISyntaxException , IOException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; if ( numberOfMessages != 0 ) { builder . add ( NUMBER_OF_MESSAGES , Integer . toString ( numberOfMessages ) ) ; } builder . add ( VISIBILITY_TIMEOUT , Integer . toString ( visibilityTimeoutInSeconds ) ) ; final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setRequestMethod ( "GET" ) ; return request ; }

Constructs a web request to retrieve messages from the front of the
queue. Sign the web request with a length of -1L.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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.
@param numberOfMessages
A nonzero value that specifies the number of messages to
retrieve from the queue, up to a maximum of 32.
@param visibilityTimeoutInSeconds
Specifies the visibility timeout value in seconds, relative to
server time, to make the retrieved messages invisible until
the visibility timeout expires. The value must be larger than
or equal to 0, and cannot be larger than 7 days. The
visibility timeout of a message can be set to a value later
than the expiry time, which will prevent the message from
being retrieved again whether it is processed or not.
@return An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to retrieve messages from the front of the queue . Sign the web request with a length of - 1L .


public static HttpURLConnection updateMessage(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext, final String popReceipt, final int visibilityTimeoutInSeconds)
            throws URISyntaxException, IOException, StorageException {

        final UriQueryBuilder builder = new UriQueryBuilder();

        builder.add(POP_RECEIPT, popReceipt);

        builder.add(VISIBILITY_TIMEOUT, Integer.toString(visibilityTimeoutInSeconds));

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setDoOutput(true);
        request.setRequestMethod(Constants.HTTP_PUT);

        return request;
    }

public static HttpURLConnection updateMessage ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext , final String popReceipt , final int visibilityTimeoutInSeconds ) throws URISyntaxException , IOException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( POP_RECEIPT , popReceipt ) ; builder . add ( VISIBILITY_TIMEOUT , Integer . toString ( visibilityTimeoutInSeconds ) ) ; final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setDoOutput ( true ) ; request . setRequestMethod ( Constants . HTTP_PUT ) ; return request ; }

Constructs a web request to update the visibility timeout of a message in
the queue. Optionally updates the message content if a message request
body is written to the output stream of the web request. The web request
should be signed with the length of the encoded message request body if
one is included, or a length of 0 if no message request body is included.

@param uri
A URI object that specifies the absolute URI to
the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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.
@param popReceipt
A String that contains the pop receipt value
returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to
update.
@param visibilityTimeoutInSeconds
Specifies the new visibility timeout value in seconds,
relative to server time, to make the retrieved messages
invisible until the visibility timeout expires. The value must
be larger than or equal to 0, and cannot be larger than 7
days. The visibility timeout of a message can be set to a
value later than the expiry time, which will prevent the
message from being retrieved again whether it is processed or
not.
@return An HttpURLConnection configured for the specified
operation.

@throws IOException
@throws URISyntaxException
If the URI is not valid.
@throws StorageException
If a storage service error occurred during the operation.

Constructs a web request to update the visibility timeout of a message in the queue . Optionally updates the message content if a message request body is written to the output stream of the web request . The web request should be signed with the length of the encoded message request body if one is included or a length of 0 if no message request body is included .


public static HttpURLConnection setAcl(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
        final UriQueryBuilder builder = new UriQueryBuilder();
        builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setDoOutput(true);
        request.setRequestMethod(Constants.HTTP_PUT);

        return request;
    }

public static HttpURLConnection setAcl ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( Constants . QueryConstants . COMPONENT , Constants . QueryConstants . ACL ) ; final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setDoOutput ( true ) ; request . setRequestMethod ( Constants . HTTP_PUT ) ; return request ; }

Sets the ACL for the queue. Sign with length of aclBytes.

@param uri
The absolute URI to the queue.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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 HttpURLConnection configured for the operation.
@throws StorageException

Sets the ACL for the queue . Sign with length of aclBytes .


public static HttpURLConnection getAcl(final URI uri, final QueueRequestOptions queueOptions,
            final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
        final UriQueryBuilder builder = new UriQueryBuilder();
        builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);

        final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

        request.setRequestMethod(Constants.HTTP_GET);

        return request;
    }

public static HttpURLConnection getAcl ( final URI uri , final QueueRequestOptions queueOptions , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( Constants . QueryConstants . COMPONENT , Constants . QueryConstants . ACL ) ; final HttpURLConnection request = BaseRequest . createURLConnection ( uri , queueOptions , builder , opContext ) ; request . setRequestMethod ( Constants . HTTP_GET ) ; return request ; }

Constructs a web request to return the ACL for this queue. Sign with no length specified.

@param uri
The absolute URI to the container.
@param queueOptions
A {@link QueueRequestOptions} object that specifies execution options such as retry policy and timeout
settings for the operation. Specify null to use the request options specified on the
{@link CloudQueueClient}.
@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 HttpURLConnection configured for the operation.
@throws StorageException

Constructs a web request to return the ACL for this queue . Sign with no length specified .