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