Java Code Examples for com.microsoft.azure.storage.core.Utility#assertNotNullOrEmpty()
The following examples show how to use
com.microsoft.azure.storage.core.Utility#assertNotNullOrEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogRecord.java From azure-storage-android with Apache License 2.0 | 6 votes |
/** * Initializes a new instance of the LogRecord class using a LogRecordStreamReader to populate. * * @param reader * the LogRecordStreamReader to use to populate the LogRecord. * @throws IOException * @throws ParseException * @throws URISyntaxException */ protected LogRecord(LogRecordStreamReader reader) throws IOException, ParseException, URISyntaxException { LAST_MODIFIED_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); REQUEST_START_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); Utility.assertNotNull("reader", reader); this.versionNumber = reader.readString(); Utility.assertNotNullOrEmpty("versionNumber", this.versionNumber); if (this.versionNumber.equals("1.0")) { this.populateVersion1Log(reader); } else { throw new IllegalArgumentException(String.format(SR.LOG_VERSION_UNSUPPORTED, this.versionNumber)); } }
Example 2
Source File: CloudBlobDirectory.java From azure-storage-android with Apache License 2.0 | 5 votes |
/** * Returns a reference to a virtual blob directory beneath this directory. * * @param directoryName * A <code>String</code> that represents the name of the virtual subdirectory. * * @return A <code>CloudBlobDirectory</code> object that represents a virtual blob directory beneath this directory. * * @throws URISyntaxException * If the resource URI is invalid. */ public CloudBlobDirectory getDirectoryReference(String directoryName) throws URISyntaxException { Utility.assertNotNullOrEmpty("directoryName", directoryName); if (!directoryName.endsWith(this.blobServiceClient.getDirectoryDelimiter())) { directoryName = directoryName.concat(this.blobServiceClient.getDirectoryDelimiter()); } final String subDirName = this.getPrefix().concat(directoryName); final StorageUri address = PathUtility.appendPathToUri(this.storageUri, directoryName, this.blobServiceClient.getDirectoryDelimiter()); return new CloudBlobDirectory(address, subDirName, this.blobServiceClient, this.container, this); }
Example 3
Source File: CloudBlob.java From azure-storage-android with Apache License 2.0 | 4 votes |
/** * Retrieves the parent name for a blob URI. * * @param resourceAddress * A {@link StorageUri} object which represents the resource URI. * @param delimiter * A <code>String</code> which specifies the directory delimiter to use. * @param container * A {@link CloudBlobContainer} object which represents the blob container. * * @return A <code>String</code> which represents the parent address for a blob URI. * * @throws URISyntaxException */ protected static String getParentNameFromURI(final StorageUri resourceAddress, final String delimiter, final CloudBlobContainer container) throws URISyntaxException { Utility.assertNotNull("resourceAddress", resourceAddress); Utility.assertNotNull("container", container); Utility.assertNotNullOrEmpty("delimiter", delimiter); String containerName = container.getName() + "/"; String relativeURIString = Utility.safeRelativize(container.getStorageUri().getPrimaryUri(), resourceAddress.getPrimaryUri()); if (relativeURIString.endsWith(delimiter)) { relativeURIString = relativeURIString.substring(0, relativeURIString.length() - delimiter.length()); } String parentName; if (Utility.isNullOrEmpty(relativeURIString)) { // Case 1 /<ContainerName>[Delimiter]*? => /<ContainerName> // Parent of container is container itself parentName = null; } else { final int lastDelimiterDex = relativeURIString.lastIndexOf(delimiter); if (lastDelimiterDex < 0) { // Case 2 /<Container>/<folder> // Parent of a folder is container parentName = ""; } else { // Case 3 /<Container>/<folder>/[<subfolder>/]*<BlobName> // Parent of blob is folder parentName = relativeURIString.substring(0, lastDelimiterDex + delimiter.length()); if (parentName != null && parentName.equals(containerName)) { parentName = ""; } } } return parentName; }
Example 4
Source File: CloudBlob.java From azure-storage-android with Apache License 2.0 | 3 votes |
/** * Creates an instance of the <code>CloudBlob</code> class using the specified type, name, snapshot ID, and * container. * * @param type * A {@link BlobType} value which represents the type of the blob. * @param blobName * Name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot version, if applicable. * @param container * The reference to the parent container. * @throws URISyntaxException * If the resource URI is invalid. */ protected CloudBlob(final BlobType type, String blobName, String snapshotID, CloudBlobContainer container) throws URISyntaxException { Utility.assertNotNullOrEmpty("blobName", blobName); Utility.assertNotNull("container", container); this.storageUri = PathUtility.appendPathToUri(container.getStorageUri(), blobName); this.name = blobName; this.blobServiceClient = container.getServiceClient(); this.container = container; this.snapshotID = snapshotID; this.properties = new BlobProperties(type); }
Example 5
Source File: CloudFileDirectory.java From azure-storage-android with Apache License 2.0 | 3 votes |
/** * Returns a reference to a {@link CloudFile} object that represents a file in this directory. * * @param fileName * A <code>String</code> that represents the name of the file. * * @return A {@link CloudFile} object that represents a reference to the specified file. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudFile getFileReference(final String fileName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("fileName", fileName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, fileName); return new CloudFile(subdirectoryUri, fileName, this.getShare()); }
Example 6
Source File: CloudFileDirectory.java From azure-storage-android with Apache License 2.0 | 3 votes |
/** * Returns a reference to a {@link CloudFileDirectory} object that represents a directory in this directory. * * @param itemName * A <code>String</code> that represents the name of the directory. * * @return A {@link CloudFileDirectory} object that represents a reference to the specified directory. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException */ public CloudFileDirectory getDirectoryReference(final String itemName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("itemName", itemName); StorageUri subdirectoryUri = PathUtility.appendPathToUri(this.storageUri, itemName); return new CloudFileDirectory(subdirectoryUri, itemName, this.getShare()); }
Example 7
Source File: TableBatchOperation.java From azure-storage-android with Apache License 2.0 | 3 votes |
/** * Reserved for internal use. Executes this batch operation on the specified table, using the specified * {@link TableRequestOptions} and {@link OperationContext}. * <p> * This method will invoke the Storage Service REST API to execute this batch operation, using the Table service * endpoint and storage account credentials in the {@link CloudTableClient} object. * * @param client * A {@link CloudTableClient} instance specifying the Table service endpoint and storage account * credentials to use. * @param tableName * A <code>String</code> containing the name of the table. * @param options * A {@link TableRequestOptions} object that specifies execution options such as retry policy and timeout * settings for the operation. * @param opContext * An {@link OperationContext} object for tracking the current operation. * * @return * An <code>ArrayList</code> of {@link TableResult} containing the results of executing the operation. * * @throws StorageException * if an error occurs in the storage operation. */ protected ArrayList<TableResult> execute(final CloudTableClient client, final String tableName, final TableRequestOptions options, final OperationContext opContext) throws StorageException { Utility.assertNotNullOrEmpty(TableConstants.TABLE_NAME, tableName); if (this.size() == 0) { throw new IllegalArgumentException(SR.EMPTY_BATCH_NOT_ALLOWED); } return ExecutionEngine.executeWithRetry(client, this, this.executeImpl(client, tableName, options, opContext), options.getRetryPolicyFactory(), opContext); }
Example 8
Source File: CloudFileClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Gets a {@link CloudFileShare} object with the specified name. * * @param shareName * The name of the share, which must adhere to share naming rules. The share name should not * include any path separator characters (/). * Share names must be lowercase, between 3-63 characters long and must start with a letter or * number. Share names may contain only letters, numbers, and the dash (-) character. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the share. * @return A reference to a {@link CloudFileShare} object. * @throws StorageException * @throws URISyntaxException * * @see <a href="http://msdn.microsoft.com/en-us/library/azure/dn167011.aspx">Naming and Referencing Shares, * Directories, Files, and Metadata</a> */ public CloudFileShare getShareReference(final String shareName, String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("shareName", shareName); return new CloudFileShare(shareName, snapshotID, this); }
Example 9
Source File: TableOperation.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * A static factory method returning a {@link TableOperation} instance to replace the specified table entity. To * execute this {@link TableOperation} on a given table, call the * {@link CloudTable#execute(TableOperation)} method. * * @param entity * The object instance implementing {@link TableEntity} to associate with the operation. * @return * A new {@link TableOperation} instance for replacing the table entity. */ public static TableOperation replace(final TableEntity entity) { Utility.assertNotNullOrEmpty("entity etag", entity.getEtag()); return new TableOperation(entity, TableOperationType.REPLACE); }
Example 10
Source File: TableOperation.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * A static factory method returning a {@link TableOperation} instance to merge the specified table entity into * Microsoft Azure storage. To execute this {@link TableOperation} on a given table, call the * {@link CloudTable#execute(TableOperation)} method on a {@link CloudTableClient} instance with the * * @param entity * The object instance implementing {@link TableEntity} to associate with the operation. * @return * A new {@link TableOperation} instance for merging the table entity. */ public static TableOperation merge(final TableEntity entity) { Utility.assertNotNull("entity", entity); Utility.assertNotNullOrEmpty("entity etag", entity.getEtag()); return new TableOperation(entity, TableOperationType.MERGE); }
Example 11
Source File: TableOperation.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * A static factory method returning a {@link TableOperation} instance to delete the specified entity from Microsoft * Azure storage. To execute this {@link TableOperation} on a given table, call the * {@link CloudTable#execute(TableOperation)} method on a {@link CloudTableClient} instance with the * * @param entity * The object instance implementing {@link TableEntity} to associate with the operation. * @return * A new {@link TableOperation} instance to insert the table entity. */ public static TableOperation delete(final TableEntity entity) { Utility.assertNotNull("entity", entity); Utility.assertNotNullOrEmpty("entity etag", entity.getEtag()); return new TableOperation(entity, TableOperationType.DELETE); }
Example 12
Source File: TableQuery.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Sets the name of the source table for the table query. A table query must have a source table to be executed. * * @param sourceTableName * A <code>String</code> which specifies the name of the source table to use in the query. */ protected void setSourceTableName(final String sourceTableName) { Utility.assertNotNullOrEmpty("tableName", sourceTableName); this.sourceTableName = sourceTableName; }
Example 13
Source File: TableQuery.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Sets the filter expression to use in the table query. A filter expression is optional; by default a table query * will return all entities in the table. * <p> * Filter expressions for use with the {@link #setFilterString} method can be created using fluent syntax with the * overloaded {@link #generateFilterCondition} methods and {@link #combineFilters} method, using the comparison * operators defined in {@link QueryComparisons} and the logical operators defined in {@link Operators}. Note that * the first operand in a filter comparison must be a property name, and the second operand must evaluate to a * constant. The PartitionKey and RowKey property values are <code>String</code> types for comparison purposes. For * example, to query all entities with a PartitionKey value of "AccessLogs" on table query <code>myQuery</code>: * <p> * <code>    myQuery.setFilterString("PartitionKey eq 'AccessLogs'");</code> * <p> * The values that may be used in table queries are explained in more detail in the MSDN topic * * <a href="http://msdn.microsoft.com/en-us/library/azure/dd894031.aspx">Querying Tables and Entities</a>, but note * that the space characters within values do not need to be URL-encoded, as this will be done when the query is * executed. * <p> * Note that no more than 15 discrete comparisons are permitted within a filter string. * * @param filterString * A <code>String</code> which represents the filter expression to use in the query. */ public void setFilterString(final String filterString) { Utility.assertNotNullOrEmpty("filterString", filterString); this.filterString = filterString; }
Example 14
Source File: CloudFileClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Gets a {@link CloudFileShare} object with the specified name. * * @param shareName * The name of the share, which must adhere to share naming rules. The share name should not * include any path separator characters (/). * Share names must be lowercase, between 3-63 characters long and must start with a letter or * number. Share names may contain only letters, numbers, and the dash (-) character. * * @return A reference to a {@link CloudFileShare} object. * @throws StorageException * @throws URISyntaxException * * @see <a href="http://msdn.microsoft.com/en-us/library/azure/dn167011.aspx">Naming and Referencing Shares, * Directories, Files, and Metadata</a> */ public CloudFileShare getShareReference(final String shareName) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("shareName", shareName); return this.getShareReference(shareName, null); }
Example 15
Source File: CloudBlobClient.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Sets the value for the default delimiter used for cloud blob directories. * * @param directoryDelimiter * A <code>String</code> that specifies the value for the default directory delimiter. */ public void setDirectoryDelimiter(final String directoryDelimiter) { Utility.assertNotNullOrEmpty("directoryDelimiter", directoryDelimiter); this.directoryDelimiter = directoryDelimiter; }
Example 16
Source File: CloudBlobDirectory.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudPageBlob getPageBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudPageBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
Example 17
Source File: CloudBlobDirectory.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudBlockBlob getBlockBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudBlockBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }
Example 18
Source File: CloudBlobDirectory.java From azure-storage-android with Apache License 2.0 | 2 votes |
/** * Returns a reference to a {@link CloudAppendBlob} object that represents an append blob in the directory, using the * specified snapshot ID. * * @param blobName * A <code>String</code> that represents the name of the blob. * @param snapshotID * A <code>String</code> that represents the snapshot ID of the blob. * * @return A {@link CloudAppendBlob} object that represents a reference to the specified append blob. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public CloudAppendBlob getAppendBlobReference(final String blobName, final String snapshotID) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobName", blobName); return new CloudAppendBlob(this.getPrefix().concat(blobName), snapshotID, this.getContainer()); }