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.impl.operations; 007 008import java.io.InputStream; 009import java.net.URI; 010import java.util.Collection; 011 012import org.fcrepo.kernel.api.Transaction; 013import org.fcrepo.kernel.api.identifiers.FedoraId; 014import org.fcrepo.kernel.api.operations.NonRdfSourceOperationBuilder; 015 016/** 017 * An abstract operation for interacting with a non-rdf source 018 * 019 * @author bbpennel 020 */ 021public abstract class AbstractNonRdfSourceOperationBuilder implements NonRdfSourceOperationBuilder { 022 023 protected FedoraId resourceId; 024 025 protected InputStream content; 026 027 protected URI externalURI; 028 029 protected String externalType; 030 031 protected String mimeType; 032 033 protected String filename; 034 035 protected Collection<URI> digests; 036 037 protected long contentSize = -1; 038 039 protected String userPrincipal; 040 041 protected Transaction transaction; 042 043 /** 044 * Constructor for external binary. 045 * 046 * @param transaction the transaction 047 * @param rescId the internal identifier 048 * @param handling the external content handling type. 049 * @param externalUri the external content URI. 050 */ 051 protected AbstractNonRdfSourceOperationBuilder(final Transaction transaction, final FedoraId rescId, 052 final String handling, 053 final URI externalUri) { 054 this.transaction = transaction; 055 this.resourceId = rescId; 056 this.externalURI = externalUri; 057 this.externalType = handling; 058 } 059 060 /** 061 * Constructor for internal binary. 062 * 063 * @param transaction the transaction 064 * @param rescId the internal identifier. 065 * @param stream the content stream. 066 */ 067 protected AbstractNonRdfSourceOperationBuilder(final Transaction transaction, final FedoraId rescId, 068 final InputStream stream) { 069 this.transaction = transaction; 070 this.resourceId = rescId; 071 this.content = stream; 072 } 073 074 @Override 075 public NonRdfSourceOperationBuilder mimeType(final String mimetype) { 076 this.mimeType = mimetype; 077 return this; 078 } 079 080 @Override 081 public NonRdfSourceOperationBuilder filename(final String filename) { 082 this.filename = filename; 083 return this; 084 } 085 086 @Override 087 public NonRdfSourceOperationBuilder contentDigests(final Collection<URI> digests) { 088 this.digests = digests; 089 return this; 090 } 091 092 @Override 093 public NonRdfSourceOperationBuilder contentSize(final long size) { 094 this.contentSize = size; 095 return this; 096 } 097 098 @Override 099 public NonRdfSourceOperationBuilder userPrincipal(final String userPrincipal) { 100 this.userPrincipal = userPrincipal; 101 return this; 102 } 103}