Java Code Examples for org.apache.commons.lang.StringUtils#deleteWhitespace()
The following examples show how to use
org.apache.commons.lang.StringUtils#deleteWhitespace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IpRangeSet.java From zstack with Apache License 2.0 | 6 votes |
public static IpRangeSet generateIpRangeSet(String word) { word = StringUtils.deleteWhitespace(word); String[] sets = word.split(IP_SET_SEPARATOR); IpRangeSet contain = new IpRangeSet(); IpRangeSet exclude = new IpRangeSet(); for (String set : sets) { if (set.startsWith(IP_SET_INVERT_PREFIX)) { exclude.closed(set.substring(1)); } else { contain.closed(set); } } contain.remove(exclude); return contain; }
Example 2
Source File: CreditCardDataXmlInputFileType.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String) */ @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(); }
Example 3
Source File: PerDiemTxtInputFileType.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String) */ @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(); }
Example 4
Source File: PerDiemXmlInputFileType.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String) */ @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(); }
Example 5
Source File: AgencyDataXmlInputFileType.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.sys.batch.BatchInputFileType#getFileName(java.lang.String, java.lang.Object, java.lang.String) */ @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(); }
Example 6
Source File: AssetBarcodeInventoryInputFileType.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns done file name for a specific user and file user identifier * * @param user the user who uploaded or will upload the file * @param fileUserIdentifier the file identifier * @return String done file name * * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getDoneFileName(org.kuali.rice.kim.api.identity.Person, java.lang.String) */ public String getDoneFileName(Person user, String fileUserIdentifer, Date creationDate) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); StringBuilder buf = new StringBuilder(); fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer); fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER); buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()) .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer) .append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)) .append(getDoneFileExtension()); return buf.toString(); }
Example 7
Source File: ZEnchantment.java From XSeries with MIT License | 5 votes |
/** * Gets an enchantment from Vanilla and bukkit names. * There are also some aliases available. * * @param enchant the name of the enchantment. * @return an enchantment. * @since 1.0.0 */ @Nullable public static Optional<Enchantment> getByName(@Nonnull String enchant) { Validate.notEmpty(enchant, "Enchantment name cannot be null or empty"); Enchantment enchantment = null; enchant = StringUtils.deleteWhitespace(StringUtils.lowerCase(enchant, Locale.ENGLISH)); if (ISFLAT) enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchant)); // 1.13+ only if (enchantment == null) enchantment = Enchantment.getByName(enchant); if (enchantment == null) enchantment = ENCHANTMENTS.get(enchant); if (enchantment == null) enchantment = ALIASENCHANTMENTS.get(enchant); return Optional.ofNullable(enchantment); }
Example 8
Source File: AssetBarcodeInventoryInputFileType.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Return the file name based on information from user and file user identifier * * @param user Person object representing user who uploaded file * @param fileUserIdentifer String representing user who uploaded file * @return String enterprise feeder formated file name string using information from user and file user identifier * * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getFileName(java.lang.String, org.kuali.rice.kim.api.identity.Person, java.lang.String) */ public String getFileName(String fileType, String principalName, String fileUserIdentifer, Date creationDate) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); StringBuilder buf = new StringBuilder(); fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer); fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER); buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(principalName) .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer) .append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)) .append(getFileExtension(fileType)); return buf.toString(); }
Example 9
Source File: EnterpriseFeederFileSetType.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns done file name for a specific user and file user identifier * * @param user the user who uploaded or will upload the file * @param fileUserIdentifier the file identifier * @return String done file name * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getDoneFileName(org.kuali.rice.kim.api.identity.Person, java.lang.String) */ public String getDoneFileName(Person user, String fileUserIdentifer, Date creationDate) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); StringBuilder buf = new StringBuilder(); fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer); fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER); buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()) .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer) .append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)) .append(getDoneFileExtension()); return buf.toString(); }
Example 10
Source File: EnterpriseFeederFileSetType.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Return the file name based on information from user and file user identifier * * @param user Person object representing user who uploaded file * @param fileUserIdentifer String representing user who uploaded file * @return String enterprise feeder formated file name string using information from user and file user identifier * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getFileName(java.lang.String, org.kuali.rice.kim.api.identity.Person, * java.lang.String) */ public String getFileName(String fileType, String principalName, String fileUserIdentifer, Date creationDate) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); StringBuilder buf = new StringBuilder(); fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer); fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER); buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(principalName) .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer) .append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)) .append(getFileExtension(fileType)); return buf.toString(); }
Example 11
Source File: RangerValidityScheduleValidator.java From ranger with Apache License 2.0 | 5 votes |
private String getNormalizedValue(RangerValidityRecurrence recurrence, RangerValidityRecurrence.RecurrenceSchedule.ScheduleFieldSpec field) { String ret = null; if (RangerValidityRecurrence.ValidityInterval.getValidityIntervalInMinutes(recurrence.getInterval()) > 0) { String noWhiteSpace = StringUtils.deleteWhitespace(recurrence.getSchedule().getFieldValue(field)); String[] specs = StringUtils.split(noWhiteSpace, ","); List<String> values = new ArrayList<>(); for (String spec : specs) { if (StringUtils.isNotBlank(spec)) { values.add(spec); } } if (values.size() > 0) { Collections.sort(values); StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.size(); i++) { if (i != 0) { sb.append(","); } sb.append(values.get(i)); } ret = sb.toString(); } } return ret; }
Example 12
Source File: BPELDeployer.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public void initialize(List<Parameter> parameterList) throws WorkflowImplException { if (!validateParams(parameterList)) { throw new WorkflowRuntimeException("Workflow initialization failed, required parameter is missing"); } Parameter wfNameParameter = WorkflowManagementUtil .getParameter(parameterList, WFConstant.ParameterName.WORKFLOW_NAME, WFConstant.ParameterHolder .WORKFLOW_IMPL); if (wfNameParameter != null) { processName = StringUtils.deleteWhitespace(wfNameParameter.getParamValue()); role = WorkflowManagementUtil .createWorkflowRoleName(StringUtils.deleteWhitespace(wfNameParameter.getParamValue())); } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if(!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)){ tenantContext = "t/" + tenantDomain + "/"; } Parameter bpsProfileParameter = WorkflowManagementUtil .getParameter(parameterList, WFImplConstant.ParameterName.BPS_PROFILE, WFConstant.ParameterHolder .WORKFLOW_IMPL); if (bpsProfileParameter != null) { String bpsProfileName = bpsProfileParameter.getParamValue(); bpsProfile = WorkflowImplServiceDataHolder.getInstance().getWorkflowImplService().getBPSProfile (bpsProfileName, tenantId); } htName = processName + BPELDeployer.Constants.HT_SUFFIX; generateAndDeployArtifacts(); }
Example 13
Source File: QueryManagerImpl.java From cosmic with Apache License 2.0 | 5 votes |
public ListResponse<WhoHasThisAddressResponse> listWhoHasThisMac(final ListWhoHasThisMacCmd cmd) { final ListResponse<WhoHasThisAddressResponse> whoHasThisIpList = new ListResponse<>(); final List<WhoHasThisAddressResponse> responsesList = new ArrayList<>(); final String cleanedMacAddress = StringUtils.deleteWhitespace(cmd.getMacAddress()); final List<NicVO> nics = _nicDao.listByMacAddress(cleanedMacAddress); nics.forEach(nic -> { final WhoHasThisAddressResponse response = new WhoHasThisAddressResponse(); response.setObjectName("whohasthismac"); queryNicsTableResponse(responsesList, nic, response); }); final Account account = CallContext.current().getCallingAccount(); final Domain domain = _domainDao.findById(account.getDomainId()); final List<WhoHasThisAddressResponse> filteredResponsesList = responsesList.stream().filter( response -> ( (account.getDomainId() == Domain.ROOT_DOMAIN || domain.getUuid().equals(response.getDomainUuid())) && (StringUtils.isEmpty(cmd.getUuid()) || (!StringUtils.isEmpty(cmd.getUuid()) && response.getUuid().equals(cmd.getUuid()))) ) ).skip(cmd.getStartIndex()).limit(cmd.getPageSizeVal()).collect(Collectors.toList()); whoHasThisIpList.setResponses(filteredResponsesList); return whoHasThisIpList; }
Example 14
Source File: PickDto.java From ApiManager with GNU Affero General Public License v3.0 | 5 votes |
private String handleId(String id) { if (id == null){ id = System.currentTimeMillis() + Tools.getChar(10); } id = id.replaceAll("\\.", "_"); id = StringUtils.deleteWhitespace(id); return id; }
Example 15
Source File: RequestExecutor.java From carbon-identity with Apache License 2.0 | 4 votes |
private void callService(OMElement messagePayload) throws AxisFault { ServiceClient client = new ServiceClient(WorkflowImplServiceDataHolder.getInstance() .getConfigurationContextService() .getClientConfigContext(), null); Options options = new Options(); options.setAction(WFImplConstant.DEFAULT_APPROVAL_BPEL_SOAP_ACTION); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String host = bpsProfile.getWorkerHostURL(); String serviceName = StringUtils.deleteWhitespace(WorkflowManagementUtil .getParameter(parameterList, WFConstant .ParameterName.WORKFLOW_NAME, WFConstant .ParameterHolder.WORKFLOW_IMPL) .getParamValue()); serviceName = StringUtils.deleteWhitespace(serviceName); if (host.endsWith("/")) { host = host.substring(0,host.lastIndexOf("/")); } String endpoint; if (tenantDomain != null && !tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { endpoint = host + "/t/" + tenantDomain + "/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX; } else { endpoint = host + "/" + serviceName + WFConstant.TemplateConstants.SERVICE_SUFFIX; } options.setTo(new EndpointReference(endpoint)); options.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, SOAP11Constants .SOAP_11_CONTENT_TYPE); HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); auth.setUsername(bpsProfile.getUsername()); auth.setPassword(String.valueOf(bpsProfile.getPassword())); auth.setPreemptiveAuthentication(true); List<String> authSchemes = new ArrayList<>(); authSchemes.add(HttpTransportProperties.Authenticator.BASIC); auth.setAuthSchemes(authSchemes); options.setProperty(HTTPConstants.AUTHENTICATE, auth); options.setManageSession(true); client.setOptions(options); client.fireAndForget(messagePayload); }
Example 16
Source File: PdpEmailServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendErrorEmail(org.kuali.kfs.pdp.businessobject.PaymentFileLoad, * org.kuali.rice.kns.util.ErrorMap) */ @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); } } }
Example 17
Source File: PdpEmailServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendLoadEmail(org.kuali.kfs.pdp.businessobject.PaymentFileLoad, * java.util.List) */ @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); } }
Example 18
Source File: PdpEmailServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * @see org.kuali.kfs.pdp.service.PdpEmailService#sendLoadEmail(org.kuali.kfs.pdp.businessobject.Batch) */ @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); } }
Example 19
Source File: ConfigCenterClient.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
public void doWatch(String configCenter) throws UnsupportedEncodingException, InterruptedException { CountDownLatch waiter = new CountDownLatch(1); IpPort ipPort = NetUtils.parseIpPortFromURI(configCenter); String url = uriConst.REFRESH_ITEMS + "?dimensionsInfo=" + StringUtils.deleteWhitespace(URLEncoder.encode(serviceName, "UTF-8")); Map<String, String> headers = new HashMap<>(); headers.put("x-domain-name", tenantName); if (ConfigCenterConfig.INSTANCE.getToken() != null) { headers.put("X-Auth-Token", ConfigCenterConfig.INSTANCE.getToken()); } headers.put("x-environment", environment); HttpClientWithContext vertxHttpClient = HttpClients.getClient(ConfigCenterHttpClientOptionsSPI.CLIENT_NAME); vertxHttpClient.runOnContext(client -> { Map<String, String> authHeaders = new HashMap<>(); authHeaderProviders.forEach(provider -> authHeaders.putAll(provider.getSignAuthHeaders( createSignRequest(null, configCenter + url, headers, null)))); WebSocketConnectOptions options = new WebSocketConnectOptions(); options.setHost(ipPort.getHostOrIp()).setPort(refreshPort).setURI(url) .setHeaders(new CaseInsensitiveHeaders().addAll(headers) .addAll(authHeaders)); client.webSocket(options, asyncResult -> { if (asyncResult.failed()) { LOGGER.error( "watcher connect to config center {} refresh port {} failed. Error message is [{}]", configCenter, refreshPort, asyncResult.cause().getMessage()); waiter.countDown(); } else { { asyncResult.result().exceptionHandler(e -> { LOGGER.error("watch config read fail", e); stopHeartBeatThread(); isWatching = false; }); asyncResult.result().closeHandler(v -> { LOGGER.warn("watching config connection is closed accidentally"); stopHeartBeatThread(); isWatching = false; }); asyncResult.result().pongHandler(pong -> { // ignore, just prevent NPE. }); asyncResult.result().frameHandler(frame -> { Buffer action = frame.binaryData(); LOGGER.info("watching config recieved {}", action); Map<String, Object> mAction = action.toJsonObject().getMap(); if ("CREATE".equals(mAction.get("action"))) { //event loop can not be blocked,we just keep nothing changed in push mode refreshConfig(configCenter, false); } else if ("MEMBER_CHANGE".equals(mAction.get("action"))) { refreshMembers(memberdis); } else { parseConfigUtils.refreshConfigItemsIncremental(mAction); } }); startHeartBeatThread(asyncResult.result()); isWatching = true; waiter.countDown(); } } }); }); waiter.await(); }