[MRM-1747] upgrade to last modello.

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1446826 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-16 00:41:41 +00:00
parent 490f1f5656
commit b2c48de92e
10 changed files with 127 additions and 33 deletions

View File

@ -669,7 +669,11 @@
<plugin> <plugin>
<groupId>org.codehaus.modello</groupId> <groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId> <artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-15</version> <version>1.7-SNAPSHOT</version>
<configuration>
<!-- cause issue with datamanagement module -->
<useJava5>false</useJava5>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -110,18 +110,39 @@
<configuration> <configuration>
<version>1.0.1</version> <version>1.0.1</version>
<packageWithVersion>false</packageWithVersion> <packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/keys.mdo</model> <model>src/main/mdo/keys.mdo</model>
</models>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>modello-java</id> <id>modello-java</id>
<goals> <goals>
<goal>java</goal> <goal>java</goal>
<goal>jpox-metadata-class</goal>
<goal>stax-reader</goal> <goal>stax-reader</goal>
<goal>stax-writer</goal> <goal>stax-writer</goal>
</goals> </goals>
</execution> </execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.archiva.redback.components.modello</groupId>
<artifactId>jpox-modello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<version>1.0.1</version>
<packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/keys.mdo</model>
</models>
</configuration>
<executions>
<execution>
<id>modello-jpox</id>
<goals>
<goal>jpox-metadata-class</goal>
</goals>
</execution>
<execution> <execution>
<id>jpox-jdo-mapping</id> <id>jpox-jdo-mapping</id>
<goals> <goals>

View File

@ -73,12 +73,12 @@
<version>1.0.0+</version> <version>1.0.0+</version>
<type>String</type> <type>String</type>
</field> </field>
<field> <field xml.format="long">
<name>dateCreated</name> <name>dateCreated</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>
</field> </field>
<field> <field xml.format="long">
<name>dateExpires</name> <name>dateExpires</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>

View File

@ -30,4 +30,30 @@ public abstract class AbstractRole
{ {
return ( getChildRoleNames() != null ) && !getChildRoleNames().isEmpty(); return ( getChildRoleNames() != null ) && !getChildRoleNames().isEmpty();
} }
/**
* Method equals.
*
* @param other
* @return boolean
*/
public boolean equals( Object other )
{
if ( this == other )
{
return true;
}
if ( !( other instanceof AbstractRole ) )
{
return false;
}
AbstractRole that = (AbstractRole) other;
boolean result = true;
result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) );
return result;
}
} }

View File

@ -103,15 +103,15 @@
<configuration> <configuration>
<version>1.0.1</version> <version>1.0.1</version>
<packageWithVersion>false</packageWithVersion> <packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/rbac-jdo.mdo</model> <model>src/main/mdo/rbac-jdo.mdo</model>
</models>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>modello-java</id> <id>modello-java</id>
<goals> <goals>
<goal>java</goal> <goal>java</goal>
<goal>jpox-metadata-class</goal>
<goal>jpox-jdo-mapping</goal>
<!-- TODO: Move these to plexus-security-authorization-rbac-model --> <!-- TODO: Move these to plexus-security-authorization-rbac-model -->
<goal>stax-reader</goal> <goal>stax-reader</goal>
<goal>stax-writer</goal> <goal>stax-writer</goal>
@ -119,6 +119,27 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.archiva.redback.components.modello</groupId>
<artifactId>jpox-modello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<version>1.0.1</version>
<packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/rbac-jdo.mdo</model>
</models>
</configuration>
<executions>
<execution>
<id>modello-jpox</id>
<goals>
<goal>jpox-metadata-class</goal>
<goal>jpox-jdo-mapping</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>jpox-maven-plugin</artifactId> <artifactId>jpox-maven-plugin</artifactId>

View File

