本文整理汇总了Java中org.kuali.rice.krad.util.KRADConstants.SYSTEM_USER属性的典型用法代码示例。如果您正苦于以下问题:Java KRADConstants.SYSTEM_USER属性的具体用法?Java KRADConstants.SYSTEM_USER怎么用?Java KRADConstants.SYSTEM_USER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.kuali.rice.krad.util.KRADConstants
的用法示例。
在下文中一共展示了KRADConstants.SYSTEM_USER属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWorkflowPessimisticLocking
/**
* Tests the {@link org.kuali.rice.krad.service.PessimisticLockService.establishWorkflowPessimisticLocking} method.
*
* @throws Exception
*/
@Test
public void testWorkflowPessimisticLocking() throws Exception {
PessimisticLockService lockService = KRADServiceLocatorWeb.getPessimisticLockService();
AccountRequestDocument accountDoc = (AccountRequestDocument) KRADServiceLocatorWeb.getDocumentService().getNewDocument("AccountRequest");
assertTrue("The AccountRequestDocument should be using pessimistic locking",
KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(accountDoc.getClass().getName()).getUsePessimisticLocking());
// Have the system user establish a pessimistic lock on the account request document.
UserSession systemSession = new UserSession(KRADConstants.SYSTEM_USER);
lockService.establishWorkflowPessimisticLocking(accountDoc);
// Check that the system user has the only pessimistic lock
assertEquals("The wrong number of pessimistic locks are established", 1, accountDoc.getPessimisticLocks().size());
PessimisticLock krPessimisticLock = accountDoc.getPessimisticLocks().get(0);
assertTrue("kr pessimistic lock was not established", krPessimisticLock.isOwnedByUser(systemSession.getPerson()));
// Have "admin" attempt to erroneously establish a pessimistic lock on the account request document.
UserSession adminSession = new UserSession("admin");
lockService.establishPessimisticLocks(accountDoc, adminSession.getPerson(), true);
// Check that "admin" cannot establish a lock when one is already in place.
assertEquals("The wrong number of pessimistic locks are established", 1, accountDoc.getPessimisticLocks().size());
PessimisticLock adminPessimisticLock = accountDoc.getPessimisticLocks().get(0);
assertFalse("admin pessimistic lock was not established", adminPessimisticLock.isOwnedByUser(adminSession.getPerson()));
// Ensure that workflow pessimistic locks can also be released.
lockService.releaseWorkflowPessimisticLocking(accountDoc);
assertTrue("There is a pessimistic lock established", accountDoc.getPessimisticLocks().isEmpty());
}
示例2: establishPostProcessorUserSession
/**
* Establishes the UserSession if one does not already exist.
*/
protected UserSession establishPostProcessorUserSession() throws WorkflowException {
if (GlobalVariables.getUserSession() == null) {
return new UserSession(KRADConstants.SYSTEM_USER);
} else {
return GlobalVariables.getUserSession();
}
}
示例3: testEstablishLocks
/**
* tests the PessimisticLockService.establishLocks method and the PessimisticLockService.getDocumentActions method
*
* @throws Exception
*/
@Test
@Deprecated
public void testEstablishLocks() throws Exception {
PessimisticLockService lockService = KRADServiceLocatorWeb.getPessimisticLockService();
AccountRequestDocument accountDoc = (AccountRequestDocument) KRADServiceLocatorWeb.getDocumentService().getNewDocument("AccountRequest");
assertTrue("The AccountRequestDocument should be using pessimistic locking",
KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(accountDoc.getClass().getName()).getUsePessimisticLocking());
// Have "quickstart" establish a pessimistic lock on the account request document.
UserSession quickstartSession = new UserSession("quickstart");
Person[] quickstartPerson = { quickstartSession.getPerson() };
Map<String,String> editMode = new HashMap<String,String>();
editMode.put(AuthorizationConstants.EditMode.FULL_ENTRY, KRADConstants.KUALI_DEFAULT_TRUE_VALUE);
Map <?,?> finalModes = lockService.establishLocks(accountDoc, editMode, quickstartSession.getPerson());
// Verify that the lock was actually established.
assertCorrectLocksAreInPlace(true, finalModes, 1, accountDoc.getPessimisticLocks(), quickstartPerson, null);
// Now check to make sure that a different user (such as "admin") cannot save, route, cancel, or blanket approve the document.
UserSession adminSession = new UserSession("admin");
Set<String> documentActions = new HashSet<String>(Arrays.asList(new String[] { KRADConstants.KUALI_ACTION_CAN_CANCEL,
KRADConstants.KUALI_ACTION_CAN_SAVE, KRADConstants.KUALI_ACTION_CAN_ROUTE, KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE }));
Set<?> finalActions = lockService.getDocumentActions(accountDoc, adminSession.getPerson(), documentActions);
assertFalse("'admin' should not be able to cancel the locked document", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_CANCEL));
assertFalse("'admin' should not be able to save the locked document", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_SAVE));
assertFalse("'admin' should not be able to route the locked document", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_ROUTE));
assertFalse("'admin' should not be able to blanket approve the locked document", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE));
// Verify that "quickstart" can save, route, and cancel the document since he is the owner of the lock.
documentActions = new HashSet<String>(Arrays.asList(new String[] {
KRADConstants.KUALI_ACTION_CAN_CANCEL, KRADConstants.KUALI_ACTION_CAN_SAVE, KRADConstants.KUALI_ACTION_CAN_ROUTE }));
finalActions = lockService.getDocumentActions(accountDoc, quickstartSession.getPerson(), documentActions);
assertTrue("'quickstart' should have had cancel privileges", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_CANCEL));
assertTrue("'quickstart' should have had save privileges", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_SAVE));
assertTrue("'quickstart' should have had route privileges", finalActions.contains(KRADConstants.KUALI_ACTION_CAN_ROUTE));
// Check that "admin" cannot establish a lock when one is already in place.
editMode = new HashMap<String,String>();
editMode.put(AuthorizationConstants.EditMode.FULL_ENTRY, KRADConstants.KUALI_DEFAULT_TRUE_VALUE);
finalModes = lockService.establishLocks(accountDoc, editMode, adminSession.getPerson());
assertCorrectLocksAreInPlace(false, finalModes, 1, accountDoc.getPessimisticLocks(), quickstartPerson, null);
// Make sure that "quickstart" cannot create a second lock if custom lock descriptors are not in use.
editMode = new HashMap<String,String>();
editMode.put(AuthorizationConstants.EditMode.FULL_ENTRY, KRADConstants.KUALI_DEFAULT_TRUE_VALUE);
finalModes = lockService.establishLocks(accountDoc, editMode, quickstartSession.getPerson());
assertCorrectLocksAreInPlace(true, finalModes, 1, accountDoc.getPessimisticLocks(), quickstartPerson, null);
// Release lock for "quickstart" for additional testing
lockService.releaseAllLocksForUser(accountDoc.getPessimisticLocks(), quickstartSession.getPerson());
accountDoc.refreshPessimisticLocks();
// Have the system user create a workflow pessimistic lock.
UserSession systemSession = new UserSession(KRADConstants.SYSTEM_USER);
Person[] systemPerson = { systemSession.getPerson() };
lockService.establishWorkflowPessimisticLocking(accountDoc);
assertCorrectLocksAreInPlace(false, null, 1, accountDoc.getPessimisticLocks(), systemPerson, null);
// Make sure that no other users can lock when the workflow lock is in place.
editMode = new HashMap<String,String>();
editMode.put(AuthorizationConstants.EditMode.FULL_ENTRY, KRADConstants.KUALI_DEFAULT_TRUE_VALUE);
finalModes = lockService.establishLocks(accountDoc, editMode, adminSession.getPerson());
assertCorrectLocksAreInPlace(false, finalModes, 1, accountDoc.getPessimisticLocks(), systemPerson, null);
// Ensure that workflow pessimistic locks can also be released.
lockService.releaseWorkflowPessimisticLocking(accountDoc);
assertTrue("There should not be any pessimistic locks present on the document", accountDoc.getPessimisticLocks().isEmpty());
}
示例4: getWorkflowPessimisticLockOwnerUser
/**
* This method identifies the user that should be used to create and clear {@link PessimisticLock} objects required by
* Workflow.<br>
* <br>
* The default is the Kuali system user defined by {@link RiceConstants#SYSTEM_USER}. This method can be overriden by
* implementing documents if another user is needed.
*
* @return a valid {@link Person} object
*/
protected Person getWorkflowPessimisticLockOwnerUser() {
String networkId = KRADConstants.SYSTEM_USER;
return getPersonService().getPersonByPrincipalName(networkId);
}