List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:module.entities.NameFinder.RegexNameFinder.java
/** * @param args the command line arguments *//*from ww w . j a v a2 s . c om*/ public static void main(String[] args) throws SQLException, IOException { if (args.length == 1) { Config.configFile = args[0]; } long lStartTime = System.currentTimeMillis(); Timestamp startTime = new Timestamp(lStartTime); System.out.println("Regex Name Finder process started at: " + startTime); DB.initPostgres(); regexerId = DB.LogRegexFinder(lStartTime); initLexicons(); JSONObject obj = new JSONObject(); TreeMap<Integer, String> consultations = DB.getDemocracitConsultationBody(); Document doc; int count = 0; TreeMap<Integer, String> consFoundNames = new TreeMap<>(); TreeMap<Integer, String> consFoundRoles = new TreeMap<>(); for (int consId : consultations.keySet()) { String consBody = consultations.get(consId); String signName = "", roleName = ""; doc = Jsoup.parse(consBody); Elements allPars = new Elements(); Elements paragraphs = doc.select("p"); for (Element par : paragraphs) { if (par.html().contains("<br>")) { String out = "<p>" + par.html().replaceAll("<br>", "</p><p>") + "</p>"; Document internal_doc = Jsoup.parse(out); Elements subparagraphs = internal_doc.select("p"); allPars.addAll(subparagraphs); } else { allPars.add(par); } // System.out.println(formatedText); } String signature = getSignatureFromParagraphs(allPars); // System.out.println(signature); if (signature.contains("#")) { String[] sign_tokens = signature.split("#"); signName = sign_tokens[0]; if (sign_tokens.length > 1) { roleName = sign_tokens[1]; } consFoundNames.put(consId, signName.trim()); consFoundRoles.put(consId, roleName.trim()); count++; } else { System.err.println("--" + consId); } // } DB.insertDemocracitConsultationMinister(consFoundNames, consFoundRoles); TreeMap<Integer, String> consultationsCompletedText = DB.getDemocracitCompletedConsultationBody(); Document doc2; TreeMap<Integer, String> complConsFoundNames = new TreeMap<>(); int count2 = 0; for (int consId : consultationsCompletedText.keySet()) { String consBody = consultationsCompletedText.get(consId); String signName = "", roleName = ""; doc2 = Jsoup.parse(consBody); // if (doc.text().contains("<br>")) { // doc.text().replaceAll("(<[Bb][Rr]>)+", "<p>"); // } Elements allPars = new Elements(); Elements paragraphs = doc2.select("p"); for (Element par : paragraphs) { if (par.html().contains("<br>")) { String out = "<p>" + par.html().replaceAll("<br>", "</p><p>") + "</p>"; Document internal_doc = Jsoup.parse(out); Elements subparagraphs = internal_doc.select("p"); allPars.addAll(subparagraphs); } else { allPars.add(par); } } String signature = getSignatureFromParagraphs(allPars); if (signature.contains("#")) { String[] sign_tokens = signature.split("#"); signName = sign_tokens[0]; if (sign_tokens.length > 1) { roleName = sign_tokens[1]; } consFoundNames.put(consId, signName.trim()); consFoundRoles.put(consId, roleName.trim()); // System.out.println(consId); // System.out.println(signName.trim()); // System.out.println("***************"); count2++; } else { System.err.println("++" + consId); } } DB.insertDemocracitConsultationMinister(complConsFoundNames, consFoundRoles); long lEndTime = System.currentTimeMillis(); System.out.println("Regex Name Finder process finished at: " + startTime); obj.put("message", "Regex Name Finder finished with no errors"); obj.put("details", ""); DB.UpdateLogRegexFinder(lEndTime, regexerId, obj); DB.close(); }
From source file:com.example.main.Main.java
/** * @param args//from w w w . java 2 s. c o m */ public static void main(String[] args) throws Exception { String webappDirLocation = "src/main/webapp/"; // The port that we should run on can be set into an environment variable // Look for that variable and default to 8080 if it isn't there. String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = "8082"; } Server server = new Server(Integer.valueOf(webPort)); WebAppContext root = new WebAppContext(); root.setContextPath("/"); root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml"); root.setResourceBase(webappDirLocation); PersistenceManager.getInstance().getEntityManagerFactory(); // Parent loader priority is a class loader setting that Jetty accepts. // By default Jetty will behave like most web containers in that it will // allow your application to replace non-server libraries that are part of the // container. Setting parent loader priority to true changes this behavior. // Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading root.setParentLoaderPriority(true); try { JSONObject datos = new JSONObject(); datos.put("nombrePagina", "Competencias"); datos.put("urlPagina", "localHost:8082"); JSONObject datos2 = new JSONObject(); datos2.put("nombrePagina", "Competencias"); datos2.put("nuevoEstado", "Activo"); JSONObject datos3 = new JSONObject(); datos3.put("nombrePagina", "Competencias"); datos3.put("nombreServicio", "Competencias"); datos3.put("rutaServicio", "Competencias"); JSONObject datos4 = new JSONObject(); datos4.put("nombrePagina", "Competencias"); datos4.put("nombreServicio", "Ganadores"); datos4.put("rutaServicio", "Competencias/winners/{name}"); Client client = Client.create(); WebResource target = client.resource(SERVIDOR_ZK + "inscribirPagina"); target.post(JSONObject.class, datos); target = client.resource(SERVIDOR_ZK + "estadoPagina"); target.post(JSONObject.class, datos2); target = client.resource(SERVIDOR_ZK + "servicioPagina"); target.post(JSONObject.class, datos3); target = client.resource(SERVIDOR_ZK + "servicioPagina"); target.post(JSONObject.class, datos4); client.destroy(); } catch (Exception e) { e.printStackTrace(); } server.setHandler(root); server.start(); server.join(); }
From source file:com.owly.clnt.OwlyClnt.java
/** * @param args// www . jav a 2 s . c om * First argument in the port where webserver is going to start */ public static void main(String[] args) { Logger log = Logger.getLogger(OwlyClnt.class); log.debug("Executing OwlyClnt"); if (args.length == 1) { String clientport = args[0]; setPort(Integer.parseInt(clientport)); log.debug("Port to run :" + clientport); // URL used for generating the VMstat of the server get(new Route("/OwlyClnt/Stats_Vmstat") { @Override public Object handle(Request request, Response response) { Logger log = Logger.getLogger(OwlyClnt.class); log.debug("Calling Stats_Vmstat"); OSValidator osValidator = new OSValidator(); log.debug("operating System " + osValidator.getOS()); JSONObject json = new JSONObject(); if (osValidator.isWindows()) { StatsWinTypeperf testStats = new StatsWinTypeperf(); try { json = testStats.getWinTypeperf(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { if (OSValidator.isUnix()) { StatsVmstat testStats = new StatsVmstat(); try { json = testStats.getJSONVmStat(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { json.put("StatType", "NOK"); } } return json.toString(); } }); // URL used for generating the TopCPU of the server get(new Route("/OwlyClnt/Stats_TopCPU") { @Override public Object handle(Request request, Response response) { Logger log = Logger.getLogger(OwlyClnt.class); log.debug("Calling Stats_Vmstat"); OSValidator osValidator = new OSValidator(); log.debug("operating System " + osValidator.getOS()); JSONObject topCpuStatJson = new JSONObject(); if (OSValidator.isUnix()) { StatsTopCpu testStats = new StatsTopCpu(); try { topCpuStatJson = testStats.getJSONTopCpu(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { topCpuStatJson.put("StatType", "NOK"); } return topCpuStatJson.toString(); } }); // Url used for executing a healthcheck and see if the server is // available get(new Route("/healthCheck") { @Override public Object handle(Request request, Response response) { JSONObject objJSON = new JSONObject(); objJSON.put("StatusServer", "OK"); return objJSON.toString(); } }); } else { System.out.println("ERROR : you need to specify port number -> ./OwlyClnt port "); } }
From source file:gr.demokritos.iit.cru.creativity.reasoning.diagrammatic.Test.java
public static void main(String[] args) throws IOException, SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, FileNotFoundException, UnsupportedEncodingException, URISyntaxException, ParserConfigurationException, SAXException, XPathExpressionException, Exception { /* Connect c = new Connect("en"); DiagrammaticComputationalTools d = new DiagrammaticComputationalTools(c); ArrayList<String> s = new ArrayList<String>(); s.add("george");//from w w w .j a va2s . c om s.add("thing"); s.add("loves"); // System.out.println(d.FindConcepts("friend", 4, "supersumption")); System.out.println(d.FindRelations(s,4, "supersumption")); /* String text = "white"; String src = "en"; String trg = "el"; int id = 1; String response = Translator.bingTranslate(text, src, trg, "general"); System.out.println(response); */ JSONArray a = new JSONArray(); JSONObject obj1 = new JSONObject(); obj1.put("c1", "cat"); obj1.put("rel", "isA"); obj1.put("c2", "animal"); a.add(obj1); JSONObject obj2 = new JSONObject(); obj2.put("c1", "animal"); obj2.put("rel", "likes"); obj2.put("c2", "animal"); a.add(obj2); JSONObject obj3 = new JSONObject(); obj3.put("c1", "dog"); obj3.put("rel", "isA"); obj3.put("c2", "animal"); a.add(obj3); JSONObject obj4 = new JSONObject(); obj4.put("c1", "wolf"); obj4.put("rel", "isA"); obj4.put("c2", "animal"); a.add(obj4); System.out.println(a); /* JSONArray b = new JSONArray(); obj1 = new JSONObject(); obj1.put("c1", "cat"); obj1.put("rel", "isA"); obj1.put("c2", "animal"); b.add(obj1); obj2 = new JSONObject(); obj2.put("c1", "cat"); obj2.put("rel", "likes"); obj2.put("c2", "fish"); b.add(obj2); obj3 = new JSONObject(); obj3.put("c1", "dog"); obj3.put("rel", "isA"); obj3.put("c2", "animal"); b.add(obj3); obj4 = new JSONObject(); obj4.put("c1", "wolf"); obj4.put("rel", "isA"); obj4.put("c2", "animal"); b.add(obj4); JSONObject obj5 = new JSONObject(); obj5.put("c1", "wolf"); obj5.put("rel", "likes"); obj5.put("c2", "meat"); b.add(obj5); FileWriter file = new FileWriter("C:\\Users\\George\\Desktop\\animals.json"); file.write(b.toJSONString()); file.flush(); file.close();*/ // System.out.println(a); // System.out.println(b); /* d.Graphs(a, b); List<String> urls = new ArrayList<String>(); List<String> urls_temp = new ArrayList<String>(); */ // String bingAppId = "a1Q3b3YdomwYyknyDHIykZx0A5Xc5n445mYiXoCfXC8="; // BingCrawler bc = new BingCrawler(bingAppId, "en"); // List<String> urls = bc.crawlImages(phrase); /* urls_temp = HTMLUtilities.linkExtractor("http://www.dmoz.org/search?q=" + phrase + "&cat=Kids_and_Teens&all=yes", "UTF-8", 1); for (String url : urls_temp) { urls.add(StringEscapeUtils.unescapeHtml4(url)); }*/ // HashSet<String> p=d.FactRetriever("haswikipediaurl","relation"); // HashSet<String> kl = d.FindConcepts("love",2, "concept");//.Relations(s, 2, "relation"); // System.out.println(kl.size());*/ // System.out.println(list.toString()); /* HashSet<String> p=d.Relations(s, 3, "equivalence");//.Facts("haswikipediaurl","relation");//.Concepts("vouzon",3,"relation");//.ConceptFinder("love",3, "supersumption");//FactRetriever("vouzon","subject"); // //ConceptGraphAbstraction("love");//.FactRetriever("vouzon", "subject");//.ConceptGraphPolymerismEngine("automobile"); for(String j:p){ System.out.println(j); } for (String g : urls) { System.out.println(g); }*/ }
From source file:com.newproject.ApacheHttp.java
public static void main(String[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); String jsonFilePath = "/Users/vikasmohandoss/Documents/Cloud/test.txt"; String url = "http://www.sentiment140.com/api/bulkClassifyJson&appid=vm2446@columbia.edu"; JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = new JSONObject(); URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); try {/*from ww w. j ava2 s . c o m*/ FileReader fileReader = new FileReader(jsonFilePath); jsonObject = (JSONObject) jsonParser.parse(fileReader); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } System.out.println(jsonObject.toString()); /*try { /*HttpGet httpGet = new HttpGet("http://httpbin.org/get"); CloseableHttpResponse response1 = httpclient.execute(httpGet); // The underlying HTTP connection is still held by the response object // to allow the response content to be streamed directly from the network socket. // In order to ensure correct deallocation of system resources // the user MUST call CloseableHttpResponse#close() from a finally clause. // Please note that if response content is not fully consumed the underlying // connection cannot be safely re-used and will be shut down and discarded // by the connection manager. try { System.out.println(response1.getStatusLine()); HttpEntity entity1 = response1.getEntity(); // do something useful with the response body // and ensure it is fully consumed EntityUtils.consume(entity1); } finally { response1.close(); } HttpPost httpPost = new HttpPost("http://httpbin.org/post"); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("username", "vip")); nvps.add(new BasicNameValuePair("password", "secret")); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); try { System.out.println(response2.getStatusLine()); HttpEntity entity2 = response2.getEntity(); // do something useful with the response body // and ensure it is fully consumed EntityUtils.consume(entity2); } finally { response2.close(); } } finally { httpclient.close(); }*/ try { HttpPost request = new HttpPost("http://www.sentiment140.com/api/bulkClassifyJson"); StringEntity params = new StringEntity(jsonObject.toString()); request.addHeader("content-type", "application/json"); request.setEntity(params); HttpResponse response = httpclient.execute(request); System.out.println(response.toString()); String result = EntityUtils.toString(response.getEntity()); System.out.println(result); try { File file = new File("/Users/vikasmohandoss/Documents/Cloud/sentiment.txt"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(result); bw.close(); System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } // handle response here... } catch (Exception ex) { // handle exception here } finally { httpclient.close(); } }
From source file:agileinterop.AgileInterop.java
/** * @param args the command line arguments */// w ww. j a va2 s . c o m public static void main(String[] args) { JSONObject obj; try { String username, password, agileUrl, operation, body; username = args[0]; password = args[1]; agileUrl = args[2]; operation = args[3]; body = args[4]; // Connect to Agile Agile.connect(username, password, agileUrl); switch (operation) { case "getPSRData": obj = getPSRData(body); break; case "getPSRList": obj = getPSRList(body); break; case "getPSRCellValues": obj = getPSRCellValues(body); break; case "getRelatedPSRs": obj = getRelatedPSRs(body); break; case "createRelatedPSRs": obj = createRelatedPSRs(body); break; case "writeNewDataToPSRs": obj = writeNewDataToPSRs(body); break; case "attachFileToPSR": obj = attachFileToPSR(body); break; case "crawlAgileByDateOriginated": obj = crawlAgileByDateOriginated(body); break; case "crawlAgileByPSRList": obj = crawlAgileByPSRList(body); break; default: throw new AssertionError(); } obj.put("status", "success"); } catch (APIException | ParseException | InterruptedException ex) { obj = new JSONObject(); obj.put("status", "error"); obj.put("data", ex.getMessage()); } catch (Exception ex) { obj = new JSONObject(); obj.put("status", "error"); obj.put("data", ex.getMessage()); } System.out.print(obj.toJSONString()); }
From source file:com.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateUninstallCapabilityOnEdgeAcs.java
/** * @param args/*from w w w .ja v a2s. co m*/ */ public static void main(final String[] args) { HttpClient client = new HttpClient(); // client.getHostConfiguration().setProxy("", ); String host = null; String port = null; String address = "http://" + host + ":" + port + "/edge/api/"; String acsUsername = null; String acsPassword = null; if (host == null || port == null || acsUsername == null || acsPassword == null) { throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: " + acsUsername + ", and acsPassword: " + acsPassword + "."); } String realm = "NBBS_API_Realm"; AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm); // client.getState().setCredentials(realm, host, // new UsernamePasswordCredentials(acsUsername, acsPassword)); client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword)); PostMethod post = null; // ----- // ----- Execution de la capability : changeDUStateUninstall // ----- post = new PostMethod(address + "capability/execute"); post.addParameter(new NameValuePair("deviceId", "10003")); post.addParameter(new NameValuePair("timeoutMs", "60000")); post.addParameter(new NameValuePair("capability", "\"changeDUStateUninstall\"")); // UUID: string // Version: string // ExecutionEnvRef: String JSONObject object = new JSONObject(); object.put("UUID", "45"); object.put("Version", "2.2.0"); object.put("ExecutionEnvRef", "ExecutionEnvRef_value"); post.addParameter(new NameValuePair("input", object.toString())); post.setDoAuthentication(true); // post.addParameter(new NameValuePair("deviceId", "60001")); // ----- // ----- Partie commune : Execution du post // ----- try { int status = client.executeMethod(post); System.out.println("status: " + status); String resp = post.getResponseBodyAsString(); System.out.println("resp: " + resp); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { // release any connection resources used by the method post.releaseConnection(); } }
From source file:com.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateUpdateCapabilityOnEdgeAcs.java
/** * @param args/*from ww w . j a v a 2s. c o m*/ */ public static void main(final String[] args) { HttpClient client = new HttpClient(); // client.getHostConfiguration().setProxy("", ); String host = null; String port = null; String address = "http://" + host + ":" + port + "/edge/api/"; String acsUsername = null; String acsPassword = null; if (host == null || port == null || acsUsername == null || acsPassword == null) { throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: " + acsUsername + ", and acsPassword: " + acsPassword + "."); } String realm = "NBBS_API_Realm"; AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm); // client.getState().setCredentials(realm, host, // new UsernamePasswordCredentials(acsUsername, acsPassword)); client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword)); PostMethod post = null; // ----- // ----- Execution de la capability : changeDUStateUpdate // ----- post = new PostMethod(address + "capability/execute"); post.addParameter(new NameValuePair("deviceId", "10003")); post.addParameter(new NameValuePair("timeoutMs", "60000")); post.addParameter(new NameValuePair("capability", "\"changeDUStateUpdate\"")); // UUID: string // Version: string // URL: string // Username: string // Password: string JSONObject object = new JSONObject(); object.put("UUID", "45"); object.put("Version", "1.0.0"); object.put("URL", "http://127.0.0.1:8085/a/org.apache.felix.http.jetty-2.2.0.jar"); object.put("Username", "Username_value"); object.put("Password", "Password_value"); post.addParameter(new NameValuePair("input", object.toString())); post.setDoAuthentication(true); // post.addParameter(new NameValuePair("deviceId", "60001")); // ----- // ----- Partie commune : Execution du post // ----- try { int status = client.executeMethod(post); System.out.println("status: " + status); String resp = post.getResponseBodyAsString(); System.out.println("resp: " + resp); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { // release any connection resources used by the method post.releaseConnection(); } }
From source file:com.github.fhuss.kafka.streams.cep.demo.CEPStockKStreamsDemo.java
public static void main(String[] args) { Properties props = new Properties(); props.put(StreamsConfig.APPLICATION_ID_CONFIG, "streams-cep"); props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); props.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "localhost:2181"); props.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, StockEventSerDe.class); props.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, StockEventSerDe.class); // setting offset reset to earliest so that we can re-run the demo code with the same pre-loaded data props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); // build query final Pattern<Object, StockEvent> pattern = new QueryBuilder<Object, StockEvent>().select() .where((k, v, ts, store) -> v.volume > 1000).<Long>fold("avg", (k, v, curr) -> v.price).then() .select().zeroOrMore().skipTillNextMatch() .where((k, v, ts, state) -> v.price > (long) state.get("avg")) .<Long>fold("avg", (k, v, curr) -> (curr + v.price) / 2) .<Long>fold("volume", (k, v, curr) -> v.volume).then().select().skipTillNextMatch() .where((k, v, ts, state) -> v.volume < 0.8 * state.getOrElse("volume", 0L)) .within(1, TimeUnit.HOURS).build(); KStreamBuilder builder = new KStreamBuilder(); CEPStream<Object, StockEvent> stream = new CEPStream<>(builder.stream("StockEvents")); KStream<Object, Sequence<Object, StockEvent>> stocks = stream.query("Stocks", pattern); stocks.mapValues(seq -> {/*from w w w . j a v a2s . c o m*/ JSONObject json = new JSONObject(); seq.asMap().forEach((k, v) -> { JSONArray events = new JSONArray(); json.put(k, events); List<String> collect = v.stream().map(e -> e.value.name).collect(Collectors.toList()); Collections.reverse(collect); collect.forEach(e -> events.add(e)); }); return json.toJSONString(); }).through(null, Serdes.String(), "Matches").print(); //Use the topologyBuilder and streamingConfig to start the kafka streams process KafkaStreams streaming = new KafkaStreams(builder, props); //streaming.cleanUp(); streaming.start(); }
From source file:com.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateInstallCapabilityOnEdgeAcs.java
/** * @param args/*from w ww . j a v a 2s .com*/ */ public static void main(final String[] args) { HttpClient client = new HttpClient(); // client.getHostConfiguration().setProxy("", ); String host = null; String port = null; String address = "http://" + host + ":" + port + "/edge/api/"; String acsUsername = null; String acsPassword = null; if (host == null || port == null || acsUsername == null || acsPassword == null) { throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: " + acsUsername + ", and acsPassword: " + acsPassword + "."); } String realm = "NBBS_API_Realm"; AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm); // client.getState().setCredentials(realm, host, // new UsernamePasswordCredentials(acsUsername, acsPassword)); client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword)); PostMethod post = null; // ----- // ----- Execution de la capability : changeDUStateInstall // ----- post = new PostMethod(address + "capability/execute"); post.addParameter(new NameValuePair("deviceId", "10003")); post.addParameter(new NameValuePair("timeoutMs", "60000")); post.addParameter(new NameValuePair("capability", "\"changeDUStateInstall\"")); // URL: string // UUID: string // Username: string // Password: string // ExecutionEnvRef: string JSONObject object = new JSONObject(); object.put("URL", "http://127.0.0.1:8085/a/org.apache.felix.http.jetty-1.0.0.jar"); // object.put("UUID", "UUID_value"); object.put("Username", "Username_value"); object.put("Password", "Password_value"); object.put("ExecutionEnvRef", "ExecutionEnvRef_value"); post.addParameter(new NameValuePair("input", object.toString())); post.setDoAuthentication(true); // post.addParameter(new NameValuePair("deviceId", "60001")); // ----- // ----- Partie commune : Execution du post // ----- try { int status = client.executeMethod(post); System.out.println("status: " + status); String resp = post.getResponseBodyAsString(); System.out.println("resp: " + resp); // 10 avr. 2013 10:09:23 // org.apache.commons.httpclient.auth.AuthChallengeProcessor // selectAuthScheme // INFO: basic authentication scheme selected // status: 200 // resp: "executed: changeDUStateInstall: {Password=Password_value, // Username=Username_value, ExecutionEnvRef=ExecutionEnvRef_value, // URL=http:\/\/archive.apache.org\/dist\/felix\/org.apache.felix.http.jetty-1.0.0.jar}, // resp: com.netopia.nbbs.tr69.msg.ChangeDUStateResponse@2db81edf" } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { // release any connection resources used by the method post.releaseConnection(); } }