001package org.kuali.common.devops.model; 002 003import org.kuali.common.util.Assert; 004import org.kuali.common.util.maven.model.Artifact; 005 006/** 007 * <p> 008 * A named software package compressed into a zip file containing the version number as part of the filename. eg <code>apache-tomcat-7.0.47.zip</code> 009 * </p> 010 * 011 * <p> 012 * When unzipped it must create a new directory that exactly matches the artifactId + version number. For example, unzipping <code>apache-tomcat-7.0.47.zip</code> into 013 * <code>/usr/local</code> will produce <code>/usr/local/apache-tomcat-7.0.47</code> 014 * </p> 015 */ 016public final class ZipPackage { 017 018 private final String name; 019 private final Artifact artifact; 020 021 public static class Builder { 022 023 private static final String ZIP = "zip"; 024 025 // Required 026 private final String name; 027 private final Artifact artifact; 028 029 /** 030 * Use this constructor only if the package name exactly matches the artifact id 031 */ 032 public Builder(Artifact artifact) { 033 this(artifact.getArtifactId(), artifact); 034 } 035 036 /** 037 * Use this constructor if the package name is different than the artifact id 038 */ 039 public Builder(String name, Artifact artifact) { 040 this.name = name; 041 this.artifact = artifact; 042 } 043 044 public ZipPackage build() { 045 Assert.noNulls(artifact); 046 Assert.noBlanks(name); 047 Assert.isTrue(artifact.getType().equalsIgnoreCase(ZIP)); 048 return new ZipPackage(this); 049 } 050 } 051 052 private ZipPackage(Builder builder) { 053 this.name = builder.name; 054 this.artifact = builder.artifact; 055 } 056 057 public String getName() { 058 return name; 059 } 060 061 public Artifact getArtifact() { 062 return artifact; 063 } 064 065}