001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance 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, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.camel;
019
020import org.apache.camel.RuntimeCamelException;
021import org.apache.camel.spi.UriParam;
022import org.apache.camel.spi.UriParams;
023import org.springframework.transaction.PlatformTransactionManager;
024
025/**
026 * An FcrepoConfiguration class.
027 *
028 * @author Aaron Coburn
029 * @since Jan 20, 2015
030 */
031@UriParams
032public class FcrepoConfiguration implements Cloneable {
033
034    private String baseUrl = "";
035
036    @UriParam
037    private String contentType = null;
038
039    @UriParam
040    private String accept = null;
041
042    @UriParam
043    private String authUsername = null;
044
045    @UriParam
046    private String authPassword = null;
047
048    @UriParam
049    private String authHost = null;
050
051    @UriParam
052    private Boolean fixity = false;
053
054    @UriParam
055    private Boolean metadata = true;
056
057    @UriParam
058    private Boolean throwExceptionOnFailure = true;
059
060    @UriParam
061    private String preferInclude = null;
062
063    @UriParam
064    private String preferOmit = null;
065
066    @UriParam
067    private PlatformTransactionManager transactionManager = null;
068
069    /**
070     * Create a new FcrepoConfiguration object
071     */
072    public FcrepoConfiguration() {
073        super();
074    }
075
076    /**
077     * Copy an FcrepoConfiguration object.
078     *
079     * @return a copy of the component-wide configuration
080     */
081    @Override
082    public FcrepoConfiguration clone() {
083        try {
084            return (FcrepoConfiguration) super.clone();
085        } catch (CloneNotSupportedException e) {
086            throw new RuntimeCamelException(e);
087        }
088    }
089
090   /**
091     * baseUrl setter
092     * 
093     * @param url the baseUrl string
094     */
095    public void setBaseUrl(final String url) {
096        this.baseUrl = url;
097    }
098
099    /**
100     * baseUrl getter
101     *
102     * @return the fedora base url
103     */
104    public String getBaseUrl() {
105        return baseUrl;
106    }
107
108    /**
109     * accept setter
110     *
111     * @param type the mime-type for Accept headers
112     */
113    public void setAccept(final String type) {
114        this.accept = type.replaceAll(" ", "+");
115    }
116
117    /**
118     * accept getter
119     *
120     * @return the mime-type for Accept headers
121     */
122    public String getAccept() {
123        return accept;
124    }
125
126    /**
127     * contentType setter
128     *
129     * @param type the mime-type used with Content-Type headers
130     */
131    public void setContentType(final String type) {
132        this.contentType = type.replaceAll(" ", "+");
133    }
134
135    /**
136     * contentType getter
137     *
138     * @return the mime-type used with Content-Type headers
139     */
140    public String getContentType() {
141        return contentType;
142    }
143
144    /**
145     * authUsername setter
146     * 
147     * @param username used for repository authentication
148     */
149    public void setAuthUsername(final String username) {
150        this.authUsername = username;
151    }
152
153    /**
154     * authUsername getter
155     *
156     * @return the username used for repository authentication
157     */
158    public String getAuthUsername() {
159        return authUsername;
160    }
161
162    /**
163     * authPassword setter
164     * 
165     * @param password used for repository authentication
166     */
167    public void setAuthPassword(final String password) {
168        this.authPassword = password;
169    }
170
171    /**
172     * authPassword getter
173     *
174     * @return the password used for repository authentication
175     */
176    public String getAuthPassword() {
177        return authPassword;
178    }
179
180    /**
181     * authHost setter
182     * 
183     * @param host used for authentication
184     */
185    public void setAuthHost(final String host) {
186        this.authHost = host;
187    }
188
189    /**
190     * authHost getter
191     *
192     * @return the host realm used for repository authentication
193     */
194    public String getAuthHost() {
195        return authHost;
196    }
197
198    /**
199     * metadata setter
200     * 
201     * @param metadata whether to retrieve rdf metadata for non-rdf nodes
202     */
203    public void setMetadata(final Boolean metadata) {
204        this.metadata = metadata;
205    }
206
207    /**
208     * metadata getter
209     *
210     * @return whether to retrieve the rdf metadata for non-rdf nodes
211     */
212    public Boolean getMetadata() {
213        return metadata;
214    }
215
216    /**
217     * throwExceptionOnFailure setter
218     *
219     * @param throwOnFailure whether HTTP response errors throw exceptions
220     */
221    public void setThrowExceptionOnFailure(final Boolean throwOnFailure) {
222        this.throwExceptionOnFailure = throwOnFailure;
223    }
224
225    /**
226     * throwExceptionOnFailure getter
227     *
228     * @return whether HTTP response errors throw exceptions
229     */
230    public Boolean getThrowExceptionOnFailure() {
231        return throwExceptionOnFailure;
232    }
233
234    /**
235     * preferInclude setter
236     *
237     * @param include the URI(s) that populate the include section in a Prefer header
238     */
239    public void setPreferInclude(final String include) {
240        this.preferInclude = include;
241    }
242
243    /**
244     * preferInclude getter
245     * 
246     * @return the URI(s) that populate the include section in a Prefer header
247     */
248    public String getPreferInclude() {
249        return preferInclude;
250    }
251
252    /**
253     * preferOmit setter
254     *
255     * @param omit the URI(s) that populate the omit section in a Prefer header
256     */
257    public void setPreferOmit(final String omit) {
258        this.preferOmit = omit;
259    }
260
261    /**
262     * preferOmit getter
263     *
264     * @return the URI(s) that populate the omit section in a Prefer header
265     */
266    public String getPreferOmit() {
267        return preferOmit;
268    }
269
270
271    /**
272     * transactionManager setter
273     *
274     * @param transactionManager the transaction manager for handling transactions
275     */
276    public void setTransactionManager(final PlatformTransactionManager transactionManager) {
277        this.transactionManager = transactionManager;
278    }
279
280    /**
281     * transactionManger getter
282     *
283     * @return the transaction manager for handling transactions
284     */
285    public PlatformTransactionManager getTransactionManager() {
286        return transactionManager;
287    }
288
289    /**
290     * fixity setter
291     *
292     * @param fixity whether to run a fixity check on the fcrepo resource
293     */
294    public void setFixity(final Boolean fixity) {
295        this.fixity = fixity;
296    }
297
298    /**
299     * fixity getter
300     *
301     * @return whether to access the /fcr:fixity endpoint for a resource
302     */
303    public Boolean getFixity() {
304        return fixity;
305    }
306
307
308}