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 *     Nuxeo - initial API and implementation
011 *
012 */
013package org.nuxeo.ecm.core.convert.cache;
014
015import java.io.IOException;
016
017import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
018
019/**
020 * Extended interface for {@link BlobHolder} that can be cached.
021 * <p>
022 * A BlobHolder can be cached if it can be persisted to disk and reloaded from a file. Converters need to return
023 * BlobHolders that implement this interface to make the result cachable.
024 *
025 * @author tiry
026 */
027public interface CachableBlobHolder extends BlobHolder {
028
029    /**
030     * Persists the blobHolder to disk.
031     *
032     * @param basePath the base path (existing directory) as determined by the caller
033     * @return the full path of the newly created FileSystem resource
034     */
035    String persist(String basePath) throws IOException;
036
037    /**
038     * Reloads the {@link BlobHolder} from a file.
039     *
040     * @param path
041     */
042    void load(String path) throws IOException;
043
044}