All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.tweeenveertig.openstack.headers.object.ObjectMetadata Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package nl.tweeenveertig.openstack.headers.object;

import nl.tweeenveertig.openstack.headers.Metadata;
import org.apache.http.HttpResponse;

import java.util.Map;
import java.util.TreeMap;

public class ObjectMetadata extends Metadata {

    public static final String X_OBJECT_META_PREFIX = "X-Object-Meta-";

    public ObjectMetadata(String name, String value) {
        super(name, value);
    }

    @Override
    public String getHeaderName() {
        return X_OBJECT_META_PREFIX + getName();
    }

    public static Map fromResponse(HttpResponse response) {
        Map metadata = new TreeMap();
        for (org.apache.http.Header header : getResponseHeadersStartingWith(response, X_OBJECT_META_PREFIX)) {
            ObjectMetadata objectMetadata = new ObjectMetadata(header.getName().substring(X_OBJECT_META_PREFIX.length()), header.getValue());
            metadata.put(objectMetadata.getName(), objectMetadata);
        }
        return metadata;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy