Revision f0aad502
Added by Andreas Kohlbecker over 6 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/CdmAuthority.java | ||
---|---|---|
75 | 75 |
// Making sure that operation is always initialized, for both |
76 | 76 |
// - the string representation to have a '[]' |
77 | 77 |
// - and the object representation to never be null (with check in constructors) |
78 |
EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class);;
|
|
78 |
EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class); |
|
79 | 79 |
UUID targetUuid; |
80 | 80 |
|
81 |
public CdmAuthority(CdmBase targetDomainObject, EnumSet<CRUD> operation, UUID uuid){
|
|
81 |
public CdmAuthority(CdmBase targetDomainObject, EnumSet<CRUD> operation){ |
|
82 | 82 |
this.permissionClass = CdmPermissionClass.getValueOf(targetDomainObject); |
83 | 83 |
this.property = null; |
84 | 84 |
if(operation != null) { |
85 | 85 |
this.operation = operation; |
86 | 86 |
} |
87 |
this.targetUuid = uuid; |
|
87 |
if(targetDomainObject.getUuid() == null){ |
|
88 |
throw new NullPointerException("UUID of targetDomainObject is null. CDM entities need to be saved prior using this function"); |
|
89 |
} |
|
90 |
this.targetUuid = targetDomainObject.getUuid(); |
|
88 | 91 |
} |
89 | 92 |
|
90 | 93 |
public CdmAuthority(CdmBase targetDomainObject, String property, EnumSet<CRUD> operation, UUID uuid){ |
... | ... | |
96 | 99 |
this.targetUuid = uuid; |
97 | 100 |
} |
98 | 101 |
|
102 |
public CdmAuthority(Class<? extends CdmBase> targetDomainType, String property, EnumSet<CRUD> operation, UUID uuid){ |
|
103 |
this.permissionClass = CdmPermissionClass.getValueOf(targetDomainType); |
|
104 |
this.property = property; |
|
105 |
if(operation != null) { |
|
106 |
this.operation = operation; |
|
107 |
} |
|
108 |
this.targetUuid = uuid; |
|
109 |
} |
|
110 |
|
|
99 | 111 |
|
100 | 112 |
public CdmAuthority(CdmPermissionClass permissionClass, String property, EnumSet<CRUD> operation, UUID uuid){ |
101 | 113 |
this.permissionClass = permissionClass; |
Also available in: Unified diff
refactoring CdmPermissionEvaluator and CdmAuthoritiy for a more comprehensible API