List of usage examples for java.util Map toString
public String toString()
From source file:com.example.zf_android.trade.API.java
public static void CARTFIRM1( Context context, int customerId, ArrayList<Integer> cartid, int addressId, String comment, int is_need_invoice, int invoice_type, String invoice_info, HttpCallback callback) { Map<String, Object> params = new HashMap<String, Object>(); params.put("customerId", customerId); params.put("cartid", cartid); params.put("addressId", addressId); params.put("comment", comment); params.put("is_need_invoice", is_need_invoice); params.put("invoice_type", invoice_type); params.put("invoice_info", invoice_info); System.out.println("CCC--" + params.toString()); new HttpRequest(context, callback).post(Config.URL_ORDER_SHOP, params); }
From source file:org.codice.ddf.resourcemanagement.usage.service.DataUsage.java
@Override public void updateUserDataLimit(Map<String, Long> userMap) { LOGGER.debug("Updating user data limit : {}", userMap.toString()); for (Map.Entry<String, Long> entry : userMap.entrySet()) { long dataLimit = entry.getValue(); String username = entry.getKey(); try {//from ww w .j a va 2 s . c o m attributesStore.setDataLimit(username, dataLimit); } catch (PersistenceException e) { LOGGER.warn("Unable to update properties for {}.", username, e); } } }
From source file:gemlite.core.internal.index.compare.ComparatorImpl.java
private int compareBigMap(Map<?, ?> o1, Map<?, ?> o2) { if (o1 == null || o1.values() == null) return -1; if (o2 == null || o2.values() == null) return 1; CompareToBuilder cb = new CompareToBuilder(); cb.append(o1.toString(), o2.toString()); return cb.toComparison(); }
From source file:org.codelabor.system.file.web.servlet.FileUploadStreamServlet.java
@Override protected void upload(HttpServletRequest request, HttpServletResponse response) throws Exception { WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(this.getServletContext()); FileManager fileManager = (FileManager) ctx.getBean("fileManager"); boolean isMultipart = ServletFileUpload.isMultipartContent(request); Map<String, Object> paramMap = RequestUtils.getParameterMap(request); if (logger.isDebugEnabled()) { logger.debug(paramMap.toString()); }/*from w ww . ja va 2 s . c om*/ String mapId = (String) paramMap.get("mapId"); RepositoryType acceptedRepositoryType = repositoryType; String requestedRepositoryType = (String) paramMap.get("repositoryType"); if (StringUtils.isNotEmpty(requestedRepositoryType)) { acceptedRepositoryType = RepositoryType.valueOf(requestedRepositoryType); } if (isMultipart) { ServletFileUpload upload = new ServletFileUpload(); upload.setFileSizeMax(fileSizeMax); upload.setSizeMax(requestSizeMax); upload.setHeaderEncoding(characterEncoding); upload.setProgressListener(new FileUploadProgressListener()); try { FileItemIterator iter = upload.getItemIterator(request); while (iter.hasNext()) { FileItemStream fileItemSteam = iter.next(); if (logger.isDebugEnabled()) { logger.debug(fileItemSteam.toString()); } FileDTO fileDTO = null; if (fileItemSteam.isFormField()) { paramMap.put(fileItemSteam.getFieldName(), Streams.asString(fileItemSteam.openStream(), characterEncoding)); } else { if (fileItemSteam.getName() == null || fileItemSteam.getName().length() == 0) continue; // set DTO fileDTO = new FileDTO(); fileDTO.setMapId(mapId); fileDTO.setRealFilename(FilenameUtils.getName(fileItemSteam.getName())); if (acceptedRepositoryType == RepositoryType.FILE_SYSTEM) { fileDTO.setUniqueFilename(getUniqueFilename()); } fileDTO.setContentType(fileItemSteam.getContentType()); fileDTO.setRepositoryPath(realRepositoryPath); if (logger.isDebugEnabled()) { logger.debug(fileDTO.toString()); } UploadUtils.processFile(acceptedRepositoryType, fileItemSteam.openStream(), fileDTO); } if (fileDTO != null) fileManager.insertFile(fileDTO); } } catch (FileUploadException e) { e.printStackTrace(); logger.error(e.getMessage()); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } } else { paramMap = RequestUtils.getParameterMap(request); } try { processParameters(paramMap); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); } dispatch(request, response, forwardPathUpload); }
From source file:edu.arizona.kra.proposaldevelopment.service.impl.PropDevRoutingStateServiceImpl.java
/** * Method that generates the search results for the lookup framework. * Called by performLookup()/*from www. j av a2 s . c o m*/ * * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResults(java.util.Map) */ @Override public List<ProposalDevelopmentRoutingState> findPropDevRoutingState(Map<String, String> searchCriteria) { LOG.debug("getSearchResults():" + searchCriteria.toString()); List<ProposalDevelopmentRoutingState> results = new ArrayList<ProposalDevelopmentRoutingState>(); try { results = propDevRoutingStateDao.getPropDevRoutingState(searchCriteria); } catch (Exception e) { LOG.error(e); } LOG.debug("getSearchResults(): size=" + results.size()); return results; }
From source file:org.esupportail.portlet.filemanager.services.opencmis.TrustedHttpheadersCmisAuthenticationProvider.java
@Override public Map<String, List<String>> getHTTPHeaders(String url) { Map<String, List<String>> httpHeaders = null; Object httpHeadersObject = ContextUtils.getSessionAttribute(ESUP_HEADER_SHIB_HTTP_HEADERS); if (httpHeadersObject != null) { httpHeaders = (Map<String, List<String>>) httpHeadersObject; log.debug("httpHeaders :" + httpHeaders.toString()); } else {/*from w w w. j av a2 s . co m*/ log.warn("httpHeaders will be null : we don't retrieve any userinfos attributes !"); } return httpHeaders; }
From source file:org.apache.solr.metrics.reporters.solr.SolrCloudReportersTest.java
@Test public void testExplicitConfiguration() throws Exception { String solrXml = IOUtils// w w w .j a v a 2 s. co m .toString(SolrCloudReportersTest.class.getResourceAsStream("/solr/solr-solrreporter.xml"), "UTF-8"); configureCluster(2).withSolrXml(solrXml).configure(); cluster.uploadConfigSet(Paths.get(TEST_PATH().toString(), "configsets", "minimal", "conf"), "test"); System.out.println("ZK: " + cluster.getZkServer().getZkAddress()); CollectionAdminRequest.createCollection("test_collection", "test", 2, 2).setMaxShardsPerNode(4) .process(cluster.getSolrClient()); waitForState("Expected test_collection with 2 shards and 2 replicas", "test_collection", clusterShape(2, 2)); Thread.sleep(15000); cluster.getJettySolrRunners().forEach(jetty -> { CoreContainer cc = jetty.getCoreContainer(); // verify registry names for (String name : cc.getLoadedCoreNames()) { SolrCore core = cc.getCore(name); try { String registryName = core.getCoreMetricManager().getRegistryName(); String leaderRegistryName = core.getCoreMetricManager().getLeaderRegistryName(); String coreName = core.getName(); String collectionName = core.getCoreDescriptor().getCollectionName(); String coreNodeName = core.getCoreDescriptor().getCloudDescriptor().getCoreNodeName(); String replicaName = coreName.split("_")[3]; String shardId = core.getCoreDescriptor().getCloudDescriptor().getShardId(); assertEquals("solr.core." + collectionName + "." + shardId + "." + replicaName, registryName); assertEquals("solr.collection." + collectionName + "." + shardId + ".leader", leaderRegistryName); } finally { if (core != null) { core.close(); } } } SolrMetricManager metricManager = cc.getMetricManager(); Map<String, SolrMetricReporter> reporters = metricManager.getReporters("solr.cluster"); assertEquals(reporters.toString(), 1, reporters.size()); SolrMetricReporter reporter = reporters.get("test"); assertNotNull(reporter); assertTrue(reporter.toString(), reporter instanceof SolrClusterReporter); SolrClusterReporter sor = (SolrClusterReporter) reporter; assertEquals(5, sor.getPeriod()); for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) { reporters = metricManager.getReporters(registryName); assertEquals(reporters.toString(), 1 + jmxReporter, reporters.size()); reporter = null; for (String name : reporters.keySet()) { if (name.startsWith("test")) { reporter = reporters.get(name); } } assertNotNull(reporter); assertTrue(reporter.toString(), reporter instanceof SolrShardReporter); SolrShardReporter srr = (SolrShardReporter) reporter; assertEquals(5, srr.getPeriod()); } for (String registryName : metricManager.registryNames(".*\\.leader")) { leaderRegistries++; reporters = metricManager.getReporters(registryName); // no reporters registered for leader registry assertEquals(reporters.toString(), 0, reporters.size()); // verify specific metrics Map<String, Metric> metrics = metricManager.registry(registryName).getMetrics(); String key = "QUERY./select.requests"; assertTrue(key, metrics.containsKey(key)); assertTrue(key, metrics.get(key) instanceof AggregateMetric); key = "UPDATE./update/json.requests"; assertTrue(key, metrics.containsKey(key)); assertTrue(key, metrics.get(key) instanceof AggregateMetric); } if (metricManager.registryNames().contains("solr.cluster")) { clusterRegistries++; Map<String, Metric> metrics = metricManager.registry("solr.cluster").getMetrics(); String key = "jvm.memory.heap.init"; assertTrue(key, metrics.containsKey(key)); assertTrue(key, metrics.get(key) instanceof AggregateMetric); key = "leader.test_collection.shard1.UPDATE./update/json.requests.max"; assertTrue(key, metrics.containsKey(key)); assertTrue(key, metrics.get(key) instanceof AggregateMetric); } }); assertEquals("leaderRegistries", 2, leaderRegistries); assertEquals("clusterRegistries", 1, clusterRegistries); }
From source file:com.trenako.results.SearchRangeTests.java
@Test public void shouldReturnParamsAsMapsOnlyForNotDefaultValues() { SearchRange range = new SearchRange(10, new Sort(Direction.DESC, "lastModified"), SINCE, MAX); Map<String, Object> params = range.asMap(); String expected = "{max=501171ab575ef9abd1a0c71f, since=501171ab575ef9abd1a0c71e}"; assertNotNull(params);/*from w w w.jav a 2 s .c o m*/ assertEquals(2, params.size()); assertEquals(expected, params.toString()); }
From source file:org.megam.deccanplato.provider.box.BoxAdapterAccess.java
@Override public <T extends Object> DataMap<T> authenticate(DataMap<T> access) throws AdapterAccessException { Map<String, T> accessMap = access.map(); System.out.print("OAUTH MAP" + accessMap.toString()); Map<String, String> headerMap = new HashMap<String, String>(); headerMap.put("Authorization", "BoxAuth api_key=" + (String) accessMap.get(API_KEY)); Map<String, String> boxList = new HashMap<String, String>(); boxList.put("email", (String) accessMap.get(EMAIL)); TransportTools tools = new TransportTools(BOX_OAUTH2_URL, null, headerMap); Gson obj = new GsonBuilder().setPrettyPrinting().create(); System.out.println(obj.toJson(boxList)); tools.setContentType(ContentType.APPLICATION_JSON, obj.toJson(boxList)); String responseBody = null;//from w w w.j ava 2s .c o m TransportResponse response = null; try { response = TransportMachinery.post(tools); responseBody = response.entityToString(); success = true; System.out.println("OUTPUT:" + responseBody); } catch (ClientProtocolException ce) { throw new AdapterAccessException("An error occurred during post operation.", ce); } catch (IOException ioe) { throw new AdapterAccessException("An error occurred during post operation.", ioe); } DataMap<T> accessMap1 = new DefaultDataMap<>(); accessMap1.map().put(OUTPUT, (T) accessMap.get(API_KEY)); return accessMap1; /* * Old Box code written by Thomas Alrin */ /*BOX_OAUTH2_URL = BOX_OAUTH2_URL + accessMap.get("api_key"); TransportTools tools = new TransportTools(BOX_OAUTH2_URL, null); String responseBody = null; TransportResponse response = null; try { try { response = TransportMachinery.get(tools); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } responseBody = response.entityToString(); } catch (ClientProtocolException ce) { throw new AdapterAccessException( "An error occurred during post operation.", ce); } catch (IOException ioe) { throw new AdapterAccessException( "An error occurred during post operation.", ioe); } DocumentBuilder db = null; try { db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } InputSource is = new InputSource(); is.setCharacterStream(new StringReader(responseBody)); Document doc = null; try { doc = (Document) db.parse(is); } catch (SAXException | IOException e) { e.printStackTrace(); } NodeList nodes = ((Node) doc).getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node element = nodes.item(i); NodeList child = element.getChildNodes(); for (int j = 0; j < child.getLength(); j++) { Node ele = child.item(j); if (ele.getNodeName().equals("ticket")) { Ticket = ele.getTextContent(); } } } BoxAuthToken((String) accessMap.get("api_key"),Ticket); return null; } public void BoxAuthToken(String api, String tick) throws AdapterAccessException { String url = "https://www.box.com/api/1.0/rest?action=get_auth_token&api_key="+api+"&ticket="+tick; TransportTools tools = new TransportTools(url, null); String responseBody = null; TransportResponse response = null; try { try { response = TransportMachinery.get(tools); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } responseBody = response.entityToString(); } catch (ClientProtocolException ce) { throw new AdapterAccessException( "An error occurred during post operation.", ce); } catch (IOException ioe) { throw new AdapterAccessException( "An error occurred during post operation.", ioe); }*/ }
From source file:org.apache.marmotta.ucuenca.wk.commons.function.TranslateForSemanticDistance.java
private synchronized String http2(String s, Map<String, String> mp) throws SQLException, IOException { String md = s + mp.toString(); Statement stmt = conn.createStatement(); String sql;/*from w ww . jav a2 s .co m*/ sql = "SELECT * FROM cache where cache.key='" + commonservices.getMD5(md) + "'"; java.sql.ResultSet rs = stmt.executeQuery(sql); String resp = ""; if (rs.next()) { resp = rs.getString("value"); rs.close(); stmt.close(); } else { rs.close(); stmt.close(); HttpClient client = new HttpClient(); PostMethod method = new PostMethod(s); //Add any parameter if u want to send it with Post req. for (Map.Entry<String, String> mcc : mp.entrySet()) { method.addParameter(mcc.getKey(), mcc.getValue()); } int statusCode = client.executeMethod(method); if (statusCode != -1) { InputStream in = method.getResponseBodyAsStream(); final Scanner reader = new Scanner(in, "UTF-8"); while (reader.hasNextLine()) { final String line = reader.nextLine(); resp += line + "\n"; } reader.close(); try { JsonParser parser = new JsonParser(); parser.parse(resp); PreparedStatement stmt2 = conn.prepareStatement("INSERT INTO cache (key, value) values (?, ?)"); stmt2.setString(1, commonservices.getMD5(md)); stmt2.setString(2, resp); stmt2.executeUpdate(); stmt2.close(); } catch (Exception e) { } } } return resp; }