View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.web.jcr.rest.client;
25  
26  import java.io.File;
27  import java.net.URL;
28  import java.util.Collection;
29  import org.modeshape.web.jcr.rest.client.Status.Severity;
30  import org.modeshape.web.jcr.rest.client.domain.Repository;
31  import org.modeshape.web.jcr.rest.client.domain.Server;
32  import org.modeshape.web.jcr.rest.client.domain.Workspace;
33  
34  /**
35   * The <code>IRestClient</code> interface is the API for all REST clients used by the Eclipse ModeShape plugin.
36   */
37  public interface IRestClient {
38  
39      /**
40       * Obtains the ModeShape repositories defined within the specified server.
41       * 
42       * @param server the server whose repositories are being requested (never <code>null</code>)
43       * @return the repositories within the specified server (never <code>null</code>)
44       * @throws Exception if there is a problem obtaining the repositories
45       */
46      Collection<Repository> getRepositories( Server server ) throws Exception;
47  
48      /**
49       * @param file the file whose URL is being requested (never <code>null</code>)
50       * @param path the path in the ModeShape workspace where the file is/could be located (never <code>null</code>)
51       * @param workspace the workspace where the file is/could be located (never <code>null</code>)
52       * @return the workspace URL for the specified file (never <code>null</code>)
53       * @throws Exception if there is a problem obtaining the URL or if the file is a directory
54       */
55      URL getUrl( File file,
56                  String path,
57                  Workspace workspace ) throws Exception;
58  
59      /**
60       * Obtains the workspaces defined within the specified ModeShape respository.
61       * 
62       * @param repository the repository whose workspaces are being requested (never <code>null</code>)
63       * @return the workspaces within the specified repository (never <code>null</code>)
64       * @throws Exception if there is a problem obtaining the workspaces
65       */
66      Collection<Workspace> getWorkspaces( Repository repository ) throws Exception;
67  
68      /**
69       * Publishes, or uploads, a local file to the workspace at the specified path.
70       * 
71       * @param workspace the workspace where the resource will be published (never <code>null</code>)
72       * @param path the unencoded path to the folder where the file will be published (never <code>null</code>)
73       * @param file the resource being published (never <code>null</code>)
74       * @return a status of the publishing operation outcome (never <code>null</code>)
75       */
76      Status publish( Workspace workspace,
77                      String path,
78                      File file );
79  
80      /**
81       * Unpublishes, or deletes, the resource at the specified path in the workspace. If a file being unpublished is not found in
82       * the workspace an {@link Severity#INFO info status} is returned.
83       * 
84       * @param workspace the workspace where the resource will be unpublished (never <code>null</code>)
85       * @param path the unencoded path to the folder where the file is published (never <code>null</code>)
86       * @param file the file being unpublished (never <code>null</code>)
87       * @return a status of the unpublishing operation outcome (never <code>null</code>)
88       */
89      Status unpublish( Workspace workspace,
90                        String path,
91                        File file );
92  
93  }