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;
035import java.util.Map;
036
037/**
038 * A repository session which provides basic file and folder operations
039 * to the resources in the VFS of OpenCms.<p>
040 *
041 * @since 6.2.4
042 */
043public interface I_CmsRepositorySession {
044
045    /**
046     * Copies the item found at the source path to the destination path.<p>
047     *
048     * @param src the path of the item which should be copied
049     * @param dest the destination path where to copy to
050     * @param overwrite should any existing item be overwritten
051     * @param shallow if true, when copying a folder, only the folder will be copied and not its contents
052     *
053     * @throws CmsException if something goes wrong
054     */
055    void copy(String src, String dest, boolean overwrite, boolean shallow) throws CmsException;
056
057    /**
058     * Creates a new item at the given path.<p>
059     *
060     * In this case this should be a collection (directory).<p>
061     *
062     * @param path the complete path of the new collection
063     *
064     * @throws CmsException if something goes wrong
065     */
066    void create(String path) throws CmsException;
067
068    /**
069     * Deletes the item at the given path.<p>
070     *
071     * @param path the complete path of the item to delete
072     *
073     * @throws CmsException if something goes wrong
074     */
075    void delete(String path) throws CmsException;
076
077    /**
078     * Returns if an item exists at the given path.<p>
079     *
080     * @param path the complete path of the item to check existance
081     *
082     * @return true if the item exists otherwise false
083     */
084    boolean exists(String path);
085
086    /**
087     * Returns the item found at the given path.<p>
088     *
089     * @param path the complete path of the item to return
090     *
091     * @return the item found at the path
092     *
093     * @throws CmsException if something goes wrong
094     */
095    I_CmsRepositoryItem getItem(String path) throws CmsException;
096
097    /**
098     * Returns the lock for the resource at the given path.<p>
099     *
100     * @param path the complete path where to return the lock for
101     *
102     * @return the found lock as CmsWebdavLockInfo or null if not found
103     */
104    CmsRepositoryLockInfo getLock(String path);
105
106    /**
107     * Gets the properties for the given path.
108     *
109     * @param path the path
110     * @return the properties for the path
111     *
112     * @throws CmsException if something goes wrong
113     */
114    Map<CmsPropertyName, String> getProperties(String path) throws CmsException;
115
116    /**
117     * Returns a list with all items found directly in the given path.<p>
118     *
119     * @param path the complete path from which to return the items
120     *
121     * @return a list with {@link I_CmsRepositoryItem} found in the path
122     *
123     * @throws CmsException if something goes wrong
124     */
125    List<I_CmsRepositoryItem> list(String path) throws CmsException;
126
127    /**
128     * Creates a new lock on the item at the path with the given information
129     * in the lock info.<p>
130     *
131     * @param path the complete path of the item
132     * @param lock the information about the lock to create
133     *
134     * @return if the lock was successfully
135     *
136     * @throws CmsException if something goes wrong
137     */
138    boolean lock(String path, CmsRepositoryLockInfo lock) throws CmsException;
139
140    /**
141     * Moves an item from a source path to a destination path.<p>
142     *
143     * @param src the complete path to the item which should be copied
144     * @param dest the complete destination path where to copy to
145     * @param overwrite should any existing item should be overwritten
146     *
147     * @throws CmsException if something goes wrong
148     */
149    void move(String src, String dest, boolean overwrite) throws CmsException;
150
151    /**
152     * Saves an item at the given path.<p>
153     *
154     * This creates a new single item (file) if it does not exist.<p>
155     *
156     * @param path the complete path of the new item
157     * @param inputStream the content of the item
158     * @param overwrite should an existing item at the path be overwritten
159     *
160     * @throws CmsException if something goes wrong
161     * @throws IOException if a write error occurs
162     */
163    void save(String path, InputStream inputStream, boolean overwrite) throws CmsException, IOException;
164
165    /**
166     * Unlocks the item found at the path.<p>
167     *
168     * @param path The complete path of the item to unlock
169     */
170    void unlock(String path);
171
172    /**
173     * Updates the properties for the given path.
174     *
175     * @param path the path
176     * @param properties the properties
177     *
178     * @throws CmsException if something goes wrong
179     */
180    void updateProperties(String path, Map<CmsPropertyName, String> properties) throws CmsException;
181}