This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.proxy.model;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.repository.ManagedRepositoryContent;
023import org.apache.archiva.repository.RemoteRepositoryContent;
024import org.apache.archiva.repository.connector.RepositoryConnector;
025
026import java.util.Iterator;
027import java.util.List;
028import java.util.Map;
029
030/**
031 * This represents a connector for a repository to repository proxy.
032 */
033public class ProxyConnector
034    implements RepositoryConnector
035{
036    private ManagedRepositoryContent sourceRepository;
037
038    private RemoteRepositoryContent targetRepository;
039
040    private List<String> blacklist;
041
042    private List<String> whitelist;
043
044    private String proxyId;
045
046    private int order;
047
048    private Map<String, String> policies;
049
050    private boolean disabled;
051
052    public ProxyConnector()
053    {
054        // no op
055    }
056
057    @Override
058    public boolean isDisabled()
059    {
060        return disabled;
061    }
062
063    @Override
064    public void setDisabled( boolean disabled )
065    {
066        this.disabled = disabled;
067    }
068
069    @Override
070    public List<String> getBlacklist()
071    {
072        return blacklist;
073    }
074
075    public void setBlacklist( List<String> blacklist )
076    {
077        this.blacklist = blacklist;
078    }
079
080    @Override
081    public ManagedRepositoryContent getSourceRepository()
082    {
083        return sourceRepository;
084    }
085
086    public void setSourceRepository( ManagedRepositoryContent sourceRepository )
087    {
088        this.sourceRepository = sourceRepository;
089    }
090
091    @Override
092    public RemoteRepositoryContent getTargetRepository()
093    {
094        return targetRepository;
095    }
096
097    public void setTargetRepository( RemoteRepositoryContent targetRepository )
098    {
099        this.targetRepository = targetRepository;
100    }
101
102    @Override
103    public List<String> getWhitelist()
104    {
105        return whitelist;
106    }
107
108    public void setWhitelist( List<String> whitelist )
109    {
110        this.whitelist = whitelist;
111    }
112
113    public Map<String, String> getPolicies()
114    {
115        return policies;
116    }
117
118    public void setPolicies( Map<String, String> policies )
119    {
120        this.policies = policies;
121    }
122
123    public String getProxyId()
124    {
125        return proxyId;
126    }
127
128    public void setProxyId( String proxyId )
129    {
130        this.proxyId = proxyId;
131    }
132
133    @Override
134    public String toString()
135    {
136        StringBuilder sb = new StringBuilder();
137
138        sb.append( "ProxyConnector[\n" );
139        sb.append( "  source: [managed] " ).append( this.sourceRepository.getRepoRoot() ).append( "\n" );
140        sb.append( "  target: [remote] " ).append( this.targetRepository.getRepository().getUrl() ).append( "\n" );
141        sb.append( "  proxyId:" ).append( this.proxyId ).append( "\n" );
142
143        Iterator<String> keys = this.policies.keySet().iterator();
144        while ( keys.hasNext() )
145        {
146            String name = keys.next();
147            sb.append( "  policy[" ).append( name ).append( "]:" );
148            sb.append( this.policies.get( name ) ).append( "\n" );
149        }
150
151        sb.append( "]" );
152
153        return sb.toString();
154    }
155
156    public void setPolicy( String policyId, String policySetting )
157    {
158        this.policies.put( policyId, policySetting );
159    }
160
161    public int getOrder()
162    {
163        return order;
164    }
165
166    public void setOrder( int order )
167    {
168        this.order = order;
169    }
170}