* This URL points to a GRATE session that contains the object readily waiting
* to be rendered, already injected into the appropriate environment.
* @throws PlatoServiceException if the connection to the GRATE server failed
*/
public String startSession (String samplename, byte[] data, String toolID) throws PlatoServiceException{
ToolConfig config = getToolConfig(toolID);
String response;
try {
HttpClient client = new HttpClient();
MultipartPostMethod mPost = new MultipartPostMethod(config.getTool().getExecutablePath());
client.setConnectionTimeout(8000);
// MultipartPostMethod needs a file instance
File sample = File.createTempFile(samplename+System.nanoTime(), "tmp");
OutputStream out = new BufferedOutputStream(new FileOutputStream(sample));
out.write(data);
out.close();
mPost.addParameter("datei", samplename, sample);
int statusCode = client.executeMethod(mPost);
response = mPost.getResponseBodyAsString();
return response+ config.getParams();
} catch (HttpException e) {
throw new PlatoServiceException("Could not connect to GRATE.", e);
} catch (FileNotFoundException e) {
throw new PlatoServiceException("Could not create temp file.", e);