</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </exclusion>
- </exclusions>
+ <artifactId>archiva-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-policies</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-xml-tools</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-checksum</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-model</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
</dependency>
<dependency>
<!-- TEST Scope -->
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.lmax</groupId>
- <artifactId>disruptor</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva.components.cache</groupId>
- <artifactId>archiva-components-spring-cache-ehcache</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
* under the License.
*/
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
import me.prettyprint.cassandra.serializers.LongSerializer;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.template.ColumnFamilyResult;
import me.prettyprint.hector.api.query.QueryResult;
import me.prettyprint.hector.api.query.RangeSlicesQuery;
import org.apache.archiva.checksum.ChecksumAlgorithm;
-import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.metadata.QueryParameter;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import java.time.Instant;
import java.time.ZonedDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.UUID;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Collectors;
private static final String ARTIFACT_METADATA_MODEL_KEY = "artifactMetadataModel.key";
private Logger logger = LoggerFactory.getLogger( getClass() );
- private ArchivaConfiguration configuration;
-
private final CassandraArchivaManager cassandraArchivaManager;
private final ColumnFamilyTemplate<String, String> projectVersionMetadataTemplate;
private final StringSerializer ss = StringSerializer.get();
public CassandraMetadataRepository( MetadataService metadataService,
- ArchivaConfiguration configuration,
CassandraArchivaManager cassandraArchivaManager )
{
super( metadataService );
- this.configuration = configuration;
this.cassandraArchivaManager = cassandraArchivaManager;
this.keyspace = cassandraArchivaManager.getKeyspace();
.addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) //
.execute();
- Set<String> namespaces = new HashSet<String>( result.get().getCount() );
+ Set<String> namespaces = new HashSet<>( result.get( ).getCount( ) );
for ( Row<String, String, String> row : result.get() )
{
.execute();
// project exists ? if yes return nothing to update here
- if ( result.get().getCount() > 0 )
- {
- return;
- }
- else
+ if ( result.get( ).getCount( ) <= 0 )
{
Namespace namespace = updateOrAddNamespace( repositoryId, projectMetadata.getNamespace() );
.addEqualsExpression( NAMESPACE_ID.toString(), namespace ) //
.execute();
- final Set<String> projects = new HashSet<String>( result.get().getCount() );
+ final Set<String> projects = new HashSet<>( result.get( ).getCount( ) );
for ( Row<String, String, String> row : result.get() )
{
return Collections.emptyList();
}
- Set<String> versions = new HashSet<String>( count );
+ Set<String> versions = new HashSet<>( count );
for ( Row<String, String, String> orderedRows : result.get() )
{
.addEqualsExpression( PROJECT_VERSION.toString(), versionMetadata.getId() ) //
.execute();
- ProjectVersionMetadataModel projectVersionMetadataModel = null;
+ ProjectVersionMetadataModel projectVersionMetadataModel;
boolean creation = true;
if ( result.get().getCount() > 0 )
{
recordDependencies( key, versionMetadata.getDependencies(), repositoryId );
- MutationResult mutationResult = mutator.execute();
+ mutator.execute();
}
else
{
{
ColumnSlice<String, String> columnSlice = row.getColumnSlice();
String facetId = getStringValue( columnSlice, FACET_ID.toString() );
- Map<String, String> metaValues = metadataFacetsPerFacetIds.get( facetId );
- if ( metaValues == null )
- {
- metaValues = new HashMap<>();
- metadataFacetsPerFacetIds.put( facetId, metaValues );
- }
+ Map<String, String> metaValues = metadataFacetsPerFacetIds.computeIfAbsent( facetId, k -> new HashMap<>( ) );
metaValues.put( getStringValue( columnSlice, KEY.toString() ), getStringValue( columnSlice, VALUE.toString() ) );
}
{
for ( Map.Entry<String, Map<String, String>> entry : metadataFacetsPerFacetIds.entrySet() )
{
- MetadataFacetFactory metadataFacetFactory = getFacetFactory( entry.getKey() );
+ MetadataFacetFactory<?> metadataFacetFactory = getFacetFactory( entry.getKey() );
if ( metadataFacetFactory != null )
{
MetadataFacet metadataFacet = metadataFacetFactory.createMetadataFacet();
private Map<String, String> mapChecksums(Map<ChecksumAlgorithm,String> checksums) {
return checksums.entrySet().stream().collect(Collectors.toMap(
- e -> e.getKey().name(), e -> e.getValue()
+ e -> e.getKey().name(), Map.Entry::getValue
));
}
private Map<ChecksumAlgorithm, String> mapChecksumsReverse(Map<String,String> checksums) {
return checksums.entrySet().stream().collect(Collectors.toMap(
- e -> ChecksumAlgorithm.valueOf(e.getKey()), e -> e.getValue()
+ e -> ChecksumAlgorithm.valueOf(e.getKey()), Map.Entry::getValue
));
}
return null;
}
final String facetId = metadataFacetFactory.getFacetId( );
- if ( metadataFacetFactory == null )
- {
- return null;
- }
QueryResult<OrderedRows<String, String, String>> result = HFactory //
.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
}
}
- return new ArrayList(artifactMetadataMap.values());
+ return new ArrayList<>(artifactMetadataMap.values());
}
/**
return Collections.emptyList();
}
- List<ArtifactMetadata> artifactMetadatas = new LinkedList<ArtifactMetadata>();
+ List<ArtifactMetadata> artifactMetadatas = new LinkedList<>( );
// TODO doing multiple queries, there should be a way to get all the artifactMetadatas for any number of
// projects
return Collections.emptyList();
}
- List<ArtifactMetadata> artifacts = new LinkedList<ArtifactMetadata>();
+ List<ArtifactMetadata> artifacts = new LinkedList<>( );
for ( Row<String, String, String> row : result.get() )
{
for ( final ArtifactMetadata artifactMetadata : artifactMetadatas )
{
- Iterable<MetadataFacetModel> metadataFacetModelIterable =
- Iterables.filter( metadataFacetModels, new Predicate<MetadataFacetModel>()
+ Iterator<MetadataFacetModel> iterator = metadataFacetModels.stream( ).filter( metadataFacetModel -> {
+ if ( metadataFacetModel != null )
{
- @Override
- public boolean apply( MetadataFacetModel metadataFacetModel )
- {
- if ( metadataFacetModel != null )
- {
- return StringUtils.equals( artifactMetadata.getVersion(),
- metadataFacetModel.getProjectVersion() );
- }
- return false;
- }
- } );
- Iterator<MetadataFacetModel> iterator = metadataFacetModelIterable.iterator();
+ return StringUtils.equals( artifactMetadata.getVersion( ),
+ metadataFacetModel.getProjectVersion( ) );
+ }
+ return false;
+
+ } ).iterator( );
Map<String, List<MetadataFacetModel>> metadataFacetValuesPerFacetId = new HashMap<>();
while ( iterator.hasNext() )
{
for ( Map.Entry<String, List<MetadataFacetModel>> entry : metadataFacetValuesPerFacetId.entrySet() )
{
- MetadataFacetFactory metadataFacetFactory = getFacetFactory( entry.getKey() );
+ MetadataFacetFactory<?> metadataFacetFactory = getFacetFactory( entry.getKey() );
if ( metadataFacetFactory != null )
{
List<MetadataFacetModel> facetModels = entry.getValue();
throws MetadataRepositoryException
{
// TODO optimize
- List<ArtifactMetadata> artifacts = new LinkedList<ArtifactMetadata>();
+ List<ArtifactMetadata> artifacts = new LinkedList<>( );
artifacts.addAll( this.getArtifactsByAttribute( session, key, text, repositoryId ) );
artifacts.addAll( this.getArtifactsByProjectVersionAttribute( session, key, text, repositoryId ) );
return artifacts;