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


Java CloudTable.deleteIfExists方法代码示例

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


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

示例1: handleActionOnTable

import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
public void handleActionOnTable(String tableName, ActionOnTable actionTable)
        throws IOException, StorageException, InvalidKeyException, URISyntaxException {

    // FIXME How does this will behave in a distributed runtime ? See where to place correctly this
    // instruction...
    CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName);
    switch (actionTable) {
    case Create_table:
        cloudTable.create();
        break;
    case Create_table_if_does_not_exist:
        cloudTable.createIfNotExists();
        break;
    case Drop_and_create_table:
        cloudTable.delete();
        createTableAfterDeletion(cloudTable);
        break;
    case Drop_table_if_exist_and_create:
        cloudTable.deleteIfExists();
        createTableAfterDeletion(cloudTable);
        break;
    case Default:
    default:
        return;
    }

}
 
开发者ID:Talend,项目名称:components,代码行数:28,代码来源:AzureStorageTableService.java

示例2: tableAcl

import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
/**
 * Manage table access properties
 * @param tableClient Azure Storage Table Service
 */
private void tableAcl(CloudTableClient tableClient) throws StorageException, URISyntaxException, InterruptedException {
    // Get a reference to a table
    // The table name must be lower case
    CloudTable table = tableClient.getTableReference("table"
            + UUID.randomUUID().toString().replace("-", ""));

    try {
        // Create the table
        System.out.println("Create table");
        table.createIfNotExists();

        // Get permissions
        TablePermissions permissions = table.downloadPermissions();

        System.out.println("Set table permissions");
        final Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        cal.add(Calendar.MINUTE, -30);
        final Date start = cal.getTime();
        cal.add(Calendar.MINUTE, 30);
        final Date expiry = cal.getTime();

        SharedAccessTablePolicy policy = new SharedAccessTablePolicy();
        policy.setPermissions(EnumSet.of(SharedAccessTablePermissions.ADD, SharedAccessTablePermissions.DELETE, SharedAccessTablePermissions.UPDATE));
        policy.setSharedAccessStartTime(start);
        policy.setSharedAccessExpiryTime(expiry);
        permissions.getSharedAccessPolicies().put("key1", policy);

        // Set table permissions
        table.uploadPermissions(permissions);
        Thread.sleep(30000);

        System.out.println("Get table permissions");
        // Get table permissions
        permissions = table.downloadPermissions();

        HashMap<String, SharedAccessTablePolicy> accessPolicies = permissions.getSharedAccessPolicies();
        Iterator it = accessPolicies.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            SharedAccessTablePolicy value = (SharedAccessTablePolicy) pair.getValue();
            System.out.printf(" %s: %n", pair.getKey());
            System.out.printf("  Permissions: %s%n", value.permissionsToString());
            System.out.printf("  Start: %s%n", value.getSharedAccessStartTime());
            System.out.printf("  Expiry: %s%n", value.getSharedAccessStartTime());
            it.remove();
        }

        System.out.println("Clear table permissions");
        // Clear permissions
        permissions.getSharedAccessPolicies().clear();
        table.uploadPermissions(permissions);
    }
    finally {
        // Delete the table
        System.out.println("Delete table");
        table.deleteIfExists();
    }
}
 
开发者ID:Azure-Samples,项目名称:storage-table-java-getting-started,代码行数:63,代码来源:TableAdvanced.java

示例3: main

import com.microsoft.azure.storage.table.CloudTable; //导入方法依赖的package包/类
public static void main(String[] args) throws URISyntaxException,
        StorageException, InvalidKeyException, NoSuchAlgorithmException {
    Utility.printSampleStartInfo("TableResolverAttributes");

    // Retrieve storage account information from connection string
    // How to create a storage connection string -
    // https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/
    CloudStorageAccount storageAccount = CloudStorageAccount
            .parse(Utility.storageConnectionString);
    CloudTableClient client = storageAccount.createCloudTableClient();
    CloudTable table = client.getTableReference("encryptiontableattributes"
            + UUID.randomUUID().toString().replace("-", ""));

    try {
        table.createIfNotExists();

        // Create the IKey used for encryption.
        RsaKey key = new RsaKey("private:key1");

        EncryptedEntity ent = new EncryptedEntity(UUID.randomUUID()
                .toString(), String.valueOf(new Date().getTime()));
        ent.Populate();

        TableRequestOptions insertOptions = new TableRequestOptions();
        insertOptions.setEncryptionPolicy(new TableEncryptionPolicy(key,
                null));

        // Insert Entity
        System.out.println("Inserting the encrypted entity.");
        table.execute(TableOperation.insert(ent), insertOptions, null);

        // For retrieves, a resolver can be set up that will help pick the
        // key based on the key id.
        LocalResolver resolver = new LocalResolver();
        resolver.add(key);

        TableRequestOptions retrieveOptions = new TableRequestOptions();
        retrieveOptions.setEncryptionPolicy(new TableEncryptionPolicy(null,
                resolver));

        // Retrieve Entity
        System.out.println("Retrieving the encrypted entity.");
        TableOperation operation = TableOperation.retrieve(
                ent.getPartitionKey(), ent.getRowKey(),
                EncryptedEntity.class);
        TableResult result = table
                .execute(operation, retrieveOptions, null);
        EncryptedEntity resultEntity = result.getResultAsType();
        System.out.println("EncryptedProperty2 = "
                + resultEntity.getEncryptedProperty2());
    } finally {
        table.deleteIfExists();
        Utility.printSampleCompleteInfo("TableResolverAttributes");
    }
}
 
开发者ID:Azure,项目名称:azure-storage-java,代码行数:56,代码来源:TableGettingStartedAttributes.java


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