| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
package org.kuali.rice.kns.web.spring.controller; |
| 12 | |
|
| 13 | |
import java.util.Collections; |
| 14 | |
import java.util.Enumeration; |
| 15 | |
import java.util.HashMap; |
| 16 | |
import java.util.HashSet; |
| 17 | |
import java.util.Map; |
| 18 | |
import java.util.Map.Entry; |
| 19 | |
import java.util.Properties; |
| 20 | |
import java.util.Set; |
| 21 | |
|
| 22 | |
import javax.servlet.http.HttpServletRequest; |
| 23 | |
import javax.servlet.http.HttpServletResponse; |
| 24 | |
|
| 25 | |
import org.apache.commons.lang.StringUtils; |
| 26 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 27 | |
import org.kuali.rice.core.util.AttributeSet; |
| 28 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
| 29 | |
import org.kuali.rice.kim.util.KimConstants; |
| 30 | |
import org.kuali.rice.kns.UserSession; |
| 31 | |
import org.kuali.rice.kns.exception.AuthorizationException; |
| 32 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 33 | |
import org.kuali.rice.kns.service.ModuleService; |
| 34 | |
import org.kuali.rice.kns.service.SessionDocumentService; |
| 35 | |
import org.kuali.rice.kns.uif.UifConstants; |
| 36 | |
import org.kuali.rice.kns.uif.UifParameters; |
| 37 | |
import org.kuali.rice.kns.uif.container.View; |
| 38 | |
import org.kuali.rice.kns.uif.core.Component; |
| 39 | |
import org.kuali.rice.kns.uif.service.ViewService; |
| 40 | |
import org.kuali.rice.kns.uif.field.AttributeQueryResult; |
| 41 | |
import org.kuali.rice.kns.uif.util.ComponentFactory; |
| 42 | |
import org.kuali.rice.kns.uif.util.LookupInquiryUtils; |
| 43 | |
import org.kuali.rice.kns.uif.util.UifWebUtils; |
| 44 | |
import org.kuali.rice.kns.util.GlobalVariables; |
| 45 | |
import org.kuali.rice.kns.util.KNSConstants; |
| 46 | |
import org.kuali.rice.kns.util.KNSUtils; |
| 47 | |
import org.kuali.rice.kns.util.UrlFactory; |
| 48 | |
import org.kuali.rice.kns.util.WebUtils; |
| 49 | |
import org.kuali.rice.kns.web.spring.form.UifFormBase; |
| 50 | |
import org.springframework.validation.BindingResult; |
| 51 | |
import org.springframework.web.bind.annotation.ModelAttribute; |
| 52 | |
import org.springframework.web.bind.annotation.RequestMapping; |
| 53 | |
import org.springframework.web.bind.annotation.RequestMethod; |
| 54 | |
import org.springframework.web.bind.annotation.ResponseBody; |
| 55 | |
import org.springframework.web.servlet.ModelAndView; |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | 0 | public abstract class UifControllerBase { |
| 75 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UifControllerBase.class); |
| 76 | |
|
| 77 | |
protected static final String REDIRECT_PREFIX = "redirect:"; |
| 78 | |
private SessionDocumentService sessionDocumentService; |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
@ModelAttribute(value = "KualiForm") |
| 88 | |
public UifFormBase initForm(HttpServletRequest request) { |
| 89 | 0 | UifFormBase form = null; |
| 90 | 0 | String formKeyParam = request.getParameter(UifParameters.FORM_KEY); |
| 91 | 0 | String documentNumber = request.getParameter(KNSConstants.DOCUMENT_DOCUMENT_NUMBER); |
| 92 | |
|
| 93 | 0 | if (StringUtils.isNotBlank(formKeyParam)) { |
| 94 | 0 | form = (UifFormBase) request.getSession().getAttribute(formKeyParam); |
| 95 | |
|
| 96 | |
|
| 97 | 0 | if (form == null) { |
| 98 | 0 | UserSession userSession = (UserSession) request.getSession() |
| 99 | |
.getAttribute(KNSConstants.USER_SESSION_KEY); |
| 100 | 0 | form = getSessionDocumentService().getUifDocumentForm(documentNumber, formKeyParam, userSession, |
| 101 | |
request.getRemoteAddr()); |
| 102 | 0 | } |
| 103 | |
} else { |
| 104 | 0 | form = createInitialForm(request); |
| 105 | |
} |
| 106 | |
|
| 107 | 0 | return form; |
| 108 | |
} |
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
protected abstract UifFormBase createInitialForm(HttpServletRequest request); |
| 118 | |
|
| 119 | 0 | private Set<String> methodToCallsToNotCheckAuthorization = new HashSet<String>(); |
| 120 | |
{ |
| 121 | 0 | methodToCallsToNotCheckAuthorization.add("performLookup"); |
| 122 | 0 | methodToCallsToNotCheckAuthorization.add("performQuestion"); |
| 123 | 0 | methodToCallsToNotCheckAuthorization.add("performQuestionWithInput"); |
| 124 | 0 | methodToCallsToNotCheckAuthorization.add("performQuestionWithInputAgainBecauseOfErrors"); |
| 125 | 0 | methodToCallsToNotCheckAuthorization.add("performQuestionWithoutInput"); |
| 126 | 0 | methodToCallsToNotCheckAuthorization.add("performWorkgroupLookup"); |
| 127 | 0 | } |
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
protected final void addMethodToCallToUncheckedList(String methodToCall) { |
| 135 | 0 | methodToCallsToNotCheckAuthorization.add(methodToCall); |
| 136 | 0 | } |
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
public Set<String> getMethodToCallsToNotCheckAuthorization() { |
| 143 | 0 | return Collections.unmodifiableSet(methodToCallsToNotCheckAuthorization); |
| 144 | |
} |
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
public void checkAuthorization(UifFormBase form, String methodToCall) throws AuthorizationException { |
| 151 | 0 | String principalId = GlobalVariables.getUserSession().getPrincipalId(); |
| 152 | 0 | AttributeSet roleQualifier = new AttributeSet(getRoleQualification(form, methodToCall)); |
| 153 | 0 | AttributeSet permissionDetails = KNSUtils.getNamespaceAndActionClass(this.getClass()); |
| 154 | |
|
| 155 | 0 | if (!KimApiServiceLocator.getIdentityManagementService().isAuthorizedByTemplateName(principalId, |
| 156 | |
KNSConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.USE_SCREEN, permissionDetails, |
| 157 | |
roleQualifier)) { |
| 158 | 0 | throw new AuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalName(), |
| 159 | |
methodToCall, this.getClass().getSimpleName()); |
| 160 | |
} |
| 161 | 0 | } |
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
protected Map<String, String> getRoleQualification(UifFormBase form, String methodToCall) { |
| 168 | 0 | return new HashMap<String, String>(); |
| 169 | |
} |
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
@RequestMapping(method = RequestMethod.GET, params = "methodToCall=start") |
| 176 | |
public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 177 | |
HttpServletRequest request, HttpServletResponse response) { |
| 178 | |
|
| 179 | 0 | return getUIFModelAndView(form); |
| 180 | |
} |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLine") |
| 188 | |
public ModelAndView addLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, |
| 189 | |
HttpServletRequest request, HttpServletResponse response) { |
| 190 | |
|
| 191 | 0 | String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH); |
| 192 | 0 | if (StringUtils.isBlank(selectedCollectionPath)) { |
| 193 | 0 | throw new RuntimeException("Selected collection was not set for add line action, cannot add new line"); |
| 194 | |
} |
| 195 | |
|
| 196 | 0 | View view = uifForm.getPreviousView(); |
| 197 | 0 | view.getViewHelperService().processCollectionAddLine(view, uifForm, selectedCollectionPath); |
| 198 | |
|
| 199 | 0 | return getUIFModelAndView(uifForm); |
| 200 | |
} |
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteLine") |
| 209 | |
public ModelAndView deleteLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, |
| 210 | |
HttpServletRequest request, HttpServletResponse response) { |
| 211 | |
|
| 212 | 0 | String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH); |
| 213 | 0 | if (StringUtils.isBlank(selectedCollectionPath)) { |
| 214 | 0 | throw new RuntimeException("Selected collection was not set for delete line action, cannot delete line"); |
| 215 | |
} |
| 216 | |
|
| 217 | 0 | int selectedLineIndex = -1; |
| 218 | 0 | String selectedLine = uifForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX); |
| 219 | 0 | if (StringUtils.isNotBlank(selectedLine)) { |
| 220 | 0 | selectedLineIndex = Integer.parseInt(selectedLine); |
| 221 | |
} |
| 222 | |
|
| 223 | 0 | if (selectedLineIndex == -1) { |
| 224 | 0 | throw new RuntimeException("Selected line index was not set for delete line action, cannot delete line"); |
| 225 | |
} |
| 226 | |
|
| 227 | 0 | View view = uifForm.getPreviousView(); |
| 228 | 0 | view.getViewHelperService().processCollectionDeleteLine(view, uifForm, selectedCollectionPath, |
| 229 | |
selectedLineIndex); |
| 230 | |
|
| 231 | 0 | return getUIFModelAndView(uifForm); |
| 232 | |
} |
| 233 | |
|
| 234 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=showInactiveRecords") |
| 235 | |
public ModelAndView showInactiveRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, |
| 236 | |
HttpServletRequest request, HttpServletResponse response) { |
| 237 | |
|
| 238 | 0 | String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH); |
| 239 | 0 | if (StringUtils.isBlank(selectedCollectionPath)) { |
| 240 | 0 | throw new RuntimeException("Selected collection was not set for show inactive records"); |
| 241 | |
} |
| 242 | |
|
| 243 | 0 | return getUIFModelAndView(uifForm); |
| 244 | |
} |
| 245 | |
|
| 246 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=hideInactiveRecords") |
| 247 | |
public ModelAndView hideInactiveRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, |
| 248 | |
HttpServletRequest request, HttpServletResponse response) { |
| 249 | |
|
| 250 | 0 | String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH); |
| 251 | 0 | if (StringUtils.isBlank(selectedCollectionPath)) { |
| 252 | 0 | throw new RuntimeException("Selected collection was not set for hide inactive records"); |
| 253 | |
} |
| 254 | |
|
| 255 | 0 | return getUIFModelAndView(uifForm); |
| 256 | |
} |
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
@RequestMapping(params = "methodToCall=cancel") |
| 262 | |
public ModelAndView cancel(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 263 | |
HttpServletRequest request, HttpServletResponse response) { |
| 264 | 0 | return close(form, result, request, response); |
| 265 | |
} |
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
@RequestMapping(params = "methodToCall=close") |
| 271 | |
public ModelAndView close(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 272 | |
HttpServletRequest request, HttpServletResponse response) { |
| 273 | 0 | Properties props = new Properties(); |
| 274 | 0 | props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH); |
| 275 | 0 | if (StringUtils.isNotBlank(form.getReturnFormKey())) { |
| 276 | 0 | props.put(UifParameters.FORM_KEY, form.getReturnFormKey()); |
| 277 | |
} |
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | 0 | String returnUrl = form.getReturnLocation(); |
| 282 | 0 | if (StringUtils.isBlank(returnUrl)) { |
| 283 | 0 | returnUrl = ConfigContext.getCurrentContextConfig().getProperty(KNSConstants.APPLICATION_URL_KEY); |
| 284 | |
} |
| 285 | |
|
| 286 | 0 | return performRedirect(form, returnUrl, props); |
| 287 | |
} |
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate") |
| 293 | |
public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 294 | |
HttpServletRequest request, HttpServletResponse response) { |
| 295 | 0 | String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID); |
| 296 | |
|
| 297 | |
|
| 298 | 0 | form.setRenderFullView(false); |
| 299 | |
|
| 300 | 0 | return getUIFModelAndView(form, form.getViewId(), pageId); |
| 301 | |
} |
| 302 | |
|
| 303 | |
@RequestMapping(params = "methodToCall=refresh") |
| 304 | |
public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 305 | |
HttpServletRequest request, HttpServletResponse response) throws Exception { |
| 306 | |
|
| 307 | |
|
| 308 | 0 | return getUIFModelAndView(form); |
| 309 | |
} |
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=updateComponent") |
| 322 | |
public ModelAndView updateComponent(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 323 | |
HttpServletRequest request, HttpServletResponse response) { |
| 324 | |
|
| 325 | 0 | Component comp = ComponentFactory.getComponentById(form, request.getParameter("reqComponentId")); |
| 326 | |
|
| 327 | 0 | return UifWebUtils.getComponentModelAndView(comp, form); |
| 328 | |
} |
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | |
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=performLookup") |
| 335 | |
public ModelAndView performLookup(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, |
| 336 | |
HttpServletRequest request, HttpServletResponse response) { |
| 337 | 0 | Properties lookupParameters = form.getActionParametersAsProperties(); |
| 338 | |
|
| 339 | 0 | String lookupObjectClassName = (String) lookupParameters.get(UifParameters.DATA_OBJECT_CLASS_NAME); |
| 340 | 0 | Class<?> lookupObjectClass = null; |
| 341 | |
try { |
| 342 | 0 | lookupObjectClass = Class.forName(lookupObjectClassName); |
| 343 | 0 | } catch (ClassNotFoundException e) { |
| 344 | 0 | LOG.error("Unable to get class for name: " + lookupObjectClassName); |
| 345 | 0 | throw new RuntimeException("Unable to get class for name: " + lookupObjectClassName, e); |
| 346 | 0 | } |
| 347 | |
|
| 348 | |
|
| 349 | 0 | String lookupParameterString = (String) lookupParameters.get(UifParameters.LOOKUP_PARAMETERS); |
| 350 | 0 | if (lookupParameterString != null) { |
| 351 | 0 | Map<String, String> lookupParameterFields = WebUtils.getMapFromParameterString(lookupParameterString); |
| 352 | 0 | for (Entry<String, String> lookupParameter : lookupParameterFields.entrySet()) { |
| 353 | 0 | String lookupParameterValue = LookupInquiryUtils.retrieveLookupParameterValue(form, request, |
| 354 | |
lookupObjectClass, lookupParameter.getValue(), lookupParameter.getKey()); |
| 355 | 0 | if (StringUtils.isNotBlank(lookupParameterValue)) { |
| 356 | 0 | lookupParameters.put(lookupParameter.getValue(), lookupParameterValue); |
| 357 | |
} |
| 358 | 0 | } |
| 359 | |
} |
| 360 | |
|
| 361 | |
|
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | 0 | String baseLookupUrl = (String) lookupParameters.get(UifParameters.BASE_LOOKUP_URL); |
| 366 | 0 | lookupParameters.remove(UifParameters.BASE_LOOKUP_URL); |
| 367 | |
|
| 368 | |
|
| 369 | 0 | lookupParameters.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.START); |
| 370 | 0 | String autoSearchString = (String) lookupParameters.get(UifParameters.AUTO_SEARCH); |
| 371 | 0 | if (Boolean.parseBoolean(autoSearchString)) { |
| 372 | 0 | lookupParameters.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.SEARCH); |
| 373 | |
} |
| 374 | |
|
| 375 | 0 | lookupParameters.put(UifParameters.RETURN_LOCATION, form.getFormPostUrl()); |
| 376 | 0 | lookupParameters.put(UifParameters.RETURN_FORM_KEY, form.getFormKey()); |
| 377 | |
|
| 378 | |
|
| 379 | 0 | if (lookupObjectClass != null) { |
| 380 | 0 | ModuleService responsibleModuleService = KNSServiceLocatorWeb.getKualiModuleService() |
| 381 | |
.getResponsibleModuleService(lookupObjectClass); |
| 382 | 0 | if (responsibleModuleService != null && responsibleModuleService.isExternalizable(lookupObjectClass)) { |
| 383 | 0 | Map<String, String> parameterMap = new HashMap<String, String>(); |
| 384 | 0 | Enumeration<Object> e = lookupParameters.keys(); |
| 385 | 0 | while (e.hasMoreElements()) { |
| 386 | 0 | String paramName = (String) e.nextElement(); |
| 387 | 0 | parameterMap.put(paramName, lookupParameters.getProperty(paramName)); |
| 388 | 0 | } |
| 389 | |
|
| 390 | 0 | String lookupUrl = responsibleModuleService.getExternalizableBusinessObjectLookupUrl(lookupObjectClass, |
| 391 | |
parameterMap); |
| 392 | 0 | return performRedirect(form, lookupUrl, new Properties()); |
| 393 | |
} |
| 394 | |
} |
| 395 | |
|
| 396 | 0 | return performRedirect(form, baseLookupUrl, lookupParameters); |
| 397 | |
} |
| 398 | |
|
| 399 | |
|
| 400 | |
|
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
@RequestMapping(method = RequestMethod.GET, params = "methodToCall=performFieldSuggest") |
| 406 | |
public @ResponseBody AttributeQueryResult performFieldSuggest(@ModelAttribute("KualiForm") UifFormBase form, |
| 407 | |
BindingResult result, HttpServletRequest request, HttpServletResponse response) { |
| 408 | |
|
| 409 | |
|
| 410 | 0 | Map<String, String> queryParameters = new HashMap<String, String>(); |
| 411 | 0 | for (Object parameterName : request.getParameterMap().keySet()) { |
| 412 | 0 | if (parameterName.toString().startsWith(UifParameters.QUERY_PARAMETER + ".")) { |
| 413 | 0 | String fieldName = |
| 414 | |
StringUtils.substringAfter(parameterName.toString(), UifParameters.QUERY_PARAMETER + "."); |
| 415 | 0 | String fieldValue = request.getParameter(parameterName.toString()); |
| 416 | 0 | queryParameters.put(fieldName, fieldValue); |
| 417 | 0 | } |
| 418 | |
} |
| 419 | |
|
| 420 | |
|
| 421 | 0 | String queryFieldId = request.getParameter(UifParameters.QUERY_FIELD_ID); |
| 422 | 0 | if (StringUtils.isBlank(queryFieldId)) { |
| 423 | 0 | throw new RuntimeException( |
| 424 | |
"Unable to find id for field to perform query on under request parameter name: " + |
| 425 | |
UifParameters.QUERY_FIELD_ID); |
| 426 | |
} |
| 427 | |
|
| 428 | |
|
| 429 | 0 | String queryTerm = request.getParameter(UifParameters.QUERY_TERM); |
| 430 | 0 | if (StringUtils.isBlank(queryTerm)) { |
| 431 | 0 | throw new RuntimeException( |
| 432 | |
"Unable to find id for query term value for attribute query on under request parameter name: " + |
| 433 | |
UifParameters.QUERY_TERM); |
| 434 | |
} |
| 435 | |
|
| 436 | |
|
| 437 | 0 | AttributeQueryResult queryResult = KNSServiceLocatorWeb.getAttributeQueryService() |
| 438 | |
.performFieldSuggestQuery(form.getView(), queryFieldId, queryTerm, queryParameters); |
| 439 | |
|
| 440 | 0 | return queryResult; |
| 441 | |
} |
| 442 | |
|
| 443 | |
|
| 444 | |
|
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | |
@RequestMapping(method = RequestMethod.GET, params = "methodToCall=performFieldQuery") |
| 451 | |
public @ResponseBody AttributeQueryResult performFieldQuery(@ModelAttribute("KualiForm") UifFormBase form, |
| 452 | |
BindingResult result, HttpServletRequest request, HttpServletResponse response) { |
| 453 | |
|
| 454 | |
|
| 455 | 0 | Map<String, String> queryParameters = new HashMap<String, String>(); |
| 456 | 0 | for (Object parameterName : request.getParameterMap().keySet()) { |
| 457 | 0 | if (parameterName.toString().startsWith(UifParameters.QUERY_PARAMETER + ".")) { |
| 458 | 0 | String fieldName = |
| 459 | |
StringUtils.substringAfter(parameterName.toString(), UifParameters.QUERY_PARAMETER + "."); |
| 460 | 0 | String fieldValue = request.getParameter(parameterName.toString()); |
| 461 | 0 | queryParameters.put(fieldName, fieldValue); |
| 462 | 0 | } |
| 463 | |
} |
| 464 | |
|
| 465 | |
|
| 466 | 0 | String queryFieldId = request.getParameter(UifParameters.QUERY_FIELD_ID); |
| 467 | 0 | if (StringUtils.isBlank(queryFieldId)) { |
| 468 | 0 | throw new RuntimeException( |
| 469 | |
"Unable to find id for field to perform query on under request parameter name: " + |
| 470 | |
UifParameters.QUERY_FIELD_ID); |
| 471 | |
} |
| 472 | |
|
| 473 | |
|
| 474 | 0 | AttributeQueryResult queryResult = KNSServiceLocatorWeb.getAttributeQueryService() |
| 475 | |
.performFieldQuery(form.getView(), queryFieldId, queryParameters); |
| 476 | |
|
| 477 | 0 | return queryResult; |
| 478 | |
} |
| 479 | |
|
| 480 | |
|
| 481 | |
|
| 482 | |
|
| 483 | |
|
| 484 | |
|
| 485 | |
|
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
protected ModelAndView performRedirect(UifFormBase form, String baseUrl, Properties urlParameters) { |
| 493 | |
|
| 494 | |
|
| 495 | 0 | urlParameters.setProperty(UifConstants.UrlParams.HISTORY, form.getFormHistory().getHistoryParameterString()); |
| 496 | |
|
| 497 | |
|
| 498 | |
|
| 499 | 0 | if (urlParameters.get("ajaxCall") != null && urlParameters.get("ajaxCall").equals("true")) { |
| 500 | 0 | urlParameters.remove("ajaxCall"); |
| 501 | 0 | String redirectUrl = UrlFactory.parameterizeUrl(baseUrl, urlParameters); |
| 502 | |
|
| 503 | 0 | ModelAndView modelAndView = new ModelAndView("redirectURL"); |
| 504 | 0 | modelAndView.addObject("redirectUrl", redirectUrl); |
| 505 | 0 | return modelAndView; |
| 506 | |
} |
| 507 | |
|
| 508 | 0 | String redirectUrl = UrlFactory.parameterizeUrl(baseUrl, urlParameters); |
| 509 | 0 | ModelAndView modelAndView = new ModelAndView(REDIRECT_PREFIX + redirectUrl); |
| 510 | |
|
| 511 | 0 | return modelAndView; |
| 512 | |
} |
| 513 | |
|
| 514 | |
protected ModelAndView getUIFModelAndView(UifFormBase form) { |
| 515 | 0 | return getUIFModelAndView(form, form.getViewId(), form.getPageId()); |
| 516 | |
} |
| 517 | |
|
| 518 | |
protected ModelAndView getUIFModelAndView(UifFormBase form, String viewId) { |
| 519 | 0 | return getUIFModelAndView(form, viewId, ""); |
| 520 | |
} |
| 521 | |
|
| 522 | |
|
| 523 | |
|
| 524 | |
|
| 525 | |
|
| 526 | |
|
| 527 | |
|
| 528 | |
|
| 529 | |
|
| 530 | |
|
| 531 | |
|
| 532 | |
|
| 533 | |
|
| 534 | |
|
| 535 | |
protected ModelAndView getUIFModelAndView(UifFormBase form, String viewId, String pageId) { |
| 536 | 0 | return UifWebUtils.getUIFModelAndView(form, viewId, pageId); |
| 537 | |
} |
| 538 | |
|
| 539 | |
protected ViewService getViewService() { |
| 540 | 0 | return KNSServiceLocatorWeb.getViewService(); |
| 541 | |
} |
| 542 | |
|
| 543 | |
public SessionDocumentService getSessionDocumentService() { |
| 544 | 0 | return KNSServiceLocatorWeb.getSessionDocumentService(); |
| 545 | |
} |
| 546 | |
|
| 547 | |
} |