Example usage for org.apache.commons.lang3 StringUtils substringBetween

List of usage examples for org.apache.commons.lang3 StringUtils substringBetween

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substringBetween.

Prototype

public static String substringBetween(final String str, final String open, final String close) 

Source Link

Document

Gets the String that is nested in between two Strings.

Usage

From source file:org.kuali.coeus.propdev.impl.core.ProposalDevelopmentProposalAction.java

/**
 * This method reads a String value from the methodToCall form attribute.
 * @param request/* w  w w  .  ja  va2 s.co  m*/
 * @param parameterName
 * @return
 */
private String getMethodToCallParameter(HttpServletRequest request, String parameterName) {
    String methodToCallAttribute = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    return StringUtils.substringBetween(methodToCallAttribute, "." + parameterName, ".");
}

From source file:org.kuali.coeus.propdev.impl.questionnaire.ProposalDevelopmentQuestionsAction.java

/**
 * This is specifically for 'lookup' return a value.
 * @see org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase#refresh(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   w  ww .  j a  v  a 2  s  .com*/
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionForward forward = super.refresh(mapping, form, request, response);
    if (request.getParameter("refreshCaller") != null
            && request.getParameter("refreshCaller").toString().equals("kualiLookupable")) {
        // Lookup field 'onchange' is not working if it is return a value from 'lookup', so do it on server side
        for (Object obj : request.getParameterMap().keySet()) {
            if (StringUtils.indexOf((String) obj, "questionnaireHelper.answerHeaders[") == 0) {
                ((ProposalDevelopmentForm) form).getQuestionnaireHelper()
                        .updateChildIndicator(Integer.parseInt(StringUtils.substringBetween((String) obj,
                                "questionnaireHelper.answerHeaders[", "].answers[")));
            } else if (StringUtils.indexOf((String) obj, "s2sQuestionnaireHelper.answerHeaders[") == 0) {
                ((ProposalDevelopmentForm) form).getS2sQuestionnaireHelper()
                        .updateChildIndicator(Integer.parseInt(StringUtils.substringBetween((String) obj,
                                "s2sQuestionnaireHelper.answerHeaders[", "].answers[")));
            }
        }
    }
    return forward;
}

From source file:org.kuali.coeus.propdev.impl.s2s.ProposalDevelopmentGrantsGovAction.java

protected int getParameterForToken(HttpServletRequest request, String token) {
    int selectedLine = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        String lineNumber = StringUtils.substringBetween(parameterName, ("." + token), ".");
        if (StringUtils.isEmpty(lineNumber)) {
            return selectedLine;
        }/*from w  w  w  .  j ava  2 s.co  m*/
        selectedLine = Integer.parseInt(lineNumber);
    }

    return selectedLine;
}

From source file:org.kuali.coeus.sys.framework.controller.KcTransactionalDocumentActionBase.java

/**
 * Retrieves substring of document contents from maintainable tag name. Then use xml service to translate xml into a business
 * object.//from  w w  w .  j av a 2 s  .  c  o m
 */
private PersistableBusinessObject getBusinessObjectFromXML(String xmlDocumentContents, String objectTagName) {
    String objXml = StringUtils.substringBetween(xmlDocumentContents, "<" + objectTagName + ">",
            "</" + objectTagName + ">");
    objXml = "<" + objectTagName + ">" + objXml + "</" + objectTagName + ">";
    if (objXml.contains("itemDesctiption")) {
        objXml = objXml.replaceAll("itemDesctiption", "itemDescription");
    }
    PersistableBusinessObject businessObject = (PersistableBusinessObject) KRADServiceLocator
            .getXmlObjectSerializerService().fromXml(objXml);
    return businessObject;
}

From source file:org.kuali.coeus.sys.framework.model.KcTransactionalDocumentFormBase.java

