View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.lib.to;
20  
21  import com.fasterxml.jackson.annotation.JsonIgnore;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
23  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
24  import io.swagger.v3.oas.annotations.media.Schema;
25  import java.util.ArrayList;
26  import java.util.EnumSet;
27  import java.util.List;
28  import java.util.Optional;
29  import java.util.Set;
30  import javax.ws.rs.PathParam;
31  import org.apache.commons.lang3.builder.EqualsBuilder;
32  import org.apache.commons.lang3.builder.HashCodeBuilder;
33  import org.apache.syncope.common.lib.types.ConnConfProperty;
34  import org.apache.syncope.common.lib.types.ConnectorCapability;
35  
36  public class ConnInstanceTO implements EntityTO {
37  
38      private static final long serialVersionUID = 2707778645445168671L;
39  
40      private String key;
41  
42      private boolean errored;
43  
44      private String adminRealm;
45  
46      private String location;
47  
48      private String connectorName;
49  
50      private String bundleName;
51  
52      private String version;
53  
54      private final List<ConnConfProperty> conf = new ArrayList<>();
55  
56      private final Set<ConnectorCapability> capabilities = EnumSet.noneOf(ConnectorCapability.class);
57  
58      private String displayName;
59  
60      private Integer connRequestTimeout;
61  
62      private ConnPoolConfTO poolConf;
63  
64      @Override
65      public String getKey() {
66          return key;
67      }
68  
69      @PathParam("key")
70      @Override
71      public void setKey(final String key) {
72          this.key = key;
73      }
74  
75      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
76      public boolean isErrored() {
77          return errored;
78      }
79  
80      public void setErrored(final boolean errored) {
81          this.errored = errored;
82      }
83  
84      public String getAdminRealm() {
85          return adminRealm;
86      }
87  
88      public void setAdminRealm(final String adminRealm) {
89          this.adminRealm = adminRealm;
90      }
91  
92      public String getLocation() {
93          return location;
94      }
95  
96      public void setLocation(final String location) {
97          this.location = location;
98      }
99  
100     public String getConnectorName() {
101         return connectorName;
102     }
103 
104     public void setConnectorName(final String connectorname) {
105         this.connectorName = connectorname;
106     }
107 
108     public String getBundleName() {
109         return bundleName;
110     }
111 
112     public void setBundleName(final String bundlename) {
113         this.bundleName = bundlename;
114     }
115 
116     public String getVersion() {
117         return version;
118     }
119 
120     public void setVersion(final String version) {
121         this.version = version;
122     }
123 
124     @JacksonXmlElementWrapper(localName = "conf")
125     @JacksonXmlProperty(localName = "property")
126     public List<ConnConfProperty> getConf() {
127         return this.conf;
128     }
129 
130     @JsonIgnore
131     public Optional<ConnConfProperty> getConf(final String schemaName) {
132         return conf.stream().filter(property -> property.getSchema().getName().equals(schemaName)).findFirst();
133     }
134 
135     @JacksonXmlElementWrapper(localName = "capabilities")
136     @JacksonXmlProperty(localName = "capability")
137     public Set<ConnectorCapability> getCapabilities() {
138         return capabilities;
139     }
140 
141     public String getDisplayName() {
142         return displayName;
143     }
144 
145     public void setDisplayName(final String displayName) {
146         this.displayName = displayName;
147     }
148 
149     /**
150      * Get connector request timeout.
151      * It is not applied in case of sync, full reconciliation and search.
152      *
153      * @return timeout.
154      */
155     public Integer getConnRequestTimeout() {
156         return connRequestTimeout;
157     }
158 
159     /**
160      * Set connector request timeout.
161      * It is not applied in case of sync, full reconciliation and search.
162      *
163      * @param connRequestTimeout timeout
164      */
165     public void setConnRequestTimeout(final Integer connRequestTimeout) {
166         this.connRequestTimeout = connRequestTimeout;
167     }
168 
169     public ConnPoolConfTO getPoolConf() {
170         return poolConf;
171     }
172 
173     public void setPoolConf(final ConnPoolConfTO poolConf) {
174         this.poolConf = poolConf;
175     }
176 
177     @Override
178     public boolean equals(final Object obj) {
179         if (this == obj) {
180             return true;
181         }
182         if (obj == null) {
183             return false;
184         }
185         if (getClass() != obj.getClass()) {
186             return false;
187         }
188         ConnInstanceTO other = (ConnInstanceTO) obj;
189         return new EqualsBuilder().
190                 append(key, other.key).
191                 append(errored, other.errored).
192                 append(adminRealm, other.adminRealm).
193                 append(location, other.location).
194                 append(connectorName, other.connectorName).
195                 append(bundleName, other.bundleName).
196                 append(version, other.version).
197                 append(conf, other.conf).
198                 append(capabilities, other.capabilities).
199                 append(displayName, other.displayName).
200                 append(connRequestTimeout, other.connRequestTimeout).
201                 append(poolConf, other.poolConf).
202                 build();
203     }
204 
205     @Override
206     public int hashCode() {
207         return new HashCodeBuilder().
208                 append(key).
209                 append(errored).
210                 append(adminRealm).
211                 append(location).
212                 append(connectorName).
213                 append(bundleName).
214                 append(version).
215                 append(conf).
216                 append(capabilities).
217                 append(displayName).
218                 append(connRequestTimeout).
219                 append(poolConf).
220                 build();
221     }
222 }