View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.spi.connector;
20  
21  import java.io.File;
22  import java.nio.file.Path;
23  
24  import org.eclipse.aether.RequestTrace;
25  import org.eclipse.aether.artifact.Artifact;
26  import org.eclipse.aether.transfer.ArtifactTransferException;
27  import org.eclipse.aether.transfer.TransferListener;
28  
29  /**
30   * An upload of an artifact to a remote repository. A repository connector processing this upload has to use
31   * {@link #setException(ArtifactTransferException)} to report the results of the transfer.
32   */
33  public final class ArtifactUpload extends ArtifactTransfer {
34      /**
35       * Creates a new uninitialized upload.
36       */
37      public ArtifactUpload() {
38          // enables default constructor
39      }
40  
41      /**
42       * Creates a new upload with the specified properties.
43       *
44       * @param artifact The artifact to upload, may be {@code null}.
45       * @param file The local file to upload the artifact from, may be {@code null}.
46       * @deprecated Use {@link #ArtifactUpload(Artifact, Path)} instead.
47       */
48      @Deprecated
49      public ArtifactUpload(Artifact artifact, File file) {
50          setArtifact(artifact);
51          setFile(file);
52      }
53  
54      /**
55       * Creates a new upload with the specified properties.
56       *
57       * @param artifact The artifact to upload, may be {@code null}.
58       * @param path The local file to upload the artifact from, may be {@code null}.
59       * @since 2.0.0
60       */
61      public ArtifactUpload(Artifact artifact, Path path) {
62          setArtifact(artifact);
63          setPath(path);
64      }
65  
66      @Override
67      public ArtifactUpload setArtifact(Artifact artifact) {
68          super.setArtifact(artifact);
69          return this;
70      }
71  
72      @Deprecated
73      @Override
74      public ArtifactUpload setFile(File file) {
75          super.setFile(file);
76          return this;
77      }
78  
79      @Override
80      public ArtifactUpload setPath(Path path) {
81          super.setPath(path);
82          return this;
83      }
84  
85      @Override
86      public ArtifactUpload setException(ArtifactTransferException exception) {
87          super.setException(exception);
88          return this;
89      }
90  
91      @Override
92      public ArtifactUpload setListener(TransferListener listener) {
93          super.setListener(listener);
94          return this;
95      }
96  
97      @Override
98      public ArtifactUpload setTrace(RequestTrace trace) {
99          super.setTrace(trace);
100         return this;
101     }
102 
103     @Override
104     public String toString() {
105         return getArtifact() + " - " + getPath();
106     }
107 }