X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fdeployment%2FDeployResult.java;fp=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Fdeployment%2FDeployResult.java;h=fcda3ca0cc78c5a1c988a1213e7444b24f050e0e;hb=825d60c5348dbe3f5be25b0bccf7bdebfe694219;hp=0000000000000000000000000000000000000000;hpb=5e991fff5cba01858dcc5747a27e637325bc5c8e;p=gpl%2Fargeo-jcr.git diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java new file mode 100644 index 0000000..fcda3ca --- /dev/null +++ b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java @@ -0,0 +1,165 @@ +/******************************************************************************* + * 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.artifact.Artifact; +import org.eclipse.aether.metadata.Metadata; + +/** + * The result of deploying artifacts and their accompanying metadata into the a remote repository. + * + * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest) + */ +public final class DeployResult +{ + + private final DeployRequest request; + + private Collection artifacts; + + private Collection metadata; + + /** + * Creates a new result for the specified request. + * + * @param request The deployment request, must not be {@code null}. + */ + public DeployResult( DeployRequest request ) + { + if ( request == null ) + { + throw new IllegalArgumentException( "deploy request has not been specified" ); + } + this.request = request; + artifacts = Collections.emptyList(); + metadata = Collections.emptyList(); + } + + /** + * Gets the deploy request that was made. + * + * @return The deploy request, never {@code null}. + */ + public DeployRequest getRequest() + { + return request; + } + + /** + * Gets the artifacts that got deployed. + * + * @return The deployed artifacts, never {@code null}. + */ + public Collection getArtifacts() + { + return artifacts; + } + + /** + * Sets the artifacts that got deployed. + * + * @param artifacts The deployed artifacts, may be {@code null}. + * @return This result for chaining, never {@code null}. + */ + public DeployResult setArtifacts( Collection artifacts ) + { + if ( artifacts == null ) + { + this.artifacts = Collections.emptyList(); + } + else + { + this.artifacts = artifacts; + } + return this; + } + + /** + * Adds the specified artifacts to the result. + * + * @param artifact The deployed artifact to add, may be {@code null}. + * @return This result for chaining, never {@code null}. + */ + public DeployResult addArtifact( Artifact artifact ) + { + if ( artifact != null ) + { + if ( artifacts.isEmpty() ) + { + artifacts = new ArrayList(); + } + artifacts.add( artifact ); + } + return this; + } + + /** + * Gets the metadata that got deployed. Note that due to automatically generated metadata, there might have been + * more metadata deployed than originally specified in the deploy request. + * + * @return The deployed metadata, never {@code null}. + */ + public Collection getMetadata() + { + return metadata; + } + + /** + * Sets the metadata that got deployed. + * + * @param metadata The deployed metadata, may be {@code null}. + * @return This result for chaining, never {@code null}. + */ + public DeployResult setMetadata( Collection metadata ) + { + if ( metadata == null ) + { + this.metadata = Collections.emptyList(); + } + else + { + this.metadata = metadata; + } + return this; + } + + /** + * Adds the specified metadata to this result. + * + * @param metadata The deployed metadata to add, may be {@code null}. + * @return This result for chaining, never {@code null}. + */ + public DeployResult addMetadata( Metadata metadata ) + { + if ( metadata != null ) + { + if ( this.metadata.isEmpty() ) + { + this.metadata = new ArrayList(); + } + this.metadata.add( metadata ); + } + return this; + } + + @Override + public String toString() + { + return getArtifacts() + ", " + getMetadata(); + } + +}