Coverage Report - org.kuali.rice.kim.impl.jaxb.PermissionsXmlDTO
 
Classes in this File Line Coverage Branch Coverage Complexity
PermissionsXmlDTO
0%
0/22
0%
0/2
1.444
 
 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.kim.impl.jaxb;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.xml.bind.Marshaller;
 22  
 import javax.xml.bind.UnmarshalException;
 23  
 import javax.xml.bind.Unmarshaller;
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlElement;
 27  
 import javax.xml.bind.annotation.XmlType;
 28  
 
 29  
 import org.kuali.rice.core.util.jaxb.RiceXmlExportList;
 30  
 import org.kuali.rice.core.util.jaxb.RiceXmlImportList;
 31  
 import org.kuali.rice.core.util.jaxb.RiceXmlListAdditionListener;
 32  
 import org.kuali.rice.core.util.jaxb.RiceXmlListGetterListener;
 33  
 import org.kuali.rice.kim.api.permission.PermissionContract;
 34  
 
 35  
 /**
 36  
  * This class represents a <permissions> element. 
 37  
  * 
 38  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 39  
  */
 40  0
 @XmlAccessorType(XmlAccessType.FIELD)
 41  
 @XmlType(name="PermissionsType", propOrder={"permissions"})
 42  
 public class PermissionsXmlDTO implements RiceXmlListAdditionListener<PermissionXmlDTO>,
 43  
         RiceXmlListGetterListener<PermissionXmlDTO,Object>, Serializable {
 44  
     
 45  
     private static final long serialVersionUID = 1L;
 46  
     
 47  
     @XmlElement(name="permission")
 48  
     private List<PermissionXmlDTO> permissions;
 49  
     
 50  0
     public PermissionsXmlDTO() {}
 51  
     
 52  0
     public PermissionsXmlDTO(List<? extends Object> permissionsToExport) {
 53  0
         this.permissions = new RiceXmlExportList<PermissionXmlDTO,Object>(permissionsToExport, this);
 54  0
     }
 55  
     
 56  
     /**
 57  
      * @return the permissions
 58  
      */
 59  
     public List<PermissionXmlDTO> getPermissions() {
 60  0
         return this.permissions;
 61  
     }
 62  
 
 63  
     /**
 64  
      * @param permissions the permissions to set
 65  
      */
 66  
     public void setPermissions(List<PermissionXmlDTO> permissions) {
 67  0
         this.permissions = permissions;
 68  0
     }
 69  
 
 70  
     void beforeUnmarshal(Unmarshaller unmarshaller, Object parent) {
 71  0
         permissions = new RiceXmlImportList<PermissionXmlDTO>(this);
 72  0
     }
 73  
     
 74  
     void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
 75  0
         permissions = null;
 76  0
     }
 77  
     
 78  
     public void newItemAdded(PermissionXmlDTO item) {
 79  
         try {
 80  0
             PermissionXmlUtil.validateAndPersistNewPermission(item);
 81  0
         } catch (UnmarshalException e) {
 82  0
             throw new RuntimeException(e);
 83  0
         }
 84  0
     }
 85  
 
 86  
     void afterMarshal(Marshaller marshaller) {
 87  0
         permissions = null;
 88  0
     }
 89  
     
 90  
     public PermissionXmlDTO gettingNextItem(Object nextItem, int index) {
 91  0
         if (!(nextItem instanceof PermissionContract)) {
 92  0
             throw new IllegalStateException("Object for exportation should have been a permission");
 93  
         }
 94  0
         return new PermissionXmlDTO((PermissionContract) nextItem);
 95  
     }
 96  
 }