Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.impl.document.security;
 
 
 import java.util.List;
 import java.util.Map;

Reference implementation of the DocumentSecurityHandlerService.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 
 
     @Override
     public List<StringgetAuthorizedDocumentIds(String principalIdList<DocumentSecurityDirectivedocumentSecurityDirectives ) {
         if (StringUtils.isBlank(principalId)) {
             throw new RiceIllegalArgumentException("principalId was null or blank");
         }
         if (documentSecurityDirectives == null) {
             documentSecurityDirectives = Collections.emptyList();
         }
         List<StringauthorizedDocumentIds = new ArrayList<String>();
         Map<StringDocumentSecurityAttributesecurityAttributeCache = new HashMap<StringDocumentSecurityAttribute>();
         for (DocumentSecurityDirective documentSecurityDirective : documentSecurityDirectives) {
             List<DocumentSecurityAttributeattributesToApply = loadSecurityAttributes(documentSecurityDirectivesecurityAttributeCache);
             for (Document document : documentSecurityDirective.getDocuments()) {
                 // if it's already authorized, we don't need to do anything
                 if (!authorizedDocumentIds.contains(document.getDocumentId())) {
                     for (DocumentSecurityAttribute securityAttribute : attributesToApply) {
                         if (securityAttribute.isAuthorizedForDocument(principalIddocument)) {
                             authorizedDocumentIds.add(document.getDocumentId());
                             break;
                         }
                     }
                 }
             }
         }
         return authorizedDocumentIds;
     }
 
     protected List<DocumentSecurityAttributeloadSecurityAttributes(DocumentSecurityDirective documentSecurityDirective,
             Map<StringDocumentSecurityAttributesecurityAttributeCache) {
         List<DocumentSecurityAttributesecurityAttributes = new ArrayList<DocumentSecurityAttribute>();
         for (String documentSecurityAttributeName : documentSecurityDirective.getDocumentSecurityAttributeNames()) {
             securityAttributes.add(loadAndCacheSecurityAttribute(documentSecurityAttributeNamesecurityAttributeCache));
         }
         return securityAttributes;
     }
 
     protected DocumentSecurityAttribute loadAndCacheSecurityAttribute(String securityAttributeNameMap<StringDocumentSecurityAttributesecurityAttributeCache) {
         if (securityAttributeCache.containsKey(securityAttributeName)) {
             return securityAttributeCache.get(securityAttributeName);
         }
         ExtensionDefinition extensionDefinition = .getExtensionByName(securityAttributeName);
         if (extensionDefinition == null) {
             throw new RiceIllegalArgumentException("Failed to locate a SecurityAttribute with the given name: " + securityAttributeName);
         }
         DocumentSecurityAttribute securityAttribute = loadSecurityAttribute(extensionDefinition);
         securityAttributeCache.put(securityAttributeNamesecurityAttribute);
         return securityAttribute;
     }
 
     protected DocumentSecurityAttribute loadSecurityAttribute(ExtensionDefinition extensionDefinition) {
         Object securityAttribute = ExtensionUtils.loadExtension(extensionDefinition);
         if (securityAttribute == null) {
             throw new RiceIllegalArgumentException("Failed to load SecurityAttribute for: " + extensionDefinition);
         }
         return (DocumentSecurityAttribute)securityAttribute;
     }
 
        return ;
    }
    public void setExtensionRepositoryService(ExtensionRepositoryService extensionRepositoryService) {
        this. = extensionRepositoryService;
    }
New to GrepCode? Check out our FAQ X