@ -80,8 +80,7 @@
</class> </class>
<class jpox.stashable="true" <class jpox.stashable="true"
jpox.table="ROLES" jpox.table="ROLES">
jpox.not-persisted-fields="modelEncoding">
<name>JdoRole</name> <name>JdoRole</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<interfaces> <interfaces>
@ -155,8 +154,7 @@
</class> </class>
<class jpox.stashable="true" <class jpox.stashable="true"
jpox.table="PERMISSIONS" jpox.table="PERMISSIONS">
jpox.not-persisted-fields="modelEncoding">
<name>JdoPermission</name> <name>JdoPermission</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<interfaces> <interfaces>
@ -212,8 +210,7 @@
</class> </class>
<class jpox.stashable="true" <class jpox.stashable="true"
jpox.table="OPERATIONS" jpox.table="OPERATIONS">
jpox.not-persisted-fields="modelEncoding">
<name>JdoOperation</name> <name>JdoOperation</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<interfaces> <interfaces>
@ -251,8 +248,7 @@
</class> </class>
<class jpox.stashable="true" <class jpox.stashable="true"
jpox.table="RESOURCES" jpox.table="RESOURCES">
jpox.not-persisted-fields="modelEncoding">
<name>JdoResource</name> <name>JdoResource</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<description> <description>
@ -292,8 +288,7 @@
</class> </class>
<class jpox.stashable="true" <class jpox.stashable="true"
jpox.table="USER_ASSIGNMENTS" jpox.table="USER_ASSIGNMENTS">
jpox.not-persisted-fields="modelEncoding">
<name>JdoUserAssignment</name> <name>JdoUserAssignment</name>
<description>binding of a principal to a role</description> <description>binding of a principal to a role</description>
<version>1.0.0+</version> <version>1.0.0+</version>
@ -308,7 +303,7 @@
<type>String</type> <type>String</type>
<identifier>true</identifier> <identifier>true</identifier>
</field> </field>
<field jpox.column="LAST_UPDATED"> <field jpox.column="LAST_UPDATED" xml.format="long">
<name>timestamp</name> <name>timestamp</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>

View File

