List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
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/* ww w . java 2 s .c o m*/ * @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); }