List of usage examples for java.lang String toString
public String toString()
From source file:com.clustercontrol.notify.util.QueryUtil.java
public static NotifyLogEscalateInfo getNotifyLogEscalateInfoPK(String pk) throws NotifyNotFound { HinemosEntityManager em = new JpaTransactionManager().getEntityManager(); NotifyLogEscalateInfo entity = em.find(NotifyLogEscalateInfo.class, pk, ObjectPrivilegeMode.READ); if (entity == null) { NotifyNotFound e = new NotifyNotFound("NotifyLogEscalateInfoEntity.findByPrimaryKey" + pk.toString()); m_log.info("getNotifyLogEscalateInfoPK() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); throw e;/*w w w. j a v a 2s. co m*/ } return entity; }
From source file:helpers.BaseFilterController.java
protected static void executeFilter(BaseFilter baseFilter, FilterOptions options, File image, String url) { try {//www .j a v a 2 s . com Promise<ApplyFilterResult> now = null; if (image == null) { now = new ApplyFilterJob(baseFilter, new URL(url), options).now(); } else { now = new ApplyFilterJob(baseFilter, image, options).now(); } ApplyFilterResult output = await(now); if (output.getException() != null) { throw output.getException(); } String format = null; if (image == null) { format = SupportedFormats.getFormatExtension(url.toString()); } else { format = SupportedFormats.getFormatExtension(image.getAbsolutePath()); } if (StringUtils.isNotBlank(format)) { response.setHeader("Content-Type", "image/" + format); } response.out = output.getOutput(); } catch (Exception e) { handleError(e); } }
From source file:hydrograph.engine.spark.helper.DelimitedAndFixedWidthHelper.java
public static String spillOneLineToOutput(String sb, String[] lengthsAndDelimiters) { String line = ""; if (!isLastFieldNewLine(lengthsAndDelimiters) && !isLastFixedWidthFieldNewLineField(lengthsAndDelimiters)) { if (hasaNewLineField(lengthsAndDelimiters) || containsNewLine(sb)) { String[] splits = sb.toString().split("\n"); for (int i = 0; i < splits.length; i++) { if (i != splits.length - 1) { line += splits[i];//from w ww . j ava2 s. c o m line += "\n"; } } return line.substring(0, line.length() - 1); } } else { sb = sb.substring(0, sb.length() - 1); return sb; } return line; }
From source file:esg.common.Utils.java
public static String getNodeID() { String nodeID = null; if (null != nodeID) { return nodeID; }//from w w w.j a v a 2 s. c o m try { nodeID = java.net.InetAddress.getLocalHost().getHostAddress(); } catch (java.net.UnknownHostException ex) { log.error(ex); } //NOTE: Doing the call to "toString" on purpose to force a null //pointer exception the return value should NEVER be null! return nodeID.toString(); }
From source file:us.colloquy.util.ElasticLoader.java
private static void indexDiaries(List<DiaryEntry> diaryEntryList, RestHighLevelClient client, BulkRequest bulkRequest) throws IOException { ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); for (DiaryEntry diary : diaryEntryList) { String json = ow.writeValueAsString(diary); String id = diary.getId() + "-" + diary.getDate() + "-" + diary.getSource(); if (StringUtils.isNotEmpty(json)) { IndexRequest indexRequest = new IndexRequest("lntolstoy-diaries", "diaries", id).source(json, XContentType.JSON);/*from w w w . j ava 2 s. c om*/ bulkRequest.add(new UpdateRequest("lntolstoy-diaries", "diaries", id).doc(json, XContentType.JSON) .upsert(indexRequest)); } else { System.out.println("empty doc: " + id.toString()); } } BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT); if (bulkResponse.hasFailures()) { // process failures by iterating through each bulk response item for (BulkItemResponse br : bulkResponse.getItems()) { System.out.println(br.getFailureMessage()); } } }
From source file:com.game.simple.Game3.java
public static void sendEmail(String address, String subject, String content) { //---timer---// //StartReConnect(); //-----------// String[] _address = { address.toString() }; Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, _address); email.putExtra(Intent.EXTRA_SUBJECT, subject); email.putExtra(Intent.EXTRA_TEXT, content); email.setType("message/rfc822"); self.startActivity(Intent.createChooser(email, "Choose an Email client :")); }
From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java
private static void prepareSamlResponseFailConnector(final HttpServletRequest request, AbstractEIDASException exc, IEIDASSession eidasSession) { ICONNECTORSAMLService connectorSamlService = ApplicationContextProvider.getApplicationContext() .getBean(ICONNECTORSAMLService.class); if (connectorSamlService == null) { return;/*from w w w. j a va 2 s .c om*/ } String spUrl = getErrorReportingUrl(request, eidasSession); if (spUrl == null || !isErrorCodeAllowedForSamlGeneration(exc)) { LOG.info("ERROR : " + getEidasErrorMessage(exc, null)); return; } byte[] samlToken = connectorSamlService.generateErrorAuthenticationResponse(getInResponseTo(request), getIssuer(request), spUrl.toString(), request.getRemoteAddr(), getSamlStatusCode(request), getSamlSubStatusCode(exc), exc.getErrorMessage()); exc.setSamlTokenFail(EIDASUtil.encodeSAMLToken(samlToken)); if (eidasSession != null) { eidasSession.put(EIDASParameters.ERROR_REDIRECT_URL.toString(), spUrl); } }
From source file:plugins.marauders.MaraudersInteractor.java
public static void updateStudentIDData(int newStudentMax) { String doc = String.format("{\"doc\": {\"lastStudentID\": \"%s\"}}", newStudentMax + ""); try {/*from w w w.j a v a 2s . c om*/ Data d = getData(); d.getLastStudentID(); RestAdapter adapter = new RestAdapter.Builder() .setEndpoint("http://s40server.csse.rose-hulman.edu:9200").build(); MaraudersService service = adapter.create(MaraudersService.class); LinkedTreeMap o = (LinkedTreeMap) service.updateData(new TypedJsonString(doc.toString())); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.impetus.client.couchdb.CouchDBUtils.java
/** * Creates the design document if not exist. * //from w w w. j a va2 s. c om * @param httpClient * the http client * @param httpHost * the http host * @param gson * the gson * @param tableName * the table name * @param schemaName * the schema name * @param viewName * the view name * @param columns * the columns * @throws URISyntaxException * the URI syntax exception * @throws UnsupportedEncodingException * the unsupported encoding exception * @throws IOException * Signals that an I/O exception has occurred. * @throws ClientProtocolException * the client protocol exception */ public static void createDesignDocumentIfNotExist(HttpClient httpClient, HttpHost httpHost, Gson gson, String tableName, String schemaName, String viewName, List<String> columns) throws URISyntaxException, UnsupportedEncodingException, IOException, ClientProtocolException { URI uri; HttpResponse response = null; CouchDBDesignDocument designDocument = CouchDBUtils.getDesignDocument(httpClient, httpHost, gson, tableName, schemaName); Map<String, MapReduce> views = designDocument.getViews(); if (views == null) { views = new HashMap<String, MapReduce>(); } if (views.get(viewName.toString()) == null) { CouchDBUtils.createView(views, viewName, columns); } String id = CouchDBConstants.DESIGN + tableName; if (designDocument.get_rev() == null) { uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR + id, null, null); } else { StringBuilder builder = new StringBuilder("rev="); builder.append(designDocument.get_rev()); uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR + id, builder.toString(), null); } HttpPut put = new HttpPut(uri); designDocument.setViews(views); String jsonObject = gson.toJson(designDocument); StringEntity entity = new StringEntity(jsonObject); put.setEntity(entity); try { response = httpClient.execute(httpHost, put, CouchDBUtils.getContext(httpHost)); } finally { CouchDBUtils.closeContent(response); } }
From source file:plugins.marauders.MaraudersInteractor.java
public static boolean updateStudentLocation(String name, String location) { Student s = getStudent(name);/* www .java 2s . c om*/ if (s == null) { return false; } else { String doc = String.format("{\"doc\": {\"location\": \"%s\"}}", location + ""); try { RestAdapter adapter = new RestAdapter.Builder() .setEndpoint("http://s40server.csse.rose-hulman.edu:9200").build(); MaraudersService service = adapter.create(MaraudersService.class); LinkedTreeMap o = (LinkedTreeMap) service.updateStudent(Integer.parseInt(s.getID()), new TypedJsonString(doc.toString())); return true; } catch (Exception e) { e.printStackTrace(); return false; } } }