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