@ -32,6 +32,7 @@ import javax.xml.stream.XMLStreamException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.archiva.redback.rbac.Operation; import org.apache.archiva.redback.rbac.Operation;
import org.apache.archiva.redback.rbac.Permission;
import org.apache.archiva.redback.rbac.Resource; import org.apache.archiva.redback.rbac.Resource;
import org.apache.archiva.redback.rbac.jdo.io.stax.RbacJdoModelStaxReader; import org.apache.archiva.redback.rbac.jdo.io.stax.RbacJdoModelStaxReader;
import org.apache.archiva.redback.rbac.jdo.io.stax.RbacJdoModelStaxWriter; import org.apache.archiva.redback.rbac.jdo.io.stax.RbacJdoModelStaxWriter;
@ -155,13 +156,13 @@ public class RbacJdoModelStaxTest
assertEquals( expectedAssignment.getRoleNames(), assignment.getRoleNames() ); assertEquals( expectedAssignment.getRoleNames(), assignment.getRoleNames() );
} }
private void assertPermissions( List<JdoPermission> expectedPermissions, List<JdoPermission> permissions ) private void assertPermissions( List<Permission> expectedPermissions, List<Permission> permissions )
{ {
assertEquals( expectedPermissions.size(), permissions.size() ); assertEquals( expectedPermissions.size(), permissions.size() );
for ( JdoPermission permission : permissions ) for ( Permission permission : permissions )
{ {
boolean found = false; boolean found = false;
for ( JdoPermission expectedPermission : expectedPermissions ) for ( Permission expectedPermission : expectedPermissions )
{ {
if ( expectedPermission.getName().equals( permission.getName() ) ) if ( expectedPermission.getName().equals( permission.getName() ) )
{ {
@ -177,7 +178,7 @@ public class RbacJdoModelStaxTest
} }
} }
private void assertPermission( JdoPermission expectedPermission, JdoPermission permission ) private void assertPermission( Permission expectedPermission, Permission permission )
{ {
assertEquals( expectedPermission.getDescription(), permission.getDescription() ); assertEquals( expectedPermission.getDescription(), permission.getDescription() );
assertOperation( expectedPermission.getOperation(), permission.getOperation() ); assertOperation( expectedPermission.getOperation(), permission.getOperation() );

View File

@ -260,7 +260,8 @@ public abstract class AbstractRbacManagerTestCase
Role actualAdmin = rbacManager.getRole( adminRole.getName() ); Role actualAdmin = rbacManager.getRole( adminRole.getName() );
Role actualDevel = rbacManager.getRole( develRole.getName() ); Role actualDevel = rbacManager.getRole( develRole.getName() );
assertEquals( adminRole, actualAdmin ); assertEquals( adminRole.getName(), actualAdmin.getName() );
assertEquals( adminRole.getChildRoleNames(), actualAdmin.getChildRoleNames() );
assertEquals( develRole, actualDevel ); assertEquals( develRole, actualDevel );
/* Assert some event tracker stuff */ /* Assert some event tracker stuff */
@ -287,7 +288,8 @@ public abstract class AbstractRbacManagerTestCase
Role actualRole = rbacManager.getRole( rolename ); Role actualRole = rbacManager.getRole( rolename );
assertEquals( testRole, actualRole ); assertEquals( testRole.getName(), actualRole.getName() );
assertEquals( testRole.getChildRoleNames(), actualRole.getChildRoleNames() );
assertEquals( 1, rbacManager.getAllRoles().size() ); assertEquals( 1, rbacManager.getAllRoles().size() );
assertEquals( 0, rbacManager.getAllPermissions().size() ); assertEquals( 0, rbacManager.getAllPermissions().size() );
@ -329,7 +331,8 @@ public abstract class AbstractRbacManagerTestCase
Role actualAdmin = manager.getRole( adminRole.getName() ); Role actualAdmin = manager.getRole( adminRole.getName() );
Role actualDevel = manager.getRole( develRole.getName() ); Role actualDevel = manager.getRole( develRole.getName() );
assertEquals( adminRole, actualAdmin ); assertEquals( adminRole.getName(), actualAdmin.getName() );
assertEquals( adminRole.getChildRoleNames(), actualAdmin.getChildRoleNames() );
assertEquals( develRole, actualDevel ); assertEquals( develRole, actualDevel );
// Now add a child role. // Now add a child role.
@ -360,7 +363,8 @@ public abstract class AbstractRbacManagerTestCase
Role actualAdmin = manager.getRole( adminRole.getName() ); Role actualAdmin = manager.getRole( adminRole.getName() );
Role actualDevel = manager.getRole( develRole.getName() ); Role actualDevel = manager.getRole( develRole.getName() );
assertEquals( adminRole, actualAdmin ); assertEquals( adminRole.getName(), actualAdmin.getName() );
assertEquals( adminRole.getChildRoleNames(), actualAdmin.getChildRoleNames() );
assertEquals( develRole, actualDevel ); assertEquals( develRole, actualDevel );
// Now do a child role. // Now do a child role.
@ -769,7 +773,8 @@ public abstract class AbstractRbacManagerTestCase
Role actualAdmin = rbacManager.getRole( adminRole.getName() ); Role actualAdmin = rbacManager.getRole( adminRole.getName() );
Role actualDevel = rbacManager.getRole( develRole.getName() ); Role actualDevel = rbacManager.getRole( develRole.getName() );
assertEquals( adminRole, actualAdmin ); assertEquals( adminRole.getName(), actualAdmin.getName() );
assertEquals( adminRole.getChildRoleNames(), actualAdmin.getChildRoleNames() );
assertEquals( develRole, actualDevel ); assertEquals( develRole, actualDevel );
// Attempt to remove perm now. // Attempt to remove perm now.

View File

@ -116,18 +116,39 @@
<configuration> <configuration>
<version>1.0.1</version> <version>1.0.1</version>
<packageWithVersion>false</packageWithVersion> <packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/user.mdo</model> <model>src/main/mdo/user.mdo</model>
</models>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>modello-java</id> <id>modello-java</id>
<goals> <goals>
<goal>java</goal> <goal>java</goal>
<goal>jpox-metadata-class</goal>
<goal>stax-reader</goal> <goal>stax-reader</goal>
<goal>stax-writer</goal> <goal>stax-writer</goal>
</goals> </goals>
</execution> </execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.archiva.redback.components.modello</groupId>
<artifactId>jpox-modello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<version>1.0.1</version>
<packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/user.mdo</model>
</models>
</configuration>
<executions>
<execution>
<id>modello-jpox</id>
<goals>
<goal>jpox-metadata-class</goal>
</goals>
</execution>
<execution> <execution>
<id>jpox-jdo-mapping</id> <id>jpox-jdo-mapping</id>
<goals> <goals>

View File

@ -83,12 +83,12 @@
<type>String</type> <type>String</type>
<identifier>true</identifier> <identifier>true</identifier>
</field> </field>
<field> <field xml.format="long">
<name>lastPasswordChange</name> <name>lastPasswordChange</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>
</field> </field>
<field> <field xml.format="long">
<name>lastLoginDate</name> <name>lastLoginDate</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>
@ -134,7 +134,7 @@
<multiplicity>*</multiplicity> <multiplicity>*</multiplicity>
</association> </association>
</field> </field>
<field> <field xml.format="long">
<name>accountCreationDate</name> <name>accountCreationDate</name>
<version>1.0.0+</version> <version>1.0.0+</version>
<type>Date</type> <type>Date</type>