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