001/* 002 * (C) Copyright 2012 Nuxeo SA (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 * Antoine Taillefer <ataillefer@nuxeo.com> 016 */ 017package org.nuxeo.drive.service; 018 019import java.util.Set; 020 021import org.nuxeo.drive.adapter.FileSystemItem; 022import org.nuxeo.drive.adapter.FolderItem; 023import org.nuxeo.drive.service.impl.FileSystemItemAdapterServiceImpl; 024import org.nuxeo.ecm.core.api.DocumentModel; 025 026/** 027 * Service for creating the right {@link FileSystemItem} adapter depending on the {@link DocumentModel} type or facet. 028 * <p> 029 * Factories can be contributed to implement a specific behavior for the {@link FileSystemItem} adapter creation. 030 * 031 * @author Antoine Taillefer 032 * @see FileSystemItemAdapterServiceImpl 033 */ 034public interface FileSystemItemAdapterService { 035 036 /** 037 * Gets the {@link FileSystemItem} for the given {@link DocumentModel}. If the document is in the "deleted" life 038 * cycle state it is not considered as adaptable as a {@link FileSystemItem}, thus the method returns null. 039 * 040 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 041 * {@link FileSystemItem} 042 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel) 043 */ 044 FileSystemItem getFileSystemItem(DocumentModel doc); 045 046 /** 047 * Gets the {@link FileSystemItem} for the given {@link DocumentModel}. If {@code includeDeleted} is true no filter 048 * is applied on the "deleted" life cycle state, else if the document is in this state it is not considered as 049 * adaptable as a {@link FileSystemItem}, thus the method returns null. 050 * 051 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 052 * {@link FileSystemItem} 053 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel) 054 */ 055 FileSystemItem getFileSystemItem(DocumentModel doc, boolean includeDeleted); 056 057 /** 058 * Gets the {@link FileSystemItem} for the given {@link DocumentModel}. 059 * <p> 060 * If {@code includeDeleted} is true no filter is applied on the "deleted" life cycle state, else if the document is 061 * in this state it is not considered as adaptable as a {@link FileSystemItem}, thus the method returns null. 062 * <p> 063 * If {@code relaxSyncRootConstraint} is true no filter is applied on the synchronization root aspect for the 064 * current user. 065 * 066 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 067 * {@link FileSystemItem} 068 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel) 069 */ 070 FileSystemItem getFileSystemItem(DocumentModel doc, boolean includeDeleted, boolean relaxSyncRootConstraint); 071 072 /** 073 * Gets the {@link FileSystemItem} for the given {@link DocumentModel} forcing its parent id with the given id. If 074 * the document is in the "deleted" life cycle state it is not considered as adaptable as a {@link FileSystemItem}, 075 * thus the method returns null. 076 * 077 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 078 * {@link FileSystemItem} 079 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel, String) 080 */ 081 FileSystemItem getFileSystemItem(DocumentModel doc, FolderItem parentItem); 082 083 /** 084 * Gets the {@link FileSystemItem} for the given {@link DocumentModel} forcing its parent id with the given id. If 085 * {@code includeDeleted} is true no filter is applied on the "deleted" life cycle state, else if the document is in 086 * this state it is not considered as adaptable as a {@link FileSystemItem}, thus the method returns null. 087 * 088 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 089 * {@link FileSystemItem} 090 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel, String) 091 */ 092 FileSystemItem getFileSystemItem(DocumentModel doc, FolderItem parentItem, boolean includeDeleted); 093 094 /** 095 * Gets the {@link FileSystemItem} for the given {@link DocumentModel} forcing its parent id with the given id. 096 * <p> 097 * If {@code includeDeleted} is true no filter is applied on the "deleted" life cycle state, else if the document is 098 * in this state it is not considered as adaptable as a {@link FileSystemItem}, thus the method returns null. 099 * <p> 100 * If {@code relaxSyncRootConstraint} is true no filter is applied on the synchronization root aspect for the 101 * current user. 102 * 103 * @return the {@link FileSystemItem} or null if the {@link DocumentModel} is not adaptable as a 104 * {@link FileSystemItem} 105 * @see FileSystemItemFactory#getFileSystemItem(DocumentModel, String) 106 */ 107 FileSystemItem getFileSystemItem(DocumentModel doc, FolderItem parentItem, boolean includeDeleted, 108 boolean relaxSyncRootConstraint); 109 110 /** 111 * Gets the {@link FileSystemItemFactory} that can handle the the given {@link FileSystemItem} id. 112 * 113 * @see FileSystemItemFactory#canHandleFileSystemItemId(String) 114 */ 115 FileSystemItemFactory getFileSystemItemFactoryForId(String id); 116 117 /** 118 * Gets the {@link TopLevelFolderItemFactory}. 119 */ 120 TopLevelFolderItemFactory getTopLevelFolderItemFactory(); 121 122 /** 123 * Gets the {@link VirtualFolderItemFactory} for the given factory name. 124 */ 125 VirtualFolderItemFactory getVirtualFolderItemFactory(String factoryName); 126 127 /** 128 * Gets the active {@link FileSystemItem} factory names. 129 */ 130 Set<String> getActiveFileSystemItemFactories(); 131 132}