2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
;
11 import org
.apache
.log4j
.Logger
;
13 import eu
.etaxonomy
.cdm
.model
.CdmBaseType
;
14 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
17 * see also {@link CdmBaseType}
20 * @author a.kohlbecker
23 public enum CdmPermissionClass
{
31 DESCRIPTIONELEMENTBASE
,
32 DESCRIPTIONELEMENTSOURCE
,
51 MEDIAREPRESENTATIONPART
,
57 NOMENCLATURALSTATUSTYPE
,
58 SPECIMENOROBSERVATIONBASE
,
59 SPECIMENTYPEDESIGNATION
,
75 * return the appropriate CdmPermissionClass for the given Object
78 * @return the CdmPermissionClass or null
80 public static CdmPermissionClass
getValueOf(CdmBase o
){
81 return CdmPermissionClass
.getValueOf(o
.getClass());
85 * return the appropriate CdmPermissionClass for the given Object
88 * @return the CdmPermissionClass or null
90 public static CdmPermissionClass
getValueOf(Class o
){
92 CdmPermissionClass permissionClass
= _valueOf(o
);
93 if(permissionClass
== null) {
94 Logger
.getLogger(CdmPermissionClass
.class).error("Permission class support for " + o
+ " not implemented");
96 return permissionClass
;
106 protected static CdmPermissionClass
_valueOf(Class o
) {
108 String normalizedName
= o
.getSimpleName().toUpperCase();
109 return CdmPermissionClass
.valueOf(normalizedName
);
110 } catch(IllegalArgumentException e
){
111 if (CdmBase
.class.isAssignableFrom(o
)){
112 return _valueOf(o
.getSuperclass());