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.metadata.Metadata;
26 import org.eclipse.aether.transfer.MetadataTransferException;
27 import org.eclipse.aether.transfer.TransferListener;
28
29 /**
30 * An upload of metadata to a remote repository. A repository connector processing this upload has to use
31 * {@link #setException(MetadataTransferException)} to report the results of the transfer.
32 */
33 public final class MetadataUpload extends MetadataTransfer {
34
35 /**
36 * Creates a new uninitialized upload.
37 */
38 public MetadataUpload() {
39 // enables default constructor
40 }
41
42 /**
43 * Creates a new upload with the specified properties.
44 *
45 * @param metadata The metadata to upload, may be {@code null}.
46 * @param file The local file to upload the metadata from, may be {@code null}.
47 * @deprecated Use {@link #MetadataUpload(Metadata, Path)} instead.
48 */
49 @Deprecated
50 public MetadataUpload(Metadata metadata, File file) {
51 setMetadata(metadata);
52 setFile(file);
53 }
54
55 /**
56 * Creates a new upload with the specified properties.
57 *
58 * @param metadata The metadata to upload, may be {@code null}.
59 * @param path The local file to upload the metadata from, may be {@code null}.
60 * @since 2.0.0
61 */
62 public MetadataUpload(Metadata metadata, Path path) {
63 setMetadata(metadata);
64 setPath(path);
65 }
66
67 @Override
68 public MetadataUpload setMetadata(Metadata metadata) {
69 super.setMetadata(metadata);
70 return this;
71 }
72
73 @Deprecated
74 @Override
75 public MetadataUpload setFile(File file) {
76 super.setFile(file);
77 return this;
78 }
79
80 @Override
81 public MetadataUpload setPath(Path path) {
82 super.setPath(path);
83 return this;
84 }
85
86 @Override
87 public MetadataUpload setException(MetadataTransferException exception) {
88 super.setException(exception);
89 return this;
90 }
91
92 @Override
93 public MetadataUpload setListener(TransferListener listener) {
94 super.setListener(listener);
95 return this;
96 }
97
98 @Override
99 public MetadataUpload setTrace(RequestTrace trace) {
100 super.setTrace(trace);
101 return this;
102 }
103
104 @Override
105 public String toString() {
106 return getMetadata() + " - " + getPath();
107 }
108 }