mirror of https://github.com/apache/archiva.git
start work on proxy connector screen
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1237580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
256a116349
commit
91d63e741b
|
@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
||||||
|
import org.apache.archiva.rest.api.model.PolicyInformation;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
||||||
|
|
||||||
|
@ -85,5 +86,13 @@ public interface ProxyConnectorService
|
||||||
Boolean updateProxyConnector( ProxyConnector proxyConnector )
|
Boolean updateProxyConnector( ProxyConnector proxyConnector )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path( "allPolicies" )
|
||||||
|
@GET
|
||||||
|
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||||
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||||
|
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
|
List<PolicyInformation> getAllPolicyInformations()
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,21 @@ package org.apache.archiva.rest.services;
|
||||||
|
|
||||||
import org.apache.archiva.admin.model.AuditInformation;
|
import org.apache.archiva.admin.model.AuditInformation;
|
||||||
import org.apache.archiva.audit.AuditListener;
|
import org.apache.archiva.audit.AuditListener;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.codehaus.plexus.redback.users.User;
|
import org.codehaus.plexus.redback.users.User;
|
||||||
import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
|
import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
|
||||||
import org.codehaus.redback.rest.services.RedbackRequestInformation;
|
import org.codehaus.redback.rest.services.RedbackRequestInformation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* abstract class with common utilities methods
|
* abstract class with common utilities methods
|
||||||
|
@ -73,4 +77,21 @@ public abstract class AbstractRestService
|
||||||
? ""
|
? ""
|
||||||
: ":" + req.getServerPort() ) + req.getContextPath();
|
: ":" + req.getServerPort() ) + req.getContextPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <T> Map<String, T> getBeansOfType( ApplicationContext applicationContext, Class<T> clazz )
|
||||||
|
{
|
||||||
|
//TODO do some caching here !!!
|
||||||
|
// olamy : with plexus we get only roleHint
|
||||||
|
// as per convention we named spring bean role#hint remove role# if exists
|
||||||
|
Map<String, T> springBeans = applicationContext.getBeansOfType( clazz );
|
||||||
|
|
||||||
|
Map<String, T> beans = new HashMap<String, T>( springBeans.size() );
|
||||||
|
|
||||||
|
for ( Map.Entry<String, T> entry : springBeans.entrySet() )
|
||||||
|
{
|
||||||
|
String key = StringUtils.substringAfterLast( entry.getKey(), "#" );
|
||||||
|
beans.put( key, entry.getValue() );
|
||||||
|
}
|
||||||
|
return beans;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,15 @@ package org.apache.archiva.rest.services;
|
||||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
import org.apache.archiva.admin.model.beans.ProxyConnector;
|
||||||
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
|
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
|
||||||
|
import org.apache.archiva.policies.Policy;
|
||||||
|
import org.apache.archiva.rest.api.model.PolicyInformation;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||||
import org.apache.archiva.rest.api.services.ProxyConnectorService;
|
import org.apache.archiva.rest.api.services.ProxyConnectorService;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -40,6 +44,14 @@ public class DefaultProxyConnectorService
|
||||||
@Inject
|
@Inject
|
||||||
private ProxyConnectorAdmin proxyConnectorAdmin;
|
private ProxyConnectorAdmin proxyConnectorAdmin;
|
||||||
|
|
||||||
|
private List<Policy> allPolicies;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public DefaultProxyConnectorService( ApplicationContext applicationContext )
|
||||||
|
{
|
||||||
|
allPolicies = new ArrayList<Policy>( getBeansOfType( applicationContext, Policy.class ).values() );
|
||||||
|
}
|
||||||
|
|
||||||
public List<ProxyConnector> getProxyConnectors()
|
public List<ProxyConnector> getProxyConnectors()
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
{
|
{
|
||||||
|
@ -118,6 +130,21 @@ public class DefaultProxyConnectorService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PolicyInformation> getAllPolicyInformations()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
List<PolicyInformation> policyInformations = new ArrayList<PolicyInformation>( allPolicies.size() );
|
||||||
|
|
||||||
|
for ( Policy policy : allPolicies )
|
||||||
|
{
|
||||||
|
policyInformations.add(
|
||||||
|
new PolicyInformation( policy.getOptions(), policy.getDefaultOption(), policy.getId(),
|
||||||
|
policy.getName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return policyInformations;
|
||||||
|
}
|
||||||
|
|
||||||
public ProxyConnectorAdmin getProxyConnectorAdmin()
|
public ProxyConnectorAdmin getProxyConnectorAdmin()
|
||||||
{
|
{
|
||||||
return proxyConnectorAdmin;
|
return proxyConnectorAdmin;
|
||||||
|
|
Loading…
Reference in New Issue