1 package org.apache.archiva.rest.api.model;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.metadata.model.ArtifactMetadata;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import java.io.Serializable;
25 import java.text.DecimalFormat;
26 import java.text.DecimalFormatSymbols;
27 import java.util.Locale;
30 * @author Olivier Lamy
33 @XmlRootElement( name = "artifactDownloadInfo" )
34 public class ArtifactDownloadInfo
35 implements Serializable
39 private String namespace;
41 private String project;
47 private String repositoryId;
49 private String version;
53 private String classifier;
55 public ArtifactDownloadInfo( ArtifactMetadata artifact, String path, String type, String classifier )
57 this.repositoryId = artifact.getRepositoryId();
58 this.path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifact.getId();
61 this.classifier = classifier;
63 this.namespace = artifact.getNamespace();
64 this.project = artifact.getProject();
66 // TODO: find a reusable formatter for this
67 double s = artifact.getSize();
87 DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US ) );
88 this.size = df.format( s ) + " " + symbol;
89 this.id = artifact.getId();
90 this.version = artifact.getVersion();
93 public String getType()
98 public void setType( String type )
103 public String getNamespace()
108 public void setNamespace( String namespace )
110 this.namespace = namespace;
113 public String getProject()
118 public void setProject( String project )
120 this.project = project;
123 public String getSize()
128 public void setSize( String size )
133 public String getId()
138 public void setId( String id )
143 public String getRepositoryId()
148 public void setRepositoryId( String repositoryId )
150 this.repositoryId = repositoryId;
153 public String getVersion()
158 public void setVersion( String version )
160 this.version = version;
163 public String getPath()
168 public void setPath( String path )
173 public String getClassifier()
178 public void setClassifier( String classifier )
180 this.classifier = classifier;
184 public String toString()
186 final StringBuilder sb = new StringBuilder();
187 sb.append( "ArtifactDownloadInfo" );
188 sb.append( "{type='" ).append( type ).append( '\'' );
189 sb.append( ", namespace='" ).append( namespace ).append( '\'' );
190 sb.append( ", project='" ).append( project ).append( '\'' );
191 sb.append( ", size='" ).append( size ).append( '\'' );
192 sb.append( ", id='" ).append( id ).append( '\'' );
193 sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
194 sb.append( ", version='" ).append( version ).append( '\'' );
195 sb.append( ", path='" ).append( path ).append( '\'' );
196 sb.append( ", classifier='" ).append( classifier ).append( '\'' );
198 return sb.toString();