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.migration; 017 018import java.io.IOException; 019import java.io.InputStream; 020 021/** 022 * An interface defining access to information about a version of a 023 * fedora datastream. 024 * @author mdurbin 025 */ 026public interface DatastreamVersion { 027 028 /** 029 * Gets the information about the datastream for which this is 030 * a version. (which in turn can be queried to get information about 031 * the object). 032 * 033 * @return {@link org.fcrepo.migration.DatastreamInfo} 034 */ 035 public DatastreamInfo getDatastreamInfo(); 036 037 /** 038 * Gets the id for this version. 039 * 040 * @return version id 041 */ 042 public String getVersionId(); 043 044 /** 045 * Gets the mime type for this version. 046 * 047 * @return mime-type 048 */ 049 public String getMimeType(); 050 051 /** 052 * Gets the label for this version. 053 * 054 * @return label 055 */ 056 public String getLabel(); 057 058 /** 059 * Gets the date when this version was created. 060 * 061 * @return creation date 062 */ 063 public String getCreated(); 064 065 /** 066 * Gets the altIDs value for this version. 067 * 068 * @return alternate IDs 069 */ 070 public String getAltIds(); 071 072 /** 073 * Gets the format URI for this version. 074 * 075 * @return format URI 076 */ 077 public String getFormatUri(); 078 079 /** 080 * Gets the size (in bytes) for the content of this datastream 081 * version. 082 * 083 * @return size 084 */ 085 public long getSize(); 086 087 /** 088 * Gets the content digest (if available) for this version. 089 * 090 * @return {@link org.fcrepo.migration.ContentDigest} 091 */ 092 public ContentDigest getContentDigest(); 093 094 /** 095 * Gets access to the content of this datastream. When text, the 096 * encoding can be expected to be UTF-8. 097 * 098 * @return {@link java.io.InputStream of content} 099 * @throws IllegalStateException if invoked outside of the call 100 * to @{link StreamingFedoraObjectHandler#processDatastreamVersion} 101 * @throws IOException when unable to access the stream 102 */ 103 public InputStream getContent() throws IOException; 104 105 /** 106 * Returns the URL to which an External (X) or Redirect (R) datastream 107 * points. Throws IllegalStateException if this isn't an external or 108 * redirect datastream. 109 * 110 * @return URL of datastream 111 */ 112 public String getExternalOrRedirectURL(); 113 114 /** 115 * Determines if this is the first version of a datastream. 116 * 117 * @param obj to be tested whether is first version 118 * 119 * @return True if this is the first version, false otherwise. 120 */ 121 public boolean isFirstVersionIn(ObjectReference obj); 122 123 /** 124 * Determines if this is the last version of a datastream. 125 * 126 * @param obj to be tested whether is last version 127 * 128 * @return True if this is the last version, false otherwise. 129 */ 130 public boolean isLastVersionIn(ObjectReference obj); 131}