Revision d14347e9
Added by Andreas Kohlbecker over 6 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/CdmPermissionClass.java | ||
---|---|---|
30 | 30 |
TAXONNAME, |
31 | 31 |
TEAMORPERSONBASE, |
32 | 32 |
REGISTRATION, |
33 |
TYPEDESIGNATIONBASE;
|
|
33 |
SPECIMENOROBSERVATIONBASE;
|
|
34 | 34 |
|
35 | 35 |
/** |
36 | 36 |
* return the appropriate CdmPermissionClass for the given Object |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/voter/SpecimenOrObservationBaseVoter.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2014 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.voter; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
12 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author a.kohlbecker |
|
16 |
* @date Feb 24, 2014 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class SpecimenOrObservationBaseVoter extends CdmPermissionVoter { |
|
20 |
|
|
21 |
/* (non-Javadoc) |
|
22 |
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#getResponsibilityClass() |
|
23 |
*/ |
|
24 |
@Override |
|
25 |
public Class<? extends CdmBase> getResponsibilityClass() { |
|
26 |
return SpecimenOrObservationBase.class; |
|
27 |
} |
|
28 |
|
|
29 |
/* (non-Javadoc) |
|
30 |
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#isOrpahn(eu.etaxonomy.cdm.model.common.CdmBase) |
|
31 |
*/ |
|
32 |
@Override |
|
33 |
public boolean isOrpahn(CdmBase object) { |
|
34 |
// the permission to delete a SpecimenOrObservationBase is not granted on base of hierachical |
|
35 |
// permission propagation, therefore it is save to treat all entities as orphan. |
|
36 |
return true; |
|
37 |
} |
|
38 |
|
|
39 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/hibernate/permission/voter/TypeDesignationVoter.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2014 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.voter; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
12 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author a.kohlbecker |
|
16 |
* @date Feb 24, 2014 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class TypeDesignationVoter extends CdmPermissionVoter { |
|
20 |
|
|
21 |
/* (non-Javadoc) |
|
22 |
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#getResponsibilityClass() |
|
23 |
*/ |
|
24 |
@Override |
|
25 |
public Class<? extends CdmBase> getResponsibilityClass() { |
|
26 |
return TypeDesignationBase.class; |
|
27 |
} |
|
28 |
|
|
29 |
/* (non-Javadoc) |
|
30 |
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#isOrpahn(eu.etaxonomy.cdm.model.common.CdmBase) |
|
31 |
*/ |
|
32 |
@Override |
|
33 |
public boolean isOrpahn(CdmBase object) { |
|
34 |
if(object instanceof TypeDesignationBase){ |
|
35 |
TypeDesignationBase<?> typeDesignation = (TypeDesignationBase<?>)object; |
|
36 |
return typeDesignation.getTypifiedNames().isEmpty() && typeDesignation.getRegistrations().isEmpty(); |
|
37 |
} else { |
|
38 |
throw new RuntimeException("Invalid object type: " + object.getClass().getName()); |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibenate/permission/CdmPermissionClassTest.java | ||
---|---|---|
18 | 18 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
19 | 19 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
20 | 20 |
import eu.etaxonomy.cdm.model.description.TaxonNameDescription; |
21 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
|
22 | 21 |
import eu.etaxonomy.cdm.model.name.Rank; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.Registration; |
24 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
25 | 23 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
24 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
25 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
26 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
27 | 28 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
28 | 29 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
112 | 113 |
} |
113 | 114 |
|
114 | 115 |
@Test |
115 |
public void testTYPEDESIGNATION(){
|
|
116 |
public void testSPECIMENOROBSERVATIONBASE(){
|
|
116 | 117 |
Assert.assertEquals( |
117 |
CdmPermissionClass.TYPEDESIGNATIONBASE,
|
|
118 |
CdmPermissionClass.getValueOf(SpecimenTypeDesignation.NewInstance())
|
|
118 |
CdmPermissionClass.SPECIMENOROBSERVATIONBASE,
|
|
119 |
CdmPermissionClass.getValueOf(FieldUnit.NewInstance())
|
|
119 | 120 |
); |
120 | 121 |
Assert.assertEquals( |
121 |
CdmPermissionClass.TYPEDESIGNATIONBASE,
|
|
122 |
CdmPermissionClass.getValueOf(NameTypeDesignation.NewInstance())
|
|
122 |
CdmPermissionClass.SPECIMENOROBSERVATIONBASE,
|
|
123 |
CdmPermissionClass.getValueOf(DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit))
|
|
123 | 124 |
); |
124 | 125 |
} |
125 | 126 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/FirstDataInserter.java | ||
---|---|---|
88 | 88 |
new CdmAuthority(CdmPermissionClass.TAXONBASE, CREATE_READ_UPDATE_DELETE).toString(), |
89 | 89 |
new CdmAuthority(CdmPermissionClass.DESCRIPTIONBASE, CREATE_READ_UPDATE_DELETE).toString(), |
90 | 90 |
new CdmAuthority(CdmPermissionClass.DESCRIPTIONELEMENTBASE, CREATE_READ_UPDATE_DELETE).toString(), |
91 |
new CdmAuthority(CdmPermissionClass.TYPEDESIGNATIONBASE, CREATE_READ_UPDATE_DELETE).toString(),
|
|
91 |
new CdmAuthority(CdmPermissionClass.SPECIMENOROBSERVATIONBASE, CREATE_READ_UPDATE_DELETE).toString(),
|
|
92 | 92 |
}; |
93 | 93 |
|
94 | 94 |
public static final String[] PROJECT_MANAGER_GROUP_AUTHORITIES = new String[]{ |
Also available in: Unified diff
ref #7018 ref #7016 turning the not needed TypeDesignationVoter into a SpecimenOrObservationBaseVoter