001package org.apache.archiva.converter.artifact; 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 022import org.apache.maven.artifact.Artifact; 023import org.apache.maven.artifact.repository.ArtifactRepository; 024import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata; 025import org.apache.maven.artifact.repository.metadata.Snapshot; 026 027/** 028 * 029 * This is a copy of org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata 030 * from the maven-compat module, because this is the only class that we use from the compat module and 031 * we can get rid of the dependency. 032 * 033 * Metadata for the artifact version directory of the repository. 034 * 035 * 036 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 037 * 038 */ 039public class SnapshotArtifactRepositoryMetadata 040 extends AbstractRepositoryMetadata 041{ 042 private Artifact artifact; 043 044 public SnapshotArtifactRepositoryMetadata( Artifact artifact ) 045 { 046 super( createMetadata( artifact, null ) ); 047 this.artifact = artifact; 048 } 049 050 public SnapshotArtifactRepositoryMetadata( Artifact artifact, 051 Snapshot snapshot ) 052 { 053 super( createMetadata( artifact, createVersioning( snapshot ) ) ); 054 this.artifact = artifact; 055 } 056 057 public boolean storedInGroupDirectory() 058 { 059 return false; 060 } 061 062 public boolean storedInArtifactVersionDirectory() 063 { 064 return true; 065 } 066 067 public String getGroupId() 068 { 069 return artifact.getGroupId(); 070 } 071 072 public String getArtifactId() 073 { 074 return artifact.getArtifactId(); 075 } 076 077 public String getBaseVersion() 078 { 079 return artifact.getBaseVersion(); 080 } 081 082 public Object getKey() 083 { 084 return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); 085 } 086 087 public boolean isSnapshot() 088 { 089 return artifact.isSnapshot(); 090 } 091 092 public int getNature() 093 { 094 return isSnapshot() ? SNAPSHOT : RELEASE; 095 } 096 097 public ArtifactRepository getRepository() 098 { 099 return artifact.getRepository(); 100 } 101 102 public void setRepository( ArtifactRepository remoteRepository ) 103 { 104 artifact.setRepository( remoteRepository ); 105 } 106}