use last modello 1.6 for redback-rbac-role-manager to be use 1.5

jpox part has been removed from modello plugin so not possible ....

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1415426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-29 22:50:42 +00:00
parent 0f75dfab50
commit cd099ede58
7 changed files with 76 additions and 78 deletions

View File

@ -102,6 +102,7 @@
<plugin> <plugin>
<groupId>org.codehaus.modello</groupId> <groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId> <artifactId>modello-maven-plugin</artifactId>
<version>1.6</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@ -111,7 +112,10 @@
<goal>stax-writer</goal> <goal>stax-writer</goal>
</goals> </goals>
<configuration> <configuration>
<useJava5>true</useJava5>
<models>
<model>src/main/mdo/redback-role-profiles.mdo</model> <model>src/main/mdo/redback-role-profiles.mdo</model>
</models>
<version>1.0.0</version> <version>1.0.0</version>
</configuration> </configuration>
</execution> </execution>

View File

@ -112,11 +112,11 @@ public class DefaultRoleManager
RedbackRoleModel roleModel = reader.read( inputStreamReader ); RedbackRoleModel roleModel = reader.read( inputStreamReader );
for ( ModelApplication app : (List<ModelApplication>) roleModel.getApplications() ) for ( ModelApplication app : roleModel.getApplications() )
{ {
if ( !knownResources.containsKey( app.getId() ) ) if ( !knownResources.containsKey( app.getId() ) )
{ {
log.info( "loading " + app.getId() ); log.info( "loading {}", app.getId() );
loadApplication( app ); loadApplication( app );
} }
} }
@ -143,7 +143,7 @@ public class DefaultRoleManager
public void loadRoleModel( RedbackRoleModel roleModel ) public void loadRoleModel( RedbackRoleModel roleModel )
throws RoleManagerException throws RoleManagerException
{ {
for ( ModelApplication app : (List<ModelApplication>) roleModel.getApplications() ) for ( ModelApplication app : roleModel.getApplications() )
{ {
if ( !knownResources.containsKey( app.getId() ) ) if ( !knownResources.containsKey( app.getId() ) )
{ {

View File

@ -80,9 +80,9 @@ public class DefaultRoleModelProcessor
private void processResources( RedbackRoleModel model ) private void processResources( RedbackRoleModel model )
throws RoleManagerException throws RoleManagerException
{ {
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelResource profileResource : (List<ModelResource>) application.getResources() ) for ( ModelResource profileResource : application.getResources() )
{ {
try try
{ {
@ -115,9 +115,9 @@ public class DefaultRoleModelProcessor
private void processOperations( RedbackRoleModel model ) private void processOperations( RedbackRoleModel model )
throws RoleManagerException throws RoleManagerException
{ {
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelOperation profileOperation : (List<ModelOperation>) application.getOperations() ) for ( ModelOperation profileOperation : application.getOperations() )
{ {
try try
{ {

View File

@ -65,9 +65,9 @@ public class DefaultRoleTemplateProcessor
public void create( RedbackRoleModel model, String templateId, String resource ) public void create( RedbackRoleModel model, String templateId, String resource )
throws RoleManagerException throws RoleManagerException
{ {
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( templateId.equals( template.getId() ) ) if ( templateId.equals( template.getId() ) )
{ {
@ -89,9 +89,9 @@ public class DefaultRoleTemplateProcessor
public void remove( RedbackRoleModel model, String templateId, String resource ) public void remove( RedbackRoleModel model, String templateId, String resource )
throws RoleManagerException throws RoleManagerException
{ {
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( templateId.equals( template.getId() ) ) if ( templateId.equals( template.getId() ) )
{ {

View File

@ -42,12 +42,12 @@ import java.util.List;
public class RoleModelUtils public class RoleModelUtils
{ {
@SuppressWarnings( "unchecked" )
public static List<ModelRole> getRoles( RedbackRoleModel model ) public static List<ModelRole> getRoles( RedbackRoleModel model )
{ {
List<ModelRole> roleList = new ArrayList<ModelRole>( ); List<ModelRole> roleList = new ArrayList<ModelRole>( );
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
roleList.addAll( application.getRoles() ); roleList.addAll( application.getRoles() );
} }
@ -55,12 +55,11 @@ public class RoleModelUtils
return roleList; return roleList;
} }
@SuppressWarnings( "unchecked" )
public static List<ModelTemplate> getTemplates( RedbackRoleModel model ) public static List<ModelTemplate> getTemplates( RedbackRoleModel model )
{ {
List<ModelTemplate> templateList = new ArrayList<ModelTemplate>(); List<ModelTemplate> templateList = new ArrayList<ModelTemplate>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
templateList.addAll( application.getTemplates() ); templateList.addAll( application.getTemplates() );
} }
@ -73,9 +72,9 @@ public class RoleModelUtils
{ {
List<String> operationsIdList = new ArrayList<String>(); List<String> operationsIdList = new ArrayList<String>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelOperation operation : (List<ModelOperation>) application.getOperations() ) for ( ModelOperation operation : application.getOperations() )
{ {
operationsIdList.add( operation.getId() ); operationsIdList.add( operation.getId() );
} }
@ -89,9 +88,9 @@ public class RoleModelUtils
{ {
List<String> resourceIdList = new ArrayList<String>(); List<String> resourceIdList = new ArrayList<String>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelResource resource : (List<ModelResource>) application.getResources() ) for ( ModelResource resource : application.getResources() )
{ {
resourceIdList.add( resource.getId() ); resourceIdList.add( resource.getId() );
} }
@ -100,14 +99,13 @@ public class RoleModelUtils
return resourceIdList; return resourceIdList;
} }
@SuppressWarnings( "unchecked" )
public static List<String> getRoleIdList( RedbackRoleModel model ) public static List<String> getRoleIdList( RedbackRoleModel model )
{ {
List<String> roleIdList = new ArrayList<String>(); List<String> roleIdList = new ArrayList<String>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
roleIdList.add( role.getId() ); roleIdList.add( role.getId() );
} }
@ -116,14 +114,14 @@ public class RoleModelUtils
return roleIdList; return roleIdList;
} }
@SuppressWarnings( "unchecked" )
public static List<String> getTemplateIdList( RedbackRoleModel model ) public static List<String> getTemplateIdList( RedbackRoleModel model )
{ {
List<String> templateIdList = new ArrayList<String>(); List<String> templateIdList = new ArrayList<String>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
templateIdList.add( template.getId() ); templateIdList.add( template.getId() );
} }
@ -145,9 +143,9 @@ public class RoleModelUtils
{ {
ModelRole mrole = null; ModelRole mrole = null;
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( roleId.equals( role.getId() ) ) if ( roleId.equals( role.getId() ) )
{ {
@ -171,9 +169,9 @@ public class RoleModelUtils
{ {
ModelTemplate mtemplate = null; ModelTemplate mtemplate = null;
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( templateId.equals( template.getId() ) ) if ( templateId.equals( template.getId() ) )
{ {
@ -197,9 +195,9 @@ public class RoleModelUtils
{ {
ModelOperation moperation = null; ModelOperation moperation = null;
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelOperation operation : (List<ModelOperation>) application.getOperations() ) for ( ModelOperation operation : application.getOperations() )
{ {
if ( operationId.equals( operation.getId() ) ) if ( operationId.equals( operation.getId() ) )
{ {
@ -216,9 +214,9 @@ public class RoleModelUtils
{ {
ModelResource mresource = null; ModelResource mresource = null;
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelResource resource : (List<ModelResource>) application.getResources() ) for ( ModelResource resource : application.getResources() )
{ {
if ( resourceId.equals( resource.getId() ) ) if ( resourceId.equals( resource.getId() ) )
{ {
@ -236,15 +234,15 @@ public class RoleModelUtils
{ {
DAG roleGraph = new DAG(); DAG roleGraph = new DAG();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
roleGraph.addVertex( role.getId() ); roleGraph.addVertex( role.getId() );
if ( role.getChildRoles() != null ) if ( role.getChildRoles() != null )
{ {
for ( String childRole : (List<String>) role.getChildRoles() ) for ( String childRole : role.getChildRoles() )
{ {
roleGraph.addVertex( childRole ); roleGraph.addVertex( childRole );
@ -254,7 +252,7 @@ public class RoleModelUtils
if ( role.getParentRoles() != null ) if ( role.getParentRoles() != null )
{ {
for ( String parentRole : (List<String>) role.getParentRoles() ) for ( String parentRole : role.getParentRoles() )
{ {
roleGraph.addVertex( parentRole ); roleGraph.addVertex( parentRole );
@ -273,15 +271,15 @@ public class RoleModelUtils
{ {
DAG templateGraph = generateRoleGraph( model ); DAG templateGraph = generateRoleGraph( model );
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
templateGraph.addVertex( template.getId() ); templateGraph.addVertex( template.getId() );
if ( template.getChildRoles() != null ) if ( template.getChildRoles() != null )
{ {
for ( String childRole : (List<String>) template.getChildRoles() ) for ( String childRole : template.getChildRoles() )
{ {
templateGraph.addVertex( childRole ); templateGraph.addVertex( childRole );
@ -291,7 +289,7 @@ public class RoleModelUtils
if ( template.getParentRoles() != null ) if ( template.getParentRoles() != null )
{ {
for ( String parentRole : (List<String>) template.getParentRoles() ) for ( String parentRole : template.getParentRoles() )
{ {
templateGraph.addVertex( parentRole ); templateGraph.addVertex( parentRole );
@ -301,7 +299,7 @@ public class RoleModelUtils
if ( template.getChildTemplates() != null ) if ( template.getChildTemplates() != null )
{ {
for ( String childTemplate : (List<String>) template.getChildTemplates() ) for ( String childTemplate : template.getChildTemplates() )
{ {
templateGraph.addVertex( childTemplate ); templateGraph.addVertex( childTemplate );
@ -311,7 +309,7 @@ public class RoleModelUtils
if ( template.getParentTemplates() != null ) if ( template.getParentTemplates() != null )
{ {
for ( String parentTemplate : (List<String>) template.getParentTemplates() ) for ( String parentTemplate : template.getParentTemplates() )
{ {
templateGraph.addVertex( parentTemplate ); templateGraph.addVertex( parentTemplate );

View File

@ -96,7 +96,7 @@ public class DefaultRoleModelValidator
{ {
// validate model has name // validate model has name
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
if ( application.getId() == null ) if ( application.getId() == null )
{ {
@ -110,7 +110,7 @@ public class DefaultRoleModelValidator
} }
// validate resource bits // validate resource bits
for ( ModelResource resource : (List<ModelResource>) application.getResources() ) for ( ModelResource resource : application.getResources() )
{ {
if ( resource.getName() == null ) if ( resource.getName() == null )
{ {
@ -124,7 +124,7 @@ public class DefaultRoleModelValidator
} }
// validate the operations // validate the operations
for ( ModelOperation operation : (List<ModelOperation>) application.getOperations() ) for ( ModelOperation operation : application.getOperations() )
{ {
if ( operation.getName() == null ) if ( operation.getName() == null )
{ {
@ -137,7 +137,7 @@ public class DefaultRoleModelValidator
} }
} }
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( role.getId() == null ) if ( role.getId() == null )
{ {
@ -151,7 +151,7 @@ public class DefaultRoleModelValidator
if ( role.getPermissions() != null ) if ( role.getPermissions() != null )
{ {
for ( ModelPermission permission : (List<ModelPermission>) role.getPermissions() ) for ( ModelPermission permission : role.getPermissions() )
{ {
if ( permission.getName() == null ) if ( permission.getName() == null )
{ {
@ -176,7 +176,7 @@ public class DefaultRoleModelValidator
} }
} }
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( template.getId() == null ) if ( template.getId() == null )
{ {
@ -190,7 +190,7 @@ public class DefaultRoleModelValidator
if ( template.getPermissions() != null ) if ( template.getPermissions() != null )
{ {
for ( ModelPermission permission : (List<ModelPermission>) template.getPermissions() ) for ( ModelPermission permission : template.getPermissions() )
{ {
if ( permission.getName() == null ) if ( permission.getName() == null )
{ {
@ -222,19 +222,18 @@ public class DefaultRoleModelValidator
* *
* @param model * @param model
*/ */
@SuppressWarnings( "unchecked" )
private void validateOperationClosure( RedbackRoleModel model ) private void validateOperationClosure( RedbackRoleModel model )
{ {
List<String> operationIdList = RoleModelUtils.getOperationIdList( model ); List<String> operationIdList = RoleModelUtils.getOperationIdList( model );
// check the operations in role permissions // check the operations in role permissions
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( role.getPermissions() != null ) if ( role.getPermissions() != null )
{ {
for ( ModelPermission permission : (List<ModelPermission>) role.getPermissions() ) for ( ModelPermission permission : role.getPermissions() )
{ {
if ( !operationIdList.contains( permission.getOperation() ) ) if ( !operationIdList.contains( permission.getOperation() ) )
{ {
@ -246,11 +245,11 @@ public class DefaultRoleModelValidator
} }
// check the operations in template permissions // check the operations in template permissions
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( template.getPermissions() != null ) if ( template.getPermissions() != null )
{ {
for ( ModelPermission permission : (List<ModelPermission>) template.getPermissions() ) for ( ModelPermission permission : template.getPermissions() )
{ {
if ( !operationIdList.contains( permission.getOperation() ) ) if ( !operationIdList.contains( permission.getOperation() ) )
{ {
@ -263,17 +262,16 @@ public class DefaultRoleModelValidator
} }
} }
@SuppressWarnings( "unchecked" )
private void validateResourceClosure( RedbackRoleModel model ) private void validateResourceClosure( RedbackRoleModel model )
{ {
List<String> resourceIdList = RoleModelUtils.getResourceIdList( model ); List<String> resourceIdList = RoleModelUtils.getResourceIdList( model );
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( role.getPermissions() != null ) if ( role.getPermissions() != null )
{ {
for ( ModelPermission permission : (List<ModelPermission>) role.getPermissions() ) for ( ModelPermission permission : role.getPermissions() )
{ {
if ( !resourceIdList.contains( permission.getResource() ) ) if ( !resourceIdList.contains( permission.getResource() ) )
{ {
@ -286,17 +284,16 @@ public class DefaultRoleModelValidator
} }
} }
@SuppressWarnings( "unchecked" )
private void validateChildRoleClosure( RedbackRoleModel model ) private void validateChildRoleClosure( RedbackRoleModel model )
{ {
List<String> roleIdList = RoleModelUtils.getRoleIdList( model ); List<String> roleIdList = RoleModelUtils.getRoleIdList( model );
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( role.getChildRoles() != null ) if ( role.getChildRoles() != null )
{ {
for ( String childRoleId : (List<String>) role.getChildRoles() ) for ( String childRoleId : role.getChildRoles() )
{ {
if ( !roleIdList.contains( childRoleId ) ) if ( !roleIdList.contains( childRoleId ) )
{ {
@ -307,11 +304,11 @@ public class DefaultRoleModelValidator
} }
} }
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( template.getChildRoles() != null ) if ( template.getChildRoles() != null )
{ {
for ( String childRoleId : (List<String>) template.getChildRoles() ) for ( String childRoleId : template.getChildRoles() )
{ {
if ( !roleIdList.contains( childRoleId ) ) if ( !roleIdList.contains( childRoleId ) )
{ {
@ -329,13 +326,13 @@ public class DefaultRoleModelValidator
{ {
List roleIdList = RoleModelUtils.getRoleIdList( model ); List roleIdList = RoleModelUtils.getRoleIdList( model );
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelRole role : (List<ModelRole>) application.getRoles() ) for ( ModelRole role : application.getRoles() )
{ {
if ( role.getParentRoles() != null ) if ( role.getParentRoles() != null )
{ {
for ( String parentRoleId : (List<String>) role.getParentRoles() ) for ( String parentRoleId : role.getParentRoles() )
{ {
if ( !roleIdList.contains( parentRoleId ) ) if ( !roleIdList.contains( parentRoleId ) )
{ {
@ -346,11 +343,11 @@ public class DefaultRoleModelValidator
} }
} }
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( template.getParentRoles() != null ) if ( template.getParentRoles() != null )
{ {
for ( String parentRoleId : (List<String>) template.getParentRoles() ) for ( String parentRoleId : template.getParentRoles() )
{ {
if ( !roleIdList.contains( parentRoleId ) ) if ( !roleIdList.contains( parentRoleId ) )
{ {
@ -363,7 +360,6 @@ public class DefaultRoleModelValidator
} }
} }
@SuppressWarnings( "unchecked" )
private void validateTemplateClosure( RedbackRoleModel model ) private void validateTemplateClosure( RedbackRoleModel model )
{ {
List templateIdList = RoleModelUtils.getTemplateIdList( model ); List templateIdList = RoleModelUtils.getTemplateIdList( model );
@ -371,13 +367,13 @@ public class DefaultRoleModelValidator
// template name prefix must be unique // template name prefix must be unique
List<String> templateNamePrefixList = new ArrayList<String>(); List<String> templateNamePrefixList = new ArrayList<String>();
for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) for ( ModelApplication application : model.getApplications() )
{ {
for ( ModelTemplate template : (List<ModelTemplate>) application.getTemplates() ) for ( ModelTemplate template : application.getTemplates() )
{ {
if ( template.getParentTemplates() != null ) if ( template.getParentTemplates() != null )
{ {
for ( String parentTemplateId : (List<String>) template.getParentTemplates() ) for ( String parentTemplateId : template.getParentTemplates() )
{ {
if ( !templateIdList.contains( parentTemplateId ) ) if ( !templateIdList.contains( parentTemplateId ) )
{ {
@ -390,7 +386,7 @@ public class DefaultRoleModelValidator
if ( template.getChildTemplates() != null ) if ( template.getChildTemplates() != null )
{ {
for ( String childTemplateId : (List<String>) template.getChildTemplates() ) for ( String childTemplateId : template.getChildTemplates() )
{ {
if ( !templateIdList.contains( childTemplateId ) ) if ( !templateIdList.contains( childTemplateId ) )
{ {

View File

@ -18,7 +18,7 @@
~ under the License. ~ under the License.
--> -->
<model> <model xml.namespace="http://archiva.apache.org/redback/role/${version}">
<id>redback-role-model</id> <id>redback-role-model</id>
<name>RedbackRoleModel</name> <name>RedbackRoleModel</name>
<description></description> <description></description>