Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BE586200CBF for ; Sat, 24 Jun 2017 01:06:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BD02D160BE5; Fri, 23 Jun 2017 23:06:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C235E160C00 for ; Sat, 24 Jun 2017 01:06:52 +0200 (CEST) Received: (qmail 79426 invoked by uid 500); 23 Jun 2017 23:06:52 -0000 Mailing-List: contact commits-help@archiva.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@archiva.apache.org Delivered-To: mailing list commits@archiva.apache.org Received: (qmail 79108 invoked by uid 99); 23 Jun 2017 23:06:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jun 2017 23:06:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A781CDFBDA; Fri, 23 Jun 2017 23:06:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: olamy@apache.org To: commits@archiva.apache.org Date: Fri, 23 Jun 2017 23:07:00 -0000 Message-Id: <02585bf05e47466a95b6e8a312d7213b@git.apache.org> In-Reply-To: <18c88c6a6a054e40ad3e788b126b0a85@git.apache.org> References: <18c88c6a6a054e40ad3e788b126b0a85@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/13] archiva git commit: Adding jcr oak implementation archived-at: Fri, 23 Jun 2017 23:06:54 -0000 Adding jcr oak implementation Project: http://git-wip-us.apache.org/repos/asf/archiva/repo Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/7d2cc26b Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/7d2cc26b Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/7d2cc26b Branch: refs/heads/feature/jcr_oak Commit: 7d2cc26b4bf41a5e9429aba3a54665669cf6cf79 Parents: 42df217 Author: Martin Stockhammer Authored: Wed Jun 21 23:52:17 2017 +0200 Committer: olivier lamy Committed: Sat Jun 24 09:05:49 2017 +1000 ---------------------------------------------------------------------- .../archiva-lucene-consumers/pom.xml | 35 ++- .../src/test/resources/spring-context.xml | 3 +- .../archiva-base/archiva-indexer/pom.xml | 10 + .../archiva-base/archiva-plexus-bridge/pom.xml | 10 + .../archiva-repository-admin-api/pom.xml | 8 + .../archiva-scheduler-indexing/pom.xml | 10 + .../archiva-rest/archiva-rest-services/pom.xml | 16 -- .../archiva-web/archiva-web-common/pom.xml | 15 - .../archiva-web/archiva-webapp/pom.xml | 23 -- .../main/resources/META-INF/spring-context.xml | 3 +- .../archiva-web/archiva-webdav/pom.xml | 12 - .../plugins/metadata-store-jcr/pom.xml | 85 +++++- .../jcr/ArchivaJcrRepositoryConfig.java | 64 ----- .../repository/jcr/JcrMetadataRepository.java | 22 +- .../repository/jcr/RepositoryFactory.java | 285 +++++++++++++++++++ .../src/main/resources/log4j2-test.xml | 42 +++ .../META-INF/spring-context.xml | 14 +- .../src/test/resources/log4j2-test.xml | 42 +++ .../plugins/repository-statistics/pom.xml | 16 -- pom.xml | 31 +- 20 files changed, 537 insertions(+), 209 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml index 6eed0b8..e8b970b 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml @@ -66,10 +66,30 @@ commons-io commons-io + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + org.apache.maven.indexer indexer-core + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + javax.inject @@ -111,21 +131,6 @@ test - org.apache.jackrabbit - jackrabbit-core - test - - - commons-logging - commons-logging - - - org.slf4j - jcl-over-slf4j - - - - xerces xercesImpl test http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml index db01db7..a891372 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml @@ -59,6 +59,7 @@ + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-base/archiva-indexer/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index 5695593..eae5642 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -85,6 +85,16 @@ org.apache.maven.indexer indexer-core + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + org.eclipse.sisu http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml index fe40f62..d8b477e 100644 --- a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml +++ b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml @@ -58,6 +58,16 @@ org.apache.maven.indexer indexer-core + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + org.codehaus.plexus http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml index a57c21f..d1ca7d7 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml @@ -73,6 +73,14 @@ com.google.code.atinject atinject + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 5aca8e1..58a5f5b 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -44,6 +44,16 @@ org.apache.maven.indexer indexer-core + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + com.google.guava http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 882cd6f..56c3cde 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -329,22 +329,6 @@ - org.apache.jackrabbit - jackrabbit-core - test - - - commons-logging - commons-logging - - - org.slf4j - jcl-over-slf4j - - - - - org.apache.lucene lucene-core test http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-web/archiva-web-common/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index 71ac238..645419f 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -369,21 +369,6 @@ - org.apache.jackrabbit - jackrabbit-core - test - - - commons-logging - commons-logging - - - org.slf4j - jcl-over-slf4j - - - - org.assertj assertj-core test http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-web/archiva-webapp/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 1d3c53e..bdb0b6b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -131,29 +131,6 @@ - org.apache.jackrabbit - jackrabbit-jcr-commons - - - org.apache.jackrabbit - jackrabbit-core - - - commons-logging - commons-logging - - - org.slf4j - jcl-over-slf4j - - - commons-dbcp - commons-dbcp - - - - - commons-configuration commons-configuration http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml index b0b3840..a66c925 100755 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml @@ -37,6 +37,7 @@ + http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/archiva-web/archiva-webdav/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index 2b08b3f..044b964 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -95,16 +95,6 @@ archiva-filelock - org.apache.jackrabbit - jackrabbit-webdav - - - org.slf4j - jcl-over-slf4j - - - - joda-time joda-time @@ -298,8 +288,6 @@ org.apache.archiva.metadata.repository.storage;version=${project.version}, org.apache.commons.io;version="[1.4,2)", org.apache.commons.lang;version="[2.4,3)", - org.apache.jackrabbit.util;version="[1,3)", - org.apache.jackrabbit.webdav*;version="[1,3)", org.joda.time*;version="[1.5,2)", org.springframework*;version="[3,4)", org.apache.maven.index*, http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml index 8fa3086..831b639 100644 --- a/archiva-modules/plugins/metadata-store-jcr/pom.xml +++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml @@ -28,6 +28,9 @@ metadata-store-jcr bundle Archiva Core Plugins :: JCR Storage for Metadata + + 1.7.1 + org.apache.archiva @@ -48,6 +51,12 @@ archiva-test-utils ${project.version} test + + + org.slf4j + slf4j-simple + + javax.jcr @@ -55,25 +64,42 @@ org.apache.jackrabbit - jackrabbit-jcr-commons + oak-jcr + ${jcr-oak.version} org.apache.jackrabbit - jackrabbit-core - provided - + oak-segment-tar + ${jcr-oak.version} + + + org.apache.jackrabbit + oak-lucene + ${jcr-oak.version} - org.slf4j - jcl-over-slf4j + org.apache.lucene + lucene-misc + + + org.apache.lucene + lucene-facet org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j log4j-jcl + org.apache.logging.log4j + log4j-slf4j-impl + + org.springframework spring-test test @@ -98,6 +124,51 @@ xercesImpl test + + org.apache.lucene + lucene-core + ${lucene.version} + + + org.apache.lucene + lucene-misc + ${lucene.version} + + + org.apache.lucene + lucene-facet + ${lucene.version} + + + org.apache.lucene + lucene-codecs + ${lucene.version} + + + org.apache.lucene + lucene-queryparser + ${lucene.version} + + + org.apache.lucene + lucene-sandbox + ${lucene.version} + + + org.apache.lucene + lucene-highlighter + ${lucene.version} + + + org.apache.lucene + lucene-memory + ${lucene.version} + + + org.apache.lucene + lucene-analyzers-common + ${lucene.version} + @@ -126,8 +197,6 @@ org.apache.archiva.metadata.model;version=${project.version}, org.apache.archiva.metadata.repository;version=${project.version}, org.apache.commons.lang;version="[2.4,3)", - org.apache.jackrabbit.commons;version="[2.3,3)", - org.apache.jackrabbit.core.config, org.springframework*;version="[3,4)", org.slf4j;resolution:=optional, org.apache.commons.lang.time http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/ArchivaJcrRepositoryConfig.java ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/ArchivaJcrRepositoryConfig.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/ArchivaJcrRepositoryConfig.java deleted file mode 100644 index 8271e2b..0000000 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/ArchivaJcrRepositoryConfig.java +++ /dev/null @@ -1,64 +0,0 @@ -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.jackrabbit.core.config.ConfigurationException; -import org.apache.jackrabbit.core.config.RepositoryConfig; -import org.slf4j.LoggerFactory; - -import java.io.File; - -/** - * @author Olivier Lamy - * @since 1.4-M1 - */ -public class ArchivaJcrRepositoryConfig -{ - // Recommended to avoid inconsistencies caused by race conditions. - static - { - if ( !System.getProperties( ).containsKey( "org.apache.jackrabbit.core.state.validatehierarchy" ) ) - { - System.setProperty( "org.apache.jackrabbit.core.state.validatehierarchy", "true" ); - } - } - - public static RepositoryConfig create( String file, String home ) - throws ConfigurationException - { - File homeFile = new File( home ); - if ( !homeFile.exists( ) ) - { - homeFile.mkdirs( ); - } - - File configurationFile = new File( file ); - if ( !configurationFile.exists( ) ) - { - String resourcePath = "org/apache/archiva/metadata/repository/jcr/repository.xml"; - LoggerFactory.getLogger( ArchivaJcrRepositoryConfig.class ).info( - "no repository.xml file in path {} so use default from resources path {}", file, resourcePath ); - // use bundled repository.xml - return RepositoryConfig.create( - Thread.currentThread( ).getContextClassLoader( ).getResourceAsStream( resourcePath ), home ); - } - - return RepositoryConfig.create( file, home ); - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java ---------------------------------------------------------------------- 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 3649309..2bf9406 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 @@ -37,6 +37,8 @@ import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.MetadataResolutionException; import org.apache.commons.lang.StringUtils; import org.apache.jackrabbit.commons.JcrUtils; +import org.apache.jackrabbit.oak.plugins.index.IndexUtils; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -139,6 +141,8 @@ public class JcrMetadataRepository registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.FACET_NODE_TYPE ); registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE ); + + } private static void registerMixinNodeType( NodeTypeManager nodeTypeManager, String name ) @@ -156,6 +160,8 @@ public class JcrMetadataRepository } } + + @Override public void updateProject( String repositoryId, ProjectMetadata project ) throws MetadataRepositoryException @@ -755,6 +761,10 @@ public class JcrMetadataRepository { throw new MetadataRepositoryException( e.getMessage(), e ); } + log.info("Artifacts found {}", artifacts.size()); + for (ArtifactMetadata meta : artifacts) { + log.info("Artifact: "+meta.getVersion()+" "+meta.getFacetList()); + } return artifacts; } @@ -1418,11 +1428,9 @@ public class JcrMetadataRepository } @Override - public List searchArtifacts( String key, String text, String repositoryId, boolean exact ) + public List searchArtifacts( String key, String text, String repositoryId, boolean e ) throws MetadataRepositoryException { - // we can't do exact search in any property (*), we need a key - boolean e = exact && key != null; String theKey = key == null ? "*" : "[" + key + "]"; String projectVersionCondition = e ? "(projectVersion." + theKey + " = $value)" : "contains([projectVersion]." + theKey + ", $value)"; @@ -1432,7 +1440,6 @@ public class JcrMetadataRepository + ARTIFACT_NODE_TYPE + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) LEFT OUTER JOIN [" + FACET_NODE_TYPE + "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE (" + projectVersionCondition + " OR " + facetCondition + ")"; - return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", text ) ); } @@ -1555,7 +1562,7 @@ public class JcrMetadataRepository private static String getRepositoryContentPath( String repositoryId ) { - return getRepositoryPath( repositoryId ) + "/content/"; + return getRepositoryPath( repositoryId ) + "/content"; } private static String getFacetPath( String repositoryId, String facetId ) @@ -1565,7 +1572,7 @@ public class JcrMetadataRepository private static String getNamespacePath( String repositoryId, String namespace ) { - return getRepositoryContentPath( repositoryId ) + namespace.replace( '.', '/' ); + return getRepositoryContentPath( repositoryId ) + "/" + namespace.replace( '.', '/' ); } private static String getProjectPath( String repositoryId, String namespace, String projectId ) @@ -1594,6 +1601,7 @@ public class JcrMetadataRepository private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType ) throws RepositoryException { + log.debug("getOrAddNodeByPath"+baseNode+" "+name+" "+nodeType); Node node = baseNode; for ( String n : name.split( "/" ) ) { @@ -1614,8 +1622,10 @@ public class JcrMetadataRepository private Node getOrAddRepositoryNode( String repositoryId ) throws RepositoryException { + log.debug("getOrAddRepositoryNode "+repositoryId); Node root = getJcrSession().getRootNode(); Node node = JcrUtils.getOrAddNode( root, "repositories" ); + log.debug("Repositories "+node); node = JcrUtils.getOrAddNode( node, repositoryId ); return node; } http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java new file mode 100644 index 0000000..65e1ace --- /dev/null +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java @@ -0,0 +1,285 @@ +package org.apache.archiva.metadata.repository.jcr; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.MoreExecutors; +import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.Oak; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.IndexConstants; +import org.apache.jackrabbit.oak.plugins.index.IndexUtils; +import org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache; +import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; +import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider; +import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue; +import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.ExternalObserverBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver; +import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory; +import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneInitializerHelper; +import org.apache.jackrabbit.oak.segment.SegmentNodeStore; +import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders; +import org.apache.jackrabbit.oak.segment.file.FileStore; +import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder; +import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException; +import org.apache.jackrabbit.oak.spi.commit.Observer; +import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer; +import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider; +import org.apache.jackrabbit.oak.spi.mount.Mounts; +import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.apache.jackrabbit.oak.stats.StatisticsProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; +import javax.jcr.Repository; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME; +import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_TYPES; + +/** + * Created by martin on 14.06.17. + * + * @author Martin Stockhammer + * @since 3.0.0 + */ +public class RepositoryFactory +{ + + Logger log = LoggerFactory.getLogger( RepositoryFactory.class ); + + public static final String SEGMENT_FILE_TYPE = "oak-segment-tar"; + public static final String IN_MEMORY_TYPE = "oak-memory"; + + String storeType = SEGMENT_FILE_TYPE; + + Path repositoryPath = Paths.get( "repository" ); + + public Repository createRepository( ) throws IOException, InvalidFileStoreVersionException + { + NodeStore nodeStore; + if ( SEGMENT_FILE_TYPE.equals( storeType ) ) + { + FileStore fs = FileStoreBuilder.fileStoreBuilder( repositoryPath.toFile( ) ).build( ); + nodeStore = SegmentNodeStoreBuilders.builder( fs ).build( ); + } else if (IN_MEMORY_TYPE.equals(storeType)) { + nodeStore = null; + } else { + throw new IllegalArgumentException( "Store type "+storeType+" not recognized" ); + } + + Oak oak = nodeStore==null ? new Oak() : new Oak(nodeStore); + oak.with( new RepositoryInitializer( ) + { + @Override + public void initialize( @Nonnull NodeBuilder root ) + { + log.info("Creating index "); + + NodeBuilder lucene = IndexUtils.getOrCreateOakIndex( root ).child("lucene"); + lucene.setProperty( JcrConstants.JCR_PRIMARYTYPE, "oak:QueryIndexDefinition", Type.NAME); + + lucene.setProperty("compatVersion", 2); + lucene.setProperty("type", "lucene"); + // lucene.setProperty("async", "async"); + lucene.setProperty(INCLUDE_PROPERTY_TYPES, + ImmutableSet.of("String"), Type.STRINGS); + // lucene.setProperty("refresh",true); + lucene.setProperty("async",ImmutableSet.of("async", "sync"), Type.STRINGS); + NodeBuilder rules = lucene.child("indexRules"). + setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + rules.setProperty(":childOrder",ImmutableSet.of("archiva:projectVersion","archiva:artifact", + "archiva:facet","archiva:namespace", "archiva:project"), Type.STRINGS); + NodeBuilder allProps = rules.child("archiva:projectVersion") + .child("properties").setProperty( JcrConstants.JCR_PRIMARYTYPE, + "nt:unstructured", Type.NAME) + .setProperty( ":childOrder", ImmutableSet.of("allProps"), Type.STRINGS ) + .setProperty("indexNodeName",true) + .child("allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + allProps.setProperty("name", ".*"); + allProps.setProperty("isRegexp", true); + allProps.setProperty("nodeScopeIndex", true); + allProps.setProperty("index",true); + allProps.setProperty("analyzed",true); + // allProps.setProperty("propertyIndex",true); + allProps = rules.child("archiva:artifact") + .child("properties").setProperty( JcrConstants.JCR_PRIMARYTYPE, + "nt:unstructured", Type.NAME) + .setProperty( ":childOrder", ImmutableSet.of("allProps"), Type.STRINGS ) + .setProperty("indexNodeName",true) + .child("allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + allProps.setProperty("name", ".*"); + allProps.setProperty("isRegexp", true); + allProps.setProperty("nodeScopeIndex", true); + allProps.setProperty("index",true); + allProps.setProperty("analyzed",true); + allProps = rules.child("archiva:facet") + .child("properties").setProperty( JcrConstants.JCR_PRIMARYTYPE, + "nt:unstructured", Type.NAME) + .setProperty( ":childOrder", ImmutableSet.of("allProps"), Type.STRINGS ) + .setProperty("indexNodeName",true) + .child("allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + allProps.setProperty("name", ".*"); + allProps.setProperty("isRegexp", true); + allProps.setProperty("nodeScopeIndex", true); + allProps.setProperty("index",true); + allProps.setProperty("analyzed",true); + allProps = rules.child("archiva:namespace") + .child("properties").setProperty( JcrConstants.JCR_PRIMARYTYPE, + "nt:unstructured", Type.NAME) + .setProperty( ":childOrder", ImmutableSet.of("allProps"), Type.STRINGS ) + .setProperty("indexNodeName",true) + .child("allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + allProps.setProperty("name", ".*"); + allProps.setProperty("isRegexp", true); + allProps.setProperty("nodeScopeIndex", true); + allProps.setProperty("index",true); + allProps.setProperty("analyzed",true); + allProps = rules.child("archiva:project") + .child("properties").setProperty( JcrConstants.JCR_PRIMARYTYPE, + "nt:unstructured", Type.NAME) + .setProperty( ":childOrder", ImmutableSet.of("allProps"), Type.STRINGS ) + .setProperty("indexNodeName",true) + .child("allProps").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); + allProps.setProperty("name", ".*"); + allProps.setProperty("isRegexp", true); + allProps.setProperty("nodeScopeIndex", true); + allProps.setProperty("index",true); + allProps.setProperty("analyzed",true); + + log.info("Index: "+lucene+" myIndex "+lucene.getChildNode( "myIndex" )); + log.info("myIndex "+lucene.getChildNode( "myIndex" ).getProperties()); + // IndexUtils.createIndexDefinition( ) + + } + } ); + + ExecutorService executorService = createExecutor(); + StatisticsProvider statsProvider = StatisticsProvider.NOOP; + int queueSize = Integer.getInteger("queueSize", 10000); + File indexDir = Files.createTempDirectory( "archiva_index" ).toFile(); + log.info("Queue Index "+indexDir.toString()); + IndexCopier indexCopier = new IndexCopier( executorService, indexDir, true ); + NRTIndexFactory nrtIndexFactory = new NRTIndexFactory( indexCopier, statsProvider); + MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider( ); + IndexTracker tracker = new IndexTracker(new DefaultIndexReaderFactory( mountInfoProvider, indexCopier ), nrtIndexFactory); + DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider); + LocalIndexObserver localIndexObserver = new LocalIndexObserver( queue, statsProvider); + LuceneIndexProvider provider = new LuceneIndexProvider(tracker); + + // ExternalObserverBuilder builder = new ExternalObserverBuilder(queue, tracker, statsProvider, +// executorService, queueSize); +// Observer observer = builder.build(); +// builder.getBackgroundObserver(); + + LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, + tracker, new ExtractedTextCache(0, 0), null, mountInfoProvider); + editorProvider.setIndexingQueue(queue); + + + log.info("Oak: "+oak+" with nodeStore "+nodeStore); + Jcr jcr = new Jcr(oak).with( editorProvider ).with( (Observer) provider ) + .with(localIndexObserver) + // .with(observer) + .with( ( QueryIndexProvider) provider ) + .withAsyncIndexing("async",5 ); + Repository r = jcr.createRepository(); + try + { + Thread.currentThread().sleep(1000); + } + catch ( InterruptedException e ) + { + e.printStackTrace( ); + } + return r; + + + } + + public String getStoreType( ) + { + return storeType; + } + + public void setStoreType( String storeType ) + { + this.storeType = storeType; + } + + public Path getRepositoryPath( ) + { + return repositoryPath; + } + + public void setRepositoryPath( Path repositoryPath ) + { + this.repositoryPath = repositoryPath; + } + + public void setRepositoryPath( String repositoryPath ) + { + this.repositoryPath = Paths.get( repositoryPath ); + if ( !Files.exists( this.repositoryPath ) ) + { + try + { + Files.createDirectories( this.repositoryPath ); + } + catch ( IOException e ) + { + e.printStackTrace( ); + } + } + } + + private ExecutorService createExecutor() { + ThreadPoolExecutor executor = new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, + new LinkedBlockingQueue(), new ThreadFactory() { + private final AtomicInteger counter = new AtomicInteger(); + private final Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + log.warn("Error occurred in asynchronous processing ", e); + } + }; + @Override + public Thread newThread(@Nonnull Runnable r) { + Thread thread = new Thread(r, createName()); + thread.setDaemon(true); + thread.setPriority(Thread.MIN_PRIORITY); + thread.setUncaughtExceptionHandler(handler); + return thread; + } + + private String createName() { + return "oak-lucene-" + counter.getAndIncrement(); + } + }); + executor.setKeepAliveTime(1, TimeUnit.MINUTES); + executor.allowCoreThreadTimeOut(true); + return executor; + } + +} http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/log4j2-test.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/resources/log4j2-test.xml b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/log4j2-test.xml new file mode 100644 index 0000000..74dd077 --- /dev/null +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/log4j2-test.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml b/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml index 43f6d08..f98b79b 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml +++ b/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml @@ -19,14 +19,14 @@ --> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - - + + - - - + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml b/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..74dd077 --- /dev/null +++ b/archiva-modules/plugins/metadata-store-jcr/src/test/resources/log4j2-test.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/archiva-modules/plugins/repository-statistics/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml index 2d20aca..ccbdbfc 100644 --- a/archiva-modules/plugins/repository-statistics/pom.xml +++ b/archiva-modules/plugins/repository-statistics/pom.xml @@ -45,10 +45,6 @@ jcr - org.apache.jackrabbit - jackrabbit-jcr-commons - - org.apache.archiva archiva-test-utils ${project.version} @@ -60,17 +56,6 @@ test - org.apache.jackrabbit - jackrabbit-core - test - - - org.slf4j - jcl-over-slf4j - - - - org.mockito mockito-all test @@ -96,7 +81,6 @@ javax.jcr, javax.jcr.query, - org.apache.jackrabbit.commons;version="[2.3,3)", org.apache.archiva.metadata.model;version=${project.version}, org.apache.archiva.metadata.repository;version=${project.version}, org.apache.archiva.metadata.repository.storage.maven2;version=${project.version}, http://git-wip-us.apache.org/repos/asf/archiva/blob/7d2cc26b/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 8e12a4c..f335da7 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 1.6 3.2.1 1.2.2 - 2.4 + 2.5 2.6 3.0.5 @@ -59,7 +59,8 @@ 1.13.1 2.1 - 5.1.1 + + 6.0-SNAPSHOT 2.9 3.0.0-SNAPSHOT 2.2 @@ -75,7 +76,7 @@ 2.0 UTF-8 true - 3.6.2 + 4.10.4 2.14.1 3.0.3 @@ -127,17 +128,6 @@ test - org.apache.jackrabbit - jackrabbit-webdav - ${jackrabbit.version} - - - commons-logging - commons-logging - - - - xerces xercesImpl 2.11.0 @@ -1317,16 +1307,7 @@ jcr ${javax.jcr.version} - - org.apache.jackrabbit - jackrabbit-jcr-commons - ${jackrabbit.version} - - - org.apache.jackrabbit - jackrabbit-core - ${jackrabbit.version} - + @@ -1623,7 +1604,7 @@ org.apache.maven.plugins maven-surefire-plugin - @{jacocoproperty} + ${surefire.redirectTestOutputToFile} alphabetical