当前位置: 首页>>代码示例>>Java>>正文


Java GlobalVariables.clear方法代码示例

本文整理汇总了Java中org.kuali.rice.krad.util.GlobalVariables.clear方法的典型用法代码示例。如果您正苦于以下问题:Java GlobalVariables.clear方法的具体用法?Java GlobalVariables.clear怎么用?Java GlobalVariables.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.krad.util.GlobalVariables的用法示例。


在下文中一共展示了GlobalVariables.clear方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preHandle

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的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;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:33,代码来源:UifControllerHandlerInterceptor.java

示例2: assertSearchableAttributeMultiplesWork

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * A convenience method for testing multiple value fields on searchable attributes.
 *
 * @param docType The document type containing the attributes.
 * @param principalId The ID of the user performing the search.
 * @param fieldDefKey The name of the field given by the field definition on the searchable attribute.
 * @param searchValues The wildcard-filled search strings to test.
 * @param resultSizes The number of expected documents to be returned by the search; use -1 to indicate that an error should have occurred.
 * @throws Exception
 */
private void assertSearchableAttributeMultiplesWork(DocumentType docType, String principalId, String fieldDefKey, String[][] searchValues,
		int[] resultSizes) throws Exception {
    DocumentSearchCriteria.Builder criteria = null;
    DocumentSearchResults results = null;
    DocumentSearchService docSearchService = KEWServiceLocator.getDocumentSearchService();
    for (int i = 0; i < resultSizes.length; i++) {
        criteria = DocumentSearchCriteria.Builder.create();
    	criteria.setDocumentTypeName(docType.getName());
    	addSearchableAttribute(criteria, fieldDefKey, searchValues[i]);
    	try {
            results = docSearchService.lookupDocuments(principalId, criteria.build());
            if (resultSizes[i] < 0) {
    			fail(fieldDefKey + "'s search at loop index " + i + " should have thrown an exception");
    		}
    		if(resultSizes[i] != results.getSearchResults().size()){
    			assertEquals(fieldDefKey + "'s search results at loop index " + i + " returned the wrong number of documents.", resultSizes[i], results.getSearchResults().size());
    		}
    	} catch (Exception ex) {
    		if (resultSizes[i] >= 0) {
    			fail(fieldDefKey + "'s search at loop index " + i + " should not have thrown an exception");
    		}
    	}
    	GlobalVariables.clear();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:SearchableAttributeTest.java

示例3: documentExists

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DocumentService#documentExists(java.lang.String)
 */
@Override
public boolean documentExists(String documentHeaderId) {
    // validate parameters
    if (StringUtils.isBlank(documentHeaderId)) {
        throw new IllegalArgumentException("invalid (blank) documentHeaderId");
    }

    boolean internalUserSession = false;
    try {
        // KFSMI-2543 - allowed method to run without a user session so it can be used
        // by workflow processes
        if (GlobalVariables.getUserSession() == null) {
            internalUserSession = true;
            GlobalVariables.setUserSession(new UserSession(KRADConstants.SYSTEM_USER));
            GlobalVariables.clear();
        }

        // look for workflowDocumentHeader, since that supposedly won't break the transaction
        if (getWorkflowDocumentService().workflowDocumentExists(documentHeaderId)) {
            // look for docHeaderId, since that fails without breaking the transaction
            return documentHeaderService.getDocumentHeaderById(documentHeaderId) != null;
        }

        return false;
    } finally {
        // if a user session was established for this call, clear it our
        if (internalUserSession) {
            GlobalVariables.clear();
            GlobalVariables.setUserSession(null);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:DocumentServiceImpl.java

示例4: getByDocumentHeaderId

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * This is temporary until workflow 2.0 and reads from a table to get documents whose status has changed to A
 * (approved - no
 * outstanding approval actions requested)
 *
 * @param documentHeaderId
 * @return Document
 * @throws WorkflowException
 */
@Override
public Document getByDocumentHeaderId(String documentHeaderId) throws WorkflowException {
    if (documentHeaderId == null) {
        throw new IllegalArgumentException("invalid (null) documentHeaderId");
    }
    boolean internalUserSession = false;
    try {
        // KFSMI-2543 - allowed method to run without a user session so it can be used
        // by workflow processes
        if (GlobalVariables.getUserSession() == null) {
            internalUserSession = true;
            GlobalVariables.setUserSession(new UserSession(KRADConstants.SYSTEM_USER));
            GlobalVariables.clear();
        }

     WorkflowDocument workflowDocument = null;

        if (LOG.isDebugEnabled()) {
            LOG.debug("Retrieving doc id: " + documentHeaderId + " from workflow service.");
        }
        workflowDocument = getWorkflowDocumentService()
                .loadWorkflowDocument(documentHeaderId, GlobalVariables.getUserSession().getPerson());
        UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), workflowDocument);

     Class<? extends Document> documentClass = getDocumentClassByTypeName(workflowDocument.getDocumentTypeName());

        // retrieve the Document
     Document document = getLegacyDataAdapter().findByDocumentHeaderId(documentClass, documentHeaderId);
        return postProcessDocument(documentHeaderId, workflowDocument, document);
    } finally {
        // if a user session was established for this call, clear it out
        if (internalUserSession) {
            GlobalVariables.clear();
            GlobalVariables.setUserSession(null);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:47,代码来源:DocumentServiceImpl.java

示例5: processPreprocess

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * This overridden method ...
 * 
 * @see org.apache.struts.action.RequestProcessor#processPreprocess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
protected boolean processPreprocess(HttpServletRequest request,
		HttpServletResponse response) {
	final UserSession session = KRADUtils.getUserSessionFromRequest(request);

       if (session == null) {
           throw new IllegalStateException("the user session has not been established");
       }

       GlobalVariables.setUserSession(session);
       GlobalVariables.clear();
	return super.processPreprocess(request, response);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:KSBStrutsRequestProcessor.java

示例6: assertSearchableAttributeWildcardsWork

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * A convenience method for testing wildcards on searchable attributes.
 *
 * @param docType The document type containing the attributes.
 * @param principalId The ID of the user performing the search.
 * @param fieldDefKey The name of the field given by the field definition on the searchable attribute.
 * @param searchValues The wildcard-filled search strings to test.
 * @param resultSizes The number of expected documents to be returned by the search; use -1 to indicate that an error should have occurred.
 * @throws Exception
 */
private void assertSearchableAttributeWildcardsWork(DocumentType docType, String principalId, String fieldDefKey, String[] searchValues,
		int[] resultSizes) throws Exception {
	DocumentSearchCriteria.Builder criteria = null;
    DocumentSearchResults results = null;
    DocumentSearchService docSearchService = KEWServiceLocator.getDocumentSearchService();
    for (int i = 0; i < resultSizes.length; i++) {
    	criteria = DocumentSearchCriteria.Builder.create();
    	criteria.setDocumentTypeName(docType.getName());
    	addSearchableAttribute(criteria, fieldDefKey, searchValues[i]);
    	try {
    		results = docSearchService.lookupDocuments(principalId, criteria.build());
    		if (resultSizes[i] < 0) {
    			fail(fieldDefKey + "'s search at loop index " + i + " should have thrown an exception");
    		}
    		if(resultSizes[i] != results.getSearchResults().size()){
    			assertEquals(fieldDefKey + "'s search results at loop index " + i + " returned the wrong number of documents.", resultSizes[i], results.getSearchResults().size());
    		}
    	} catch (Exception ex) {
    		if (resultSizes[i] >= 0) {
                ex.printStackTrace();
    			fail(fieldDefKey + "'s search at loop index " + i + " should not have thrown an exception");
    		}
    	}
    	GlobalVariables.clear();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:37,代码来源:SearchableAttributeTest.java

示例7: assertDDSearchableAttributesWork

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * A convenience method for testing wildcards on data dictionary searchable attributes.
 *
 * @param docType The document type containing the attributes.
 * @param principalId The ID of the user performing the search.
 * @param fieldName The name of the field on the test document.
 * @param searchValues The search expressions to test. Has to be a String array (for regular fields) or a String[] array (for multi-select fields).
 * @param resultSizes The number of expected documents to be returned by the search; use -1 to indicate that an error should have occurred.
 * @throws Exception
 */
private void assertDDSearchableAttributesWork(DocumentType docType, String principalId, String fieldName, Object[] searchValues,
		int[] resultSizes) throws Exception {
	if (!(searchValues instanceof String[]) && !(searchValues instanceof String[][])) {
		throw new IllegalArgumentException("'searchValues' parameter has to be either a String[] or a String[][]");
	}
	DocumentSearchCriteria.Builder criteria = null;
    DocumentSearchResults results = null;
    DocumentSearchService docSearchService = KEWServiceLocator.getDocumentSearchService();
    for (int i = 0; i < resultSizes.length; i++) {
    	criteria = DocumentSearchCriteria.Builder.create();
    	criteria.setDocumentTypeName(docType.getName());
    	criteria.addDocumentAttributeValue(fieldName, searchValues[i].toString());
    	try {
    		results = docSearchService.lookupDocuments(principalId, criteria.build());
    		if (resultSizes[i] < 0) {
    			Assert.fail(fieldName + "'s search at loop index " + i + " should have thrown an exception");
    		}
    		if(resultSizes[i] != results.getSearchResults().size()){
    			assertEquals(fieldName + "'s search results at loop index " + i + " returned the wrong number of documents.", resultSizes[i], results.getSearchResults().size());
    		}
    	} catch (Exception ex) {
    		if (resultSizes[i] >= 0) {
    			Assert.fail(fieldName + "'s search at loop index " + i + " should not have thrown an exception");
    		}
    	}
    	GlobalVariables.clear();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:39,代码来源:SearchAttributeIndexRequestTest.java

示例8: tearDownMockUserSession

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * Shut down the mock user session. When {@link #establishMockUserSession(String)} is used with
 * {@link Before}, then this method should be used with {@link After} to tear down resources.
 */
public static void tearDownMockUserSession() {
    GlobalVariables.setUserSession(null);
    GlobalVariables.clear();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:UifUnitTestUtils.java

示例9: testKradUifCollectionGroupBuilder

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
@Test
public void testKradUifCollectionGroupBuilder() throws Throwable {
    UifUnitTestUtils.establishMockConfig(ObjectPropertyUtilsTest.class.getSimpleName());
    UifUnitTestUtils.establishMockUserSession("testuser");
    try {
        // Performance medium generates this property path:
        // newCollectionLines['newCollectionLines_'mediumCollection1'_.subList']

        // Below recreates the stack trace that ensued due to poorly escaped quotes,
        // and proves that the parser works around bad quoting in a manner similar to BeanWrapper 

        final CollectionGroupBuilder collectionGroupBuilder = new CollectionGroupBuilder();
        final CollectionTestForm form = new CollectionTestForm();
        CollectionTestItem item = new CollectionTestItem();
        item.setFoobar("barfoo");
        ObjectPropertyUtils.setPropertyValue(form, "foo.baz['foo_bar_'badquotes'_.foobar']", item);
        assertEquals("barfoo", form.foo.baz.get("foo_bar_'badquotes'_.foobar").foobar);

        final FormView view = new FormView();
        view.setFormClass(CollectionTestForm.class);
        view.setViewHelperService(new ViewHelperServiceImpl());
        view.setPresentationController(new ViewPresentationControllerBase());
        view.setAuthorizer(UifUnitTestUtils.getAllowMostViewAuthorizer());

        final CollectionGroup collectionGroup = new CollectionGroupBase();
        collectionGroup.setCollectionObjectClass(CollectionTestItem.class);
        collectionGroup.setAddLinePropertyName("addLineFoo");

        StackedLayoutManager layoutManager = new StackedLayoutManagerBase();
        Group lineGroupPrototype = new GroupBase();
        layoutManager.setLineGroupPrototype(lineGroupPrototype);
        collectionGroup.setLayoutManager(layoutManager);

        BindingInfo addLineBindingInfo = new BindingInfo();
        addLineBindingInfo.setBindingPath("foo.baz['foo_bar_'badquotes'_.foobar']");
        collectionGroup.setAddLineBindingInfo(addLineBindingInfo);

        BindingInfo collectionBindingInfo = new BindingInfo();
        collectionBindingInfo.setBindingPath("foo.bar");
        collectionGroup.setBindingInfo(collectionBindingInfo);

        ViewLifecycle.encapsulateLifecycle(view, form, null, new Runnable() {
            @Override
            public void run() {
                collectionGroupBuilder.build(view, form, (CollectionGroup) CopyUtils.copy(collectionGroup));
            }
        });
    } finally {
        GlobalVariables.setUserSession(null);
        GlobalVariables.clear();
        GlobalResourceLoader.stop();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:54,代码来源:ObjectPropertyUtilsTest.java

示例10: getDocumentsByListOfDocumentHeaderIds

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * The default implementation - this retrieves all documents by a list of documentHeader for a given class.
 *
 * @see org.kuali.rice.krad.service.DocumentService#getDocumentsByListOfDocumentHeaderIds(java.lang.Class,
 *      java.util.List)
 */
@Override
public List<Document> getDocumentsByListOfDocumentHeaderIds(Class<? extends Document> documentClass,
        List<String> documentHeaderIds) throws WorkflowException {
    // validate documentHeaderIdList and contents
    if (documentHeaderIds == null) {
        throw new IllegalArgumentException("invalid (null) documentHeaderId list");
    }
    int index = 0;
    for (String documentHeaderId : documentHeaderIds) {
        if (StringUtils.isBlank(documentHeaderId)) {
            throw new IllegalArgumentException("invalid (blank) documentHeaderId at list index " + index);
        }
        index++;
    }

    boolean internalUserSession = false;
    try {
        // KFSMI-2543 - allowed method to run without a user session so it can be used
        // by workflow processes
        if (GlobalVariables.getUserSession() == null) {
            internalUserSession = true;
            GlobalVariables.setUserSession(new UserSession(KRADConstants.SYSTEM_USER));
            GlobalVariables.clear();
        }

        // retrieve all documents that match the document header ids
        List<? extends Document> rawDocuments = getLegacyDataAdapter().findByDocumentHeaderIds(documentClass,
                documentHeaderIds);

     // post-process them
     List<Document> documents = new ArrayList<Document>();
     for (Document document : rawDocuments) {
         WorkflowDocument workflowDocument = getWorkflowDocumentService().loadWorkflowDocument(document.getDocumentNumber(), GlobalVariables.getUserSession().getPerson());

            document = postProcessDocument(document.getDocumentNumber(), workflowDocument, document);
            documents.add(document);
        }
        return documents;
    } finally {
        // if a user session was established for this call, clear it our
        if (internalUserSession) {
            GlobalVariables.clear();
            GlobalVariables.setUserSession(null);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:53,代码来源:DocumentServiceImpl.java

示例11: clear

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
@Deprecated
public static void clear() {
    GlobalVariables.clear();
    messageLists.set(new MessageList());
    kualiForms.set(null);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:7,代码来源:KNSGlobalVariables.java

示例12: assertDDSearchableAttributeWildcardsWork

import org.kuali.rice.krad.util.GlobalVariables; //导入方法依赖的package包/类
/**
 * A convenience method for testing wildcards on data dictionary searchable attributes
 *
 * @param docType The document type containing the attributes.
 * @param principalId The ID of the user performing the search.
 * @param fieldName The name of the field on the test document.
 * @param searchValues The search expressions to test. Has to be a String array (for regular fields) or a String[] array (for multi-select fields).
 * @param resultSizes The number of expected documents to be returned by the search; use -1 to indicate that an error should have occurred.
 * @throws Exception
 */
private void assertDDSearchableAttributeWildcardsWork(DocumentType docType, String principalId, String fieldName, Object[] searchValues,
		int[] resultSizes) throws Exception {
	if (!(searchValues instanceof String[]) && !(searchValues instanceof String[][])) {
		throw new IllegalArgumentException("'searchValues' parameter has to be either a String[] or a String[][]");
	}
	DocumentSearchCriteria.Builder criteria = null;
    DocumentSearchResults results = null;
    DocumentSearchService docSearchService = KEWServiceLocator.getDocumentSearchService();
    for (int i = 0; i < resultSizes.length; i++) {
    	criteria = DocumentSearchCriteria.Builder.create();
    	criteria.setDocumentTypeName(docType.getName());
        if (searchValues instanceof String[][]) {
            String[] innerArray = (String[]) searchValues[i];
            for (int j=0; j<innerArray.length; j++) {
                criteria.addDocumentAttributeValue(fieldName, innerArray[j]);
            }
        } else {
            criteria.addDocumentAttributeValue(fieldName, searchValues[i].toString());
        }

    	try {
    		results = docSearchService.lookupDocuments(principalId, criteria.build());
    		if (resultSizes[i] < 0) {
    			Assert.fail(fieldName + "'s search at loop index " + i + " should have thrown an exception");
    		}
    		if(resultSizes[i] != results.getSearchResults().size()){
    			assertEquals(fieldName + "'s search results at loop index " + i + " returned the wrong number of documents.", resultSizes[i], results.getSearchResults().size());
    		}
    	} catch (Exception ex) {
    		if (resultSizes[i] >= 0) {
                LOG.error("exception", ex);
    			Assert.fail(fieldName
                        + "'s search at loop index "
                        + i
                        + " for search value '"
                        + searchValues[i]
                        + "' should not have thrown an exception");
    		}
    	}
    	GlobalVariables.clear();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:53,代码来源:DataDictionarySearchableAttributeTest.java


注:本文中的org.kuali.rice.krad.util.GlobalVariables.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。