1 package org.apache.maven.shared.transfer.metadata.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.artifact.metadata.ArtifactMetadata;
25 import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
26 import org.sonatype.aether.metadata.Metadata;
27
28
29
30
31
32
33
34 public class Maven30MetadataBridge implements Metadata
35 {
36 private ArtifactMetadata metadata;
37
38 private File file;
39
40 public Maven30MetadataBridge( ArtifactMetadata metadata )
41 {
42 this.metadata = metadata;
43 }
44
45 @Override
46 public String getGroupId()
47 {
48 return emptify( metadata.getGroupId() );
49 }
50
51 @Override
52 public String getArtifactId()
53 {
54 return metadata.storedInGroupDirectory() ? "" : emptify( metadata.getArtifactId() );
55 }
56
57 @Override
58 public String getVersion()
59 {
60 return metadata.storedInArtifactVersionDirectory() ? emptify( metadata.getBaseVersion() ) : "";
61 }
62
63 @Override
64 public String getType()
65 {
66 return metadata.getRemoteFilename();
67 }
68
69 private String emptify( String string )
70 {
71 return ( string != null ) ? string : "";
72 }
73
74 @Override
75 public File getFile()
76 {
77 return file;
78 }
79
80 @Override
81 public Maven30MetadataBridge setFile( File file )
82 {
83 this.file = file;
84 return this;
85 }
86
87 @Override
88 public Nature getNature()
89 {
90 if ( metadata instanceof RepositoryMetadata )
91 {
92 switch ( ( (RepositoryMetadata) metadata ).getNature() )
93 {
94 case RepositoryMetadata.RELEASE_OR_SNAPSHOT:
95 return Nature.RELEASE_OR_SNAPSHOT;
96 case RepositoryMetadata.SNAPSHOT:
97 return Nature.SNAPSHOT;
98 default:
99 return Nature.RELEASE;
100 }
101 }
102 else
103 {
104 return Nature.RELEASE;
105 }
106 }
107 }