mirror of https://github.com/apache/archiva.git
[MRM-1579] rewrite repositories scanning admin page
improve rest services to ease screen implementation. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1298149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1f1599658f
commit
1646114f7a
|
@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
|
|||
import org.apache.archiva.admin.model.beans.NetworkConfiguration;
|
||||
import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
||||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
||||
|
||||
|
@ -157,6 +158,26 @@ public interface ArchivaAdministrationService
|
|||
List<String> getKnownContentConsumers()
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "getKnownContentAdminRepositoryConsumers" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||
/**
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
List<AdminRepositoryConsumer> getKnownContentAdminRepositoryConsumers()
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "getInvalidContentAdminRepositoryConsumers" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||
/**
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
List<AdminRepositoryConsumer> getInvalidContentAdminRepositoryConsumers()
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "getInvalidContentConsumers" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
|
|
|
@ -27,8 +27,13 @@ import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
|||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
||||
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||
import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
|
||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
import org.apache.archiva.rest.services.utils.AddAdminRepoConsumerClosure;
|
||||
import org.apache.archiva.rest.services.utils.AdminRepositoryConsumerComparator;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -55,6 +60,9 @@ public class DefaultArchivaAdministrationService
|
|||
@Named( value = "managedRepositoryContent#legacy" )
|
||||
private ManagedRepositoryContent repositoryContent;
|
||||
|
||||
@Inject
|
||||
private RepositoryContentConsumers repoConsumerUtil;
|
||||
|
||||
public List<LegacyArtifactPath> getLegacyArtifactPaths()
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
|
@ -386,4 +394,40 @@ public class DefaultArchivaAdministrationService
|
|||
throw new ArchivaRestServiceException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public List<AdminRepositoryConsumer> getKnownContentAdminRepositoryConsumers()
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
try
|
||||
{
|
||||
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
||||
new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
|
||||
CollectionUtils.forAllDo( repoConsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
|
||||
List<AdminRepositoryConsumer> knownContentConsumers = addAdminRepoConsumer.getList();
|
||||
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||
return knownContentConsumers;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new ArchivaRestServiceException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public List<AdminRepositoryConsumer> getInvalidContentAdminRepositoryConsumers()
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
try
|
||||
{
|
||||
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
||||
new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
|
||||
CollectionUtils.forAllDo( repoConsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
|
||||
List<AdminRepositoryConsumer> invalidContentConsumers = addAdminRepoConsumer.getList();
|
||||
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||
return invalidContentConsumers;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new ArchivaRestServiceException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.archiva.web.action.admin.scanning;
|
||||
package org.apache.archiva.rest.services.utils;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.archiva.web.action.admin.scanning;
|
||||
package org.apache.archiva.rest.services.utils;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -22,10 +22,12 @@ import org.apache.archiva.admin.model.beans.FileType;
|
|||
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
|
||||
import org.apache.archiva.admin.model.beans.OrganisationInformation;
|
||||
import org.apache.archiva.admin.model.beans.UiConfiguration;
|
||||
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
|
@ -130,4 +132,54 @@ public class ArchivaAdministrationServiceTest
|
|||
assertFalse( ui.isAppletFindEnabled() );
|
||||
assertFalse( ui.isShowFindArtifacts() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getKnownContentAdminRepositoryConsumer()
|
||||
throws Exception
|
||||
{
|
||||
List<AdminRepositoryConsumer> consumers =
|
||||
getArchivaAdministrationService().getKnownContentAdminRepositoryConsumers();
|
||||
assertFalse( consumers.isEmpty() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInvalidContentAdminRepositoryConsumer()
|
||||
throws Exception
|
||||
{
|
||||
List<AdminRepositoryConsumer> consumers =
|
||||
getArchivaAdministrationService().getInvalidContentAdminRepositoryConsumers();
|
||||
assertFalse( consumers.isEmpty() );
|
||||
assertAllDisabled( consumers );
|
||||
|
||||
getArchivaAdministrationService().addInvalidContentConsumer( "foo" );
|
||||
|
||||
consumers = getArchivaAdministrationService().getInvalidContentAdminRepositoryConsumers();
|
||||
assertFalse( consumers.isEmpty() );
|
||||
assertAllEnabled( consumers );
|
||||
|
||||
|
||||
getArchivaAdministrationService().removeInvalidContentConsumer( "foo" );
|
||||
|
||||
consumers = getArchivaAdministrationService().getInvalidContentAdminRepositoryConsumers();
|
||||
|
||||
assertAllDisabled( consumers );
|
||||
|
||||
assertFalse( consumers.isEmpty() );
|
||||
}
|
||||
|
||||
private void assertAllEnabled( List<AdminRepositoryConsumer> consumers )
|
||||
{
|
||||
for ( AdminRepositoryConsumer consumer : consumers )
|
||||
{
|
||||
assertTrue( consumer.isEnabled() );
|
||||
}
|
||||
}
|
||||
|
||||
private void assertAllDisabled( List<AdminRepositoryConsumer> consumers )
|
||||
{
|
||||
for ( AdminRepositoryConsumer consumer : consumers )
|
||||
{
|
||||
assertFalse( consumer.isEnabled() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package org.apache.archiva.rest.services.utils;
|
||||
/*
|
||||
* 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.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.consumers.ConsumerException;
|
||||
import org.apache.archiva.consumers.ConsumerMonitor;
|
||||
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
*/
|
||||
@Service( "InvalidRepositoryContentConsumer#mock" )
|
||||
public class MockInvalidRepositoryContentConsumer
|
||||
implements InvalidRepositoryContentConsumer
|
||||
{
|
||||
public String getId()
|
||||
{
|
||||
return "foo";
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return "the foo";
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addConsumerMonitor( ConsumerMonitor monitor )
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void removeConsumerMonitor( ConsumerMonitor monitor )
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public List<String> getIncludes()
|
||||
{
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public List<String> getExcludes()
|
||||
{
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepository repository, Date whenGathered )
|
||||
throws ConsumerException
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
|
||||
throws ConsumerException
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void processFile( String path )
|
||||
throws ConsumerException
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void processFile( String path, boolean executeOnEntireRepo )
|
||||
throws Exception
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void completeScan( boolean executeOnEntireRepo )
|
||||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public boolean isProcessUnmodified()
|
||||
{
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
|
@ -28,6 +28,8 @@ import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
|
|||
import org.apache.archiva.audit.Auditable;
|
||||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
||||
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||
import org.apache.archiva.rest.services.utils.AddAdminRepoConsumerClosure;
|
||||
import org.apache.archiva.rest.services.utils.AdminRepositoryConsumerComparator;
|
||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
|
Loading…
Reference in New Issue