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

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

Introduction

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

Prototype

@Override
public String getResponseBodyAsString() throws IOException 

Source Link

Document

Returns the response body of the HTTP method, if any, as a String .

Usage

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

public String getFileSHA1(long fileID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//from  w  w  w.  j a  va2s  .  co m
        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 {//from   www. j  a  va 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 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 {// w  w w . j av  a2s  .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  .  j av a  2s  . c om*/
        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);
    }
}

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

public long convertPlaneFromTIFF(final long pixelsID, final int theZ, final int theC, final int theT,
        final long fileID) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {/*from   w w  w  .  ja  va  2s  .co  m*/
        post.addParameter("Method", "ConvertTIFF");
        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));
        executeCall(post);

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

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

public long convertPlaneFromTIFF(final long pixelsID, final int theZ, final int theC, final int theT,
        final long fileID, final int directory) throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {/*from   ww w  .ja va2s .  c  o m*/
        post.addParameter("Method", "ConvertTIFF");
        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("TIFFDirIndex", Integer.toString(directory));
        executeCall(post);

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

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

public long convertRows(final long pixelsID, final int theY, final int numRows, final int theZ, final int theC,
        final int theT, final long fileID, final long offset, final boolean bigEndian)
        throws ImageServerException {
    MultipartPostMethod post = startCall();
    try {//ww  w. j  av  a 2  s. c  o  m
        post.addParameter("Method", "ConvertRows");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        post.addParameter("theY", Integer.toString(theY));
        post.addParameter("nRows", Integer.toString(numRows));
        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);
    }
}

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

public PlaneStatistics getPlaneStatistics(long pixelsID) throws ImageServerException {
    PixelsFileFormat pff = getPixelsInfo(pixelsID);
    int sizeZ = pff.getSizeZ();
    int sizeC = pff.getSizeC();
    int sizeT = pff.getSizeT();

    MultipartPostMethod post = startCall();
    try {//from   w ww .j  ava  2  s  .  c  om
        post.addParameter("Method", "GetPlaneStats");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        executeCall(post);

        double[][][] minimum = new double[sizeZ][sizeC][sizeT], maximum = new double[sizeZ][sizeC][sizeT],
                mean = new double[sizeZ][sizeC][sizeT], sigma = new double[sizeZ][sizeC][sizeT],
                geomean = new double[sizeZ][sizeC][sizeT], geosigma = new double[sizeZ][sizeC][sizeT],
                centroidX = new double[sizeZ][sizeC][sizeT], centroidY = new double[sizeZ][sizeC][sizeT],
                sumI = new double[sizeZ][sizeC][sizeT], sumI2 = new double[sizeZ][sizeC][sizeT],
                sumLogI = new double[sizeZ][sizeC][sizeT], sumXI = new double[sizeZ][sizeC][sizeT],
                sumYI = new double[sizeZ][sizeC][sizeT], sumZI = new double[sizeZ][sizeC][sizeT];

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

        while (rtoken.hasMoreTokens()) {
            String line = rtoken.nextToken();
            StringTokenizer ltoken = new StringTokenizer(line, "\t");

            int theC = getIntToken(ltoken);
            int theT = getIntToken(ltoken);
            int theZ = getIntToken(ltoken);
            minimum[theZ][theC][theT] = getDoubleToken(ltoken);
            maximum[theZ][theC][theT] = getDoubleToken(ltoken);
            mean[theZ][theC][theT] = getDoubleToken(ltoken);
            geomean[theZ][theC][theT] = getDoubleToken(ltoken);
            geosigma[theZ][theC][theT] = getDoubleToken(ltoken);
            centroidX[theZ][theC][theT] = getDoubleToken(ltoken);
            centroidY[theZ][theC][theT] = getDoubleToken(ltoken);
            sumI[theZ][theC][theT] = getDoubleToken(ltoken);
            sumI2[theZ][theC][theT] = getDoubleToken(ltoken);
            sumLogI[theZ][theC][theT] = getDoubleToken(ltoken);
            sumXI[theZ][theC][theT] = getDoubleToken(ltoken);
            sumYI[theZ][theC][theT] = getDoubleToken(ltoken);
            sumZI[theZ][theC][theT] = getDoubleToken(ltoken);
        }

        return new PlaneStatistics(minimum, maximum, mean, sigma, geomean, geosigma, centroidX, centroidY, sumI,
                sumI2, sumLogI, sumXI, sumYI, sumZI);
    } finally {
        finishCall(post);
    }
}

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

public StackStatistics getStackStatistics(long pixelsID) throws ImageServerException {
    PixelsFileFormat pff = getPixelsInfo(pixelsID);
    int sizeC = pff.getSizeC();
    int sizeT = pff.getSizeT();

    MultipartPostMethod post = startCall();
    try {//from   w  w  w.  j av a2 s .  co  m
        post.addParameter("Method", "GetStackStats");
        post.addParameter("PixelsID", Long.toString(pixelsID));
        executeCall(post);

        double[][] minimum = new double[sizeC][sizeT], maximum = new double[sizeC][sizeT],
                mean = new double[sizeC][sizeT], sigma = new double[sizeC][sizeT],
                geomean = new double[sizeC][sizeT], geosigma = new double[sizeC][sizeT],
                centroidX = new double[sizeC][sizeT], centroidY = new double[sizeC][sizeT],
                centroidZ = new double[sizeC][sizeT], sumI = new double[sizeC][sizeT],
                sumI2 = new double[sizeC][sizeT], sumLogI = new double[sizeC][sizeT],
                sumXI = new double[sizeC][sizeT], sumYI = new double[sizeC][sizeT],
                sumZI = new double[sizeC][sizeT];

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

        while (rtoken.hasMoreTokens()) {
            String line = rtoken.nextToken();
            StringTokenizer ltoken = new StringTokenizer(line, "\t");

            int theC = getIntToken(ltoken);
            int theT = getIntToken(ltoken);
            minimum[theC][theT] = getDoubleToken(ltoken);
            maximum[theC][theT] = getDoubleToken(ltoken);
            mean[theC][theT] = getDoubleToken(ltoken);
            geomean[theC][theT] = getDoubleToken(ltoken);
            geosigma[theC][theT] = getDoubleToken(ltoken);
            centroidX[theC][theT] = getDoubleToken(ltoken);
            centroidY[theC][theT] = getDoubleToken(ltoken);
            centroidZ[theC][theT] = getDoubleToken(ltoken);
            sumI[theC][theT] = getDoubleToken(ltoken);
            sumI2[theC][theT] = getDoubleToken(ltoken);
            sumLogI[theC][theT] = getDoubleToken(ltoken);
            sumXI[theC][theT] = getDoubleToken(ltoken);
            sumYI[theC][theT] = getDoubleToken(ltoken);
            sumZI[theC][theT] = getDoubleToken(ltoken);
        }

        return new StackStatistics(minimum, maximum, mean, sigma, geomean, geosigma, centroidX, centroidY,
                centroidZ, sumI, sumI2, sumLogI, sumXI, sumYI, sumZI);
    } finally {
        finishCall(post);
    }
}