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.kernel.api.services;
007
008import org.apache.jena.rdf.model.Model;
009import org.fcrepo.kernel.api.Transaction;
010import org.fcrepo.kernel.api.identifiers.FedoraId;
011import org.fcrepo.kernel.api.models.ExternalContent;
012
013import java.io.InputStream;
014import java.net.URI;
015import java.util.Collection;
016import java.util.List;
017
018/**
019 * Interface for a service to create a new resource via a POST request.
020 * @author whikloj
021 * @since 2019-11-05
022 */
023public interface CreateResourceService {
024
025    /**
026     * Create a new NonRdfSource resource.
027     *
028     * @param tx The transaction for the request.
029     * @param userPrincipal the principal of the user performing the service
030     * @param fedoraId The internal identifier of the resource.
031     * @param contentType The content-type header or null if none.
032     * @param filename The original filename of the binary
033     * @param contentSize The size of the content stream
034     * @param linkHeaders The original LINK headers or null if none.
035     * @param digest The binary digest or null if none.
036     * @param requestBody The request body or null if none.
037     * @param externalContent The external content handler or null if none.
038     */
039    void perform(Transaction tx, String userPrincipal, FedoraId fedoraId,
040                 String contentType, String filename, long contentSize, List<String> linkHeaders,
041                 Collection<URI> digest, InputStream requestBody, ExternalContent externalContent);
042
043    default void perform(Transaction tx, String userPrincipal, FedoraId fedoraId,
044                         List<String> linkHeaders, Model model) {
045        perform(tx, userPrincipal, fedoraId, linkHeaders, model, false);
046    }
047
048    /**
049     * Create a new RdfSource resource.
050     *
051     * @param tx The transaction for the request.
052     * @param userPrincipal the principal of the user performing the service
053     * @param fedoraId The internal identifier of the resource
054     * @param linkHeaders The original LINK headers or null if none.
055     * @param model The request body RDF as a Model
056     * @param isOverwrite if the new resource is overwriting a tombstone
057     */
058    void perform(Transaction tx, String userPrincipal, FedoraId fedoraId,
059            List<String> linkHeaders, Model model, boolean isOverwrite);
060
061}