List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:gate.corpora.DataSiftFormat.java
@Override public void unpackMarkup(gate.Document doc) throws DocumentFormatException { if ((doc == null) || (doc.getSourceUrl() == null && doc.getContent() == null)) { throw new DocumentFormatException("GATE document is null or no content found. Nothing to parse!"); }// w w w.j av a 2 s .com setNewLineProperty(doc); String jsonString = StringUtils.trimToEmpty(doc.getContent().toString()); // TODO build the new content StringBuilder concatenation = new StringBuilder(); try { ObjectMapper om = new ObjectMapper(); JsonFactory factory = new JsonFactory(om); JsonParser parser = factory.createParser(jsonString); Map<DataSift, Long> offsets = new HashMap<DataSift, Long>(); Iterator<DataSift> it = parser.readValuesAs(DataSift.class); while (it.hasNext()) { DataSift ds = it.next(); offsets.put(ds, (long) concatenation.length()); concatenation.append(ds.getInteraction().getContent()).append("\n\n"); } // Set new document content DocumentContent newContent = new DocumentContentImpl(concatenation.toString()); doc.edit(0L, doc.getContent().size(), newContent); AnnotationSet originalMarkups = doc.getAnnotations("Original markups"); for (Map.Entry<DataSift, Long> item : offsets.entrySet()) { DataSift ds = item.getKey(); Interaction interaction = ds.getInteraction(); Long start = item.getValue(); FeatureMap features = interaction.asFeatureMap(); features.putAll(ds.getFurtherData()); originalMarkups.add(start, start + interaction.getContent().length(), "Interaction", features); } } catch (InvalidOffsetException | IOException e) { throw new DocumentFormatException(e); } }
From source file:eionet.meta.scheduled.AbstractScheduledJob.java
@Override public void contextInitialized(ServletContextEvent sce) { Class<? extends AbstractScheduledJob> clazz = this.getClass(); JobBuilder jobBuilder = JobBuilder.newJob(clazz); jobBuilder.withIdentity(clazz.getSimpleName(), clazz.getName()); JobDetail jobDetails = jobBuilder.build(); String jobData = Props.getProperty(getDataPropName()); jobData = StringUtils.trimToEmpty(jobData); if (StringUtils.isNotBlank(jobData)) { parseJobData(jobDetails, jobData); }/* w w w .j a v a 2 s .c om*/ String propName = getSchedulePropName(); String intervalPrpValue = Props.getProperty(propName); try { if (CronExpression.isValidExpression(intervalPrpValue)) { DDJobScheduler.scheduleCronJob(intervalPrpValue, jobDetails); LOGGER.info(getName() + " job started crontab " + intervalPrpValue); } else { long interval = Props.getTimePropertyMilliseconds(propName, DDJobScheduler.DEFAULT_SCHEDULE_INTERVAL); DDJobScheduler.scheduleIntervalJob(interval, jobDetails); LOGGER.info(getName() + " job started with interval " + interval + " ms"); } } catch (Exception e) { LOGGER.error("Failed to initialize job: " + getName() + ": \n" + e); } }
From source file:hudson.plugins.sonar.model.LightProjectConfig.java
public String getJavaVersion() { return StringUtils.trimToEmpty(javaVersion); }
From source file:com.edgenius.core.service.impl.JavaMailSenderImpl.java
/** * mailProperties changed, this method will reload mail session *//*from w ww . j av a2 s . co m*/ public void resetMailSessionByProperties() { //always reset session to null, so make "reset" meaningful. This is also a trick, as setSession() doesn't allow null //however, this.setJavaMailProperties(prop) will reset Session to null internally... this.setJavaMailProperties(new Properties()); //multiple properties separated by ";;" and, each property separated by ":" with name and value pair String[] properties = mailProperties.split(";;"); int sep; for (String property : properties) { sep = StringUtils.indexOf(property, ":"); if (sep < 0) { continue; } String name = StringUtils.trimToEmpty(property.substring(0, sep)); String value = StringUtils.trimToEmpty(property.substring(sep + 1)); Properties prop = new Properties(); if (!"".equals(name)) { prop.setProperty(name, value); } //this method will reset session to null as well this.setJavaMailProperties(prop); } }
From source file:com.hangum.tadpole.engine.utils.MakeJDBCConnectionStringUtil.java
private static String getPueURL(String strTempURL, final UserDBDAO userDB) { return String.format(strTempURL, StringUtils.trimToEmpty(userDB.getHost()), StringUtils.trimToEmpty(userDB.getPort()), StringUtils.trimToEmpty(userDB.getDb())); }
From source file:com.egt.core.db.util.SqlAgent.java
private static SqlAgentMessage executeProcedure(String procedimiento, Long rastro, Object[] args, boolean logging) { Bitacora.trace(SqlAgent.class, "executeProcedure", procedimiento, rastro); Utils.traceObjectArray(args);/* ww w . j a va2 s . c o m*/ String procedure = StringUtils.trimToEmpty(procedimiento); // String archivo = logging ? getLogFileName(rastro) : null; String archivo = null; EnumCondicionEjeFun condicion = EnumCondicionEjeFun.EJECUCION_EN_PROGRESO; String mensaje = TLC.getBitacora().info(CBM2.PROCESS_EXECUTION_BEGIN, procedure); boolean ok = Auditor.grabarRastroProceso(rastro, condicion, archivo, mensaje); if (ok) { try { // <editor-fold defaultstate="collapsed"> // Object resultado = TLC.getAgenteSql().executeProcedure(procedure, args); // if (resultado == null) { // condicion = EnumCondicionEjeFun.EJECUTADO_CON_ERRORES; // mensaje = TLC.getBitacora().error(CBM2.PROCESS_EXECUTION_ABEND, procedure); // } else { // condicion = EnumCondicionEjeFun.EJECUTADO_SIN_ERRORES; // if (resultado instanceof Number) { // mensaje = TLC.getBitacora().info(procedure + " = " + resultado); // } else if (resultado instanceof ResultSet) { // ResultSet resultSet = (ResultSet) resultado; // if (resultSet.next()) { // mensaje = TLC.getBitacora().info(procedure + " = " + resultSet.getObject(1)); // } else { // mensaje = TLC.getBitacora().info(procedure + " = " + STP.STRING_VALOR_NULO); // } // } else { // mensaje = TLC.getBitacora().warn(CBM2.PROCESS_EXECUTION_END, procedure); // } // } // </editor-fold> Object resultado = TLC.getAgenteSql().executeProcedure(procedure, args); if (resultado == null) { condicion = EnumCondicionEjeFun.EJECUTADO_CON_ERRORES; mensaje = TLC.getBitacora().error(CBM2.PROCESS_EXECUTION_ABEND, procedure); } else { condicion = EnumCondicionEjeFun.EJECUTADO_SIN_ERRORES; mensaje = TLC.getBitacora().info(CBM2.PROCESS_EXECUTION_END, procedure); if (resultado instanceof ResultSet) { ResultSet resultSet = (ResultSet) resultado; if (resultSet.next()) { mensaje += " (" + resultSet.getObject(1) + ") "; } } else if (resultado.getClass().isPrimitive()) { mensaje += " (" + resultado + ") "; } } } catch (Exception ex) { condicion = EnumCondicionEjeFun.EJECUTADO_CON_ERRORES; mensaje = ThrowableUtils.getString(ex); TLC.getBitacora().fatal(ex); TLC.getBitacora().fatal(CBM2.PROCESS_EXECUTION_ABEND, procedure); } finally { Auditor.grabarRastroProceso(rastro, condicion, archivo, mensaje); // DB.close(resultSet); } } else { condicion = EnumCondicionEjeFun.EJECUCION_CANCELADA; mensaje = TLC.getBitacora().error(CBM2.PROCESS_EXECUTION_ABEND, procedure); } SqlAgentMessage message = new SqlAgentMessage(procedure); message.setArgs(args); message.setRastro(rastro); message.setCondicion(condicion); message.setArchivo(archivo); message.setMensaje(mensaje); return message; }
From source file:hudson.plugins.sonar.model.LightProjectConfig.java
public String getProjectSrcDir() { return StringUtils.trimToEmpty(projectSrcDir); }
From source file:com.hangum.tadpole.application.start.dialog.login.FindPasswordDialog.java
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEmail.getText()); logger.info("Find password dialog" + strEmail); if (!checkValidation()) { MessageDialog.openWarning(getShell(), Messages.get().Confirm, Messages.get().FindPasswordDialog_6); textEmail.setFocus();/*from www. j av a 2 s.co m*/ return; } UserDAO userDao = new UserDAO(); userDao.setEmail(strEmail); String strTmpPassword = Utils.getUniqueDigit(12); userDao.setPasswd(strTmpPassword); try { TadpoleSystem_UserQuery.updateUserPasswordWithID(userDao); sendEmailAccessKey(strEmail, strTmpPassword); MessageDialog.openInformation(getShell(), Messages.get().Confirm, Messages.get().SendMsg); } catch (Exception e) { logger.error("password initialize and send email ", e); MessageDialog.openError(getShell(), Messages.get().Error, String.format(Messages.get().SendMsgErr, GetAdminPreference.getSMTPINFO().getEmail(), e.getMessage())); } super.okPressed(); }
From source file:com.metasoft.claim.service.impl.report.BillingServiceImpl.java
@Override public BillingSearchResultVoPaging searchPaging(String paramCloseDateStart, String paramCloseDateEnd, String paramPartyInsuranceId, String paramClaimTypeId, int start, int length) { Date closeDateStart = null;/*from w w w. j a va 2s. c om*/ Date closeDateEnd = null; StdInsurance partyInsurance = null; ClaimType claimType = null; if (StringUtils.isNotBlank(paramCloseDateStart)) { closeDateStart = DateToolsUtil.convertStringToDate(paramCloseDateStart, DateToolsUtil.LOCALE_TH); } if (StringUtils.isNotBlank(paramCloseDateEnd)) { closeDateEnd = DateToolsUtil.convertStringToDate(paramCloseDateEnd, DateToolsUtil.LOCALE_TH); } if (StringUtils.isNotBlank(paramPartyInsuranceId)) { partyInsurance = insuranceService.findById(Integer.parseInt(paramPartyInsuranceId)); } if (StringUtils.isNotBlank(paramClaimTypeId)) { claimType = ClaimType.getById(Integer.parseInt(paramClaimTypeId)); } ClaimPaging paging = claimDao.searchBillingPaging(closeDateStart, closeDateEnd, partyInsurance, claimType, start, length); BillingSearchResultVoPaging voPaging = new BillingSearchResultVoPaging(); voPaging.setDraw(paging.getDraw()); voPaging.setRecordsFiltered(paging.getRecordsFiltered()); voPaging.setRecordsTotal(paging.getRecordsTotal()); voPaging.setData(new ArrayList<BillingSearchResultVo>()); if (paging != null && paging.getData() != null) { for (TblClaimRecovery claim : paging.getData()) { BillingSearchResultVo vo = new BillingSearchResultVo(); if (claim.getCloseDate() != null) { vo.setCloseDate(DateToolsUtil.convertToString(claim.getCloseDate(), DateToolsUtil.LOCALE_TH)); } vo.setJobNo(StringUtils.trimToEmpty(claim.getJobNo())); vo.setClaimNumber(StringUtils.trimToEmpty(claim.getClaimNumber())); vo.setLicenseNumber(StringUtils.trimToEmpty(claim.getLicenseNumber())); if (claim.getClaimType() != null) { vo.setClaimType(claim.getClaimType().getName()); } if (claim.getPartyInsurance() != null) { vo.setInsuranceName(claim.getPartyInsurance().getName()); } if (claim.getLicenseNumber() != null) { vo.setLicenseNumber(claim.getLicenseNumber()); } if (ClaimType.FAST_TRACK.equals(claim.getClaimType())) { vo.setWage("300"); } else if (ClaimType.KFK.equals(claim.getClaimType())) { vo.setWage("300"); } else if (ClaimType.REQUEST.equals(claim.getClaimType())) { vo.setWage("300"); } vo.setClaimId(claim.getId().toString()); voPaging.getData().add(vo); } } return voPaging; }
From source file:com.bluexml.xforms.actions.AbstractWorkflowAction.java
@Override public void submit() throws ServletException { if (controller.isInStandaloneMode()) { String msg = "The Alfresco Controller is in standalone mode. Some actions are unavailable"; navigationPath.setStatusMsg(msg); throw new ServletException(msg); }/* ww w. j a va 2 s. com*/ Page currentPage = navigationPath.peekCurrentPage(); // do the work TransitionResultBean resultBean = submitWork(); // redirect the client to the appropriate next page String msg = navigationPath.getStatusMsg(); String URLsuffix = MsgId.PARAM_STATUS_MSG + "=" + StringUtils.trimToEmpty(msg); if (resultBean.isSuccess()) { redirectSuccess(currentPage, resultBean, URLsuffix); } else { redirectFailure(currentPage, URLsuffix); } }