cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [3/7] add docker client
Date Sun, 30 Mar 2014 18:04:18 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketClientHandler.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketClientHandler.java b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketClientHandler.java
new file mode 100644
index 0000000..6ce3f1c
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketClientHandler.java
@@ -0,0 +1,213 @@
+package com.kpelykh.docker.client;
+
+import com.sun.jersey.api.client.*;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.core.header.InBoundHeaders;
+import com.sun.jersey.core.util.ReaderWriter;
+import jnr.unixsocket.UnixSocketAddress;
+import jnr.unixsocket.UnixSocketChannel;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.entity.BufferedHttpEntity;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.io.DefaultHttpResponseParser;
+import org.apache.http.impl.io.HttpRequestWriter;
+import org.apache.http.message.BasicLineFormatter;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.params.BasicHttpParams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.URI;
+import java.nio.channels.Channels;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO: Make thread-safe.
+ */
+@NotThreadSafe
+public class UnixSocketClientHandler extends RequestWriter implements ClientHandler {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(UnixSocketClientHandler.class);
+
+  public static final int BUFFERSIZE = 1024;
+  public static final String DOCKER_SOCKET_PATH = "/var/run/docker.sock";
+
+  @Override
+  public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
+    try {
+      File path = new File(DOCKER_SOCKET_PATH);
+      UnixSocketAddress address = new UnixSocketAddress(path);
+      UnixSocketChannel channel = UnixSocketChannel.open(address);
+      OutputStream unixSocketChannelOutputStream = Channels.newOutputStream(channel);
+
+      final HttpUriRequest request = getUriHttpRequest(cr);
+      BasicHttpParams params = new BasicHttpParams();
+
+      UnixSocketSessionOutputBuffer outputBuffer = new UnixSocketSessionOutputBuffer();
+      outputBuffer.init(unixSocketChannelOutputStream, BUFFERSIZE, params);
+      HttpRequestWriter writer = new HttpRequestWriter(outputBuffer, new BasicLineFormatter(), params);
+      writer.write(request);
+      outputBuffer.flush();
+
+      UnixSocketSessionInputBuffer inputBuffer = new UnixSocketSessionInputBuffer();
+      inputBuffer.init(Channels.newInputStream(channel), BUFFERSIZE, params);
+
+      HttpResponse response = new DefaultHttpResponseParser(inputBuffer, new BasicLineParser(), new DefaultHttpResponseFactory(), params).parse();
+      LOGGER.trace(response.toString());
+
+      ClientResponse clientResponse = new ClientResponse(response.getStatusLine().getStatusCode(),
+        getInBoundHeaders(response),
+        new HttpClientResponseInputStream(response),
+        getMessageBodyWorkers());
+
+      clientResponse.bufferEntity();
+      clientResponse.close();
+
+      return clientResponse;
+
+    } catch (IOException e) {
+      e.printStackTrace();
+    } catch (HttpException e) {
+      e.printStackTrace();
+    }
+    return null;
+  }
+
+  private HttpUriRequest getUriHttpRequest(final ClientRequest cr) {
+    final String strMethod = cr.getMethod();
+    final URI uri = cr.getURI();
+
+    final HttpEntity entity = getHttpEntity(cr);
+    final HttpUriRequest request;
+
+    if (strMethod.equals("GET")) {
+      request = new HttpGet(uri);
+    } else if (strMethod.equals("POST")) {
+      request = new HttpPost(uri);
+    } else if (strMethod.equals("PUT")) {
+      request = new HttpPut(uri);
+    } else if (strMethod.equals("DELETE")) {
+      request = new HttpDelete(uri);
+    } else if (strMethod.equals("HEAD")) {
+      request = new HttpHead(uri);
+    } else if (strMethod.equals("OPTIONS")) {
+      request = new HttpOptions(uri);
+    } else {
+      request = new HttpEntityEnclosingRequestBase() {
+        @Override
+        public String getMethod() {
+          return strMethod;
+        }
+
+        @Override
+        public URI getURI() {
+          return uri;
+        }
+      };
+    }
+
+    if (entity != null && request instanceof HttpEntityEnclosingRequestBase) {
+      ((HttpEntityEnclosingRequestBase) request).setEntity(entity);
+    } else if (entity != null) {
+      throw new ClientHandlerException("Adding entity to http method " + cr.getMethod() + " is not supported.");
+    }
+
+    return request;
+  }
+
+  private HttpEntity getHttpEntity(final ClientRequest cr) {
+    final Object entity = cr.getEntity();
+
+    if (entity == null)
+      return null;
+
+    final RequestEntityWriter requestEntityWriter = getRequestEntityWriter(cr);
+
+    try {
+      HttpEntity httpEntity = new AbstractHttpEntity() {
+        @Override
+        public boolean isRepeatable() {
+          return false;
+        }
+
+        @Override
+        public long getContentLength() {
+          return requestEntityWriter.getSize();
+        }
+
+        @Override
+        public InputStream getContent() throws IOException, IllegalStateException {
+          return null;
+        }
+
+        @Override
+        public void writeTo(OutputStream outputStream) throws IOException {
+          requestEntityWriter.writeRequestEntity(outputStream);
+        }
+
+        @Override
+        public boolean isStreaming() {
+          return false;
+        }
+      };
+
+      if (cr.getProperties().get(ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE) != null) {
+        // TODO return InputStreamEntity
+        return httpEntity;
+      } else {
+        return new BufferedHttpEntity(httpEntity);
+      }
+    } catch (Exception ex) {
+      // TODO warning/error?
+    }
+
+    return null;
+  }
+
+  private InBoundHeaders getInBoundHeaders(final HttpResponse response) {
+    final InBoundHeaders headers = new InBoundHeaders();
+    final Header[] respHeaders = response.getAllHeaders();
+    for (Header header : respHeaders) {
+      List<String> list = headers.get(header.getName());
+      if (list == null) {
+        list = new ArrayList<String>();
+      }
+      list.add(header.getValue());
+      headers.put(header.getName(), list);
+    }
+    return headers;
+  }
+
+  private static final class HttpClientResponseInputStream extends FilterInputStream {
+
+    HttpClientResponseInputStream(final HttpResponse response) throws IOException {
+      super(getInputStream(response));
+    }
+
+    @Override
+    public void close()
+      throws IOException {
+      super.close();
+    }
+  }
+
+  private static InputStream getInputStream(final HttpResponse response) throws IOException {
+
+    if (response.getEntity() == null) {
+      return new ByteArrayInputStream(new byte[0]);
+    } else {
+      final InputStream i = response.getEntity().getContent();
+      if (i.markSupported())
+        return i;
+      return new BufferedInputStream(i, ReaderWriter.BUFFER_SIZE);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionInputBuffer.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionInputBuffer.java b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionInputBuffer.java
new file mode 100644
index 0000000..9c7f150
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionInputBuffer.java
@@ -0,0 +1,23 @@
+package com.kpelykh.docker.client;
+
+import org.apache.http.impl.io.AbstractSessionInputBuffer;
+import org.apache.http.params.HttpParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ */
+public class UnixSocketSessionInputBuffer extends AbstractSessionInputBuffer {
+
+  @Override
+  protected void init(InputStream instream, int buffersize, HttpParams params) {
+    super.init(instream, buffersize, params);
+  }
+
+  @Override
+  public boolean isDataAvailable(int timeout) throws IOException {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionOutputBuffer.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionOutputBuffer.java b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionOutputBuffer.java
new file mode 100644
index 0000000..411096f
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/UnixSocketSessionOutputBuffer.java
@@ -0,0 +1,17 @@
+package com.kpelykh.docker.client;
+
+import org.apache.http.impl.io.AbstractSessionOutputBuffer;
+import org.apache.http.params.HttpParams;
+
+import java.io.OutputStream;
+
+/**
+ * {@link org.apache.http.impl.io.AbstractSessionOutputBuffer} implementation for UNIX sockets.
+ */
+public class UnixSocketSessionOutputBuffer extends AbstractSessionOutputBuffer {
+
+  @Override
+  protected void init(OutputStream outstream, int buffersize, HttpParams params) {
+    super.init(outstream, buffersize, params);
+  }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/BoundHostVolumes.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/BoundHostVolumes.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/BoundHostVolumes.java
new file mode 100644
index 0000000..c5c30de
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/BoundHostVolumes.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.kpelykh.docker.client.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+
+/**
+ * @author Kevin A. Archie <karchie@wustl.edu>
+ *
+ */
+@JsonSerialize(using=BoundHostVolumes.Serializer.class)
+public class BoundHostVolumes {
+    private static final String[] STRING_ARRAY = new String[0];
+    private final String[] dests, binds;
+
+    /**
+     * 
+     * @param specs Iterable of String binding specs, each of form "{host-path}:{container-patch}:[rw|ro]"
+     * @throws MalformedVolumeSpecException if any specs are null or empty
+     */
+    public BoundHostVolumes(final Iterable<String> specs) {
+        final List<String> dests = new ArrayList<String>(), binds = new ArrayList<String>();
+        for (final String spec : specs) {
+            if (null == spec || "".equals(spec)) {
+                // skip empty spec lines
+            } else {
+                final String[] sspec = spec.split(":");
+                dests.add(sspec.length > 1 ? sspec[1] : sspec[0]);
+                binds.add(spec);
+            }
+        }
+        this.dests = dests.toArray(STRING_ARRAY);
+        this.binds = binds.toArray(STRING_ARRAY);
+    }
+
+    public String[] asBinds() {
+        return binds;
+    }
+
+    private BoundHostVolumes writeVolumes(final JsonGenerator jg) throws IOException {
+        jg.writeStartObject();
+        for (final String dest : dests) {
+            jg.writeObjectFieldStart(dest);
+            jg.writeEndObject();
+        }
+        jg.writeEndObject();
+        return this;
+    }
+
+    /**
+     * This is an ugly hack. We assume that the serializer only gets called when
+     * a containing ContainerConfig gets serialized, when POSTing to
+     * /containers/create . In that context, we pass only the container-path
+     * part (the key in the volumes map).
+     * 
+     * @author Kevin A. Archie <karchie@wustl.edu>
+     * 
+     */
+    public static class Serializer extends JsonSerializer<BoundHostVolumes> {
+        /* (non-Javadoc)
+         * @see org.codehaus.jackson.map.JsonSerializer#serialize(java.lang.Object, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.map.SerializerProvider)
+         */
+        @Override
+        public void serialize(final BoundHostVolumes volumes, final JsonGenerator jg, final SerializerProvider sp)
+                throws IOException {
+            volumes.writeVolumes(jg);
+        }       
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ChangeLog.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ChangeLog.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ChangeLog.java
new file mode 100644
index 0000000..be6df3a
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ChangeLog.java
@@ -0,0 +1,33 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class ChangeLog {
+
+    @JsonProperty("Path")
+    private String path;
+
+    @JsonProperty("Kind")
+    private int kind;
+
+    public String getPath() {
+        return path;
+    }
+
+    public int getKind() {
+        return kind;
+    }
+
+    @Override
+    public String toString() {
+        return "ChangeLog{" +
+                "path='" + path + '\'' +
+                ", kind=" + kind +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/CommitConfig.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/CommitConfig.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/CommitConfig.java
new file mode 100644
index 0000000..69af995
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/CommitConfig.java
@@ -0,0 +1,85 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class CommitConfig {
+
+    @JsonProperty("container")
+    private String container;
+
+    @JsonProperty("repo")
+    private String repo;
+
+    @JsonProperty("tag")
+    private String tag;
+
+    @JsonProperty("m")
+    private String message;
+
+    //author (eg. “John Hannibal Smith <hannibal@a-team.com>”)
+    @JsonProperty("author")
+    private String author;
+
+    //config automatically applied when the image is run. (ex: {“Cmd”: [“cat”, “/world”], “PortSpecs”:[“22”]})
+    @JsonProperty("run")
+    private String run;
+
+    public String getContainer() {
+        return container;
+    }
+
+    public String getRepo() {
+        return repo;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public String getRun() {
+        return run;
+    }
+
+    public CommitConfig setRepo(String repo) {
+        this.repo = repo;
+        return this;
+    }
+
+    public CommitConfig setTag(String tag) {
+        this.tag = tag;
+        return this;
+    }
+
+    public CommitConfig setMessage(String message) {
+        this.message = message;
+        return this;
+    }
+
+    public CommitConfig setAuthor(String author) {
+        this.author = author;
+        return this;
+    }
+
+    public CommitConfig setRun(String run) {
+        this.run = run;
+        return this;
+    }
+
+    public CommitConfig(String container) {
+        this.container = container;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Container.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Container.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Container.java
new file mode 100644
index 0000000..14970c3
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Container.java
@@ -0,0 +1,140 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class Container {
+
+    @JsonProperty("Id")
+    private String id;
+
+    @JsonProperty("Command")
+    private String command;
+
+    @JsonProperty("Image")
+    private String image;
+
+    @JsonProperty("Created")
+    private long created;
+
+    @JsonProperty("Status")
+    private String status;
+
+    /* Example:
+    "Ports": {
+        "22/tcp": [
+            {
+                "HostIp": "0.0.0.0",
+                "HostPort": "8022"
+            }
+        ]
+    }
+    */
+
+    @JsonProperty("Ports")    
+    public Ports ports;
+
+    @JsonProperty("SizeRw")
+    private int size;
+
+    @JsonProperty("SizeRootFs")
+    private int sizeRootFs;
+
+    @JsonProperty("Names")
+    private String[] names;
+
+    public String getId() {
+        return id;
+    }
+
+    public String getCommand() {
+        return command;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public long getCreated() {
+        return created;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public Ports getPorts() {
+        return ports;
+    }
+
+    public void setPorts(Ports ports) {
+        this.ports = ports;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public int getSizeRootFs() {
+        return sizeRootFs;
+    }
+
+    public String[] getNames() {
+        return names;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setCommand(String command) {
+        this.command = command;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public void setCreated(long created) {
+        this.created = created;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public void setSizeRootFs(int sizeRootFs) {
+        this.sizeRootFs = sizeRootFs;
+    }
+
+    public void setNames(String[] names) {
+        this.names = names;
+    }
+
+    @Override
+    public String toString() {
+        return "Container{" +
+                "id='" + id + '\'' +
+                ", command='" + command + '\'' +
+                ", image='" + image + '\'' +
+                ", created=" + created +
+                ", status='" + status + '\'' +
+                ", ports=" + ports +
+                ", size=" + size +
+                ", sizeRootFs=" + sizeRootFs +
+                ", names=" + Arrays.toString(names) +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java
new file mode 100644
index 0000000..a756a4e
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java
@@ -0,0 +1,282 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+import java.util.Map;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class ContainerConfig {
+
+    @JsonProperty("Hostname")     private String    hostName = "";
+    @JsonProperty("PortSpecs")    private String[]  portSpecs;
+    @JsonProperty("User")         private String    user = "";
+    @JsonProperty("Tty")          private boolean   tty = false;
+    @JsonProperty("OpenStdin")    private boolean   stdinOpen = false;
+    @JsonProperty("StdinOnce")    private boolean   stdInOnce = false;
+    @JsonProperty("Memory")       private long      memoryLimit = 0;
+    @JsonProperty("MemorySwap")   private long      memorySwap = 0;
+    @JsonProperty("CpuShares")    private int       cpuShares = 0;
+    @JsonProperty("AttachStdin")  private boolean   attachStdin = false;
+    @JsonProperty("AttachStdout") private boolean   attachStdout = false;
+    @JsonProperty("AttachStderr") private boolean   attachStderr = false;
+    @JsonProperty("Env")          private String[]  env;
+    @JsonProperty("Cmd")          private String[]  cmd;
+    @JsonProperty("Dns")          private String[]  dns;
+    @JsonProperty("Image")        private String    image;
+    @JsonProperty("Volumes")      private BoundHostVolumes   volumes;
+    @JsonProperty("VolumesFrom")  private String    volumesFrom = "";
+    @JsonProperty("Entrypoint")   private String[]  entrypoint = new String[]{};
+    @JsonProperty("NetworkDisabled") private boolean networkDisabled = false;
+    @JsonProperty("Privileged")   private boolean privileged = false;
+    @JsonProperty("WorkingDir")   private String workingDir = "";
+    @JsonProperty("Domainname")   private String domainName = "";
+    // FIXME Is this the right type? -BJE
+    @JsonProperty("ExposedPorts")   private Map<String, ?> exposedPorts;
+    @JsonProperty("OnBuild")          private String[]  onBuild;
+
+    public Map<String, ?> getExposedPorts() {
+        return exposedPorts;
+    }
+
+    public boolean isNetworkDisabled() {
+        return networkDisabled;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public String getWorkingDir() { return workingDir; }
+
+    public ContainerConfig setWorkingDir(String workingDir) {
+        this.workingDir = workingDir;
+        return this;
+    }
+
+    public boolean isPrivileged() {
+        return privileged;
+    }
+
+    public ContainerConfig setPrivileged(boolean privileged) {
+        this.privileged = privileged;
+        return this;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public ContainerConfig setNetworkDisabled(boolean networkDisabled) {
+        this.networkDisabled = networkDisabled;
+        return this;
+    }
+
+    public ContainerConfig setHostName(String hostName) {
+        this.hostName = hostName;
+        return this;
+    }
+
+    public String[] getPortSpecs() {
+        return portSpecs;
+    }
+
+    public ContainerConfig setPortSpecs(String[] portSpecs) {
+        this.portSpecs = portSpecs;
+        return this;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public ContainerConfig setUser(String user) {
+        this.user = user;
+        return this;
+    }
+
+    public boolean isTty() {
+        return tty;
+    }
+
+    public ContainerConfig setTty(boolean tty) {
+        this.tty = tty;
+        return this;
+    }
+
+    public boolean isStdinOpen() {
+        return stdinOpen;
+    }
+
+    public ContainerConfig setStdinOpen(boolean stdinOpen) {
+        this.stdinOpen = stdinOpen;
+        return this;
+    }
+
+    public boolean isStdInOnce() {
+        return stdInOnce;
+    }
+
+    public ContainerConfig setStdInOnce(boolean stdInOnce) {
+        this.stdInOnce = stdInOnce;
+        return this;
+    }
+
+    public long getMemoryLimit() {
+        return memoryLimit;
+    }
+
+    public ContainerConfig setMemoryLimit(long memoryLimit) {
+        this.memoryLimit = memoryLimit;
+        return this;
+    }
+
+    public long getMemorySwap() {
+        return memorySwap;
+    }
+
+    public ContainerConfig setMemorySwap(long memorySwap) {
+        this.memorySwap = memorySwap;
+        return this;
+    }
+
+    public int getCpuShares() {
+        return cpuShares;
+    }
+
+    public ContainerConfig setCpuShares(int cpuShares) {
+        this.cpuShares = cpuShares;
+        return this;
+    }
+
+    public boolean isAttachStdin() {
+        return attachStdin;
+    }
+
+    public ContainerConfig setAttachStdin(boolean attachStdin) {
+        this.attachStdin = attachStdin;
+        return this;
+    }
+
+    public boolean isAttachStdout() {
+        return attachStdout;
+    }
+
+    public ContainerConfig setAttachStdout(boolean attachStdout) {
+        this.attachStdout = attachStdout;
+        return this;
+    }
+
+    public boolean isAttachStderr() {
+        return attachStderr;
+    }
+
+    public ContainerConfig setAttachStderr(boolean attachStderr) {
+        this.attachStderr = attachStderr;
+        return this;
+    }
+
+    public String[] getEnv() {
+        return env;
+    }
+
+    public ContainerConfig setEnv(String[] env) {
+        this.env = env;
+        return this;
+    }
+
+    public String[] getCmd() {
+        return cmd;
+    }
+
+    public ContainerConfig setCmd(String[] cmd) {
+        this.cmd = cmd;
+        return this;
+    }
+
+    public String[] getDns() {
+        return dns;
+    }
+
+    public ContainerConfig setDns(String[] dns) {
+        this.dns = dns;
+        return this;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public ContainerConfig setImage(String image) {
+        this.image = image;
+        return this;
+    }
+
+    public BoundHostVolumes getVolumes() {
+        return volumes;
+    }
+
+    public ContainerConfig setVolumes(BoundHostVolumes volumes) {
+        this.volumes = volumes;
+        return this;
+    }
+
+    public String getVolumesFrom() {
+        return volumesFrom;
+    }
+
+    public ContainerConfig setVolumesFrom(String volumesFrom) {
+        this.volumesFrom = volumesFrom;
+        return this;
+    }
+
+    public String[] getEntrypoint() {
+        return entrypoint;
+    }
+
+    public ContainerConfig setEntrypoint(String[] entrypoint) {
+        this.entrypoint = entrypoint;
+        return this;
+    }
+
+    public String[] getOnBuild() {
+	return onBuild;
+    }
+
+    public void setOnBuild(String[] onBuild) {
+	this.onBuild=onBuild;
+    }
+
+    @Override
+    public String toString() {
+        return "ContainerConfig{" +
+                "hostName='" + hostName + '\'' +
+                ", portSpecs=" + Arrays.toString(portSpecs) +
+                ", user='" + user + '\'' +
+                ", tty=" + tty +
+                ", stdinOpen=" + stdinOpen +
+                ", stdInOnce=" + stdInOnce +
+                ", memoryLimit=" + memoryLimit +
+                ", memorySwap=" + memorySwap +
+                ", cpuShares=" + cpuShares +
+                ", attachStdin=" + attachStdin +
+                ", attachStdout=" + attachStdout +
+                ", attachStderr=" + attachStderr +
+                ", env=" + Arrays.toString(env) +
+                ", cmd=" + Arrays.toString(cmd) +
+                ", dns=" + Arrays.toString(dns) +
+                ", image='" + image + '\'' +
+                ", volumes=" + volumes +
+                ", volumesFrom='" + volumesFrom + '\'' +
+                ", entrypoint=" + Arrays.toString(entrypoint) +
+                ", networkDisabled=" + networkDisabled +
+                ", privileged=" + privileged +
+                ", workingDir='" + workingDir + '\'' +
+                ", domainName='" + domainName + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerCreateResponse.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerCreateResponse.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerCreateResponse.java
new file mode 100644
index 0000000..d56d677
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerCreateResponse.java
@@ -0,0 +1,43 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class ContainerCreateResponse {
+
+    @JsonProperty("Id")
+    private String id;
+
+    @JsonProperty("Warnings")
+    private String[] warnings;
+
+    public String getId() {
+        return id;
+    }
+
+    public String[] getWarnings() {
+        return warnings;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setWarnings(String[] warnings) {
+        this.warnings = warnings;
+    }
+
+    @Override
+    public String toString() {
+        return "ContainerCreateResponse{" +
+                "id='" + id + '\'' +
+                ", warnings=" + Arrays.toString(warnings) +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java
new file mode 100644
index 0000000..04d2f8c
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java
@@ -0,0 +1,247 @@
+package com.kpelykh.docker.client.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+import java.util.Map;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class ContainerInspectResponse {
+
+    @JsonProperty("ID")
+    private String id;
+
+    @JsonProperty("Created")
+    private String created;
+
+    @JsonProperty("Path")
+    private String path;
+
+    @JsonProperty("Args")
+    private String[] args;
+
+    @JsonProperty("Config")
+    public ContainerConfig config;
+
+    @JsonProperty("State")
+    private ContainerState state;
+
+    @JsonProperty("Image")
+    private String image;
+
+    @JsonProperty("NetworkSettings")
+    private NetworkSettings networkSettings;
+
+    @JsonProperty("SysInitPath")
+    private String sysInitPath;
+
+    @JsonProperty("ResolvConfPath")
+    private String resolvConfPath;
+
+    @JsonProperty("Volumes")
+    private Map<String, String> volumes;
+
+    @JsonProperty("VolumesRW")
+    private Map<String, String> volumesRW;
+
+    @JsonProperty("HostnamePath")
+    private String hostnamePath;
+
+    @JsonProperty("HostsPath")
+    private String hostsPath;
+
+    @JsonProperty("Name")
+    private String name;
+
+    @JsonProperty("Driver")
+    private String driver;
+
+    @JsonProperty("HostConfig")
+    private HostConfig hostConfig;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getCreated() {
+        return created;
+    }
+
+    public void setCreated(String created) {
+        this.created = created;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String[] getArgs() {
+        return args;
+    }
+
+    public void setArgs(String[] args) {
+        this.args = args;
+    }
+
+    public ContainerConfig getConfig() {
+        return config;
+    }
+
+    public void setConfig(ContainerConfig config) {
+        this.config = config;
+    }
+
+    public ContainerState getState() {
+        return state;
+    }
+
+    public void setState(ContainerState state) {
+        this.state = state;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public NetworkSettings getNetworkSettings() {
+        return networkSettings;
+    }
+
+    public void setNetworkSettings(NetworkSettings networkSettings) {
+        this.networkSettings = networkSettings;
+    }
+
+    public String getSysInitPath() {
+        return sysInitPath;
+    }
+
+    public void setSysInitPath(String sysInitPath) {
+        this.sysInitPath = sysInitPath;
+    }
+
+    public String getResolvConfPath() {
+        return resolvConfPath;
+    }
+
+    public void setResolvConfPath(String resolvConfPath) {
+        this.resolvConfPath = resolvConfPath;
+    }
+
+    public Map<String, String> getVolumes() {
+        return volumes;
+    }
+
+    public void setVolumes(Map<String, String> volumes) {
+        this.volumes = volumes;
+    }
+
+    public Map<String, String> getVolumesRW() {
+        return volumesRW;
+    }
+
+    public void setVolumesRW(Map<String, String> volumesRW) {
+        this.volumesRW = volumesRW;
+    }
+
+    public String getHostnamePath() {
+        return hostnamePath;
+    }
+
+    public void setHostnamePath(String hostnamePath) {
+        this.hostnamePath = hostnamePath;
+    }
+
+    public String getHostsPath() {
+        return hostsPath;
+    }
+
+    public void setHostsPath(String hostsPath) {
+        this.hostsPath = hostsPath;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    public HostConfig getHostConfig() {
+        return hostConfig;
+    }
+
+    public void setHostConfig(HostConfig hostConfig) {
+        this.hostConfig = hostConfig;
+    }
+
+    public class NetworkSettings {
+
+        @JsonProperty("IPAddress") public String ipAddress;
+        @JsonProperty("IPPrefixLen") public int ipPrefixLen;
+        @JsonProperty("Gateway") public String gateway;
+        @JsonProperty("Bridge") public String bridge;
+        @JsonProperty("PortMapping") public Map<String,Map<String, String>> portMapping;
+        @JsonProperty("Ports") public Ports ports;
+
+        @Override
+        public String toString() {
+            return "NetworkSettings{" +
+                    "ports=" + ports +
+                    ", portMapping=" + portMapping +
+                    ", bridge='" + bridge + '\'' +
+                    ", gateway='" + gateway + '\'' +
+                    ", ipPrefixLen=" + ipPrefixLen +
+                    ", ipAddress='" + ipAddress + '\'' +
+                    '}';
+        }
+    }
+
+    public class ContainerState {
+
+        @JsonProperty("Running") public boolean running;
+        @JsonProperty("Pid") public int pid;
+        @JsonProperty("ExitCode") public int exitCode;
+        @JsonProperty("StartedAt") public String startedAt;
+        @JsonProperty("Ghost") public boolean ghost;
+        @JsonProperty("FinishedAt") private String finishedAt;
+
+        @Override
+        public String toString() {
+            return "ContainerState{" +
+                    "running=" + running +
+                    ", pid=" + pid +
+                    ", exitCode=" + exitCode +
+                    ", startedAt='" + startedAt + '\'' +
+                    ", ghost=" + ghost +
+                    ", finishedAt='" + finishedAt + '\'' +
+                    '}';
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/CopyConfig.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/CopyConfig.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/CopyConfig.java
new file mode 100755
index 0000000..f94106c
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/CopyConfig.java
@@ -0,0 +1,61 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Configuration object for copy command.
+ * @author Victor Lyuboslavsky
+ */
+public class CopyConfig {
+
+    @JsonProperty("HostPath")
+    private String hostPath;
+
+    @JsonProperty("Resource")
+    private String resource;
+
+    /**
+     * Constructor.
+     */
+    public CopyConfig() {
+        hostPath = ".";
+    }
+
+    /**
+     * Retrieves the 'resource' variable.
+     * @return the 'resource' variable value
+     */
+    public String getResource() {
+        return resource;
+    }
+
+    /**
+     * Sets the 'resource' variable.
+     * @param resource the new 'resource' variable value to set
+     */
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    /**
+     * Retrieves the 'hostPath' variable.
+     * @return the 'hostPath' variable value
+     */
+    public String getHostPath() {
+        return hostPath;
+    }
+
+    /**
+     * Sets the 'hostPath' variable.
+     * @param hostPath the new 'hostPath' variable value to set
+     */
+    public void setHostPath(String hostPath) {
+        this.hostPath = hostPath;
+    }
+
+    @Override
+    public String toString() {
+        return "{\"HostPath\":\"" + hostPath + "\", \"Resource\":\"" + resource + "\"}";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/DriverStatus.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/DriverStatus.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/DriverStatus.java
new file mode 100644
index 0000000..2ed1922
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/DriverStatus.java
@@ -0,0 +1,31 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by ben on 12/12/13.
+ */
+public class DriverStatus {
+
+    @JsonProperty("Root Dir")
+    private String rootDir;
+
+    @JsonProperty("Dirs")
+    private int dirs;
+
+    public String getRootDir() {
+        return rootDir;
+    }
+
+    public int getDirs() {
+        return dirs;
+    }
+
+    @Override
+    public String toString() {
+        return "DriverStatus{" +
+                "rootDir='" + rootDir + '\'' +
+                ", dirs=" + dirs +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/HostConfig.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/HostConfig.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/HostConfig.java
new file mode 100644
index 0000000..47a12fe
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/HostConfig.java
@@ -0,0 +1,148 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class HostConfig {
+
+    @JsonProperty("Binds")
+    private String[] binds;
+
+    @JsonProperty("ContainerIDFile")
+    private String containerIDFile;
+
+    @JsonProperty("LxcConf")
+    private LxcConf[] lxcConf;
+
+
+    @JsonProperty("Links")
+    private String[] links;
+
+    @JsonProperty("PortBindings")
+    private Ports portBindings;
+
+    @JsonProperty("Privileged")
+    private boolean privileged;
+
+    @JsonProperty("PublishAllPorts")
+    private boolean publishAllPorts;
+
+    public HostConfig() {
+        this.binds = null;
+    }
+
+
+    public String[] getBinds() {
+        return binds;
+    }
+
+    public void setBinds(String[] binds) {
+        this.binds = binds;
+    }
+    
+    public void setBinds(final BoundHostVolumes volumes) {
+        setBinds(volumes.asBinds());
+    }
+
+    public String getContainerIDFile() {
+        return containerIDFile;
+    }
+
+    public void setContainerIDFile(String containerIDFile) {
+        this.containerIDFile = containerIDFile;
+    }
+
+    public LxcConf[] getLxcConf() {
+        return lxcConf;
+    }
+
+    public void setLxcConf(LxcConf[] lxcConf) {
+        this.lxcConf = lxcConf;
+    }
+
+    public String[] getLinks() {
+        return links;
+    }
+
+    public void setLinks(String[] links) {
+        this.links = links;
+    }
+
+    public Ports getPortBindings() {
+        return portBindings;
+    }
+
+    public void setPortBindings(Ports portBindings) {
+        this.portBindings = portBindings;
+    }
+
+    public boolean isPrivileged() {
+        return privileged;
+    }
+
+    public void setPrivileged(boolean privileged) {
+        this.privileged = privileged;
+    }
+
+    public boolean isPublishAllPorts() {
+        return publishAllPorts;
+    }
+
+    public void setPublishAllPorts(boolean publishAllPorts) {
+        this.publishAllPorts = publishAllPorts;
+    }
+
+    @Override
+    public String toString() {
+        return "HostConfig{" +
+                "binds=" + Arrays.toString(binds) +
+                ", containerIDFile='" + containerIDFile + '\'' +
+                ", lxcConf=" + Arrays.toString(lxcConf) +
+                ", links=" + Arrays.toString(links) +
+                ", portBindings=" + portBindings +
+                ", privileged=" + privileged +
+                ", publishAllPorts=" + publishAllPorts +
+                '}';
+    }
+
+    public class LxcConf {
+        @JsonProperty("Key")
+        public String key;
+
+        @JsonProperty("Value")
+        public String value;
+
+        public LxcConf(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+
+        public LxcConf() {
+        }
+
+        public String getKey() {
+            return key;
+        }
+
+        public LxcConf setKey(String key) {
+            this.key = key;
+            return this;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+        public LxcConf setValue(String value) {
+            this.value = value;
+            return this;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/IBuilder.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/IBuilder.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/IBuilder.java
new file mode 100644
index 0000000..7f5f160
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/IBuilder.java
@@ -0,0 +1,9 @@
+package com.kpelykh.docker.client.model;
+
+/**
+ * Created by ben on 12/12/13.
+ */
+public interface IBuilder<T> {
+
+    T build();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Image.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Image.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Image.java
new file mode 100644
index 0000000..4b68590
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Image.java
@@ -0,0 +1,116 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class Image {
+
+    @JsonProperty("Id")
+    private String id;
+
+    @JsonProperty("RepoTags")
+    private String[] repoTags;
+
+    @JsonProperty("Repository")
+    private String repository;
+
+    @JsonProperty("Tag")
+    private String tag;
+
+
+    @JsonProperty("ParentId")
+    private String parentId;
+
+    @JsonProperty("Created")
+    private long created;
+
+    @JsonProperty("Size")
+    private long size;
+
+    @JsonProperty("VirtualSize")
+    private long virtualSize;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String[] getRepoTags() {
+        return repoTags;
+    }
+
+    public void setRepoTags(String[] repoTags) {
+        this.repoTags = repoTags;
+    }
+
+    public String getRepository() {
+        return repository;
+    }
+
+    public void setRepository(String repository) {
+        this.repository = repository;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public long getCreated() {
+        return created;
+    }
+
+    public void setCreated(long created) {
+        this.created = created;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public long getVirtualSize() {
+        return virtualSize;
+    }
+
+    public void setVirtualSize(long virtualSize) {
+        this.virtualSize = virtualSize;
+    }
+
+    @Override
+    public String toString() {
+        return "Image{" +
+                "virtualSize=" + virtualSize +
+                ", id='" + id + '\'' +
+                ", repoTags=" + Arrays.toString(repoTags) +
+                ", repository='" + repository + '\'' +
+                ", tag='" + tag + '\'' +
+                ", parentId='" + parentId + '\'' +
+                ", created=" + created +
+                ", size=" + size +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageCreateResponse.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageCreateResponse.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageCreateResponse.java
new file mode 100644
index 0000000..4be6807
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageCreateResponse.java
@@ -0,0 +1,30 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Arrays;
+
+/**
+ * Parse reponses from /images/create
+ *
+ * @author Ryan Campbell (ryan.campbell@gmail.com)
+ *
+ */
+public class ImageCreateResponse {
+
+    @JsonProperty("status")
+    private String id;
+
+
+    public String getId() {
+        return id;
+    }
+
+
+    @Override
+    public String toString() {
+        return "ContainerCreateResponse{" +
+                "id='" + id + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageInspectResponse.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageInspectResponse.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageInspectResponse.java
new file mode 100644
index 0000000..4b714f4
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/ImageInspectResponse.java
@@ -0,0 +1,150 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class ImageInspectResponse {
+
+    @JsonProperty("id")
+    private String id;
+
+    @JsonProperty("parent") private String parent;
+
+    @JsonProperty("created") private String created;
+
+    @JsonProperty("container") private String container;
+
+    @JsonProperty("container_config") private ContainerConfig containerConfig;
+
+    @JsonProperty("Size") private int size;
+
+    @JsonProperty("docker_version") private String dockerVersion;
+
+    @JsonProperty("config") private ContainerConfig config;
+
+    @JsonProperty("architecture") private String arch;
+
+    @JsonProperty("comment") private String comment;
+
+    @JsonProperty("author") private String author;
+
+    @JsonProperty("os") private String os;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getParent() {
+        return parent;
+    }
+
+    public void setParent(String parent) {
+        this.parent = parent;
+    }
+
+    public String getCreated() {
+        return created;
+    }
+
+    public void setCreated(String created) {
+        this.created = created;
+    }
+
+    public String getContainer() {
+        return container;
+    }
+
+    public void setContainer(String container) {
+        this.container = container;
+    }
+
+    public ContainerConfig getContainerConfig() {
+        return containerConfig;
+    }
+
+    public void setContainerConfig(ContainerConfig containerConfig) {
+        this.containerConfig = containerConfig;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public String getDockerVersion() {
+        return dockerVersion;
+    }
+
+    public void setDockerVersion(String dockerVersion) {
+        this.dockerVersion = dockerVersion;
+    }
+
+    public ContainerConfig getConfig() {
+        return config;
+    }
+
+    public void setConfig(ContainerConfig config) {
+        this.config = config;
+    }
+
+    public String getArch() {
+        return arch;
+    }
+
+    public void setArch(String arch) {
+        this.arch = arch;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+
+    public String getOs() {
+        return os;
+    }
+
+    public void setOs(String os) {
+        this.os = os;
+    }
+
+    @Override
+    public String toString() {
+        return "ImageInspectResponse{" +
+                "id='" + id + '\'' +
+                ", parent='" + parent + '\'' +
+                ", created='" + created + '\'' +
+                ", container='" + container + '\'' +
+                ", containerConfig=" + containerConfig +
+                ", size=" + size +
+                ", dockerVersion='" + dockerVersion + '\'' +
+                ", config=" + config +
+                ", arch='" + arch + '\'' +
+                ", comment='" + comment + '\'' +
+                ", author='" + author + '\'' +
+                ", os='" + os + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Info.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Info.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Info.java
new file mode 100644
index 0000000..f340dc8
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Info.java
@@ -0,0 +1,225 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.List;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class Info {
+
+    @JsonProperty("Debug")
+    private boolean debug;
+
+    @JsonProperty("Containers")
+    private int    containers;
+
+    @JsonProperty("Driver")
+    private String driver;
+
+    @JsonProperty("DriverStatus")
+    private List<Object> driverStatuses;
+
+
+    @JsonProperty("Images")
+    private int    images;
+
+    @JsonProperty("IPv4Forwarding")
+    private String IPv4Forwarding;
+
+    @JsonProperty("IndexServerAddress")
+    private String IndexServerAddress;
+
+
+    @JsonProperty("InitPath")
+    private String initPath;
+
+    @JsonProperty("InitSha1")
+    private String initSha1;
+
+    @JsonProperty("KernelVersion")
+    private String kernelVersion;
+
+    @JsonProperty("LXCVersion")
+    private String lxcVersion;
+
+    @JsonProperty("MemoryLimit")
+    private boolean memoryLimit;
+
+    @JsonProperty("NEventsListener")
+    private long nEventListener;
+
+    @JsonProperty("NFd")
+    private int    NFd;
+
+    @JsonProperty("NGoroutines")
+    private int    NGoroutines;
+    
+    @JsonProperty("SwapLimit")
+    private int swapLimit;
+
+    @JsonProperty("ExecutionDriver")
+    private String executionDriver;
+
+    public boolean isDebug() {
+        return debug;
+    }
+
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
+
+    public int getContainers() {
+        return containers;
+    }
+
+    public void setContainers(int containers) {
+        this.containers = containers;
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    public List<Object> getDriverStatuses() {
+        return driverStatuses;
+    }
+
+    public void setDriverStatuses(List<Object> driverStatuses) {
+        this.driverStatuses = driverStatuses;
+    }
+
+    public int getImages() {
+        return images;
+    }
+
+    public void setImages(int images) {
+        this.images = images;
+    }
+
+    public String getIPv4Forwarding() {
+        return IPv4Forwarding;
+    }
+
+    public void setIPv4Forwarding(String IPv4Forwarding) {
+        this.IPv4Forwarding = IPv4Forwarding;
+    }
+
+    public String getIndexServerAddress() {
+        return IndexServerAddress;
+    }
+
+    public void setIndexServerAddress(String indexServerAddress) {
+        IndexServerAddress = indexServerAddress;
+    }
+
+    public String getInitPath() {
+        return initPath;
+    }
+
+    public void setInitPath(String initPath) {
+        this.initPath = initPath;
+    }
+
+    public String getInitSha1() {
+        return initSha1;
+    }
+
+    public void setInitSha1(String initSha1) {
+        this.initSha1 = initSha1;
+    }
+
+    public String getKernelVersion() {
+        return kernelVersion;
+    }
+
+    public void setKernelVersion(String kernelVersion) {
+        this.kernelVersion = kernelVersion;
+    }
+
+    public String getLxcVersion() {
+        return lxcVersion;
+    }
+
+    public void setLxcVersion(String lxcVersion) {
+        this.lxcVersion = lxcVersion;
+    }
+
+    public boolean isMemoryLimit() {
+        return memoryLimit;
+    }
+
+    public void setMemoryLimit(boolean memoryLimit) {
+        this.memoryLimit = memoryLimit;
+    }
+
+    public long getnEventListener() {
+        return nEventListener;
+    }
+
+    public void setnEventListener(long nEventListener) {
+        this.nEventListener = nEventListener;
+    }
+
+    public int getNFd() {
+        return NFd;
+    }
+
+    public void setNFd(int NFd) {
+        this.NFd = NFd;
+    }
+
+    public int getNGoroutines() {
+        return NGoroutines;
+    }
+
+    public void setNGoroutines(int NGoroutines) {
+        this.NGoroutines = NGoroutines;
+    }
+
+    public int getSwapLimit() {
+        return swapLimit;
+    }
+
+    public void setSwapLimit(int swapLimit) {
+        this.swapLimit = swapLimit;
+    }
+    public String getExecutionDriver() {
+        return executionDriver;
+    }
+
+    public void setExecutionDriver(String executionDriver) {
+        this.executionDriver=executionDriver;
+    }
+
+    @Override
+    public String toString() {
+        return "Info{" +
+                "debug=" + debug +
+                ", containers=" + containers +
+                ", driver='" + driver + '\'' +
+                ", driverStatuses=" + driverStatuses +
+                ", images=" + images +
+                ", IPv4Forwarding='" + IPv4Forwarding + '\'' +
+                ", IndexServerAddress='" + IndexServerAddress + '\'' +
+                ", initPath='" + initPath + '\'' +
+                ", initSha1='" + initSha1 + '\'' +
+                ", kernelVersion='" + kernelVersion + '\'' +
+                ", lxcVersion='" + lxcVersion + '\'' +
+                ", memoryLimit=" + memoryLimit +
+                ", nEventListener=" + nEventListener +
+                ", NFd=" + NFd +
+                ", NGoroutines=" + NGoroutines +
+                ", swapLimit=" + swapLimit +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Port.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Port.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Port.java
new file mode 100644
index 0000000..b4fa913
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Port.java
@@ -0,0 +1,52 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+  * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
+  */
+
+public class Port {
+
+    @JsonProperty("PrivatePort")
+    private long privatePort;
+
+    @JsonProperty("PublicPort")
+    private long publicPort;
+
+    @JsonProperty("Type")
+    private String type;
+
+    public long getPrivatePort() {
+        return privatePort;
+    }
+
+    public void setPrivatePort(long privatePort) {
+        this.privatePort = privatePort;
+    }
+
+    public long getPublicPort() {
+        return publicPort;
+    }
+
+    public void setPublicPort(long publicPort) {
+        this.publicPort = publicPort;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    @Override
+    public String toString() {
+        return "Port{" +
+                "privatePort=" + privatePort +
+                ", publicPort=" + publicPort +
+                ", type='" + type + '\'' +
+                '}';
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Ports.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Ports.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Ports.java
new file mode 100644
index 0000000..d9fdab6
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Ports.java
@@ -0,0 +1,131 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.*;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.node.NullNode;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Created by ben on 16/12/13.
+ */
+@JsonDeserialize(using=Ports.Deserializer.class)
+@JsonSerialize(using=Ports.Serializer.class)
+public class Ports {
+
+
+    private final Map<String, Port> ports = new HashMap<String, Port>();
+
+    public Ports() { }
+
+    public void addPort(Port port) {
+        ports.put(port.getPort(), port);
+    }
+
+    @Override
+    public String toString(){
+        return ports.toString();
+    }
+
+    public Map<String, Port> getAllPorts(){
+        return ports;
+    }
+
+    public static class Port{
+
+        private final String scheme;
+        private final String port;
+        private final String hostIp;
+        private final String hostPort;
+
+        public Port(String scheme_, String port_, String hostIp_, String hostPort_) {
+            scheme = scheme_;
+            port = port_;
+            hostIp = hostIp_;
+            hostPort = hostPort_;
+        }
+
+        public String getScheme() {
+            return scheme;
+        }
+
+        public String getPort() {
+            return port;
+        }
+
+        public String getHostIp() {
+            return hostIp;
+        }
+
+        public String getHostPort() {
+            return hostPort;
+        }
+
+        public static Port makePort(String full, String hostIp, String hostPort) {
+            if (full == null) return null;
+            String[] pieces = full.split("/");
+            return new Port(pieces[1], pieces[0], hostIp, hostPort);
+        }
+
+        @Override
+        public String toString() {
+            return "Port{" +
+                    "scheme='" + scheme + '\'' +
+                    ", port='" + port + '\'' +
+                    ", hostIp='" + hostIp + '\'' +
+                    ", hostPort='" + hostPort + '\'' +
+                    '}';
+        }
+    }
+
+    public static class Deserializer extends JsonDeserializer<Ports> {
+        @Override
+        public Ports deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+
+            Ports out = new Ports();
+            ObjectCodec oc = jsonParser.getCodec();
+            JsonNode node = oc.readTree(jsonParser);
+            for (Iterator<Map.Entry<String, JsonNode>> it = node.getFields(); it.hasNext();) {
+
+                Map.Entry<String, JsonNode> field = it.next();
+                if (!field.getValue().equals(NullNode.getInstance())) {
+                    String hostIp = field.getValue().get(0).get("HostIp").getTextValue();
+                    String hostPort = field.getValue().get(0).get("HostPort").getTextValue();
+                    out.addPort(Port.makePort(field.getKey(), hostIp, hostPort));
+                }
+            }
+            return out;
+        }
+    }
+
+    public static class Serializer extends JsonSerializer<Ports> {
+
+        @Override
+        public void serialize(Ports ports, JsonGenerator jsonGen,
+                              SerializerProvider serProvider) throws IOException, JsonProcessingException {
+
+            jsonGen.writeStartObject();//{
+            for(String portKey : ports.getAllPorts().keySet()){
+                Port p = ports.getAllPorts().get(portKey);
+                jsonGen.writeFieldName(p.getPort() + "/" + p.getScheme());
+                jsonGen.writeStartArray();
+                jsonGen.writeStartObject();
+                jsonGen.writeStringField("HostIp", p.hostIp);
+                jsonGen.writeStringField("HostPort", p.hostPort);
+                jsonGen.writeEndObject();
+                jsonGen.writeEndArray();
+            }
+            jsonGen.writeEndObject();//}
+        }
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/SearchItem.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/SearchItem.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/SearchItem.java
new file mode 100644
index 0000000..9c0942e
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/SearchItem.java
@@ -0,0 +1,52 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class SearchItem {
+
+    @JsonProperty("star_count")
+    private int starCount;
+
+    @JsonProperty("is_official")
+    private boolean isOfficial;
+
+    @JsonProperty("is_trusted")
+    private boolean isTrusted;
+
+    @JsonProperty("name")
+    private String name;
+
+    @JsonProperty("description")
+    private String description;
+
+    public int getStarCount() {
+        return starCount;
+    }
+
+    public boolean isOfficial() {
+        return isOfficial;
+    }
+
+    public boolean isTrusted() {
+        return isTrusted;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public String toString() {
+        return  "name='" + name + '\'' +
+                ", description='" + description + '\'' + '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/model/Version.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/model/Version.java b/docker-java/src/main/java/com/kpelykh/docker/client/model/Version.java
new file mode 100644
index 0000000..915ae67
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/model/Version.java
@@ -0,0 +1,91 @@
+package com.kpelykh.docker.client.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class Version {
+
+
+    @JsonProperty("Version")
+    private String version;
+
+    @JsonProperty("GitCommit")
+    private String  gitCommit;
+
+    @JsonProperty("GoVersion")
+    private String  goVersion;
+    
+    @JsonProperty("KernelVersion")
+    private String kernelVersion;
+
+    @JsonProperty("Arch")
+    private String  arch;
+
+    @JsonProperty("Os")
+    private String operatingSystem;
+
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public String getGitCommit() {
+        return gitCommit;
+    }
+
+    public void setGitCommit(String gitCommit) {
+        this.gitCommit = gitCommit;
+    }
+
+    public String getGoVersion() {
+        return goVersion;
+    }
+
+    public void setGoVersion(String goVersion) {
+        this.goVersion = goVersion;
+    }
+
+    public String getKernelVersion() {
+        return kernelVersion;
+    }
+
+    public void setKernelVersion(String kernelVersion) {
+        this.kernelVersion = kernelVersion;
+    }
+
+    public String getArch() {
+        return arch;
+    }
+
+    public void setArch(String arch) {
+        this.arch = arch;
+    }
+
+    public String getOperatingSystem() {
+        return operatingSystem;
+    }
+
+    public void setOperatingSystem(String operatingSystem) {
+        this.operatingSystem = operatingSystem;
+    }
+
+    @Override
+    public String toString() {
+        return "Version{" +
+                "version='" + version + '\'' +
+                ", gitCommit='" + gitCommit + '\'' +
+                ", goVersion='" + goVersion + '\'' +
+                ", kernelVersion='" + kernelVersion + '\'' +
+                ", arch='" + arch + '\'' +
+                ", operatingSystem='" + operatingSystem + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/utils/CompressArchiveUtil.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/utils/CompressArchiveUtil.java b/docker-java/src/main/java/com/kpelykh/docker/client/utils/CompressArchiveUtil.java
new file mode 100644
index 0000000..502ad0b
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/utils/CompressArchiveUtil.java
@@ -0,0 +1,59 @@
+package com.kpelykh.docker.client.utils;
+
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.RegexFileFilter;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.*;
+import java.util.Collection;
+
+import static org.apache.commons.io.filefilter.FileFilterUtils.*;
+
+public class CompressArchiveUtil {
+
+	public static File archiveTARFiles(File baseDir, String archiveNameWithOutExtension) throws IOException {
+
+		File tarFile = null;
+		
+        tarFile = new File(FileUtils.getTempDirectoryPath(), archiveNameWithOutExtension + ".tar");
+
+        Collection<File> files =
+                FileUtils.listFiles(
+                        baseDir,
+                        new RegexFileFilter("^(.*?)"),
+                        and(directoryFileFilter(), notFileFilter(nameFileFilter(baseDir.getName()))));
+
+        byte[] buf = new byte[1024];
+        int len;
+
+        {
+            TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile));
+            tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
+            for (File file : files) {
+                TarArchiveEntry tarEntry = new TarArchiveEntry(file);
+                tarEntry.setName(StringUtils.substringAfter(file.toString(), baseDir.getPath()));
+
+                tos.putArchiveEntry(tarEntry);
+
+                if (!file.isDirectory()) {
+                    FileInputStream fin = new FileInputStream(file);
+                    BufferedInputStream in = new BufferedInputStream(fin);
+
+                    while ((len = in.read(buf)) != -1) {
+                        tos.write(buf, 0, len);
+                    }
+
+                    in.close();
+                }
+                tos.closeArchiveEntry();
+
+            }
+            tos.close();
+        }
+
+		
+		return tarFile;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd8a4520/docker-java/src/main/java/com/kpelykh/docker/client/utils/JsonClientFilter.java
----------------------------------------------------------------------
diff --git a/docker-java/src/main/java/com/kpelykh/docker/client/utils/JsonClientFilter.java b/docker-java/src/main/java/com/kpelykh/docker/client/utils/JsonClientFilter.java
new file mode 100644
index 0000000..55b8b28
--- /dev/null
+++ b/docker-java/src/main/java/com/kpelykh/docker/client/utils/JsonClientFilter.java
@@ -0,0 +1,26 @@
+package com.kpelykh.docker.client.utils;
+
+
+import com.sun.jersey.api.client.ClientRequest;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.filter.ClientFilter;
+
+/**
+ *
+ * @author Konstantin Pelykh (kpelykh@gmail.com)
+ *
+ */
+public class JsonClientFilter extends ClientFilter {
+
+    public ClientResponse handle(ClientRequest cr) {
+        // Call the next filter
+        ClientResponse resp = getNext().handle(cr);
+        String respContentType = resp.getHeaders().getFirst("Content-Type");
+        if (respContentType.startsWith("text/plain")) {
+            String newContentType = "application/json" + respContentType.substring(10);
+            resp.getHeaders().putSingle("Content-Type", newContentType);
+        }
+        return resp;
+    }
+
+}


Mime
View raw message