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
{
29 DESCRIPTIONELEMENTBASE
,
38 MEDIAREPRESENTATIONPART
,
41 SPECIMENOROBSERVATIONBASE
,
42 SPECIMENTYPEDESIGNATION
,
56 * return the appropriate CdmPermissionClass for the given Object
59 * @return the CdmPermissionClass or null
61 public static CdmPermissionClass
getValueOf(CdmBase o
){
62 return CdmPermissionClass
.getValueOf(o
.getClass());
66 * return the appropriate CdmPermissionClass for the given Object
69 * @return the CdmPermissionClass or null
71 public static CdmPermissionClass
getValueOf(Class o
){
73 CdmPermissionClass permissionClass
= _valueOf(o
);
74 if(permissionClass
== null) {
75 Logger
.getLogger(CdmPermissionClass
.class).error("Permission class support for " + o
+ " not implemented");
77 return permissionClass
;
87 protected static CdmPermissionClass
_valueOf(Class o
) {
89 String normalizedName
= o
.getSimpleName().toUpperCase();
90 return CdmPermissionClass
.valueOf(normalizedName
);
91 } catch(IllegalArgumentException e
){
92 if (CdmBase
.class.isAssignableFrom(o
)){
93 return _valueOf(o
.getSuperclass());