001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.http.commons;
007
008import java.util.function.Supplier;
009
010import javax.inject.Inject;
011import javax.ws.rs.core.Context;
012import javax.ws.rs.core.HttpHeaders;
013import javax.ws.rs.core.UriInfo;
014
015import org.fcrepo.config.FedoraPropsConfig;
016import org.fcrepo.kernel.api.models.ResourceFactory;
017import org.fcrepo.kernel.api.services.VersionService;
018import org.fcrepo.kernel.api.services.functions.ConfigurableHierarchicalSupplier;
019import org.fcrepo.kernel.api.services.functions.UniqueValueSupplier;
020
021import org.jvnet.hk2.annotations.Optional;
022
023/**
024 * Superclass for Fedora JAX-RS Resources, providing convenience fields and methods.
025 *
026 * @author ajs6f
027 */
028public class AbstractResource {
029
030    @Inject
031    protected FedoraPropsConfig fedoraPropsConfig;
032
033    /**
034     * Useful for constructing URLs
035     */
036    @Context
037    protected UriInfo uriInfo;
038
039    /**
040     * For getting user agent
041     */
042    @Context
043    protected HttpHeaders headers;
044
045    @Inject
046    protected ResourceFactory resourceFactory;
047
048    /**
049     * The version service
050     */
051    @Inject
052    protected VersionService versionService;
053
054    /**
055     * A resource that can mint new Fedora PIDs.
056     */
057    @Inject
058    @Optional
059    protected Supplier<String> pidMinter;
060
061    // Mint non-hierarchical identifiers. To force pairtree creation as default, use
062    //  ConfigurableHierarchicalSupplier(int length, count) instead.
063    protected UniqueValueSupplier defaultPidMinter = new ConfigurableHierarchicalSupplier();
064
065}