1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
29
30
31
32
33 public class GenericPermissionMaintainable extends KualiMaintainableImpl {
34
35 private static final Logger LOG = Logger.getLogger( GenericPermissionMaintainable.class );
36 private static final long serialVersionUID = -8102504656976243468L;
37
38
39
40
41
42
43 @Override
44 public void saveBusinessObject() {
45 try {
46 if ( LOG.isInfoEnabled() ) {
47 LOG.info( "Attempting to save GenericPermission BO via PermissionUpdateService: " + getBusinessObject() );
48 }
49 GenericPermission perm = (GenericPermission)getBusinessObject();
50
51 KIMServiceLocator.getPermissionUpdateService().savePermission( perm.getPermissionId(),
52 perm.getTemplateId(),
53 perm.getNamespaceCode(),
54 perm.getName(),
55 perm.getDescription(),
56 perm.isActive(),
57 perm.getDetails() );
58 } catch ( RuntimeException ex ) {
59 LOG.error( "Exception in saveBusinessObject()", ex );
60 throw ex;
61 }
62 }
63
64
65
66
67
68
69 @Override
70 public Class<? extends BusinessObject> getBoClass() {
71 return GenericPermission.class;
72 }
73
74
75
76
77
78
79 @Override
80 public boolean isExternalBusinessObject() {
81 return true;
82 }
83
84
85
86
87
88
89 @Override
90 public void prepareBusinessObject(BusinessObject businessObject) {
91 try {
92 if ( businessObject == null ) {
93 throw new RuntimeException( "Configuration ERROR: GenericPermissionMaintainable.prepareBusinessObject passed a null object." );
94 }
95 if ( businessObject instanceof PermissionImpl ) {
96 KimPermissionImpl perm = getBusinessObjectService().findBySinglePrimaryKey(KimPermissionImpl.class, ((PermissionImpl)businessObject).getPermissionId() );
97 businessObject = new GenericPermission( perm );
98 } else if ( businessObject instanceof GenericPermission ) {
99
100 KimPermissionImpl perm = getBusinessObjectService().findBySinglePrimaryKey(KimPermissionImpl.class, ((GenericPermission)businessObject).getPermissionId() );
101 ((GenericPermission)businessObject).loadFromKimPermission(perm);
102 } else {
103 throw new RuntimeException( "Configuration ERROR: GenericPermissionMaintainable passed an unsupported object type: " + businessObject.getClass() );
104 }
105 if ( businessObject instanceof PersistableBusinessObject ) {
106 setBusinessObject( (PersistableBusinessObject)businessObject );
107 }
108 super.prepareBusinessObject(businessObject);
109 } catch ( RuntimeException ex ) {
110 LOG.error( "Exception in prepareBusinessObject()", ex );
111 throw ex;
112 }
113 }
114
115 }