remove not used anymore classes

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1396046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-09 14:36:57 +00:00
parent 80e0c953ec
commit e7bd58f6fc
5 changed files with 0 additions and 563 deletions

View File

@ -1,158 +0,0 @@
package org.apache.archiva.redback.integration.reports;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.rbac.Role;
import org.apache.archiva.redback.rbac.UserAssignment;
import org.apache.archiva.redback.users.UserManager;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.archiva.redback.system.SecuritySystem;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.integration.util.RoleSorter;
import org.apache.archiva.redback.integration.util.UserComparator;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* CsvRolesMatrix
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
@Service( "report#rolesmatrix-csv" )
public class CsvRolesMatrix
implements Report
{
@Inject
private SecuritySystem securitySystem;
@Inject
@Named( value = "rBACManager#jdo" )
private RBACManager rbacManager;
public String getName()
{
return "Roles Matrix";
}
public String getType()
{
return "csv";
}
public void writeReport( OutputStream os )
throws ReportException
{
UserManager userManager = securitySystem.getUserManager();
List<User> allUsers = userManager.getUsers();
List<Role> allRoles;
Map<String, List<String>> assignmentsMap;
try
{
allRoles = rbacManager.getAllRoles();
Collections.sort( allRoles, new RoleSorter() );
assignmentsMap = new HashMap<String, List<String>>();
for ( UserAssignment assignment : rbacManager.getAllUserAssignments() )
{
assignmentsMap.put( assignment.getPrincipal(), assignment.getRoleNames() );
}
}
catch ( RbacManagerException e )
{
throw new ReportException( "Unable to obtain list of all roles.", e );
}
Collections.sort( allUsers, new UserComparator( "username", true ) );
PrintWriter out = new PrintWriter( os );
writeCsvHeader( out, allRoles );
for ( User user : allUsers )
{
writeCsvRow( out, user, assignmentsMap, allRoles );
}
out.flush();
}
private void writeCsvHeader( PrintWriter out, List<Role> allRoles )
{
out.print( "Username,Full Name,Email Address" );
for ( Role role : allRoles )
{
out.print( "," + escapeCell( role.getName() ) );
}
out.println();
}
private void writeCsvRow( PrintWriter out, User user, Map<String, List<String>> assignmentsMap,
List<Role> allRoles )
{
out.print( escapeCell( user.getUsername() ) );
out.print( "," + escapeCell( user.getFullName() ) );
out.print( "," + escapeCell( user.getEmail() ) );
List<String> assignedRoleNames = assignmentsMap.get( user.getPrincipal().toString() );
if ( assignedRoleNames == null )
{
assignedRoleNames = new ArrayList<String>();
}
for ( Role role : allRoles )
{
out.print( ',' );
if ( assignedRoleNames.contains( role.getName() ) )
{
out.print( 'Y' );
}
}
out.println();
}
private String escapeCell( String cell )
{
return "\"" + StringEscapeUtils.escapeJava( cell ) + "\"";
}
public String getId()
{
return "rolesmatrix";
}
public String getMimeType()
{
return "text/csv";
}
}

View File

