The NetworkConfiguration .
</description>
</field>
+ <field>
+ <name>proxyConnectorRuleConfigurations</name>
+ <version>1.4.0+</version>
+ <association>
+ <type>ProxyConnectorRuleConfiguration</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ The list of ProxyConnectorRuleConfigurations.
+ </description>
+ </field>
</fields>
<codeSegments>
<codeSegment>
</codeSegments>
</class>
+ <class>
+ <name>ProxyConnectorRuleConfiguration</name>
+ <version>1.4.0+</version>
+ <fields>
+ <field>
+ <name>ruleType</name>
+ <version>1.4.0+</version>
+ <type>String</type>
+ <description>
+ The type if this rule: whiteList, blackList etc..
+ </description>
+ </field>
+ <field>
+ <name>pattern</name>
+ <version>1.4.0+</version>
+ <type>String</type>
+ <description>
+ The pattern for this rule: whiteList, blackList etc..
+ </description>
+ </field>
+ <field>
+ <name>proxyConnectors</name>
+ <version>1.4.0+</version>
+ <description>Associated proxyConnectors configuration.</description>
+ <association>
+ <type>ProxyConnectorConfiguration</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ </fields>
+ </class>
+
<class>
<superClass>AbstractRepositoryConnectorConfiguration</superClass>
<name>ProxyConnectorConfiguration</name>
--- /dev/null
+package org.apache.archiva.admin.model.beans;
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+@XmlRootElement ( name = "proxyConnectorRule" )
+public class ProxyConnectorRule
+ implements Serializable
+{
+ private String pattern;
+
+ //FIXME: olamy possible tru rest ? or a String
+ private ProxyConnectorRuleType proxyConnectorRuleType;
+
+ private List<ProxyConnector> proxyConnectors;
+
+ public ProxyConnectorRule()
+ {
+ // no op
+ }
+
+ public ProxyConnectorRule( String pattern, ProxyConnectorRuleType proxyConnectorRuleType,
+ List<ProxyConnector> proxyConnectors )
+ {
+ this.pattern = pattern;
+ this.proxyConnectorRuleType = proxyConnectorRuleType;
+ this.proxyConnectors = proxyConnectors;
+ }
+
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+ public void setPattern( String pattern )
+ {
+ this.pattern = pattern;
+ }
+
+ public ProxyConnectorRuleType getProxyConnectorRuleType()
+ {
+ return proxyConnectorRuleType;
+ }
+
+ public void setProxyConnectorRuleType( ProxyConnectorRuleType proxyConnectorRuleType )
+ {
+ this.proxyConnectorRuleType = proxyConnectorRuleType;
+ }
+
+ public List<ProxyConnector> getProxyConnectors()
+ {
+ if ( this.proxyConnectors == null )
+ {
+ this.proxyConnectors = new ArrayList<ProxyConnector>();
+ }
+ return proxyConnectors;
+ }
+
+ public void setProxyConnectors( List<ProxyConnector> proxyConnectors )
+ {
+ this.proxyConnectors = proxyConnectors;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof ProxyConnectorRule ) )
+ {
+ return false;
+ }
+
+ ProxyConnectorRule that = (ProxyConnectorRule) o;
+
+ if ( !pattern.equals( that.pattern ) )
+ {
+ return false;
+ }
+ if ( proxyConnectorRuleType != that.proxyConnectorRuleType )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = pattern.hashCode();
+ result = 31 * result + proxyConnectorRuleType.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ProxyConnectorRule" );
+ sb.append( "{pattern='" ).append( pattern ).append( '\'' );
+ sb.append( ", proxyConnectorRuleType=" ).append( proxyConnectorRuleType );
+ sb.append( ", proxyConnectors=" ).append( proxyConnectors );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
--- /dev/null
+package org.apache.archiva.admin.model.beans;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public enum ProxyConnectorRuleType
+{
+ WHITE_LIST( "whiteList" ), BLACK_LIST( "blackList" );
+
+ private String ruleType;
+
+ private ProxyConnectorRuleType( String ruleType )
+ {
+ this.ruleType = ruleType;
+ }
+
+ public void setRuleType( String ruleType )
+ {
+ this.ruleType = ruleType;
+ }
+
+ public String getRuleType()
+ {
+ return ruleType;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ProxyConnectorRuleType" );
+ sb.append( "{ruleType='" ).append( ruleType ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRule;
import java.util.List;
import java.util.Map;
--- /dev/null
+package org.apache.archiva.admin.model.proxyconnectorrule;
+/*
+ * 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.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRule;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public interface ProxyConnectorRuleAdmin
+{
+ /**
+ * @return
+ * @throws org.apache.archiva.admin.model.RepositoryAdminException
+ *
+ * @since 1.4-M3
+ */
+ List<ProxyConnectorRule> getProxyConnectorRules()
+ throws RepositoryAdminException;
+
+ /**
+ * @param proxyConnectorRule
+ * @throws RepositoryAdminException
+ * @since 1.4-M3
+ */
+ void addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ /**
+ * @param proxyConnectorRule
+ * @throws RepositoryAdminException
+ * @since 1.4-M3
+ */
+ void deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+
+ /**
+ * <b>only to update attached proxy connectors to update pattern delete then add</b>
+ * @param proxyConnectorRule
+ * @throws RepositoryAdminException
+ * @since 1.4-M3
+ */
+ void updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException;
+}
* @author Olivier Lamy
* @since 1.4-M1
*/
-@Service( "proxyConnectorAdmin#default" )
+@Service ( "proxyConnectorAdmin#default" )
public class DefaultProxyConnectorAdmin
extends AbstractRepositoryAdmin
implements ProxyConnectorAdmin
}
+ // FIXME take of proxyConnectorRules !
public Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
throws RepositoryAdminException
{
return Boolean.TRUE;
}
+ // FIXME take of proxyConnectorRules !
public Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
throws RepositoryAdminException
{
protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector )
{
- /*
- ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
- proxyConnectorConfiguration.setOrder( proxyConnector.getOrder() );
- proxyConnectorConfiguration.setBlackListPatterns(
- new ArrayList<String>( proxyConnector.getBlackListPatterns() ) );
- proxyConnectorConfiguration.setWhiteListPatterns(
- new ArrayList<String>( proxyConnector.getWhiteListPatterns() ) );
- proxyConnectorConfiguration.setDisabled( proxyConnector.isDisabled() );
- proxyConnectorConfiguration.setPolicies( new HashMap( proxyConnector.getPolicies() ) );
- proxyConnectorConfiguration.setProperties( new HashMap( proxyConnector.getProperties() ) );
- proxyConnectorConfiguration.setProxyId( proxyConnector.getProxyId() );
- proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
- proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
- return proxyConnectorConfiguration;*/
-
return proxyConnector == null
? null
: new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
--- /dev/null
+package org.apache.archiva.admin.repository.proxyconnectorrule;
+/*
+ * 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.AuditInformation;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRule;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRuleType;
+import org.apache.archiva.admin.model.proxyconnectorrule.ProxyConnectorRuleAdmin;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.configuration.ProxyConnectorRuleConfiguration;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+@Service ( "proxyConnectorRuleAdmin#default" )
+public class DefaultProxyConnectorRuleAdmin
+ extends AbstractRepositoryAdmin
+ implements ProxyConnectorRuleAdmin
+{
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ public List<ProxyConnectorRule> getProxyConnectorRules()
+ throws RepositoryAdminException
+ {
+ List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
+ getArchivaConfiguration().getConfiguration().getProxyConnectorRuleConfigurations();
+ if ( proxyConnectorRuleConfigurations.isEmpty() )
+ {
+ return Collections.emptyList();
+ }
+ List<ProxyConnectorRule> proxyConnectorRules =
+ new ArrayList<ProxyConnectorRule>( proxyConnectorRuleConfigurations.size() );
+ for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : proxyConnectorRuleConfigurations )
+ {
+
+ ProxyConnectorRule proxyConnectorRule = new ProxyConnectorRule();
+ proxyConnectorRule.setPattern( proxyConnectorRuleConfiguration.getPattern() );
+ proxyConnectorRule.setProxyConnectorRuleType(
+ getProxyConnectorRuleType( proxyConnectorRuleConfiguration.getRuleType() ) );
+ for ( ProxyConnectorConfiguration proxyConnectorConfiguration : proxyConnectorRuleConfiguration.getProxyConnectors() )
+ {
+ ProxyConnector proxyConnector = new ProxyConnector();
+ proxyConnector.setSourceRepoId( proxyConnectorConfiguration.getSourceRepoId() );
+ proxyConnector.setTargetRepoId( proxyConnectorConfiguration.getTargetRepoId() );
+ proxyConnectorRule.getProxyConnectors().add( proxyConnector );
+ }
+ proxyConnectorRules.add( proxyConnectorRule );
+ }
+
+ return proxyConnectorRules;
+ }
+
+
+ private ProxyConnectorRuleType getProxyConnectorRuleType( String type )
+ {
+ if ( StringUtils.equals( ProxyConnectorRuleType.WHITE_LIST.getRuleType(), type ) )
+ {
+ return ProxyConnectorRuleType.WHITE_LIST;
+ }
+ if ( StringUtils.equals( ProxyConnectorRuleType.BLACK_LIST.getRuleType(), type ) )
+ {
+ return ProxyConnectorRuleType.BLACK_LIST;
+ }
+ return null;
+ }
+
+ public void addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration = new ProxyConnectorRuleConfiguration();
+ proxyConnectorRuleConfiguration.setPattern( proxyConnectorRule.getPattern() );
+ proxyConnectorRuleConfiguration.setRuleType( proxyConnectorRule.getProxyConnectorRuleType().getRuleType() );
+ for ( ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors() )
+ {
+ ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
+ proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
+ proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
+ proxyConnectorRuleConfiguration.getProxyConnectors().add( proxyConnectorConfiguration );
+ }
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ configuration.getProxyConnectorRuleConfigurations().add( proxyConnectorRuleConfiguration );
+ saveConfiguration( configuration );
+ }
+
+ public void deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ // key is the pattern !!
+ // recreate a list without the pattern
+
+ boolean toSave = false;
+
+ List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations =
+ new ArrayList<ProxyConnectorRuleConfiguration>();
+
+ for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations() )
+ {
+ if ( StringUtils.equals( proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern() ) )
+ {
+ toSave = true;
+ }
+ else
+ {
+ proxyConnectorRuleConfigurations.add( proxyConnectorRuleConfiguration );
+ }
+ }
+
+ if ( toSave )
+ {
+ configuration.setProxyConnectorRuleConfigurations( proxyConnectorRuleConfigurations );
+ saveConfiguration( configuration );
+ }
+
+ }
+
+ public void updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule, AuditInformation auditInformation )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+
+ for ( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration : configuration.getProxyConnectorRuleConfigurations() )
+ {
+ if ( StringUtils.equals( proxyConnectorRuleConfiguration.getPattern(), proxyConnectorRule.getPattern() ) )
+ {
+ List<ProxyConnectorConfiguration> proxyConnectors =
+ new ArrayList<ProxyConnectorConfiguration>( proxyConnectorRule.getProxyConnectors().size() );
+ for ( ProxyConnector proxyConnector : proxyConnectorRule.getProxyConnectors() )
+ {
+ ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
+ proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
+ proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
+ proxyConnectors.add( proxyConnectorConfiguration );
+ }
+ proxyConnectorRuleConfiguration.setProxyConnectors( proxyConnectors );
+ saveConfiguration( configuration );
+ }
+ }
+
+ }
+}
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.model.proxyconnectorrule.ProxyConnectorRuleAdmin;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.redback.users.User;
import org.apache.commons.io.FileUtils;
@Inject
protected ProxyConnectorAdmin proxyConnectorAdmin;
+ @Inject
+ protected ProxyConnectorRuleAdmin proxyConnectorRuleAdmin;
+
protected AuditInformation getFakeAuditInformation()
{
AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost" );
--- /dev/null
+package org.apache.archiva.admin.repository.proxyconnectorrule;
+/*
+ * 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.ProxyConnector;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRule;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRuleType;
+import org.apache.archiva.admin.model.beans.RemoteRepository;
+import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ProxyConnectorRuleAdminTest
+ extends AbstractRepositoryAdminTest
+{
+ @Test
+ public void addProxyConnectorRule()
+ throws Exception
+ {
+ ProxyConnector proxyConnector = new ProxyConnector();
+ proxyConnector.setSourceRepoId( "snapshots" );
+ proxyConnector.setTargetRepoId( "central" );
+
+ ProxyConnectorRule rule = null;
+ try
+ {
+ int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
+ assertEquals( 0, size );
+
+ proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation() );
+
+ rule = new ProxyConnectorRule( "org/apache/maven", ProxyConnectorRuleType.BLACK_LIST,
+ Arrays.asList( proxyConnector ) );
+
+ proxyConnectorRuleAdmin.addProxyConnectorRule( rule, getFakeAuditInformation() );
+ assertEquals( size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size() );
+
+ rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get( 0 );
+
+ assertEquals( "org/apache/maven", rule.getPattern() );
+ assertEquals( 1, rule.getProxyConnectors().size() );
+ assertEquals( "snapshots", rule.getProxyConnectors().get( 0 ).getSourceRepoId() );
+ assertEquals( "central", rule.getProxyConnectors().get( 0 ).getTargetRepoId() );
+ assertEquals( ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType() );
+ }
+ finally
+ {
+ proxyConnectorRuleAdmin.deleteProxyConnectorRule( rule, getFakeAuditInformation() );
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation() );
+ }
+ }
+
+ @Test
+ public void addProxyConnectorRuleWithTwoProxyConnectors()
+ throws Exception
+ {
+ RemoteRepository remoteRepository = new RemoteRepository();
+ remoteRepository.setId( "archiva" );
+ remoteRepository.setName( "archiva rocks" );
+ remoteRepository.setUrl( "http://wine.org" );
+
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
+
+ int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
+ assertEquals( 0, size );
+ ProxyConnector proxyConnector1 = new ProxyConnector();
+ proxyConnector1.setSourceRepoId( "snapshots" );
+ proxyConnector1.setTargetRepoId( "central" );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector1, getFakeAuditInformation() );
+
+ ProxyConnector proxyConnector2 = new ProxyConnector();
+ proxyConnector2.setSourceRepoId( "snapshots" );
+ proxyConnector2.setTargetRepoId( "archiva" );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector2, getFakeAuditInformation() );
+
+ ProxyConnectorRule rule = new ProxyConnectorRule( "org/apache/maven", ProxyConnectorRuleType.BLACK_LIST,
+ Arrays.asList( proxyConnector1, proxyConnector2 ) );
+ try
+ {
+ proxyConnectorRuleAdmin.addProxyConnectorRule( rule, getFakeAuditInformation() );
+ assertEquals( size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size() );
+
+ rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get( 0 );
+
+ assertEquals( "org/apache/maven", rule.getPattern() );
+ assertEquals( 2, rule.getProxyConnectors().size() );
+ assertEquals( ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType() );
+ }
+ finally
+ {
+ proxyConnectorRuleAdmin.deleteProxyConnectorRule( rule, getFakeAuditInformation() );
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector1, getFakeAuditInformation() );
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector2, getFakeAuditInformation() );
+ remoteRepositoryAdmin.deleteRemoteRepository( remoteRepository.getId(), getFakeAuditInformation() );
+ }
+ }
+
+
+ @Test
+ public void updateProxyConnectorRuleWithTwoProxyConnectors()
+ throws Exception
+ {
+ RemoteRepository remoteRepository = new RemoteRepository();
+ remoteRepository.setId( "archiva" );
+ remoteRepository.setName( "archiva rocks" );
+ remoteRepository.setUrl( "http://wine.org" );
+
+ remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
+
+ int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
+ assertEquals( 0, size );
+ ProxyConnector proxyConnector1 = new ProxyConnector();
+ proxyConnector1.setSourceRepoId( "snapshots" );
+ proxyConnector1.setTargetRepoId( "central" );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector1, getFakeAuditInformation() );
+
+ ProxyConnector proxyConnector2 = new ProxyConnector();
+ proxyConnector2.setSourceRepoId( "snapshots" );
+ proxyConnector2.setTargetRepoId( "archiva" );
+ proxyConnectorAdmin.addProxyConnector( proxyConnector2, getFakeAuditInformation() );
+
+ ProxyConnectorRule rule = new ProxyConnectorRule( "org/apache/maven", ProxyConnectorRuleType.BLACK_LIST,
+ Arrays.asList( proxyConnector1, proxyConnector2 ) );
+ try
+ {
+ proxyConnectorRuleAdmin.addProxyConnectorRule( rule, getFakeAuditInformation() );
+ assertEquals( size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size() );
+
+ rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get( 0 );
+
+ assertEquals( "org/apache/maven", rule.getPattern() );
+ assertEquals( 2, rule.getProxyConnectors().size() );
+ //assertEquals( "snapshots", rule.getProxyConnectors().get( 0 ).getSourceRepoId() );
+ //assertEquals( "central", rule.getProxyConnectors().get( 0 ).getTargetRepoId() );
+ assertEquals( ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType() );
+
+ rule.setProxyConnectors( Arrays.asList( proxyConnector1 ) );
+
+ proxyConnectorRuleAdmin.updateProxyConnectorRule( rule, getFakeAuditInformation() );
+
+ assertEquals( size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size() );
+
+ rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get( 0 );
+
+ assertEquals( "org/apache/maven", rule.getPattern() );
+ assertEquals( 1, rule.getProxyConnectors().size() );
+ assertEquals( "snapshots", rule.getProxyConnectors().get( 0 ).getSourceRepoId() );
+ assertEquals( "central", rule.getProxyConnectors().get( 0 ).getTargetRepoId() );
+
+ }
+ finally
+ {
+ proxyConnectorRuleAdmin.deleteProxyConnectorRule( rule, getFakeAuditInformation() );
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector1, getFakeAuditInformation() );
+ proxyConnectorAdmin.deleteProxyConnector( proxyConnector2, getFakeAuditInformation() );
+ remoteRepositoryAdmin.deleteRemoteRepository( remoteRepository.getId(), getFakeAuditInformation() );
+ }
+ }
+
+}
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.admin.model.beans.ProxyConnector;
+import org.apache.archiva.admin.model.beans.ProxyConnectorRule;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
implements RemoteRepositoryAdmin, ManagedRepositoryAdmin, ProxyConnectorAdmin, NetworkProxyAdmin
{
@Inject
- @Named( value = "archivaConfiguration#test" )
+ @Named (value = "archivaConfiguration#test")
private ArchivaConfiguration archivaConfiguration;
public List<RemoteRepository> getRemoteRepositories()
? null
: new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
}
+
+ public List<ProxyConnectorRule> getProxyConnectorRules()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
+ throws RepositoryAdminException
+ {
+
+ }
+
+ public void updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
+ throws RepositoryAdminException
+ {
+
+ }
}