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.utils;
019
020import java.io.InputStream;
021import java.net.URI;
022import java.util.Collection;
023
024import org.fcrepo.kernel.api.exception.UnsupportedAlgorithmException;
025
026/**
027 * A CacheEntry abstraction for the various possible types of entries
028 * @author fasseg
029 *
030 */
031public interface CacheEntry {
032
033    /**
034     * Check the fixity of a {@link CacheEntry}
035     * @param algorithm the given algorithm
036     * @return a {@link FixityResult} containing the relevant data
037     */
038    Collection<FixityResult> checkFixity(final String algorithm);
039
040    /**
041     * Check the fixity of a {@link CacheEntry} with list of digest algorithms
042     * @param algorithms the given algorithms
043     * @return a {@link FixityResult} containing the relevant data
044     * @throws UnsupportedAlgorithmException in case the fixity check tries to use an unsupported algorithm
045     */
046    Collection<URI> checkFixity(final Collection<String> algorithms) throws UnsupportedAlgorithmException;
047
048    /**
049     * Get a raw input stream from the underlying store
050     * @return the content for this entry
051     */
052    InputStream getInputStream();
053
054    /**
055     * Generate a human-readable identifier for the location of this entry
056     *
057     * @return human-readable identifier for the location of this entry
058     */
059    String getExternalIdentifier();
060}