View Javadoc

1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.services.repository;
16  
17  import org.figure8.join.businessobjects.artifact.Artifact;
18  
19  import java.io.File;
20  import java.io.InputStream;
21  /**
22   * This is a simple interface for storing and retrieving an {@link Artifact}
23   * within a repository. A much more elaborate design would have separate repository
24   * representation from its access or connection methods representation but it's not
25   * really the point here ... Such details are left to implementations and we can find
26   * such well designed repository access libraries (look at VFS on http://jakarta.apache.org/commons/vfs
27   * or at Wagon for Maven2 on http://maven.apache.org).<br/>
28   * Implementations or wrapper around existing libraries may choose to use the
29   * Artifact informations to categorize it within their internal structure.
30   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
31   * @version $Revision: 1.2 $
32   *
33   * @see org.figure8.join.businessobjects.artifact.Artifact
34   */
35  public interface Repository{
36  
37     // Public -------------------------------------------------------------------
38  
39     /**
40      * Retrieve the input stream corresponding to a given Artifact. This
41      * method can be used for artifact content downloading or retrieval.
42      * @param artifact The domain object representing artifact to retrieve
43      * @return An {@code InputStream} on artifact content
44      * @throws ConnectionException if physical repository cannot be connected
45      * @throws TransferException if something wrong occur after connection, during transfer
46      */
47     public abstract InputStream getArtifact(Artifact artifact) throws ConnectionException, TransferException;
48  
49     /**
50      * Store the content of a given Artifact within repository datastore.
51      * @param artifact The domain object representing artifact to store
52      * @param content File representing artifact content (must not be a directory)
53      * @throws ConnectionException if physical repository cannot be connected
54      * @throws TransferException if something wrong occur after connection, during transfer
55      */
56     public abstract void storeArtifact(Artifact artifact, File content) throws ConnectionException, TransferException;
57  
58     /**
59      * Store the content of a given Artifact within repository datastore using an input stream.
60      * @param artifact The domain object representing artifact to store
61      * @param is InputStream on artifact content
62      * @throws ConnectionException if physical repository cannot be connected
63      * @throws TransferException if something wrong occur after connection, during transfer
64      */
65     public abstract void storeArtifact(Artifact artifact, InputStream is) throws ConnectionException, TransferException;
66  }