Coverage Report - org.kuali.rice.kim.document.GenericPermissionMaintainable
 
Classes in this File Line Coverage Branch Coverage Complexity
GenericPermissionMaintainable
0%
0/31
0%
0/10
3.75
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.kim.document;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.kim.bo.impl.GenericPermission;
 20  
 import org.kuali.rice.kim.bo.impl.PermissionImpl;
 21  
 import org.kuali.rice.kim.bo.role.impl.KimPermissionImpl;
 22  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 23  
 import org.kuali.rice.kns.bo.BusinessObject;
 24  
 import org.kuali.rice.kns.bo.PersistableBusinessObject;
 25  
 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
 26  
 
 27  
 /**
 28  
  * This is a description of what this class does - jonathan don't forget to fill this in. 
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  0
 public class GenericPermissionMaintainable extends KualiMaintainableImpl {
 34  
 
 35  0
         private static final Logger LOG = Logger.getLogger( GenericPermissionMaintainable.class );        
 36  
         private static final long serialVersionUID = -8102504656976243468L;
 37  
 
 38  
         /**
 39  
          * Saves the responsibility via the responsibility update service
 40  
          * 
 41  
          * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#saveBusinessObject()
 42  
          */
 43  
         @Override
 44  
         public void saveBusinessObject() {
 45  
                 try {
 46  0
                         if ( LOG.isInfoEnabled() ) {
 47  0
                                 LOG.info( "Attempting to save GenericPermission BO via PermissionUpdateService: " + getBusinessObject() );
 48  
                         }
 49  0
                         GenericPermission perm = (GenericPermission)getBusinessObject();
 50  
                         
 51  0
                         KIMServiceLocator.getPermissionUpdateService().savePermission( perm.getPermissionId(), 
 52  
                                         perm.getTemplateId(),
 53  
                                         perm.getNamespaceCode(), 
 54  
                                         perm.getName(), 
 55  
                                         perm.getDescription(), 
 56  
                                         perm.isActive(), 
 57  
                                         perm.getDetails() );
 58  0
                 } catch ( RuntimeException ex ) {
 59  0
                         LOG.error( "Exception in saveBusinessObject()", ex );
 60  0
                         throw ex;
 61  0
                 }
 62  0
         }
 63  
         
 64  
         /**
 65  
          * This overridden method ...
 66  
          * 
 67  
          * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#getBoClass()
 68  
          */
 69  
         @Override
 70  
         public Class<? extends BusinessObject> getBoClass() {
 71  0
                 return GenericPermission.class;
 72  
         }
 73  
         
 74  
         /**
 75  
          * This overridden method ...
 76  
          * 
 77  
          * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#isExternalBusinessObject()
 78  
          */
 79  
         @Override
 80  
         public boolean isExternalBusinessObject() {
 81  0
                 return true;
 82  
         }
 83  
         
 84  
         /**
 85  
          * This overridden method ...
 86  
          * 
 87  
          * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#prepareBusinessObject(org.kuali.rice.kns.bo.BusinessObject)
 88  
          */
 89  
         @Override
 90  
         public void prepareBusinessObject(BusinessObject businessObject) {
 91  
                 try {
 92  0
                         if ( businessObject == null ) {
 93  0
                                 throw new RuntimeException( "Configuration ERROR: GenericPermissionMaintainable.prepareBusinessObject passed a null object." );
 94  
                         }
 95  0
                         if ( businessObject instanceof PermissionImpl ) {
 96  0
                                 KimPermissionImpl perm = getBusinessObjectService().findBySinglePrimaryKey(KimPermissionImpl.class, ((PermissionImpl)businessObject).getPermissionId() );
 97  0
                                 businessObject = new GenericPermission( perm );
 98  0
                         } else if ( businessObject instanceof GenericPermission ) {
 99  
                                 // lookup the KimResponsibilityImpl and convert to a ReviewResponsibility
 100  0
                                 KimPermissionImpl perm = getBusinessObjectService().findBySinglePrimaryKey(KimPermissionImpl.class, ((GenericPermission)businessObject).getPermissionId() );                
 101  0
                                 ((GenericPermission)businessObject).loadFromKimPermission(perm);
 102  0
                         } else {
 103  0
                                 throw new RuntimeException( "Configuration ERROR: GenericPermissionMaintainable passed an unsupported object type: " + businessObject.getClass() );
 104  
                         }
 105  0
                         if ( businessObject instanceof PersistableBusinessObject ) {
 106  0
                                 setBusinessObject( (PersistableBusinessObject)businessObject );
 107  
                         }
 108  0
                         super.prepareBusinessObject(businessObject);
 109  0
                 } catch ( RuntimeException ex ) {
 110  0
                         LOG.error( "Exception in prepareBusinessObject()", ex );
 111  0
                         throw ex;
 112  0
                 }
 113  0
         }
 114  
         
 115  
 }