import com.opensymphony.xwork.Preparable;
import org.apache.commons.collections.Closure;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Transformer;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.archiva.web.action.admin.repositories.AdminRepositoryConfiguration;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
extends PlexusActionSupport
implements SecureAction, Preparable
{
- /**
- * @plexus.requirement role-hint="adminrepoconfig"
- */
- private Transformer repoConfigToAdmin;
-
/**
* @plexus.requirement
*/
private ArchivaConfiguration archivaConfiguration;
- private Map /*<String,AdminRepositoryConfiguration>*/repoMap;
+ private Map repoMap;
/**
* Map of Proxy Connectors.
*/
- private Map /*<String,AdminProxyConnector>*/proxyConnectorMap;
+ private Map proxyConnectorMap;
public void prepare()
- throws Exception
{
Configuration config = archivaConfiguration.getConfiguration();
repoMap = new HashMap();
-
- Closure addToRepoMap = new Closure()
- {
- public void execute( Object input )
- {
- AdminRepositoryConfiguration arepo =
- (AdminRepositoryConfiguration) repoConfigToAdmin.transform( input );
- repoMap.put( arepo.getId(), arepo );
- }
- };
-
- CollectionUtils.forAllDo( config.getManagedRepositories(), addToRepoMap );
- CollectionUtils.forAllDo( config.getRemoteRepositories(), addToRepoMap );
+ repoMap.putAll( config.getRemoteRepositoriesAsMap() );
+ repoMap.putAll( config.getManagedRepositoriesAsMap() );
proxyConnectorMap = new HashMap();
return repoMap;
}
- public void setRepoMap( Map repoMap )
- {
- this.repoMap = repoMap;
- }
-
public Map getProxyConnectorMap()
{
return proxyConnectorMap;
}
-
- public void setProxyConnectorMap( Map proxyConnectorMap )
- {
- this.proxyConnectorMap = proxyConnectorMap;
- }
}
+++ /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 org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.model.RepositoryContentStatistics;
-
-/**
- * AdminRepositoryConfiguration
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- * @todo! split from remote repo (which shouldn't need stats, use native class)
- */
-public class AdminRepositoryConfiguration
- extends ManagedRepositoryConfiguration
-{
- private RepositoryContentStatistics stats;
-
- public AdminRepositoryConfiguration()
- {
- }
-
- /**
- * Copy Constructor.
- */
- public AdminRepositoryConfiguration( ManagedRepositoryConfiguration repoconfig )
- {
- this.setId( repoconfig.getId() );
- this.setName( repoconfig.getName() );
- this.setLocation( repoconfig.getLocation() );
- this.setLayout( repoconfig.getLayout() );
- this.setIndexed( repoconfig.isIndexed() );
- this.setReleases( repoconfig.isReleases() );
- this.setSnapshots( repoconfig.isSnapshots() );
-
- this.setIndexDir( repoconfig.getIndexDir() );
- this.setRefreshCronExpression( repoconfig.getRefreshCronExpression() );
-
- this.setDaysOlder( repoconfig.getDaysOlder() );
- this.setRetentionCount( repoconfig.getRetentionCount() );
- this.setDeleteReleasedSnapshots( repoconfig.isDeleteReleasedSnapshots() );
- }
-
- public RepositoryContentStatistics getStats()
- {
- return stats;
- }
-
- public void setStats( RepositoryContentStatistics stats )
- {
- this.stats = stats;
- }
-}
/**
* The model for this action.
*/
- private AdminRepositoryConfiguration repository;
+ private ManagedRepositoryConfiguration repository;
/**
* @plexus.requirement role-hint="default"
String result = SUCCESS;
if ( StringUtils.equals( mode, "delete-entry" ) || StringUtils.equals( mode, "delete-contents" ) )
{
- AdminRepositoryConfiguration existingRepository = repository;
+ ManagedRepositoryConfiguration existingRepository = repository;
if ( existingRepository == null )
{
addActionError( "A repository with that id does not exist" );
return result;
}
- public AdminRepositoryConfiguration getRepository()
+ public ManagedRepositoryConfiguration getRepository()
{
return repository;
}
String id = repoid;
if ( id == null )
{
- this.repository = new AdminRepositoryConfiguration();
+ this.repository = new ManagedRepositoryConfiguration();
this.repository.setReleases( false );
this.repository.setIndexed( false );
}
-
- ManagedRepositoryConfiguration repoconfig =
- archivaConfiguration.getConfiguration().findManagedRepositoryById( id );
- if ( repoconfig != null )
+ else
{
- this.repository = new AdminRepositoryConfiguration( repoconfig );
+ repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( id );
}
}
return containsError;
}
- private void addRepository( AdminRepositoryConfiguration repository, Configuration configuration )
+ private void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
throws IOException, RoleManagerException
{
// Normalize the path
roleManager.createTemplatedRole( "archiva-repository-observer", repository.getId() );
}
- private void removeContents( AdminRepositoryConfiguration existingRepository )
+ private void removeContents( ManagedRepositoryConfiguration existingRepository )
throws IOException
{
FileUtils.deleteDirectory( new File( existingRepository.getLocation() ) );
+++ /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 org.apache.commons.collections.Transformer;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
-import org.apache.maven.archiva.model.RepositoryContentStatistics;
-
-import java.util.List;
-
-/**
- * RepositoryConfigurationAdminTransformer
- *
- * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
- * @version $Id$
- * @todo check usages!
- * @plexus.component role="org.apache.commons.collections.Transformer"
- * role-hint="adminrepoconfig"
- */
-public class RepositoryConfigurationAdminTransformer
- implements Transformer
-{
- /**
- * @plexus.requirement role-hint="jdo"
- */
- private ArchivaDAO dao;
-
- public Object transform( Object input )
- {
- if ( input instanceof ManagedRepositoryConfiguration )
- {
- ManagedRepositoryConfiguration repoconfig = (ManagedRepositoryConfiguration) input;
- AdminRepositoryConfiguration arepo = new AdminRepositoryConfiguration( repoconfig );
-
- arepo.setStats( getLatestStats( arepo.getId() ) );
-
- return arepo;
- }
-
- return null;
- }
-
- private RepositoryContentStatistics getLatestStats( String repoId )
- {
- List results = dao.query( new MostRecentRepositoryScanStatistics( repoId ) );
- if ( results.isEmpty() )
- {
- return null;
- }
-
- return (RepositoryContentStatistics) results.get( 0 );
- }
-}
action.prepare();
assertNull( action.getRepoid() );
assertNull( action.getMode() );
- AdminRepositoryConfiguration configuration = action.getRepository();
+ ManagedRepositoryConfiguration configuration = action.getRepository();
assertNotNull( configuration );
assertNull( configuration.getId() );
// check all booleans are false
action.prepare();
action.setMode( "add" );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
assertFalse( location.exists() );
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
action.prepare();
action.setMode( "edit" );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
repository.setName( "new repo name" );
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
ManagedRepositoryConfiguration originalRepository = createRepository();
Configuration configuration = executeDeletionTest( "unmodified", originalRepository );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories() );
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertEquals( mode, action.getMode() );
- AdminRepositoryConfiguration repository = action.getRepository();
+ ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );