本文整理汇总了Java中org.jclouds.blobstore.BlobStore.containerExists方法的典型用法代码示例。如果您正苦于以下问题:Java BlobStore.containerExists方法的具体用法?Java BlobStore.containerExists怎么用?Java BlobStore.containerExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.blobstore.BlobStore
的用法示例。
在下文中一共展示了BlobStore.containerExists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putContainer
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@PUT
public Response putContainer(@NotNull @PathParam("container") String container,
@HeaderParam("X-Auth-Token") String authToken,
@HeaderParam("X-Container-Read") String readACL,
@HeaderParam("X-Container-write") String writeACL,
@HeaderParam("X-Container-Sync-To") String syncTo,
@HeaderParam("X-Container-Sync-Key") String syncKey,
@HeaderParam("X-Versions-Location") String versionsLocation,
@HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType,
@HeaderParam("X-Detect-Content-Type") boolean detectContentType,
@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
Response.Status status;
BlobStore store = getBlobStore(authToken).get(container);
if (store.containerExists(container)) {
status = Response.Status.ACCEPTED;
} else {
createContainer(authToken, container);
status = Response.Status.CREATED;
}
return Response.status(status).build();
}
示例2: deleteContainer
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@DELETE
public Response deleteContainer(@NotNull @PathParam("container") String container,
@HeaderParam("X-Auth-Token") String authToken) {
BlobStore store = getBlobStore(authToken).get(container);
if (!store.containerExists(container)) {
return Response.status(Response.Status.NOT_FOUND).build();
}
if (store.deleteContainerIfEmpty(container)) {
return Response.noContent().build();
} else {
return Response.status(Response.Status.CONFLICT)
.entity("<html><h1>Conflict</h1><p>There was a conflict when trying to complete your request.</p></html>")
.build();
}
}
示例3: handleContainerDelete
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private static void handleContainerDelete(HttpServletResponse response,
BlobStore blobStore, String containerName)
throws IOException, S3Exception {
if (!blobStore.containerExists(containerName)) {
throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET);
}
String blobStoreType = getBlobStoreType(blobStore);
if (blobStoreType.equals("b2")) {
// S3 allows deleting a container with in-progress MPU while B2 does
// not. Explicitly cancel uploads for B2.
for (MultipartUpload mpu : blobStore.listMultipartUploads(
containerName)) {
blobStore.abortMultipartUpload(mpu);
}
}
if (!blobStore.deleteContainerIfEmpty(containerName)) {
throw new S3Exception(S3ErrorCode.BUCKET_NOT_EMPTY);
}
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
示例4: headContainer
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@HEAD
public Response headContainer(@NotNull @PathParam("container") String container,
@HeaderParam("X-Auth-Token") String authToken,
@HeaderParam("X-Newest") @DefaultValue("false") boolean newest) {
BlobStore store = getBlobStore(authToken).get(container);
if (!store.containerExists(container)) {
return Response.status(Response.Status.NOT_FOUND).build();
}
long objectCount = -1;
String provider = store.getContext().unwrap().getId();
if (provider.equals("transient") || provider.equals("openstack-swift")) {
objectCount = store.countBlobs(container);
}
return Response.status(Response.Status.NO_CONTENT).entity("")
.header("X-Container-Object-Count", objectCount)
.header("X-Container-Bytes-Used", 0) // TODO: bogus value
.header("X-Versions-Location", "")
.header("X-Timestamp", -1)
.header("X-Trans-Id", -1)
.header("Accept-Ranges", "bytes")
.build();
}
示例5: getContainer
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@GET
@Timed
@Path("/{name}")
public Container getContainer(@PathParam("id") int providerId, @PathParam("name") String containerName) {
BlobStore blobStore = app.getBlobStore(containerName);
if (containerName == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
if (blobStore == null) {
// This occurs for containers that are not virtual containers
blobStore = app.getBlobStore(providerId);
}
if (blobStore == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
if (!blobStore.containerExists(containerName)) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
List<ContainerObject> objects = blobStore.list(containerName,
ListContainerOptions.Builder.maxResults(MAX_OBJECTS).recursive())
.stream()
.map(sm -> {
ImmutableSet<BounceStorageMetadata.Region> regions;
if (sm instanceof BounceStorageMetadata) {
BounceStorageMetadata bounceMeta = (BounceStorageMetadata) sm;
regions = bounceMeta.getRegions();
} else {
regions = BounceStorageMetadata.NEAR_ONLY;
}
return new ContainerObject(sm.getName(), sm.getSize(), regions);
})
.collect(Collectors.toList());
Container container = createContainerObject(containerName, createVirtualContainerMap(providerId));
container.objects = objects;
return container;
}
示例6: containerExists
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
* Check if a {@link BlobStore} specific container exists or not
*/
public static boolean containerExists(BlobStore blobStore, String container) throws IOException {
boolean result = blobStore.containerExists(container);
return result;
}
示例7: activateService
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@Override
public void activateService()
throws Exception
{
configuration.refresh();
String provider = configuration.get().provider().get();
String identifier = configuration.get().identifier().get();
String credentials = configuration.get().credential().get();
String endpoint = configuration.get().endpoint().get();
Map<String, String> properties = configuration.get().properties().get();
container = configuration.get().container().get();
if( provider != null )
{
checkArgument( contains( allKeys, provider ), "provider %s not in supported list: %s", provider, allKeys );
}
else
{
provider = "transient";
}
if( container == null )
{
container = "polygene-entities";
}
storeContext = ContextBuilder.newBuilder( provider )
.endpoint( endpoint == null ? "" : endpoint )
.credentials( identifier, credentials )
.overrides( asProperties( properties ) )
.buildView( BlobStoreContext.class );
BlobStore blobStore = storeContext.getBlobStore();
if( !blobStore.containerExists( container ) )
{
if( !blobStore.createContainerInLocation( null, container ) )
{
throw new EntityStoreException( "Unable to create JClouds Blob Container, cannot continue." );
}
else
{
LOGGER.debug( "Created new container: {}", container );
}
}
LOGGER.info( "Activated using {} cloud provider [id:{}]", provider, identifier );
}
示例8: getObject
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@GET
public Response getObject(@NotNull @PathParam("container") String container,
@NotNull @Encoded @PathParam("object") String object,
@NotNull @PathParam("account") String account,
@HeaderParam("X-Auth-Token") String authToken,
@HeaderParam("X-Newest") boolean newest,
@QueryParam("signature") String signature,
@QueryParam("expires") String expires,
@QueryParam("multipart-manifest") String multiPartManifest,
@HeaderParam("Range") String range,
@HeaderParam("If-Match") String ifMatch,
@HeaderParam("If-None-Match") String ifNoneMatch,
@HeaderParam("If-Modified-Since") Date ifModifiedSince,
@HeaderParam("If-Unmodified-Since") Date ifUnmodifiedSince) {
logger.debug("GET account={} container={} object={}", account, container, object);
BlobStore blobStore = getBlobStore(authToken).get(container, object);
if (!blobStore.containerExists(container)) {
return notFound();
}
GetOptions options = new GetOptions();
List<Pair<Long, Long>> ranges = null;
if (range != null) {
ranges = parseRange(range);
if (ranges != null) {
options = addRanges(options, ranges);
}
}
if (ifMatch != null) {
options.ifETagMatches(maybeUnquote(ifMatch));
}
if (ifNoneMatch != null) {
options.ifETagDoesntMatch(maybeUnquote(ifNoneMatch));
}
if (ifModifiedSince != null) {
options.ifModifiedSince(ifModifiedSince);
}
if (ifUnmodifiedSince != null) {
options.ifUnmodifiedSince(ifUnmodifiedSince);
}
return getObject(blobStore, container, object, options, ranges, "get".equals(multiPartManifest));
}
示例9: postObject
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@POST
@Consumes(" ")
public Response postObject(@NotNull @PathParam("container") String container,
@NotNull @Encoded @PathParam("object") String objectName,
@NotNull @PathParam("account") String account,
@HeaderParam("X-Auth-Token") String authToken,
@HeaderParam("X-Delete-At") long deleteAt,
@HeaderParam(HttpHeaders.CONTENT_DISPOSITION) String contentDisposition,
@HeaderParam(HttpHeaders.CONTENT_ENCODING) String contentEncoding,
@HeaderParam("X-Delete-After") long deleteAfter,
@HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType,
@HeaderParam("X-Detect-Content-Type") boolean detectContentType,
@Context Request request) {
if (objectName.length() > InfoResource.CONFIG.swift.max_object_name_length) {
return badRequest();
}
BlobStore blobStore = getBlobStore(authToken).get(container, objectName);
if (!blobStore.containerExists(container)) {
return notFound();
}
BlobMetadata meta = blobStore.blobMetadata(container, objectName);
if (meta == null) {
return notFound();
}
Map<String, String> newMetadata = getUserMetadata(request);
validateUserMetadata(newMetadata);
Map<String, String> originalMetadata = meta.getUserMetadata();
// copy the dlo/slo headers
RESERVED_METADATA.stream()
.filter(k -> originalMetadata.containsKey(k))
.forEach(k -> newMetadata.put(k, originalMetadata.get(k)));
CopyOptions options = CopyOptions.builder().userMetadata(newMetadata).build();
String etag = serverCopyBlob(blobStore, container, objectName, container, objectName, options);
if (etag == null) {
return notFound();
}
return Response.accepted()
.header(HttpHeaders.DATE, new Date())
.build();
}
示例10: deleteObject
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
@DELETE
public Response deleteObject(@NotNull @PathParam("account") String account,
@NotNull @PathParam("container") String container,
@NotNull @Encoded @PathParam("object") String objectName,
@QueryParam("multipart-manifest") String multipartManifest,
@HeaderParam("X-Auth-Token") String authToken) throws IOException {
if (objectName.length() > InfoResource.CONFIG.swift.max_object_name_length) {
return badRequest();
}
BlobStore store = getBlobStore(authToken).get(container, objectName);
if ("delete".equals(multipartManifest)) {
Blob blob;
try {
blob = store.getBlob(container, objectName);
} catch (ContainerNotFoundException cnfe) {
blob = null;
}
if (blob == null) {
return Response.status(Response.Status.OK)
.entity("{\"Number Not Found\": 1" +
", \"Response Status\": \"404 Not Found\"" +
// TODO: JSON encode container and objectName
", \"Errors\": [[\"/" + container + "/" + objectName + "\", \"Not found\"]]" +
", \"Number Deleted\": 0" +
", \"Response Body\": \"\"}")
.build();
}
if (!blob.getMetadata().getUserMetadata().containsKey(STATIC_OBJECT_MANIFEST)) {
return Response.status(Response.Status.OK)
.entity("{\"Number Not Found\": 0" +
", \"Response Status\": \"400 Bad Request\"" +
// TODO: JSON encode container and objectName
", \"Errors\": [[\"/" + container + "/" + objectName + "\", \"Not an SLO manifest\"]]" +
", \"Number Deleted\": 0" +
", \"Response Body\": \"\"}")
.build();
}
ManifestEntry[] entries = readSLOManifest(blob.getPayload().openStream());
Arrays.stream(entries).parallel().forEach(e -> store.removeBlob(e.container, e.object));
store.removeBlob(container, objectName);
return Response.status(Response.Status.OK)
.entity("{\"Number Not Found\": 0" +
", \"Response Status\": \"200 OK\"" +
", \"Errors\": [[]]" +
", \"Number Deleted\": " + entries.length +
", \"Response Body\": \"\"}")
.build();
}
if (!store.containerExists(container)) {
return Response.status(Response.Status.NOT_FOUND).build();
}
BlobMetadata meta = store.blobMetadata(container, objectName);
if (meta == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
store.removeBlob(container, objectName);
return Response.noContent()
.type(meta.getContentMetadata().getContentType())
.build();
}
示例11: handleContainerExists
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
private static void handleContainerExists(BlobStore blobStore,
String containerName) throws IOException, S3Exception {
if (!blobStore.containerExists(containerName)) {
throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET);
}
}
示例12: ensureContainerExists
import org.jclouds.blobstore.BlobStore; //导入方法依赖的package包/类
/**
* Checks if container exists and creates one if not.
*
* @param blobStore The {@link BlobStore} to use.
* @param container The container name to check against.
* @param locationId The locationId to create the container if not found.
*/
public static void ensureContainerExists(BlobStore blobStore, String container, String locationId) {
if (blobStore != null && !Strings.isNullOrEmpty(container) && !blobStore.containerExists(container)) {
blobStore.createContainerInLocation(getLocationById(blobStore, locationId), container);
}
}