001 package 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 022 import org.apache.archiva.repository.ManagedRepositoryContent; 023 import org.apache.archiva.repository.RemoteRepositoryContent; 024 import org.apache.archiva.repository.connector.RepositoryConnector; 025 026 import java.util.Iterator; 027 import java.util.List; 028 import java.util.Map; 029 030 /** 031 * This represents a connector for a repository to repository proxy. 032 */ 033 public 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 public boolean isDisabled() 058 { 059 return disabled; 060 } 061 062 public void setDisabled( boolean disabled ) 063 { 064 this.disabled = disabled; 065 } 066 067 public List<String> getBlacklist() 068 { 069 return blacklist; 070 } 071 072 public void setBlacklist( List<String> blacklist ) 073 { 074 this.blacklist = blacklist; 075 } 076 077 public ManagedRepositoryContent getSourceRepository() 078 { 079 return sourceRepository; 080 } 081 082 public void setSourceRepository( ManagedRepositoryContent sourceRepository ) 083 { 084 this.sourceRepository = sourceRepository; 085 } 086 087 public RemoteRepositoryContent getTargetRepository() 088 { 089 return targetRepository; 090 } 091 092 public void setTargetRepository( RemoteRepositoryContent targetRepository ) 093 { 094 this.targetRepository = targetRepository; 095 } 096 097 public List<String> getWhitelist() 098 { 099 return whitelist; 100 } 101 102 public void setWhitelist( List<String> whitelist ) 103 { 104 this.whitelist = whitelist; 105 } 106 107 public Map<String, String> getPolicies() 108 { 109 return policies; 110 } 111 112 public void setPolicies( Map<String, String> policies ) 113 { 114 this.policies = policies; 115 } 116 117 public String getProxyId() 118 { 119 return proxyId; 120 } 121 122 public void setProxyId( String proxyId ) 123 { 124 this.proxyId = proxyId; 125 } 126 127 @Override 128 public String toString() 129 { 130 StringBuilder sb = new StringBuilder(); 131 132 sb.append( "ProxyConnector[\n" ); 133 sb.append( " source: [managed] " ).append( this.sourceRepository.getRepoRoot() ).append( "\n" ); 134 sb.append( " target: [remote] " ).append( this.targetRepository.getRepository().getUrl() ).append( "\n" ); 135 sb.append( " proxyId:" ).append( this.proxyId ).append( "\n" ); 136 137 Iterator<String> keys = this.policies.keySet().iterator(); 138 while ( keys.hasNext() ) 139 { 140 String name = keys.next(); 141 sb.append( " policy[" ).append( name ).append( "]:" ); 142 sb.append( this.policies.get( name ) ).append( "\n" ); 143 } 144 145 sb.append( "]" ); 146 147 return sb.toString(); 148 } 149 150 public void setPolicy( String policyId, String policySetting ) 151 { 152 this.policies.put( policyId, policySetting ); 153 } 154 155 public int getOrder() 156 { 157 return order; 158 } 159 160 public void setOrder( int order ) 161 { 162 this.order = order; 163 } 164 }