List of usage examples for java.util List toString
public String toString()
From source file:com.chinamobile.bcbsp.io.titan.TitanRecordWriter.java
/** * Check whether there is a vertex which having given id in Titan database. * @param id//w w w. j a v a 2 s. c o m * vertexID to have. * @return if have true, * else false. */ private boolean hasVertex(String id) { List<Map<String, Object>> result = null; try { result = client.execute("g.V('vertexID','" + id + "').vertexID"); } catch (RexProException e) { LOG.error("RexProException: Can not read data from database"); } catch (IOException e) { LOG.error("IOException: Can not read data from database"); } if (result.toString().length() <= 2) { return false; } else { return true; } }
From source file:org.lcog.cyclelane.TripUploader.java
boolean uploadOneTrip(long currentTripId) { boolean result = false; List<NameValuePair> nameValuePairs; try {//from ww w .j av a2 s . co m nameValuePairs = getPostData(currentTripId); } catch (JSONException e) { e.printStackTrace(); return result; } Log.v("PostData", nameValuePairs.toString()); HttpClient client = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(postUrl); try { postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(postRequest); String responseString = convertStreamToString(response.getEntity().getContent()); Log.v("httpResponse", responseString); JSONObject responseData = new JSONObject(responseString); if (responseData.getString("status").equals("success")) { mDb.open(); mDb.updateTripStatus(currentTripId, TripData.STATUS_SENT); mDb.close(); result = true; } } catch (IllegalStateException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } catch (JSONException e) { e.printStackTrace(); return false; } return result; }
From source file:com.crankworks.cycletracks.TripUploader.java
boolean uploadOneTrip(long currentTripId) { boolean result = false; List<NameValuePair> nameValuePairs; try {/*from w w w . jav a 2 s.c o m*/ nameValuePairs = getPostData(currentTripId); } catch (JSONException e) { e.printStackTrace(); return result; } Log.v("PostData", nameValuePairs.toString()); HttpClient client = new DefaultHttpClient(); final String postUrl = "http://bikedatabase.sfcta.org/post/"; HttpPost postRequest = new HttpPost(postUrl); try { postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(postRequest); String responseString = convertStreamToString(response.getEntity().getContent()); Log.v("httpResponse", responseString); JSONObject responseData = new JSONObject(responseString); if (responseData.getString("status").equals("success")) { mDb.open(); mDb.updateTripStatus(currentTripId, TripData.STATUS_SENT); mDb.close(); result = true; } } catch (IllegalStateException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } catch (JSONException e) { e.printStackTrace(); return false; } return result; }
From source file:com.fatwire.dta.sscrawler.reporting.reporters.DefaultArgumentsAsPageCriteriaReporter.java
public synchronized void addToReport(final ResultPage page) { if (page.getResponseCode() == 200) { if (pagenamesDone.contains(page.getPageName())) { return; }//from w ww. ja va 2 s.com pagenamesDone.add(page.getPageName()); final List<String> pageCriteria = extractPageCriteria(page.getResponseHeaders()); for (final Header header : page.getResponseHeaders()) { if (header.getName().startsWith(DEFAULT_ARGUMENTS)) { final String v = header.getValue().split("\\|", 2)[0]; if (!pageCriteria.contains(v)) { count.incrementAndGet(); report.addRow(new String[] { page.getPageName(), v, pageCriteria.toString() }); } } } } }
From source file:com.kentli.cycletrack.TripUploader.java
boolean uploadOneTrip(long currentTripId) { boolean result = false; List<NameValuePair> nameValuePairs; try {//from w w w . j ava 2s .co m nameValuePairs = getPostData(currentTripId); } catch (JSONException e) { e.printStackTrace(); return result; } Log.v("PostData", nameValuePairs.toString()); HttpClient client = new DefaultHttpClient(); final String postUrl = "http://fathomless-brook-26316.herokuapp.com/post/"; HttpPost postRequest = new HttpPost(postUrl); try { postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(postRequest); String responseString = convertStreamToString(response.getEntity().getContent()); Log.v("httpResponse", responseString); JSONObject responseData = new JSONObject(responseString); if (responseData.getString("status").equals("success")) { mDb.open(); mDb.updateTripStatus(currentTripId, TripData.STATUS_SENT); mDb.close(); result = true; } } catch (IllegalStateException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } catch (JSONException e) { e.printStackTrace(); return false; } return result; }
From source file:controlador.Controlador.java
private Destino handleUsuario(HttpServletRequest request, HttpServletResponse response, String op, String accion, String origen) throws JSONException { switch (op) { case "login": if (origen.equals("android")) { JSONObject obj = GestorUsuario.getLogin(request.getParameter("login"), request.getParameter("pass")); return new Destino(Camino.print, "", obj.toString()); }/*from w w w . j a va 2s. c o m*/ if (origen.equals("web")) { JSONObject obj = GestorUsuario.getLogin(request.getParameter("login"), request.getParameter("pass")); if (obj.getBoolean("r")) { List<Keep> keeps = GestorKeep.listKeeps(request.getParameter("login")); request.setAttribute("listado", keeps); request.setAttribute("login", GestorUsuario.getUserbyName(request.getParameter("login"))); return new Destino(Camino.forward, "/WEB-INF/viewkeeps.jsp", keeps.toString()); } else { return new Destino(Camino.print, "index.html", obj.toString()); } } } return null; }
From source file:gov.nih.nci.cabig.labviewer.grid.LabViewerStudyConsumer.java
/** * @param callerId//from w w w . ja va2 s .c om * @throws StudyCreationException */ private void checkAuthorization(String callerId, Study study) throws StudyCreationException { if (callerId == null) { log.error("Error saving study: no user credentials provided"); throw createStudyCreationException("No user credentials provided"); } log.debug("Service called by: " + callerId); int beginIndex = callerId.lastIndexOf("=") + 1; int endIndex = callerId.length(); String username = callerId.substring(beginIndex, endIndex); log.debug("Username = " + username); List<String> siteNciInstituteCodes = getSiteNciInstituteCodes(study); log.debug("Site NCI institute codes = " + siteNciInstituteCodes.toString()); if (siteNciInstituteCodes == null) { log.error("Error saving study: site NCI institute code is null"); throw createStudyCreationException("Site NCI institute code is null"); } List<SuiteRole> studyConsumerRoles = new ArrayList<SuiteRole>(); studyConsumerRoles.add(SuiteRole.STUDY_CREATOR); studyConsumerRoles.add(SuiteRole.STUDY_QA_MANAGER); try { Map<SuiteRole, SuiteRoleMembership> userRoleMemberships = getAuthorizationHelper() .getUserRoleMemberships(username); boolean userAuthorizedForStudyConsumerRole = false; boolean userAuthorizedForSite = false; for (SuiteRole studyConsumerRole : studyConsumerRoles) { log.debug("Checking study consumer role: " + studyConsumerRole.toString()); if (userRoleMemberships.containsKey(studyConsumerRole)) { log.debug("User role memberships contains role: " + studyConsumerRole.toString()); userAuthorizedForStudyConsumerRole = true; SuiteRoleMembership userRoleMembership = userRoleMemberships.get(studyConsumerRole); // if the user has permission to access specific sites (not all sites), then verify the sites if (userRoleMembership.isAllSites()) { log.debug("User is authorized for all sites"); userAuthorizedForSite = true; } else { for (String siteNciInstituteCode : siteNciInstituteCodes) { log.debug("Checking site NCI institute code: " + siteNciInstituteCode); if (userRoleMembership.getSiteIdentifiers().contains(siteNciInstituteCode)) { log.debug( "User is authorized for site NCI institute code: " + siteNciInstituteCode); userAuthorizedForSite = true; } } } } } log.info("userAuthorizedForStudyConsumerRole = " + userAuthorizedForStudyConsumerRole); if (!userAuthorizedForStudyConsumerRole) { throw new SuiteAuthorizationAccessException("Username %s is not authorized for roles %s", username, studyConsumerRoles.toString()); } log.info("userAuthorizedForSite = " + userAuthorizedForSite); if (!userAuthorizedForSite) { throw new SuiteAuthorizationAccessException("Username %s is not authorized for sites %s", username, siteNciInstituteCodes.toString()); } } catch (SuiteAuthorizationAccessException e) { log.error("Error saving study: ", e); throw createStudyCreationException(e.getMessage()); } catch (Exception e) { log.error("Error saving study: ", e); throw createStudyCreationException(e.getMessage()); } }
From source file:ml.shifu.shifu.core.alg.TensorflowTrainer.java
public void train() throws IOException { List<String> commands = buildCommands(); ProcessBuilder pb = new ProcessBuilder(commands); pb.directory(new File("./")); pb.redirectErrorStream(true);/*from w ww .j a v a 2 s . c o m*/ LOGGER.info("Start trainning sub process. Commands {}", commands.toString()); Process process = pb.start(); StreamCollector sc = new StreamCollector(process.getInputStream()); sc.start(); try { process.waitFor(); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { if (sc != null) { sc.close(); } } }
From source file:ru.org.linux.tag.TagService.java
/** * ? ./* w w w . j a v a 2 s. c o m*/ * * @param oldTags ?? ? * @param newTags ?? */ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void updateCounters(final List<String> oldTags, final List<String> newTags) { StringBuilder logStr = new StringBuilder() .append(" ? ; ? [") .append(oldTags.toString()).append("]; [").append(newTags.toString()) .append(']'); logger.debug(logStr); for (String tag : newTags) { if (!oldTags.contains(tag)) { int id = getOrCreateTag(tag); logger.trace(" ? ? " + tag); tagDao.increaseCounterById(id, 1); } } for (String tag : oldTags) { if (!newTags.contains(tag)) { int id = getOrCreateTag(tag); logger.trace(" ? ? " + tag); tagDao.decreaseCounterById(id, 1); } } logger.trace(": " + logStr); }
From source file:nl.surfnet.coin.janus.JanusRestClient.java
@Override public boolean isConnectionAllowed(String spEntityId, String idpEntityId) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("spentityid", spEntityId); parameters.put("idpentityid", idpEntityId); URI signedUri = null;//from w ww .jav a 2 s . c o m try { signedUri = sign("isConnectionAllowed", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } } catch (IOException e) { LOG.error("Could not do isConnectionAllowed request to Janus", e); } final List restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return CollectionUtils.isEmpty(restResponse) ? false : (Boolean) restResponse.get(0); }