Coverage Report - org.kuali.rice.kew.framework.document.security.DocumentSecurityDirective
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentSecurityDirective
0%
0/14
0%
0/2
1.4
DocumentSecurityDirective$Constants
0%
0/1
N/A
1.4
DocumentSecurityDirective$Elements
0%
0/1
N/A
1.4
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.framework.document.security;
 17  
 
 18  
 import org.apache.commons.collections.CollectionUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.ModelObjectUtils;
 21  
 import org.kuali.rice.kew.api.document.Document;
 22  
 import org.w3c.dom.Element;
 23  
 
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlAnyElement;
 27  
 import javax.xml.bind.annotation.XmlElement;
 28  
 import javax.xml.bind.annotation.XmlElementWrapper;
 29  
 import javax.xml.bind.annotation.XmlRootElement;
 30  
 import javax.xml.bind.annotation.XmlType;
 31  
 import java.util.Collection;
 32  
 import java.util.List;
 33  
 
 34  
 /**
 35  
  * Defines a directive for processing a list of security attributes against a supplied list of documents.  The names of
 36  
  * these security attributes represent the name of an {@link org.kuali.rice.kew.api.extension.ExtensionDefinition} which
 37  
  * will be used to load the appropriate {@link DocumentSecurityAttribute} implementation in order to perform the security filtering.
 38  
  *
 39  
  * <p>The actual directive is supplied to the appropriate application that is responsible for the given security attributes
 40  
  * by invoking that applications {@link DocumentSecurityHandlerService}.  This class primarily functions as a form of
 41  
  * data transport in order to package and send the required information.</p>
 42  
  *
 43  
  * @see DocumentSecurityAttribute
 44  
  * @see DocumentSecurityHandlerService
 45  
  * @see org.kuali.rice.kew.api.extension.ExtensionDefinition
 46  
  */
 47  
 @XmlRootElement(name = DocumentSecurityDirective.Constants.ROOT_ELEMENT_NAME)
 48  
 @XmlAccessorType(XmlAccessType.NONE)
 49  
 @XmlType(name = DocumentSecurityDirective.Constants.TYPE_NAME, propOrder = {
 50  
     DocumentSecurityDirective.Elements.DOCUMENT_SECURITY_ATTRIBUTE_NAMES,
 51  
     DocumentSecurityDirective.Elements.DOCUMENTS,
 52  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 53  
 })
 54  
 public final class DocumentSecurityDirective {
 55  
 
 56  
     @XmlElementWrapper(name = Elements.DOCUMENT_SECURITY_ATTRIBUTE_NAMES, required = true)
 57  
     @XmlElement(name = Elements.DOCUMENT_SECURITY_ATTRIBUTE_NAME, required = true)
 58  
     private final List<String> documentSecurityAttributeNames;
 59  
 
 60  
     @XmlElementWrapper(name = Elements.DOCUMENTS, required = true)
 61  
     @XmlElement(name = Elements.DOCUMENT, required = true)
 62  
     private final List<Document> documents;
 63  
 
 64  0
     @SuppressWarnings("unused")
 65  
     @XmlAnyElement
 66  
     private final Collection<Element> _futureElements = null;
 67  
 
 68  
     /**
 69  
      * Private constructor used only by JAXB.
 70  
      */
 71  
     @SuppressWarnings("unused")
 72  0
     private DocumentSecurityDirective() {
 73  0
         this.documentSecurityAttributeNames = null;
 74  0
         this.documents = null;
 75  0
     }
 76  
 
 77  0
     private DocumentSecurityDirective(List<String> documentSecurityAttributeNames, List<Document> documents) {
 78  0
         if (CollectionUtils.isEmpty(documentSecurityAttributeNames)) {
 79  0
             throw new IllegalArgumentException("documentSecurityAttributeNames cannot be null or empty");
 80  
         }
 81  0
         this.documentSecurityAttributeNames = ModelObjectUtils.createImmutableCopy(documentSecurityAttributeNames);
 82  0
         this.documents = ModelObjectUtils.createImmutableCopy(documents);
 83  0
     }
 84  
 
 85  
     /**
 86  
      * Creates a new security directive from the given list of document secruity attribute names and documents.
 87  
      *
 88  
      * @param documentSecurityAttributeNames the list of document security attribute names with which to create this
 89  
      * security directive
 90  
      * @param documents the list of documents with which to create this security directive
 91  
      *
 92  
      * @return a new document security directive instance
 93  
      *
 94  
      * @throws IllegalArgumentException if the given list of security attribute names is null or empty
 95  
      */
 96  
     public static DocumentSecurityDirective create(List<String> documentSecurityAttributeNames,
 97  
             List<Document> documents) {
 98  0
         return new DocumentSecurityDirective(documentSecurityAttributeNames, documents);
 99  
     }
 100  
 
 101  
     /**
 102  
      * Returns the list of document security attribute names on this security directive.  Will never return a null or
 103  
      * empty list.
 104  
      *
 105  
      * @return the list of document security attribute names on this security directive
 106  
      */
 107  
     public List<String> getDocumentSecurityAttributeNames() {
 108  0
         return documentSecurityAttributeNames;
 109  
     }
 110  
 
 111  
     /**
 112  
      * Returns the list of documents on this security directive.  Will never return null, but may return an empty list.
 113  
      *
 114  
      * @return the list of documents on this security directive
 115  
      */
 116  
     public List<Document> getDocuments() {
 117  0
         return documents;
 118  
     }
 119  
 
 120  
     /**
 121  
      * Defines some internal constants used on this class.
 122  
      */
 123  0
     static class Constants {
 124  
         final static String ROOT_ELEMENT_NAME = "documentSecurityDirective";
 125  
         final static String TYPE_NAME = "DocumentSecurityDirectiveType";
 126  
     }
 127  
 
 128  
     /**
 129  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 130  
      */
 131  0
     static class Elements {
 132  
         final static String DOCUMENT_SECURITY_ATTRIBUTE_NAMES = "documentSecurityAttributeNames";
 133  
         final static String DOCUMENT_SECURITY_ATTRIBUTE_NAME = "documentSecurityAttributeName";
 134  
         final static String DOCUMENTS = "documents";
 135  
         final static String DOCUMENT = "document";
 136  
     }
 137  
 
 138  
 }