@ -1,182 +0,0 @@
package org.apache.archiva.redback.integration.reports;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.archiva.redback.system.SecuritySystem;
import org.apache.archiva.redback.integration.util.UserComparator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* CsvUserList
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
@Service( "report#userlist-csv" )
public class CsvUserList
implements Report
{
private Logger log = LoggerFactory.getLogger( CsvUserList.class );
@Inject
private SecuritySystem securitySystem;
private Map<String, String> fields;
public CsvUserList()
{
fields = new HashMap<String, String>();
fields.put( "username", "User Name" );
fields.put( "fullName", "Full Name" );
fields.put( "email", "Email Address" );
fields.put( "permanent", "Permanent User" );
fields.put( "locked", "Locked User" );
fields.put( "validated", "Validated User" );
fields.put( "passwordChangeRequired", "Must Change Password On Next Login" );
fields.put( "countFailedLoginAttempts", "Failed Login Attempts" );
fields.put( "lastPasswordChange", "Last Password Change" );
fields.put( "accountCreationDate", "Date Created" );
fields.put( "lastLoginDate", "Date Last Logged In" );
}
public String getId()
{
return "userlist";
}
public String getMimeType()
{
return "text/csv";
}
public String getName()
{
return "User List";
}
public String getType()
{
return "csv";
}
public void writeReport( OutputStream os )
throws ReportException
{
UserManager userManager = securitySystem.getUserManager();
List<User> allUsers = userManager.getUsers();
Collections.sort( allUsers, new UserComparator( "username", true ) );
PrintWriter out = new PrintWriter( os );
writeCsvHeader( out );
Iterator<User> itUsers = allUsers.iterator();
while ( itUsers.hasNext() )
{
User user = (User) itUsers.next();
writeCsvRow( out, user );
}
out.flush();
}
private void writeCsvHeader( PrintWriter out )
{
boolean hasPreviousField = false;
for ( String heading : fields.values() )
{
if ( hasPreviousField )
{
out.print( "," );
}
out.print( escapeCell( heading ) );
hasPreviousField = true;
}
out.println();
}
@SuppressWarnings( "unchecked" )
private void writeCsvRow( PrintWriter out, User user )
throws ReportException
{
try
{
boolean hasPreviousField = false;
Map<String, Object> propMap = PropertyUtils.describe( user );
for ( String propName : fields.keySet() )
{
Object propValue = propMap.get( propName );
if ( hasPreviousField )
{
out.print( "," );
}
if ( propValue != null )
{
out.print( escapeCell( propValue.toString() ) );
}
hasPreviousField = true;
}
out.println();
}
catch ( IllegalAccessException e )
{
String emsg = "Unable to produce " + getName() + " report.";
log.error( emsg, e );
throw new ReportException( emsg, e );
}
catch ( InvocationTargetException e )
{
String emsg = "Unable to produce " + getName() + " report.";
log.error( emsg, e );
throw new ReportException( emsg, e );
}
catch ( NoSuchMethodException e )
{
String emsg = "Unable to produce " + getName() + " report.";
log.error( emsg, e );
throw new ReportException( emsg, e );
}
}
private String escapeCell( String cell )
{
return "\"" + StringEscapeUtils.escapeJava( cell ) + "\"";
}
}

View File

@ -1,69 +0,0 @@
package org.apache.archiva.redback.integration.reports;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.OutputStream;
/**
* Report
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public interface Report
{
/**
* The Name of the Report (for display to the user)
*
* @return the name of the report.
*/
String getName();
/**
* The type of report (example: 'csv', 'xls', 'pdf')
* Used in the display of the report links to the user.
*
* @return the type of report.
*/
String getType();
/**
* The mimetype of the report. (used to set download content type correctly)
*
* @return the mimetype.
*/
String getMimeType();
/**
* The ID for this report.
*
* @return the ID for this report.
*/
String getId();
/**
* Write Report to provided outputstream.
*
* @param os the outputstream to write to.
* @throws ReportException if there was a problem in generating the report.
*/
void writeReport( OutputStream os )
throws ReportException;
}

View File

@ -1,51 +0,0 @@
package org.apache.archiva.redback.integration.reports;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* ReportException
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public class ReportException
extends Exception
{
public ReportException()
{
super();
}
public ReportException( String message, Throwable cause )
{
super( message, cause );
}
public ReportException( String message )
{
super( message );
}
public ReportException( Throwable cause )
{
super( cause );
}
}

View File

@ -1,103 +0,0 @@
package org.apache.archiva.redback.integration.reports;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* ReportManager
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
@Service( "reportManager" )
public class ReportManager
{
@Inject
private List<Report> availableReports;
@Inject
private ApplicationContext applicationContext;
private Map<String, Map<String, Report>> reportMap;
public Report findReport( String id, String type )
throws ReportException
{
if ( StringUtils.isBlank( id ) )
{
throw new ReportException( "Unable to generate report from empty report id." );
}
if ( StringUtils.isBlank( type ) )
{
throw new ReportException( "Unable to generate report from empty report type." );
}
Map<String, Report> typeMap = reportMap.get( id );
if ( typeMap == null )
{
throw new ReportException( "Unable to find report id [" + id + "]" );
}
Report requestedReport = typeMap.get( type );
if ( requestedReport == null )
{
throw new ReportException( "Unable to find report id [" + id + "] type [" + type + "]" );
}
return requestedReport;
}
public Map<String, Map<String, Report>> getReportMap()
{
return Collections.unmodifiableMap( reportMap );
}
@SuppressWarnings( "unchecked" )
@PostConstruct
public void initialize()
{
reportMap = new HashMap<String, Map<String, Report>>();
for ( Report report : availableReports )
{
Map<String, Report> typeMap = reportMap.get( report.getId() );
if ( typeMap == null )
{
typeMap = new HashMap<String, Report>();
}
typeMap.put( report.getType(), report );
reportMap.put( report.getId(), typeMap );
}
}
}