aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/metadata-store-jcr/src
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-06-20 17:44:00 +0200
committerMartin Stockhammer <martin_s@apache.org>2020-06-20 17:44:00 +0200
commitcc10ae9f1e8ae56a9118656c8940dc2f6598347c (patch)
tree0325a5b45b9ffa69aaddf57e5b53c6b9d9b55560 /archiva-modules/plugins/metadata-store-jcr/src
parent3988bfa918a1b4a08497c075ba23f5f2615eaf58 (diff)
downloadarchiva-cc10ae9f1e8ae56a9118656c8940dc2f6598347c.tar.gz
archiva-cc10ae9f1e8ae56a9118656c8940dc2f6598347c.zip
Dependency cleanup of metadata-store-jcr
Diffstat (limited to 'archiva-modules/plugins/metadata-store-jcr/src')
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java85
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/OakRepositoryFactory.java36
2 files changed, 97 insertions, 24 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 fb171f3b0..811fb0733 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
@@ -19,12 +19,31 @@ package org.apache.archiva.metadata.repository.jcr;
* under the License.
*/
-import com.google.common.collect.ImmutableMap;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.metadata.QueryParameter;
-import org.apache.archiva.metadata.model.*;
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
-import 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.FacetedMetadata;
+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.ModelInfo;
+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.apache.archiva.metadata.repository.AbstractMetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.archiva.metadata.repository.MetadataService;
+import org.apache.archiva.metadata.repository.MetadataSessionException;
+import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics;
import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider;
import org.apache.commons.lang3.StringUtils;
@@ -34,14 +53,43 @@ import org.apache.jackrabbit.commons.cnd.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.*;
-import javax.jcr.query.*;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.time.ZonedDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
+import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -845,7 +893,10 @@ public class JcrMetadataRepository
throws MetadataRepositoryException {
final Session jcrSession = getSession(session);
final String q = new StringBuilder(QUERY_ARTIFACTS_BY_PROJECT_VERSION_1).append(key).append(QUERY_ARTIFACTS_BY_PROJECT_VERSION_2).toString();
- return runJcrQuery(jcrSession, repositoryId, q, ImmutableMap.of("value", value));
+ Map<String, String> parameterMap = new HashMap<>();
+ parameterMap.put("value", value);
+ parameterMap = Collections.unmodifiableMap(parameterMap);
+ return runJcrQuery(jcrSession, repositoryId, q, parameterMap);
}
@@ -854,7 +905,10 @@ public class JcrMetadataRepository
throws MetadataRepositoryException {
final Session jcrSession = getSession(session);
final String q = new StringBuilder(QUERY_ARTIFACTS_BY_METADATA_1).append(key).append(QUERY_ARTIFACTS_BY_METADATA_2).toString();
- return runJcrQuery(jcrSession, repositoryId, q, ImmutableMap.of("value", value));
+ Map<String, String> parameterMap = new HashMap<>();
+ parameterMap.put("value", value);
+ parameterMap = Collections.unmodifiableMap(parameterMap);
+ return runJcrQuery(jcrSession, repositoryId, q, parameterMap);
}
@@ -863,7 +917,10 @@ public class JcrMetadataRepository
throws MetadataRepositoryException {
final Session jcrSession = getSession(session);
final String q = new StringBuilder(QUERY_ARTIFACTS_BY_PROPERTY_1).append(key).append(QUERY_ARTIFACTS_BY_PROPERTY_2).toString();
- return runJcrQuery(jcrSession, repositoryId, q, ImmutableMap.of("value", value));
+ Map<String, String> parameterMap = new HashMap<>();
+ parameterMap.put("value", value);
+ parameterMap = Collections.unmodifiableMap(parameterMap);
+ return runJcrQuery(jcrSession, repositoryId, q, parameterMap);
}
@@ -1400,14 +1457,20 @@ public class JcrMetadataRepository
"SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE
+ "] AS projectVersion LEFT OUTER JOIN [" + ARTIFACT_NODE_TYPE
+ "] AS artifact ON ISCHILDNODE(artifact, projectVersion) WHERE " + projectVersionCondition + descendantCondition;
- result.addAll(runJcrQuery(jcrSession, repositoryId, q1, ImmutableMap.of("value", text), false));
+ Map<String, String> parameterMap = new HashMap<>();
+ parameterMap.put("value", text);
+ parameterMap = Collections.unmodifiableMap(parameterMap);
+ result.addAll(runJcrQuery(jcrSession, repositoryId, q1, parameterMap, false));
}
String q2 =
"SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE
+ "] AS projectVersion LEFT OUTER JOIN [" + ARTIFACT_NODE_TYPE
+ "] AS artifact ON ISCHILDNODE(artifact, projectVersion) LEFT OUTER JOIN [" + FACET_NODE_TYPE
+ "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE " + facetCondition + descendantCondition;
- result.addAll(runJcrQuery(jcrSession, repositoryId, q2, ImmutableMap.of("value", text), false));
+ Map<String, String> parameterMap = new HashMap<>();
+ parameterMap.put("value", text);
+ parameterMap = Collections.unmodifiableMap(parameterMap);
+ result.addAll(runJcrQuery(jcrSession, repositoryId, q2, parameterMap, false));
return result;
}
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/OakRepositoryFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/OakRepositoryFactory.java
index cbd80c344..8822ff07b 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/OakRepositoryFactory.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/OakRepositoryFactory.java
@@ -19,8 +19,6 @@ package org.apache.archiva.metadata.repository.jcr;
* under the License.
*/
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.jcr.Jcr;
@@ -71,7 +69,6 @@ import org.apache.jackrabbit.oak.spi.state.Clusterable;
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.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,6 +78,11 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
@@ -88,7 +90,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.archiva.metadata.repository.jcr.JcrConstants.*;
import static org.apache.archiva.metadata.repository.jcr.OakRepositoryFactory.StoreType.IN_MEMORY_TYPE;
import static org.apache.archiva.metadata.repository.jcr.OakRepositoryFactory.StoreType.SEGMENT_FILE_TYPE;
@@ -241,7 +242,7 @@ public class OakRepositoryFactory
}
};
@Override
- public Thread newThread(@NotNull Runnable r) {
+ public Thread newThread(Runnable r) {
Thread thread = new Thread(r, createName());
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY);
@@ -305,7 +306,10 @@ public class OakRepositoryFactory
}
private Path getIndexCheckDir() {
- return checkNotNull(indexDir).resolve("indexCheckDir");
+ if (indexDir==null) {
+ throw new NullPointerException( "Null value for indexDir encountered." );
+ }
+ return indexDir.resolve("indexCheckDir");
}
private LuceneIndexImporter registerIndexImporterProvider() {
@@ -343,7 +347,10 @@ public class OakRepositoryFactory
editorProvider.setBlobStore(blobStore);
if (hybridIndex){
- editorProvider.setIndexingQueue(checkNotNull(documentQueue));
+ if (documentQueue==null) {
+ throw new NullPointerException( "Null value for documentQueue encountered" );
+ }
+ editorProvider.setIndexingQueue(documentQueue);
}
@@ -456,14 +463,15 @@ public class OakRepositoryFactory
// lucene.setProperty("refresh",true);
NodeBuilder rules = lucene.child( "indexRules" ).
setProperty( JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME );
- rules.setProperty( ":childOrder", ImmutableSet.of(
- REPOSITORY_NODE_TYPE,
- NAMESPACE_MIXIN_TYPE, //
- PROJECT_MIXIN_TYPE,
+ Set<String> parameterSet = new HashSet<>( Arrays.asList(REPOSITORY_NODE_TYPE,
+ NAMESPACE_MIXIN_TYPE, //
+ PROJECT_MIXIN_TYPE,
PROJECT_VERSION_NODE_TYPE, //
ARTIFACT_NODE_TYPE, //
FACET_NODE_TYPE //
- ), Type.STRINGS );
+ ));
+ parameterSet = Collections.unmodifiableSet(parameterSet);
+ rules.setProperty( ":childOrder", parameterSet, Type.STRINGS );
IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder( lucene );
idxBuilder.async( "async", "nrt", "sync" ).includedPaths( "/repositories" ).evaluatePathRestrictions();
@@ -526,7 +534,9 @@ public class OakRepositoryFactory
idxBuilder.build( );
- IndexUtils.createIndexDefinition( oakIdx, "baseIndexes", true, false, ImmutableList.of( "jcr:uuid", "rep:principalName" ), null );
+ List<String> parameterList = Arrays.asList("jcr:uuid", "rep:principalName");
+ parameterList = Collections.unmodifiableList(parameterList);
+ IndexUtils.createIndexDefinition( oakIdx, "baseIndexes", true, false, parameterList, null );
log.info( "Index: {} repo-lucene: {}", lucene, lucene.getChildNode( "repo-lucene" ) );
log.info( "repo-lucene Properties: {}", lucene.getChildNode( "repo-lucene" ).getProperties( ) );