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;
022
023import org.eclipse.aether.RequestTrace;
024import org.eclipse.aether.artifact.Artifact;
025import org.eclipse.aether.transfer.ArtifactTransferException;
026import org.eclipse.aether.transfer.TransferListener;
027
028/**
029 * An upload of an artifact to a remote repository. A repository connector processing this upload has to use
030 * {@link #setException(ArtifactTransferException)} to report the results of the transfer.
031 */
032public final class ArtifactUpload extends ArtifactTransfer {
033    /**
034     * Creates a new uninitialized upload.
035     */
036    public ArtifactUpload() {
037        // enables default constructor
038    }
039
040    /**
041     * Creates a new upload with the specified properties.
042     *
043     * @param artifact The artifact to upload, may be {@code null}.
044     * @param file The local file to upload the artifact from, may be {@code null}.
045     */
046    public ArtifactUpload(Artifact artifact, File file) {
047        setArtifact(artifact);
048        setFile(file);
049    }
050
051    @Override
052    public ArtifactUpload setArtifact(Artifact artifact) {
053        super.setArtifact(artifact);
054        return this;
055    }
056
057    @Override
058    public ArtifactUpload setFile(File file) {
059        super.setFile(file);
060        return this;
061    }
062
063    @Override
064    public ArtifactUpload setException(ArtifactTransferException exception) {
065        super.setException(exception);
066        return this;
067    }
068
069    @Override
070    public ArtifactUpload setListener(TransferListener listener) {
071        super.setListener(listener);
072        return this;
073    }
074
075    @Override
076    public ArtifactUpload setTrace(RequestTrace trace) {
077        super.setTrace(trace);
078        return this;
079    }
080
081    @Override
082    public String toString() {
083        return getArtifact() + " - " + getFile();
084    }
085}