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;
017
018import org.apache.avalon.framework.component.Component;
019
020/**
021 * Factory for retrieving type of {@link AmetysObject}.
022 * @param <A> the actual type of {@link AmetysObject}s
023 */
024public interface AmetysObjectFactory<A extends AmetysObject> extends Component
025{
026    /**
027     * Retrieves an {@link AmetysObject}, given its id.<br>
028     * Id are like <code>&lt;protocol&gt;://&lt;protocol-specific-part&gt;</code>.
029     * @param id the identifier.
030     * @return the corresponding {@link AmetysObject}.
031     * @throws AmetysRepositoryException if an error occurs.
032     */
033    A getAmetysObjectById(String id) throws AmetysRepositoryException;
034    
035    /**
036     * Return true if the specified id correspond to an existing {@link AmetysObject}.
037     * Id are like <code>&lt;protocol&gt;://&lt;protocol-specific-part&gt;</code>.
038     * @param id the identifier.
039     * @return true if the specified id correspond to an existing {@link AmetysObject}.
040     * @throws AmetysRepositoryException if an error occurs.
041     */
042    boolean hasAmetysObjectForId(String id) throws AmetysRepositoryException;
043    
044    /**
045     * Returns the protocol of this factory, used to construct unique ids.
046     * @return the protocol of this factory.
047     */
048    String getScheme();
049}