List of usage examples for java.util List toString
public String toString()
From source file:com.gst.integrationtests.common.GroupHelper.java
public static void verifyGroupMembers(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedGroupID, final Integer groupMember) { List<String> list = new ArrayList<>(); System.out//from w w w . ja v a 2 s. c o m .println("------------------------------CHECK GROUP MEMBERS------------------------------------\n"); final String GROUP_URL = "/fineract-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER; list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers"); assertTrue("ERROR IN GROUP MEMBER", list.toString().contains("id=" + groupMember.toString())); }
From source file:com.cbtec.eliademyutils.EliademyUtils.java
public static String serviceCall(String data, String webService, String token, String serviceClient) { String retval = null;/* w w w. ja v a 2 s . c o m*/ Log.d("EliademyUtils", "Service: " + data + " Service: " + webService); try { DefaultHttpClient httpclient = new DefaultHttpClient(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); if (data.toString().length() > 0) { JSONObject jsObj = new JSONObject(data.toString()); nameValuePairs.addAll(nameValueJson(jsObj, "")); } nameValuePairs.add(new BasicNameValuePair("wstoken", token)); nameValuePairs.add(new BasicNameValuePair("wsfunction", webService)); nameValuePairs.add(new BasicNameValuePair("moodlewsrestformat", "json")); HttpPost httppost = new HttpPost(serviceClient + "/webservice/rest/server.php?"); Log.d("EliademyUtils", nameValuePairs.toString()); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); if (entity != null) { StringBuilder jsonStr = new StringBuilder(); InputStream iStream = entity.getContent(); BufferedReader bufferReader = new BufferedReader(new InputStreamReader(iStream)); String jpart; while ((jpart = bufferReader.readLine()) != null) { jsonStr.append(jpart); } iStream.close(); return jsonStr.toString(); } } catch (Exception e) { Log.e("EliademyUtils", "exception", e); return retval; } return retval; }
From source file:com.taobao.android.builder.tools.proguard.AtlasProguardHelper.java
private static void addChildDependency(BundleItem bundleItem, Input input, Map<BundleInfo, AwbTransform> bundleInfoAwbTransformMap) throws IOException { List<String> pkgNames = new ArrayList<>(); input.getAwbBundles().forEach(awbTransform -> pkgNames.add(awbTransform.getAwbBundle().getPackageName())); sLogger.info("combine to proguard bundles:" + pkgNames.toString()); List<AwbTransform> childTransforms = new ArrayList<>(); sLogger.info("combine to proguard bundles:" + pkgNames.toString()); for (BundleItem child : bundleItem.children) { if (!pkgNames.contains(child.bundleInfo.getPkgName())) { childTransforms.add(bundleInfoAwbTransformMap.get(child.bundleInfo)); } else {//from ww w.jav a 2 s. c o m sLogger.error(child.bundleInfo.getPkgName() + " in proguard bundles so discard from " + bundleItem.bundleInfo.getPkgName() + "libraries..."); } for (BundleInfo sub : child.circles) { if (!pkgNames.contains(sub.getPkgName())) { childTransforms.add(bundleInfoAwbTransformMap.get(sub)); } else { sLogger.error(sub.getPkgName() + " in proguard bundles so discard from " + bundleItem.bundleInfo.getPkgName() + " libraries..."); } } } List<AwbBundle> childBundles = new ArrayList<>(); for (AwbTransform child : childTransforms) { input.getLibraries().addAll(child.getInputLibraries()); //join childBundles.add(child.getAwbBundle()); } }
From source file:com.comcast.oscar.dictionary.DictionaryTLV.java
/** * // ww w . j a v a 2 s . c o m * @param sTlvDotNotation Example 24.1.3 * @param dsq DictionarySQLQueries * @return ArrayDeque<String> of TLV Names found in Dictionary */ public static ArrayDeque<String> getTypeHierarchyStack(String sTlvDotNotation, DictionarySQLQueries dsq) { boolean localDebug = Boolean.FALSE; ArrayDeque<String> adTypeHierarchyStack = new ArrayDeque<String>(); List<String> lsTlvDotNotation = new ArrayList<String>(); lsTlvDotNotation = Arrays.asList(sTlvDotNotation.split("\\.")); if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): " + lsTlvDotNotation.toString()); //Get TLV Dictionary for the Top Level JSONObject joTlvDictionary = dsq.getTlvDefinition(Integer.decode(lsTlvDotNotation.get(0))); //Search for TLV Definition if (lsTlvDotNotation.size() == 1) { try { adTypeHierarchyStack.addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } } else if (lsTlvDotNotation.size() >= 1) { try { adTypeHierarchyStack.addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } int iRecursiveSearch = 0; while (iRecursiveSearch < lsTlvDotNotation.size()) { if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): WHILE-LOOP"); try { if (joTlvDictionary.getString(Dictionary.TYPE).equals(lsTlvDotNotation.get(iRecursiveSearch))) { if (joTlvDictionary.getBoolean(Dictionary.ARE_SUBTYPES)) { try { JSONArray jaTlvDictionary = joTlvDictionary.getJSONArray(Dictionary.SUBTYPE_ARRAY); for (int iIndex = 0; iIndex < jaTlvDictionary.length(); iIndex++) { if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): FOR-LOOP"); JSONObject joTlvDictionaryTemp = jaTlvDictionary.getJSONObject(iIndex); if (joTlvDictionaryTemp.getString(Dictionary.TYPE) .equals(lsTlvDotNotation.get(iRecursiveSearch + 1))) { joTlvDictionary = joTlvDictionaryTemp; iRecursiveSearch++; try { adTypeHierarchyStack .addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } break; } } } catch (JSONException e) { e.printStackTrace(); } } else { iRecursiveSearch++; } } } catch (JSONException e1) { e1.printStackTrace(); } } } return adTypeHierarchyStack; }
From source file:com.evolveum.liferay.usercreatehook.service.CustomUserLocalServiceImpl.java
public static void callWSForAccountCreate(String email, String name, String password, String firstName, String lastName, String fullName, String organizationName, String subOrganizationName, List<String> roles, long companyId) { LOG.info("Calling external WS for verified user creation with following data: [email='" + email + "', name='" + name + "', password='***', firstName='" + firstName + "', lastName='" + lastName + "', fullName='" + fullName + "', organizationName='" + organizationName + "', subOrganizationName='" + subOrganizationName + "', roles='" + roles.toString() + "']"); long start = System.currentTimeMillis(); LOG.debug("callWSForAccountCreate() for screenname '" + name + "' START"); boolean result = ModelPortWrapper.createUser(email, name, password, firstName, lastName, fullName, organizationName, subOrganizationName, roles); long took = System.currentTimeMillis() - start; String message = "callWSForAccountCreate() for screenname '" + name + "' took " + took + " [ms] and returned '" + result + "' END"; if (result == false || took > TRESHOLD) { LOG.info(message);/*from w w w . j a v a 2s .co m*/ } else { LOG.debug(message); } if (!result) { sendEmail("callWSForAccountCreate()", companyId); } }
From source file:edu.harvard.i2b2.fhir.I2b2Util.java
public static List<Project> getUserProjectMap(String pmResponseXml) throws XQueryUtilException { logger.trace("got xml" + pmResponseXml); List<Project> list = new ArrayList<Project>(); ArrayList<String> projectsXml = XQueryUtil.getStringSequence( "//user/project", pmResponseXml); for (String xml : projectsXml) { logger.debug("xml:" + xml); String projId = XQueryUtil.processXQuery(".//project/@id/string()", xml); String projName = XQueryUtil.processXQuery(".//project/name/text()", xml); Project p = new Project(); p.setId(projId);/*from w ww. ja v a2s . c o m*/ p.setName(projName); list.add(p); logger.trace("added proj:" + p); } logger.trace("returning projects:" + list.toString()); return list; }
From source file:language_engine.bing.BingTranslationApi.java
/** * using AJAX api now: http://msdn.microsoft.com/en-us/library/ff512402.aspx * @param accessToken// w ww .j a v a2 s . com * @param querys * @param from * @param to * @return list of String, which is the result */ public static List<String> getTranslatedStringArrays2(String accessToken, List<String> querys, SupportedLanguages from, SupportedLanguages to) { // Log.i(querys.toString()); String url = generateUrl(accessToken, querys, from, to); Header[] headers = new Header[] { new BasicHeader("Authorization", "Bearer " + accessToken), new BasicHeader("Content-Type", "text/plain; charset=" + ENCODING), new BasicHeader("Accept-Charset", ENCODING) }; String getResult = HttpUtils.doHttpGet(url, headers); // Log.i(getResult); JsonArray jsonArray = null; try { jsonArray = new JsonParser().parse(getResult).getAsJsonArray(); } catch (JsonSyntaxException e) { e.printStackTrace(); } if (jsonArray == null) return null; // Log.i("jsonArray.size: " + jsonArray.size()); List<String> result = new ArrayList<String>(); for (int i = 0; i < jsonArray.size(); i++) { String translatedText = jsonArray.get(i).getAsJsonObject().get("TranslatedText").getAsString(); if (translatedText == null) { result.add(""); } else { result.add(StringEscapeUtils.unescapeJava(translatedText)); } } if (querys.size() > result.size()) { for (int i = 0; i < querys.size(); i++) { if (querys.get(i).isEmpty()) { result.add(i, ""); } if (querys.size() == result.size()) break; } } Log.i(result.toString()); return result; }
From source file:com.xpn.xwiki.plugin.tag.TagQueryUtils.java
/** * Get cardinality map of tags matching a parameterized hql query. * * @param fromHql the <code>from</code> fragment of the hql query * @param whereHql the <code>where</code> fragment of the hql query * @param parameterValues list of parameter values for the query * @param context XWiki context.//from ww w . j av a 2 s . co m * @return map of tags (alphabetical order) with their occurrences counts. * @throws XWikiException if search query fails (possible failures: DB access problems, etc). * @since 1.18 * @see TagPluginApi#getTagCountForQuery(String, String, java.util.List) */ public static Map<String, Integer> getTagCountForQuery(String fromHql, String whereHql, List<?> parameterValues, XWikiContext context) throws XWikiException { List<String> results = null; Map<String, Integer> tagCount = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER); String from = "select elements(prop.list) from XWikiDocument as doc, BaseObject as tagobject, " + "DBStringListProperty as prop"; String where = " where tagobject.name=doc.fullName and tagobject.className='XWiki.TagClass' and " + "tagobject.id=prop.id.id and prop.id.name='tags'"; // If at least one of the fragments is passed, the query should be matching XWiki documents if (!StringUtils.isBlank(fromHql) || !StringUtils.isBlank(whereHql)) { from += fromHql; } if (!StringUtils.isBlank(whereHql)) { where += " and " + whereHql; } List<?> params = parameterValues; if (params == null) { params = new ArrayList<String>(); } String hql = from + where; try { Query query = context.getWiki().getStore().getQueryManager().createQuery(hql, Query.HQL); query.bindValues((List<Object>) params); query.addFilter(Utils.<QueryFilter>getComponent(QueryFilter.class, HiddenDocumentFilter.HINT)); results = query.execute(); } catch (QueryException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, String .format("Failed to get tag count for query [%s], with parameters [%s]", hql, params.toString()), e); } Collections.sort(results, String.CASE_INSENSITIVE_ORDER); Map<String, String> processedTags = new HashMap<String, String>(); // We have to manually build a cardinality map since we have to ignore tags case. for (String result : results) { // This key allows to keep track of the case variants we've encountered. String lowerTag = result.toLowerCase(); // We store the first case variant to reuse it in the final result set. if (!processedTags.containsKey(lowerTag)) { processedTags.put(lowerTag, result); } String tagCountKey = processedTags.get(lowerTag); int tagCountForTag = 0; if (tagCount.get(tagCountKey) != null) { tagCountForTag = tagCount.get(tagCountKey); } tagCount.put(tagCountKey, tagCountForTag + 1); } return tagCount; }
From source file:energy.usef.environment.tool.security.VaultService.java
/** * Executes a class's static main method with the current java executable and classpath in a separate process. * /* w w w .ja v a 2 s . c om*/ * @param klass the class to call the static main method for * @param params the parameters to provide * @return the exit code of the process * @throws IOException * @throws InterruptedException */ public static int exec(@SuppressWarnings("rawtypes") Class klass, List<String> params) throws IOException, InterruptedException { String javaHome = System.getProperty("java.home"); String javaBin = javaHome + File.separator + "bin" + File.separator + "java"; String classpath = System.getProperty("java.class.path"); String className = klass.getCanonicalName(); // construct the command line List<String> command = new ArrayList<String>(); command.add(javaBin); command.add("-cp"); command.add(classpath); command.add(className); command.addAll(params); LOGGER.debug("executing class '{}' with params '{}' in classpath '{}' with java binary '{}'", className, params.toString(), classpath, javaBin); // build and start the Vault's process ProcessBuilder builder = new ProcessBuilder(command); Process process = builder.start(); process.waitFor(); // get the input and error streams of the process and log them InputStream in = process.getInputStream(); InputStream en = process.getErrorStream(); InputStreamReader is = new InputStreamReader(in); InputStreamReader es = new InputStreamReader(en); BufferedReader br = new BufferedReader(is); BufferedReader be = new BufferedReader(es); String read = br.readLine(); while (read != null) { LOGGER.debug(read); read = br.readLine(); } read = be.readLine(); while (read != null) { LOGGER.debug(read); read = be.readLine(); } br.close(); is.close(); in.close(); return process.exitValue(); }
From source file:controllers.nwbib.Application.java
static Promise<Result> call(final String q, final String person, final String name, final String subject, final String id, final String publisher, final String issued, final String medium, final String nwbibspatial, final String nwbibsubject, final int from, final int size, String owner, String t, String sort, boolean showDetails, String set, String location, String word, String corporation, String raw) { final WSRequestHolder requestHolder = Lobid.request(q, person, name, subject, id, publisher, issued, medium, nwbibspatial, nwbibsubject, from, size, owner, t, sort, showDetails, set, location, word, corporation, raw);/*from w w w . ja v a 2 s .c o m*/ return requestHolder.get().map((WSResponse response) -> { Long hits = 0L; String s = "{}"; if (response.getStatus() == Http.Status.OK) { JsonNode json = response.asJson(); hits = Lobid.getTotalResults(json); s = json.toString(); if (id.isEmpty()) { List<JsonNode> ids = json.findValues("hbzId"); uncache(ids.stream().map(j -> j.asText()).collect(Collectors.toList())); Cache.set(session("uuid") + "-lastSearch", ids.toString(), ONE_DAY); } } else { Logger.warn("{}: {} ({}, {})", response.getStatus(), response.getStatusText(), requestHolder.getUrl(), requestHolder.getQueryParameters()); } if (showDetails) { String json = ""; JsonNode nodes = Json.parse(s); if (nodes.isArray() && nodes.size() == 2) { // first: metadata json = nodes.get(1).toString(); } else { Logger.warn("No suitable data to show details for: {}", nodes); } return ok(details.render(CONFIG, json, id)); } return ok(search.render(s, q, person, name, subject, id, publisher, issued, medium, nwbibspatial, nwbibsubject, from, size, hits, owner, t, sort, set, location, word, corporation, raw)); }); }