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

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

Introduction

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

Prototype

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

Source Link

Document

Gets the String that is nested in between two Strings.

Usage

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

/**
 * Determines which tab was requested to be toggled
 *
 * @param request//from  www.j  a va 2 s. c  o  m
 * @return
 */
protected String getTabToToggle(HttpServletRequest request) {
    String tabToToggle = "";
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        tabToToggle = StringUtils.substringBetween(parameterName, ".tab", ".");
    }

    return tabToToggle;
}

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

/**
 * Retrieves the image context/* w w w .j a  v a2s . c  o  m*/
 *
 * @param request
 * @param contextKey
 * @return
 */
protected String getImageContext(HttpServletRequest request, String contextKey) {
    String imageContext = "";
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isBlank(parameterName)) {
        parameterName = request.getParameter("methodToCallPath");
    }
    if (StringUtils.isNotBlank(parameterName)) {
        imageContext = StringUtils.substringBetween(parameterName, contextKey, ".");
    }
    return imageContext;
}

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

/**
 * Takes care of storing the action form in the User session and forwarding to the lookup action.
 *
 * @param mapping//  w ww. j a  va  2s .  com
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public ActionForward performLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    // parse out the important strings from our methodToCall parameter
    String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    validateLookupInquiryFullParameter(request, form, fullParameter);

    KualiForm kualiForm = (KualiForm) form;

    // when we return from the lookup, our next request's method to call is going to be refresh
    kualiForm.registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);

    // parse out the baseLookupUrl if there is one
    String baseLookupUrl = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM14_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM14_RIGHT_DEL);

    // parse out business object class name for lookup
    String boClassName = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, KRADConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL);
    if (StringUtils.isBlank(boClassName)) {
        throw new RuntimeException("Illegal call to perform lookup, no business object class name specified.");
    }
    Class boClass = null;

    try {
        boClass = Class.forName(boClassName);
    } catch (ClassNotFoundException cnfex) {
        if ((StringUtils.isNotEmpty(baseLookupUrl)
                && baseLookupUrl.startsWith(getApplicationBaseUrl() + "/kr/"))
                || StringUtils.isEmpty(baseLookupUrl)) {
            throw new IllegalArgumentException("The class (" + boClassName
                    + ") cannot be found by this particular " + "application. " + "ApplicationBaseUrl: "
                    + getApplicationBaseUrl() + " ; baseLookupUrl: " + baseLookupUrl);
        } else {
            LOG.info("The class (" + boClassName + ") cannot be found by this particular application. "
                    + "ApplicationBaseUrl: " + getApplicationBaseUrl() + " ; baseLookupUrl: " + baseLookupUrl);
        }
    }

    // build the parameters for the lookup url
    Properties parameters = new Properties();
    String conversionFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
    if (StringUtils.isNotBlank(conversionFields)) {
        parameters.put(KRADConstants.CONVERSION_FIELDS_PARAMETER, conversionFields);

        // register each of the destination parameters of the field conversion string as editable
        String[] fieldConversions = conversionFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
        for (String fieldConversion : fieldConversions) {
            String destination = fieldConversion.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2)[1];
            kualiForm.registerEditableProperty(destination);
        }
    }

    // pass values from form that should be pre-populated on lookup search
    String parameterFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
    if (LOG.isDebugEnabled()) {
        LOG.debug("fullParameter: " + fullParameter);
        LOG.debug("parameterFields: " + parameterFields);
    }
    if (StringUtils.isNotBlank(parameterFields)) {
        String[] lookupParams = parameterFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
        if (LOG.isDebugEnabled()) {
            LOG.debug("lookupParams: " + Arrays.toString(lookupParams));
        }
        for (String lookupParam : lookupParams) {
            String[] keyValue = lookupParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2);
            if (keyValue.length != 2) {
                throw new RuntimeException("malformed field conversion pair: " + Arrays.toString(keyValue));
            }

            String lookupParameterValue = retrieveLookupParameterValue(boClass, keyValue[1], keyValue[0], form,
                    request);
            if (StringUtils.isNotBlank(lookupParameterValue)) {
                parameters.put(keyValue[1], lookupParameterValue);
            }

            if (LOG.isDebugEnabled()) {
                LOG.debug("keyValue[0]: " + keyValue[0]);
                LOG.debug("keyValue[1]: " + keyValue[1]);
            }
        }
    }

    // pass values from form that should be read-Only on lookup search
    String readOnlyFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM8_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM8_RIGHT_DEL);
    if (StringUtils.isNotBlank(readOnlyFields)) {
        parameters.put(KRADConstants.LOOKUP_READ_ONLY_FIELDS, readOnlyFields);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("fullParameter: " + fullParameter);
        LOG.debug("readOnlyFields: " + readOnlyFields);
    }

    // grab whether or not the "return value" link should be hidden or not
    String hideReturnLink = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL);
    if (StringUtils.isNotBlank(hideReturnLink)) {
        parameters.put(KRADConstants.HIDE_LOOKUP_RETURN_LINK, hideReturnLink);
    }

    // add the optional extra button source and parameters string
    String extraButtonSource = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM4_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM4_RIGHT_DEL);
    if (StringUtils.isNotBlank(extraButtonSource)) {
        parameters.put(KRADConstants.EXTRA_BUTTON_SOURCE, extraButtonSource);
    }
    String extraButtonParams = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM5_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM5_RIGHT_DEL);
    if (StringUtils.isNotBlank(extraButtonParams)) {
        parameters.put(KRADConstants.EXTRA_BUTTON_PARAMS, extraButtonParams);
    }

    String lookupAction = KRADConstants.LOOKUP_ACTION;

    // is this a multi-value return?
    boolean isMultipleValue = false;
    String multipleValues = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM6_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM6_RIGHT_DEL);
    if ((new Boolean(multipleValues).booleanValue())) {
        parameters.put(KRADConstants.MULTIPLE_VALUE, multipleValues);
        lookupAction = KRADConstants.MULTIPLE_VALUE_LOOKUP_ACTION;
        isMultipleValue = true;
    }

    // the name of the collection being looked up (primarily for multivalue lookups
    String lookedUpCollectionName = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM11_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM11_RIGHT_DEL);
    if (StringUtils.isNotBlank(lookedUpCollectionName)) {
        parameters.put(KRADConstants.LOOKED_UP_COLLECTION_NAME, lookedUpCollectionName);
    }

    // grab whether or not the "suppress actions" column should be hidden or not
    String suppressActions = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM7_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM7_RIGHT_DEL);
    if (StringUtils.isNotBlank(suppressActions)) {
        parameters.put(KRADConstants.SUPPRESS_ACTIONS, suppressActions);
    }

    // grab the references that should be refreshed upon returning from the lookup
    String referencesToRefresh = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM10_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM10_RIGHT_DEL);
    if (StringUtils.isNotBlank(referencesToRefresh)) {
        parameters.put(KRADConstants.REFERENCES_TO_REFRESH, referencesToRefresh);
    }

    // anchor, if it exists
    if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) {
        parameters.put(KRADConstants.LOOKUP_ANCHOR, ((KualiForm) form).getAnchor());
    }

    // now add required parameters
    parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "start");

    // pass value from form that shows if autoSearch is desired for lookup search
    String autoSearch = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM9_LEFT_DEL,
            KRADConstants.METHOD_TO_CALL_PARM9_RIGHT_DEL);

    if (StringUtils.isNotBlank(autoSearch)) {
        parameters.put(KRADConstants.LOOKUP_AUTO_SEARCH, autoSearch);
        if ("YES".equalsIgnoreCase(autoSearch)) {
            parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "search");
        }
    }

    parameters.put(KRADConstants.DOC_FORM_KEY,
            GlobalVariables.getUserSession().addObjectWithGeneratedKey(form));
    parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName);

    parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation(request, mapping));

    if (form instanceof KualiDocumentFormBase) {
        String docNum = ((KualiDocumentFormBase) form).getDocument().getDocumentNumber();
        if (docNum != null) {
            parameters.put(KRADConstants.DOC_NUM, docNum);
        }
    } else if (form instanceof LookupForm) {
        String docNum = ((LookupForm) form).getDocNum();
        if (docNum != null) {
            parameters.put(KRADConstants.DOC_NUM, ((LookupForm) form).getDocNum());
        }
    }

    if (boClass != null) {
        ModuleService responsibleModuleService = getKualiModuleService().getResponsibleModuleService(boClass);
        if (responsibleModuleService != null && responsibleModuleService.isExternalizable(boClass)) {
            Map<String, String> parameterMap = new HashMap<String, String>();
            Enumeration<Object> e = parameters.keys();
            while (e.hasMoreElements()) {
                String paramName = (String) e.nextElement();
                parameterMap.put(paramName, parameters.getProperty(paramName));
            }
            return new ActionForward(
                    responsibleModuleService.getExternalizableBusinessObjectLookupUrl(boClass, parameterMap),
                    true);
        }
    }

    if (StringUtils.isBlank(baseLookupUrl)) {
        baseLookupUrl = getApplicationBaseUrl() + "/kr/" + lookupAction;
    } else {
        if (isMultipleValue) {
            LookupUtils.transformLookupUrlToMultiple(baseLookupUrl);
        }
    }
    String lookupUrl = UrlFactory.parameterizeUrl(baseLookupUrl, parameters);
    return new ActionForward(lookupUrl, true);
}

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

@SuppressWarnings("unchecked")
public ActionForward performInquiry(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    // parse out the important strings from our methodToCall parameter
    String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    validateLookupInquiryFullParameter(request, form, fullParameter);

    // when javascript is disabled, the inquiry will appear in the same window as the document.  when we close the inquiry, 
    // our next request's method to call is going to be refresh
    KualiForm kualiForm = (KualiForm) form;
    kualiForm.registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);

    // parse out business object class name for lookup
    String boClassName = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, KRADConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL);
    if (StringUtils.isBlank(boClassName)) {
        throw new RuntimeException("Illegal call to perform inquiry, no business object class name specified.");
    }/*from w w  w. j  a v  a  2  s  . c  om*/

    // build the parameters for the inquiry url
    Properties parameters = new Properties();
    parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName);

    parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation(request, mapping));

    // pass values from form that should be pre-populated on inquiry
    String parameterFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
    if (LOG.isDebugEnabled()) {
        LOG.debug("fullParameter: " + fullParameter);
        LOG.debug("parameterFields: " + parameterFields);
    }
    if (StringUtils.isNotBlank(parameterFields)) {
        // TODO : create a method for this to be used by both lookup & inquiry ?
        String[] inquiryParams = parameterFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
        if (LOG.isDebugEnabled()) {
            LOG.debug("inquiryParams: " + inquiryParams);
        }
        Class<? extends BusinessObject> boClass = (Class<? extends BusinessObject>) Class.forName(boClassName);
        for (String inquiryParam : inquiryParams) {
            String[] keyValue = inquiryParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2);

            String inquiryParameterValue = retrieveLookupParameterValue(boClass, keyValue[1], keyValue[0], form,
                    request);
            if (inquiryParameterValue == null) {
                parameters.put(keyValue[1], "directInquiryKeyNotSpecified");
            } else {
                parameters.put(keyValue[1], inquiryParameterValue);
            }

            if (LOG.isDebugEnabled()) {
                LOG.debug("keyValue[0]: " + keyValue[0]);
                LOG.debug("keyValue[1]: " + keyValue[1]);
            }
        }
    }
    parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "start");
    parameters.put(KRADConstants.DOC_FORM_KEY,
            GlobalVariables.getUserSession().addObjectWithGeneratedKey(form));
    String inquiryUrl = null;
    try {
        Class.forName(boClassName);
        inquiryUrl = getApplicationBaseUrl() + "/kr/" + KRADConstants.DIRECT_INQUIRY_ACTION;
    } catch (ClassNotFoundException ex) {
        // allow inquiry url to be null (and therefore no inquiry link will be displayed) but at least log a warning
        LOG.warn("Class name does not represent a valid class which this application understands: "
                + boClassName);
    }
    inquiryUrl = UrlFactory.parameterizeUrl(inquiryUrl, parameters);
    return new ActionForward(inquiryUrl, true);

}

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

