Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private PAKCRestServiceWrapperTO callService(
- SimulationInstanceTO simulationInstanceTO,
- SessionIndexTO sessionIndexTO, InputStream is) throws Exception {
- String session = null;
- PAKCRestServiceWrapperTO result = new PAKCRestServiceWrapperTO();
- PAKCRestServiceTO simulationInstance = new PAKCRestServiceTO();
- byte[] cfgFileByteArr = IOUtils.toByteArray(is);
- simulationInstance.setCfgFile(cfgFileByteArr);
- String parameter = Util.getJsonStrFromObject(simulationInstance);
- System.out
- .println("http://213.249.38.66:7072/SolverInterface/webresources/solver/authenticate"
- + "/testusername/password");
- session = Request
- .Get("http://213.249.38.66:7072/SolverInterface/webresources/solver/authenticate"
- + "/testusername/password").execute().returnContent()
- .asString();
- System.out.println(session);
- Request.Post(
- "http://213.249.38.66:7072/SolverInterface/webresources/ConfigurationFile/upload/"
- + session)
- .bodyForm(
- Form.form().add("simulationInstance", parameter)
- .build()).execute();
- Request.Get(
- "http://213.249.38.66:7072/SolverInterface/webresources/solver/cad/init"
- + "/" + session).execute();
- Integer status = HttpStatus.SC_NOT_FOUND;
- while(status!=HttpStatus.SC_OK){
- status = getStatus(session);
- Thread.sleep(15000);
- }
- System.out.println();
- System.out.println("OK");
- /*
- * Thread.sleep(240000);
- */
- //subscribeWithTopicLookup(session);
- System.out.println(" -------------- Done");
- String responseContentStr = Request
- .Get("http://213.249.38.66:7072/SolverInterface/webresources/accessResults/simulation/"
- + session).execute().returnContent().asString();
- System.out.println(" -------------- Done");
- Gson gson = new GsonBuilder().create();
- simulationInstance = gson.fromJson(responseContentStr,PAKCRestServiceTO.class);
- InputStream datIS = new ByteArrayInputStream(simulationInstance.getDatFile());
- InputStream unvIS = new ByteArrayInputStream(simulationInstance.getUnvFile());
- System.out.println(" -------------- Done");
- result.setSessionID(session);
- result.setDatFile(datIS);
- result.setUnvFile(unvIS);
- System.out.println(" -------------- Done Result");
- return result;
- }
- private int getStatus(String session) throws ClientProtocolException, IOException {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- int result = 0;
- try{
- HttpGet getRequest = new HttpGet(
- "http://213.249.38.66:7072/SolverInterface/webresources/accessResults/simulation"+ "/" + session);
- getRequest.addHeader("accept", "application/json");
- HttpResponse response = httpclient.execute(getRequest);
- result = response.getStatusLine().getStatusCode();
- }finally{
- httpclient.close();
- httpclient.getConnectionManager().shutdown();
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement