[MRM-1327] very rough prototype of a JCR based storage mechanism. Passes tests, but needs to be cleaned up and properly integrated, then tested for performance

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1050283 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2010-12-17 06:26:09 +00:00
parent f2579ffce2
commit 4423d46b4f
8 changed files with 1721 additions and 57 deletions

View File

@ -20,11 +20,18 @@ package org.apache.archiva.metadata.repository;
*/
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.IssueManagement;
import org.apache.archiva.metadata.model.License;
import org.apache.archiva.metadata.model.MailingList;
import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.model.Scm;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import java.util.ArrayList;
@ -102,7 +109,87 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), namespaces );
}
public void testGetNamespaceOnly()
{
assertEquals( Collections.emptyList(), repository.getRootNamespaces( TEST_REPO_ID ) );
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
public void testGetProjectOnly()
{
assertNull( repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) );
assertEquals( Collections.emptyList(), repository.getRootNamespaces( TEST_REPO_ID ) );
ProjectMetadata project = new ProjectMetadata();
project.setId( TEST_PROJECT );
project.setNamespace( TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, project );
project = repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
assertEquals( TEST_PROJECT, project.getId() );
assertEquals( TEST_NAMESPACE, project.getNamespace() );
// test that namespace is also constructed
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
public void testGetProjectVersionOnly()
throws MetadataResolutionException
{
assertNull( repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) );
assertNull( repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) );
assertEquals( Collections.<String>emptyList(), repository.getRootNamespaces( TEST_REPO_ID ) );
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( TEST_PROJECT_VERSION );
repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( TEST_PROJECT_VERSION, metadata.getId() );
// test that namespace and project is also constructed
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
ProjectMetadata projectMetadata = repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
assertEquals( TEST_PROJECT, projectMetadata.getId() );
assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace() );
}
public void testGetArtifactOnly()
throws MetadataResolutionException
{
assertEquals( Collections.<ArtifactMetadata>emptyList(),
new ArrayList<ArtifactMetadata>(
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
assertNull( repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) );
assertNull( repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) );
assertEquals( Collections.<String>emptyList(), repository.getRootNamespaces( TEST_REPO_ID ) );
ArtifactMetadata metadata = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
Collection<ArtifactMetadata> artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
TEST_PROJECT_VERSION );
assertEquals( Collections.singletonList( metadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
// test that namespace, project and project version is also constructed
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
ProjectMetadata projectMetadata = repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
assertEquals( TEST_PROJECT, projectMetadata.getId() );
assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace() );
ProjectVersionMetadata projectVersionMetadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( TEST_PROJECT_VERSION, projectVersionMetadata.getId() );
}
public void testUpdateProjectVersionMetadataWithNoOtherArchives()
throws MetadataResolutionException
{
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( TEST_PROJECT_VERSION );
@ -111,6 +198,134 @@ public abstract class AbstractMetadataRepositoryTest
mailingList.setOtherArchives( Collections.<String>emptyList() );
metadata.setMailingLists( Collections.singletonList( mailingList ) );
repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( TEST_PROJECT_VERSION, metadata.getId() );
assertEquals( 1, metadata.getMailingLists().size() );
mailingList = metadata.getMailingLists().get( 0 );
assertEquals( "Foo List", mailingList.getName() );
assertEquals( Collections.<String>emptyList(), mailingList.getOtherArchives() );
}
public void testUpdateProjectVersionMetadataWithAllElements()
throws MetadataResolutionException
{
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( TEST_PROJECT_VERSION );
metadata.setName( "project name" );
metadata.setDescription( "project description" );
MailingList mailingList = new MailingList();
mailingList.setName( "Foo List" );
mailingList.setOtherArchives( Collections.singletonList( "other archive" ) );
metadata.setMailingLists( Collections.singletonList( mailingList ) );
Scm scm = new Scm();
scm.setConnection( "connection" );
scm.setDeveloperConnection( "dev conn" );
scm.setUrl( "url" );
metadata.setScm( scm );
CiManagement ci = new CiManagement();
ci.setSystem( "system" );
ci.setUrl( "ci url" );
metadata.setCiManagement( ci );
IssueManagement tracker = new IssueManagement();
tracker.setSystem( "system" );
tracker.setUrl( "issue tracker url" );
metadata.setIssueManagement( tracker );
Organization org = new Organization();
org.setName( "org name" );
org.setUrl( "url" );
metadata.setOrganization( org );
License l = new License();
l.setName( "license name" );
l.setUrl( "license url" );
metadata.addLicense( l );
Dependency d = new Dependency();
d.setArtifactId( "artifactId" );
d.setClassifier( "classifier" );
d.setGroupId( "groupId" );
d.setScope( "scope" );
d.setSystemPath( "system path" );
d.setType( "type" );
d.setVersion( "version" );
metadata.addDependency( d );
repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( TEST_PROJECT_VERSION, metadata.getId() );
assertEquals( TEST_PROJECT_VERSION, metadata.getVersion() );
assertEquals( "project name", metadata.getName() );
assertEquals( "project description", metadata.getDescription() );
assertEquals( 1, metadata.getMailingLists().size() );
mailingList = metadata.getMailingLists().get( 0 );
assertEquals( "Foo List", mailingList.getName() );
assertEquals( Collections.singletonList( "other archive" ), mailingList.getOtherArchives() );
assertEquals( "connection", metadata.getScm().getConnection() );
assertEquals( "dev conn", metadata.getScm().getDeveloperConnection() );
assertEquals( "url", metadata.getScm().getUrl() );
assertEquals( "system", metadata.getCiManagement().getSystem() );
assertEquals( "ci url", metadata.getCiManagement().getUrl() );
assertEquals( "system", metadata.getIssueManagement().getSystem() );
assertEquals( "issue tracker url", metadata.getIssueManagement().getUrl() );
assertEquals( "org name", metadata.getOrganization().getName() );
assertEquals( "url", metadata.getOrganization().getUrl() );
assertEquals( 1, metadata.getLicenses().size() );
l = metadata.getLicenses().get( 0 );
assertEquals( "license name", l.getName() );
assertEquals( "license url", l.getUrl() );
assertEquals( 1, metadata.getDependencies().size() );
d = metadata.getDependencies().get( 0 );
assertEquals( "artifactId", d.getArtifactId() );
assertEquals( "classifier", d.getClassifier() );
assertEquals( "groupId", d.getGroupId() );
assertEquals( "scope", d.getScope() );
assertEquals( "system path", d.getSystemPath() );
assertEquals( "type", d.getType() );
assertEquals( "version", d.getVersion() );
}
public void testUpdateProjectReference()
{
ProjectVersionReference reference = new ProjectVersionReference();
reference.setNamespace( "another.namespace" );
reference.setProjectId( "another-project-id" );
reference.setProjectVersion( "1.1" );
reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
repository.updateProjectReference( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, reference );
Collection<ProjectVersionReference> references = repository.getProjectReferences( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( 1, references.size() );
reference = references.iterator().next();
assertEquals( "another.namespace", reference.getNamespace() );
assertEquals( "another-project-id", reference.getProjectId() );
assertEquals( "1.1", reference.getProjectVersion() );
assertEquals( ProjectVersionReference.ReferenceType.DEPENDENCY, reference.getReferenceType() );
}
public void testGetRepositories()
{
// currently set up this way so the behaviour of both the test and the mock config return the same repository
// set as the File implementation just uses the config rather than the content
repository.updateNamespace( TEST_REPO_ID, "namespace" );
repository.updateNamespace( "other-repo", "namespace" );
assertEquals( Arrays.asList( TEST_REPO_ID, "other-repo" ), new ArrayList<String>( repository.getRepositories() ) );
}
public void testUpdateProjectVersionMetadataIncomplete()
@ -123,6 +338,17 @@ public abstract class AbstractMetadataRepositoryTest
metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( true, metadata.isIncomplete() );
assertNull( metadata.getCiManagement() );
assertNull( metadata.getScm() );
assertNull( metadata.getIssueManagement() );
assertNull( metadata.getOrganization() );
assertNull( metadata.getDescription() );
assertNull( metadata.getName() );
assertEquals( TEST_PROJECT_VERSION, metadata.getId() );
assertEquals( TEST_PROJECT_VERSION, metadata.getVersion() );
assertTrue( metadata.getMailingLists().isEmpty() );
assertTrue( metadata.getLicenses().isEmpty() );
assertTrue( metadata.getDependencies().isEmpty() );
}
public void testUpdateProjectVersionMetadataWithExistingFacets()
@ -311,9 +537,16 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacetsWhenUnknown()
{
// testing no exception
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
}
public void testRemoveFacetWhenUnknown()
{
// testing no exception
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
}
public void testRemoveFacet()
{
TestMetadataFacet metadataFacet = new TestMetadataFacet( TEST_VALUE );
@ -343,11 +576,6 @@ public abstract class AbstractMetadataRepositoryTest
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
public void testRemoveFacetWhenUnknown()
{
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
}
public void testGetArtifacts()
{
ArtifactMetadata artifact1 = createArtifact();
@ -405,8 +633,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeOpen()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -417,8 +643,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeSparseNamespace()
{
String namespace = "org.apache.archiva";
repository.updateNamespace( TEST_REPO_ID, namespace );
repository.updateProject( TEST_REPO_ID, createProject( namespace ) );
ArtifactMetadata artifact = createArtifact();
artifact.setNamespace( namespace );
repository.updateArtifact( TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -429,8 +653,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeLowerBound()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -441,8 +663,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeLowerBoundOutOfRange()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -452,8 +672,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeLowerAndUpperBound()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -465,8 +683,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeUpperBound()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -477,8 +693,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByDateRangeUpperBoundOutOfRange()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -488,13 +702,9 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByRepoId()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertFalse( repository.getArtifacts(TEST_REPO_ID).isEmpty());
assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) );
}
public void testGetNamespacesWithSparseDepth()
@ -509,8 +719,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByChecksumSingleResultMd5()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -520,8 +728,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByChecksumSingleResultSha1()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
@ -529,19 +735,23 @@ public abstract class AbstractMetadataRepositoryTest
TEST_SHA1 ) );
}
public void testGetArtifactsByChecksumDeepNamespace()
{
ArtifactMetadata artifact = createArtifact();
String namespace = "multi.level.ns";
artifact.setNamespace( namespace );
repository.updateArtifact( TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID,
TEST_SHA1 ) );
}
public void testGetArtifactsByChecksumMultipleResult()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
ProjectMetadata projectMetadata = createProject();
repository.updateProject( TEST_REPO_ID, projectMetadata );
ArtifactMetadata artifact1 = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
projectMetadata = createProject();
String newProjectId = "another-project";
projectMetadata.setId( newProjectId );
repository.updateProject( TEST_REPO_ID, projectMetadata );
ArtifactMetadata artifact2 = createArtifact();
artifact2.setProject( newProjectId );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, newProjectId, TEST_PROJECT_VERSION, artifact2 );
@ -554,18 +764,17 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetArtifactsByChecksumNoResult()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertEquals( Collections.<ArtifactMetadata>emptyList(), repository.getArtifactsByChecksum( TEST_REPO_ID,
"not a checksum" ) );
assertEquals( Collections.<ArtifactMetadata>emptyList(), repository.getArtifactsByChecksum( TEST_REPO_ID, "not a checksum" ) );
}
public void testDeleteArtifact()
{
ArtifactMetadata artifact = createArtifact();
artifact.addFacet( new TestMetadataFacet( "value" ) );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>( repository.getArtifacts(
@ -608,15 +817,16 @@ public abstract class AbstractMetadataRepositoryTest
repository.deleteRepository( TEST_REPO_ID );
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ).isEmpty() );
assertTrue( repository.getArtifacts( TEST_REPO_ID ).isEmpty() );
assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() );
}
private ProjectMetadata createProject()
private static ProjectMetadata createProject()
{
return createProject( TEST_NAMESPACE );
}
private ProjectMetadata createProject( String ns )
private static ProjectMetadata createProject( String ns )
{
ProjectMetadata project = new ProjectMetadata();
project.setId( TEST_PROJECT );
@ -624,12 +834,12 @@ public abstract class AbstractMetadataRepositoryTest
return project;
}
private ArtifactMetadata createArtifact()
private static ArtifactMetadata createArtifact()
{
return createArtifact( "jar" );
}
private ArtifactMetadata createArtifact( String type )
private static ArtifactMetadata createArtifact( String type )
{
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "." + type );
@ -645,7 +855,7 @@ public abstract class AbstractMetadataRepositoryTest
return artifact;
}
private class ArtifactMetadataComparator
private static class ArtifactMetadataComparator
implements Comparator<ArtifactMetadata>
{
public final int compare( ArtifactMetadata a, ArtifactMetadata b )

View File

@ -133,7 +133,7 @@ public class FileMetadataRepository
Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY );
// remove properties that are not references or artifacts
for ( Object key : new ArrayList( properties.keySet() ) )
for ( Object key : new ArrayList<Object>( properties.keySet() ) )
{
String name = (String) key;
if ( !name.contains( ":" ) && !name.equals( "facetIds" ) )
@ -579,7 +579,7 @@ public class FileMetadataRepository
properties.remove( "artifact:facetIds:" + id );
String prefix = "artifact:facet:" + id + ":";
for ( Object key : new ArrayList( properties.keySet() ) )
for ( Object key : new ArrayList<Object>( properties.keySet() ) )
{
String property = (String) key;
if ( property.startsWith( prefix ) )
@ -666,6 +666,10 @@ public class FileMetadataRepository
public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
ArtifactMetadata artifact )
{
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( projectVersion );
updateProjectVersion( repoId, namespace, projectId, metadata );
File directory = new File( getDirectory( repoId ), namespace + "/" + projectId + "/" + projectVersion );
Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY );
@ -741,11 +745,18 @@ public class FileMetadataRepository
{
File directory = new File( getDirectory( repoId ), namespace + "/" + projectId );
Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY );
Properties properties = readOrCreateProperties( directory, PROJECT_METADATA_KEY );
ProjectMetadata project = new ProjectMetadata();
ProjectMetadata project = null;
String id = properties.getProperty( "id" );
if ( id != null )
{
project = new ProjectMetadata();
project.setNamespace( properties.getProperty( "namespace" ) );
project.setId( properties.getProperty( "id" ) );
project.setId( id );
}
return project;
}
@ -838,8 +849,15 @@ public class FileMetadataRepository
MailingList mailingList = new MailingList();
mailingList.setName( mailingListName );
mailingList.setMainArchiveUrl( properties.getProperty( "mailingList." + i + ".archive" ) );
mailingList.setOtherArchives( Arrays.asList( properties.getProperty(
"mailingList." + i + ".otherArchives" ).split( "," ) ) );
String p = properties.getProperty( "mailingList." + i + ".otherArchives" );
if ( p != null && p.length() > 0 )
{
mailingList.setOtherArchives( Arrays.asList( p.split( "," ) ) );
}
else
{
mailingList.setOtherArchives( Collections.<String>emptyList() );
}
mailingList.setPostAddress( properties.getProperty( "mailingList." + i + ".post" ) );
mailingList.setSubscribeAddress( properties.getProperty( "mailingList." + i + ".subscribe" ) );
mailingList.setUnsubscribeAddress( properties.getProperty( "mailingList." + i + ".unsubscribe" ) );
@ -1078,7 +1096,6 @@ public class FileMetadataRepository
public List<ArtifactMetadata> getArtifacts( String repoId )
{
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
for ( String ns : getRootNamespaces( repoId ) )
{
@ -1100,9 +1117,7 @@ public class FileMetadataRepository
{
for ( ArtifactMetadata artifact : getArtifacts( repoId, ns, project, version ) )
{
artifacts.add( artifact );
}
}
}

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>plugins</artifactId>
<groupId>org.apache.archiva</groupId>
<version>1.4-SNAPSHOT</version>
</parent>
<artifactId>metadata-store-jcr</artifactId>
<name>JCR Storage for Metadata</name>
<dependencies>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-spring</artifactId>
<scope>test</scope>
</dependency>
<!-- TODO: dependency management -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>${jackrabbit.version}</version>
<!-- TODO: trim more, or look for a lighter container? -->
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-text-extractors</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,58 @@
package org.apache.archiva.metadata.repository.jcr;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Map;
public class JcrMetadataRepositoryTest
extends AbstractMetadataRepositoryTest
{
private JcrMetadataRepository jcrMetadataRepository;
public void setUp()
throws Exception
{
super.setUp();
File directory = getTestFile( "target/test-repositories" );
FileUtils.deleteDirectory( directory );
Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
jcrMetadataRepository = new JcrMetadataRepository();
jcrMetadataRepository.setMetadataFacetFactories( factories );
this.repository = jcrMetadataRepository;
}
@Override
protected void tearDown()
throws Exception
{
super.tearDown();
jcrMetadataRepository.close();
}
}

View File

@ -0,0 +1,49 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.6//EN"
"http://jackrabbit.apache.org/dtd/repository-1.6.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.mem.MemoryFileSystem"/>
<!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository"/>
</FileSystem> -->
<Security appName="Jackrabbit">
<SecurityManager class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager" workspaceName="security"/>
<AccessManager class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager"/>
<LoginModule class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule"/>
</Security>
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
<Workspace name="${wsp.name}">
<FileSystem class="org.apache.jackrabbit.core.fs.mem.MemoryFileSystem"/>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager"/>
<!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}"/>
</FileSystem> <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager"/> -->
</Workspace>
<Versioning rootPath="${rep.home}/version">
<FileSystem class="org.apache.jackrabbit.core.fs.mem.MemoryFileSystem"/>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.mem.InMemPersistenceManager"/>
<!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/version"/>
</FileSystem>
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager"/>-->
</Versioning>
</Repository>

View File

@ -37,5 +37,6 @@
<module>maven1-repository</module>
<module>stage-repository-merge</module>
<module>generic-metadata-support</module>
<module>metadata-store-jcr</module>
</modules>
</project>

View File

@ -241,7 +241,7 @@
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-webdav</artifactId>
<version>1.5.0</version>
<version>${jackrabbit.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
@ -315,6 +315,11 @@
<version>1.4-SNAPSHOT</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-store-jcr</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-file</artifactId>
@ -1167,6 +1172,7 @@
<slf4j.version>1.5.8</slf4j.version>
<binder.version>0.9</binder.version>
<spring.version>2.5.6</spring.version>
<jackrabbit.version>2.2.0</jackrabbit.version>
</properties>
<profiles>
<profile>