/**
 * Takes care of storing the action form in the User session and forwarding to the workflow workgroup lookup action.
 *
 * @param mapping/*from  ww w.j  a v a  2 s  .co m*/
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward performWorkgroupLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String returnUrl = null;
    if ("/kr".equals(mapping.getModuleConfig().getPrefix())) {
        returnUrl = getApplicationBaseUrl() + mapping.getModuleConfig().getPrefix() + mapping.getPath() + ".do";
    } else {
        returnUrl = getApplicationBaseUrl() + mapping.getPath() + ".do";
    }

    String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    String conversionFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);

    String deploymentBaseUrl = CoreApiServiceLocator.getKualiConfigurationService()
            .getPropertyValueAsString(KRADConstants.WORKFLOW_URL_KEY);
    String workgroupLookupUrl = deploymentBaseUrl
            + "/Lookup.do?lookupableImplServiceName=WorkGroupLookupableImplService&methodToCall=start&docFormKey="
            + GlobalVariables.getUserSession().addObjectWithGeneratedKey(form);

    if (conversionFields != null) {
        workgroupLookupUrl += "&conversionFields=" + conversionFields;
    }
    if (form instanceof KualiDocumentFormBase) {
        workgroupLookupUrl += "&docNum=" + ((KualiDocumentFormBase) form).getDocument().getDocumentNumber();
    }

    workgroupLookupUrl += "&returnLocation=" + returnUrl;

    return new ActionForward(workgroupLookupUrl, true);
}

