本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils类的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils类的具体用法?Java KRADUtils怎么用?Java KRADUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KRADUtils类属于org.kuali.rice.krad.util包,在下文中一共展示了KRADUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAuthorization
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
@Override
protected void checkAuthorization(ActionForm form, String methodToCall) throws AuthorizationException {
if (!(form instanceof LookupForm)) {
super.checkAuthorization(form, methodToCall);
} else {
try {
Class businessObjectClass = Class.forName(((LookupForm) form).getBusinessObjectClassName());
if (!KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(
GlobalVariables.getUserSession().getPrincipalId(), KRADConstants.KNS_NAMESPACE,
KimConstants.PermissionTemplateNames.LOOK_UP_RECORDS,
KRADUtils.getNamespaceAndComponentSimpleName(businessObjectClass),
Collections.<String, String>emptyMap())) {
throw new AuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalName(),
KimConstants.PermissionTemplateNames.LOOK_UP_RECORDS,
businessObjectClass.getSimpleName());
}
}
catch (ClassNotFoundException e) {
LOG.warn("Unable to load BusinessObject class: " + ((LookupForm) form).getBusinessObjectClassName(), e);
super.checkAuthorization(form, methodToCall);
}
}
}
示例2: backdoorLogout
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Method to logout the backdoor user and return to the view.
*
* @return the view to return to
*/
@RequestMapping(params = "methodToCall=backdoorLogout")
public ModelAndView backdoorLogout(@ModelAttribute("KualiForm") DummyLoginForm uifForm, BindingResult result,
HttpServletRequest request, HttpServletResponse response) {
String returnUrl = decode(uifForm.getReturnLocation());
if (StringUtils.isBlank(returnUrl)) {
returnUrl = ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.APPLICATION_URL_KEY);
}
UserSession userSession = KRADUtils.getUserSessionFromRequest(request);
if (userSession.isBackdoorInUse()) {
userSession.clearBackdoorUser();
}
return performRedirect(uifForm, returnUrl, new Properties());
}
示例3: preHandle
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Before the controller executes the user session is set on GlobalVariables
* and messages are cleared, in addition setup for the history manager and a check on missing session
* forms is performed.
*
* {@inheritDoc}
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
checkHandlerMethodAccess(request, handler);
final ParameterService parameterService = CoreFrameworkServiceLocator.getParameterService();
if (parameterService.getParameterValueAsBoolean(KRADConstants.KUALI_RICE_SYSTEM_NAMESPACE, ParameterConstants.ALL_COMPONENT, CsrfValidator.CSRF_PROTECTION_ENABLED_PARAM) && !CsrfValidator.validateCsrf(request, response)) {
return false;
}
final UserSession session = KRADUtils.getUserSessionFromRequest(request);
GlobalVariables.setUserSession(session);
GlobalVariables.clear();
createUifFormManagerIfNecessary(request);
// add the HistoryManager for storing HistoryFlows to the session
if (request.getSession().getAttribute(UifConstants.HistoryFlow.HISTORY_MANAGER) == null) {
request.getSession().setAttribute(UifConstants.HistoryFlow.HISTORY_MANAGER, new HistoryManager());
}
ProcessLogger.trace("pre-handle");
return true;
}
示例4: getMaintenanceActionUrl
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
@Override
protected String getMaintenanceActionUrl(LookupForm lookupForm, Object dataObject, String methodToCall,
List<String> pkNames) {
Properties props = new Properties();
props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
for (String primaryKey : primaryKeyValues.keySet()) {
String primaryKeyValue = primaryKeyValues.get(primaryKey);
props.put(primaryKey, primaryKeyValue);
props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
}
if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
}
props.put(UifParameters.DATA_OBJECT_CLASS_NAME, PropositionBo.class.getName());
props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.PROPOSITION_PATH, props);
}
示例5: getRedirectUrl
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Inspects the given view session policy to determine how the request should be redirected
*
* <p>
* The request will either be redirected to the application home, a custom URL, the same request URL but
* modified to call the <code>sessionTimeout</code> method, or a redirect to show the session timeout view
* </p>
*
* @param sessionPolicy session policy instance to inspect
* @param httpServletRequest request instance for pulling parameters
* @return redirect URL or null if no redirect was configured
*/
protected String getRedirectUrl(ViewSessionPolicy sessionPolicy, HttpServletRequest httpServletRequest) {
String redirectUrl = null;
if (sessionPolicy.isRedirectToHome()) {
redirectUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
KRADConstants.APPLICATION_URL_KEY);
} else if (StringUtils.isNotBlank(sessionPolicy.getRedirectUrl())) {
redirectUrl = sessionPolicy.getRedirectUrl();
} else if (sessionPolicy.isRenderTimeoutView()) {
String kradUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
KRADConstants.KRAD_URL_KEY);
redirectUrl = KRADUtils.buildViewUrl(kradUrl, KRADConstants.REQUEST_MAPPING_SESSION_TIMEOUT,
KRADConstants.SESSION_TIMEOUT_VIEW_ID);
}
return redirectUrl;
}
示例6: establishBackdoorUser
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* establishes the backdoor user on the established user id if backdoor capabilities are valid.
*/
private void establishBackdoorUser(HttpServletRequest request) {
final String backdoor = request.getParameter(KRADConstants.BACKDOOR_PARAMETER);
if (StringUtils.isNotBlank(backdoor)) {
if (!getKualiConfigurationService().getPropertyValueAsString(KRADConstants.PROD_ENVIRONMENT_CODE_KEY)
.equalsIgnoreCase(getKualiConfigurationService().getPropertyValueAsString(
KRADConstants.ENVIRONMENT_KEY))) {
if (getParameterService().getParameterValueAsBoolean(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE,
KRADConstants.DetailTypes.BACKDOOR_DETAIL_TYPE, KewApiConstants.SHOW_BACK_DOOR_LOGIN_IND)) {
try {
KRADUtils.getUserSessionFromRequest(request).setBackdoorUser(backdoor);
} catch (RiceRuntimeException re) {
//Ignore so BackdoorAction can redirect to invalid_backdoor_portal
}
}
}
}
}
示例7: testValidInheritedAppDocStatusWithCategories
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
*
* This method an inherited valid set of values and categories.
*
* @throws Exception
*/
@Test public void testValidInheritedAppDocStatusWithCategories() throws Exception {
// Create document
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "TestAppDocStatusDoc5");
document.saveDocumentData();
assertNotNull(document.getDocumentId());
assertTrue("Document should be initiatied", document.isInitiated());
assertTrue("Invalid route level.", document.getNodeNames().contains("Initiated"));
DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName("TestAppDocStatusDoc5");
assertTrue(KRADUtils.isNotNull(documentType));
assertTrue(KRADUtils.isNotNull(documentType.getValidApplicationStatuses()));
LOG.info("valid application status size: " + documentType.getValidApplicationStatuses().size());
assertEquals(6,documentType.getValidApplicationStatuses().size());
assertTrue(KRADUtils.isNotNull(documentType.getApplicationStatusCategories()));
assertEquals(2,documentType.getApplicationStatusCategories().size());
}
示例8: getMessages
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Gets all the messages from the list of lists passed in (which are
* lists of ErrorMessages associated to the key) and uses the configuration
* service to get the message String associated. This will also combine
* error messages per a field if that option is turned on. If
* displayFieldLabelWithMessages is turned on, it will also find the label
* by key passed in.
*
* @param view
* @param key
* @param lists
* @return list of messages
*/
protected List<String> getMessages(View view, String key, List<List<ErrorMessage>> lists) {
List<String> result = new ArrayList<String>();
for (List<ErrorMessage> errorList : lists) {
if (errorList != null && StringUtils.isNotBlank(key)) {
for (ErrorMessage e : errorList) {
String message = KRADUtils.getMessageText(e, true);
message = MessageStructureUtils.translateStringMessage(message);
result.add(message);
}
}
}
return result;
}
示例9: convertStringToPropertyType
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Convert a string property value to the targeted property type.
*
* @param propertyValue The string property value.
* @return The property value, converted to the property type.
*/
private Object convertStringToPropertyType(String propertyValue) {
Class<?> propertyType = getPropertyType();
// TODO: these methods, and their inversions (below) need to be either support escaping
// or be removed. Both have been included for equivalence with previous BeanWrapper
// implementation.
if (List.class.equals(propertyType)) {
return KRADUtils.convertStringParameterToList(propertyValue);
} else if (Map.class.equals(propertyType)) {
return KRADUtils.convertStringParameterToMap(propertyValue);
} else {
PropertyEditor editor = ObjectPropertyUtils.getPropertyEditor(rootBean, rootPath);
if (editor == null) {
throw new IllegalArgumentException("No property editor available for converting '" + propertyValue
+ "' to " + propertyType);
}
editor.setAsText((String) propertyValue);
return editor.getValue();
}
}
示例10: compareFieldStringValues
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Compare the field values by computing the two string values and comparing them based on the
* sort type.
*
* @param columnSort the comparison metadata (which column number, which direction, what type of
* sort)
* @param protoField the prototype Field for the column being sorted
* @param index1 the index of the first modelCollection element for comparison
* @param index2 the index of the second modelCollection element for comparison
* @return 0 if the two elements are considered equal, a positive integer if the element at
* index1 is considered greater, else a negative integer
*/
private int compareFieldStringValues(ColumnSort columnSort, Field protoField, Integer index1, Integer index2) {
final int sortResult;
final String fieldValue1;
final String fieldValue2;
if (!CollectionUtils.sizeIsEmpty(protoField.getPropertyExpressions())) {
// We have to evaluate expressions
fieldValue1 = calculateFieldValue(protoField, index1, columnSort.getColumnIndex());
fieldValue2 = calculateFieldValue(protoField, index2, columnSort.getColumnIndex());
} else {
fieldValue1 = KRADUtils.getSimpleFieldValue(modelCollection.get(index1), protoField);
fieldValue2 = KRADUtils.getSimpleFieldValue(modelCollection.get(index2), protoField);
}
sortResult = columnTypeCompare(fieldValue1, fieldValue2, columnSort.getSortType());
return sortResult;
}
示例11: generateMessageText
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Returns formatted message text for the given message namespace, component, and key
*
* @param namespace namespace code the message is associated with, if null the default namespace
* will be used
* @param componentCode component code the message is associated with, if null default component
* code is used
* @param messageKey key for the message to retrieve
* @param params list of parameters for the message text
* @return formatted message text
*/
public static String generateMessageText(String namespace, String componentCode, String messageKey,
List<String> params) {
String message = "NO MESSAGE";
if (StringUtils.isNotEmpty(messageKey)) {
message = KRADServiceLocatorWeb.getMessageService().getMessageText(namespace, componentCode, messageKey);
if (params != null && !params.isEmpty() && StringUtils.isNotEmpty(message)) {
message = MessageFormat.format(message, params.toArray());
message = MessageStructureUtils.translateStringMessage(message);
}
}
if (StringUtils.isEmpty(message)) {
message = messageKey;
}
//replace characters that might cause issues with their equivalent html codes
message = KRADUtils.convertToHTMLAttributeSafeString(message);
return message;
}
示例12: getUnresolvedInheritedDocHandlerUrl
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* This method retrieves the unresolved document handler URL either from this object or from a parent document type
* object. If the forDisplayPurposes value is true the value returned will be invalid for system use.
* <p/>
* This method will first call the {@link #getUnresolvedDocHandlerUrl()} method to check for a value on this object.
* If none is found a parent document type must exist because the document handler URL is required and is used. The
* system will use inheritance to find the document handler url from a document type somewhere in the hierarchy.
*
* @param forDisplayPurposes - if true then the string returned will have a label explaining where the value came from
* @return the unresolved document handler URL value or a displayable value with sourcing information
*/
protected String getUnresolvedInheritedDocHandlerUrl(boolean forDisplayPurposes) {
if (StringUtils.isNotBlank(getUnresolvedDocHandlerUrl())) {
// this object has a direct value set, so return it
return getUnresolvedDocHandlerUrl();
}
// check for a parent document to see if the doc handler url can be inherited
DocumentType docType = getParentDocType();
if (KRADUtils.isNotNull(docType)) {
String parentValue = docType.getUnresolvedDocHandlerUrl();
if (StringUtils.isNotBlank(parentValue)) {
// found a parent value set on the immediate parent object so return it
if (forDisplayPurposes) {
parentValue += " " + KewApiConstants.DOCUMENT_TYPE_INHERITED_VALUE_INDICATOR;
}
return parentValue;
}
// no valid value exists on the immediate parent, so check the hierarchy
return docType.getUnresolvedInheritedDocHandlerUrl(forDisplayPurposes);
}
return null;
}
示例13: getAriaAttributesAsString
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getAriaAttributesAsString() {
String attributes = "";
if (getAriaAttributes() == null) {
return attributes;
}
for (Map.Entry<String, String> aria : getAriaAttributes().entrySet()) {
if (aria != null && aria.getValue() != null) {
attributes = attributes + " " + "aria-" + aria.getKey() + "=\"" +
KRADUtils.convertToHTMLAttributeSafeString(aria.getValue()) + "\"";
}
}
return attributes;
}
示例14: prepareSelectFieldForLine
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
public static void prepareSelectFieldForLine(Field selectField, CollectionGroup collectionGroup, String lineBindingPath,
Object line) {
// if select property name set use as property name for select field
String selectPropertyName = collectionGroup.getLineSelectPropertyName();
if (StringUtils.isNotBlank(selectPropertyName)) {
// if select property contains form prefix, will bind to form and not each line
if (selectPropertyName.startsWith(UifConstants.NO_BIND_ADJUST_PREFIX)) {
selectPropertyName = StringUtils.removeStart(selectPropertyName, UifConstants.NO_BIND_ADJUST_PREFIX);
((DataBinding) selectField).getBindingInfo().setBindingName(selectPropertyName);
((DataBinding) selectField).getBindingInfo().setBindToForm(true);
} else {
((DataBinding) selectField).getBindingInfo().setBindingName(selectPropertyName);
((DataBinding) selectField).getBindingInfo().setBindByNamePrefix(lineBindingPath);
}
} else {
// select property name not given, use UifFormBase#selectedCollectionLines
String collectionLineKey = KRADUtils.translateToMapSafeKey(
collectionGroup.getBindingInfo().getBindingPath());
String selectBindingPath = UifPropertyPaths.SELECTED_COLLECTION_LINES + "['" + collectionLineKey + "']";
((DataBinding) selectField).getBindingInfo().setBindingName(selectBindingPath);
((DataBinding) selectField).getBindingInfo().setBindToForm(true);
}
setControlValueToLineIdentifier(selectField, line, lineBindingPath);
}
示例15: start
import org.kuali.rice.krad.util.KRADUtils; //导入依赖的package包/类
/**
* Determines if the inquiry request needs to be redirected based on the module service, if not retrieves
* the inquiry data object and sets the instance onto the form for display.
*
* <p>Note the inquiry data object is retrieved based on the key values passed by the request.</p>
*
* {@inheritDoc}
*/
@Override
public ModelAndView start(UifFormBase form) {
InquiryForm inquiryForm = (InquiryForm) form;
HttpServletRequest request = form.getRequest();
Boolean hasRedirectedInquiryParameter = (request.getParameter(UifParameters.REDIRECTED_INQUIRY) != null
&& request.getParameter(UifParameters.REDIRECTED_INQUIRY).contains("true"));
if (!inquiryForm.isRedirectedInquiry() && !hasRedirectedInquiryParameter) {
ModelAndView redirectModelAndView = checkForModuleInquiryRedirect(inquiryForm, request);
if (redirectModelAndView != null) {
return redirectModelAndView;
}
}
// invoke inquirable to retrieve inquiry data object
Object dataObject = inquiryForm.getInquirable().retrieveDataObject(KRADUtils.translateRequestParameterMap(
request.getParameterMap()));
inquiryForm.setDataObject(dataObject);
return super.start(inquiryForm);
}