List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>( proxyConnectorConfigurations.size() );
for ( ProxyConnectorConfiguration configuration : proxyConnectorConfigurations )
{
- ProxyConnector proxyConnector = new ProxyConnector();
- proxyConnectors.add( proxyConnector );
- proxyConnector.setOrder( configuration.getOrder() );
- proxyConnector.setBlackListPatterns( new ArrayList<String>( configuration.getBlackListPatterns() ) );
- proxyConnector.setWhiteListPatterns( new ArrayList<String>( configuration.getWhiteListPatterns() ) );
- proxyConnector.setDisabled( configuration.isDisabled() );
- proxyConnector.setPolicies( new HashMap<String, String>( configuration.getPolicies() ) );
- proxyConnector.setProperties( new HashMap<String, String>( configuration.getProperties() ) );
- proxyConnector.setProxyId( configuration.getProxyId() );
- proxyConnector.setSourceRepoId( configuration.getSourceRepoId() );
- proxyConnector.setTargetRepoId( configuration.getTargetRepoId() );
+ proxyConnectors.add( getProxyConnector( configuration ) );
}
return proxyConnectors;
return proxyConnectorMap;
}
- public ProxyConnector findProxyConnector( String sourceId, String targetId )
- throws RepositoryAdminException
- {
- return getProxyConnector(
- findProxyConnector( sourceId, targetId, getArchivaConfiguration().getConfiguration() ) );
- }
-
private ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId,
Configuration configuration )
{
*/
public static final String POLICY_CACHE_FAILURES = "cache-failures";
-/**
+ /**
*
* The order of the proxy connectors. (0 means no order specified)
* .
Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
throws RepositoryAdminException;
- ProxyConnector findProxyConnector( String sourceId, String targetId )
- throws RepositoryAdminException;
-
-
}
public void findProxyConnector()
throws Exception
{
- ProxyConnector proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+ ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
assertNotNull( proxyConnector );
}
- @Test
+ @Test
public void updateProxyConnector()
throws Exception
{
- ProxyConnector proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+ ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
assertNotNull( proxyConnector );
proxyConnector.setDisabled( false );
proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
assertFalse( proxyConnector.isDisabled() );
-
proxyConnector.setDisabled( true );
proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
assertTrue( proxyConnector.isDisabled() );
proxyConnector.setOrder( 4 );
proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
- proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+ proxyConnector = proxyConnectorAdmin.getProxyConnector( "internal", "central" );
assertEquals( 4, proxyConnector.getOrder() );
}
private String name;
- private String location;
-
private String layout;
+ private String location;
+
private boolean snapshots = false;
private boolean releases = false;
// no op
}
- public ManagedRepository( String id, String name, String location, String layout, boolean snapshots, boolean releases,
- boolean blockRedeployments, boolean stageRepoNeeded, String cronExpression )
+ public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
+ boolean releases, boolean blockRedeployments, boolean stageRepoNeeded,
+ String cronExpression )
{
this.id = id;
this.name = name;
--- /dev/null
+package org.apache.archiva.rest.api.model;
+/*
+ * 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 javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@XmlRootElement( name = "proxyConnector" )
+public class ProxyConnector
+ implements Serializable
+{
+ /**
+ * The order of the proxy connectors. (0 means no order specified)
+ * .
+ */
+ private int order = 0;
+
+ /**
+ * The Repository Source for this connector.
+ */
+ private String sourceRepoId;
+
+ /**
+ * The Repository Target for this connector.
+ */
+ private String targetRepoId;
+
+ /**
+ * The network proxy ID to use for this connector.
+ */
+ private String proxyId;
+
+ /**
+ * Field blackListPatterns.
+ */
+ private List<String> blackListPatterns;
+
+ /**
+ * Field whiteListPatterns.
+ */
+ private List<String> whiteListPatterns;
+
+ /**
+ * Field policies.
+ */
+ private Map<String, String> policies;
+
+ /**
+ * Field properties.
+ */
+ private Map<String, String> properties;
+
+ /**
+ * If the the repository proxy connector is disabled or not
+ */
+ private boolean disabled = false;
+
+ /**
+ * Get the order of the proxy connectors. (0 means no order specified)
+ *
+ * @return int
+ */
+ public int getOrder()
+ {
+ return this.order;
+ }
+
+
+ /**
+ * Set the order of the proxy connectors. (0 means no order specified)
+ *
+ * @param order
+ */
+ public void setOrder( int order )
+ {
+ this.order = order;
+ }
+
+ public String getSourceRepoId()
+ {
+ return sourceRepoId;
+ }
+
+ public void setSourceRepoId( String sourceRepoId )
+ {
+ this.sourceRepoId = sourceRepoId;
+ }
+
+ public String getTargetRepoId()
+ {
+ return targetRepoId;
+ }
+
+ public void setTargetRepoId( String targetRepoId )
+ {
+ this.targetRepoId = targetRepoId;
+ }
+
+ public String getProxyId()
+ {
+ return proxyId;
+ }
+
+ public void setProxyId( String proxyId )
+ {
+ this.proxyId = proxyId;
+ }
+
+ public List<String> getBlackListPatterns()
+ {
+ return blackListPatterns;
+ }
+
+ public void setBlackListPatterns( List<String> blackListPatterns )
+ {
+ this.blackListPatterns = blackListPatterns;
+ }
+
+ public List<String> getWhiteListPatterns()
+ {
+ return whiteListPatterns;
+ }
+
+ public void setWhiteListPatterns( List<String> whiteListPatterns )
+ {
+ this.whiteListPatterns = whiteListPatterns;
+ }
+
+ public Map<String, String> getPolicies()
+ {
+ return policies;
+ }
+
+ public void setPolicies( Map<String, String> policies )
+ {
+ this.policies = policies;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties( Map<String, String> properties )
+ {
+ this.properties = properties;
+ }
+
+ public boolean isDisabled()
+ {
+ return disabled;
+ }
+
+ public void setDisabled( boolean disabled )
+ {
+ this.disabled = disabled;
+ }
+}
private String name;
- private String url;
-
private String layout;
+ private String url;
+
private String userName;
private String password;
--- /dev/null
+package org.apache.archiva.rest.api.services;
+/*
+ * 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.repository.RepositoryAdminException;
+import org.apache.archiva.rest.api.model.ProxyConnector;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <b>No update method for changing source and target here as id is : sourceRepoId and targetRepoId, use delete then add.</b>
+ *
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Path( "/proxyConnectorService/" )
+public interface ProxyConnectorService
+{
+ @Path( "getProxyConnectors" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ List<ProxyConnector> getProxyConnectors()
+ throws RepositoryAdminException;
+
+ @Path( "getProxyConnector" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ ProxyConnector getProxyConnector( @QueryParam( "sourceRepoId" ) String sourceRepoId, @QueryParam( "targetRepoId" ) String targetRepoId )
+ throws RepositoryAdminException;
+
+ @Path( "addProxyConnector" )
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ Boolean addProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException;
+
+ @Path( "deleteProxyConnector" )
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ Boolean deleteProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException;
+
+ /**
+ * <b>only for enabled/disable or changing bean values except target/source</b>
+ *
+ * @param proxyConnector
+ * @return
+ * @throws org.apache.archiva.admin.repository.RepositoryAdminException
+ *
+ */
+ @Path( "updateProxyConnector" )
+ @POST
+ @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ Boolean updateProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException;
+
+
+ @Path( "getProxyConnectorAsMap" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+ throws RepositoryAdminException;
+
+}
import org.apache.archiva.rest.api.model.Artifact;
import org.apache.archiva.rest.api.model.Dependency;
+import javax.ws.rs.Path;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;
-@XmlRootElement( name = "searchRequest" )
+@Path( "/searchService/" )
public interface SearchService
{
/*
<artifactId>jsr311-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.sf.beanlib</groupId>
+ <artifactId>beanlib</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<!-- normally not needed but here for wadl feature currently in cxf -->
<dependency>
<groupId>org.apache.cxf</groupId>
--- /dev/null
+package org.apache.archiva.rest.services;
+/*
+ * 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 net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.rest.api.model.ProxyConnector;
+import org.apache.archiva.rest.api.services.ProxyConnectorService;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Olivier Lamy
+ */
+@Service( "proxyConnectorService#rest" )
+public class DefaultProxyConnectorService
+ extends AbstractRestService
+ implements ProxyConnectorService
+{
+ @Inject
+ private ProxyConnectorAdmin proxyConnectorAdmin;
+
+ public List<ProxyConnector> getProxyConnectors()
+ throws RepositoryAdminException
+ {
+ List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>();
+ for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() )
+ {
+ proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
+ }
+ return proxyConnectors;
+ }
+
+ public ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
+ throws RepositoryAdminException
+ {
+ org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector =
+ proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
+ return proxyConnector == null
+ ? null
+ : new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class );
+ }
+
+ public Boolean addProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException
+ {
+ if ( proxyConnector == null )
+ {
+ return Boolean.FALSE;
+ }
+ return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
+ org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ getAuditInformation() );
+ }
+
+ public Boolean deleteProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException
+ {
+ if ( proxyConnector == null )
+ {
+ return Boolean.FALSE;
+ }
+ return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
+ org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ getAuditInformation() );
+ }
+
+ public Boolean updateProxyConnector( ProxyConnector proxyConnector )
+ throws RepositoryAdminException
+ {
+ if ( proxyConnector == null )
+ {
+ return Boolean.FALSE;
+ }
+ return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
+ org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
+ getAuditInformation() );
+ }
+
+ public Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+ throws RepositoryAdminException
+ {
+ Map<String, List<org.apache.archiva.admin.repository.proxyconnector.ProxyConnector>> modelMap =
+ proxyConnectorAdmin.getProxyConnectorAsMap();
+ if ( modelMap == null || modelMap.isEmpty() )
+ {
+ return Collections.emptyMap();
+ }
+ Map<String, List<ProxyConnector>> map = new HashMap<String, List<ProxyConnector>>( modelMap.size() );
+ for ( Map.Entry<String, List<org.apache.archiva.admin.repository.proxyconnector.ProxyConnector>> entry : modelMap.entrySet() )
+ {
+ List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>( entry.getValue().size() );
+ for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : entry.getValue() )
+ {
+ proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
+ }
+ map.put( entry.getKey(), proxyConnectors );
+ }
+ return map;
+ }
+
+
+ public ProxyConnectorAdmin getProxyConnectorAdmin()
+ {
+ return proxyConnectorAdmin;
+ }
+
+ public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
+ {
+ this.proxyConnectorAdmin = proxyConnectorAdmin;
+ }
+}
+
+
<ref bean="managedRepositoriesService#rest"/>
<ref bean="remoteRepositoriesService#rest"/>
<ref bean="repositoryGroupService#rest"/>
+ <ref bean="proxyConnectorService#rest"/>
</jaxrs:serviceBeans>
<jaxrs:outInterceptors>