From source file:org.kuali.rice.kns.web.struts.action.KualiAction.java

/**
 * This method takes the {@link org.kuali.rice.krad.util.KRADConstants.METHOD_TO_CALL_ATTRIBUTE} out of the request
 * and parses it returning the required fields needed for a text area. The fields returned
 * are the following in this order.//  w w  w .  j a  v a  2s. c  o  m
 * <ol>
 * <li>{@link #TEXT_AREA_FIELD_NAME}</li>
 * <li>{@link #FORM_ACTION}</li>
 * <li>{@link #TEXT_AREA_FIELD_LABEL}</li>
 * <li>{@link #TEXT_AREA_READ_ONLY}</li>
 * <li>{@link #TEXT_AREA_MAX_LENGTH}</li>
 * </ol>
 * 
 * @param request the request to retrieve the textarea parameters
 * @return a string array holding the parsed fields
 */
private String[] getTextAreaParams(HttpServletRequest request) {
    // parse out the important strings from our methodToCall parameter
    String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);

    // parse textfieldname:htmlformaction
    String parameterFields = StringUtils.substringBetween(fullParameter,
            KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
    if (LOG.isDebugEnabled()) {
        LOG.debug("fullParameter: " + fullParameter);
        LOG.debug("parameterFields: " + parameterFields);
    }
    String[] keyValue = null;
    if (StringUtils.isNotBlank(parameterFields)) {
        String[] textAreaParams = parameterFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
        if (LOG.isDebugEnabled()) {
            LOG.debug("lookupParams: " + textAreaParams);
        }
        for (final String textAreaParam : textAreaParams) {
            keyValue = textAreaParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2);

            if (LOG.isDebugEnabled()) {
                LOG.debug("keyValue[0]: " + keyValue[0]);
                LOG.debug("keyValue[1]: " + keyValue[1]);
                LOG.debug("keyValue[2]: " + keyValue[2]);
                LOG.debug("keyValue[3]: " + keyValue[3]);
                LOG.debug("keyValue[4]: " + keyValue[4]);
            }
        }
    }

    return keyValue;
}

