001/*
002 * (C) Copyright 2002-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.filemanager.api;
021
022import java.io.IOException;
023import java.security.NoSuchAlgorithmException;
024import java.security.Principal;
025import java.util.List;
026
027import org.nuxeo.ecm.core.api.Blob;
028import org.nuxeo.ecm.core.api.CoreSession;
029import org.nuxeo.ecm.core.api.DocumentLocation;
030import org.nuxeo.ecm.core.api.DocumentModel;
031import org.nuxeo.ecm.core.api.DocumentModelList;
032import org.nuxeo.ecm.core.api.VersioningOption;
033
034/**
035 * File Manager.
036 * <p>
037 * File Manager to handle file
038 *
039 * @author Andreas Kalogeropoulos
040 */
041public interface FileManager {
042
043    /**
044     * Returns an initialized doc based on a given blob.
045     *
046     * @param input the blob containing the content and the mime type
047     * @param path the path were to create the document
048     * @param overwrite boolean how decide to overwrite or not
049     * @param fullName the fullname that contains the filename
050     * @return the created Document
051     */
052    DocumentModel createDocumentFromBlob(CoreSession documentManager, Blob input, String path, boolean overwrite,
053            String fullName) throws IOException;
054
055    /**
056     * Just applies the same actions as creation but does not changes the doc type.
057     *
058     * @param input the blob containing the content and the mime type
059     * @param path the path to the file to update
060     * @param fullName the full name that contains the filename
061     * @return the updated Document
062     */
063    DocumentModel updateDocumentFromBlob(CoreSession documentManager, Blob input, String path, String fullName);
064
065    /**
066     * Creates a Folder.
067     *
068     * @param fullname the full name of the folder
069     * @param path the path were to create the folder
070     * @return the Folder Created
071     */
072    DocumentModel createFolder(CoreSession documentManager, String fullname, String path) throws
073            IOException;
074
075    /**
076     * Returns the list of document that are to be suggested to principalName as a candidate container for a new
077     * document of type docType on all registered repositories.
078     *
079     * @return the list of candidate containers
080     */
081    DocumentModelList getCreationContainers(Principal principal, String docType);
082
083    /**
084     * Returns the list of document that are to be suggested to the principal of documentManager as a candidate
085     * container for a new document of type docType.
086     *
087     * @return the list of candidate containers
088     */
089    DocumentModelList getCreationContainers(CoreSession documentManager, String docType);
090
091    List<DocumentLocation> findExistingDocumentWithFile(CoreSession documentManager, String path, String digest,
092            Principal principal);
093
094    boolean isUnicityEnabled();
095
096    List<String> getFields();
097
098    String getDigestAlgorithm();
099
100    boolean isDigestComputingEnabled();
101
102    /**
103     * Gets the versioning applied on an overwritten document before it is overwritten.
104     *
105     * @since 5.7
106     */
107    VersioningOption getVersioningOption();
108
109    /**
110     * Checks whether versioning should also be applied after a document is added.
111     *
112     * @since 5.7
113     */
114    boolean doVersioningAfterAdd();
115
116}