@Override
public void populate(HttpServletRequest request) {
    super.populate(request);

    // Hack to get panels with add/delete items that are editable after add (Protocol Participants, Special Review) to work correctly with validation.  
    // In this scenario, the user adds a couple of correctly formatted items but then changes one of the fields to an incorrect format and saves.  This will
    // cause validation errors, but if the user now tries to delete the errant entry, validation will fail because the validator in the Kuali Request 
    // ProcessDefinitionDefinitionor still detects the error in the message map.  We don't want validation to run for a delete method, so we need to clear the current error 
    // messages, preventing the validator from running and allowing the delete to go through.
    //// www. ja  v a 2s  . c o  m
    // This is detected by the existence of "validate0" on the methodToCall property (similar to finding the line number of a delete).
    String methodToCallAttribute = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.contains(methodToCallAttribute, "validate")) {
        String validateParameter = StringUtils.substringBetween(methodToCallAttribute, ".validate", ".");
        if (StringUtils.equals("0", validateParameter)) {
            GlobalVariables.getMessageMap().clearErrorMessages();
        }
    }
}

From source file:org.kuali.kfs.kns.util.WebUtils.java

/**
 * Parses out the methodToCall command and also sets the request attribute
 * for the methodToCall./*from  ww  w.jav a 2  s.c om*/
 *
 * @param form    the ActionForm
 * @param request the request to set the attribute on
 * @param string  the methodToCall string
 * @return the methodToCall command
 */
private static String getMethodToCallSettingAttribute(ActionForm form, HttpServletRequest request,
        String string) {
    if (form instanceof KualiForm && !((KualiForm) form).shouldMethodToCallParameterBeUsed(string,
            request.getParameter(string), request)) {
        throw new RuntimeException("Cannot verify that the methodToCall should be " + string);
    }
    // always adding a coordinate even if not an image
    final String attributeValue = endsWithCoordinates(string) ? string
            : string + IMAGE_COORDINATE_CLICKED_X_EXTENSION;
    final String methodToCall = StringUtils.substringBetween(attributeValue,
            KRADConstants.DISPATCH_REQUEST_PARAMETER + ".", ".");
    request.setAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE, attributeValue);
    return methodToCall;
}

From source file:org.kuali.kra.award.web.struts.action.AwardAction.java

protected String getSyncScopesString(HttpServletRequest request) {
    String syncScopesList = null;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName) && parameterName.indexOf(".scopes") != -1) {
        syncScopesList = StringUtils.substringBetween(parameterName, ".scopes", ".anchor");
    }/*from  w w  w .j  a va 2 s . co m*/
    return syncScopesList;
}

From source file:org.kuali.kra.award.web.struts.action.AwardActionsAction.java

protected String getAwardNumber(HttpServletRequest request) {
    String awardNumber = "";
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        awardNumber = StringUtils.substringBetween(parameterName, ".awardNumber", ".");
    }/*from  ww  w  .j a  v a  2  s .  com*/

    return awardNumber;
}

From source file:org.kuali.kra.award.web.struts.action.AwardNotesAndAttachmentsAction.java

public ActionForward syncComment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    AwardForm awardForm = (AwardForm) form;
    //find specified comment
    String awardCommentIndex = null;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        awardCommentIndex = StringUtils.substringBetween(parameterName, ".awardCommentIdx", ".");
    }//from   w  ww  .  j av a2 s  . co  m
    //AwardComment comment = awardForm.getAwardDocument().getAward().getAwardCommentByType(awardCommentTypeCode, false, false);
    AwardComment comment = awardForm.getAwardDocument().getAward()
            .getAwardComment(Integer.parseInt(awardCommentIndex));
    getAwardSyncCreationService().addAwardSyncChange(awardForm.getAwardDocument().getAward(),
            new AwardSyncPendingChangeBean(AwardSyncType.ADD_SYNC, comment, "awardComments"));
    return mapping.findForward(Constants.MAPPING_BASIC);
}

From source file:org.kuali.kra.award.web.struts.action.AwardPaymentReportsAndTermsAction.java

protected int getSelectedAwardTermRecord(HttpServletRequest request) {
    int selectedLine = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        String lineNumber = StringUtils.substringBetween(parameterName, ".awardReportTermItems", ".");
        selectedLine = Integer.parseInt(lineNumber);
    }//from ww  w .  j  ava  2  s.c om

    return selectedLine;
}