mirror of https://github.com/apache/archiva.git
[MRM-1579] rewrite repositories scanning admin page
start some refactoring to ease implementation (reusable beans) git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1298148 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
18f3888b23
commit
1f1599658f
|
@ -1,4 +1,4 @@
|
||||||
package org.apache.archiva.web.action.admin.scanning;
|
package org.apache.archiva.rest.api.model;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -19,17 +19,34 @@ package org.apache.archiva.web.action.admin.scanning;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdminRepositoryConsumer
|
* AdminRepositoryConsumer
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
@XmlRootElement( name = "adminRepositoryConsumer" )
|
||||||
public class AdminRepositoryConsumer
|
public class AdminRepositoryConsumer
|
||||||
{
|
{
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
public AdminRepositoryConsumer()
|
||||||
|
{
|
||||||
|
// no op
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdminRepositoryConsumer( boolean enabled, String id, String description )
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.id = id;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
|
@ -296,4 +296,43 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------
|
||||||
|
// repository scanning part
|
||||||
|
//---------------------------
|
||||||
|
|
||||||
|
FileType=function(id,patterns){
|
||||||
|
//private String id;
|
||||||
|
this.id=ko.observable(id);
|
||||||
|
|
||||||
|
//private List<String> patterns;
|
||||||
|
this.patterns=ko.observableArray(patterns);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mapFileType=function(data){
|
||||||
|
return new FileType(data.id,data.patterns);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapFileTypes=function(data){
|
||||||
|
if (data!=null){
|
||||||
|
return $.isArray(data)? $.map(data,function(item){
|
||||||
|
return mapFileType(item)
|
||||||
|
}):[mapFileType(data)];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
displayRepositoryScanning=function(){
|
||||||
|
|
||||||
|
$.ajax("restServices/archivaServices/archivaAdministrationService/getFileTypes", {
|
||||||
|
type: "GET",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data){
|
||||||
|
var fileTypes=mapFileTypes(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -45,6 +45,9 @@
|
||||||
<li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
|
<li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
|
||||||
<a href="#" id="menu-legacy-support-list-a" onclick="displayLegacyArtifactPathSupport()">${$.i18n.prop('menu.legacy-artifact-support')}</a>
|
<a href="#" id="menu-legacy-support-list-a" onclick="displayLegacyArtifactPathSupport()">${$.i18n.prop('menu.legacy-artifact-support')}</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
|
||||||
|
<a href="#" id="menu-repository-scanning-list-a" onclick="displayRepositoryScanning()">${$.i18n.prop('menu.repository-scanning')}</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="nav nav-list" redback-permissions="{permissions: ['archiva-manage-users']}">
|
<ul class="nav nav-list" redback-permissions="{permissions: ['archiva-manage-users']}">
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.web.action.admin.scanning;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||||
import org.apache.commons.collections.Closure;
|
import org.apache.commons.collections.Closure;
|
||||||
import org.apache.archiva.consumers.RepositoryContentConsumer;
|
import org.apache.archiva.consumers.RepositoryContentConsumer;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.archiva.web.action.admin.scanning;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.archiva.admin.model.beans.FileType;
|
||||||
import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
|
import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
|
||||||
import org.apache.archiva.audit.Auditable;
|
import org.apache.archiva.audit.Auditable;
|
||||||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
||||||
|
import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -67,7 +68,7 @@ public class RepositoryScanningAction
|
||||||
private List<String> fileTypeIds;
|
private List<String> fileTypeIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of {@link AdminRepositoryConsumer} objects for consumers of known content.
|
* List of {@link org.apache.archiva.rest.api.model.AdminRepositoryConsumer} objects for consumers of known content.
|
||||||
*/
|
*/
|
||||||
private List<AdminRepositoryConsumer> knownContentConsumers;
|
private List<AdminRepositoryConsumer> knownContentConsumers;
|
||||||
|
|
||||||
|
@ -102,6 +103,30 @@ public class RepositoryScanningAction
|
||||||
log.info( "[ActionMessage] {}", aMessage );
|
log.info( "[ActionMessage] {}", aMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void prepare()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
|
||||||
|
|
||||||
|
CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
|
||||||
|
fileTypeMap = filetypeToMapClosure.getMap();
|
||||||
|
|
||||||
|
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
||||||
|
new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
|
||||||
|
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
|
||||||
|
this.knownContentConsumers = addAdminRepoConsumer.getList();
|
||||||
|
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||||
|
|
||||||
|
addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
|
||||||
|
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
|
||||||
|
this.invalidContentConsumers = addAdminRepoConsumer.getList();
|
||||||
|
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||||
|
|
||||||
|
fileTypeIds = new ArrayList<String>();
|
||||||
|
fileTypeIds.addAll( fileTypeMap.keySet() );
|
||||||
|
Collections.sort( fileTypeIds );
|
||||||
|
}
|
||||||
|
|
||||||
public String addFiletypePattern()
|
public String addFiletypePattern()
|
||||||
{
|
{
|
||||||
log.info( "Add New File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
|
log.info( "Add New File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
|
||||||
|
@ -187,32 +212,6 @@ public class RepositoryScanningAction
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
|
|
||||||
|
|
||||||
CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
|
|
||||||
fileTypeMap = filetypeToMapClosure.getMap();
|
|
||||||
|
|
||||||
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
|
||||||
new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
|
|
||||||
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
|
|
||||||
this.knownContentConsumers = addAdminRepoConsumer.getList();
|
|
||||||
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
|
||||||
|
|
||||||
addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
|
|
||||||
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
|
|
||||||
this.invalidContentConsumers = addAdminRepoConsumer.getList();
|
|
||||||
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
|
||||||
|
|
||||||
fileTypeIds = new ArrayList<String>();
|
|
||||||
fileTypeIds.addAll( fileTypeMap.keySet() );
|
|
||||||
Collections.sort( fileTypeIds );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFileTypeId( String fileTypeId )
|
public void setFileTypeId( String fileTypeId )
|
||||||
{
|
{
|
||||||
this.fileTypeId = fileTypeId;
|
this.fileTypeId = fileTypeId;
|
||||||
|
|
Loading…
Reference in New Issue