001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.server.core.replication; 021 022 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException; 023 import org.apache.directory.shared.ldap.util.LdapURL; 024 025 /** 026 * The replication provider data structure. 027 * 028 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 029 * @version $Rev: $, $Date: $ 030 */ 031 public class ReplicationProvider 032 { 033 /** The provider unique identifier */ 034 private int id; 035 036 /** The type of replication (refreshOnly or refreshAndPersist */ 037 private ReplicationType type = ReplicationType.REFRESH_AND_PERSIST; 038 039 /** The sizeLimit for the searchRequest. Default to unlimited. */ 040 private long sizeLimit = 0; 041 042 /** The timeLimit for the search request. Default to unlimited. */ 043 private int timeLimit = 0; 044 045 /** The search operation to conduct */ 046 private LdapURL url; 047 048 /** The connection to the replica */ 049 private ReplicaConnection connection; 050 051 052 /** 053 * @return the connection 054 */ 055 public ReplicaConnection getConnection() 056 { 057 return connection; 058 } 059 060 061 /** 062 * @param connection the connection to set 063 */ 064 public void setConnection( ReplicaConnection connection ) 065 { 066 this.connection = connection; 067 } 068 069 070 public ReplicationProvider() 071 { 072 type = ReplicationType.REFRESH_AND_PERSIST; 073 } 074 075 076 /** 077 * @return the providerId 078 */ 079 public int getId() 080 { 081 return id; 082 } 083 084 085 /** 086 * @param id the provider Id to set 087 */ 088 public void setId( int id ) 089 { 090 this.id = id; 091 } 092 093 094 /** 095 * @return the type 096 */ 097 public ReplicationType getReplicationType() 098 { 099 return type; 100 } 101 102 103 /** 104 * @param type the replication type to set 105 */ 106 public void setType( String type ) 107 { 108 this.type = ReplicationType.getInstance( type ); 109 } 110 111 112 /** 113 * @return the sizeLimit 114 */ 115 public long getSizeLimit() 116 { 117 return sizeLimit; 118 } 119 120 121 /** 122 * @param sizeLimit the sizeLimit to set 123 */ 124 public void setSizeLimit( long sizeLimit ) 125 { 126 this.sizeLimit = sizeLimit; 127 } 128 129 130 /** 131 * @return the timeLimit 132 */ 133 public int getTimeLimit() 134 { 135 return timeLimit; 136 } 137 138 139 /** 140 * @param timeLimit the timeLimit to set 141 */ 142 public void setTimeLimit( int timeLimit ) 143 { 144 this.timeLimit = timeLimit; 145 } 146 147 148 /** 149 * @return the url 150 */ 151 public LdapURL getUrl() 152 { 153 return url; 154 } 155 156 157 /** 158 * 159 * @param url The URL to use for the replication search request 160 */ 161 public void setUrl( String url ) 162 { 163 try 164 { 165 this.url = new LdapURL( url ); 166 } 167 catch ( LdapURLEncodingException luee ) 168 { 169 this.url = null; 170 } 171 } 172 }