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 transform = null;
044
045    @UriParam
046    private String authUsername = null;
047
048    @UriParam
049    private String authPassword = null;
050
051    @UriParam
052    private String authHost = null;
053
054    @UriParam
055    private Boolean tombstone = false;
056
057    @UriParam
058    private Boolean fixity = false;
059
060    @UriParam
061    private Boolean metadata = true;
062
063    @UriParam
064    private Boolean throwExceptionOnFailure = true;
065
066    @UriParam
067    private String preferInclude = null;
068
069    @UriParam
070    private String preferOmit = null;
071
072    @UriParam
073    private PlatformTransactionManager transactionManager = null;
074
075    /**
076     * Create a new FcrepoConfiguration object
077     */
078    public FcrepoConfiguration() {
079        super();
080    }
081
082    /**
083     * Copy an FcrepoConfiguration object.
084     *
085     * @return a copy of the component-wide configuration
086     */
087    @Override
088    public FcrepoConfiguration clone() {
089        try {
090            return (FcrepoConfiguration) super.clone();
091        } catch (CloneNotSupportedException e) {
092            throw new RuntimeCamelException(e);
093        }
094    }
095
096   /**
097     * baseUrl setter
098     * 
099     * @param url the baseUrl string
100     */
101    public void setBaseUrl(final String url) {
102        this.baseUrl = url;
103    }
104
105    /**
106     * baseUrl getter
107     *
108     * @return the fedora base url
109     */
110    public String getBaseUrl() {
111        return baseUrl;
112    }
113
114    /**
115     * accept setter
116     *
117     * @param type the mime-type for Accept headers
118     */
119    public void setAccept(final String type) {
120        this.accept = type.replaceAll(" ", "+");
121    }
122
123    /**
124     * accept getter
125     *
126     * @return the mime-type for Accept headers
127     */
128    public String getAccept() {
129        return accept;
130    }
131
132    /**
133     * contentType setter
134     *
135     * @param type the mime-type used with Content-Type headers
136     */
137    public void setContentType(final String type) {
138        this.contentType = type.replaceAll(" ", "+");
139    }
140
141    /**
142     * contentType getter
143     *
144     * @return the mime-type used with Content-Type headers
145     */
146    public String getContentType() {
147        return contentType;
148    }
149
150    /**
151     * authUsername setter
152     * 
153     * @param username used for repository authentication
154     */
155    public void setAuthUsername(final String username) {
156        this.authUsername = username;
157    }
158
159    /**
160     * authUsername getter
161     *
162     * @return the username used for repository authentication
163     */
164    public String getAuthUsername() {
165        return authUsername;
166    }
167
168    /**
169     * authPassword setter
170     * 
171     * @param password used for repository authentication
172     */
173    public void setAuthPassword(final String password) {
174        this.authPassword = password;
175    }
176
177    /**
178     * authPassword getter
179     *
180     * @return the password used for repository authentication
181     */
182    public String getAuthPassword() {
183        return authPassword;
184    }
185
186    /**
187     * authHost setter
188     * 
189     * @param host used for authentication
190     */
191    public void setAuthHost(final String host) {
192        this.authHost = host;
193    }
194
195    /**
196     * authHost getter
197     *
198     * @return the host realm used for repository authentication
199     */
200    public String getAuthHost() {
201        return authHost;
202    }
203
204    /**
205     * metadata setter
206     * 
207     * @param metadata whether to retrieve rdf metadata for non-rdf nodes
208     */
209    public void setMetadata(final Boolean metadata) {
210        this.metadata = metadata;
211    }
212
213    /**
214     * metadata getter
215     *
216     * @return whether to retrieve the rdf metadata for non-rdf nodes
217     */
218    public Boolean getMetadata() {
219        return metadata;
220    }
221
222    /**
223     * throwExceptionOnFailure setter
224     *
225     * @param throwOnFailure whether HTTP response errors throw exceptions
226     */
227    public void setThrowExceptionOnFailure(final Boolean throwOnFailure) {
228        this.throwExceptionOnFailure = throwOnFailure;
229    }
230
231    /**
232     * throwExceptionOnFailure getter
233     *
234     * @return whether HTTP response errors throw exceptions
235     */
236    public Boolean getThrowExceptionOnFailure() {
237        return throwExceptionOnFailure;
238    }
239
240    /**
241     * transform setter
242     * 
243     * @param transform define an LD-Path transform program for converting RDF to JSON
244     */
245    @Deprecated
246    public void setTransform(final String transform) {
247        this.transform = transform;
248    }
249
250    /**
251     * transform getter
252     *
253     * @return the name of an LD-Path transform program used to convert RDF to JSON
254     */
255    public String getTransform() {
256        return transform;
257    }
258
259    /**
260     * tombstone setter
261     * 
262     * @param tombstone whether to access the /fcr:tombstone endpoint for a resource
263     */
264    @Deprecated
265    public void setTombstone(final Boolean tombstone) {
266        this.tombstone = tombstone;
267    }
268
269    /**
270     * tombstone getter
271     *
272     * @return whether to access the /fcr:tombstone endpoint for a resource
273     */
274    public Boolean getTombstone() {
275        return tombstone;
276    }
277
278    /**
279     * preferInclude setter
280     *
281     * @param include the URI(s) that populate the include section in a Prefer header
282     */
283    public void setPreferInclude(final String include) {
284        this.preferInclude = include;
285    }
286
287    /**
288     * preferInclude getter
289     * 
290     * @return the URI(s) that populate the include section in a Prefer header
291     */
292    public String getPreferInclude() {
293        return preferInclude;
294    }
295
296    /**
297     * preferOmit setter
298     *
299     * @param omit the URI(s) that populate the omit section in a Prefer header
300     */
301    public void setPreferOmit(final String omit) {
302        this.preferOmit = omit;
303    }
304
305    /**
306     * preferOmit getter
307     *
308     * @return the URI(s) that populate the omit section in a Prefer header
309     */
310    public String getPreferOmit() {
311        return preferOmit;
312    }
313
314
315    /**
316     * transactionManager setter
317     *
318     * @param transactionManager the transaction manager for handling transactions
319     */
320    public void setTransactionManager(final PlatformTransactionManager transactionManager) {
321        this.transactionManager = transactionManager;
322    }
323
324    /**
325     * transactionManger getter
326     *
327     * @return the transaction manager for handling transactions
328     */
329    public PlatformTransactionManager getTransactionManager() {
330        return transactionManager;
331    }
332
333    /**
334     * fixity setter
335     *
336     * @param fixity whether to run a fixity check on the fcrepo resource
337     */
338    public void setFixity(final Boolean fixity) {
339        this.fixity = fixity;
340    }
341
342    /**
343     * fixity getter
344     *
345     * @return whether to access the /fcr:fixity endpoint for a resource
346     */
347    public Boolean getFixity() {
348        return fixity;
349    }
350
351
352}