View Javadoc

1   package org.apache.maven.wagon;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.wagon.authentication.AuthenticationException;
23  import org.apache.maven.wagon.authentication.AuthenticationInfo;
24  import org.apache.maven.wagon.authorization.AuthorizationException;
25  import org.apache.maven.wagon.events.SessionListener;
26  import org.apache.maven.wagon.events.TransferListener;
27  import org.apache.maven.wagon.proxy.ProxyInfo;
28  import org.apache.maven.wagon.proxy.ProxyInfoProvider;
29  import org.apache.maven.wagon.repository.Repository;
30  
31  import java.io.File;
32  import java.util.List;
33  
34  public interface Wagon
35  {
36      String ROLE = Wagon.class.getName();
37  
38      // ----------------------------------------------------------------------
39      // File/File handling
40      // ----------------------------------------------------------------------
41  
42      /**
43       * Downloads specified resource from the repository to given file.
44       *
45       * @param resourceName
46       * @param destination
47       * @throws TransferFailedException
48       * @throws ResourceDoesNotExistException
49       * @throws AuthorizationException
50       */
51      void get( String resourceName, File destination )
52          throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
53  
54      /**
55       * Downloads specified resource from the repository
56       * if it was modified since specified date.
57       * The date is measured in milliseconds, between the current time and midnight, January 1, 1970 UTC
58       * and aligned to GMT timezone.
59       *
60       * @param resourceName
61       * @param destination
62       * @param timestamp
63       * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource
64       *         in the repository is older or has the same age.
65       * @throws TransferFailedException
66       * @throws ResourceDoesNotExistException
67       * @throws AuthorizationException
68       */
69      boolean getIfNewer( String resourceName, File destination, long timestamp )
70          throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
71  
72      /**
73       * Copy a file from local system to remote
74       *
75       * @param source      the local file
76       * @param destination the remote destination
77       * @throws TransferFailedException
78       * @throws ResourceDoesNotExistException
79       * @throws AuthorizationException
80       */
81      void put( File source, String destination )
82          throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
83  
84      /**
85       * Copy a directory from local system to remote
86       *
87       * @param sourceDirectory      the local directory
88       * @param destinationDirectory the remote destination
89       * @throws TransferFailedException
90       * @throws ResourceDoesNotExistException
91       * @throws AuthorizationException
92       */
93      void putDirectory( File sourceDirectory, String destinationDirectory )
94          throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
95  
96      /**
97       * Check if a remote resource exists
98       *
99       * @param resourceName
100      * @return whether the resource exists or not
101      * @throws TransferFailedException if there's an error trying to access the remote side
102      * @throws AuthorizationException  if not authorized to verify the existence of the resource
103      */
104     boolean resourceExists( String resourceName )
105         throws TransferFailedException, AuthorizationException;
106 
107     /**
108      * <p/>
109      * Returns a {@link List} of strings naming the files and directories in the directory denoted by
110      * this abstract pathname.
111      * </p>
112      * <p/>
113      * If this abstract pathname does not denote a directory, or does not exist, then this method throws
114      * {@link ResourceDoesNotExistException}.
115      * Otherwise a {@link List} of strings is returned, one for each file or directory in the directory.
116      * Names denoting the directory itself and the directory's parent directory are not included in
117      * the result. Each string is a file name rather than a complete path.
118      * </p>
119      * <p/>
120      * There is no guarantee that the name strings in the resulting list will appear in any specific
121      * order; they are not, in particular, guaranteed to appear in alphabetical order.
122      * </p>
123      *
124      * @param destinationDirectory directory to list contents of
125      * @return A {@link List} of strings naming the files and directories in the directory denoted by
126      *         this abstract pathname. The {@link List} will be empty if the directory is empty.
127      * @throws TransferFailedException       if there's an error trying to access the remote side
128      * @throws ResourceDoesNotExistException if destinationDirectory does not exist or is not a directory
129      * @throws AuthorizationException        if not authorized to list the contents of the directory
130      */
131     List getFileList( String destinationDirectory )
132         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
133 
134     /**
135      * Flag indicating if this wagon supports directory copy operations.
136      *
137      * @return whether if this wagon supports directory operations
138      */
139     boolean supportsDirectoryCopy();
140 
141     Repository getRepository();
142 
143     // ----------------------------------------------------------------------
144     // Connection/Disconnection
145     // ----------------------------------------------------------------------
146 
147     /**
148      * Initiate the connection to the repository.
149      *
150      * @param source the repository to connect to
151      * @throws ConnectionException if there is a problem connecting
152      * @throws org.apache.maven.wagon.authentication.AuthenticationException
153      *                             if the credentials for connecting are not sufficient
154      */
155     void connect( Repository source )
156         throws ConnectionException, AuthenticationException;
157 
158     /**
159      * Initiate the connection to the repository.
160      *
161      * @param source the repository to connect to
162      * @throws ConnectionException if there is a problem connecting
163      * @throws org.apache.maven.wagon.authentication.AuthenticationException
164      *                             if the credentials for connecting are not sufficient
165      */
166     void connect( Repository source, ProxyInfo proxyInfo )
167         throws ConnectionException, AuthenticationException;
168 
169     /**
170      * Initiate the connection to the repository.
171      *
172      * @param source the repository to connect to
173      * @param proxyInfoProvider  the provider to obtain a network proxy to use to connect to the remote repository
174      * @throws ConnectionException if there is a problem connecting
175      * @throws org.apache.maven.wagon.authentication.AuthenticationException
176      *                             if the credentials for connecting are not sufficient
177      */
178     void connect( Repository source, ProxyInfoProvider proxyInfoProvider )
179         throws ConnectionException, AuthenticationException;
180 
181     /**
182      * Initiate the connection to the repository.
183      *
184      * @param source             the repository to connect to
185      * @param authenticationInfo authentication credentials for connecting
186      * @throws ConnectionException if there is a problem connecting
187      * @throws org.apache.maven.wagon.authentication.AuthenticationException
188      *                             if the credentials for connecting are not sufficient
189      */
190     void connect( Repository source, AuthenticationInfo authenticationInfo )
191         throws ConnectionException, AuthenticationException;
192 
193     /**
194      * Initiate the connection to the repository.
195      *
196      * @param source             the repository to connect to
197      * @param authenticationInfo authentication credentials for connecting
198      * @param proxyInfo          the network proxy to use to connect to the remote repository
199      * @throws ConnectionException if there is a problem connecting
200      * @throws org.apache.maven.wagon.authentication.AuthenticationException
201      *                             if the credentials for connecting are not sufficient
202      */
203     void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
204         throws ConnectionException, AuthenticationException;
205 
206     /**
207      * Initiate the connection to the repository.
208      *
209      * @param source             the repository to connect to
210      * @param authenticationInfo authentication credentials for connecting
211      * @param proxyInfoProvider  the provider to obtain a network proxy to use to connect to the remote repository
212      * @throws ConnectionException if there is a problem connecting
213      * @throws org.apache.maven.wagon.authentication.AuthenticationException
214      *                             if the credentials for connecting are not sufficient
215      */
216     void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider )
217         throws ConnectionException, AuthenticationException;
218 
219     /**
220      * Initiate the connection to the repository.
221      *
222      * @throws ConnectionException if there is a problem connecting
223      * @throws org.apache.maven.wagon.authentication.AuthenticationException
224      *                             if ther credentials for connecting are not sufficient
225      * @todo delegate this to a truly internal connection method
226      * @deprecated connect using the {@link #connect(org.apache.maven.wagon.repository.Repository)} or related methods
227      *             - this is an internal method
228      */
229     void openConnection()
230         throws ConnectionException, AuthenticationException;
231 
232     /**
233      * Disconnect from the repository.
234      *
235      * @throws ConnectionException if there is a problem disconnecting
236      */
237     void disconnect()
238         throws ConnectionException;
239     
240     /**
241      * Set the connection timeout limit in milliseconds
242      */
243     void setTimeout( int timeoutValue );
244     
245     /**
246      * Get the connection timeout limit in milliseconds
247      */
248     int getTimeout();
249 
250     // ----------------------------------------------------------------------
251     //  Session listener
252     // ----------------------------------------------------------------------
253 
254     void addSessionListener( SessionListener listener );
255 
256     void removeSessionListener( SessionListener listener );
257 
258     boolean hasSessionListener( SessionListener listener );
259 
260     // ----------------------------------------------------------------------
261     // Transfer listener
262     // ----------------------------------------------------------------------
263 
264     void addTransferListener( TransferListener listener );
265 
266     void removeTransferListener( TransferListener listener );
267 
268     boolean hasTransferListener( TransferListener listener );
269 
270     boolean isInteractive();
271 
272     void setInteractive( boolean interactive );
273 }