diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java index b4e3abf3d..f9a89b5e0 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.converter.artifact; * under the License. */ +import org.apache.archiva.common.plexusbridge.DigesterUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.commons.io.FileUtils; @@ -78,11 +79,14 @@ public class LegacyToDefaultConverter * {@link List}<{@link Digester} * plexus.requirement role="org.codehaus.plexus.digest.Digester" */ - private List digesters; + private List digesters; @Inject private PlexusSisuBridge plexusSisuBridge; + @Inject + private DigesterUtils digesterUtils; + /** * plexus.requirement */ @@ -114,7 +118,7 @@ public class LegacyToDefaultConverter public void initialize() throws PlexusSisuBridgeException { - this.digesters = plexusSisuBridge.lookupList( Digester.class ); + this.digesters = digesterUtils.getAllDigesters(); translator = plexusSisuBridge.lookup( ModelConverter.class ); artifactFactory = plexusSisuBridge.lookup( ArtifactFactory.class ); artifactHandlerManager = plexusSisuBridge.lookup( ArtifactHandlerManager.class ); @@ -716,7 +720,7 @@ public class LegacyToDefaultConverter } - public List getDigesters() + public List getDigesters() { return digesters; } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java index 24e4a9797..13bb7575d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/ValidateChecksumConsumer.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.consumers.core; * under the License. */ +import org.apache.archiva.common.plexusbridge.DigesterUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -81,11 +82,14 @@ public class ValidateChecksumConsumer /** * plexus.requirement role="org.codehaus.plexus.digest.Digester" */ - private List digesterList; + private List allDigesters; @Inject private PlexusSisuBridge plexusSisuBridge; + @Inject + private DigesterUtils digesterUtils; + private File repositoryDir; private List includes = new ArrayList(); @@ -163,7 +167,7 @@ public class ValidateChecksumConsumer } } - public void processFile( String path, boolean executeOnEntireRepo ) + public void processFile( String path, boolean executeOnEntireReDpo ) throws Exception { processFile( path ); @@ -174,10 +178,9 @@ public class ValidateChecksumConsumer throws PlexusSisuBridgeException { checksum = plexusSisuBridge.lookup( ChecksumFile.class ); - digesterList = plexusSisuBridge.lookupList( Digester.class ); - for ( Iterator itDigesters = digesterList.iterator(); itDigesters.hasNext(); ) + List allDigesters = new ArrayList( digesterUtils.getAllDigesters() ); + for ( Digester digester : allDigesters ) { - Digester digester = itDigesters.next(); includes.add( "**/*" + digester.getFilenameExtension() ); } } diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml index 0da840e23..1a98f4203 100644 --- a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml +++ b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml @@ -53,5 +53,15 @@ org.apache.maven.indexer indexer-core + + org.codehaus.plexus + plexus-digest + + + org.codehaus.plexus + plexus-component-api + + + diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/DigesterUtils.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/DigesterUtils.java new file mode 100644 index 000000000..a8a72d417 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/DigesterUtils.java @@ -0,0 +1,74 @@ +package org.apache.archiva.common.plexusbridge; + +/* + * 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.codehaus.plexus.digest.Digester; +import org.codehaus.plexus.digest.Md5Digester; +import org.codehaus.plexus.digest.Sha1Digester; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.util.Arrays; +import java.util.List; + +/** + * @author Olivier Lamy + * @since 1.4 + */ +@Service( "digesterUtils" ) +public class DigesterUtils +{ + + private Logger log = LoggerFactory.getLogger( getClass() ); + + private List allDigesters; + + @Inject + public DigesterUtils( PlexusSisuBridge plexusSisuBridge ) + throws PlexusSisuBridgeException + { + this.allDigesters = plexusSisuBridge.lookupList( Digester.class ); + + if ( allDigesters == null || allDigesters.isEmpty() ) + { + // olamy when the TCL is not a URLClassLoader lookupList fail ! + // when using tomcat maven plugin so adding a simple hack + log.warn( "using lookList from sisu plexus failed so build plexus Digesters manually" ); + + allDigesters = Arrays.asList( new Sha1Digester(), new Md5Digester() ); + + } + + log.debug( "allIndexCreators {}", allDigesters ); + + } + + public List getAllDigesters() + { + return allDigesters; + } + + public void setAllDigesters( List allDigesters ) + { + this.allDigesters = allDigesters; + } +} diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java index 602d5b479..a0f35bd6f 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java @@ -49,19 +49,19 @@ public abstract class AbstractTransactionEvent /** * {@link List}<{@link Digester}> */ - private List digesters; + private List digesters; protected AbstractTransactionEvent() { this( new ArrayList( 0 ) ); } - protected AbstractTransactionEvent( List digesters ) + protected AbstractTransactionEvent( List digesters ) { this.digesters = digesters; } - protected List getDigesters() + protected List getDigesters() { return digesters; } diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java index 094743ec5..0b4763e2e 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java @@ -44,7 +44,7 @@ public class CopyFileEvent * @param destination * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming */ - public CopyFileEvent( File source, File destination, List digesters ) + public CopyFileEvent( File source, File destination, List digesters ) { super( digesters ); this.source = source; diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java index ea8f51014..206518463 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java @@ -43,7 +43,7 @@ public class CreateFileEvent * @param destination * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming */ - public CreateFileEvent( String content, File destination, List digesters ) + public CreateFileEvent( String content, File destination, List digesters ) { super( digesters ); this.content = content; diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java index ca2d168ce..45972ede4 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java @@ -79,7 +79,7 @@ public class FileTransaction * @param destination * @param digesters {@link List}<{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming */ - public void copyFile( File source, File destination, List digesters ) + public void copyFile( File source, File destination, List digesters ) { events.add( new CopyFileEvent( source, destination, digesters ) ); } @@ -89,7 +89,7 @@ public class FileTransaction * @param destination * @param digesters {@link List}<{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming */ - public void createFile( String content, File destination, List digesters ) + public void createFile( String content, File destination, List digesters ) { events.add( new CreateFileEvent( content, destination, digesters ) ); }