Package ch.iterate.openstack.swift.model

Examples of ch.iterate.openstack.swift.model.ObjectMetadata


    public Map<String, List<StorageObject>> listObjectSegments(Region region, String container, String name) throws IOException {

        Map<String, List<StorageObject>> existingSegments = new HashMap<String, List<StorageObject>>();

        try {
            ObjectMetadata existingMetadata = getObjectMetaData(region, container, name);

            if(existingMetadata.getMetaData().containsKey(Constants.MANIFEST_HEADER)) {
                /*
                 * We have found an existing dynamic large object, so use the prefix to get a list of
                 * existing objects. If we're putting up a new dlo, make sure the segment prefixes are
                 * different, then we can delete anything that's not in the new list if necessary.
                 */
                String manifestDLO = existingMetadata.getMetaData().get(Constants.MANIFEST_HEADER);
                String segmentContainer = manifestDLO.substring(1, manifestDLO.indexOf('/', 1));
                String segmentPath = manifestDLO.substring(manifestDLO.indexOf('/', 1), manifestDLO.length());
                existingSegments.put(segmentContainer, this.listObjects(region, segmentContainer, segmentPath));
            }
            else if(existingMetadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) {
                /*
                 * We have found an existing static large object, so grab the manifest data that
                 * details the existing segments - delete any later that we don't need any more
                 */
                boolean isSLO = "true".equals(existingMetadata.getMetaData().get(Constants.X_STATIC_LARGE_OBJECT).toLowerCase(Locale.ENGLISH));
                if(isSLO) {
                    final JsonParser parser = new JsonParser();
                    URIBuilder urlBuild = new URIBuilder(region.getStorageUrl(container, name));
                    urlBuild.setParameter("multipart-manifest", "get");
                    URI url = urlBuild.build();
View Full Code Here


    public Map<String, List<StorageObject>> listObjectSegments(Region region, String container, String name) throws IOException {

        Map<String, List<StorageObject>> existingSegments = new HashMap<String, List<StorageObject>>();

        try {
            ObjectMetadata existingMetadata = getObjectMetaData(region, container, name);

            if(existingMetadata.getMetaData().containsKey(Constants.MANIFEST_HEADER)) {
                /*
                 * We have found an existing dynamic large object, so use the prefix to get a list of
                 * existing objects. If we're putting up a new dlo, make sure the segment prefixes are
                 * different, then we can delete anything that's not in the new list if necessary.
                 */
                String manifestDLO = existingMetadata.getMetaData().get(Constants.MANIFEST_HEADER);
                String segmentContainer = manifestDLO.substring(1, manifestDLO.indexOf('/', 1));
                String segmentPath = manifestDLO.substring(manifestDLO.indexOf('/', 1), manifestDLO.length());
                existingSegments.put(segmentContainer, this.listObjects(region, segmentContainer, segmentPath));
            }
            else if(existingMetadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) {
                /*
                 * We have found an existing static large object, so grab the manifest data that
                 * details the existing segments - delete any later that we don't need any more
                 */
                boolean isSLO = "true".equals(existingMetadata.getMetaData().get(Constants.X_STATIC_LARGE_OBJECT).toLowerCase(Locale.ENGLISH));
                if(isSLO) {
                    JSONParser parser = new JSONParser();
                    URIBuilder urlBuild = new URIBuilder(region.getStorageUrl(container, name));
                    urlBuild.setParameter("multipart-manifest", "get");
                    URI url = urlBuild.build();
View Full Code Here

    public ObjectMetadata handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT ||
                response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

            ObjectMetadata metadata = new ObjectMetadata(
                    this.getContentType(response),
                    this.getContentLength(response),
                    this.getETag(response),
                    this.getLastModified(response));

            for(Header h : response.getAllHeaders()) {
                if(h.getName().startsWith(Constants.X_OBJECT_META)
                        || Constants.HTTP_HEADER_EDITABLE_NAMES.contains(h.getName().toLowerCase(Locale.ENGLISH))) {
                    metadata.addMetaData(h.getName(), decode(h.getValue()));
                }
            }
            return metadata;
        }
        else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
View Full Code Here

    public ObjectMetadata handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT ||
                response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

            ObjectMetadata metadata = new ObjectMetadata(
                    this.getContentType(response),
                    this.getContentLength(response),
                    this.getETag(response),
                    this.getLastModified(response));

            for(Header h : response.getAllHeaders()) {
                if(h.getName().startsWith(Constants.X_OBJECT_META)
                        || Constants.HTTP_HEADER_EDITABLE_NAMES.contains(h.getName().toLowerCase(Locale.ENGLISH))) {
                    metadata.addMetaData(h.getName(), decode(h.getValue()));
                }
            }
            return metadata;
        }
        else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
View Full Code Here

TOP

Related Classes of ch.iterate.openstack.swift.model.ObjectMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.