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