Example usage for org.apache.commons.httpclient.methods MultipartPostMethod addParameter

List of usage examples for org.apache.commons.httpclient.methods MultipartPostMethod addParameter

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods MultipartPostMethod addParameter.

Prototype

public void addParameter(String paramString1, String paramString2) 

Source Link

Usage

From source file:org.openmicroscopy.is.HttpImageServer.java

public void setThumbnail(long pixelsID, CompositingSettings settings) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from w  ww .  j a v  a2  s .c  om
        post.addParameter("Method", "Composite");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        post.addParameter("SetThumb", "1");
        addCompositingSettings(post, settings);
        executeCall(post);

        return;
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public BufferedImage getThumbnail(long pixelsID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {/*from   ww  w . j  a  v  a 2  s  .c  o  m*/
        post.addParameter("Method", "GetThumb");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        executeCall(post);

        byte[] imageBuf = post.getResponseBody();
        ByteArrayInputStream is = new ByteArrayInputStream(imageBuf);
        try {
            return ImageIO.read(is);
        } catch (IOException e) {
            throw new ImageServerException("Cannot read byte array stream?");
        }
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public BufferedImage getThumbnail(long pixelsID, int sizeX, int sizeY) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from  w w  w.j av  a 2  s.com
        post.addParameter("Method", "GetThumb");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        String size = Integer.toString(sizeX) + "," + Integer.toString(sizeY);
        post.addParameter("Size", size);
        executeCall(post);

        byte[] imageBuf = post.getResponseBody();
        ByteArrayInputStream is = new ByteArrayInputStream(imageBuf);
        try {
            return ImageIO.read(is);
        } catch (IOException e) {
            throw new ImageServerException("Cannot read byte array stream?");
        }
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public long uploadFile(File file) throws ImageServerException, FileNotFoundException {
    MultipartPostMethod post = startCall();
    try {/*from  ww  w .ja  v  a  2 s.c  om*/
        post.addParameter("Method", "UploadFile");
        post.addParameter("File", file);
        executeCall(post);

        return Long.parseLong(post.getResponseBodyAsString().trim());
    } catch (NumberFormatException e) {
        throw new ImageServerException("Illegal response: Invalid file ID");
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public FileInfo getFileInfo(long fileID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {/*from   ww  w  . j  a v  a2s  .co m*/
        post.addParameter("Method", "FileInfo");
        post.addParameter("FileID", Long.toString(fileID));
        executeCall(post);

        String result = post.getResponseBodyAsString();
        StringTokenizer token = new StringTokenizer(result, "\r\n=,");

        checkToken(token, "Name");

        // Just for the filename token, ignore "=" and "," as
        // delimeters.  Also, there will be a leading "=" that we
        // need to remove.
        String name = token.nextToken("\r\n").substring(1);

        // Set the delimeters back
        checkToken(token, "Length", "\r\n=,");
        long length = getLongToken(token);

        return new FileInfo(name, length);
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public String getFileSHA1(long fileID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from  w ww. j  a  va 2s. com
        post.addParameter("Method", "FileSHA1");
        post.addParameter("FileID", Long.toString(fileID));
        executeCall(post);

        return post.getResponseBodyAsString().trim();
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public String getFileServerPath(long fileID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {// w  w  w .j  a  v  a  2 s.com
        post.addParameter("Method", "GetLocalPath");
        post.addParameter("FileID", Long.toString(fileID));
        executeCall(post);

        return post.getResponseBodyAsString().trim();
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public byte[] readFileWithoutCaching(final long fileID, final long offset, final int length)
        throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from   ww  w . j a  v a  2 s .  c o  m
        post.addParameter("Method", "ReadFile");
        post.addParameter("FileID", Long.toString(fileID));
        post.addParameter("Offset", Long.toString(offset));
        post.addParameter("Length", Integer.toString(length));
        executeCall(post);

        return post.getResponseBody();
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public long convertStack(final long pixelsID, final int theC, final int theT, final long fileID,
        final long offset, final boolean bigEndian) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {/*from  w ww .jav  a 2s. c  o  m*/
        post.addParameter("Method", "ConvertStack");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        post.addParameter("theC", Integer.toString(theC));
        post.addParameter("theT", Integer.toString(theT));
        post.addParameter("FileID", Long.toString(fileID));
        post.addParameter("Offset", Long.toString(offset));
        post.addParameter("BigEndian", bigEndian ? "1" : "0");
        executeCall(post);

        return Long.parseLong(post.getResponseBodyAsString().trim());
    } finally {
        finishCall(post);
    }
}

From source file:org.openmicroscopy.is.HttpImageServer.java

public long convertPlane(final long pixelsID, final int theZ, final int theC, final int theT, final long fileID,
        final long offset, final boolean bigEndian) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from ww  w. ja  v  a 2  s  .co m
        post.addParameter("Method", "ConvertPlane");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        post.addParameter("theZ", Integer.toString(theZ));
        post.addParameter("theC", Integer.toString(theC));
        post.addParameter("theT", Integer.toString(theT));
        post.addParameter("FileID", Long.toString(fileID));
        post.addParameter("Offset", Long.toString(offset));
        post.addParameter("BigEndian", bigEndian ? "1" : "0");
        executeCall(post);

        return Long.parseLong(post.getResponseBodyAsString().trim());
    } finally {
        finishCall(post);
    }
}