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.NonRdfSourceOperation; 026 027/** 028 * An abstract operation for interacting with a non-rdf source 029 * 030 * @author bbpennel 031 */ 032public abstract class AbstractNonRdfSourceOperation extends AbstractResourceOperation implements 033 NonRdfSourceOperation { 034 035 private InputStream content; 036 037 private URI externalHandlingURI; 038 039 private String externalHandlingType; 040 041 private String mimeType; 042 043 private String filename; 044 045 private Collection<URI> digests; 046 047 private long contentSize = -1; 048 049 /** 050 * Constructor for external content. 051 * 052 * @param rescId the internal identifier. 053 * @param externalContentURI the URI of the external content. 054 * @param externalHandling the type of external content handling (REDIRECT, PROXY) 055 */ 056 protected AbstractNonRdfSourceOperation(final FedoraId rescId, final URI externalContentURI, 057 final String externalHandling) { 058 super(rescId); 059 this.externalHandlingURI = externalContentURI; 060 this.externalHandlingType = externalHandling; 061 } 062 063 /** 064 * Constructor for internal binaries. 065 * 066 * @param rescId the internal identifier. 067 * @param content the stream of the content. 068 */ 069 protected AbstractNonRdfSourceOperation(final FedoraId rescId, final InputStream content) { 070 super(rescId); 071 this.content = content; 072 } 073 074 /** 075 * Basic constructor. 076 * 077 * @param rescId The internal Fedora ID. 078 */ 079 protected AbstractNonRdfSourceOperation(final FedoraId rescId) { 080 super(rescId); 081 } 082 083 @Override 084 public InputStream getContentStream() { 085 return content; 086 } 087 088 @Override 089 public String getExternalHandling() { 090 return externalHandlingType; 091 } 092 093 @Override 094 public URI getContentUri() { 095 return externalHandlingURI; 096 } 097 098 @Override 099 public String getMimeType() { 100 return mimeType; 101 } 102 103 @Override 104 public String getFilename() { 105 return filename; 106 } 107 108 @Override 109 public Collection<URI> getContentDigests() { 110 return digests; 111 } 112 113 @Override 114 public long getContentSize() { 115 return contentSize; 116 } 117 118 /** 119 * @return the content 120 */ 121 protected InputStream getContent() { 122 return content; 123 } 124 125 /** 126 * @param content the content to set 127 */ 128 protected void setContent(final InputStream content) { 129 this.content = content; 130 } 131 132 /** 133 * @return the externalHandlingURI 134 */ 135 protected URI getExternalHandlingURI() { 136 return externalHandlingURI; 137 } 138 139 /** 140 * @param externalHandlingURI the externalHandlingURI to set 141 */ 142 protected void setExternalHandlingURI(final URI externalHandlingURI) { 143 this.externalHandlingURI = externalHandlingURI; 144 } 145 146 /** 147 * @return the externalHandlingType 148 */ 149 protected String getExternalHandlingType() { 150 return externalHandlingType; 151 } 152 153 /** 154 * @param externalHandlingType the externalHandlingType to set 155 */ 156 protected void setExternalHandlingType(final String externalHandlingType) { 157 this.externalHandlingType = externalHandlingType; 158 } 159 160 /** 161 * @return the digests 162 */ 163 protected Collection<URI> getDigests() { 164 return digests; 165 } 166 167 /** 168 * @param digests the digests to set 169 */ 170 protected void setDigests(final Collection<URI> digests) { 171 this.digests = digests; 172 } 173 174 /** 175 * @param mimeType the mimeType to set 176 */ 177 protected void setMimeType(final String mimeType) { 178 this.mimeType = mimeType; 179 } 180 181 /** 182 * @param filename the filename to set 183 */ 184 protected void setFilename(final String filename) { 185 this.filename = filename; 186 } 187 188 /** 189 * @param contentSize the contentSize to set 190 */ 191 protected void setContentSize(final long contentSize) { 192 this.contentSize = contentSize; 193 } 194}