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
.common
.CdmBase
;
16 * see also {@link CdmBaseType}
19 * @author a.kohlbecker
22 public enum CdmPermissionClass
{
25 DESCRIPTIONELEMENTBASE
,
35 SPECIMENOROBSERVATIONBASE
,
36 SPECIMENTYPEDESIGNATION
,
47 * return the appropriate CdmPermissionClass for the given Object
50 * @return the CdmPermissionClass or null
52 public static CdmPermissionClass
getValueOf(CdmBase o
){
53 return CdmPermissionClass
.getValueOf(o
.getClass());
57 * return the appropriate CdmPermissionClass for the given Object
60 * @return the CdmPermissionClass or null
62 public static CdmPermissionClass
getValueOf(Class o
){
64 CdmPermissionClass permissionClass
= _valueOf(o
);
65 if(permissionClass
== null) {
66 Logger
.getLogger(CdmPermissionClass
.class).error("Permission class support for " + o
+ " not implemented");
68 return permissionClass
;
78 protected static CdmPermissionClass
_valueOf(Class o
) {
80 String normalizedName
= o
.getSimpleName().toUpperCase();
81 return CdmPermissionClass
.valueOf(normalizedName
);
82 } catch(IllegalArgumentException e
){
83 if (CdmBase
.class.isAssignableFrom(o
)){
84 return _valueOf(o
.getSuperclass());