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 */
016package org.ametys.plugins.repository.metadata;
017
018import java.util.Collection;
019
020import org.ametys.plugins.repository.AmetysRepositoryException;
021
022/**
023 * Interface representing a folder.
024 */
025public interface Folder
026{   
027    /**
028     * Returns the folder name.
029     * @return the folder name.
030     * @throws AmetysRepositoryException if an error occurs.
031     */
032    public String getName() throws AmetysRepositoryException;
033    
034    /**
035     * Returns a Collection containing all subfolders of this folder.
036     * @return a Collection containing all subfolders of this folder.
037     * @throws AmetysRepositoryException if an error occurs
038     */
039    public Collection<? extends Folder> getFolders() throws AmetysRepositoryException;
040    
041    /**
042     * Returns the folder with the specified name.
043     * @param folderName the name of the folder.
044     * @return the folder with the specified name.
045     * @throws UnknownMetadataException if the folder does not exist.
046     * @throws AmetysRepositoryException if an error occurs.
047     */
048    public Folder getFolder(String folderName) throws UnknownMetadataException, AmetysRepositoryException;
049    
050    /**
051     * Returns a Collection containing all files of this folder.
052     * @return a Collection containing all files of this folder.
053     * @throws AmetysRepositoryException if an error occurs.
054     */
055    public Collection<? extends File> getFiles() throws AmetysRepositoryException;
056    
057    /**
058     * Tests the existence of a file.
059     * @param fileName the name of the file.
060     * @return true if the specified file exists in this folder.
061     * @throws AmetysRepositoryException if an error occurs.
062     */
063    public boolean hasFile(String fileName) throws AmetysRepositoryException;
064    
065    /**
066     * Returns the file with the specified name.
067     * @param fileName the name of the file.
068     * @return the file with the specified name.
069     * @throws UnknownMetadataException if the folder does not exist.
070     * @throws AmetysRepositoryException if an error occurs.
071     */
072    public File getFile(String fileName) throws UnknownMetadataException, AmetysRepositoryException;
073}