List of usage examples for java.lang System lineSeparator
String lineSeparator
To view the source code for java.lang System lineSeparator.
Click Source Link
From source file:com.pearson.eidetic.driver.threads.MonitorSnapshotVolumeTime.java
public String getPeriod(JSONObject eideticParameters, Volume vol) { if ((eideticParameters == null)) { return null; }//from w w w. ja v a2s.c o m JSONObject createSnapshot = null; if (eideticParameters.containsKey("CreateSnapshot")) { createSnapshot = (JSONObject) eideticParameters.get("CreateSnapshot"); } if (createSnapshot == null) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return null; } String period = null; if (createSnapshot.containsKey("Interval")) { try { period = createSnapshot.get("Interval").toString(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } return period; }
From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java
public static String createDataCode(DataModel dataModel) { try {//from www . j a v a 2s . co m // get all data templates String data = getScriptTemplateByName(DATA_TEMPLATE_SCRIPT); String field = getScriptTemplateByName(FIELD_TEMPLATE_SCRIPT); String list = getScriptTemplateByName(LIST_TEMPLATE_SCRIPT); String map = getScriptTemplateByName(MAP_TEMPLATE_SCRIPT); String methodField = getScriptTemplateByName(METHOD_FIELD_TEMPLATE_SCRIPT); String methodList = getScriptTemplateByName(METHOD_LIST_TEMPLATE_SCRIPT); String methodMap = getScriptTemplateByName(METHOD_MAP_TEMPLATE_SCRIPT); // prepare fields and methods StringBuilder f = new StringBuilder(); StringBuilder m = new StringBuilder(); for (FieldModel fieldModel : dataModel.getFields()) { Map<String, Object> bindings = new HashMap<>(); bindings.put("fieldName", fieldModel.getName()); bindings.put("className", fieldModel.getClassName()); if (fieldModel.getCollection().equals(FieldModel.COLLECTION_TYPE.NONE)) { f.append(fillTemplate(field, bindings)).append(System.lineSeparator()); m.append(fillTemplate(methodField, bindings)).append(System.lineSeparator()); } else if (fieldModel.getCollection().equals(FieldModel.COLLECTION_TYPE.LIST)) { f.append(fillTemplate(list, bindings)).append(System.lineSeparator()); m.append(fillTemplate(methodList, bindings)).append(System.lineSeparator()); // } else if (fieldModel.getCollection().equals(COLLECTION_TYPE.MAP)) { // f.append(fillTemplate(map.getSource(), bindings)).append(System.lineSeparator()); // m.append(fillTemplate(methodMap.getSource(), bindings)).append(System.lineSeparator()); } } // create final script Map<String, Object> bindings = new HashMap<>(); bindings.put("className", dataModel.getName()); bindings.put("fields", f.toString()); bindings.put("methods", m.toString()); String source = fillTemplate(data, bindings); return source; } catch (Exception ex) { logger.log(Level.SEVERE, ex.getMessage(), ex); return null; } }
From source file:com.pearson.eidetic.driver.threads.MonitorSnapshotVolumeTime.java
public String getRunAt(JSONObject eideticParameters, Volume vol) { if ((eideticParameters == null)) { return null; }//from w w w . j a va 2 s. c o m JSONObject createSnapshot = null; if (eideticParameters.containsKey("CreateSnapshot")) { createSnapshot = (JSONObject) eideticParameters.get("CreateSnapshot"); } if (createSnapshot == null) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return null; } String runAt = null; if (createSnapshot.containsKey("RunAt")) { try { runAt = createSnapshot.get("RunAt").toString(); } catch (Exception e) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } return runAt; }
From source file:com.spotify.docker.BuildMojoTest.java
private void testLogOutputToFile(boolean newFile) throws Exception { final File pom = getTestFile("src/test/resources/pom-build-log-output.xml"); assertNotNull("Null pom.xml", pom); assertTrue("pom.xml does not exist", pom.exists()); // Make sure initially the file to be logged does not exist final String outputFileName = "target/docker/outputDir/file-to-log-output.log"; final File outputFile = getTestFile(outputFileName); assertNotNull("Null output file", outputFile); assertFalse("output file already exists", outputFile.exists()); final BuildMojo mojo = setupMojo(pom); final DockerClient docker = mock(DockerClient.class); // A matcher that grabs the instantiated AnsiProgressHandler and logs a message final String testMessage = "Testing progress is logged to file"; ArgumentMatcher<AnsiProgressHandler> matcher = new ArgumentMatcher<AnsiProgressHandler>() { @Override//from w w w .j av a2s .c o m public boolean matches(Object argument) { assertTrue(AnsiProgressHandler.class.isInstance(argument)); AnsiProgressHandler handler = AnsiProgressHandler.class.cast(argument); ProgressMessage message = new ProgressMessage(); message.status(testMessage); try { handler.progress(message); } catch (DockerException e) { fail("Unexpected error"); } return true; } }; if (!newFile) { File parent = outputFile.getParentFile(); assertTrue("Cannot create parent directory", parent.exists() || parent.mkdirs()); assertTrue("Cannot create output file", outputFile.createNewFile()); } when(docker.build(eq(Paths.get("target/docker")), eq("busybox"), argThat(matcher))) .thenReturn(StringUtils.EMPTY); mojo.execute(docker); verify(docker).build(eq(Paths.get("target/docker")), eq("busybox"), any(AnsiProgressHandler.class)); // Make sure output file exists and message is logged assertFileExists(outputFileName); byte[] encoded = Files.readAllBytes(Paths.get(outputFileName)); assertEquals(testMessage + System.lineSeparator(), new String(encoded, "UTF-8")); }
From source file:listener.Handler.java
License:asdf
private void switchPower(String[] message) { if (acc.hasAccountPrivilege(AccountPrivileges.PERM_CMD_SWITCHPOWER)) { // if (message.length > ) if (message.length > 3) { String infoString = "Executing switch command"; if (verbose) Logger.logMessage('I', this, infoString); this.replyMessage(infoString); if (verbose) Logger.logMessage('I', this, "infoString"); try { Runtime.getRuntime().exec("sudo send " + message[1] + " " + message[2] + " " + message[3]); } catch (IOException e) { String error = "Error when trying to execute send command"; Logger.logException('E', error, e); this.replyMessage(error + " " + e.getMessage() + System.lineSeparator() + e.getStackTrace()); }/*from w ww. j av a 2 s . c o m*/ } else { String error = "usage: switchOn <systemID> <unitID>; switchOff <systemID> <unitID>; switch <systemID> <unitID> <state>; see help for more information."; // TODO: Multi-line messages Logger.logMessage('E', "not enough arguments for switchOn command. " + error); this.replyMessage(error); } } else { this.noPermAns("switchPower"); } }
From source file:org.apache.hadoop.yarn.client.cli.TopCLI.java
private void setAppsHeader() { List<String> formattedStrings = new ArrayList<>(); for (EnumMap.Entry<Columns, ColumnInformation> entry : columnInformationEnumMap.entrySet()) { if (entry.getValue().display) { formattedStrings.add(String.format(entry.getValue().format, entry.getValue().header)); }//from w w w . j a va2 s . com } appsHeader = StringUtils.join(formattedStrings.toArray(), " "); if (appsHeader.length() > terminalWidth) { appsHeader = appsHeader.substring(0, terminalWidth - System.lineSeparator().length()); } else { appsHeader += StringUtils.repeat(" ", terminalWidth - appsHeader.length() - System.lineSeparator().length()); } appsHeader += System.lineSeparator(); }
From source file:com.pearson.eidetic.driver.threads.MonitorSnapshotVolumeTime.java
public Integer getKeep(JSONObject eideticParameters, Volume vol) { if ((eideticParameters == null) || (vol == null)) { return null; }/*from w w w . j av a2 s . c o m*/ JSONObject createSnapshot = null; if (eideticParameters.containsKey("CreateSnapshot")) { createSnapshot = (JSONObject) eideticParameters.get("CreateSnapshot"); } if (createSnapshot == null) { logger.error("Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return null; } Integer keep = null; if (createSnapshot.containsKey("Retain")) { try { keep = Integer.parseInt(createSnapshot.get("Retain").toString()); } catch (Exception e) { logger.error("awsAccountNickname=\"" + awsAccount_.getUniqueAwsAccountIdentifier() + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } return keep; }
From source file:com.vmware.identity.SsoController.java
/** * Allows view jsp to query logon banner attributes of the tenant * * @param tenant/* w w w. java 2 s. c o m*/ * the cookieAuthenticator to set */ // @ModelAttribute("tenant_logonbanner_title") // @ModelAttribute("tenant_logonbanner_content") // @ModelAttribute("enable_logonbanner_checkbox") private void setLogonBannerModelAttributes(String tenant, Model model) { if (tenant == null || tenant.isEmpty()) { return; } DefaultIdmAccessorFactory idmFactory = new DefaultIdmAccessorFactory(); Validate.notNull(idmFactory, "idmFactory"); IdmAccessor idmAccessor = idmFactory.getIdmAccessor(); idmAccessor.setTenant(tenant); String logonBannerTitle = idmAccessor.getLogonBannerTitle(); String logonBannerContent = idmAccessor.getLogonBannerContent(); // escape html and javascript logonBannerTitle = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(logonBannerTitle)); logonBannerContent = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(logonBannerContent)); logger.trace("Accessing Tenant " + tenant + ", logon banner title " + logonBannerTitle); logger.trace("Accessing Tenant " + tenant + ", logon banner content" + System.lineSeparator() + logonBannerContent); model.addAttribute("tenant_logonbanner_title", logonBannerTitle); model.addAttribute("tenant_logonbanner_content", logonBannerContent); model.addAttribute("enable_logonbanner_checkbox", idmAccessor.getLogonBannerCheckboxFlag()); }
From source file:net.certifi.audittablegen.GenericDMR.java
String getCreateTableSQL(List<DBChangeUnit> op) { StringBuilder builder = new StringBuilder(); StringBuilder constraints = new StringBuilder(); DataTypeDef dataTypeDef = null;//from w w w. jav a 2s . c o m boolean firstCol = true; String schema; if (verifiedSchema != null) { schema = verifiedSchema + "."; } else { schema = ""; } for (DBChangeUnit unit : op) { switch (unit.changeType) { case begin: //nothinig break; case end: builder.append(constraints); builder.append(")").append(System.lineSeparator()); //execute SQL here... break; case createTable: builder.append("CREATE TABLE ").append(schema).append(unit.tableName).append(" (") .append(System.lineSeparator()); break; case addColumn: if (!firstCol) { builder.append(", "); } else { firstCol = false; } dataTypeDef = getDataType(unit.typeName); if (unit.identity) { builder.append(unit.columnName).append(" ").append("serial PRIMARY KEY") .append(System.lineSeparator()); } else { builder.append(unit.columnName).append(" ").append(unit.typeName); // if (dataTypeDef.create_params != null && unit.size > 0){ if (dataTypeDef.createWithSize && unit.size > 0) { builder.append(" (").append(unit.size); if (unit.decimalSize > 0) { builder.append(",").append(unit.decimalSize); } builder.append(") "); } if (!unit.foreignTable.isEmpty()) { builder.append("REFERENCES ").append(unit.foreignTable).append(" (").append(unit.columnName) .append(")"); //constraints.append("CONSTRAINT ").append(unit.columnName).append(" REFERENCES ").append(unit.foreignTable); } builder.append(System.lineSeparator()); } break; default: //should not get here if the list is valid, unless a new changetype //was added that this DMR does not know about. If which case - fail. logger.error("unimplemented DBChangeUnit '{}' for create table operation", unit.getChangeType().toString()); return null; } } return builder.toString(); }
From source file:com.basistech.rosette.api.HttpRosetteAPI.java
/** * Gets response from HTTP connection, according to the specified response class; * throws for an error response.//from w w w. j a v a2s . c o m * * @param httpResponse the response object * @param clazz Response class * @return Response * @throws IOException */ private <T extends Object> T getResponse(HttpResponse httpResponse, Class<T> clazz) throws IOException, HttpRosetteAPIException { int status = httpResponse.getStatusLine().getStatusCode(); String encoding = headerValueOrNull(httpResponse.getFirstHeader(HttpHeaders.CONTENT_ENCODING)); try (InputStream stream = httpResponse.getEntity().getContent(); InputStream inputStream = "gzip".equalsIgnoreCase(encoding) ? new GZIPInputStream(stream) : stream) { String ridHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-DocumentRequest-Id")); if (HTTP_OK != status) { String ecHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Code")); String emHeader = headerValueOrNull(httpResponse.getFirstHeader("X-RosetteAPI-Status-Message")); String responseContentType = headerValueOrNull( httpResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE)); if ("application/json".equals(responseContentType)) { ErrorResponse errorResponse = mapper.readValue(inputStream, ErrorResponse.class); if (ridHeader != null) { LOG.debug("DocumentRequest ID " + ridHeader); } if (ecHeader != null) { errorResponse.setCode(ecHeader); } if (429 == status) { String concurrencyMessage = "You have exceeded your plan's limit on concurrent calls. " + "This could be caused by multiple processes or threads making Rosette API calls in parallel, " + "or if your httpClient is configured with higher concurrency than your plan allows."; if (emHeader == null) { emHeader = concurrencyMessage; } else { emHeader = concurrencyMessage + System.lineSeparator() + emHeader; } } if (emHeader != null) { errorResponse.setMessage(emHeader); } throw new HttpRosetteAPIException(errorResponse, status); } else { String errorContent; if (inputStream != null) { byte[] content = getBytes(inputStream); errorContent = new String(content, "utf-8"); } else { errorContent = "(no body)"; } // something not from us at all throw new HttpRosetteAPIException("Invalid error response (not json)", new ErrorResponse("invalidErrorResponse", errorContent), status); } } else { return mapper.readValue(inputStream, clazz); } } }