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