if ( isValidModel( model, repo, artifact ) )
{
- getLogger().info( "Adding project model to database - " + Keys.toKey( model ) );
-
+ getLogger().info( "Adding project model to database - " + Keys.toKey( model ) );
dao.getProjectModelDAO().saveProjectModel( model );
}
else
import java.io.Serializable;
import java.util.List;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
/**
* ArchivaDAO - The interface for all content within the database.
*
* @return the post-serialized object.
*/
Object save( Serializable obj );
-
+
ArtifactDAO getArtifactDAO();
ProjectModelDAO getProjectModelDAO();
RepositoryProblemDAO getRepositoryProblemDAO();
+
+ RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO();
}
--- /dev/null
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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.
+ */
+
+/**
+ * RepositoryContentStatisticsByRepositoryConstraint
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class RepositoryContentStatisticsByRepositoryConstraint
+ extends AbstractDeclarativeConstraint
+{
+ private String whereClause;
+
+ public RepositoryContentStatisticsByRepositoryConstraint( String repoId )
+ {
+ whereClause = "repositoryId == repoId";
+ declParams = new String[] { "String repoId" };
+ params = new Object[] { repoId };
+ }
+
+ public String getSortColumn()
+ {
+ return "whenGathered";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.apache.maven.archiva.database.SimpleConstraint;
import org.codehaus.plexus.logging.AbstractLogEnabled;
* @plexus.requirement role-hint="jdo"
*/
private RepositoryProblemDAO repositoryProblemDAO;
+
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO;
+
public List query( SimpleConstraint constraint )
{
{
return jdo.saveObject( obj );
}
-
+
public ArtifactDAO getArtifactDAO()
{
return artifactDAO;
{
return repositoryProblemDAO;
}
+
+ public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO()
+ {
+ return repositoryContentStatisticsDAO;
+ }
}
--- /dev/null
+package org.apache.maven.archiva.database.jdo;
+
+/*
+ * 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.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * JdoRepositoryContentStatisticsDAO
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ *
+ * @plexus.component role-hint="jdo"
+ */
+public class JdoRepositoryContentStatisticsDAO
+ implements RepositoryContentStatisticsDAO
+{
+ /**
+ * @plexus.requirement role-hint="archiva"
+ */
+ private JdoAccess jdo;
+
+ public void deleteRepositoryContentStatistics( RepositoryContentStatistics stats )
+ throws ArchivaDatabaseException
+ {
+ jdo.removeObject( stats );
+ }
+
+ public List queryRepositoryContentStatistics( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ List results = jdo.queryObjects( RepositoryContentStatistics.class, constraint );
+
+ return results;
+ }
+
+ public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats )
+ {
+ RepositoryContentStatistics savedStats = (RepositoryContentStatistics) jdo.saveObject( stats );
+
+ return savedStats;
+ }
+
+}
--- /dev/null
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * 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.util.List;
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * RepositoryContentStatisticsByRepositoryConstraintTest
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class RepositoryContentStatisticsByRepositoryConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
+ long newfiles )
+ throws Exception
+ {
+ RepositoryContentStatistics stats = new RepositoryContentStatistics();
+ stats.setRepositoryId( repoId );
+ stats.setDuration( duration );
+ stats.setNewFileCount( newfiles );
+ stats.setTotalFileCount( totalfiles );
+ stats.setWhenGathered( toDate( timestamp ) );
+
+ return stats;
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics(
+ createStats( "internal", "2007/10/21 8:00:00", 20000, 12000, 400 ) );
+ dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics(
+ createStats( "internal", "2007/10/20 8:00:00", 20000, 11800, 0 ) );
+ dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics(
+ createStats( "internal", "2007/10/19 8:00:00", 20000, 11800, 100 ) );
+ dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics(
+ createStats( "internal", "2007/10/18 8:00:00", 20000, 11700, 320 ) );
+ }
+
+ public void testStats()
+ throws Exception
+ {
+ Constraint constraint = new RepositoryContentStatisticsByRepositoryConstraint( "internal" );
+ List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
+ assertNotNull( "Stats: results (not null)", results );
+ assertEquals( "Stats: results.size", 4, results.size() );
+
+ assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 0 ) ).getRepositoryId() );
+ assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 1 ) ).getRepositoryId() );
+ assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 2 ) ).getRepositoryId() );
+ assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 3 ) ).getRepositoryId() );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.database.jdo;
+
+/*
+ * 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.util.List;
+
+import javax.jdo.JDOHelper;
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
+import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * JdoRepositoryContentStatisticsDAOTest
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class JdoRepositoryContentStatisticsDAOTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ public void testCRUD()
+ throws Exception
+ {
+ RepositoryContentStatisticsDAO repoContentStatisticsDAO = dao.getRepositoryContentStatisticsDAO();
+
+ // create
+ RepositoryContentStatistics savedStats =
+ repoContentStatisticsDAO.saveRepositoryContentStatistics( createStats( "internal", "2007/10/21 8:00:00",
+ 20000, 12000, 400 ) );
+ assertNotNull( savedStats );
+
+ String savedKeyId = JDOHelper.getObjectId( savedStats ).toString();
+ assertEquals( "1[OID]org.apache.maven.archiva.model.RepositoryContentStatistics", savedKeyId );
+
+ // query
+ List results =
+ repoContentStatisticsDAO.queryRepositoryContentStatistics( new RepositoryContentStatisticsByRepositoryConstraint(
+ "internal" ) );
+ assertNotNull( results );
+ assertEquals( 1, results.size() );
+
+ RepositoryContentStatistics stats = (RepositoryContentStatistics) results.get( 0 );
+ assertEquals( "internal", stats.getRepositoryId() );
+
+ // delete
+ repoContentStatisticsDAO.deleteRepositoryContentStatistics( stats );
+
+ assertEquals( 0, repoContentStatisticsDAO.queryRepositoryContentStatistics(
+ new RepositoryContentStatisticsByRepositoryConstraint( "internal" ) ).size() );
+ }
+
+ private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
+ long newfiles )
+ throws Exception
+ {
+ RepositoryContentStatistics stats = new RepositoryContentStatistics();
+ stats.setRepositoryId( repoId );
+ stats.setDuration( duration );
+ stats.setNewFileCount( newfiles );
+ stats.setTotalFileCount( totalfiles );
+ stats.setWhenGathered( toDate( timestamp ) );
+
+ return stats;
+ }
+}
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
import org.apache.maven.archiva.repository.RepositoryException;
dbstats.setTotalFileCount( stats.getTotalFileCount() );
dbstats.setWhenGathered( stats.getWhenGathered() );
- dao.save( dbstats );
+ dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );
}
catch ( RepositoryException e )
{
throw new TaskExecutionException( "Repository error when executing repository job.", e );
- }
+ }
}
}
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint;
+import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
import org.codehaus.plexus.redback.role.RoleManagerException;
import java.io.IOException;
import java.util.List;
/**
- * DeleteManagedRepositoryAction
- *
+ * DeleteManagedRepositoryAction
+ *
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteManagedRepositoryAction"
*/
public class DeleteManagedRepositoryAction
private String repoid;
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private ArchivaDAO archivaDAO;
+
public void prepare()
{
if ( StringUtils.isNotBlank( repoid ) )
try
{
Configuration configuration = archivaConfiguration.getConfiguration();
+ cleanupRepositoryData( existingRepository );
removeRepository( repoid, configuration );
result = saveConfiguration( configuration );
if ( result.equals( SUCCESS ) )
{
- cleanupRepositoryData( existingRepository );
-
if ( deleteContents )
{
removeContents( existingRepository );
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
+ catch ( ArchivaDatabaseException e )
+ {
+ addActionError( "Unable to delete repositoy: " + e.getMessage() );
+ result = ERROR;
+ }
return result;
}
private void cleanupRepositoryData( ManagedRepositoryConfiguration cleanupRepository )
- throws RoleManagerException
+ throws RoleManagerException, ArchivaDatabaseException
{
removeRepositoryRoles( cleanupRepository );
// TODO: [MRM-382] Remove index from artifacts of deleted managed repositories.
- // TODO: [MRM-265] After removing a managed repository - Browse/Search still see it
-
+ // [MRM-265] After removing a managed repository - Browse/Search still see it
+ cleanupDatabase( cleanupRepository.getId() );
+ cleanupScanStats( cleanupRepository.getId() );
+
// [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
List<ProxyConnectorConfiguration> proxyConnectors = getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
}
}
+ private void cleanupDatabase( String repoId )
+ throws ArchivaDatabaseException
+ {
+ Constraint constraint = new ArtifactsByRepositoryConstraint( repoId );
+
+ List<ArchivaArtifact> artifacts = archivaDAO.getArtifactDAO().queryArtifacts( constraint );
+
+ for ( ArchivaArtifact artifact : artifacts )
+ {
+ getLogger().info( "Removing artifact " + artifact + " from the database." );
+ try
+ {
+ archivaDAO.getArtifactDAO().deleteArtifact( artifact );
+
+ ArchivaProjectModel projectModel =
+ archivaDAO.getProjectModelDAO().getProjectModel( artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion() );
+
+ archivaDAO.getProjectModelDAO().deleteProjectModel( projectModel );
+ }
+ catch ( ObjectNotFoundException oe )
+ {
+ getLogger().info( "Project model of artifact " + artifact + " does not exist in the database. " +
+ "Moving on to the next artifact." );
+ }
+ catch ( ArchivaDatabaseException ae )
+ {
+ getLogger().info( "Unable to delete artifact " + artifact + " from the database. " +
+ "Moving on to the next artifact." );
+ }
+ }
+ }
+
+ private void cleanupScanStats( String repoId )
+ throws ArchivaDatabaseException
+ {
+ List<RepositoryContentStatistics> results =
+ archivaDAO.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics(
+ new RepositoryContentStatisticsByRepositoryConstraint( repoId ) );
+
+ for ( RepositoryContentStatistics stats : results )
+ {
+ archivaDAO.getRepositoryContentStatisticsDAO().deleteRepositoryContentStatistics( stats );
+ }
+ }
+
public ManagedRepositoryConfiguration getRepository()
{
return repository;
{
this.repoid = repoid;
}
+
+ public void setArchivaDAO( ArchivaDAO archivaDAO )
+ {
+ this.archivaDAO = archivaDAO;
+ }
+
+ public ArchivaDAO getArchivaDAO()
+ {
+ return archivaDAO;
+ }
}
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.apache.maven.archiva.database.SimpleConstraint;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
public List query( SimpleConstraint constraint )
{
Assert.assertEquals( RepositoryContentStatistics.class, constraint.getResultClass() );
+
List<RepositoryContentStatistics> stats = new ArrayList<RepositoryContentStatistics>();
for ( String repo : configuration.getConfiguration().getManagedRepositoriesAsMap().keySet() )
public ArtifactDAO getArtifactDAO()
{
- throw new UnsupportedOperationException( "query not implemented for stub" );
+ throw new UnsupportedOperationException( "method not implemented for stub" );
}
public ProjectModelDAO getProjectModelDAO()
{
- throw new UnsupportedOperationException( "query not implemented for stub" );
+ throw new UnsupportedOperationException( "method not implemented for stub" );
}
public RepositoryProblemDAO getRepositoryProblemDAO()
{
- throw new UnsupportedOperationException( "query not implemented for stub" );
+ throw new UnsupportedOperationException( "method not implemented for stub" );
+ }
+
+ public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO()
+ {
+ throw new UnsupportedOperationException( "method not implemented for stub" );
}
+
}
--- /dev/null
+package org.apache.maven.archiva.web.action.admin.repositories;
+
+/*
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaArtifactModel;
+
+/**
+ * ArtifactDAOStub
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class ArtifactDAOStub
+ implements ArtifactDAO
+{
+
+ public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier,
+ String type )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void deleteArtifact( ArchivaArtifact artifact )
+ throws ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ArchivaArtifact getArtifact( String groupId, String artifactId, String version, String classifier,
+ String type )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<ArchivaArtifact> queryArtifacts( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+
+ List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>();
+
+ ArchivaArtifactModel model = new ArchivaArtifactModel();
+ model.setGroupId( "org.apache.maven.archiva" );
+ model.setArtifactId( "test-artifact" );
+ model.setVersion( "1.0" );
+ model.setType( "jar" );
+ model.setRepositoryId( "repo-ident" );
+
+ ArchivaArtifact artifact = new ArchivaArtifact( model );
+ artifacts.add( artifact );
+
+ return artifacts;
+ }
+
+ public ArchivaArtifact saveArtifact( ArchivaArtifact artifact )
+ throws ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.redback.role.RoleManager;
private MockControl archivaConfigurationControl;
private ArchivaConfiguration archivaConfiguration;
-
+
private static final String REPO_ID = "repo-ident";
private File location;
super.setUp();
action = (DeleteManagedRepositoryAction) lookup( Action.class.getName(), "deleteManagedRepositoryAction" );
-
+
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
action.setArchivaConfiguration( archivaConfiguration );
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
action.setRoleManager( roleManager );
- location = getTestFile( "target/test/location" );
+ location = getTestFile( "target/test/location" );
}
public void testSecureActionBundle()
public void testDeleteRepositoryKeepContent()
throws Exception
- {
+ {
prepareRoleManagerMock();
- Configuration configuration = prepDeletionTest( createRepository(), 3 );
- String status = action.deleteEntry();
+ Configuration configuration = prepDeletionTest( createRepository(), 3 );
+
+ String status = action.deleteEntry();
+
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
{
prepareRoleManagerMock();
- Configuration configuration = prepDeletionTest( createRepository(), 3 );
+ Configuration configuration = prepDeletionTest( createRepository(), 3 );
+
String status = action.deleteContents();
+
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
roleManagerControl.replay();
}
+
+ protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
+ {
+ ArchivaProjectModel projectModel = new ArchivaProjectModel();
+ projectModel.setGroupId( groupId );
+ projectModel.setArtifactId( artifactId );
+ projectModel.setVersion( version );
+
+ return projectModel;
+ }
}
--- /dev/null
+package org.apache.maven.archiva.web.action.admin.repositories;
+
+/*
+ * 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.Serializable;
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.database.SimpleConstraint;
+
+/**
+ * DeleteManagedRepositoryArchivaDAOStub
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class DeleteManagedRepositoryArchivaDAOStub
+ implements ArchivaDAO
+{
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private ProjectModelDAO projectModelDAO;
+
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private ArtifactDAO artifactDAO;
+
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private RepositoryContentStatisticsDAO repoContentStatisticsDAO;
+
+ public List query( SimpleConstraint constraint )
+ {
+ return null;
+ }
+
+ public Object save( Serializable obj )
+ {
+ throw new UnsupportedOperationException( "query not implemented for stub" );
+ }
+
+ public ArtifactDAO getArtifactDAO()
+ {
+ return artifactDAO;
+ }
+
+ public ProjectModelDAO getProjectModelDAO()
+ {
+ return projectModelDAO;
+ }
+
+ public RepositoryProblemDAO getRepositoryProblemDAO()
+ {
+ throw new UnsupportedOperationException( "query not implemented for stub" );
+ }
+
+ public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO()
+ {
+ return repoContentStatisticsDAO;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.web.action.admin.repositories;
+
+/*
+ * 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.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+
+/**
+ * ProjectModelDAOStub
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class ProjectModelDAOStub
+ implements ProjectModelDAO
+{
+
+ public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void deleteProjectModel( ArchivaProjectModel model )
+ throws ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ ArchivaProjectModel projectModel = new ArchivaProjectModel();
+ projectModel.setGroupId( groupId );
+ projectModel.setArtifactId( artifactId );
+ projectModel.setVersion( version );
+
+ return projectModel;
+ }
+
+ public List queryProjectModels( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model )
+ throws ArchivaDatabaseException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
--- /dev/null
+<!--
+ ~ 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.
+ -->
+
+<plexus>
+ <components>
+ <component>
+ <role>org.codehaus.plexus.logging.LoggerManager</role>
+ <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
+ <lifecycle-handler>basic</lifecycle-handler>
+ </component>
+ <component>
+ <role>com.opensymphony.xwork.Action</role>
+ <role-hint>deleteManagedRepositoryAction</role-hint>
+ <implementation>org.apache.maven.archiva.web.action.admin.repositories.DeleteManagedRepositoryAction</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.archiva.database.ArchivaDAO</role>
+ <role-hint>jdo</role-hint>
+ <field-name>archivaDAO</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.archiva.database.ArchivaDAO</role>
+ <role-hint>jdo</role-hint>
+ <implementation>org.apache.maven.archiva.web.action.admin.repositories.DeleteManagedRepositoryArchivaDAOStub</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.archiva.database.ArtifactDAO</role>
+ <role-hint>jdo</role-hint>
+ <field-name>artifactDAO</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.database.ProjectModelDAO</role>
+ <role-hint>jdo</role-hint>
+ <field-name>projectModelDAO</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role>
+ <role-hint>jdo</role-hint>
+ <field-name>repoContentStatisticsDAO</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.archiva.database.ArtifactDAO</role>
+ <role-hint>jdo</role-hint>
+ <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.archiva.database.ProjectModelDAO</role>
+ <role-hint>jdo</role-hint>
+ <implementation>org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role>
+ <role-hint>jdo</role-hint>
+ <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub</implementation>
+ </component>
+ </components>
+</plexus>