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.metadata.Metadata; 026import org.eclipse.aether.transfer.MetadataTransferException; 027import org.eclipse.aether.transfer.TransferListener; 028 029/** 030 * An upload of metadata to a remote repository. A repository connector processing this upload has to use 031 * {@link #setException(MetadataTransferException)} to report the results of the transfer. 032 */ 033public final class MetadataUpload extends MetadataTransfer { 034 035 /** 036 * Creates a new uninitialized upload. 037 */ 038 public MetadataUpload() { 039 // enables default constructor 040 } 041 042 /** 043 * Creates a new upload with the specified properties. 044 * 045 * @param metadata The metadata to upload, may be {@code null}. 046 * @param file The local file to upload the metadata from, may be {@code null}. 047 * @deprecated Use {@link #MetadataUpload(Metadata, Path)} instead. 048 */ 049 @Deprecated 050 public MetadataUpload(Metadata metadata, File file) { 051 setMetadata(metadata); 052 setFile(file); 053 } 054 055 /** 056 * Creates a new upload with the specified properties. 057 * 058 * @param metadata The metadata to upload, may be {@code null}. 059 * @param path The local file to upload the metadata from, may be {@code null}. 060 * @since 2.0.0 061 */ 062 public MetadataUpload(Metadata metadata, Path path) { 063 setMetadata(metadata); 064 setPath(path); 065 } 066 067 @Override 068 public MetadataUpload setMetadata(Metadata metadata) { 069 super.setMetadata(metadata); 070 return this; 071 } 072 073 @Deprecated 074 @Override 075 public MetadataUpload setFile(File file) { 076 super.setFile(file); 077 return this; 078 } 079 080 @Override 081 public MetadataUpload setPath(Path path) { 082 super.setPath(path); 083 return this; 084 } 085 086 @Override 087 public MetadataUpload setException(MetadataTransferException exception) { 088 super.setException(exception); 089 return this; 090 } 091 092 @Override 093 public MetadataUpload setListener(TransferListener listener) { 094 super.setListener(listener); 095 return this; 096 } 097 098 @Override 099 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}