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:com.bluexml.xforms.actions.WorkflowTransitionAction.java
/** * Worker function./* w w w . ja v a 2 s .c o m*/ * * @return false if exception or can't do the transition. Otherwise true. * @throws ServletException */ protected TransitionResultBean submitWork() throws ServletException { TransitionResultBean resultBean = new TransitionResultBean(); HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>(); currentPage = navigationPath.peekCurrentPage(); // check the transition although should never throw up... normally. String transitionToTake = requestParameters.get(TRANSITION_NAME); if (StringUtils.trimToEmpty(transitionToTake).equals(StringUtils.EMPTY)) { throw new RuntimeException("XForms WorkflowTransitionAction: no transition name given."); } // collect info for use later String wkFormName = currentPage.getFormName(); WorkflowTaskInfoBean taskBean = controller.getWorkflowTaskInfoBean(wkFormName); userName = getCurrentUserName(); transaction.setLogin(userName); // get process id; try url params first. String candidateId = currentPage.getInitParams().get(MsgId.PARAM_WORKFLOW_PROCESS_ID.getText()); String processId = findProcessId(candidateId, wkFormName); if (processId == null) { navigationPath.setStatusMsg("Could not find the process Id. Giving up."); return resultBean; } collectTaskProperties(properties, node, taskBean, processId); // check that the user is authorized. Already done for the initial task so don't redo. if (/* * (controller.isStartTaskForm(wkFormName) == false) * && */(validateCurrentUser(taskBean, properties) == false)) { navigationPath.setStatusMsg(MsgPool.getMsg(MsgId.MSG_STATUS_WKFLW_FAIL_INITIATOR)); if (logger.isErrorEnabled()) { logger.error(MsgPool.getMsg(MsgId.MSG_STATUS_WKFLW_FAIL_INITIATOR)); } return resultBean; } // add properties from the form fields String formTaskName = controller.getWorkflowBlueXMLTaskName(wkFormName); // no need to continue if in standalone mode if (controller.isInStandaloneMode()) { navigationPath.setStatusMsg( "The Alfresco Controller is in standalone mode. Workflow actions are not available."); return resultBean; } // check that there's some repository content to associate with the workflow package // # 1299: try to save the data form. In case of initial task, this will provide a data id. // In all cases, currentPage.getDataId() returns a valid id. Certified :-) String dataForm = controller.getUnderlyingDataFormForWorkflow(wkFormName); if (dataForm != null) { // #1284 SubmitAction action = new SubmitAction(); action.setProperties(controller, uri); action.setSubmitProperties(this.result, submission, node, NavigationSessionListener.getServletURL(action.getSessionId())); try { action.submit(); } catch (Exception e) { navigationPath.setStatusMsg("Could not save the data form."); if (logger.isErrorEnabled()) { logger.error("Auto-save at workflow: error when saving the data form.", e); } return resultBean; } } // launch a workflow if on a start task form - also set the instance id if (initializeTask(wkFormName, taskBean, properties, processId) == false) { return resultBean; } // there's no point in continuing without a workflow instance Id String wkflwInstanceId = currentPage.getWkflwInstanceId(); if (StringUtils.trimToNull(wkflwInstanceId) == null) { navigationPath.setStatusMsg("Transition not followed. No workflow instance id is available."); return resultBean; } // check that an active task for the workflow instance is consistent with the current form logger.debug("Getting the current tasks for workflow instance with id: " + wkflwInstanceId); List<String> tasks = controller.workflowGetCurrentTasksInfo(transaction, wkflwInstanceId); if (tasks.size() == 0) { navigationPath.setStatusMsg( "Transition not followed. No tasks were found for instance id '" + wkflwInstanceId + "'."); return resultBean; } logger.debug("Finding the relevant tasks for form " + formTaskName + " amongst tasks '" + tasks + "'"); String taskInfoString = findRelevantTaskForForm(formTaskName, tasks); if (taskInfoString == null) { navigationPath.setStatusMsg("Transition not followed. The form '" + wkFormName + "' is not consistent with the current task(s) on the workflow instance."); return resultBean; } // save the task's current state logger.debug("Updating task " + taskInfoString); String taskId = getIdFromTaskIdNameTitle(taskInfoString); if (controller.workflowUpdateTask(transaction, taskId, properties) == false) { navigationPath.setStatusMsg("Transition not followed. Failed while updating the task."); return resultBean; } // trigger the transition whose button was clicked logger.debug("Ending task " + taskId + " with transition " + transitionToTake); if (controller.workflowEndTask(transaction, taskId, transitionToTake) == false) { navigationPath.setStatusMsg("Transition not followed. Failed while ending the task."); return resultBean; } // set assignment for next task(s) if any logger.debug("Reassigning workflow " + wkflwInstanceId); return reassignWorkflow(transaction, properties); }
From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.SQLToStringDialog.java
private void sqlToStr() { StringBuffer sbStr = new StringBuffer(); String[] sqls = parseSQL();//from w w w. j av a 2 s. co m SQLToLanguageConvert slt = new SQLToLanguageConvert(userDB, (EditorDefine.SQL_TO_APPLICATION) comboLanguageType.getData(comboLanguageType.getText())); String variable = textVariable.getText(); if (StringUtils.isEmpty(variable)) { variable = slt.getDefaultVariable(); textVariable.setText(variable); } for (int i = 0; i < sqls.length; i++) { if ("".equals(StringUtils.trimToEmpty(sqls[i]))) //$NON-NLS-1$ continue; if (i == 0) sbStr.append(slt.sqlToString(variable, sqls[i])); else sbStr.append(slt.sqlToString(variable + i, sqls[i])); // ? . sbStr.append("\r\n"); //$NON-NLS-1$ } textConvert.setText(sbStr.toString()); }
From source file:com.prowidesoftware.swift.model.field.Field257.java
/** * Serializes the fields' components into the single string value (SWIFT format) *///from ww w . j a va2s. c o m @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); result.append(StringUtils.trimToEmpty(getComponent2())); result.append(StringUtils.trimToEmpty(getComponent3())); result.append(StringUtils.trimToEmpty(getComponent4())); if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent5())) { result.append(StringUtils.trimToEmpty(getComponent5())); } return result.toString(); }
From source file:com.prowidesoftware.swift.model.field.Field29G.java
/** * Serializes the fields' components into the single string value (SWIFT format) *//*w ww . ja v a 2 s.c o m*/ @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(StringUtils.trimToEmpty(getComponent1())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent2())); if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent3())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent4())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent5()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent6())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent5())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent6())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent7()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent8())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent7())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent8())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent9()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent10())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent9())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent10())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent11()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent12())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent11())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent12())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent13()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent14())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent13())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent14())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent15()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent16())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent15())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent16())); } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent17()) || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent18())) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); result.append(StringUtils.trimToEmpty(getComponent17())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent18())); } return result.toString(); }
From source file:com.prowidesoftware.swift.model.field.Field92J.java
/** * Serializes the fields' components into the single string value (SWIFT format) */// w w w.jav a 2s. c o m @Override public String getValue() { final StringBuilder result = new StringBuilder(); result.append(":"); result.append(StringUtils.trimToEmpty(getComponent1())); result.append("/"); if (StringUtils.isNotEmpty(getComponent2())) { result.append(StringUtils.trimToEmpty(getComponent2())); } result.append("/"); result.append(StringUtils.trimToEmpty(getComponent3())); result.append("/"); result.append(StringUtils.trimToEmpty(getComponent4())); result.append(StringUtils.trimToEmpty(getComponent5())); if (StringUtils.isNotEmpty(getComponent6())) { result.append("/"); result.append(StringUtils.trimToEmpty(getComponent6())); } return result.toString(); }
From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java
@Override public String getMessage(String message, String onTime, String offTime) { if (StringUtils.isBlank(message)) { return message; }/*from ww w. j av a2 s . c o m*/ message = StringUtils.trimToEmpty(message); boolean allowHTML = false; if (StringUtils.startsWith(message, "html:")) { allowHTML = true; message = StringUtils.removeStart(message, "html:"); } if (onTime != null) { message = StringUtils.replace(message, "{{ onTime }}", onTime); } if (offTime != null) { message = StringUtils.replace(message, "{{ offTime }}", offTime); } if (!allowHTML) { message = message.replaceAll("(\r\n|\n)", "<br />"); } return message; }
From source file:com.iyonger.apm.web.configuration.Config.java
/** * Get the ngrinder instance IPs consisting of the current cluster from the configuration. * * @return ngrinder instance IPs/*from www . jav a 2 s. c o m*/ */ public String[] getClusterURIs() { String clusterUri = getClusterProperties().getProperty(PROP_CLUSTER_MEMBERS); return StringUtils.split(StringUtils.trimToEmpty(clusterUri), ",;"); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopDateField.java
@Override public void setDateFormat(String dateFormat) { dateTimeFormat = dateFormat;/*from ww w . j a va2 s.c o m*/ StringBuilder date = new StringBuilder(dateFormat); StringBuilder time = new StringBuilder(dateFormat); int timeStartPos = findTimeStartPos(dateFormat); if (timeStartPos >= 0) { time.delete(0, timeStartPos); timeFormat = StringUtils.trimToEmpty(time.toString()); timeField.setFormat(timeFormat); _setResolution(resolution); date.delete(timeStartPos, dateFormat.length()); } else if (resolution.ordinal() < Resolution.DAY.ordinal()) { _setResolution(Resolution.DAY); } this.dateFormat = StringUtils.trimToEmpty(date.toString()); datePicker.setFormats(this.dateFormat); updateLayout(); }
From source file:com.prowidesoftware.swift.model.field.Field42A.java
/** * Serializes the fields' components into the single string value (SWIFT format) *//*from www . j ava 2s. c o m*/ @Override public String getValue() { final StringBuilder result = new StringBuilder(); boolean wroteSomething = false; if (getComponent1() != null) { result.append("/" + StringUtils.trimToEmpty(getComponent1())); wroteSomething = true; } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent2())) { result.append("/" + StringUtils.trimToEmpty(getComponent2())); wroteSomething = true; } if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) { if (wroteSomething) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent3())); } return result.toString(); }
From source file:com.haulmont.cuba.web.sys.WindowBreadCrumbs.java
public void update() { AppUI ui = AppUI.getCurrent();/* w ww . j av a2 s . c o m*/ boolean isTestMode = ui.isTestMode(); linksLayout.removeAllComponents(); btn2win.clear(); for (Iterator<Window> it = windows.iterator(); it.hasNext();) { Window window = it.next(); Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener()); button.setSizeUndefined(); button.setStyleName(BaseTheme.BUTTON_LINK); button.setTabIndex(-1); if (isTestMode) { button.setCubaId("breadCrubms_Button_" + window.getId()); button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId())); } btn2win.put(button, window); if (it.hasNext()) { linksLayout.addComponent(button); Label separatorLab = new Label(" > "); separatorLab.setStyleName("c-breadcrumbs-separator"); separatorLab.setSizeUndefined(); separatorLab.setContentMode(ContentMode.HTML); linksLayout.addComponent(separatorLab); } else { Label captionLabel = new Label(window.getCaption()); captionLabel.setStyleName("c-breadcrumbs-win-caption"); captionLabel.setSizeUndefined(); linksLayout.addComponent(captionLabel); this.label = captionLabel; } } }