in src/main/java/org/apache/directory/fortress/core/cli/CommandLineInterpreter.java [916:1032]
private void processGroupCommand( Set<String> commands, Options options )
{
String command;
try
{
if ( commands.contains( ADD_GROUP ) )
{
command = ADD_GROUP;
LOG.info( command );
Group group = options.getGroup();
groupMgr.add( group );
}
else if ( commands.contains( UPDATE_GROUP ) )
{
command = UPDATE_GROUP;
LOG.info( command );
Group group = options.getGroup();
groupMgr.update( group );
}
else if ( commands.contains( DELETE_GROUP ) )
{
command = DELETE_GROUP;
LOG.info( command );
Group group = options.getGroup();
groupMgr.delete( group );
}
else if ( commands.contains( READ_GROUP ) )
{
command = READ_GROUP;
LOG.info( command );
Group group = options.getGroup();
Group outGroup = groupMgr.read( group );
printGroup( outGroup );
}
else if ( commands.contains( FIND_GROUP ) )
{
command = FIND_GROUP;
LOG.info( command );
Group inGroup = options.getGroup();
List<Group> groups = groupMgr.find( inGroup );
if ( CollectionUtils.isNotEmpty( groups ) )
{
for ( Group outGroup : groups )
{
printGroup( outGroup );
}
}
}
else if ( commands.contains( ASSIGN_GROUP ) )
{
command = ASSIGN_GROUP;
LOG.info( command );
Group group = options.getGroup();
if ( CollectionUtils.isNotEmpty( group.getMembers() ) )
{
for ( String member : group.getMembers() )
{
groupMgr.assign( group, member );
}
}
}
else if ( commands.contains( DEASSIGN_GROUP ) )
{
command = DEASSIGN_GROUP;
LOG.info( command );
Group group = options.getGroup();
if ( CollectionUtils.isNotEmpty( group.getMembers() ) )
{
for ( String member : group.getMembers() )
{
groupMgr.deassign( group, member );
}
}
}
else if ( commands.contains( ADD_GROUP_PROP ) )
{
command = ADD_GROUP_PROP;
LOG.info( command );
Group group = options.getGroup();
if ( PropUtil.isNotEmpty( group.getProperties() ) )
{
for ( Enumeration<?> e = group.getProperties().propertyNames(); e.hasMoreElements(); )
{
String key = ( String ) e.nextElement();
String val = group.getProperty( key );
groupMgr.add( group, key, val );
}
}
}
else if ( commands.contains( DELETE_GROUP_PROP ) )
{
command = DELETE_GROUP_PROP;
LOG.info( command );
Group group = options.getGroup();
if ( PropUtil.isNotEmpty( group.getProperties() ) )
{
for ( Enumeration<?> e = group.getProperties().propertyNames(); e.hasMoreElements(); )
{
String key = ( String ) e.nextElement();
String val = group.getProperty( key );
groupMgr.delete( group, key, val );
}
}
}
else
{
LOG.warn( "unknown group operation detected" );
return;
}
LOG.info( "command:{} was successful", command );
}
catch ( SecurityException se )
{
String error = "processGroupCommand caught SecurityException=" + se + ", return code=" + se.getErrorId();
LOG.error( error );
}
}