• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StorageErrorCodeStrings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testBatchOver100Entities

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
@Test
public void testBatchOver100Entities() throws StorageException {
    TableRequestOptions options = new TableRequestOptions();
    options.setTablePayloadFormat(TablePayloadFormat.Json);

    TableBatchOperation batch = new TableBatchOperation();
    try {
        for (int m = 0; m < 101; m++) {
            batch.insert(TableTestHelper.generateRandomEntity("jxscl_odata"));
        }

        this.table.execute(batch, options, null);
        fail("Batch with over 100 entities should fail.");
    }
    catch (TableServiceException ex) {
        assertEquals(ex.getMessage(), "Bad Request");
        String errorAfterSemiColon = ex.getExtendedErrorInformation().getErrorMessage();
        errorAfterSemiColon = errorAfterSemiColon.substring(errorAfterSemiColon.indexOf(":") + 1);
        assertTrue(errorAfterSemiColon.startsWith("The batch request operation exceeds the maximum 100 changes per change set."));
        assertEquals(ex.getErrorCode(), StorageErrorCodeStrings.INVALID_INPUT);
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:23,代码来源:TableBatchOperationTests.java


示例17: testBatchInsertFail

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
@Test
public void testBatchInsertFail() throws StorageException {
    TableRequestOptions options = new TableRequestOptions();
    options.setTablePayloadFormat(TablePayloadFormat.Json);

    // insert entity
    Class1 ref = TableTestHelper.generateRandomEntity("jxscl_odata");
    this.table.execute(TableOperation.insert(ref), options, null);
    try {
        TableBatchOperation batch = new TableBatchOperation();
        batch.insert(ref);
        this.table.execute(batch, options, null);
        fail();
    }
    catch (TableServiceException ex) {
        assertEquals(ex.getMessage(), "Conflict");
        assertTrue(ex.getExtendedErrorInformation().getErrorMessage()
                .startsWith("The specified entity already exists"));
        assertEquals(ex.getErrorCode(), StorageErrorCodeStrings.ENTITY_ALREADY_EXISTS);
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:22,代码来源:TableBatchOperationTests.java


示例18: 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.populateAndApplyDefaults(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:Azure,项目名称:azure-storage-android,代码行数:45,代码来源:CloudBlobContainer.java


示例19: assertCorrectBlobType

import com.microsoft.azure.storage.StorageErrorCodeStrings; //导入依赖的package包/类
/**
 * Asserts that the blob has the correct blob type specified in the blob attributes.
 *
 * @throws StorageException
 *             If an incorrect blob type is used.
 */
protected final void assertCorrectBlobType() throws StorageException {
    if (this instanceof CloudBlockBlob && this.properties.getBlobType() != BlobType.BLOCK_BLOB) {
        throw new StorageException(StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, String.format(SR.INVALID_BLOB_TYPE,
                BlobType.BLOCK_BLOB, this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306,
                null, null);
    } 
    else if (this instanceof CloudPageBlob && this.properties.getBlobType() != BlobType.PAGE_BLOB) {
        throw new StorageException(StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, String.format(SR.INVALID_BLOB_TYPE,
                BlobType.PAGE_BLOB, this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306,
                null, null);
    } 
    else if (this instanceof CloudAppendBlob && this.properties.getBlobType() != BlobType.APPEND_BLOB) {
        throw new StorageException(StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, String.format(SR.INVALID_BLOB_TYPE,
                BlobType.APPEND_BLOB, this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306,
                null, null);
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:24,代码来源:CloudBlob.java


示例20: 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.
 * @throws URISyntaxException 
 */
@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;
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:46,代码来源:CloudFileDirectory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleVectorValueChecker类代码示例发布时间:2022-05-23
下一篇:
Java KrbLoginManagerFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap