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


Java StorageException类代码示例

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


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

示例1: delete

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public void delete(String blobName) throws UnableToDeleteException, FileNotFoundException {
	log.debug(LOGGER_KEY + "-- Delete --" + _exchangeType);
	CloudBlockBlob deleteBlob = null;
	try {
		deleteBlob = this.mBlobContainer.getBlockBlobReference(blobName);
		if (this.config.getPostProcess().equalsIgnoreCase(PluginConstants.POST_PROCESS_DELETE)) {
			boolean status = deleteBlob.deleteIfExists();
			log.info(LOGGER_KEY + "Post processing Status (delete): " + status);
		} else {
			log.info(LOGGER_KEY + "Post processing skipped: " + this.config.getPostProcess());
		}
	} catch (URISyntaxException | StorageException e) {
		log.error(LOGGER_KEY + e.getMessage());
		throw new UnableToDeleteException("Unable to Delete Source Blob [" + blobName + "]" + e.getMessage(), e);
	}
}
 
开发者ID:cmanda,项目名称:axway-b2b-plugins,代码行数:18,代码来源:AzureBlobPluggableTransport.java

示例2: moveBlob

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public void moveBlob(String account, LocationMode mode, String container, String sourceBlob, String targetBlob) throws URISyntaxException, StorageException {
    logger.debug("moveBlob container [{}], sourceBlob [{}], targetBlob [{}]", container, sourceBlob, targetBlob);

    CloudBlobClient client = this.getSelectedClient(account, mode);
    CloudBlobContainer blobContainer = client.getContainerReference(container);
    CloudBlockBlob blobSource = blobContainer.getBlockBlobReference(sourceBlob);
    if (blobSource.exists()) {
        CloudBlockBlob blobTarget = blobContainer.getBlockBlobReference(targetBlob);
        SocketAccess.doPrivilegedVoidException(() -> {
            blobTarget.startCopy(blobSource);
            blobSource.delete();
        });
        logger.debug("moveBlob container [{}], sourceBlob [{}], targetBlob [{}] -> done", container, sourceBlob, targetBlob);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AzureStorageServiceImpl.java

示例3: setUpStorageAccount

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
private static CloudBlobContainer setUpStorageAccount(String connectionString, String containerName) {
    try {
        CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
        // Create a blob service client
        CloudBlobClient blobClient = account.createCloudBlobClient();
        CloudBlobContainer container = blobClient.getContainerReference(containerName);
        container.createIfNotExists();
        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
        // Include public access in the permissions object
        containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
        // Set the permissions on the container
        container.uploadPermissions(containerPermissions);
        return container;
    } catch (StorageException | URISyntaxException | InvalidKeyException e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:19,代码来源:ManageLinuxWebAppStorageAccountConnection.java

示例4: getConfiguration

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public LoggingConfiguration getConfiguration(final Path container) throws BackgroundException {
    try {
        final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context);
        final LoggingConfiguration configuration = new LoggingConfiguration(
                !properties.getLogging().getLogOperationTypes().isEmpty(),
                "$logs"
        );
        // When you have configured Storage Logging to log request data from your storage account, it saves the log data
        // to blobs in a container named $logs in your storage account.
        configuration.setContainers(Collections.singletonList(
                new Path("/$logs", EnumSet.of(Path.Type.volume, Path.Type.directory)))
        );
        return configuration;
    }
    catch(StorageException e) {
        throw new AzureExceptionMappingService().map("Cannot read container configuration", e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:AzureLoggingFeature.java

示例5: setConfiguration

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public void setConfiguration(final Path container, final LoggingConfiguration configuration) throws BackgroundException {
    try {
        final ServiceProperties properties = session.getClient().downloadServiceProperties(null, context);
        final LoggingProperties l = new LoggingProperties();
        if(configuration.isEnabled()) {
            l.setLogOperationTypes(EnumSet.allOf(LoggingOperations.class));
        }
        else {
            l.setLogOperationTypes(EnumSet.noneOf(LoggingOperations.class));
        }
        properties.setLogging(l);
        session.getClient().uploadServiceProperties(properties, null, context);
    }
    catch(StorageException e) {
        throw new AzureExceptionMappingService().map("Failure to write attributes of {0}", e, container);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:AzureLoggingFeature.java

示例6: getImageAsArray

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public byte[] getImageAsArray(String imagefilename) {
  	byte[] b = null;
  	
      CloudBlobClient serviceClient = cloudStorageAccount.createCloudBlobClient();
      // Container name must be lower case.
      CloudBlobContainer container;
try {
	container = serviceClient.getContainerReference(azureStorageProperties.getBlobContainer());
       CloudBlockBlob imgBlob = container.getBlockBlobReference(imagefilename);
       b = downloadImage(imgBlob);
} catch (URISyntaxException | StorageException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
      //return result
      return b;    	
  }
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:18,代码来源:AzureImageStorageServiceImpl.java

示例7: storeImage

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public String storeImage(String IncidentId, String fileName, String contentType, byte[] fileBuffer) {
      CloudBlobClient serviceClient = cloudStorageAccount.createCloudBlobClient();
      String imageUriString = null;
      // Container name must be lower case.
      CloudBlobContainer container;
try {
	container = serviceClient.getContainerReference(azureStorageProperties.getBlobContainer());
	container.createIfNotExists();
       // Set anonymous access on the container.
       BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
       containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
       container.uploadPermissions(containerPermissions);
       String incidentBlob = getIncidentBlobFilename(IncidentId,fileName);
       CloudBlockBlob imgBlob = container.getBlockBlobReference(incidentBlob);
       imgBlob.getProperties().setContentType(contentType);
       imgBlob.uploadFromByteArray(fileBuffer, 0, fileBuffer.length);
       imageUriString = incidentBlob;
} catch (URISyntaxException | StorageException | IOException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
      //return result
      return imageUriString;
  	
  }
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:26,代码来源:AzureImageStorageServiceImpl.java

示例8: getImageAsArray

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public byte[] getImageAsArray(String imagefilename) {
	byte[] b = null;

	CloudBlobClient serviceClient = cloudStorageAccount.createCloudBlobClient();
	// Container name must be lower case.
	CloudBlobContainer container;
	try {
		container = serviceClient.getContainerReference(azureStorageProperties.getBlobContainer());
		CloudBlockBlob imgBlob = container.getBlockBlobReference(imagefilename);
		b = downloadImage(imgBlob);
	} catch (URISyntaxException | StorageException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	//return result
	return b;    	
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:18,代码来源:AzureImageStorageServiceImpl.java

示例9: storeImage

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public String storeImage(String IncidentId, String fileName, String contentType, byte[] fileBuffer) {
	CloudBlobClient serviceClient = cloudStorageAccount.createCloudBlobClient();
	String imageUriString = null;
	// Container name must be lower case.
	CloudBlobContainer container;
	try {
		container = serviceClient.getContainerReference(azureStorageProperties.getBlobContainer());
		container.createIfNotExists();
		// Set anonymous access on the container.
		BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
		containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
		container.uploadPermissions(containerPermissions);
		String incidentBlob = getIncidentBlobFilename(IncidentId,fileName);
		CloudBlockBlob imgBlob = container.getBlockBlobReference(incidentBlob);
		imgBlob.getProperties().setContentType(contentType);
		imgBlob.uploadFromByteArray(fileBuffer, 0, fileBuffer.length);
		imageUriString = incidentBlob;
	} catch (URISyntaxException | StorageException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	//return result
	return imageUriString;

}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:26,代码来源:AzureImageStorageServiceImpl.java

示例10: downloadPageRanges

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public ArrayList<PageRange> downloadPageRanges(BlobRequestOptions options,
    OperationContext opContext) throws StorageException {
  return ((CloudPageBlob) getBlob()).downloadPageRanges(
      null, options, opContext);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:StorageInterfaceImpl.java

示例11: regularUpload

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
private boolean regularUpload(CloudBlobContainer container, String fileName, PluggableMessage pluggableMessage,
		Map<String, String> customMetadata, long fileSize) throws UnableToProduceException {
	boolean status = false;
	CloudBlockBlob singleBlob;
	String containerName = container.getName();
	try {

		if (container.exists()) {
			log.info(LOGGER_KEY + "Container exists: " + containerName);
			singleBlob = container.getBlockBlobReference(fileName);

			log.info(LOGGER_KEY + "User metadata being applied ..." + customMetadata.size() + " key(s)");
			singleBlob.setMetadata((HashMap<String, String>) customMetadata);
			log.info(LOGGER_KEY + "Initiating blob upload with regular mode");

			singleBlob.upload(FileUtils.openInputStream(pluggableMessage.getData().toFile()), fileSize);
			if (singleBlob.exists())
				log.info(LOGGER_KEY + "Azure Blob upload finished successfully.");
		}
	} catch (URISyntaxException urie) {
		log.error(LOGGER_KEY + "Azure Resource URI constructed based on the containerName is invalid. "
				+ urie.getMessage());
		throw new UnableToProduceException(urie.getMessage(), urie);
	} catch (StorageException se) {
		log.error(LOGGER_KEY + "Azure Storage Service Error occurred. " + se.getMessage());
		throw new UnableToProduceException(se.getMessage(), se);
	} catch (IOException ioe) {
		log.error(LOGGER_KEY + "Azure Storage I/O exception occurred. " + ioe.getMessage());
		throw new UnableToProduceException(ioe.getMessage(), ioe);
	} finally {
		status = true;
	}
	return status;
}
 
开发者ID:cmanda,项目名称:axway-b2b-plugins,代码行数:35,代码来源:AzureBlobPluggableTransport.java

示例12: AzureRepository

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
public AzureRepository(RepositoryMetaData metadata, Environment environment,
                       NamedXContentRegistry namedXContentRegistry, AzureStorageService storageService)
    throws IOException, URISyntaxException, StorageException {
    super(metadata, environment.settings(), namedXContentRegistry);

    blobStore = new AzureBlobStore(metadata, environment.settings(), storageService);
    String container = getValue(metadata.settings(), settings, Repository.CONTAINER_SETTING, Storage.CONTAINER_SETTING);
    this.chunkSize = getValue(metadata.settings(), settings, Repository.CHUNK_SIZE_SETTING, Storage.CHUNK_SIZE_SETTING);
    this.compress = getValue(metadata.settings(), settings, Repository.COMPRESS_SETTING, Storage.COMPRESS_SETTING);
    String modeStr = getValue(metadata.settings(), settings, Repository.LOCATION_MODE_SETTING, Storage.LOCATION_MODE_SETTING);
    Boolean forcedReadonly = metadata.settings().getAsBoolean("readonly", null);
    // If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting.
    // For secondary_only setting, the repository should be read only
    if (forcedReadonly == null) {
        if (Strings.hasLength(modeStr)) {
            LocationMode locationMode = LocationMode.valueOf(modeStr.toUpperCase(Locale.ROOT));
            this.readonly = locationMode == LocationMode.SECONDARY_ONLY;
        } else {
            this.readonly = false;
        }
    } else {
        readonly = forcedReadonly;
    }

    String basePath = getValue(metadata.settings(), settings, Repository.BASE_PATH_SETTING, Storage.BASE_PATH_SETTING);

    if (Strings.hasLength(basePath)) {
        // Remove starting / if any
        basePath = Strings.trimLeadingCharacter(basePath, '/');
        BlobPath path = new BlobPath();
        for(String elem : basePath.split("/")) {
            path = path.add(elem);
        }
        this.basePath = path;
    } else {
        this.basePath = BlobPath.cleanPath();
    }
    logger.debug("using container [{}], chunk_size [{}], compress [{}], base_path [{}]",
            container, chunkSize, compress, basePath);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:AzureRepository.java

示例13: blobExists

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public boolean blobExists(String blobName) {
    logger.trace("blobExists({})", blobName);
    try {
        return blobStore.blobExists(blobStore.container(), buildKey(blobName));
    } catch (URISyntaxException | StorageException e) {
        logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:AzureBlobContainer.java

示例14: deleteBlob

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
@Override
public void deleteBlob(String blobName) throws IOException {
    logger.trace("deleteBlob({})", blobName);

    if (!blobExists(blobName)) {
        throw new NoSuchFileException("Blob [" + blobName + "] does not exist");
    }

    try {
        blobStore.deleteBlob(blobStore.container(), buildKey(blobName));
    } catch (URISyntaxException | StorageException e) {
        logger.warn("can not access [{}] in container {{}}: {}", blobName, blobStore.container(), e.getMessage());
        throw new IOException(e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:AzureBlobContainer.java

示例15: PageBlobInputStream

import com.microsoft.azure.storage.StorageException; //导入依赖的package包/类
/**
 * Constructs a stream over the given page blob.
 */
public PageBlobInputStream(CloudPageBlobWrapper blob,
    OperationContext opContext)
    throws IOException {
  this.blob = blob;
  this.opContext = opContext;
  ArrayList<PageRange> allRanges;
  try {
    allRanges =
        blob.downloadPageRanges(new BlobRequestOptions(), opContext);
  } catch (StorageException e) {
    throw new IOException(e);
  }
  if (allRanges.size() > 0) {
    if (allRanges.get(0).getStartOffset() != 0) {
      throw badStartRangeException(blob, allRanges.get(0));
    }
    if (allRanges.size() > 1) {
      LOG.warn(String.format(
          "Blob %s has %d page ranges beyond the first range. " 
          + "Only reading the first range.",
          blob.getUri(), allRanges.size() - 1));
    }
    numberOfPagesRemaining =
        (allRanges.get(0).getEndOffset() + 1) / PAGE_SIZE;
  } else {
    numberOfPagesRemaining = 0;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:PageBlobInputStream.java


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