Project

General

Profile

Download (1.16 KB) Statistics
| Branch: | Tag: | Revision:
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.permission;
10

    
11
import eu.etaxonomy.cdm.model.common.CdmBase;
12

    
13
/**
14
 * @author k.luther
15
 * @date 06.07.2011
16
 */
17
public enum CdmPermissionClass {
18
	USER, TAXONNODE, DESCRIPTIONBASE, DESCRIPTIONELEMENTBASE, TAXONBASE, ALL;
19
	
20
	
21
	public static CdmPermissionClass getValueOf(Object s){
22
		String permissionClassString ;
23
		if (s instanceof String){
24
			permissionClassString = (String)s;
25
		}else if (s instanceof CdmBase){
26
			permissionClassString = s.getClass().getSimpleName().toUpperCase(); 
27
		} else if(s instanceof Class){
28
			permissionClassString = ((Class) s).getSimpleName().toUpperCase();
29
		}else{
30
			
31
			return null;
32
		}
33
		try{
34
			return CdmPermissionClass.valueOf(permissionClassString);
35
		}catch(IllegalArgumentException e){
36
			if (s instanceof CdmBase){
37
				s = s.getClass().getSuperclass();
38
				
39
				return getValueOf(s);
40
			}
41
			
42
		}
43
		return null;
44
	}
45
}
(3-3/6)