View Javadoc
1   package org.eclipse.aether.spi.connector;
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 java.io.File;
23  
24  import org.eclipse.aether.artifact.Artifact;
25  import org.eclipse.aether.transfer.ArtifactTransferException;
26  
27  /**
28   * A download/upload of an artifact.
29   * 
30   * @noextend This class is not intended to be extended by clients.
31   */
32  public abstract class ArtifactTransfer
33      extends Transfer
34  {
35  
36      private Artifact artifact;
37  
38      private File file;
39  
40      private ArtifactTransferException exception;
41  
42      ArtifactTransfer()
43      {
44          // hide
45      }
46  
47      /**
48       * Gets the artifact being transferred.
49       * 
50       * @return The artifact being transferred or {@code null} if not set.
51       */
52      public Artifact getArtifact()
53      {
54          return artifact;
55      }
56  
57      /**
58       * Sets the artifact to transfer.
59       * 
60       * @param artifact The artifact, may be {@code null}.
61       * @return This transfer for chaining, never {@code null}.
62       */
63      public ArtifactTransfer setArtifact( Artifact artifact )
64      {
65          this.artifact = artifact;
66          return this;
67      }
68  
69      /**
70       * Gets the local file the artifact is downloaded to or uploaded from. In case of a download, a connector should
71       * first transfer the bytes to a temporary file and only overwrite the target file once the entire download is
72       * completed such that an interrupted/failed download does not corrupt the current file contents.
73       * 
74       * @return The local file or {@code null} if not set.
75       */
76      public File getFile()
77      {
78          return file;
79      }
80  
81      /**
82       * Sets the local file the artifact is downloaded to or uploaded from.
83       * 
84       * @param file The local file, may be {@code null}.
85       * @return This transfer for chaining, never {@code null}.
86       */
87      public ArtifactTransfer setFile( File file )
88      {
89          this.file = file;
90          return this;
91      }
92  
93      /**
94       * Gets the exception that occurred during the transfer (if any).
95       * 
96       * @return The exception or {@code null} if the transfer was successful.
97       */
98      public ArtifactTransferException getException()
99      {
100         return exception;
101     }
102 
103     /**
104      * Sets the exception that occurred during the transfer.
105      * 
106      * @param exception The exception, may be {@code null} to denote a successful transfer.
107      * @return This transfer for chaining, never {@code null}.
108      */
109     public ArtifactTransfer setException( ArtifactTransferException exception )
110     {
111         this.exception = exception;
112         return this;
113     }
114 
115 }