001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.repository;
029
030import org.opencms.main.CmsException;
031
032import java.io.IOException;
033import java.io.InputStream;
034import java.util.List;
035
036/**
037 * A repository session which provides basic file and folder operations
038 * to the resources in the VFS of OpenCms.<p>
039 *
040 * @since 6.2.4
041 */
042public interface I_CmsRepositorySession {
043
044    /**
045     * Copies the item found at the source path to the destination path.<p>
046     *
047     * @param src the path of the item which should be copied
048     * @param dest the destination path where to copy to
049     * @param overwrite should any existing item be overwritten
050     *
051     * @throws CmsException if something goes wrong
052     */
053    void copy(String src, String dest, boolean overwrite) throws CmsException;
054
055    /**
056     * Creates a new item at the given path.<p>
057     *
058     * In this case this should be a collection (directory).<p>
059     *
060     * @param path the complete path of the new collection
061     *
062     * @throws CmsException if something goes wrong
063     */
064    void create(String path) throws CmsException;
065
066    /**
067     * Deletes the item at the given path.<p>
068     *
069     * @param path the complete path of the item to delete
070     *
071     * @throws CmsException if something goes wrong
072     */
073    void delete(String path) throws CmsException;
074
075    /**
076     * Returns if an item exists at the given path.<p>
077     *
078     * @param path the complete path of the item to check existance
079     *
080     * @return true if the item exists otherwise false
081     */
082    boolean exists(String path);
083
084    /**
085     * Returns the item found at the given path.<p>
086     *
087     * @param path the complete path of the item to return
088     *
089     * @return the item found at the path
090     *
091     * @throws CmsException if something goes wrong
092     */
093    I_CmsRepositoryItem getItem(String path) throws CmsException;
094
095    /**
096     * Returns the lock for the resource at the given path.<p>
097     *
098     * @param path the complete path where to return the lock for
099     *
100     * @return the found lock as CmsWebdavLockInfo or null if not found
101     */
102    CmsRepositoryLockInfo getLock(String path);
103
104    /**
105     * Returns a list with all items found directly in the given path.<p>
106     *
107     * @param path the complete path from which to return the items
108     *
109     * @return a list with {@link I_CmsRepositoryItem} found in the path
110     *
111     * @throws CmsException if something goes wrong
112     */
113    List<I_CmsRepositoryItem> list(String path) throws CmsException;
114
115    /**
116     * Creates a new lock on the item at the path with the given information
117     * in the lock info.<p>
118     *
119     * @param path the complete path of the item
120     * @param lock the information about the lock to create
121     *
122     * @return if the lock was successfully
123     *
124     * @throws CmsException if something goes wrong
125     */
126    boolean lock(String path, CmsRepositoryLockInfo lock) throws CmsException;
127
128    /**
129     * Moves an item from a source path to a destination path.<p>
130     *
131     * @param src the complete path to the item which should be copied
132     * @param dest the complete destination path where to copy to
133     * @param overwrite should any existing item should be overwritten
134     *
135     * @throws CmsException if something goes wrong
136     */
137    void move(String src, String dest, boolean overwrite) throws CmsException;
138
139    /**
140     * Saves an item at the given path.<p>
141     *
142     * This creates a new single item (file) if it does not exist.<p>
143     *
144     * @param path the complete path of the new item
145     * @param inputStream the content of the item
146     * @param overwrite should an existing item at the path be overwritten
147     *
148     * @throws CmsException if something goes wrong
149     * @throws IOException if a write error occurs
150     */
151    void save(String path, InputStream inputStream, boolean overwrite) throws CmsException, IOException;
152
153    /**
154     * Unlocks the item found at the path.<p>
155     *
156     * @param path The complete path of the item to unlock
157     */
158    void unlock(String path);
159}