001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.spi.connector; 020 021import java.io.File; 022import java.nio.file.Path; 023 024import org.eclipse.aether.RequestTrace; 025import org.eclipse.aether.artifact.Artifact; 026import org.eclipse.aether.transfer.ArtifactTransferException; 027import org.eclipse.aether.transfer.TransferListener; 028 029/** 030 * An upload of an artifact to a remote repository. A repository connector processing this upload has to use 031 * {@link #setException(ArtifactTransferException)} to report the results of the transfer. 032 */ 033public final class ArtifactUpload extends ArtifactTransfer { 034 /** 035 * Creates a new uninitialized upload. 036 */ 037 public ArtifactUpload() { 038 // enables default constructor 039 } 040 041 /** 042 * Creates a new upload with the specified properties. 043 * 044 * @param artifact The artifact to upload, may be {@code null}. 045 * @param file The local file to upload the artifact from, may be {@code null}. 046 * @deprecated Use {@link #ArtifactUpload(Artifact, Path)} instead. 047 */ 048 @Deprecated 049 public ArtifactUpload(Artifact artifact, File file) { 050 setArtifact(artifact); 051 setFile(file); 052 } 053 054 /** 055 * Creates a new upload with the specified properties. 056 * 057 * @param artifact The artifact to upload, may be {@code null}. 058 * @param path The local file to upload the artifact from, may be {@code null}. 059 * @since 2.0.0 060 */ 061 public ArtifactUpload(Artifact artifact, Path path) { 062 setArtifact(artifact); 063 setPath(path); 064 } 065 066 @Override 067 public ArtifactUpload setArtifact(Artifact artifact) { 068 super.setArtifact(artifact); 069 return this; 070 } 071 072 @Deprecated 073 @Override 074 public ArtifactUpload setFile(File file) { 075 super.setFile(file); 076 return this; 077 } 078 079 @Override 080 public ArtifactUpload setPath(Path path) { 081 super.setPath(path); 082 return this; 083 } 084 085 @Override 086 public ArtifactUpload setException(ArtifactTransferException exception) { 087 super.setException(exception); 088 return this; 089 } 090 091 @Override 092 public ArtifactUpload setListener(TransferListener listener) { 093 super.setListener(listener); 094 return this; 095 } 096 097 @Override 098 public ArtifactUpload setTrace(RequestTrace trace) { 099 super.setTrace(trace); 100 return this; 101 } 102 103 @Override 104 public String toString() { 105 return getArtifact() + " - " + getPath(); 106 } 107}