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.api.models; 017 018import com.hp.hpl.jena.rdf.model.Resource; 019import org.fcrepo.kernel.api.exception.InvalidChecksumException; 020import org.fcrepo.kernel.api.identifiers.IdentifierConverter; 021import org.fcrepo.kernel.api.RdfStream; 022import org.fcrepo.kernel.api.services.policy.StoragePolicyDecisionPoint; 023 024import java.io.InputStream; 025import java.net.URI; 026 027/** 028 * @author cabeer 029 * @since 9/19/14 030 */ 031public interface FedoraBinary extends NonRdfSource { 032 033 /** 034 * @return The InputStream of content associated with this datastream. 035 */ 036 InputStream getContent(); 037 038 /** 039 * Sets the content of this Datastream. 040 * 041 * @param content InputStream of binary content to be stored 042 * @param contentType MIME type of content (optional) 043 * @param checksum Checksum URI of the content (optional) 044 * @param originalFileName Original file name of the content (optional) 045 * @param storagePolicyDecisionPoint Policy decision point for storing the content (optional) 046 * @throws org.fcrepo.kernel.api.exception.InvalidChecksumException if invalid checksum exception occurred 047 */ 048 void setContent(InputStream content, String contentType, URI checksum, 049 String originalFileName, 050 StoragePolicyDecisionPoint storagePolicyDecisionPoint) 051 throws InvalidChecksumException; 052 053 /** 054 * @return The size in bytes of content associated with this datastream. 055 */ 056 long getContentSize(); 057 058 /** 059 * Get the pre-calculated content digest for the binary payload 060 * @return a URI with the format algorithm:value 061 */ 062 URI getContentDigest(); 063 064 /** 065 * @return The MimeType of content associated with this datastream. 066 */ 067 String getMimeType(); 068 069 /** 070 * Return the file name for the binary content 071 * @return original file name for the binary content, or the object's id. 072 */ 073 String getFilename(); 074 075 /** 076 * Get the fixity of this datastream compared to metadata stored in the repository 077 * @param idTranslator the id translator 078 * @return the fixity of this datastream compared to metadata stored in the repository 079 */ 080 RdfStream getFixity(IdentifierConverter<Resource, FedoraResource> idTranslator); 081 082 /** 083 * Get the fixity of this datastream in a given repository's binary store. 084 * @param idTranslator the id translator 085 * @param contentDigest the checksum to compare against 086 * @param size the expected size of the binary 087 * @return the fixity of the datastream 088 */ 089 RdfStream getFixity(IdentifierConverter<Resource, FedoraResource> idTranslator, 090 URI contentDigest, long size); 091}