cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/view/AuditEventDaoTest.java -text
+cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibenate/permission/CdmAuthorityTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CacheStrategyGeneratorTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CdmDeleteListenerTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/replace/ReferringObjectMetadataFactoryTest.java -text
<type>test-jar</type>
<scope>test</scope>
<version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>eu.etaxonomy</groupId>
- <artifactId>cdmlib-services</artifactId>
</dependency>
<dependency>
<groupId>eu.etaxonomy</groupId>
}\r
return 0;\r
}\r
+ \r
+ @Override\r
+ public boolean equals(Object o) {\r
+ if (o instanceof GrantedAuthority) {\r
+ if(this.authority == null && ((GrantedAuthority) o).getAuthority() == null) {\r
+ return true;\r
+ } else {\r
+ return this.authority.equals(((GrantedAuthority) o).getAuthority());\r
+ }\r
+ }\r
+ return false;\r
+ }\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.cdm.model.common.CdmBase#toString()\r
public EnumSet<CRUD> getOperation(){\r
return operation;\r
}\r
+ \r
+ public void setOperation(EnumSet<CRUD> operation) {\r
+ this.operation = operation;\r
+ }\r
\r
public UUID getTargetUUID(){\r
return targetUuid;\r
// \\.? -> .\r
// (?:(\\w*))(?:\\{([\\da-z\\-]+)\\})? -> Permmission and targetUuid\r
//\r
- String regex = "(\\w*)(?:\\((\\w*)\\))?\\.?(?:(\\w*))(?:\\{([\\da-z\\-]+)\\})?";\r
+ String regex = "(\\w*)(?:\\((\\w*)\\))?\\.?(?:\\[(\\D*)\\])?(?:\\{([\\da-z\\-]+)\\})?";\r
Pattern pattern = Pattern.compile(regex);\r
String[] tokens = new String[4];\r
logger.debug("parsing '" + authority + "'");\r
package eu.etaxonomy.cdm.persistence.hibernate.permission;\r
\r
import java.util.EnumSet;\r
+import java.util.StringTokenizer;\r
\r
\r
/**\r
if(string.equals("NONE")){\r
return NONE;\r
}\r
- return EnumSet.of(CRUD.valueOf(string));\r
+ StringTokenizer st = new StringTokenizer(string,","); \r
+ EnumSet<CRUD> op = EnumSet.noneOf(CRUD.class);\r
+\r
+ while (st.hasMoreElements()) {\r
+\r
+ String opStr = (String) st.nextElement(); \r
+ op.add(CRUD.valueOf(opStr.trim()));\r
+ }\r
+\r
+ return op;\r
}\r
\r
public static boolean isOperation(Object o){\r
cdmBase = Taxon.NewInstance(null, null);\r
cdmBase.setUuid(UUID.fromString("e463b270-c76b-11dd-ad8b-0800200c9a66"));\r
\r
- taxonEditorToken = new TestingAuthenticationToken("taxonEditor", "password", "TAXONBASE.CREATE", "TAXONBASE.UPDATE");\r
+ taxonEditorToken = new TestingAuthenticationToken("taxonEditor", "password", "TAXONBASE.[CREATE]", "TAXONBASE.[UPDATE]");\r
adminToken = new TestingAuthenticationToken("admin", "password", "ALL.ADMIN");\r
testerToken = new TestingAuthenticationToken("tester", "password");\r
\r
try{\r
cdmEntityDaoBase.save(cdmBase);\r
commitAndStartNewTransaction(null);\r
+ logger.error("Expected failure of evaluation.");\r
} catch (RuntimeException e){\r
- securityException = findSecurityRuntimeException(e);\r
- logger.error("Unexpected failure of evaluation.", securityException);\r
+ securityException = findSecurityRuntimeException(e); \r
} finally {\r
// needed in case saveOrUpdate was interrupted by the RuntimeException\r
// commitAndStartNewTransaction() would raise an UnexpectedRollbackException\r
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.persistence.hibenate.permission;
+
+import static org.junit.Assert.*;
+
+import java.util.EnumSet;
+import java.util.UUID;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.security.core.GrantedAuthority;
+
+import sun.security.provider.PolicyParser.ParsingException;
+
+import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionClass;
+
+/**
+ * @author c.mathew
+ * @created Mar 26, 2013
+ * @version 1.0
+ */
+public class CdmAuthorityTest {
+
+ private GrantedAuthorityImpl grantedAuthority;
+ private String authority;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ grantedAuthority = GrantedAuthorityImpl.NewInstance();
+ authority = "";
+ }
+
+ /**
+ * Test method for {@link eu.etaxonomy.cdm.persistence.hibernate.permission#getAuthority()}.
+ * @throws ParsingException
+ */
+ @Test
+ public final void testGetAuthority() throws ParsingException {
+ // create CdmAuthority object manually
+ CdmPermissionClass tnClass = CdmPermissionClass.TAXONBASE;
+ String property = "Taxon";
+ EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class);
+ operation.add(CRUD.READ);
+ operation.add(CRUD.UPDATE);
+ UUID uuid = UUID.fromString("e0358c98-4222-4d17-811c-7ce18bd565ee");
+ CdmAuthority cdma = new CdmAuthority(tnClass,property, operation, uuid);
+ String expectedAuthority = "TAXONBASE(Taxon).[READ, UPDATE]{e0358c98-4222-4d17-811c-7ce18bd565ee}";
+ System.out.println(cdma.getAuthority());
+ System.out.println(expectedAuthority);
+ // check object getAuthority with expectedAuthority
+ assertEquals(expectedAuthority, cdma.getAuthority());
+ //check programmatic generation of CdmAuthority by parsing authority string
+ cdma = CdmAuthority.fromGrantedAuthority(cdma);
+ assertEquals(expectedAuthority, cdma.getAuthority());
+ }
+
+
+
+}
+
<!-- create a timestamp for the whole going -->
<xsl:variable name="timestamp">
<xsl:value-of
- select="concat(year-from-date(current-date()),'-',month-from-date(current-date()),'-',day-from-date(current-date()),'T',hours-from-time(current-time()),':',minutes-from-time(current-time()),':00Z')"/>
-
+ select="concat(year-from-date(current-date()),'-',month-from-date(current-date()),'-',day-from-date(current-date()),'T',hours-from-time(current-time()),':',minutes-from-time(current-time()),':00Z')"
+ />
</xsl:variable>
+ <!-- create the username who changed/created the pages -->
+ <xsl:variable name="username">Sybille Test </xsl:variable>
+
<!-- this is the start template
it creates the mediawiki tag surounding and calls a template to create a page for
every taxon node TODO: and a category -->
<xsl:value-of select="$timestamp"/>
</timestamp>
<contributor>
- <username>Sybille Test</username>
+ <username>
+ <xsl:value-of select="$username"/>
+ </username>
</contributor>
<text xml:space="preserve">
+ <!-- add table of contents -->
<xsl:call-template name="TOC"/>
<!-- add taxo tree -->
<xsl:value-of select="concat('{{Taxo Tree|',$parent-title, '}}')"/>
+
+ <!-- add contents of taxon page -->
+ <xsl:apply-templates select="Taxon"/>
- <xsl:apply-templates select="Taxon"/>
+ <!-- put page to corresponding tax category -->
<xsl:value-of select="concat('[[Category:',$title, ']]')"/>
</text>
</revision>
<!-- we run this for the content of the page -->
<xsl:template match="Taxon" name="Taxon">
<xsl:apply-templates select="synonymy"/>
- <!--xsl:apply-templates select="synonymy"/-->
+ <xsl:apply-templates select="descriptions"/>
+
+
</xsl:template>
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xsl:text>
</xsl:text>
</xsl:template>
+ <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+ <!-- description features -->
+
+ <xsl:template match="descriptions" name="descriptions">
+ <xsl:for-each select="features/feature">
+ <xsl:choose>
+ <xsl:when test="count(feature)!=0">
+ <xsl:call-template name="secondLevelDescriptionElements"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- everything but Citation -->
+ <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
+ <xsl:call-template name="descriptionElements"/>
+ </xsl:if>
+ <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:template>
+
+ <!--.............................................-->
+
+ <xsl:template name="secondLevelDescriptionElements">
+
+ <xsl:value-of select="concat('{{Two_Leveled_Features_Title|',representation_L10n,'}}')"></xsl:value-of>
+
+ <xsl:for-each select="feature">
+ <xsl:value-of select="concat('{{Second_Level_Feature|Name=',representation_L10n,'|Elements=')"></xsl:value-of>
+ <!-- TODO create Element -->
+ <xsl:for-each select="descriptionelements/descriptionelement">
+ <xsl:value-of select="concat('{{Second_Level_Feature_DescrElement|',multilanguageText_L10n/text, '}}')"></xsl:value-of>
+ </xsl:for-each>
+ <xsl:text>}}</xsl:text>
+ </xsl:for-each>
+
+ </xsl:template>
+ <!--.............................................-->
+
+
+ <xsl:template name="descriptionElements">
+ <xsl:choose>
+ <xsl:when test="supportsCommonTaxonName='true'">
+ <!-- must be Vernacular Name feature -->
+ <xsl:call-template name="commonTaxonName"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- for example Habitat, Material Examined -->
+ <xsl:call-template name="textData"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!--.............................................-->
+
+ <xsl:template name="commonTaxonName">
+
+ <xsl:value-of select="concat('{{Tax_Feature|Name=',representation_L10n,'|Elements=')"/>
+ <xsl:for-each select="descriptionelements/descriptionelement">
+ <xsl:text/>
+ <xsl:value-of
+ select="concat('{{Common_Name_Feature_Element|Name=',name,'|Language=',language/representation_L10n,'}}')"
+ />
+ </xsl:for-each>
+ <xsl:text>}}</xsl:text>
+ </xsl:template>
+
+ <!--.............................................-->
+
+ <xsl:template name="textData">
+
+ <xsl:value-of
+ select="concat('{{Tax_Feature|Name=',representation_L10n, '|Elements={{Feature_Text|' )"/>
+ <xsl:choose>
+ <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'"> <!-- feature is not "Distribution" -->
+ <xsl:apply-templates
+ select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:text>}}}}</xsl:text>
+
+
+ <!-- LORNA TRY IMAGE HERE -->
+ <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
+
+
+ </xsl:template>
+
+ <!--.............................................-->
+
+
+ <xsl:template match="text">
+
+ <xsl:choose>
+ <xsl:when test="contains(.,"<b>")">
+ <xsl:call-template name="add-markup">
+ <xsl:with-param name="str" select="."/>
+ <!--xsl:with-param name="tag-name" select="b"/-->
+ <xsl:with-param name="tag-name">b</xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="add-markup">
+ <xsl:with-param name="str" select="."/>
+ <xsl:with-param name="tag-name">i</xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!--/fo:block -->
+ </xsl:template>
<!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
<PERMISSIONGROUP_GRANTEDAUTHORITYIMPL PERMISSIONGROUP_ID="3" GRANTEDAUTHORITIES_ID="10"/>\r
\r
\r
- <GRANTEDAUTHORITYIMPL ID="1" UUID="441a3c40-0c84-11de-8c30-0800200c9a66" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.READ"/>\r
- <GRANTEDAUTHORITYIMPL ID="2" UUID="14788361-1a7e-4eed-b22f-fd90a0b424ac" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.UPDATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="3" UUID="fa56073c-0ffd-4384-b459-b2f07e35b689" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.CREATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="4" UUID="e5354c0e-657b-4b4d-bb2f-791612199711" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.DELETE"/>\r
- <GRANTEDAUTHORITYIMPL ID="10" UUID="2fbcbdd4-97f0-4561-b635-1e479dd00375" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.ADMIN"/>\r
+ <GRANTEDAUTHORITYIMPL ID="1" UUID="441a3c40-0c84-11de-8c30-0800200c9a66" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.[READ]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="2" UUID="14788361-1a7e-4eed-b22f-fd90a0b424ac" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.[UPDATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="3" UUID="fa56073c-0ffd-4384-b459-b2f07e35b689" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.[CREATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="4" UUID="e5354c0e-657b-4b4d-bb2f-791612199711" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.[DELETE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="10" UUID="2fbcbdd4-97f0-4561-b635-1e479dd00375" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONBASE.[ADMIN]"/>\r
<GRANTEDAUTHORITYIMPL ID="5" UUID="9eabd2c6-0590-4a1e-95f5-99cc58b63aa7" CREATED="2009-02-03 17:52:26.0" AUTHORITY="ROLE_USER_MANAGER"/>\r
<GRANTEDAUTHORITYIMPL ID="14" UUID="56eac992-67ba-40be-896c-4e992ca2afc0" CREATED="2009-02-03 17:52:26.0" AUTHORITY="ROLE_ADMIN"/><!-- role prefix 'ROLE_' defined in RoleVoter !!! -->\r
- <GRANTEDAUTHORITYIMPL ID="7" UUID="2fc19d6c-a227-41d8-94e4-7c31accebc26" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONBASE.UPDATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="13" UUID="2883374b-9556-4f3b-9b17-08fdf3d4bba6" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONBASE.CREATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="11" UUID="fc8088cf-cf96-42b6-9aa5-7c1ec5ccf145" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONELEMENTBASE(Ecology).UPDATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="12" UUID="8d131171-d281-4911-a960-16992de384c7" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONELEMENTBASE(Ecology).CREATE"/>\r
- <GRANTEDAUTHORITYIMPL ID="8" UUID="45b40e93-88b0-40eb-92a4-ffdd8f1d7bc3" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}"/>\r
- <GRANTEDAUTHORITYIMPL ID="9" UUID="8696ef0f-e98c-4842-b9d2-456b82584c25" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONNODE.CREATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}"/>\r
+ <GRANTEDAUTHORITYIMPL ID="7" UUID="2fc19d6c-a227-41d8-94e4-7c31accebc26" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONBASE.[UPDATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="13" UUID="2883374b-9556-4f3b-9b17-08fdf3d4bba6" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONBASE.[CREATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="11" UUID="fc8088cf-cf96-42b6-9aa5-7c1ec5ccf145" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONELEMENTBASE(Ecology).[UPDATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="12" UUID="8d131171-d281-4911-a960-16992de384c7" CREATED="2009-02-03 17:52:26.0" AUTHORITY="DESCRIPTIONELEMENTBASE(Ecology).[CREATE]"/>\r
+ <GRANTEDAUTHORITYIMPL ID="8" UUID="45b40e93-88b0-40eb-92a4-ffdd8f1d7bc3" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONNODE.[UPDATE]{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}"/>\r
+ <GRANTEDAUTHORITYIMPL ID="9" UUID="8696ef0f-e98c-4842-b9d2-456b82584c25" CREATED="2009-02-03 17:52:26.0" AUTHORITY="TAXONNODE.[CREATE]{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}"/>\r
\r
<USERACCOUNT USERNAME="admin" ID="1" CREATED="2009-06-18 13:47:59.0" UUID="e4acf200-63b6-11dd-ad8b-0800200c9a66" PASSWORD="656a8bc965ac42adc800013e1a8612b9" ENABLED="true" ACCOUNTNONEXPIRED="true" CREDENTIALSNONEXPIRED="true" ACCOUNTNONLOCKED="true"/>\r
<USERACCOUNT USERNAME="descriptionEditor" ID="2" CREATED="2009-06-18 13:47:59.0" UUID="49efface-4c2b-40d2-84bb-e3915c0e77b1" PASSWORD="d211b476c3f3795f801c959fb9671b0c" ENABLED="true" ACCOUNTNONEXPIRED="true" CREDENTIALSNONEXPIRED="true" ACCOUNTNONLOCKED="true"/>\r