001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Anahide Tchertchian 011 */ 012package org.nuxeo.ecm.core.api.externalblob; 013 014import java.io.IOException; 015import java.io.Serializable; 016import java.util.Map; 017 018import org.nuxeo.ecm.core.api.Blob; 019import org.nuxeo.ecm.core.api.PropertyException; 020 021/** 022 * Interface to implement when defining a way to get a {@link Blob} that is not stored at the usual place handled by the 023 * repository. 024 * <p> 025 * This is done storing a string instead of a blob, using a prefix that makes it possible to find the adapter in charge 026 * of retrieving the file. It makes it also possible to use the same adapter implementation for different 027 * configurations, in conjunction with properties. 028 * <p> 029 * The string will look something like "fs:file/foo.odt", "fs" being the prefix, and "file/foo.odt" being the local 030 * name, with all the needed information to retrieve the actual file for this adapter. 031 * 032 * @author Anahide Tchertchian 033 */ 034public interface ExternalBlobAdapter extends Serializable { 035 036 String PREFIX_SEPARATOR = ":"; 037 038 /** 039 * Returns the prefix to use as marker for this adapter 040 */ 041 String getPrefix(); 042 043 /** 044 * Sets the prefix to use as marker for this adapter 045 */ 046 void setPrefix(String prefix); 047 048 /** 049 * Return specific properties for this adapter. Can be used for whatever useful property. 050 */ 051 Map<String, String> getProperties(); 052 053 /** 054 * Return property with gievn name. 055 * <p> 056 * Returns null if no property value is found. 057 */ 058 String getProperty(String name); 059 060 /** 061 * Set specific properties for this adapter. Can be used for whatever useful property. 062 */ 063 void setProperties(Map<String, String> properties); 064 065 /** 066 * Retrieves the blob for given uri. 067 * 068 * @param uri the uri describing what adapter handles the file and the needed info to retrieve it. 069 * @return the resolved blob. 070 * @throws PropertyException if the blob cannot be retrieved (if adapter cannot retrieve it or if file is not found 071 * for instance) 072 */ 073 Blob getBlob(String uri) throws PropertyException, IOException; 074 075}