| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| FilesystemStoreTools | 41 | 0 | - | 0 | 0 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.store.filesystem.internal; | |
| 21 | ||
| 22 | import java.io.File; | |
| 23 | import java.util.Date; | |
| 24 | import java.util.Map; | |
| 25 | import java.util.concurrent.locks.ReadWriteLock; | |
| 26 | ||
| 27 | import org.xwiki.component.annotation.Role; | |
| 28 | import org.xwiki.model.reference.DocumentReference; | |
| 29 | ||
| 30 | import com.xpn.xwiki.doc.XWikiAttachment; | |
| 31 | ||
| 32 | /** | |
| 33 | * Tools for getting files to store data in the filesystem. | |
| 34 | * These APIs are in flux and may change at any time without warning. | |
| 35 | * This should be replaced by a module which provides a secure extension of java.io.File. | |
| 36 | * | |
| 37 | * @version $Id: a19fabd4ff42c1f51d540a9cf4cb6b042fe1645e $ | |
| 38 | * @since 3.0M2 | |
| 39 | */ | |
| 40 | @Role | |
| 41 | public interface FilesystemStoreTools | |
| 42 | { | |
| 43 | /** | |
| 44 | * Get a backup file which for a given storage file. | |
| 45 | * This file name will never collide with any other file gotten through this interface. | |
| 46 | * | |
| 47 | * @param storageFile the file to get a backup file for. | |
| 48 | * @return a backup file with a name based on the name of the given file. | |
| 49 | */ | |
| 50 | File getBackupFile(File storageFile); | |
| 51 | ||
| 52 | /** | |
| 53 | * Get a temporary file which for a given storage file. | |
| 54 | * This file name will never collide with any other file gotten through this interface. | |
| 55 | * | |
| 56 | * @param storageFile the file to get a temporary file for. | |
| 57 | * @return a temporary file with a name based on the name of the given file. | |
| 58 | */ | |
| 59 | File getTempFile(File storageFile); | |
| 60 | ||
| 61 | /** | |
| 62 | * Get an instance of AttachmentFileProvider which will save everything to do with an attachment | |
| 63 | * in a separate location which is repeatable only with the same attachment name, and containing | |
| 64 | * document. | |
| 65 | * | |
| 66 | * @param attachment the attachment to get a tools for. | |
| 67 | * @return a provider which will provide files with collision free path and repeatable with same inputs. | |
| 68 | */ | |
| 69 | AttachmentFileProvider getAttachmentFileProvider(XWikiAttachment attachment); | |
| 70 | ||
| 71 | /** | |
| 72 | * Get an instance of AttachmentFileProvider which will save everything to do with an attachment | |
| 73 | * in a separate location which is repeatable only with the same attachment name, containing document, | |
| 74 | * and date of deletion. | |
| 75 | * | |
| 76 | * @param attachment the attachment to get a tools for. | |
| 77 | * @param deleteDate the date the attachment was deleted. | |
| 78 | * @return a provider which will provide files with collision free path and repeatable with same inputs. | |
| 79 | */ | |
| 80 | DeletedAttachmentFileProvider getDeletedAttachmentFileProvider(XWikiAttachment attachment, Date deleteDate); | |
| 81 | ||
| 82 | /** | |
| 83 | * Get a map of dates of deletion by the document where the attachment was attached. | |
| 84 | * | |
| 85 | * @param docRef a reference to the document to get deleted attachments for. | |
| 86 | * @return a map of maps which provide FileProviders by deletion dates and filenames. | |
| 87 | */ | |
| 88 | Map<String, Map<Date, DeletedAttachmentFileProvider>> deletedAttachmentsForDocument(DocumentReference docRef); | |
| 89 | ||
| 90 | /** | |
| 91 | * @return the absolute path to the directory where the files are stored. | |
| 92 | */ | |
| 93 | String getStorageLocationPath(); | |
| 94 | ||
| 95 | /** | |
| 96 | * Get a file which is global for the entire installation. | |
| 97 | * | |
| 98 | * @param name a unique identifier for the file. | |
| 99 | * @return a file unique to the given name. | |
| 100 | */ | |
| 101 | File getGlobalFile(String name); | |
| 102 | ||
| 103 | /** | |
| 104 | * Get a deleted attachment file provider from a path to the deleted attachment directory. | |
| 105 | * | |
| 106 | * @param pathToDirectory a relitive path to the directory where the deleted attachment is. | |
| 107 | * @return a DeletedAttachmentFileProvider which will provide files for that deleted attachment. | |
| 108 | */ | |
| 109 | DeletedAttachmentFileProvider getDeletedAttachmentFileProvider(String pathToDirectory); | |
| 110 | ||
| 111 | /** | |
| 112 | * Get a {@link java.util.concurrent.locks.ReadWriteLock} which is unique to the given file. | |
| 113 | * This method will always return the same lock for the path on the filesystem even if the | |
| 114 | * {@link java.io.File} object is different. | |
| 115 | * | |
| 116 | * @param toLock the file to get a lock for. | |
| 117 | * @return a lock for the given file. | |
| 118 | */ | |
| 119 | ReadWriteLock getLockForFile(File toLock); | |
| 120 | } |