1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.persistence.hibernate.permission;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.CdmBaseType;
|
12
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
13
|
|
14
|
/**
|
15
|
* see also {@link CdmBaseType}
|
16
|
*
|
17
|
* @author k.luther
|
18
|
* @author a.kohlbecker
|
19
|
* @date 06.07.2011
|
20
|
*/
|
21
|
public enum CdmPermissionClass {
|
22
|
USER,
|
23
|
DESCRIPTIONBASE,
|
24
|
DESCRIPTIONELEMENTBASE,
|
25
|
TAXONBASE,
|
26
|
ALL,
|
27
|
TAXONNODE,
|
28
|
CLASSIFICATION,
|
29
|
REFERENCE,
|
30
|
TAXONNAME,
|
31
|
TEAMORPERSONBASE,
|
32
|
REGISTRATION,
|
33
|
TYPEDESIGNATIONBASE;
|
34
|
|
35
|
/**
|
36
|
* return the appropriate CdmPermissionClass for the given Object
|
37
|
*
|
38
|
* @param o
|
39
|
* @return the CdmPermissionClass or null
|
40
|
*/
|
41
|
public static CdmPermissionClass getValueOf(CdmBase o){
|
42
|
return CdmPermissionClass.getValueOf(o.getClass());
|
43
|
}
|
44
|
|
45
|
|
46
|
|
47
|
/**
|
48
|
* return the appropriate CdmPermissionClass for the given Object
|
49
|
*
|
50
|
* @param o
|
51
|
* @return the CdmPermissionClass or null
|
52
|
*/
|
53
|
public static CdmPermissionClass getValueOf(Class o){
|
54
|
|
55
|
try{
|
56
|
String normalizedName = o.getSimpleName().toUpperCase();
|
57
|
return CdmPermissionClass.valueOf(normalizedName);
|
58
|
} catch(IllegalArgumentException e){
|
59
|
if (CdmBase.class.isAssignableFrom(o)){
|
60
|
return getValueOf(o.getSuperclass());
|
61
|
}
|
62
|
|
63
|
}
|
64
|
|
65
|
return null;
|
66
|
}
|
67
|
}
|