View Javadoc

1   package org.apache.maven.repository.internal;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import java.util.Collection;
23  import java.util.Collections;
24  import java.util.LinkedHashMap;
25  import java.util.Map;
26  
27  import org.sonatype.aether.RepositorySystemSession;
28  import org.sonatype.aether.artifact.Artifact;
29  import org.sonatype.aether.impl.MetadataGenerator;
30  import org.sonatype.aether.installation.InstallRequest;
31  import org.sonatype.aether.metadata.Metadata;
32  
33  /**
34   * @author Benjamin Bentmann
35   */
36  class LocalSnapshotMetadataGenerator
37      implements MetadataGenerator
38  {
39  
40      private Map<Object, LocalSnapshotMetadata> snapshots;
41  
42      public LocalSnapshotMetadataGenerator( RepositorySystemSession session, InstallRequest request )
43      {
44          snapshots = new LinkedHashMap<Object, LocalSnapshotMetadata>();
45      }
46  
47      public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
48      {
49          for ( Artifact artifact : artifacts )
50          {
51              if ( artifact.isSnapshot() )
52              {
53                  Object key = LocalSnapshotMetadata.getKey( artifact );
54                  LocalSnapshotMetadata snapshotMetadata = snapshots.get( key );
55                  if ( snapshotMetadata == null )
56                  {
57                      snapshotMetadata = new LocalSnapshotMetadata( artifact );
58                      snapshots.put( key, snapshotMetadata );
59                  }
60              }
61          }
62  
63          return Collections.emptyList();
64      }
65  
66      public Artifact transformArtifact( Artifact artifact )
67      {
68          return artifact;
69      }
70  
71      public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
72      {
73          return snapshots.values();
74      }
75  
76  }