X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fdeployment%2FDeployRequest.java;fp=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fdeployment%2FDeployRequest.java;h=a5372ddbac079d2e8399dbd0e075b8ff0e8c6ded;hb=825d60c5348dbe3f5be25b0bccf7bdebfe694219;hp=0000000000000000000000000000000000000000;hpb=5e991fff5cba01858dcc5747a27e637325bc5c8e;p=gpl%2Fargeo-jcr.git diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java new file mode 100644 index 0000000..a5372dd --- /dev/null +++ b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2010, 2012 Sonatype, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sonatype, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.aether.deployment; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RequestTrace; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.RemoteRepository; + +/** + * A request to deploy artifacts and their accompanying metadata into the a remote repository. + * + * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest) + */ +public final class DeployRequest +{ + + private Collection artifacts = Collections.emptyList(); + + private Collection metadata = Collections.emptyList(); + + private RemoteRepository repository; + + private RequestTrace trace; + + /** + * Creates an uninitialized request. + */ + public DeployRequest() + { + } + + /** + * Gets the artifact to deploy. + * + * @return The artifacts to deploy, never {@code null}. + */ + public Collection getArtifacts() + { + return artifacts; + } + + /** + * Sets the artifacts to deploy. + * + * @param artifacts The artifacts to deploy, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest setArtifacts( Collection artifacts ) + { + if ( artifacts == null ) + { + this.artifacts = Collections.emptyList(); + } + else + { + this.artifacts = artifacts; + } + return this; + } + + /** + * Adds the specified artifacts for deployment. + * + * @param artifact The artifact to add, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest addArtifact( Artifact artifact ) + { + if ( artifact != null ) + { + if ( artifacts.isEmpty() ) + { + artifacts = new ArrayList(); + } + artifacts.add( artifact ); + } + return this; + } + + /** + * Gets the metadata to deploy. + * + * @return The metadata to deploy, never {@code null}. + */ + public Collection getMetadata() + { + return metadata; + } + + /** + * Sets the metadata to deploy. + * + * @param metadata The metadata to deploy, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest setMetadata( Collection metadata ) + { + if ( metadata == null ) + { + this.metadata = Collections.emptyList(); + } + else + { + this.metadata = metadata; + } + return this; + } + + /** + * Adds the specified metadata for deployment. + * + * @param metadata The metadata to add, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest addMetadata( Metadata metadata ) + { + if ( metadata != null ) + { + if ( this.metadata.isEmpty() ) + { + this.metadata = new ArrayList(); + } + this.metadata.add( metadata ); + } + return this; + } + + /** + * Gets the repository to deploy to. + * + * @return The repository to deploy to or {@code null} if not set. + */ + public RemoteRepository getRepository() + { + return repository; + } + + /** + * Sets the repository to deploy to. + * + * @param repository The repository to deploy to, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest setRepository( RemoteRepository repository ) + { + this.repository = repository; + return this; + } + + /** + * Gets the trace information that describes the higher level request/operation in which this request is issued. + * + * @return The trace information about the higher level operation or {@code null} if none. + */ + public RequestTrace getTrace() + { + return trace; + } + + /** + * Sets the trace information that describes the higher level request/operation in which this request is issued. + * + * @param trace The trace information about the higher level operation, may be {@code null}. + * @return This request for chaining, never {@code null}. + */ + public DeployRequest setTrace( RequestTrace trace ) + { + this.trace = trace; + return this; + } + + @Override + public String toString() + { + return getArtifacts() + ", " + getMetadata() + " > " + getRepository(); + } + +}