Example usage for org.apache.commons.lang StringUtils trimToNull

List of usage examples for org.apache.commons.lang StringUtils trimToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils trimToNull.

Prototype

public static String trimToNull(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null.

Usage

From source file:hoptoad.HoptoadNoticeBuilder.java

private void errorClass(Throwable throwable) {
    Throwable cause = throwable;/*from  ww  w. j  av  a  2 s . c  o m*/
    while (cause.getCause() != null) {
        cause = cause.getCause();
    }
    this.errorClass = cause.getClass().getName();
    if (StringUtils.trimToNull(errorMessage) == null) {
        errorMessage = '[' + throwable.getClass().toString() + ']';
    }
}

From source file:com.google.code.configprocessor.processing.ModifyAction.java

public String getFlags() {
    return StringUtils.trimToNull(flags);
}

From source file:edu.amc.sakai.user.EmailAddressDerivingLdapAttributeMapper.java

/**
 * Calculate an email address from the given user EID. This implementation
 * simply appends the "@" delim and the domain configured by
 * {@link #setDefaultAddressDomain(String)}. If that value is <code>null</code>, 
 * or the inbound eid is <code>null</code> or whitespace, simply returns 
 * <code>null</code> //  w w w .j a v  a 2s.co m
 *  
 * @param string
 * @return
 */
public String deriveAddressFromEid(String eid) {
    if (defaultAddressDomain == null) {
        return null;
    }
    eid = StringUtils.trimToNull(eid);
    if (eid == null) {
        return null;
    }
    return eid + "@" + defaultAddressDomain;
}

From source file:com.wim.reportviewer.web.report.list.ListReportsControllerImpl.java

/**
 * @throws IOException //from   www  .  j  av a  2 s  .c o m
 * @see com.wim.reportviewer.web.report.list.ListReportsController#search(java.lang.String report, java.util.Collection<com.wim.reportviewer.web.report.ReportInfo> reports)
 */
@Override
public void search(SearchForm form) throws IOException {
    String filter = StringUtils.trimToNull((String) WebAppUtil.getPageFlowScope().get(SAVED_SEARCH));
    form.setReports(loadReports(filter));
    form.setReport(filter);//pode estar vindo da visualizao
}

From source file:com.opengamma.integration.viewer.RemoteEngine.java

public RemoteEngine(String baseUrl) {
    ArgumentChecker.notNull(StringUtils.trimToNull(baseUrl), "baseUrl");
    init(baseUrl);
}

From source file:ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.NewSampleParserObjectFactory.java

@Override
public final NewSample createObject(final String[] lineTokens) throws ParserException {
    final NewSample newSample = super.createObject(lineTokens);
    if (identifierExpectedInFile && newSample.getIdentifier() == null) {
        throw new ParserException("Mandatory column '" + NewSample.IDENTIFIER_COLUMN + "' is missing.");
    }//from  w w w .ja  v  a 2s .c o  m
    if (identifierExpectedInFile == false && newSample.getIdentifier() != null) {
        throw new ParserException("Requested automatical generation of codes. Column '"
                + NewSample.IDENTIFIER_COLUMN + "' should be removed from the file.");
    }
    if (allowExperiments == false && newSample.getExperimentIdentifier() != null) {
        throw new ParserException("Column '" + NewSample.EXPERIMENT + "' should be removed from the file.");
    }
    newSample.setSampleType(sampleType);
    setProperties(newSample, lineTokens);
    newSample.setContainerIdentifier(StringUtils.trimToNull(newSample.getContainerIdentifier()));
    newSample.setParentIdentifier(StringUtils.trimToNull(newSample.getParentIdentifier()));
    newSample.setExperimentIdentifier(StringUtils.trimToNull(newSample.getExperimentIdentifier()));
    return newSample;
}

From source file:com.bluexml.xforms.actions.WorkflowSaveAction.java

public TransitionResultBean submitWork() throws ServletException {
    TransitionResultBean resultBean = new TransitionResultBean();
    if (logger.isDebugEnabled()) {
        logger.debug("WorkflowSaveAction.submit()");
    }//from   www . ja v  a 2s. c om

    HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
    currentPage = navigationPath.peekCurrentPage();
    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) {

    }

    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;
        }
    }

    currentPage.setWkflwProcessId(processId);

    // 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;
    }

    // NO transition triggered
    // seem to be successful
    resultBean.setSuccess(true);
    return resultBean;
}

From source file:eu.scidipes.toolkits.palibrary.impl.FormFieldImpl.java

/**
 * Creates a new FormField with a display name and a parent form
 * //from   ww w  .  j a v a  2s . c  o  m
 * @param displayName
 * @param parentForm
 * @throws PreservationInitialisationException
 * 
 */
public FormFieldImpl(final String displayName, final Form parentForm)
        throws PreservationInitialisationException {

    if (StringUtils.trimToNull(displayName) == null) {
        throw new PreservationInitialisationException("Form field displayName must not be null or empty");
    }

    if (parentForm == null) {
        throw new PreservationInitialisationException("Form Field must specify valid parent");
    }

    this.displayName = displayName;
    this.parentForm = parentForm;
}

From source file:com.egt.core.util.JS.java

public static String getOpenWindowJavaScript(String url, String rpl, String window, String session) {
    if (url == null) {
        return null;
    }/*  w  w  w .j  a  v a 2  s . c  om*/
    String ventana = StringUtils.isBlank(window) ? Global.DEFAULT_WINDOW_NAME : window;
    VelocityContext context = new VelocityContext();
    context.put("url", StringUtils.trimToNull(url));
    context.put("rpl", StringUtils.trimToNull(rpl));
    context.put("window", StringUtils.trimToNull(ventana));
    context.put("sesion", StringUtils.trimToNull(session));
    return merge("js-open-window", context);
}

From source file:ips1ap101.lib.core.db.util.InterpreteSqlPostgreSQL.java

@Override
public String getComandoSelect(String comando, int limite) {
    String select = super.getComandoSelect(comando, limite);
    if (select != null) {
        int i = Utils.indexOfWord(select, KEYWORD_LIMIT);
        if (i > 0) {
            select = StringUtils.trimToNull(select.substring(0, i));
        }//from w  w  w .j a  v a  2  s  .  c  o m
    }
    if (select != null && limite > 0) {
        select += " " + KEYWORD_LIMIT + " " + limite;
    }
    return select;
}