This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.model;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022/**
023 * Class ArchivaRepositoryMetadata.
024 * 
025 * @version $Revision$ $Date$
026 */
027@SuppressWarnings( "all" )
028public class ArchivaRepositoryMetadata
029    implements java.io.Serializable
030{
031
032      //--------------------------/
033     //- Class/Member Variables -/
034    //--------------------------/
035
036    /**
037     * 
038     *             The Group ID of the metadata.
039     *           
040     */
041    private String groupId;
042
043    /**
044     * 
045     *             The Artifact ID of the metadata.
046     *           
047     */
048    private String artifactId;
049
050    /**
051     * 
052     *             The Version of the metadata.
053     *           
054     */
055    private String version;
056
057    /**
058     * 
059     *             The latest version id.
060     *           
061     */
062    private String latestVersion;
063
064    /**
065     * 
066     *             The released version id.
067     *           
068     */
069    private String releasedVersion;
070
071    /**
072     * 
073     *             The snapshot version id.
074     *           
075     */
076    private SnapshotVersion snapshotVersion;
077
078    /**
079     * Field plugins.
080     */
081    private java.util.List<Plugin> plugins;
082
083    /**
084     * Field availableVersions.
085     */
086    private java.util.List<String> availableVersions;
087
088    /**
089     * 
090     *             When the metadata was last updated.
091     *           
092     */
093    private String lastUpdated;
094
095    /**
096     * 
097     *             The Last Modified Timestamp of this file.
098     *           
099     */
100    private java.util.Date fileLastModified;
101
102    /**
103     * 
104     *             The size of the artifact on disk.
105     *           
106     */
107    private long fileSize = 0L;
108
109
110      //-----------/
111     //- Methods -/
112    //-----------/
113
114    /**
115     * Method addAvailableVersion.
116     * 
117     * @param string
118     */
119    public void addAvailableVersion( String string )
120    {
121        getAvailableVersions().add( string );
122    } //-- void addAvailableVersion( String )
123
124    /**
125     * Method addPlugin.
126     * 
127     * @param plugin
128     */
129    public void addPlugin( Plugin plugin )
130    {
131        getPlugins().add( plugin );
132    } //-- void addPlugin( Plugin )
133
134    /**
135     * Method equals.
136     * 
137     * @param other
138     * @return boolean
139     */
140    public boolean equals( Object other )
141    {
142        if ( this == other )
143        {
144            return true;
145        }
146
147        if ( !( other instanceof ArchivaRepositoryMetadata ) )
148        {
149            return false;
150        }
151
152        ArchivaRepositoryMetadata that = (ArchivaRepositoryMetadata) other;
153        boolean result = true;
154
155        result = result && ( getGroupId() == null ? that.getGroupId() == null : getGroupId().equals( that.getGroupId() ) );
156        result = result && ( getArtifactId() == null ? that.getArtifactId() == null : getArtifactId().equals( that.getArtifactId() ) );
157        result = result && ( getVersion() == null ? that.getVersion() == null : getVersion().equals( that.getVersion() ) );
158
159        return result;
160    } //-- boolean equals( Object )
161
162    /**
163     * Get the Artifact ID of the metadata.
164     * 
165     * @return String
166     */
167    public String getArtifactId()
168    {
169        return this.artifactId;
170    } //-- String getArtifactId()
171
172    /**
173     * Method getAvailableVersions.
174     * 
175     * @return List
176     */
177    public java.util.List<String> getAvailableVersions()
178    {
179        if ( this.availableVersions == null )
180        {
181            this.availableVersions = new java.util.ArrayList<String>();
182        }
183
184        return this.availableVersions;
185    } //-- java.util.List<String> getAvailableVersions()
186
187    /**
188     * Get the Last Modified Timestamp of this file.
189     * 
190     * @return Date
191     */
192    public java.util.Date getFileLastModified()
193    {
194        return this.fileLastModified;
195    } //-- java.util.Date getFileLastModified()
196
197    /**
198     * Get the size of the artifact on disk.
199     * 
200     * @return long
201     */
202    public long getFileSize()
203    {
204        return this.fileSize;
205    } //-- long getFileSize()
206
207    /**
208     * Get the Group ID of the metadata.
209     * 
210     * @return String
211     */
212    public String getGroupId()
213    {
214        return this.groupId;
215    } //-- String getGroupId()
216
217    /**
218     * Get when the metadata was last updated.
219     * 
220     * @return String
221     */
222    public String getLastUpdated()
223    {
224        return this.lastUpdated;
225    } //-- String getLastUpdated()
226
227    /**
228     * Get the latest version id.
229     * 
230     * @return String
231     */
232    public String getLatestVersion()
233    {
234        return this.latestVersion;
235    } //-- String getLatestVersion()
236
237    /**
238     * Method getPlugins.
239     * 
240     * @return List
241     */
242    public java.util.List<Plugin> getPlugins()
243    {
244        if ( this.plugins == null )
245        {
246            this.plugins = new java.util.ArrayList<Plugin>();
247        }
248
249        return this.plugins;
250    } //-- java.util.List<Plugin> getPlugins()
251
252    /**
253     * Get the released version id.
254     * 
255     * @return String
256     */
257    public String getReleasedVersion()
258    {
259        return this.releasedVersion;
260    } //-- String getReleasedVersion()
261
262    /**
263     * Get the snapshot version id.
264     * 
265     * @return SnapshotVersion
266     */
267    public SnapshotVersion getSnapshotVersion()
268    {
269        return this.snapshotVersion;
270    } //-- SnapshotVersion getSnapshotVersion()
271
272    /**
273     * Get the Version of the metadata.
274     * 
275     * @return String
276     */
277    public String getVersion()
278    {
279        return this.version;
280    } //-- String getVersion()
281
282    /**
283     * Method hashCode.
284     * 
285     * @return int
286     */
287    public int hashCode()
288    {
289        int result = 17;
290
291        result = 37 * result + ( groupId != null ? groupId.hashCode() : 0 );
292        result = 37 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
293        result = 37 * result + ( version != null ? version.hashCode() : 0 );
294
295        return result;
296    } //-- int hashCode()
297
298    /**
299     * Method removeAvailableVersion.
300     * 
301     * @param string
302     */
303    public void removeAvailableVersion( String string )
304    {
305        getAvailableVersions().remove( string );
306    } //-- void removeAvailableVersion( String )
307
308    /**
309     * Method removePlugin.
310     * 
311     * @param plugin
312     */
313    public void removePlugin( Plugin plugin )
314    {
315        getPlugins().remove( plugin );
316    } //-- void removePlugin( Plugin )
317
318    /**
319     * Set the Artifact ID of the metadata.
320     * 
321     * @param artifactId
322     */
323    public void setArtifactId( String artifactId )
324    {
325        this.artifactId = artifactId;
326    } //-- void setArtifactId( String )
327
328    /**
329     * Set the list of available version ids.
330     * 
331     * @param availableVersions
332     */
333    public void setAvailableVersions( java.util.List<String> availableVersions )
334    {
335        this.availableVersions = availableVersions;
336    } //-- void setAvailableVersions( java.util.List )
337
338    /**
339     * Set the Last Modified Timestamp of this file.
340     * 
341     * @param fileLastModified
342     */
343    public void setFileLastModified( java.util.Date fileLastModified )
344    {
345        this.fileLastModified = fileLastModified;
346    } //-- void setFileLastModified( java.util.Date )
347
348    /**
349     * Set the size of the artifact on disk.
350     * 
351     * @param fileSize
352     */
353    public void setFileSize( long fileSize )
354    {
355        this.fileSize = fileSize;
356    } //-- void setFileSize( long )
357
358    /**
359     * Set the Group ID of the metadata.
360     * 
361     * @param groupId
362     */
363    public void setGroupId( String groupId )
364    {
365        this.groupId = groupId;
366    } //-- void setGroupId( String )
367
368    /**
369     * Set when the metadata was last updated.
370     * 
371     * @param lastUpdated
372     */
373    public void setLastUpdated( String lastUpdated )
374    {
375        this.lastUpdated = lastUpdated;
376    } //-- void setLastUpdated( String )
377
378    /**
379     * Set the latest version id.
380     * 
381     * @param latestVersion
382     */
383    public void setLatestVersion( String latestVersion )
384    {
385        this.latestVersion = latestVersion;
386    } //-- void setLatestVersion( String )
387
388    /**
389     * Set the available plugins.
390     * 
391     * @param plugins
392     */
393    public void setPlugins( java.util.List<Plugin> plugins )
394    {
395        this.plugins = plugins;
396    } //-- void setPlugins( java.util.List )
397
398    /**
399     * Set the released version id.
400     * 
401     * @param releasedVersion
402     */
403    public void setReleasedVersion( String releasedVersion )
404    {
405        this.releasedVersion = releasedVersion;
406    } //-- void setReleasedVersion( String )
407
408    /**
409     * Set the snapshot version id.
410     * 
411     * @param snapshotVersion
412     */
413    public void setSnapshotVersion( SnapshotVersion snapshotVersion )
414    {
415        this.snapshotVersion = snapshotVersion;
416    } //-- void setSnapshotVersion( SnapshotVersion )
417
418    /**
419     * Set the Version of the metadata.
420     * 
421     * @param version
422     */
423    public void setVersion( String version )
424    {
425        this.version = version;
426    } //-- void setVersion( String )
427
428    /**
429     * Method toString.
430     * 
431     * @return String
432     */
433    public java.lang.String toString()
434    {
435        StringBuilder buf = new StringBuilder( 128 );
436
437        buf.append( "groupId = '" );
438        buf.append( getGroupId() );
439        buf.append( "'" );
440        buf.append( "\n" ); 
441        buf.append( "artifactId = '" );
442        buf.append( getArtifactId() );
443        buf.append( "'" );
444        buf.append( "\n" ); 
445        buf.append( "version = '" );
446        buf.append( getVersion() );
447        buf.append( "'" );
448
449        return buf.toString();
450    } //-- java.lang.String toString()
451
452    
453    private static final long serialVersionUID = 914715358219606100L;
454          
455    
456    public void updateTimestamp()
457    {
458        setLastUpdatedTimestamp( new java.util.Date() );
459    }
460
461    public void setLastUpdatedTimestamp( java.util.Date date )
462    {
463        java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" );
464        java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
465        fmt.setTimeZone( timezone );
466        setLastUpdated( fmt.format( date ) );
467    }
468          
469}