From source file:org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase.java

/**
 * special refresh needed to get the workgroups populated correctly when coming back from workgroup lookups
 *
 * @param request/*  w w w  .  j a  v a2  s  . c  om*/
 * @param kualiForm
 * @throws WorkflowException
 */
@SuppressWarnings("unchecked")
protected void refreshAdHocRoutingWorkgroupLookups(HttpServletRequest request, KualiDocumentFormBase kualiForm)
        throws WorkflowException {
    for (Enumeration<String> i = request.getParameterNames(); i.hasMoreElements();) {
        String parameterName = i.nextElement();
        if (parameterName.equals("newAdHocRouteWorkgroup.recipientName")
                && !"".equals(request.getParameter(parameterName))) {
            //check for namespace
            String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE;
            if (request.getParameter("newAdHocRouteWorkgroup.recipientNamespaceCode") != null && !""
                    .equals(request.getParameter("newAdHocRouteWorkgroup.recipientNamespaceCode").trim())) {
                namespace = request.getParameter("newAdHocRouteWorkgroup.recipientNamespaceCode").trim();
            }
            Group group = getGroupService().getGroupByNamespaceCodeAndName(namespace,
                    request.getParameter(parameterName));
            if (group != null) {
                kualiForm.getNewAdHocRouteWorkgroup().setId(group.getId());
                kualiForm.getNewAdHocRouteWorkgroup().setRecipientName(group.getName());
                kualiForm.getNewAdHocRouteWorkgroup().setRecipientNamespaceCode(group.getNamespaceCode());
            } else {
                GlobalVariables.getMessageMap().putError("newAdHocRouteWorkgroup.recipientNamespaceCode",
                        RiceKeyConstants.ERROR_INVALID_ADHOC_WORKGROUP_NAMESPACECODE);
                return;
            }
        }
        if (parameterName.startsWith("adHocRouteWorkgroup[")
                && !"".equals(request.getParameter(parameterName))) {
            if (parameterName.endsWith(".recipientName")) {
                int lineNumber = Integer.parseInt(StringUtils.substringBetween(parameterName, "[", "]"));
                //check for namespace
                String namespaceParam = "adHocRouteWorkgroup[" + lineNumber + "].recipientNamespaceCode";
                String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE;
                if (request.getParameter(namespaceParam) != null
                        && !"".equals(request.getParameter(namespaceParam).trim())) {
                    namespace = request.getParameter(namespaceParam).trim();
                }
                Group group = getGroupService().getGroupByNamespaceCodeAndName(namespace,
                        request.getParameter(parameterName));
                if (group != null) {
                    kualiForm.getAdHocRouteWorkgroup(lineNumber).setId(group.getId());
                    kualiForm.getAdHocRouteWorkgroup(lineNumber).setRecipientName(group.getName());
                    kualiForm.getAdHocRouteWorkgroup(lineNumber)
                            .setRecipientNamespaceCode(group.getNamespaceCode());
                } else {
                    GlobalVariables.getMessageMap().putError(namespaceParam,
                            RiceKeyConstants.ERROR_INVALID_ADHOC_WORKGROUP_NAMESPACECODE);
                    return;
                }
            }
        }
        /*
        if (parameterName.startsWith("newAdHocRouteWorkgroup[") && !"".equals(request.getParameter(parameterName))) {
        if (parameterName.endsWith(".recipientName")) {
            int lineNumber = Integer.parseInt(StringUtils.substringBetween(parameterName, "[", "]"));
          //check for namespace
            String namespaceParam = "newAdHocRouteWorkgroup[" + lineNumber + "].recipientNamespaceCode";
            String namespace = KimApiConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE;
            if (request.getParameter(namespaceParam) != null && !"".equals(request.getParameter(namespaceParam).trim())) {
                namespace = request.getParameter(namespaceParam).trim();
            }
            KimGroup group = getIdentityManagementService().getGroupByNamespaceCodeAndName(namespace, request.getParameter(parameterName));
            if (group != null) {
                kualiForm.getAdHocRouteWorkgroup(lineNumber).setId(group.getGroupId());
                kualiForm.getAdHocRouteWorkgroup(lineNumber).setRecipientName(group.getGroupName());
                kualiForm.getAdHocRouteWorkgroup(lineNumber).setRecipientNamespaceCode(group.getNamespaceCode());
            } else {
                throw new RuntimeException("Invalid workgroup id passed as parameter.");
            }
        }
        }
        */
    }
}

