001/** 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.kernel.models; 017 018import com.hp.hpl.jena.rdf.model.Resource; 019import org.fcrepo.kernel.exception.InvalidChecksumException; 020import org.fcrepo.kernel.identifiers.IdentifierConverter; 021import org.fcrepo.kernel.services.policy.StoragePolicyDecisionPoint; 022import org.fcrepo.kernel.utils.iterators.RdfStream; 023 024import javax.jcr.Binary; 025import java.io.InputStream; 026import java.net.URI; 027 028/** 029 * @author cabeer 030 * @since 9/19/14 031 */ 032public interface FedoraBinary extends NonRdfSource { 033 034 /** 035 * @return The InputStream of content associated with this datastream. 036 */ 037 InputStream getContent(); 038 039 040 /** 041 * @return The Binary content associated with this datastream. 042 */ 043 Binary getBinaryContent(); 044 045 /** 046 * Sets the content of this Datastream. 047 * 048 * @param content InputStream of binary content to be stored 049 * @param contentType MIME type of content (optional) 050 * @param checksum Checksum URI of the content (optional) 051 * @param originalFileName Original file name of the content (optional) 052 * @param storagePolicyDecisionPoint Policy decision point for storing the content (optional) 053 * @throws org.fcrepo.kernel.exception.InvalidChecksumException if invalid checksum exception occurred 054 */ 055 void setContent(InputStream content, String contentType, URI checksum, 056 String originalFileName, 057 StoragePolicyDecisionPoint storagePolicyDecisionPoint) 058 throws InvalidChecksumException; 059 060 /** 061 * @return The size in bytes of content associated with this datastream. 062 */ 063 long getContentSize(); 064 065 /** 066 * Get the pre-calculated content digest for the binary payload 067 * @return a URI with the format algorithm:value 068 */ 069 URI getContentDigest(); 070 071 /** 072 * @return The MimeType of content associated with this datastream. 073 */ 074 String getMimeType(); 075 076 /** 077 * Return the file name for the binary content 078 * @return original file name for the binary content, or the object's id. 079 */ 080 String getFilename(); 081 082 /** 083 * Get the fixity of this datastream compared to metadata stored in the repository 084 * @param idTranslator the id translator 085 * @return the fixity of this datastream compared to metadata stored in the repository 086 */ 087 RdfStream getFixity(IdentifierConverter<Resource, FedoraResource> idTranslator); 088 089 /** 090 * Get the fixity of this datastream in a given repository's binary store. 091 * @param idTranslator the id translator 092 * @param contentDigest the checksum to compare against 093 * @param size the expected size of the binary 094 * @return the fixity of the datastream 095 */ 096 RdfStream getFixity(IdentifierConverter<Resource, FedoraResource> idTranslator, 097 URI contentDigest, long size); 098}