List of usage examples for org.apache.commons.lang StringUtils substringBetween
public static String substringBetween(String str, String open, String close)
Gets the String that is nested in between two Strings.
From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java
/** * This method...//ww w.j av a 2s.c o m * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward selectSystemType(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form; PurchasingDocumentBase document = (PurchasingDocumentBase) purchasingForm.getDocument(); Object question = request.getParameter(PurapConstants.QUESTION_INDEX); Object buttonClicked = request.getParameter(OLEConstants.QUESTION_CLICKED_BUTTON); String systemTypeCode = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); systemTypeCode = StringUtils.substringBetween(systemTypeCode, "selectSystemType.", "."); if (question == null) { String questionText = SpringContext.getBean(ConfigurationService.class) .getPropertyValueAsString(PurapConstants.CapitalAssetTabStrings.QUESTION_SYSTEM_SWITCHING); return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, OLEConstants.CONFIRMATION_QUESTION, OLEConstants.ROUTE_METHOD, "0"); } else if (ConfirmationQuestion.YES.equals(buttonClicked)) { // document.setCapitalAssetSystemTypeCode(systemTypeCode); document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_TYPE); KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PUR_CAPITAL_ASSET_SYSTEM_TYPE_SWITCHED); } return mapping.findForward(OLEConstants.MAPPING_BASIC); }
From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java
public ActionForward deleteItemCapitalAssetByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchasingFormBase purchasingForm = (PurchasingFormBase) form; PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument(); // get specific asset item PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems() .get(getSelectedLine(request)); ItemCapitalAsset asset = assetItem.getNewPurchasingItemCapitalAssetLine(); boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new // AddPurchasingAccountsPayableItemEvent("", purDocument, item)); if (rulePassed) { String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); String systemIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); String assetIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) purDocument .getPurchasingCapitalAssetSystems().get(Integer.parseInt(systemIndex)); system.getItemCapitalAssets().remove(Integer.parseInt(assetIndex)); }/*from w w w. j a va2s.c o m*/ return mapping.findForward(OLEConstants.MAPPING_BASIC); }
From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java
public ActionForward deleteItemCapitalAssetByItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchasingFormBase purchasingForm = (PurchasingFormBase) form; PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument(); // get specific asset item PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems() .get(getSelectedLine(request)); ItemCapitalAsset asset = assetItem.getNewPurchasingItemCapitalAssetLine(); boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new // AddPurchasingAccountsPayableItemEvent("", purDocument, item)); if (rulePassed) { String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); String assetIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) assetItem .getPurchasingCapitalAssetSystem(); system.getItemCapitalAssets().remove(Integer.parseInt(assetIndex)); }/*from w w w.jav a 2s . c o m*/ return mapping.findForward(OLEConstants.MAPPING_BASIC); }
From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java
public ActionForward deleteCapitalAssetLocationByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchasingFormBase purchasingForm = (PurchasingFormBase) form; CapitalAssetLocation location = purchasingForm.getNewPurchasingCapitalAssetLocationLine(); PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument(); boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new // AddPurchasingAccountsPayableItemEvent("", purDocument, item)); if (rulePassed) { String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); String systemIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); String locationIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); // get specific asset item and grab system as well and attach asset number CapitalAssetSystem system = purDocument.getPurchasingCapitalAssetSystems() .get(Integer.parseInt(systemIndex)); system.getCapitalAssetLocations().remove(Integer.parseInt(locationIndex)); }//from ww w . java 2s.c o m return mapping.findForward(OLEConstants.MAPPING_BASIC); }
From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java
public ActionForward deleteCapitalAssetLocationByItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchasingFormBase purchasingForm = (PurchasingFormBase) form; CapitalAssetLocation location = purchasingForm.getNewPurchasingCapitalAssetLocationLine(); PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument(); boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new // AddPurchasingAccountsPayableItemEvent("", purDocument, item)); if (rulePassed) { String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); String assetItemIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); String locationIndex = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); // get specific asset item and grab system as well and attach asset number PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems() .get(Integer.parseInt(assetItemIndex)); CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem(); system.getCapitalAssetLocations().remove(Integer.parseInt(locationIndex)); }/*from ww w.j av a2 s . c om*/ return mapping.findForward(OLEConstants.MAPPING_BASIC); }
From source file:org.kuali.ole.select.document.web.struts.OleCorrectionReceivingAction.java
/** * Will return an array of Strings containing 2 indexes, the first String is the item index and the second String is the account * index. These are obtained by parsing the method to call parameter from the request, between the word ".line" and "." The * indexes are separated by a semicolon (:) * * @param request The HttpServletRequest * @return An array of Strings containing pairs of two indices, an item index and a account index */// w ww . j ava2s. c o m protected String[] getSelectedLineForDelete(HttpServletRequest request) { LOG.debug("Inside getSelectedLineForDelete of OleCorrectionReceivingAction"); String accountString = new String(); String parameterName = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); if (StringUtils.isNotBlank(parameterName)) { accountString = StringUtils.substringBetween(parameterName, ".line", "."); } String[] result = StringUtils.split(accountString, ":"); return result; }
From source file:org.kuali.ole.select.document.web.struts.OleLineItemReceivingAction.java
/** * Will return an array of Strings containing 2 indexes, the first String is the item index and the second String is the account * index. These are obtained by parsing the method to call parameter from the request, between the word ".line" and "." The * indexes are separated by a semicolon (:) * * @param request The HttpServletRequest * @return An array of Strings containing pairs of two indices, an item index and a account index *///from w ww . j a v a2 s .c om protected String[] getSelectedLineForDelete(HttpServletRequest request) { LOG.debug("Inside getSelectedLineForDelete of OleLineItemReceivingAction"); String accountString = new String(); String parameterName = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); if (StringUtils.isNotBlank(parameterName)) { accountString = StringUtils.substringBetween(parameterName, ".line", "."); } String[] result = StringUtils.split(accountString, ":"); LOG.debug("Leaving getSelectedLineForDelete of OleLineItemReceivingAction"); return result; }
From source file:org.kuali.ole.service.impl.OleLicenseRequestServiceImpl.java
/** * This method converts the xml content into bussinessObjectBase class * @param xmlDocumentContents// www . ja v a 2s .c om * @return businessObject */ private Object getDataObjectFromXML(String xmlDocumentContents) { if (xmlDocumentContents != null || !"".equals(xmlDocumentContents) || !xmlDocumentContents.isEmpty()) { String maintXml = StringUtils.substringBetween(xmlDocumentContents, OLEConstants.OleLicenseRequest.START_TAG, OLEConstants.OleLicenseRequest.END_TAG); Object businessObject = null; if (maintXml != null) { maintXml = maintXml.substring(2, maintXml.length()); businessObject = KRADServiceLocator.getXmlObjectSerializerService().fromXml(maintXml); } return businessObject; } else { return null; } }
From source file:org.kuali.ole.sys.web.struts.KualiAccountingDocumentActionBase.java
@Override public ActionForward performLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // parse out the business object name from our methodToCall parameter String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); String boClassName = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, OLEConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL); if (!StringUtils.equals(boClassName, GeneralLedgerPendingEntry.class.getName())) { return super.performLookup(mapping, form, request, response); }/* www.j a v a 2s . c om*/ String path = super.performLookup(mapping, form, request, response).getPath(); path = path.replaceFirst(OLEConstants.LOOKUP_ACTION, OLEConstants.GL_MODIFIED_INQUIRY_ACTION); return new ActionForward(path, true); }
From source file:org.kuali.ole.sys.web.struts.KualiBalanceInquiryReportMenuAction.java
/** * Takes care of storing the action form in the user session and forwarding to the balance inquiry lookup action. * /*from ww w . j a v a 2s . c o m*/ * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward performBalanceInquiryLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); // parse out the important strings from our methodToCall parameter String fullParameter = (String) request.getAttribute(OLEConstants.METHOD_TO_CALL_ATTRIBUTE); // parse out business object class name for lookup String boClassName = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, OLEConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL); if (StringUtils.isBlank(boClassName)) { throw new RuntimeException("Illegal call to perform lookup, no business object class name specified."); } // build the parameters for the lookup url Properties parameters = new Properties(); String conversionFields = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); if (StringUtils.isNotBlank(conversionFields)) { parameters.put(OLEConstants.CONVERSION_FIELDS_PARAMETER, conversionFields); } // pass values from form that should be pre-populated on lookup search String parameterFields = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); if (StringUtils.isNotBlank(parameterFields)) { String[] lookupParams = parameterFields.split(OLEConstants.FIELD_CONVERSIONS_SEPERATOR); for (int i = 0; i < lookupParams.length; i++) { String[] keyValue = lookupParams[i].split(OLEConstants.FIELD_CONVERSION_PAIR_SEPERATOR); // hard-coded passed value if (StringUtils.contains(keyValue[0], "'")) { parameters.put(keyValue[1], StringUtils.replace(keyValue[0], "'", "")); } // passed value should come from property else if (StringUtils.isNotBlank(request.getParameter(keyValue[0]))) { parameters.put(keyValue[1], request.getParameter(keyValue[0])); } } } // grab whether or not the "return value" link should be hidden or not String hideReturnLink = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL); if (StringUtils.isNotBlank(hideReturnLink)) { parameters.put(OLEConstants.HIDE_LOOKUP_RETURN_LINK, hideReturnLink); } // anchor, if it exists if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) { parameters.put(OLEConstants.LOOKUP_ANCHOR, ((KualiForm) form).getAnchor()); } // determine what the action path is String actionPath = StringUtils.substringBetween(fullParameter, OLEConstants.METHOD_TO_CALL_PARM4_LEFT_DEL, OLEConstants.METHOD_TO_CALL_PARM4_RIGHT_DEL); if (StringUtils.isBlank(actionPath)) { throw new IllegalStateException( "The \"actionPath\" attribute is an expected parameter for the <gl:balanceInquiryLookup> tag - it " + "should never be blank."); } // now add required parameters parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, "start"); parameters.put(OLEConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); parameters.put(OLEConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName); parameters.put(OLEConstants.RETURN_LOCATION_PARAMETER, basePath + mapping.getPath() + ".do"); String lookupUrl = UrlFactory.parameterizeUrl(basePath + "/" + actionPath, parameters); return new ActionForward(lookupUrl, true); }