diff options
author | Olivier Lamy <olamy@apache.org> | 2012-12-19 15:19:53 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-12-19 15:19:53 +0000 |
commit | 58afcb111487f09821d20ce25015352ee5140b65 (patch) | |
tree | f0cfeabeff964ca1b7cc6cdac092288c749e57c4 /archiva-modules/plugins/metadata-store-jcr/src | |
parent | 31438032029fe54269ae1b349d40f49d8c73c5d3 (diff) | |
download | archiva-58afcb111487f09821d20ce25015352ee5140b65.tar.gz archiva-58afcb111487f09821d20ce25015352ee5140b65.zip |
[MRM-1729] add MetadataRepository#hasMetadataFacet to prevent slow startup time.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1423878 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/metadata-store-jcr/src')
2 files changed, 24 insertions, 1 deletions
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java index a53a176f2..7bff556f6 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java @@ -400,6 +400,26 @@ public class JcrMetadataRepository } + + public boolean hasMetadataFacet( String repositoryId, String facetId ) + throws MetadataRepositoryException + { + try + { + Node node = getJcrSession().getRootNode().getNode( getFacetPath( repositoryId, facetId ) ); + return JcrUtils.getChildNodes( node ).iterator().hasNext(); + } + catch ( PathNotFoundException e ) + { + // ignored - the facet doesn't exist, so return false + return false; + } + catch ( RepositoryException e ) + { + throw new MetadataRepositoryException( e.getMessage(), e ); + } + } + public List<String> getMetadataFacets( String repositoryId, String facetId ) throws MetadataRepositoryException { diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java index 1123eb30a..12c106ef5 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java @@ -24,6 +24,7 @@ import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.springframework.context.ApplicationContext; import java.io.File; @@ -48,7 +49,7 @@ public class JcrMetadataRepositoryTest super.setUp(); File directory = new File( "target/test-repositories" ); - if (directory.exists()) + if ( directory.exists() ) { FileUtils.deleteDirectory( directory ); } @@ -86,4 +87,6 @@ public class JcrMetadataRepositoryTest super.tearDown(); } + + } |