List of usage examples for org.apache.commons.httpclient.methods MultipartPostMethod addParameter
public void addParameter(String paramString1, String paramString2)
From source file:org.openmicroscopy.is.HttpImageServer.java
public long newPixels(int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int bytesPerPixel, boolean isSigned, boolean isFloat) throws ImageServerException { String dims = sizeX + "," + sizeY + "," + sizeZ + "," + sizeC + "," + sizeT + "," + bytesPerPixel; MultipartPostMethod post = startCall(); try {//from ww w.j av a 2 s .c om post.addParameter("Method", "NewPixels"); post.addParameter("Dims", dims); post.addParameter("IsSigned", isSigned ? "1" : "0"); post.addParameter("IsFloat", isFloat ? "1" : "0"); executeCall(post); return Long.parseLong(post.getResponseBodyAsString().trim()); } catch (NumberFormatException e) { throw new ImageServerException("Illegal response: Invalid pixels ID"); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public PixelsFileFormat getPixelsInfo(long pixelsID) throws ImageServerException { MultipartPostMethod post = startCall(); try {//from w ww.j a va 2s . co m post.addParameter("Method", "PixelsInfo"); post.addParameter("PixelsID", Long.toString(pixelsID)); executeCall(post); String result = post.getResponseBodyAsString(); StringTokenizer token = new StringTokenizer(result, "\r\n=,"); checkToken(token, "Dims"); int sizeX = getIntToken(token); int sizeY = getIntToken(token); int sizeZ = getIntToken(token); int sizeC = getIntToken(token); int sizeT = getIntToken(token); int bytesPerPixel = getIntToken(token); checkToken(token, "Finished"); getIntToken(token); checkToken(token, "Signed"); int isSigned = getIntToken(token); checkToken(token, "Float"); int isFloat = getIntToken(token); return new PixelsFileFormat(sizeX, sizeY, sizeZ, sizeC, sizeT, bytesPerPixel, isSigned == 1, isFloat == 1); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public String getPixelsSHA1(long pixelsID) throws ImageServerException { MultipartPostMethod post = startCall(); try {/*from ww w .j a va2 s .co m*/ post.addParameter("Method", "PixelsSHA1"); post.addParameter("PixelsID", Long.toString(pixelsID)); executeCall(post); return post.getResponseBodyAsString().trim(); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public String getPixelsServerPath(long pixelsID) throws ImageServerException { MultipartPostMethod post = startCall(); try {/*from ww w . j av a2s . c om*/ post.addParameter("Method", "GetLocalPath"); post.addParameter("PixelsID", Long.toString(pixelsID)); executeCall(post); return post.getResponseBodyAsString().trim(); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public boolean isPixelsFinished(long pixelsID) throws ImageServerException { MultipartPostMethod post = startCall(); try {/* w ww.j ava2s . co m*/ post.addParameter("Method", "PixelsInfo"); post.addParameter("PixelsID", Long.toString(pixelsID)); executeCall(post); String result = post.getResponseBodyAsString(); StringTokenizer token = new StringTokenizer(result, "\r\n=,"); checkToken(token, "Dims"); getIntToken(token); getIntToken(token); getIntToken(token); getIntToken(token); getIntToken(token); getIntToken(token); checkToken(token, "Finished"); int isFinished = getIntToken(token); checkToken(token, "Signed"); getIntToken(token); checkToken(token, "Float"); getIntToken(token); return (isFinished == 1); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public byte[] getPixels(long pixelsID, boolean bigEndian) throws ImageServerException { MultipartPostMethod post = startCall(); try {/* w ww . j a v a 2 s .c o m*/ post.addParameter("Method", "GetPixels"); post.addParameter("PixelsID", Long.toString(pixelsID)); post.addParameter("BigEndian", bigEndian ? "1" : "0"); executeCall(post); return post.getResponseBody(); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public byte[] getStack(long pixelsID, int theC, int theT, boolean bigEndian) throws ImageServerException { MultipartPostMethod post = startCall(); try {/*from ww w .j ava2s . c o m*/ post.addParameter("Method", "GetStack"); post.addParameter("PixelsID", Long.toString(pixelsID)); post.addParameter("theC", Integer.toString(theC)); post.addParameter("theT", Integer.toString(theT)); post.addParameter("BigEndian", bigEndian ? "1" : "0"); executeCall(post); return post.getResponseBody(); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public InputStream getStackStream(long pixelsID, int theC, int theT, boolean bigEndian) throws ImageServerException { MultipartPostMethod post = startCall(); try {/* w w w. j ava 2 s .c om*/ post.addParameter("Method", "GetStack"); post.addParameter("PixelsID", Long.toString(pixelsID)); post.addParameter("theC", Integer.toString(theC)); post.addParameter("theT", Integer.toString(theT)); post.addParameter("BigEndian", bigEndian ? "1" : "0"); executeCall(post); return post.getResponseBodyAsStream(); } catch (IOException ioe) { throw new ImageServerException("IO Exception: " + ioe); } //The caller will have to close the stream explicitely, this should //release the connection as well b/c of the auto-close mechanism used //in HttpMethodBase.readResponseBody(HttpConnection) line 2103. //REQUIRES FURTHER INVESTIGATION. }
From source file:org.openmicroscopy.is.HttpImageServer.java
public byte[] getPlane(long pixelsID, int theZ, int theC, int theT, boolean bigEndian) throws ImageServerException { MultipartPostMethod post = startCall(); try {/* ww w .j ava2 s. co m*/ post.addParameter("Method", "GetPlane"); 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("BigEndian", bigEndian ? "1" : "0"); executeCall(post); return post.getResponseBody(); } finally { finishCall(post); } }
From source file:org.openmicroscopy.is.HttpImageServer.java
public byte[] getROI(long pixelsID, int x0, int y0, int z0, int c0, int t0, int x1, int y1, int z1, int c1, int t1, boolean bigEndian) throws ImageServerException { String roi = x0 + "," + y0 + "," + z0 + "," + c0 + "," + t0 + "," + x1 + "," + y1 + "," + z1 + "," + c1 + "," + t1; MultipartPostMethod post = startCall(); try {//w ww . j a v a 2 s . co m post.addParameter("Method", "GetROI"); post.addParameter("PixelsID", Long.toString(pixelsID)); post.addParameter("ROI", roi); post.addParameter("BigEndian", bigEndian ? "1" : "0"); executeCall(post); return post.getResponseBody(); } finally { finishCall(post); } }