001/*
002 *  Copyright 2010 Anyware Services
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
017package org.ametys.plugins.repository.metadata;
018
019import java.util.Collection;
020
021import org.ametys.plugins.repository.AmetysRepositoryException;
022import org.ametys.plugins.repository.RepositoryIntegrityViolationException;
023
024/**
025 * Folder that is not read only
026 */
027public interface ModifiableFolder extends Folder
028{
029    public Collection<ModifiableFolder> getFolders() throws AmetysRepositoryException;
030    
031    public ModifiableFolder getFolder(String folderName) throws UnknownMetadataException, AmetysRepositoryException;
032    
033    public Collection<ModifiableFile> getFiles() throws AmetysRepositoryException;
034    
035    public ModifiableFile getFile(String fileName) throws UnknownMetadataException, AmetysRepositoryException;
036
037    /**
038     * Add a folder with the specified name in this folder.
039     * @param folderName the folder name.
040     * @return the created folder.
041     * @throws RepositoryIntegrityViolationException if a file
042     *         or a folder already exists with the given name.
043     * @throws AmetysRepositoryException if an error occurs.
044     */
045    public ModifiableFolder addFolder(String folderName) throws RepositoryIntegrityViolationException, AmetysRepositoryException;
046    
047    /**
048     * Add a file with the specified name in this folder.
049     * @param fileName the file name.
050     * @return the created file.
051     * @throws RepositoryIntegrityViolationException if a file
052     *         or a folder already exists with the given name.
053     * @throws AmetysRepositoryException if an error occurs.
054     */
055    public ModifiableFile addFile(String fileName) throws RepositoryIntegrityViolationException, AmetysRepositoryException;
056    
057    /**
058     * Removes the sub-element represented by the specified name.
059     * @param name the name of the folder or file to be removed.
060     * @throws UnknownMetadataException if no folder nor file does exists.
061     * @throws AmetysRepositoryException if an error occurs.
062     */
063    public void remove(String name) throws UnknownMetadataException, AmetysRepositoryException;
064    
065    /**
066     * Removes all files and folders in this folder.
067     * @throws AmetysRepositoryException if an error occurs.
068     */
069    public void removeAll() throws AmetysRepositoryException;
070}