1 package org.apache.archiva.metadata.repository.cassandra.model;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
24 import java.io.Serializable;
25 import java.util.Date;
28 * Cassandra storage model for {@link org.apache.archiva.metadata.model.ArtifactMetadata}
30 * @author Olivier Lamy
33 public class ArtifactMetadataModel
34 implements Serializable
39 private String repositoryId;
41 private String namespace;
43 private String project;
45 private String projectVersion;
47 private String version;
49 private long fileLastModified;
57 private long whenGathered;
59 public ArtifactMetadataModel()
64 public ArtifactMetadataModel( String id, String repositoryId, String namespace, String project,
65 String projectVersion, String version, Date fileLastModified, long size, String md5,
66 String sha1, Date whenGathered )
69 this.repositoryId = repositoryId;
70 this.namespace = namespace;
71 this.project = project;
72 this.projectVersion = projectVersion;
73 this.version = version;
74 this.fileLastModified = ( fileLastModified != null ? fileLastModified.getTime() : 0 );
78 this.whenGathered = whenGathered != null ? whenGathered.getTime() : new Date().getTime();
87 public void setId( String id )
92 public String getRepositoryId()
97 public void setRepositoryId( String repositoryId )
99 this.repositoryId = repositoryId;
102 public String getNamespace()
107 public void setNamespace( String namespace )
109 this.namespace = namespace;
112 public String getProject()
117 public void setProject( String project )
119 this.project = project;
122 public String getProjectVersion()
124 return projectVersion;
127 public void setProjectVersion( String projectVersion )
129 this.projectVersion = projectVersion;
132 public String getVersion()
137 public void setVersion( String version )
139 this.version = version;
142 public long getFileLastModified()
144 return fileLastModified;
147 public void setFileLastModified( long fileLastModified )
149 this.fileLastModified = fileLastModified;
152 public long getSize()
157 public void setSize( long size )
162 public String getMd5()
167 public void setMd5( String md5 )
172 public String getSha1()
177 public void setSha1( String sha1 )
182 public Date getWhenGathered()
184 return new Date( whenGathered );
187 public void setWhenGathered( long whenGathered )
189 this.whenGathered = whenGathered;
194 public String toString()
196 final StringBuilder sb = new StringBuilder( "ArtifactMetadataModel{" );
197 sb.append( ", id='" ).append( id ).append( '\'' );
198 sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
199 sb.append( ", namespace='" ).append( namespace ).append( '\'' );
200 sb.append( ", project='" ).append( project ).append( '\'' );
201 sb.append( ", projectVersion='" ).append( projectVersion ).append( '\'' );
202 sb.append( ", version='" ).append( version ).append( '\'' );
203 sb.append( ", fileLastModified=" ).append( fileLastModified );
204 sb.append( ", size=" ).append( size );
205 sb.append( ", md5='" ).append( md5 ).append( '\'' );
206 sb.append( ", sha1='" ).append( sha1 ).append( '\'' );
207 sb.append( ", whenGathered=" ).append( whenGathered );
209 return sb.toString();
212 public static class KeyBuilder
215 private String project;
219 private String namespaceId;
221 private String repositoryId;
223 private String projectVersion;
230 public KeyBuilder withId( String id )
237 public KeyBuilder withNamespace( Namespace namespace )
239 this.namespaceId = namespace.getName();
240 this.repositoryId = namespace.getRepository().getName();
244 public KeyBuilder withNamespace( String namespaceId )
246 this.namespaceId = namespaceId;
250 public KeyBuilder withProject( String project )
252 this.project = project;
256 public KeyBuilder withProjectVersion( String projectVersion )
258 this.projectVersion = projectVersion;
262 public KeyBuilder withRepositoryId( String repositoryId )
264 this.repositoryId = repositoryId;
268 public String build()
270 //repositoryId + namespaceId + project + projectVersion + id
271 // FIXME add some controls
274 CassandraUtils.generateKey( this.repositoryId, this.namespaceId, this.project, this.projectVersion,
277 //return Long.toString( str.hashCode() );