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 | 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 | |
|
40 | |
|
41 | |
|
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 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
@Override |
70 | |
public Class<? extends BusinessObject> getBoClass() { |
71 | 0 | return GenericPermission.class; |
72 | |
} |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
@Override |
80 | |
public boolean isExternalBusinessObject() { |
81 | 0 | return true; |
82 | |
} |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
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 | |
|
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 | |
} |