001/* 002 * (C) Copyright 2006-2017 Nuxeo (http://nuxeo.com/) and others. 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 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 020 */ 021 022package org.nuxeo.ecm.platform.filemanager.api; 023 024import java.io.IOException; 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.NuxeoPrincipal; 033import org.nuxeo.ecm.core.api.VersioningOption; 034 035/** 036 * File Manager. 037 * <p> 038 * File Manager to handle file 039 * 040 * @author Andreas Kalogeropoulos 041 */ 042public interface FileManager { 043 044 /** 045 * Returns an initialized doc based on a given blob. 046 * 047 * @param input the blob containing the content and the mime type 048 * @param path the path were to create the document 049 * @param overwrite whether to overwrite an existing file with the same title or not 050 * @param fullName the fullname that contains the filename 051 * @return the created Document 052 * @deprecated since 10.10. Use {@link #createOrUpdateDocument(FileImporterContext)} instead. 053 */ 054 @Deprecated 055 DocumentModel createDocumentFromBlob(CoreSession documentManager, Blob input, String path, boolean overwrite, 056 String fullName) throws IOException; 057 058 /** 059 * Returns an initialized doc based on a given blob. 060 * 061 * @param input the blob containing the content and the mime type 062 * @param path the path were to create the document 063 * @param overwrite whether to overwrite an existing file with the same title or not 064 * @param fullName the fullname that contains the filename 065 * @param noMimeTypeCheck true if the blob's mime-type doesn't have to be checked against fullName 066 * @return the created Document 067 * @since 8.10 068 * @deprecated since 10.10. Use {@link #createOrUpdateDocument(FileImporterContext)} instead. 069 */ 070 @Deprecated 071 DocumentModel createDocumentFromBlob(CoreSession documentManager, Blob input, String path, boolean overwrite, 072 String fullName, boolean noMimeTypeCheck) throws IOException; 073 074 /** 075 * Returns a created or updated document based on the given {@code context}. 076 * <p> 077 * The document may not be persisted according to {@link FileImporterContext#isPersistDocument()}. That's the 078 * caller's responsibility to actually persist the document. 079 * <p> 080 * Note that file importers may not use {@link FileImporterContext#isPersistDocument()} and always persist the 081 * document. 082 * 083 * @return the created or updated document 084 * @see FileImporterContext 085 * @since 10.10 086 */ 087 DocumentModel createOrUpdateDocument(FileImporterContext context) throws IOException; 088 089 /** 090 * Just applies the same actions as creation but does not changes the doc type. 091 * 092 * @param input the blob containing the content and the mime type 093 * @param path the path to the file to update 094 * @param fullName the full name that contains the filename 095 * @return the updated Document 096 * @deprecated since 10.10. Not used. 097 */ 098 @Deprecated 099 DocumentModel updateDocumentFromBlob(CoreSession documentManager, Blob input, String path, String fullName); 100 101 /** 102 * Creates a Folder. 103 * 104 * @param fullname the full name of the folder 105 * @param path the path were to create the folder 106 * @return the Folder Created 107 * @deprecated since 9.1, use {@link #createFolder(CoreSession, String, String, boolean)} instead 108 */ 109 @Deprecated 110 default DocumentModel createFolder(CoreSession documentManager, String fullname, String path) throws IOException { 111 return createFolder(documentManager, fullname, path, true); 112 } 113 114 /** 115 * Creates a Folder. 116 * 117 * @param fullname the full name of the folder 118 * @param path the path were to create the folder 119 * @param overwrite whether to overwrite an existing folder with the same title or not 120 * @return the Folder Created 121 * @since 9.1 122 */ 123 DocumentModel createFolder(CoreSession documentManager, String fullname, String path, boolean overwrite) 124 throws IOException; 125 126 /** 127 * Returns the list of document that are to be suggested to principalName as a candidate container for a new 128 * document of type docType on all registered repositories. 129 * 130 * @return the list of candidate containers 131 */ 132 DocumentModelList getCreationContainers(NuxeoPrincipal principal, String docType); 133 134 /** 135 * Returns the list of document that are to be suggested to the principal of documentManager as a candidate 136 * container for a new document of type docType. 137 * 138 * @return the list of candidate containers 139 */ 140 DocumentModelList getCreationContainers(CoreSession documentManager, String docType); 141 142 List<DocumentLocation> findExistingDocumentWithFile(CoreSession documentManager, String path, String digest, 143 NuxeoPrincipal principal); 144 145 boolean isUnicityEnabled(); 146 147 List<String> getFields(); 148 149 String getDigestAlgorithm(); 150 151 boolean isDigestComputingEnabled(); 152 153 /** 154 * Gets the versioning applied on an overwritten document before it is overwritten. 155 * 156 * @since 5.7 157 * @deprecated since 9.1 automatic versioning is now handled at versioning service level, remove versioning 158 * behaviors from importers 159 */ 160 @Deprecated 161 VersioningOption getVersioningOption(); 162 163 /** 164 * Checks whether versioning should also be applied after a document is added. 165 * 166 * @since 5.7 167 * @deprecated since 9.1 automatic versioning is now handled at versioning service level, remove versioning 168 * behaviors from importers 169 */ 170 @Deprecated 171 boolean doVersioningAfterAdd(); 172 173}