Coverage Report - org.kuali.rice.kew.api.action.AdHocRevoke
 
Classes in this File Line Coverage Branch Coverage Complexity
AdHocRevoke
0%
0/30
0%
0/12
2.333
AdHocRevoke$Constants
0%
0/1
N/A
2.333
AdHocRevoke$Elements
0%
0/1
N/A
2.333
 
 1  
 /*
 2  
  * Copyright 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/ecl1.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.api.action;
 17  
 
 18  
 import java.util.Collection;
 19  
 import java.util.Collections;
 20  
 import java.util.Set;
 21  
 
 22  
 import javax.xml.bind.annotation.XmlAccessType;
 23  
 import javax.xml.bind.annotation.XmlAccessorType;
 24  
 import javax.xml.bind.annotation.XmlAnyElement;
 25  
 import javax.xml.bind.annotation.XmlElement;
 26  
 import javax.xml.bind.annotation.XmlElementWrapper;
 27  
 import javax.xml.bind.annotation.XmlRootElement;
 28  
 import javax.xml.bind.annotation.XmlType;
 29  
 
 30  
 import org.apache.commons.lang.StringUtils;
 31  
 import org.kuali.rice.core.api.CoreConstants;
 32  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 33  
 import org.w3c.dom.Element;
 34  
 
 35  
 @XmlRootElement(name = AdHocRevoke.Constants.ROOT_ELEMENT_NAME)
 36  
 @XmlAccessorType(XmlAccessType.NONE)
 37  
 @XmlType(name = AdHocRevoke.Constants.TYPE_NAME, propOrder = {
 38  
                 AdHocRevoke.Elements.NODE_NAMES,
 39  
                 AdHocRevoke.Elements.PRINCIPAL_IDS,
 40  
                 AdHocRevoke.Elements.GROUP_IDS,
 41  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 42  
 })
 43  
 public final class AdHocRevoke extends AbstractDataTransferObject {
 44  
 
 45  
         private static final long serialVersionUID = 5848714514445793355L;
 46  
         
 47  
         @XmlElementWrapper(name = Elements.NODE_NAMES, required = false)
 48  
         @XmlElement(name = Elements.NODE_NAME, required = false)
 49  
         private final Set<String> nodeNames;
 50  
         
 51  
         @XmlElementWrapper(name = Elements.PRINCIPAL_IDS, required = false)
 52  
         @XmlElement(name = Elements.PRINCIPAL_ID, required = false)
 53  
         private final Set<String> principalIds;
 54  
         
 55  
         @XmlElementWrapper(name = Elements.GROUP_IDS, required = false)
 56  
         @XmlElement(name = Elements.GROUP_ID, required = false)
 57  
         private final Set<String> groupIds;
 58  
                 
 59  0
     @SuppressWarnings("unused")
 60  
     @XmlAnyElement
 61  
     private final Collection<Element> _futureElements = null;
 62  
         
 63  
     /**
 64  
      * Private constructor used only by JAXB.
 65  
      */
 66  0
     private AdHocRevoke() {
 67  0
         this.nodeNames = null;
 68  0
         this.principalIds = null;
 69  0
         this.groupIds = null;
 70  0
     }
 71  
 
 72  
     
 73  0
     private AdHocRevoke(Set<String> nodeNames, Set<String> principalIds, Set<String> groupIds) {
 74  0
             this.nodeNames = nodeNames;
 75  0
             this.principalIds = principalIds;
 76  0
             this.groupIds = groupIds;
 77  0
     }
 78  
     
 79  
     public static AdHocRevoke create(Set<String> nodeNames, Set<String> principalIds, Set<String> groupIds) {
 80  0
             return new AdHocRevoke(nodeNames, principalIds, groupIds);
 81  
     }
 82  
     
 83  
     public static AdHocRevoke createRevokeFromPrincipal(String principalId) {
 84  0
             if (StringUtils.isBlank(principalId)) {
 85  0
                     throw new IllegalArgumentException("principalId was null or blank");
 86  
             }
 87  0
             return create(null, Collections.singleton(principalId), null);
 88  
     }
 89  
     
 90  
     public static AdHocRevoke createRevokeFromGroup(String groupId) {
 91  0
             if (StringUtils.isBlank(groupId)) {
 92  0
                     throw new IllegalArgumentException("groupId was null or blank");
 93  
             }
 94  0
             return create(null, null, Collections.singleton(groupId));
 95  
     }
 96  
     
 97  
     public static AdHocRevoke createRevokeAtNode(String nodeName) {
 98  0
             if (StringUtils.isBlank(nodeName)) {
 99  0
                     throw new IllegalArgumentException("nodeName was null or blank");
 100  
             }
 101  0
             return create(Collections.singleton(nodeName), null, null);
 102  
     }
 103  
     
 104  
         public Set<String> getNodeNames() {
 105  0
                 if (nodeNames == null) {
 106  0
                         return Collections.emptySet();
 107  
                 }
 108  0
                 return Collections.unmodifiableSet(nodeNames);
 109  
         }
 110  
         
 111  
         public Set<String> getPrincipalIds() {
 112  0
                 if (principalIds == null) {
 113  0
                         return Collections.emptySet();
 114  
                 }
 115  0
                 return Collections.unmodifiableSet(principalIds);
 116  
         }
 117  
         
 118  
         public Set<String> getGroupIds() {
 119  0
                 if (groupIds == null) {
 120  0
                         return Collections.emptySet();
 121  
                 }
 122  0
                 return Collections.unmodifiableSet(groupIds);
 123  
         }
 124  
         
 125  
         /**
 126  
      * Defines some internal constants used on this class.
 127  
      */
 128  0
     static class Constants {
 129  
         final static String ROOT_ELEMENT_NAME = "adHocRevoke";
 130  
         final static String TYPE_NAME = "AdHocRevokeType";
 131  
     }
 132  
     
 133  
     /**
 134  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 135  
      */
 136  0
     static class Elements {
 137  
             final static String NODE_NAMES = "nodeNames";
 138  
         final static String NODE_NAME = "nodeName";
 139  
         final static String PRINCIPAL_IDS = "principalIds";
 140  
         final static String PRINCIPAL_ID = "principalId";
 141  
         final static String GROUP_IDS = "groupIds";
 142  
         final static String GROUP_ID = "groupId";
 143  
     }
 144  
 
 145  
 }