List of usage examples for org.apache.commons.httpclient.methods PostMethod addParameter
public void addParameter(String paramString1, String paramString2) throws IllegalArgumentException
From source file:net.adamcin.granite.client.packman.http3.Http3PackageManagerClient.java
@Override public boolean login(String username, String password) throws IOException { PostMethod request = new PostMethod(getBaseUrl() + LOGIN_PATH); request.addParameter(LOGIN_PARAM_USERNAME, username); request.addParameter(LOGIN_PARAM_PASSWORD, password); request.addParameter(LOGIN_PARAM_VALIDATE, LOGIN_VALUE_VALIDATE); request.addParameter(LOGIN_PARAM_CHARSET, LOGIN_VALUE_CHARSET); int status = getClient().executeMethod(request); if (status == 405) { // if 405 Method not allowed, fallback to legacy login return loginLegacy(username, password); } else {/*from w w w . jav a 2 s .c om*/ return status == 200; } }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceTestIT.java
@Test(enabled = TestConstants.EnabledTest) public void testPresenceSolutionHill() { log.info("=== TEST for SOLUTION GENERATION of HILLCLIMB optimizer service STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", SearchMethodName.HILLCLIMB.toString()); executeAndCheck(client, method);//from www . jav a 2 s . c o m log.info("=== TEST for SOLUTION GENERATION of HILLCLIMB optimizer service FINISEHD ==="); }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceTestIT.java
@Test(enabled = TestConstants.EnabledTest) public void testPresenceSolutionBlind() { log.info("=== TEST for SOLUTION GENERATION of BLIND optimizer service STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", "BLINDSEARCH"); executeAndCheck(client, method);/*from www . jav a 2 s .co m*/ log.info("=== TEST for SOLUTION GENERATION of BLIND optimizer service FINISEHD ==="); }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceTestIT.java
@Test(enabled = TestConstants.EnabledTest) public void testPresenceSolutionAnneal() { log.info("=== TEST for SOLUTION GENERATION of ANNEAL optimizer service STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", SearchMethodName.ANNEAL.toString()); executeAndCheck(client, method);// www . j a v a2 s. c om log.info("=== TEST for SOLUTION GENERATION of ANNEAL optimizer service FINISEHD ==="); }
From source file:fr.msch.wissl.server.TServer.java
protected void addMusicFolder(String path, RuntimeStats rtStats) throws Exception { HttpClient c = new HttpClient(); PostMethod post = new PostMethod(URL + "folders/add"); post.addRequestHeader("sessionId", this.admin_sessionId); File folder = new File(path); post.addParameter("directory", folder.getAbsolutePath()); c.executeMethod(post);/* w ww . j a va 2 s . co m*/ Assert.assertEquals(204, post.getStatusCode()); checkStats(rtStats); }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceOpenShiftTest.java
@Test(enabled = TestConstants.EnabledTestOpenShift) //check also if the class is enabled public void testPresenceSolutionBlind() { log.info("=== TEST for SOLUTION GENERATION of BLIND optimizer service DEPLOYED IN OPENSHIFT STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", SearchMethodName.BLINDSEARCH.toString()); executeAndCheck(client, method, SearchMethodName.BLINDSEARCH.toString()); log.info("=== TEST for SOLUTION GENERATION of BLIND optimizer service DEPLOYED IN OPENSHIFT FINISEHD ==="); }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceOpenShiftTest.java
@Test(enabled = TestConstants.EnabledTestOpenShift) public void testPresenceSolutionAnneal() { log.info("=== TEST for SOLUTION GENERATION of ANNEAL optimizer service STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", SearchMethodName.ANNEAL.toString()); executeAndCheck(client, method, SearchMethodName.ANNEAL.toString()); log.info("=== TEST for SOLUTION GENERATION of ANNEAL optimizer service DEPLOYED IN OPENSHIFT FINISEHD ==="); }
From source file:eu.seaclouds.platform.planner.optimizerTest.service.OptimizerServiceOpenShiftTest.java
@Test(enabled = TestConstants.EnabledTestOpenShift) public void testPresenceSolutionHill() { log.info(//from w w w . j ava 2s.co m "=== TEST for SOLUTION GENERATION of HILLCLIMB optimizer service DEPLOYED IN OPENSHIFT STARTED ==="); String url = BASE_URL + "optimize"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.addParameter("aam", appModel); method.addParameter("offers", suitableCloudOffer); method.addParameter("optmethod", SearchMethodName.HILLCLIMB.toString()); executeAndCheck(client, method, SearchMethodName.HILLCLIMB.toString()); log.info( "=== TEST for SOLUTION GENERATION of HILLCLIMB optimizer service DEPLOYED IN OPENSHIFT FINISEHD ==="); }
From source file:com._17od.upm.transport.HTTPTransport.java
public void delete(String targetLocation, String name, String username, String password) throws TransportException { targetLocation = addTrailingSlash(targetLocation) + "deletefile.php"; PostMethod post = new PostMethod(targetLocation); post.addParameter("fileToDelete", name); //This part is wrapped in a try/finally so that we can ensure //the connection to the HTTP server is always closed cleanly try {//w w w . j av a 2s.com //Set the authentication details if (username != null) { Credentials creds = new UsernamePasswordCredentials(new String(username), new String(password)); URL url = new URL(targetLocation); AuthScope authScope = new AuthScope(url.getHost(), url.getPort()); client.getState().setCredentials(authScope, creds); client.getParams().setAuthenticationPreemptive(true); } int status = client.executeMethod(post); if (status != HttpStatus.SC_OK) { throw new TransportException( "There's been some kind of problem deleting a file on the HTTP server.\n\nThe HTTP error message is [" + HttpStatus.getStatusText(status) + "]"); } if (!post.getResponseBodyAsString().equals("OK")) { throw new TransportException( "There's been some kind of problem deleting a file to the HTTP server.\n\nThe error message is [" + post.getResponseBodyAsString() + "]"); } } catch (MalformedURLException e) { throw new TransportException(e); } catch (HttpException e) { throw new TransportException(e); } catch (IOException e) { throw new TransportException(e); } finally { post.releaseConnection(); } }
From source file:com.gisgraphy.rest.RestClient.java
private HttpMethod createPostMethod(String url, Map<String, Object> map) throws RestClientException { PostMethod httpMethod = new PostMethod(url); if (map != null) { for (String key : map.keySet()) { if (map.get(key) != null) { httpMethod.addParameter(key, map.get(key).toString()); }//w w w. j a va2s . c om } } httpMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); return httpMethod; }