List of usage examples for org.apache.commons.lang StringUtils deleteWhitespace
public static String deleteWhitespace(String str)
Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .
From source file:org.kuali.kfs.module.tem.batch.AgencyDataXmlInputFileType.java
/** * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String) *///from www. j ava 2 s.c o m @Override public String getFileName(String principalName, Object parsedFileContents, String fileUserIdentifier) { StringBuilder fileName = new StringBuilder(); fileUserIdentifier = StringUtils.deleteWhitespace(fileUserIdentifier); fileUserIdentifier = StringUtils.remove(fileUserIdentifier, TemConstants.FILE_NAME_PART_DELIMITER); fileName.append(this.getFileNamePrefix()).append(TemConstants.FILE_NAME_PART_DELIMITER); fileName.append(principalName).append(TemConstants.FILE_NAME_PART_DELIMITER); fileName.append(fileUserIdentifier).append(TemConstants.FILE_NAME_PART_DELIMITER); fileName.append(dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate())); return fileName.toString(); }
From source file:org.kuali.kfs.pdp.service.impl.PdpEmailServiceImpl.java
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendErrorEmail(org.kuali.kfs.pdp.businessobject.PaymentFileLoad, * org.kuali.rice.kns.util.ErrorMap) *//*w ww .j a v a 2s .c om*/ @Override public void sendErrorEmail(PaymentFileLoad paymentFile, MessageMap errors) { LOG.debug("sendErrorEmail() starting"); // check email configuration if (!isPaymentEmailEnabled()) { return; } MailMessage message = new MailMessage(); String returnAddress = parameterService.getParameterValueAsString( KfsParameterConstants.PRE_DISBURSEMENT_BATCH.class, KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM); if (StringUtils.isEmpty(returnAddress)) { returnAddress = mailService.getBatchMailingList(); } message.setFromAddress(returnAddress); message.setSubject( getEmailSubject(PdpParameterConstants.PAYMENT_LOAD_FAILURE_EMAIL_SUBJECT_PARAMETER_NAME)); StringBuilder body = new StringBuilder(); List<String> ccAddresses = new ArrayList<String>(parameterService .getParameterValuesAsString(LoadPaymentsStep.class, PdpParameterConstants.HARD_EDIT_CC)); if (paymentFile == null) { if (ccAddresses.isEmpty()) { LOG.error("sendErrorEmail() No HARD_EDIT_CC addresses. No email sent"); return; } message.getToAddresses().addAll(ccAddresses); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_BAD_FILE_PARSE) + "\n\n"); } else { CustomerProfile customer = customerProfileService.get(paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit()); if (customer == null) { LOG.error("sendErrorEmail() Invalid Customer. Sending email to CC addresses"); if (ccAddresses.isEmpty()) { LOG.error("sendErrorEmail() No HARD_EDIT_CC addresses. No email sent"); return; } message.getToAddresses().addAll(ccAddresses); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_INVALID_CUSTOMER) + "\n\n"); } else { String toAddresses = StringUtils.deleteWhitespace(customer.getProcessingEmailAddr()); List<String> toAddressList = Arrays.asList(toAddresses.split(",")); message.getToAddresses().addAll(toAddressList); message.getCcAddresses().addAll(ccAddresses); //TODO: for some reason the mail service does not work unless the bcc list has addresss. This is a temporary workaround message.getBccAddresses().addAll(ccAddresses); } } if (paymentFile != null) { body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_NOT_LOADED) + "\n\n"); addPaymentFieldsToBody(body, null, paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit(), paymentFile.getCreationDate(), paymentFile.getPaymentCount(), paymentFile.getPaymentTotalAmount()); } body.append("\n" + getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_ERROR_MESSAGES) + "\n"); List<ErrorMessage> errorMessages = errors.getMessages(KFSConstants.GLOBAL_ERRORS); if (errorMessages != null) { for (ErrorMessage errorMessage : errorMessages) { body.append(getMessage(errorMessage.getErrorKey(), (Object[]) errorMessage.getMessageParameters()) + "\n\n"); } message.setMessage(body.toString()); // KFSMI-6475 - if not a production instance, replace the recipients with the testers list alterMessageWhenNonProductionInstance(message, null); try { mailService.sendMessage(message); } catch (Exception e) { LOG.error("sendErrorEmail() caught an exception while trying to sendMessage. Message not sent", e); throw new RuntimeException(e); } } }
From source file:org.kuali.kfs.pdp.service.impl.PdpEmailServiceImpl.java
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendLoadEmail(org.kuali.kfs.pdp.businessobject.PaymentFileLoad, * java.util.List)//from w w w . ja v a2s.c o m */ @Override public void sendLoadEmail(PaymentFileLoad paymentFile, List<String> warnings) { LOG.debug("sendLoadEmail() starting"); // check email configuration if (!isPaymentEmailEnabled()) { return; } MailMessage message = new MailMessage(); String returnAddress = parameterService.getParameterValueAsString( KfsParameterConstants.PRE_DISBURSEMENT_BATCH.class, KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM); if (StringUtils.isEmpty(returnAddress)) { returnAddress = mailService.getBatchMailingList(); } message.setFromAddress(returnAddress); message.setSubject( getEmailSubject(PdpParameterConstants.PAYMENT_LOAD_SUCCESS_EMAIL_SUBJECT_PARAMETER_NAME)); List<String> ccAddresses = new ArrayList<String>(parameterService .getParameterValuesAsString(LoadPaymentsStep.class, PdpParameterConstants.HARD_EDIT_CC)); message.getCcAddresses().addAll(ccAddresses); message.getBccAddresses().addAll(ccAddresses); CustomerProfile customer = customerProfileService.get(paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit()); String toAddresses = StringUtils.deleteWhitespace(customer.getProcessingEmailAddr()); List<String> toAddressList = Arrays.asList(toAddresses.split(",")); message.getToAddresses().addAll(toAddressList); StringBuilder body = new StringBuilder(); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_LOADED) + "\n\n"); addPaymentFieldsToBody(body, paymentFile.getBatchId().intValue(), paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit(), paymentFile.getCreationDate(), paymentFile.getPaymentCount(), paymentFile.getPaymentTotalAmount()); body.append("\n" + getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_WARNING_MESSAGES) + "\n"); for (String warning : warnings) { body.append(warning + "\n\n"); } message.setMessage(body.toString()); // KFSMI-6475 - if not a production instance, replace the recipients with the testers list alterMessageWhenNonProductionInstance(message, null); try { mailService.sendMessage(message); } catch (Exception e) { LOG.error("sendErrorEmail() Invalid email address. Message not sent", e); } if (paymentFile.isFileThreshold()) { sendThresholdEmail(true, paymentFile, customer); } if (paymentFile.isDetailThreshold()) { sendThresholdEmail(false, paymentFile, customer); } }
From source file:org.kuali.kfs.pdp.service.impl.PdpEmailServiceImpl.java
/** * Sends email for a payment that was over the customer file threshold or the detail threshold * * @param fileThreshold indicates whether the file threshold (true) was violated or the detail threshold (false) * @param paymentFile parsed payment file object * @param customer payment customer//from w ww . ja v a2s .c o m */ protected void sendThresholdEmail(boolean fileThreshold, PaymentFileLoad paymentFile, CustomerProfile customer) { MailMessage message = new MailMessage(); String returnAddress = parameterService.getParameterValueAsString( KfsParameterConstants.PRE_DISBURSEMENT_BATCH.class, KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM); if (StringUtils.isEmpty(returnAddress)) { returnAddress = mailService.getBatchMailingList(); } message.setFromAddress(returnAddress); message.setSubject( getEmailSubject(PdpParameterConstants.PAYMENT_LOAD_THRESHOLD_EMAIL_SUBJECT_PARAMETER_NAME)); StringBuilder body = new StringBuilder(); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_LOADED) + "\n\n"); addPaymentFieldsToBody(body, paymentFile.getBatchId().intValue(), paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit(), paymentFile.getCreationDate(), paymentFile.getPaymentCount(), paymentFile.getPaymentTotalAmount()); if (fileThreshold) { String toAddresses = StringUtils.deleteWhitespace(customer.getFileThresholdEmailAddress()); List<String> toAddressList = Arrays.asList(toAddresses.split(",")); message.getToAddresses().addAll(toAddressList); body.append("\n" + getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_THRESHOLD, paymentFile.getPaymentTotalAmount(), customer.getFileThresholdAmount())); } else { String toAddresses = StringUtils.deleteWhitespace(customer.getPaymentThresholdEmailAddress()); List<String> toAddressList = Arrays.asList(toAddresses.split(",")); message.getToAddresses().addAll(toAddressList); body.append("\n" + getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_DETAIL_THRESHOLD, customer.getPaymentThresholdAmount()) + "\n\n"); for (PaymentDetail paymentDetail : paymentFile.getThresholdPaymentDetails()) { paymentDetail.refresh(); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_THRESHOLD, paymentDetail.getPaymentGroup().getPayeeName(), paymentDetail.getNetPaymentAmount()) + "\n"); } } List<String> ccAddresses = new ArrayList<String>(parameterService .getParameterValuesAsString(LoadPaymentsStep.class, PdpParameterConstants.HARD_EDIT_CC)); message.getCcAddresses().addAll(ccAddresses); message.getBccAddresses().addAll(ccAddresses); message.setMessage(body.toString()); // KFSMI-6475 - if not a production instance, replace the recipients with the testers list alterMessageWhenNonProductionInstance(message, null); try { mailService.sendMessage(message); } catch (Exception e) { LOG.error("sendErrorEmail() Invalid email address. Message not sent", e); } }
From source file:org.kuali.kfs.pdp.service.impl.PdpEmailServiceImpl.java
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendLoadEmail(org.kuali.kfs.pdp.businessobject.Batch) *///from w ww. ja va2s. c om @Override public void sendLoadEmail(Batch batch) { LOG.debug("sendLoadEmail() starting"); // check email configuration if (!isPaymentEmailEnabled()) { return; } MailMessage message = new MailMessage(); String returnAddress = parameterService.getParameterValueAsString( KfsParameterConstants.PRE_DISBURSEMENT_BATCH.class, KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM); if (StringUtils.isEmpty(returnAddress)) { returnAddress = mailService.getBatchMailingList(); } message.setFromAddress(returnAddress); message.setSubject( getEmailSubject(PdpParameterConstants.PAYMENT_LOAD_SUCCESS_EMAIL_SUBJECT_PARAMETER_NAME)); StringBuilder body = new StringBuilder(); List<String> ccAddresses = new ArrayList<String>(parameterService .getParameterValuesAsString(LoadPaymentsStep.class, PdpParameterConstants.HARD_EDIT_CC)); message.getCcAddresses().addAll(ccAddresses); message.getBccAddresses().addAll(ccAddresses); CustomerProfile customer = batch.getCustomerProfile(); String toAddresses = StringUtils.deleteWhitespace(customer.getProcessingEmailAddr()); List<String> toAddressList = Arrays.asList(toAddresses.split(",")); message.getToAddresses().addAll(toAddressList); body.append(getMessage(PdpKeyConstants.MESSAGE_PAYMENT_EMAIL_FILE_LOADED) + "\n\n"); addPaymentFieldsToBody(body, batch.getId().intValue(), customer.getChartCode(), customer.getUnitCode(), customer.getSubUnitCode(), batch.getCustomerFileCreateTimestamp(), batch.getPaymentCount().intValue(), batch.getPaymentTotalAmount()); message.setMessage(body.toString()); // KFSMI-6475 - if not a production instance, replace the recipients with the testers list alterMessageWhenNonProductionInstance(message, null); try { mailService.sendMessage(message); } catch (Exception e) { LOG.error("sendErrorEmail() Invalid email address. Message not sent", e); } }
From source file:org.kuali.kfs.sys.businessobject.AccountingLineParserBase.java
/** * Calls the appropriate parseAccountingLine method * // w w w.j a v a 2 s.co m * @param stream * @param transactionalDocument * @param isSource * @return List */ protected List<AccountingLine> importAccountingLines(String fileName, InputStream stream, AccountingDocument transactionalDocument, boolean isSource) { List<AccountingLine> importedAccountingLines = new ArrayList<AccountingLine>(); this.fileName = fileName; BufferedReader br = new BufferedReader(new InputStreamReader(stream)); try { String accountingLineAsString = null; lineNo = 0; while ((accountingLineAsString = br.readLine()) != null) { lineNo++; if (StringUtils.isBlank(StringUtils.remove(StringUtils.deleteWhitespace(accountingLineAsString), KFSConstants.COMMA))) { continue; } AccountingLine accountingLine = null; try { if (isSource) { accountingLine = parseSourceAccountingLine(transactionalDocument, accountingLineAsString); } else { accountingLine = parseTargetAccountingLine(transactionalDocument, accountingLineAsString); } validateImportedAccountingLine(accountingLine, accountingLineAsString); importedAccountingLines.add(accountingLine); } catch (AccountingLineParserException e) { GlobalVariables.getMessageMap().putError( (isSource ? "sourceAccountingLines" : "targetAccountingLines"), KFSKeyConstants.ERROR_ACCOUNTING_DOCUMENT_ACCOUNTING_LINE_IMPORT_GENERAL, new String[] { e.getMessage() }); } } } catch (IOException e) { throw new InfrastructureException("unable to readLine from bufferReader in accountingLineParserBase", e); } finally { try { br.close(); } catch (IOException e) { throw new InfrastructureException("unable to close bufferReader in accountingLineParserBase", e); } } return importedAccountingLines; }
From source file:org.kuali.kfs.sys.context.SchemaBuilder.java
/** * Performs logic to processes a validation place-holder for a line. First collects the configuration given in the * place-holder (general xsd type and data dictionary attribute). If use data dictionary validation is set to false, then the * place-holder will be set to the xsd type. If data dictionary validation is set to true, the general xsd type will be * removed, and the corresponding the data dictionary will be consulted to build the dd type * /*from w w w.j av a 2s. c om*/ * <pre> * ex. type="${xsd:token,dd:Chart.chartOfAccountsCode}" with useDataDictionaryValidation=false becomes type="xsd:token" * type="${xsd:token,dd:Chart.chartOfAccountsCode}" with useDataDictionaryValidation=true becomes type="dd:Chart.chartOfAccountsCode" and XML lines created for dd Types file * </pre> * * @param validationPlaceholder the parsed place-holder contents * @param buildLine the complete line being read * @param fileName the name for the file being processed * @param lineCount count for the line being read * @param useDataDictionaryValidation indicates whether data dictionary validation should be used, if false the general xsd * datatype in the place-holder will be used * @param typesSchemaLines collection of type XML lines to add to for any new types * @param builtTypes - Set of attribute names for which a schema validation type has been built * @return String the out XML line (which validation filled in) */ protected static String processValidationPlaceholder(String validationPlaceholder, String buildLine, String fileName, int lineCount, boolean useDataDictionaryValidation, Collection typesSchemaLines, Set<String> builtTypes, boolean rebuildDDTypes) { String orignalPlaceholderValue = validationPlaceholder; // remove whitespace validationPlaceholder = StringUtils.deleteWhitespace(validationPlaceholder); // get two parts of validation place-holder String[] validationParts = StringUtils.split(validationPlaceholder, ","); String xsdValidation = validationParts[0]; if (StringUtils.isBlank(xsdValidation) || !xsdValidation.startsWith(XSD_VALIDATION_PREFIX)) { logAndThrowException( String.format("File %s, line %s: specified xsd validation is invalid, must start with %s", fileName, lineCount, XSD_VALIDATION_PREFIX)); } String ddAttributeName = validationParts[1]; if (StringUtils.isBlank(ddAttributeName) || !ddAttributeName.startsWith(DD_VALIDATION_PREFIX)) { logAndThrowException( String.format("File %s, line %s: specified dd validation is invalid, must start with %s", fileName, lineCount, DD_VALIDATION_PREFIX)); } String outLine = buildLine; if (useDataDictionaryValidation) { if (LOG.isDebugEnabled()) { LOG.debug("Setting validation to use type: " + ddAttributeName); } outLine = StringUtils.replace(outLine, SCHEMA_FILE_DD_VALIDATION_PLACEHOLDER_BEGIN + orignalPlaceholderValue + SCHEMA_FILE_DD_VALIDATION_PLACEHOLDER_END, ddAttributeName); if (rebuildDDTypes) { buildDataDictionarySchemaValidationType(ddAttributeName, typesSchemaLines, builtTypes); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Setting validation to use type: " + xsdValidation); } outLine = StringUtils.replace(outLine, SCHEMA_FILE_DD_VALIDATION_PLACEHOLDER_BEGIN + orignalPlaceholderValue + SCHEMA_FILE_DD_VALIDATION_PLACEHOLDER_END, xsdValidation); } return outLine; }
From source file:org.kuali.kra.award.AwardCustomDataAuditRule.java
/** * This method gets global audit cluster and generates new error and adds to error list on audit cluster. * @param customAttributeDocument//www. ja va 2 s .com */ @SuppressWarnings("unchecked") private void getAuditClusterAndReportErrors(CustomAttributeDocument customAttributeDocument) { String key = "CustomData" + StringUtils.deleteWhitespace(customAttributeDocument.getCustomAttribute().getGroupName()) + "Errors"; AuditCluster auditCluster = (AuditCluster) GlobalVariables.getAuditErrorMap().get(key); if (auditCluster == null) { List<AuditError> auditErrors = new ArrayList<AuditError>(); auditCluster = new AuditCluster(customAttributeDocument.getCustomAttribute().getGroupName(), auditErrors, Constants.AUDIT_ERRORS); GlobalVariables.getAuditErrorMap().put(key, auditCluster); } List<AuditError> auditErrors = auditCluster.getAuditErrorList(); auditErrors.add( new AuditError("customAttributeValues(id" + customAttributeDocument.getCustomAttributeId() + ")", RiceKeyConstants.ERROR_REQUIRED, StringUtils.deleteWhitespace(Constants.CUSTOM_ATTRIBUTES_PAGE + "." + customAttributeDocument.getCustomAttribute().getGroupName()), new String[] { customAttributeDocument.getCustomAttribute().getLabel() })); }
From source file:org.kuali.kra.printing.service.impl.PrintingServiceImpl.java
public String getReportName() { String dateString = getDateTimeService().getCurrentDate().toString(); return StringUtils.deleteWhitespace(dateString); }
From source file:org.kuali.kra.printing.service.impl.PrintingServiceImpl.java
protected void logPrintDetails(Map<String, byte[]> xmlStreamMap) throws PrintingException { byte[] xmlBytes = null; String xmlString = null;/*ww w .jav a2 s . c o m*/ String loggingDirectory = kualiConfigurationService.getPropertyString(Constants.PRINT_LOGGING_DIRECTORY); Iterator<String> it = xmlStreamMap.keySet().iterator(); if (loggingDirectory != null) { try { while (it.hasNext()) { String key = (String) it.next(); xmlBytes = xmlStreamMap.get(key); xmlString = new String(xmlBytes); String dateString = getDateTimeService().getCurrentTimestamp().toString(); String reportName = StringUtils.deleteWhitespace(key); String createdTime = StringUtils.replaceChars(StringUtils.deleteWhitespace(dateString), ":", "_"); File file = new File(loggingDirectory + reportName + createdTime + ".xml"); BufferedWriter out = new BufferedWriter(new FileWriter(file)); out.write(xmlString); out.close(); } } catch (IOException e) { LOG.error(e.getMessage(), e); throw new PrintingException(e.getMessage(), e); } } }