From source file:org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase.java

/**
 * @param request//w  w w  . j  av  a  2 s  . co  m
 * @return index of the attachment whose download button was just pressed
 */
protected int selectedAttachmentIndex(HttpServletRequest request) {
    int attachmentIndex = -1;

    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        String attachmentIndexParam = StringUtils.substringBetween(parameterName, ".attachment[", "].");

        try {
            attachmentIndex = Integer.parseInt(attachmentIndexParam);
        } catch (NumberFormatException ignored) {
        }
    }

    return attachmentIndex;
}

From source file:org.kuali.rice.kns.web.struts.action.KualiInquiryAction.java

/**
 * Turns on (or off) the inactive record display for a maintenance collection.
 *//*from  ww w.  ja  v  a  2  s  .  co m*/
public ActionForward toggleInactiveRecordDisplay(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    InquiryForm inquiryForm = (InquiryForm) form;
    if (inquiryForm.getBusinessObjectClassName() == null) {
        LOG.error("Business object name not given.");
        throw new RuntimeException("Business object name not given.");
    }

    BusinessObject bo = retrieveBOFromInquirable(inquiryForm);
    checkBO(bo);

    Inquirable kualiInquirable = inquiryForm.getInquirable();
    //////////////////////////////
    String collectionName = extractCollectionName(request, KRADConstants.TOGGLE_INACTIVE_METHOD);
    if (collectionName == null) {
        LOG.error("Unable to get find collection name in request.");
        throw new RuntimeException("Unable to get find collection class in request.");
    }
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    boolean showInactive = Boolean.parseBoolean(
            StringUtils.substringBetween(parameterName, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, "."));
    kualiInquirable.setShowInactiveRecords(collectionName, showInactive);
    //////////////////////////////

    populateSections(mapping, request, inquiryForm, bo);

    // toggling the display to be visible again, re-open any previously closed inactive records
    if (showInactive) {
        WebUtils.reopenInactiveRecords(inquiryForm.getSections(), inquiryForm.getTabStates(), collectionName);
    }

    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}

From source file:org.kuali.rice.kns.web.struts.action.KualiInquiryAction.java

/**
 * Convert a Request into a Map<String,String>. Technically, Request parameters do not neatly translate into a Map of Strings,
 * because a given parameter may legally appear more than once (so a Map of String[] would be more accurate.) This method should
 * be safe for business objects, but may not be reliable for more general uses.
 *///from   w ww  .  j  a v  a2  s.  c o m
protected String extractCollectionName(HttpServletRequest request, String methodToCall) {
    // collection name and underlying object type from request parameter
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    String collectionName = null;
    if (StringUtils.isNotBlank(parameterName)) {
        collectionName = StringUtils.substringBetween(parameterName, methodToCall + ".", ".(");
    }
    return collectionName;
}