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


Java BlobStore.containerExists方法代码示例

本文整理汇总了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();
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:24,代码来源:ContainerResource.java

示例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();
    }
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:17,代码来源:ContainerResource.java

示例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);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:24,代码来源:S3ProxyHandler.java

示例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();
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:25,代码来源:ContainerResource.java

示例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;
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:37,代码来源:ContainerResource.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:JcloudsBlobStoreHelper.java

示例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 );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:43,代码来源:JCloudsEntityStoreMixin.java

示例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));
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:46,代码来源:ObjectResource.java

示例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();
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:45,代码来源:ObjectResource.java

示例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();
}
 
开发者ID:bouncestorage,项目名称:swiftproxy,代码行数:70,代码来源:ObjectResource.java

示例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);
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:7,代码来源:S3ProxyHandler.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JcloudsBlobStoreHelper.java


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