List of usage examples for java.util Map toString
public String toString()
From source file:org.onos.yangtools.yang2sources.plugin.YangToSourcesProcessor.java
/** * Call generate on every generator from plugin configuration *///from w w w .j a va2s . co m private void generateSources(ContextHolder context) throws MojoFailureException { if (codeGenerators.size() == 0) { log.warn(Util.message("No code generators provided", LOG_PREFIX)); return; } Map<String, String> thrown = Maps.newHashMap(); for (CodeGeneratorArg codeGenerator : codeGenerators) { try { generateSourcesWithOneGenerator(context, codeGenerator); } catch (Exception e) { // try other generators, exception will be thrown after log.error(Util.message("Unable to generate sources with %s generator", LOG_PREFIX, codeGenerator.getCodeGeneratorClass()), e); thrown.put(codeGenerator.getCodeGeneratorClass(), e.getClass().getCanonicalName()); } } if (!thrown.isEmpty()) { String message = Util.message( "One or more code generators failed, including failed list(generatorClass=exception) %s", LOG_PREFIX, thrown.toString()); log.error(message); throw new MojoFailureException(message); } }
From source file:com.jing.ebike.controller.UserController.java
@SuppressWarnings("unchecked") @RequestMapping(value = "updateLicense.do", method = RequestMethod.POST) @ResponseBody//from ww w. j a v a 2 s . c o m @Transactional public GeneralResponse updateLicense(HttpSession sess, HttpServletRequest request, HttpServletResponse response) { GeneralResponse message = new GeneralResponse(); User user = (User) sess.getAttribute("loginUser"); if (user == null) { message.setCode(0); message.setMsg("???"); return message; } String certNo = user.getCertNo(); String mobi_num = user.getMobile(); if (certNo == null || mobi_num == null) { message.setCode(0); message.setMsg("???"); return message; } try { String certNoLastSix = certNo.substring(certNo.length() - 6, certNo.length()); String path = "http://122.226.49.30:60001/wy/wy/wx/pandect-getdata.action";//"http://122.226.49.30:60001/wy/wx/getdata"; Map<String, String> map = new HashMap<String, String>(); map.put("rtype", "0"); Map<String, Object> mapData = new HashMap<String, Object>(); mapData = new HashMap<String, Object>(); mapData.put("\"mobi_num\"", "\"" + mobi_num + "\"");//? mapData.put("\"id_six\"", "\"" + certNoLastSix + "\"");//??? mapData.put("\"md_five\"", "\"itylhogiwuEDjfMK\"");//MD5key=================? System.out.println("?=sign?" + mapData.toString()); String md5Str = MD5Utils.getMD5Str(mapData.toString());//MD5 mapData.put("\"sign\"", "\"" + md5Str + "\"");//DESsign mapData.remove("\"md_five\""); // String encrypt_Str = DESUtils.encrypt(mapData.toString()); logger.info("---------------encrypt_Str----------" + encrypt_Str); map.put("data", encrypt_Str); String encode = "UTF-8"; HttpRequestUtils instance = new HttpRequestUtils(); String result = instance.sendHttpClientPost(path, map, encode); logger.info("---------------result----------" + result); String resultAfterDecrypt = DESUtils.decrypt(result); logger.info("---------------resultAfterDecrypt----------" + resultAfterDecrypt); // String resultAfterDecrypt = "{\"userinfo\"=[{\"fortify\"=\"0\", \"idcard\"=\"123456789123456789\", \"mobile\"=\"12345678901\", \"licenseNumber\"=\"YK444148\", \"address\"=\"\", \"username\"=\"\", \"createtime\"=\"2016-05-29 00:00:00.0\"}, {\"fortify\"=0, \"idcard\"=\"123456789123456789\", \"mobile\"=\"12345678901\", \"licenseNumber\"=\"YK444165\", \"address\"=\"\", \"username\"=\"app\", \"createtime\"=\"2016-08-10 00:00:00.0\"}], \"result\"=true}"; if (resultAfterDecrypt.indexOf("true") > 0) { JSONObject strjsonObject = JSONObject.fromObject(resultAfterDecrypt); Map<String, Object> map1Json = new HashMap<String, Object>(); map1Json = JSONObject.fromObject(strjsonObject); String userInfo = map1Json.get("userinfo").toString(); logger.info("---------------userinfo----------" + userInfo); JSONArray arrayObject = JSONArray.fromObject(userInfo); List<CarNumber> carNumbers = new ArrayList<CarNumber>(); for (int i = 0; i < arrayObject.size(); i++) { JSONObject object = arrayObject.getJSONObject(i); map1Json = JSONObject.fromObject(object); if (map1Json.get("licenseNumber") != null) { Date date = new Date(); CarNumber carNumber = new CarNumber(); carNumber.setCarNum(map1Json.get("licenseNumber").toString()); carNumber.setId(UUIDUtils.generateUUID()); carNumber.setUserId(user.getId()); carNumber.setCreateTime(date); carNumber.setUseTime(date); carNumbers.add(carNumber); } } List<CarNumber> userCarNumbers = carNumberService.getByUserId(user.getId()); Map<String, CarNumber> userCarMap = new HashMap<String, CarNumber>(); for (CarNumber carNumber : userCarNumbers) { userCarMap.put(carNumber.getCarNum(), carNumber); } Map<String, CarNumber> copyMap = userCarMap; for (CarNumber carNumber : carNumbers) { if (userCarMap.get(carNumber.getCarNum()) != null) { copyMap.remove(carNumber.getCarNum()); } else { logger.info("carNumberService insert value= " + carNumber); carNumberService.insert(carNumber); } } for (String key : copyMap.keySet()) { CarNumber carNumber = copyMap.get(key); logger.info("carNumberService deleteById key= " + key + " and value= " + carNumber); carNumberService.deleteById(carNumber.getId()); } message.setCode(1); message.setMsg("???"); } else { message.setCode(0); message.setMsg("????"); return message; } } catch (Exception e) { message.setCode(0); message.setMsg(e.getMessage()); } return message; }
From source file:com.qmetry.qaf.automation.integration.qmetry.qmetry6.QMetryRestWebservice.java
public String searchExistsTestCase(String scriptName) { Builder builder = new RestTestBase().getWebResource(serviceUrl, "/rest/search/result").getRequestBuilder(); // add header for (Iterator<Map.Entry<String, String>> it = getRequestHeader().entrySet().iterator(); it.hasNext();) { Map.Entry<String, String> entry = it.next(); builder.header(entry.getKey(), entry.getValue()); }/*from w w w.j a v a 2s. c o m*/ // create entity Map<String, Object> filter = new HashMap<String, Object>(); ArrayList<Map<String, Object>> filters = new ArrayList<Map<String, Object>>(); ArrayList<String> array = new ArrayList<String>(); array.add("testScriptName"); filter.put("op", "CN"); filter.put("name", "keyword"); filter.put("value", scriptName); filter.put("xtype", "keyword"); filter.put("fields", array); filters.add(filter); Map<String, Object> entity = new HashMap<String, Object>(); entity.put("entityType", "TC"); entity.put("searchMode", "basic"); entity.put("scope", "Cycle"); entity.put("filters", filters); String response = null; try { response = builder.post(String.class, entity.toString()); } catch (Exception e) { e.printStackTrace(); } return response; }
From source file:com.jing.ebike.controller.UserController.java
@SuppressWarnings("unchecked") @RequestMapping(value = "register.do", method = RequestMethod.POST) @ResponseBody//from w w w .j a va 2 s. c om @Transactional public GeneralResponse register(String mobileNum, String password, String repassword, String mobile, String certNo, HttpSession sess, HttpServletRequest request, HttpServletResponse response) { GeneralResponse message = new GeneralResponse(); try { if (!password.equals(repassword)) { message.setCode(0); message.setMsg("??"); return message; } User user = userService.getByUserName(mobileNum); if (user != null) { message.setCode(0); message.setMsg("??"); return message; } User user2 = userService.getByMobile(mobile); if (user2 != null) { message.setCode(0); message.setMsg("?"); return message; } if (certNo != null && !"".equals(certNo)) { String mobi_num = mobile; String certNoLastSix = certNo.substring(certNo.length() - 6, certNo.length()); String path = "http://122.226.49.30:60001/wy/wy/wx/pandect-getdata.action";//"http://122.226.49.30:60001/wy/wx/getdata"; Map<String, String> map = new HashMap<String, String>(); map.put("rtype", "0"); Map<String, Object> mapData = new HashMap<String, Object>(); mapData = new HashMap<String, Object>(); mapData.put("\"mobi_num\"", "\"" + mobi_num + "\"");//? mapData.put("\"id_six\"", "\"" + certNoLastSix + "\"");//??? mapData.put("\"md_five\"", "\"itylhogiwuEDjfMK\"");//MD5key=================? System.out.println("?=sign?" + mapData.toString()); String md5Str = MD5Utils.getMD5Str(mapData.toString());//MD5 mapData.put("\"sign\"", "\"" + md5Str + "\"");//DESsign mapData.remove("\"md_five\""); // String encrypt_Str = DESUtils.encrypt(mapData.toString()); logger.info("---------------encrypt_Str----------" + encrypt_Str); map.put("data", encrypt_Str); String encode = "UTF-8"; HttpRequestUtils instance = new HttpRequestUtils(); String result = instance.sendHttpClientPost(path, map, encode); logger.info("---------------result----------" + result); String resultAfterDecrypt = DESUtils.decrypt(result); logger.info("---------------resultAfterDecrypt----------" + resultAfterDecrypt); // String resultAfterDecrypt = "{\"userinfo\"=[{\"fortify\"=\"0\", \"idcard\"=\"123456789123456789\", \"mobile\"=\"12345678901\", \"licenseNumber\"=\"YK444146\", \"address\"=\"\", \"username\"=\"\", \"createtime\"=\"2016-05-29 00:00:00.0\"}, {\"fortify\"=0, \"idcard\"=\"123456789123456789\", \"mobile\"=\"12345678901\", \"licenseNumber\"=\"YK444165\", \"address\"=\"\", \"username\"=\"app\", \"createtime\"=\"2016-08-10 00:00:00.0\"}], \"result\"=true}"; if (resultAfterDecrypt.indexOf("true") > 0) { JSONObject strjsonObject = JSONObject.fromObject(resultAfterDecrypt); Map<String, Object> map1Json = new HashMap<String, Object>(); map1Json = JSONObject.fromObject(strjsonObject); String userInfo = map1Json.get("userinfo").toString(); logger.info("---------------userinfo----------" + userInfo); JSONArray arrayObject = JSONArray.fromObject(userInfo); User registerUser = new User(); String userId = UUIDUtils.generateUUID(); for (int i = 0; i < arrayObject.size(); i++) { JSONObject object = arrayObject.getJSONObject(i); map1Json = JSONObject.fromObject(object); if (map1Json.get("idcard") != null) { registerUser.setCertNo(map1Json.get("idcard").toString()); } else { registerUser.setCertNo(certNo == null ? "" : certNo); } if (map1Json.get("licenseNumber") != null) { Date date = new Date(); CarNumber carNumber = new CarNumber(); carNumber.setCarNum(map1Json.get("licenseNumber").toString()); carNumber.setId(UUIDUtils.generateUUID()); carNumber.setUserId(userId); carNumber.setCreateTime(date); carNumber.setUseTime(date); carNumberService.insert(carNumber); } } registerUser.setId(userId); registerUser.setUserName(mobileNum); registerUser.setStatus(3);// registerUser.setCreateTime(new java.util.Date()); registerUser.setPassWd(MD5Utils.getMD5Str(password)); registerUser.setMobile(mobile == null ? "" : mobile); userService.insert(registerUser); // strjsonObject = JSONObject.fromObject(userInfo.substring(1, userInfo.length()-1)); message.setCode(1); message.setMsg("?"); } else { message.setCode(0); message.setMsg("????"); return message; } } else { // message.setCode(0); // message.setMsg("17????"); // return message; User registerUser = new User(); registerUser.setId(UUIDUtils.generateUUID()); registerUser.setUserName(mobileNum); registerUser.setStatus(3);// registerUser.setCreateTime(new java.util.Date()); registerUser.setPassWd(MD5Utils.getMD5Str(password)); registerUser.setMobile(mobile == null ? "" : mobile); registerUser.setCertNo(certNo == null ? "" : certNo); userService.insert(registerUser); message.setCode(1); message.setMsg("?"); } } catch (Exception e) { message.setCode(0); message.setMsg(e.getMessage()); } return message; }
From source file:com.cloudbees.hudson.plugins.folder.computed.ComputedFolderTest.java
@Issue("JENKINS-32179") @Test/*from ww w . java 2s .com*/ public void duplicateEntries() throws Exception { SampleComputedFolder d = r.jenkins.createProject(SampleComputedFolder.class, "d"); d.recompute(Result.SUCCESS); d.assertItemNames(1); d.kids.addAll(Arrays.asList("A", "B", "A", "C")); d.recompute(Result.SUCCESS); d.assertItemNames(2, "A", "B", "C"); assertEquals("[A, B, C]", d.created.toString()); d.recompute(Result.SUCCESS); d.assertItemNames(3, "A", "B", "C"); assertEquals("[A, B, C]", d.created.toString()); d.kids.remove("B"); d.recompute(Result.SUCCESS); d.assertItemNames(4, "A", "C"); assertEquals("[A, B, C]", d.created.toString()); assertEquals("[B]", d.deleted.toString()); d.kids.addAll(Arrays.asList("D", "B")); d.recompute(Result.SUCCESS); d.assertItemNames(5, "A", "B", "C", "D"); assertEquals("[A, B, C, D, B]", d.created.toString()); assertEquals("[B]", d.deleted.toString()); Map<String, String> descriptions = new TreeMap<String, String>(); for (FreeStyleProject p : d.getItems()) { descriptions.put(p.getName(), p.getDescription()); } assertEquals("{A=updated in round #5, B=created in round #5, C=updated in round #5, D=created in round #5}", descriptions.toString()); }
From source file:com.jing.ebike.controller.UserController.java
@SuppressWarnings("unchecked") @RequestMapping(value = "setDefence", method = RequestMethod.POST) @ResponseBody//from ww w . j av a 2s . c o m @Transactional public GeneralResponse setDefence(String set_status, String carNum, HttpSession sess, HttpServletRequest request, HttpServletResponse response) { GeneralResponse message = new GeneralResponse(); User loginUser = (User) sess.getAttribute("loginUser"); String defenceOperation = ""; if ("0".equals(set_status)) defenceOperation = ""; boolean test = false; if (test || "test".equals(loginUser.getUserName())) { message.setCode(1); message.setMsg("" + carNum + defenceOperation + "?"); return message; } try { // String jsonStr = "\"mobi_num\":\""+loginUser.getMobile()+"\",\"car_num\":\""+carNum+"\""; // logger.info("jsonStr:"+jsonStr); // String sign = MD5Utils.getMD5Str(jsonStr); // logger.info("sign:"+sign); // jsonStr = "{" + jsonStr + ",\"sign\":\"" + sign + "\"}"; String path = "http://122.226.49.30:60001/wy/wy/wx/pandect-getdata.action"; Map<String, String> map = new HashMap<String, String>(); map.put("rtype", "1"); Map<String, Object> mapData = new HashMap<String, Object>(); mapData = new HashMap<String, Object>(); mapData.put("\"mobi_num\"", "\"" + loginUser.getMobile() + "\"");//??? mapData.put("\"set_status\"", "\"" + set_status + "\"");// mapData.put("\"licenseNumber\"", "\"" + carNum + "\"");//? mapData.put("\"md_five\"", "\"itylhogiwuEDjfMK\"");//MD5key=================? System.out.println("?=sign?" + mapData.toString()); String md5Str = MD5Utils.getMD5Str(mapData.toString());//MD5 mapData.put("\"sign\"", "\"" + md5Str + "\"");//DESsign mapData.remove("\"md_five\""); // String sf_encrypt_Str = DESUtils.encrypt(mapData.toString()); map.put("data", sf_encrypt_Str); String encode = "utf8"; HttpRequestUtils instance = new HttpRequestUtils(); String result = instance.sendHttpClientPost(path, map, encode); logger.info("---------------result----------" + result); String resultAfterDecrypt = DESUtils.decrypt(result);//"Qia0wVT6+gGqDvNHi6qVoHljL16CORbw4afSJ+h2Mv+jwjammp0T2GgCyeZIuEQe" logger.info("---------------resultAfterDecrypt----------" + resultAfterDecrypt); if (resultAfterDecrypt.indexOf("true") > 0) { JSONObject strjsonObject = JSONObject.fromObject(resultAfterDecrypt); Map<String, Object> map1Json = new HashMap<String, Object>(); map1Json = JSONObject.fromObject(strjsonObject); String lastaddr = map1Json.get("lastaddr").toString(); logger.info("---------------lastaddr1----------" + map1Json.get("lastaddr").toString()); message.setRes(lastaddr == null ? "" : lastaddr); CarNumber carNumber = new CarNumber(); carNumber.setCarNum(carNum); carNumber.setDefenceStatus(Integer.valueOf(set_status)); carNumberService.updateByNum(carNumber); message.setCode(1); if ("0".equals(set_status)) sess.getServletContext().removeAttribute("location" + carNum); message.setMsg("" + carNum + defenceOperation + "?"); } else { message.setCode(0); message.setMsg("" + carNum + defenceOperation + ""); } } catch (Exception e) { message.setCode(0); message.setMsg(e.getMessage()); } return message; }
From source file:co.cask.cdap.internal.app.services.http.AppFabricTestBase.java
protected HttpResponse addArtifactProperties(Id.Artifact artifactId, Map<String, String> properties) throws Exception { String nonNamespacePath = String.format("artifacts/%s/versions/%s/properties", artifactId.getName(), artifactId.getVersion());/* w w w . ja v a 2 s .co m*/ String path = getVersionedAPIPath(nonNamespacePath, artifactId.getNamespace().getId()); HttpEntityEnclosingRequestBase request = getPut(path); request.setEntity(new ByteArrayEntity(properties.toString().getBytes())); return execute(request); }
From source file:com.jing.ebike.controller.UserController.java
@RequestMapping(value = "postLocationData.do", method = RequestMethod.POST) @ResponseBody/*from www . ja v a 2s. c o m*/ @Transactional public GeneralResponse postLocationData(String carNum, String address, String lng, String lat, HttpSession sess, HttpServletRequest request, HttpServletResponse response) { GeneralResponse message = new GeneralResponse(); User loginUser = (User) sess.getAttribute("loginUser"); boolean test = false; if (test || "test".equals(loginUser.getUserName())) { message.setCode(1); return message; } try { String path = "http://wx.baojutong.com/poststatus"; Map<String, String> map = new HashMap<String, String>(); Map<String, Object> mapData = new HashMap<String, Object>(); mapData = new HashMap<String, Object>(); mapData.put("\"mobi_num\"", "\"" + loginUser.getMobile() + "\"");//??? mapData.put("\"licenseNumber\"", "\"" + carNum + "\"");//? mapData.put("\"alert_addr\"", "\"" + address + "\"");//? mapData.put("\"longitude\"", "\"" + lng + "\"");//?? mapData.put("\"latitude\"", "\"" + lat + "\"");//?? System.out.println("postLocationData?" + mapData.toString()); // String sf_encrypt_Str = DESUtils.encrypt(mapData.toString()); map.put("data", sf_encrypt_Str); String encode = "UTF-8"; HttpRequestUtils instance = new HttpRequestUtils(); String result = instance.sendHttpClientPost(path, map, encode); logger.info("---------------result----------" + result); String resultAfterDecrypt = result;//DESUtils.decrypt( logger.info("---------------resultAfterDecrypt----------" + resultAfterDecrypt); if (resultAfterDecrypt.indexOf("true") > 0) { // CarNumber carNumber = new CarNumber(); // carNumber.setCarNum(carNum); // carNumberService.updateByNum(carNumber); message.setCode(1); } else { message.setCode(0); } } catch (Exception e) { message.setCode(0); message.setMsg(e.getMessage()); } return message; }
From source file:io.cloudslang.worker.management.services.OutboundBufferImpl.java
private void drainInternal(List<Message> bufferToDrain) { List<Message> bulk = new ArrayList<>(); int bulkWeight = 0; Map<String, AtomicInteger> logMap = new HashMap<>(); try {/*from w w w. ja v a 2 s . com*/ for (Message message : bufferToDrain) { if (message.getClass().equals(CompoundMessage.class)) { bulk.addAll(((CompoundMessage) message).asList()); } else { bulk.add(message); } bulkWeight += message.getWeight(); if (logger.isDebugEnabled()) { if (logMap.get(message.getClass().getSimpleName()) == null) logMap.put(message.getClass().getSimpleName(), new AtomicInteger(1)); else logMap.get(message.getClass().getSimpleName()).incrementAndGet(); } if (bulkWeight > maxBulkWeight) { if (logger.isDebugEnabled()) logger.debug("trying to drain bulk: " + logMap.toString() + ", W:" + bulkWeight); drainBulk(bulk); bulk.clear(); bulkWeight = 0; logMap.clear(); } } // drain the last bulk if (logger.isDebugEnabled()) logger.debug("trying to drain bulk: " + logMap.toString() + ", " + getStatus()); drainBulk(bulk); } catch (Exception ex) { logger.error("Failed to drain buffer, invoking worker internal recovery... ", ex); recoveryManager.doRecovery(); } }
From source file:org.apache.chemistry.opencmis.client.bindings.spi.http.AbstractApacheClientHttpInvoker.java
protected Response invoke(UrlBuilder url, String method, String contentType, Map<String, String> headers, final Output writer, final BindingSession session, BigInteger offset, BigInteger length) { int respCode = -1; try {/* ww w. j a v a 2 s . c om*/ // log before connect if (LOG.isDebugEnabled()) { LOG.debug("Session {}: {} {}", session.getSessionId(), method, url); } // get HTTP client object from session DefaultHttpClient httpclient = (DefaultHttpClient) session.get(HTTP_CLIENT); if (httpclient == null) { session.writeLock(); try { httpclient = (DefaultHttpClient) session.get(HTTP_CLIENT); if (httpclient == null) { httpclient = createHttpClient(url, session); session.put(HTTP_CLIENT, httpclient, true); } } finally { session.writeUnlock(); } } HttpRequestBase request = null; if ("GET".equals(method)) { request = new HttpGet(url.toString()); } else if ("POST".equals(method)) { request = new HttpPost(url.toString()); } else if ("PUT".equals(method)) { request = new HttpPut(url.toString()); } else if ("DELETE".equals(method)) { request = new HttpDelete(url.toString()); } else { throw new CmisRuntimeException("Invalid HTTP method!"); } // set content type if (contentType != null) { request.setHeader("Content-Type", contentType); } // set other headers if (headers != null) { for (Map.Entry<String, String> header : headers.entrySet()) { request.addHeader(header.getKey(), header.getValue()); } } // authenticate AuthenticationProvider authProvider = CmisBindingsHelper.getAuthenticationProvider(session); if (authProvider != null) { Map<String, List<String>> httpHeaders = authProvider.getHTTPHeaders(url.toString()); if (httpHeaders != null) { for (Map.Entry<String, List<String>> header : httpHeaders.entrySet()) { if (header.getKey() != null && isNotEmpty(header.getValue())) { String key = header.getKey(); if (key.equalsIgnoreCase("user-agent")) { request.setHeader("User-Agent", header.getValue().get(0)); } else { for (String value : header.getValue()) { if (value != null) { request.addHeader(key, value); } } } } } } } // range if ((offset != null) || (length != null)) { StringBuilder sb = new StringBuilder("bytes="); if ((offset == null) || (offset.signum() == -1)) { offset = BigInteger.ZERO; } sb.append(offset.toString()); sb.append('-'); if ((length != null) && (length.signum() == 1)) { sb.append(offset.add(length.subtract(BigInteger.ONE)).toString()); } request.setHeader("Range", sb.toString()); } // compression Object compression = session.get(SessionParameter.COMPRESSION); if ((compression != null) && Boolean.parseBoolean(compression.toString())) { request.setHeader("Accept-Encoding", "gzip,deflate"); } // locale if (session.get(CmisBindingsHelper.ACCEPT_LANGUAGE) instanceof String) { request.setHeader("Accept-Language", session.get(CmisBindingsHelper.ACCEPT_LANGUAGE).toString()); } // send data if (writer != null) { Object clientCompression = session.get(SessionParameter.CLIENT_COMPRESSION); final boolean clientCompressionFlag = (clientCompression != null) && Boolean.parseBoolean(clientCompression.toString()); if (clientCompressionFlag) { request.setHeader("Content-Encoding", "gzip"); } AbstractHttpEntity streamEntity = new AbstractHttpEntity() { @Override public boolean isChunked() { return true; } @Override public boolean isRepeatable() { return false; } @Override public long getContentLength() { return -1; } @Override public boolean isStreaming() { return false; } @Override public InputStream getContent() throws IOException { throw new UnsupportedOperationException(); } @Override public void writeTo(final OutputStream outstream) throws IOException { OutputStream connOut = null; if (clientCompressionFlag) { connOut = new GZIPOutputStream(outstream, 4096); } else { connOut = outstream; } OutputStream out = new BufferedOutputStream(connOut, BUFFER_SIZE); try { writer.write(out); } catch (IOException ioe) { throw ioe; } catch (Exception e) { throw new IOException(e); } out.flush(); if (connOut instanceof GZIPOutputStream) { ((GZIPOutputStream) connOut).finish(); } } }; ((HttpEntityEnclosingRequestBase) request).setEntity(streamEntity); } // connect HttpResponse response = httpclient.execute(request); HttpEntity entity = response.getEntity(); // get stream, if present respCode = response.getStatusLine().getStatusCode(); InputStream inputStream = null; InputStream errorStream = null; if ((respCode == 200) || (respCode == 201) || (respCode == 203) || (respCode == 206)) { if (entity != null) { inputStream = entity.getContent(); } else { inputStream = new ByteArrayInputStream(new byte[0]); } } else { if (entity != null) { errorStream = entity.getContent(); } else { errorStream = new ByteArrayInputStream(new byte[0]); } } // collect headers Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>(); for (Header header : response.getAllHeaders()) { List<String> values = responseHeaders.get(header.getName()); if (values == null) { values = new ArrayList<String>(); responseHeaders.put(header.getName(), values); } values.add(header.getValue()); } // log after connect if (LOG.isTraceEnabled()) { LOG.trace("Session {}: {} {} > Headers: {}", session.getSessionId(), method, url, responseHeaders.toString()); } // forward response HTTP headers if (authProvider != null) { authProvider.putResponseHeaders(url.toString(), respCode, responseHeaders); } // get the response return new Response(respCode, response.getStatusLine().getReasonPhrase(), responseHeaders, inputStream, errorStream); } catch (Exception e) { String status = (respCode > 0 ? " (HTTP status code " + respCode + ")" : ""); throw new CmisConnectionException("Cannot access \"" + url + "\"" + status + ": " + e.getMessage(), e); } }