当前位置: 首页>>代码示例>>Java>>正文


Java StorageErrorCodeStrings类代码示例

本文整理汇总了Java中com.microsoft.azure.storage.StorageErrorCodeStrings的典型用法代码示例。如果您正苦于以下问题:Java StorageErrorCodeStrings类的具体用法?Java StorageErrorCodeStrings怎么用?Java StorageErrorCodeStrings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StorageErrorCodeStrings类属于com.microsoft.azure.storage包,在下文中一共展示了StorageErrorCodeStrings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTableAfterDeletion

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * This method create a table after it's deletion.<br/>
 * the table deletion take about 40 seconds to be effective on azure CF.
 * https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Table#Remarks <br/>
 * So we try to wait 50 seconds if the first table creation return an
 * {@link StorageErrorCodeStrings.TABLE_BEING_DELETED } exception code
 * 
 * @param cloudTable
 * 
 * @throws StorageException
 * @throws IOException
 * 
 */
private void createTableAfterDeletion(CloudTable cloudTable) throws StorageException, IOException {
    try {
        cloudTable.create();
    } catch (TableServiceException e) {
        if (!e.getErrorCode().equals(StorageErrorCodeStrings.TABLE_BEING_DELETED)) {
            throw e;
        }
        LOGGER.warn("Table '{}' is currently being deleted. We'll retry in a few moments...", cloudTable.getName());
        // wait 50 seconds (min is 40s) before retrying.
        // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Table#Remarks
        try {
            Thread.sleep(50000);
        } catch (InterruptedException eint) {
            throw new IOException("Wait process for recreating table interrupted.");
        }
        cloudTable.create();
        LOGGER.debug("Table {} created.", cloudTable.getName());
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:33,代码来源:AzureStorageTableService.java

示例2: createQueueIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * This method create a queue if it doesn't exist
 */
public boolean createQueueIfNotExists(String queueName) throws InvalidKeyException, URISyntaxException, StorageException {
    CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
    CloudQueue queueRef = client.getQueueReference(queueName);
    boolean creationResult;
    try {
        creationResult = queueRef.createIfNotExists();
    } catch (StorageException e) {
        if (!e.getErrorCode().equals(StorageErrorCodeStrings.QUEUE_BEING_DELETED)) {
            throw e;
        }
        LOGGER.warn(messages.getMessage("error.QueueDeleted", queueRef.getName()));
        // Documentation doesn't specify how many seconds at least to wait.
        // 40 seconds before retrying.
        // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-queue3
        try {
            Thread.sleep(40000);
        } catch (InterruptedException eint) {
            throw new RuntimeException(messages.getMessage("error.InterruptedException"));
        }
        creationResult = queueRef.createIfNotExists();
        LOGGER.debug(messages.getMessage("debug.QueueCreated", queueRef.getName()));
    }

    return creationResult;
}
 
开发者ID:Talend,项目名称:components,代码行数:29,代码来源:AzureStorageQueueService.java

示例3: createIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Creates the container if it does not exist, using the specified request options and operation context.
 * 
 * @param options
 *            A {@link BlobRequestOptions} object that specifies any additional options for the request.
 *            Specifying <code>null</code> 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 <code>true</code> if the container did not already exist and was created; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean createIfNotExists(BlobRequestOptions options, OperationContext opContext) throws StorageException {
    options = BlobRequestOptions.applyDefaults(options, BlobType.UNSPECIFIED, this.blobServiceClient);

    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.CONTAINER_ALREADY_EXISTS.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:42,代码来源:CloudBlobContainer.java

示例4: deleteIfExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Deletes the container if it exists using the specified request options and operation context.
 * 
 * @param accessCondition
 *            An {@link AccessCondition} object that represents the access conditions for the container.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> 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 <code>true</code> if the container existed and was deleted; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean deleteIfExists(AccessCondition accessCondition, BlobRequestOptions options,
        OperationContext opContext) throws StorageException {
    options = BlobRequestOptions.applyDefaults(options, BlobType.UNSPECIFIED, this.blobServiceClient);

    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.CONTAINER_NOT_FOUND.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
    else {
        return false;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:45,代码来源:CloudBlobContainer.java

示例5: createIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * 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 <code>null</code> 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 <code>true</code> if the directory did not already exist and was created; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException {
    options = FileRequestOptions.applyDefaults(options, this.fileServiceClient);

    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;
            }
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:42,代码来源:CloudFileDirectory.java

示例6: deleteIfExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * 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
 *            <code>null</code> 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 <code>true</code> if the directory existed and was deleted; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options,
        OperationContext opContext) throws StorageException {
    options = FileRequestOptions.applyDefaults(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;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:45,代码来源:CloudFileDirectory.java

示例7: createIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Creates the share 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 <code>null</code> 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 <code>true</code> if the share did not already exist and was created; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException {
    options = FileRequestOptions.applyDefaults(options, this.fileServiceClient);

    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.SHARE_ALREADY_EXISTS.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:42,代码来源:CloudFileShare.java

示例8: deleteIfExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Deletes the share if it 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
 *            <code>null</code> 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 <code>true</code> if the share existed and was deleted; otherwise, <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 */
@DoesServiceRequest
public boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options,
        OperationContext opContext) throws StorageException {
    options = FileRequestOptions.applyDefaults(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.SHARE_NOT_FOUND.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
    else {
        return false;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:45,代码来源:CloudFileShare.java

示例9: createIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Creates the table in the storage service with the specified request options and operation context, if it does not
 * already exist.
 *
 * @param options
 *            A {@link TableRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@link CloudTableClient}).
 * @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 <code>true</code> if the table did not already exist and was created; otherwise <code>false</code> .
 *
 * @throws StorageException
 *             If a storage service error occurred during the operation.
 */
@DoesServiceRequest
public boolean createIfNotExists(TableRequestOptions options, OperationContext opContext) throws StorageException {
    options = TableRequestOptions.applyDefaults(options, this.tableServiceClient);

    boolean exists = this.exists(true, options, opContext);
    if (exists) {
        return false;
    }
    else {
        try {
            this.create(options, opContext);
            return true;
        }
        catch (StorageException e) {
            if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
                    && StorageErrorCodeStrings.TABLE_ALREADY_EXISTS.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:43,代码来源:CloudTable.java

示例10: deleteIfExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Deletes the table from the storage service using the specified request options and operation context, if it
 * exists.
 *
 * @param options
 *            A {@link TableRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@link CloudTableClient}).
 * @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 value of <code>true</code> if the table existed in the storage service and has been deleted, otherwise
 *         <code>false</code>.
 *
 * @throws StorageException
 *             If a storage service error occurred during the operation.
 */
@DoesServiceRequest
public boolean deleteIfExists(TableRequestOptions options, OperationContext opContext) throws StorageException {
    options = TableRequestOptions.applyDefaults(options, this.tableServiceClient);

    if (this.exists(true, options, opContext)) {
        try {
            this.delete(options, opContext);
        }
        catch (StorageException ex) {
            if (ex.getHttpStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
                    && StorageErrorCodeStrings.RESOURCE_NOT_FOUND.equals(ex.getErrorCode())) {
                return false;
            }
            else {
                throw ex;
            }
        }
        return true;
    }
    else {
        return false;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:43,代码来源:CloudTable.java

示例11: createIfNotExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Creates the queue if it does not already exist, using the specified request options and operation context.
 * 
 * @param options
 *            A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@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 value of <code>true</code> if the queue is created in the storage service, otherwise <code>false</code>
 *         .
 * 
 * @throws StorageException
 *             If a storage service error occurred during the operation.
 */
@DoesServiceRequest
public boolean createIfNotExists(QueueRequestOptions options, OperationContext opContext) throws StorageException {
    options = QueueRequestOptions.applyDefaults(options, this.queueServiceClient);

    boolean exists = this.exists(true, options, opContext);
    if (exists) {
        return false;
    }
    else {
        try {
            this.create(options, opContext);
            return true;
        }
        catch (StorageException e) {
            if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
                    && StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS.equals(e.getErrorCode())) {
                return false;
            }
            else {
                throw e;
            }
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:43,代码来源:CloudQueue.java

示例12: deleteIfExists

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Deletes the queue if it exists, using the specified request options and operation context.
 * 
 * @param options
 *            A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying
 *            <code>null</code> will use the default request options from the associated service client (
 *            {@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 value of <code>true</code> if the queue existed in the storage service and has been deleted, otherwise
 *         <code>false</code>.
 * 
 * @throws StorageException
 *             If a storage service error occurred during the operation.
 */
@DoesServiceRequest
public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException {
    options = QueueRequestOptions.applyDefaults(options, this.queueServiceClient);

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

    }
    else {
        return false;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:44,代码来源:CloudQueue.java

示例13: getRemainingTimeout

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Returns a value representing the remaining time before the operation expires. 0 represents an infinite timeout.
 * 
 * @param operationExpiryTimeInMs
 *            the time the request expires
 * @return the remaining time before the operation expires, or 0 to represent an infinite timeout
 * @throws StorageException
 *             wraps a TimeoutException if there is no more time remaining
 */
public static int getRemainingTimeout(Long operationExpiryTimeInMs) throws StorageException {
    if (operationExpiryTimeInMs != null) {
        long remainingTime = operationExpiryTimeInMs - new Date().getTime();
        if (remainingTime > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        }
        else if (remainingTime > 0) {
            return (int) remainingTime;
        }
        else {
            TimeoutException timeoutException = new TimeoutException(SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION);
            StorageException translatedException = new StorageException(
                    StorageErrorCodeStrings.OPERATION_TIMED_OUT, SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION,
                    Constants.HeaderConstants.HTTP_UNUSED_306, null, timeoutException);
            throw translatedException;
        }
    }
    else {
        // represents an infinite timeout
        return 0;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:32,代码来源:Utility.java

示例14: testBlobLeaseAcquireAndRelease

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
@Test
public void testBlobLeaseAcquireAndRelease() throws URISyntaxException, StorageException, IOException {
    final int length = 128;
    final CloudBlob blobRef = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, "test", 128, null);

    // Get Lease 
    OperationContext operationContext = new OperationContext();
    final String leaseID = blobRef.acquireLease(15, null /*proposed lease id */, null /*access condition*/,
            null/* BlobRequestOptions */, operationContext);
    final AccessCondition leaseCondition = AccessCondition.generateLeaseCondition(leaseID);
    assertTrue(operationContext.getLastResult().getStatusCode() == HttpURLConnection.HTTP_CREATED);

    tryUploadWithBadLease(length, blobRef, null, StorageErrorCodeStrings.LEASE_ID_MISSING);

    // Try to upload with lease
    blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition, null, null);

    // Release lease
    blobRef.releaseLease(leaseCondition);

    // now upload with no lease specified.
    blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1);
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:24,代码来源:LeaseTests.java

示例15: testDeleteShareSnapshotOptions

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
@Test
public void testDeleteShareSnapshotOptions() throws StorageException, URISyntaxException, IOException {
    // create share with metadata
    this.share.create();
    assertTrue(this.share.exists());

    // verify that exists() call on snapshot populates metadata
    CloudFileShare snapshot = this.share.createSnapshot();
    CloudFileClient client = FileTestHelper.createCloudFileClient();
    CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
    assertTrue(snapshotRef.exists());

    try {
        share.delete();
    }
    catch (final StorageException e) {
        assertEquals(StorageErrorCodeStrings.SHARE_HAS_SNAPSHOTS, e.getErrorCode());
    }
    
    share.delete(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
    assertFalse(share.exists());
    assertFalse(snapshot.exists());
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:24,代码来源:CloudFileShareTests.java


注:本文中的com.microsoft.azure.storage.StorageErrorCodeStrings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。