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.doctype.service.impl;
 
 
 import java.util.*;

Implementation of org.kuali.rice.kew.doctype.service.DocumentTypePermissionService that delegates all calls (based on the org.kuali.rice.kew.doctype.bo.DocumentType or org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue parameter to the method being called)
 
     private static final Logger LOG = Logger.getLogger(DocumentTypePermissionServiceAuthorizerImpl.class);

    
Arbitrary placeholder strings for Extension lookup. We are simply using the Extension loading convention to instantiate the DocumentTypeAuthorizor, so we do not need meaningful name or type parameters
 
     private static final String PLACEHOLDER_EXTENSION_NAME = "DocumenTypeAuthorizer";
     private static final String PLACEHOLDER_EXTENSION_TYPE = "DocumenTypeAuthorizer";

    
The default DocumentTypeAuthorizer implementation. Kept as a singleton for performance.
 
Load the KimDocumentTypeAuthorizer for the specified document, or default impl if custom impl is not specified

Parameters:
documentType the document type whose DocumentTypeAuthorizer to load
Returns:
a DocumentTypeAuthorizer impl
 
     protected DocumentTypeAuthorizer getDocumentTypeAuthorizer(DocumentType documentType) {
 
         if (documentType == null) {
             .warn("DocumentType is null, using default DocumentTypeAuthorizer impl: " + delegate.getClass());
         } else {
             String documentTypeAuthorizer = documentType.getAuthorizer();
 
             if (StringUtils.isNotBlank(documentTypeAuthorizer)) {
                 ExtensionDefinition extensionDef = ExtensionDefinition.Builder.create(documentTypeAuthorizer).build();
                 Object extension = ExtensionUtils.loadExtension(extensionDef);
 
                 if (extension == null) {
                     throw new WorkflowRuntimeException("Could not load DocumentTypeAuthorizer: " + documentTypeAuthorizer);
                 }
 
                 if (!DocumentTypeAuthorizer.class.isAssignableFrom(extension.getClass())) {
                     throw new WorkflowRuntimeException("DocumentType Authorizer '" + documentTypeAuthorizer + "' configured for document type '" + documentType.getName() + " does not implement " + DocumentTypeAuthorizer.class.getName());
                 }
 
                 delegate = (DocumentTypeAuthorizerextension;
             }
         }
 
         return delegate;
     }
 
     @Override
     public boolean canInitiate(String principalIdDocumentType documentType) {
         return getDocumentTypeAuthorizer(documentType).isActionAuthorized(new AuthorizableAction(..), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(documentType).build(), null.).isAuthorized();
     }
 
     @Override
     public boolean canBlanketApprove(String principalIdDocumentRouteHeaderValue document) {
         validateDocument(document);
         return getDocumentTypeAuthorizer(document.getDocumentType()).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(document.getDocumentType()).build(), Document.Builder.create(document).build(), .).isAuthorized();
     }
 
    @Override
    public boolean canCancel(String principalIdDocumentRouteHeaderValue document) {
        validateDocument(document);
        return getDocumentTypeAuthorizer(document.getDocumentType()).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(document.getDocumentType()).build(), Document.Builder.create(document).build(), .).isAuthorized();
    }
    @Override
    public boolean canRecall(String principalIdDocumentRouteHeaderValue document) {
        validateDocument(document);
        return getDocumentTypeAuthorizer(document.getDocumentType()).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(document.getDocumentType()).build(), Document.Builder.create(document).build(), .).isAuthorized();
    }
    @Override
    public boolean canSave(String principalIdDocumentRouteHeaderValue document) {
        validateDocument(document);
        return getDocumentTypeAuthorizer(document.getDocumentType()).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(document.getDocumentType()).build(), Document.Builder.create(document).build(), .).isAuthorized();
    }
    @Override
    public boolean canRoute(String principalIdDocumentRouteHeaderValue document) {
        validateDocument(document);
        return getDocumentTypeAuthorizer(document.getDocumentType()).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(document.getDocumentType()).build(), Document.Builder.create(document).build(), .).isAuthorized();
    }
    @Override
    public boolean canSuperUserApproveDocument(String principalIdDocumentType documentTypeCollection<StringrouteNodeNamesString routeStatusCode) {
        actionParams.put(..routeNodeNames);
        actionParams.put(..routeStatusCode);
        return getDocumentTypeAuthorizer(documentType).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(documentType).build(), nullactionParams).isAuthorized();
    }
    @Override
    public boolean canSuperUserDisapproveDocument(String principalIdDocumentType documentTypeCollection<StringrouteNodeNamesString routeStatusCode) {
        actionParams.put(..routeNodeNames);
        actionParams.put(..routeStatusCode);
        return getDocumentTypeAuthorizer(documentType).isActionAuthorized(new AuthorizableAction(.), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(documentType).build(), nullactionParams).isAuthorized();
    }
    @Override
    protected boolean canSuperUserApproveSingleActionRequest(String principalIdDocumentType documentTypeCollection<StringrouteNodeNamesString routeStatusCode) {
        actionParams.put(..routeNodeNames);
        actionParams.put(..routeStatusCode);
        return getDocumentTypeAuthorizer(documentType).isActionAuthorized(new AuthorizableAction(..), principalId, org.kuali.rice.kew.api.doctype.DocumentType.Builder.create(documentType).build(), nullactionParams).isAuthorized();
    }
New to GrepCode? Check out our FAQ X