1 package org.apache.archiva.metadata.repository.memory;
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 java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.Date;
26 import java.util.List;
28 import org.apache.archiva.metadata.model.ArtifactMetadata;
29 import org.apache.archiva.metadata.model.MetadataFacet;
30 import org.apache.archiva.metadata.model.ProjectMetadata;
31 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
32 import org.apache.archiva.metadata.model.ProjectVersionReference;
33 import org.apache.archiva.metadata.repository.MetadataRepository;
34 import org.apache.archiva.metadata.repository.MetadataResolverException;
36 public class TestMetadataRepository
37 implements MetadataRepository
39 private static final String TEST_REPO = "test-repo";
41 private static final String TEST_NAMESPACE = "org.apache.archiva";
43 private List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
45 private List<String> versions = new ArrayList<String>();
47 public TestMetadataRepository()
49 Date whenGathered = new Date( 123456789 );
51 addArtifact( "artifact-one", "1.0", whenGathered );
52 addArtifact( "artifact-one", "1.1", whenGathered );
53 addArtifact( "artifact-one", "2.0", whenGathered );
54 addArtifact( "artifact-two", "1.0.1", whenGathered );
55 addArtifact( "artifact-two", "1.0.2", whenGathered );
56 addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
57 addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
58 addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
61 private void addArtifact( String projectId, String projectVersion, Date whenGathered )
63 ArtifactMetadata artifact = new ArtifactMetadata();
64 artifact.setFileLastModified( System.currentTimeMillis() );
65 artifact.setNamespace( TEST_NAMESPACE );
66 artifact.setVersion( projectVersion );
67 artifact.setId( projectId + "-" + projectVersion + ".jar" );
68 artifact.setProject( projectId );
69 artifact.setRepositoryId( TEST_REPO );
70 artifact.setWhenGathered( whenGathered );
71 artifacts.add( artifact );
73 versions.add( projectVersion );
76 public ProjectMetadata getProject( String repoId, String namespace, String projectId )
78 throw new UnsupportedOperationException();
81 public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
82 String projectVersion )
83 throws MetadataResolverException
85 throw new UnsupportedOperationException();
88 public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
89 String projectVersion )
91 throw new UnsupportedOperationException();
94 public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
95 String projectVersion )
97 throw new UnsupportedOperationException();
100 public Collection<String> getRootNamespaces( String repoId )
102 throw new UnsupportedOperationException();
105 public Collection<String> getNamespaces( String repoId, String namespace )
107 throw new UnsupportedOperationException();
110 public Collection<String> getProjects( String repoId, String namespace )
112 throw new UnsupportedOperationException();
115 public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
116 throws MetadataResolverException
121 public void updateProject( String repoId, ProjectMetadata project )
123 throw new UnsupportedOperationException();
126 public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
127 ArtifactMetadata artifactMeta )
129 throw new UnsupportedOperationException();
132 public void updateProjectVersion( String repoId, String namespace, String projectId,
133 ProjectVersionMetadata versionMetadata )
135 throw new UnsupportedOperationException();
138 public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
139 ProjectVersionReference reference )
141 throw new UnsupportedOperationException();
144 public void updateNamespace( String repoId, String namespace )
146 throw new UnsupportedOperationException();
149 public List<String> getMetadataFacets( String repodId, String facetId )
151 return Collections.emptyList();
154 public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
156 throw new UnsupportedOperationException();
159 public void addMetadataFacet( String repositoryId, String facetId, String name, MetadataFacet metadataFacet )
161 throw new UnsupportedOperationException();
164 public void removeMetadataFacets( String repositoryId, String facetId )
166 throw new UnsupportedOperationException();
169 public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
174 public Collection<String> getRepositories()
176 return Collections.singletonList( TEST_REPO );
179 public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
180 String projectVersion )