From: Olivier Lamy Date: Tue, 9 Oct 2012 14:36:57 +0000 (+0000) Subject: remove not used anymore classes X-Git-Tag: redback-2.1~294 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e7bd58f6fc4ff9f268c628407a07c058d7c99c3a;p=archiva.git 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 --- diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvRolesMatrix.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvRolesMatrix.java deleted file mode 100644 index b73e98edb..000000000 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvRolesMatrix.java +++ /dev/null @@ -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 Joakim Erdfelt - * - */ -@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 allUsers = userManager.getUsers(); - List allRoles; - Map> assignmentsMap; - - try - { - allRoles = rbacManager.getAllRoles(); - Collections.sort( allRoles, new RoleSorter() ); - - assignmentsMap = new HashMap>(); - - 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 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> assignmentsMap, - List allRoles ) - { - out.print( escapeCell( user.getUsername() ) ); - out.print( "," + escapeCell( user.getFullName() ) ); - out.print( "," + escapeCell( user.getEmail() ) ); - - List assignedRoleNames = assignmentsMap.get( user.getPrincipal().toString() ); - if ( assignedRoleNames == null ) - { - assignedRoleNames = new ArrayList(); - } - - 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"; - } -} diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvUserList.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvUserList.java deleted file mode 100644 index 4e7e51468..000000000 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/CsvUserList.java +++ /dev/null @@ -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 Joakim Erdfelt - * - */ -@Service( "report#userlist-csv" ) -public class CsvUserList - implements Report -{ - private Logger log = LoggerFactory.getLogger( CsvUserList.class ); - - @Inject - private SecuritySystem securitySystem; - - private Map fields; - - public CsvUserList() - { - fields = new HashMap(); - 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 allUsers = userManager.getUsers(); - - Collections.sort( allUsers, new UserComparator( "username", true ) ); - - PrintWriter out = new PrintWriter( os ); - - writeCsvHeader( out ); - - Iterator 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 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 ) + "\""; - } -} diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/Report.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/Report.java deleted file mode 100644 index f96ae4067..000000000 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/Report.java +++ /dev/null @@ -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 Joakim Erdfelt - * - */ -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; -} diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportException.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportException.java deleted file mode 100644 index 547e7a8ed..000000000 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportException.java +++ /dev/null @@ -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 Joakim Erdfelt - * - */ -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 ); - } -} diff --git a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportManager.java b/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportManager.java deleted file mode 100644 index 8ccb59fd8..000000000 --- a/redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/reports/ReportManager.java +++ /dev/null @@ -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 Joakim Erdfelt - * - */ -@Service( "reportManager" ) -public class ReportManager -{ - - @Inject - private List availableReports; - - @Inject - private ApplicationContext applicationContext; - - private Map> 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 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> getReportMap() - { - return Collections.unmodifiableMap( reportMap ); - } - - @SuppressWarnings( "unchecked" ) - @PostConstruct - public void initialize() - { - reportMap = new HashMap>(); - - for ( Report report : availableReports ) - { - Map typeMap = reportMap.get( report.getId() ); - if ( typeMap == null ) - { - typeMap = new HashMap(); - } - - typeMap.put( report.getType(), report ); - reportMap.put( report.getId(), typeMap ); - } - } -}