http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdatePolicyAnalyzer.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdatePolicyAnalyzer.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdatePolicyAnalyzer.java deleted file mode 100644 index c2cdd83..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdatePolicyAnalyzer.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.util.Calendar; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.impl.UpdatePolicyAnalyzer; -import org.eclipse.aether.repository.RepositoryPolicy; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; - -/** - */ -@Named -public class DefaultUpdatePolicyAnalyzer - implements UpdatePolicyAnalyzer, Service -{ - - private Logger logger = NullLoggerFactory.LOGGER; - - public DefaultUpdatePolicyAnalyzer() - { - // enables default constructor - } - - @Inject - DefaultUpdatePolicyAnalyzer( LoggerFactory loggerFactory ) - { - setLoggerFactory( loggerFactory ); - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( LoggerFactory.class ) ); - } - - public DefaultUpdatePolicyAnalyzer setLoggerFactory( LoggerFactory loggerFactory ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, getClass() ); - return this; - } - - public String getEffectiveUpdatePolicy( RepositorySystemSession session, String policy1, String policy2 ) - { - return ordinalOfUpdatePolicy( policy1 ) < ordinalOfUpdatePolicy( policy2 ) ? policy1 : policy2; - } - - private int ordinalOfUpdatePolicy( String policy ) - { - if ( RepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) ) - { - return 1440; - } - else if ( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) ) - { - return 0; - } - else if ( policy != null && policy.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) ) - { - return getMinutes( policy ); - } - else - { - // assume "never" - return Integer.MAX_VALUE; - } - } - - public boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy ) - { - boolean checkForUpdates; - - if ( policy == null ) - { - policy = ""; - } - - if ( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) ) - { - checkForUpdates = true; - } - else if ( RepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) ) - { - Calendar cal = Calendar.getInstance(); - cal.set( Calendar.HOUR_OF_DAY, 0 ); - cal.set( Calendar.MINUTE, 0 ); - cal.set( Calendar.SECOND, 0 ); - cal.set( Calendar.MILLISECOND, 0 ); - - checkForUpdates = cal.getTimeInMillis() > lastModified; - } - else if ( policy.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) ) - { - int minutes = getMinutes( policy ); - - Calendar cal = Calendar.getInstance(); - cal.add( Calendar.MINUTE, -minutes ); - - checkForUpdates = cal.getTimeInMillis() > lastModified; - } - else - { - // assume "never" - checkForUpdates = false; - - if ( !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( policy ) ) - { - logger.warn( "Unknown repository update policy '" + policy + "', assuming '" - + RepositoryPolicy.UPDATE_POLICY_NEVER + "'" ); - } - } - - return checkForUpdates; - } - - private int getMinutes( String policy ) - { - int minutes; - try - { - String s = policy.substring( RepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 ); - minutes = Integer.valueOf( s ); - } - catch ( RuntimeException e ) - { - minutes = 24 * 60; - - logger.warn( "Non-parseable repository update policy '" + policy + "', assuming '" - + RepositoryPolicy.UPDATE_POLICY_INTERVAL + ":1440'" ); - } - return minutes; - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultVersionFilterContext.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultVersionFilterContext.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultVersionFilterContext.java deleted file mode 100644 index 2007368..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultVersionFilterContext.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.util.ArrayList; -import java.util.Collections; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.collection.VersionFilter; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.repository.ArtifactRepository; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.VersionRangeResult; -import org.eclipse.aether.version.Version; -import org.eclipse.aether.version.VersionConstraint; - -/** - * @see DefaultDependencyCollector - */ -final class DefaultVersionFilterContext - implements VersionFilter.VersionFilterContext -{ - - private final Iterator<Version> EMPTY = Collections.<Version>emptySet().iterator(); - - private final RepositorySystemSession session; - - private Dependency dependency; - - VersionRangeResult result; - - int count; - - byte[] deleted = new byte[64]; - - public DefaultVersionFilterContext( RepositorySystemSession session ) - { - this.session = session; - } - - public void set( Dependency dependency, VersionRangeResult result ) - { - this.dependency = dependency; - this.result = result; - count = result.getVersions().size(); - if ( deleted.length < count ) - { - deleted = new byte[count]; - } - else - { - for ( int i = count - 1; i >= 0; i-- ) - { - deleted[i] = 0; - } - } - } - - public List<Version> get() - { - if ( count == result.getVersions().size() ) - { - return result.getVersions(); - } - if ( count <= 1 ) - { - if ( count <= 0 ) - { - return Collections.emptyList(); - } - return Collections.singletonList( iterator().next() ); - } - List<Version> versions = new ArrayList<Version>( count ); - for ( Version version : this ) - { - versions.add( version ); - } - return versions; - } - - public RepositorySystemSession getSession() - { - return session; - } - - public Dependency getDependency() - { - return dependency; - } - - public VersionConstraint getVersionConstraint() - { - return result.getVersionConstraint(); - } - - public int getCount() - { - return count; - } - - public ArtifactRepository getRepository( Version version ) - { - return result.getRepository( version ); - } - - public List<RemoteRepository> getRepositories() - { - return Collections.unmodifiableList( result.getRequest().getRepositories() ); - } - - public Iterator<Version> iterator() - { - return ( count > 0 ) ? new VersionIterator() : EMPTY; - } - - @Override - public String toString() - { - return dependency + " " + result.getVersions(); - } - - private class VersionIterator - implements Iterator<Version> - { - - private final List<Version> versions; - - private final int size; - - private int count; - - private int index; - - private int next; - - public VersionIterator() - { - count = DefaultVersionFilterContext.this.count; - index = -1; - next = 0; - versions = result.getVersions(); - size = versions.size(); - advance(); - } - - private void advance() - { - for ( next = index + 1; next < size && deleted[next] != 0; next++ ) - { - // just advancing index - } - } - - public boolean hasNext() - { - return next < size; - } - - public Version next() - { - if ( count != DefaultVersionFilterContext.this.count ) - { - throw new ConcurrentModificationException(); - } - if ( next >= size ) - { - throw new NoSuchElementException(); - } - index = next; - advance(); - return versions.get( index ); - } - - public void remove() - { - if ( count != DefaultVersionFilterContext.this.count ) - { - throw new ConcurrentModificationException(); - } - if ( index < 0 || deleted[index] == 1 ) - { - throw new IllegalStateException(); - } - deleted[index] = 1; - count = --DefaultVersionFilterContext.this.count; - } - - @Override - public String toString() - { - return ( index < 0 ) ? "null" : String.valueOf( versions.get( index ) ); - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java deleted file mode 100644 index 11ba9a1..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.repository.LocalArtifactRegistration; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.util.ConfigUtils; - -/** - * These are implementation details for enhanced local repository manager, subject to change without prior notice. - * Repositories from which a cached artifact was resolved are tracked in a properties file named - * <code>_remote.repositories</code>, with content key as filename>repo_id and value as empty string. If a file has - * been installed in the repository, but not downloaded from a remote repository, it is tracked as empty repository id - * and always resolved. For example: - * - * <pre> - * artifact-1.0.pom>= - * artifact-1.0.jar>= - * artifact-1.0.pom>central= - * artifact-1.0.jar>central= - * artifact-1.0.zip>central= - * artifact-1.0-classifier.zip>central= - * artifact-1.0.pom>my_repo_id= - * </pre> - * - * @see EnhancedLocalRepositoryManagerFactory - */ -class EnhancedLocalRepositoryManager - extends SimpleLocalRepositoryManager -{ - - private static final String LOCAL_REPO_ID = ""; - - private final String trackingFilename; - - private final TrackingFileManager trackingFileManager; - - public EnhancedLocalRepositoryManager( File basedir, RepositorySystemSession session ) - { - super( basedir, "enhanced" ); - String filename = ConfigUtils.getString( session, "", "aether.enhancedLocalRepository.trackingFilename" ); - if ( filename.length() <= 0 || filename.contains( "/" ) || filename.contains( "\\" ) - || filename.contains( ".." ) ) - { - filename = "_remote.repositories"; - } - trackingFilename = filename; - trackingFileManager = new TrackingFileManager(); - } - - @Override - public EnhancedLocalRepositoryManager setLogger( Logger logger ) - { - super.setLogger( logger ); - trackingFileManager.setLogger( logger ); - return this; - } - - @Override - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - String path = getPathForArtifact( request.getArtifact(), false ); - File file = new File( getRepository().getBasedir(), path ); - - LocalArtifactResult result = new LocalArtifactResult( request ); - - if ( file.isFile() ) - { - result.setFile( file ); - - Properties props = readRepos( file ); - - if ( props.get( getKey( file, LOCAL_REPO_ID ) ) != null ) - { - // artifact installed into the local repo is always accepted - result.setAvailable( true ); - } - else - { - String context = request.getContext(); - for ( RemoteRepository repository : request.getRepositories() ) - { - if ( props.get( getKey( file, getRepositoryKey( repository, context ) ) ) != null ) - { - // artifact downloaded from remote repository is accepted only downloaded from request - // repositories - result.setAvailable( true ); - result.setRepository( repository ); - break; - } - } - if ( !result.isAvailable() && !isTracked( props, file ) ) - { - /* - * NOTE: The artifact is present but not tracked at all, for inter-op with simple local repo, assume - * the artifact was locally installed. - */ - result.setAvailable( true ); - } - } - } - - return result; - } - - @Override - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - Collection<String> repositories; - if ( request.getRepository() == null ) - { - repositories = Collections.singleton( LOCAL_REPO_ID ); - } - else - { - repositories = getRepositoryKeys( request.getRepository(), request.getContexts() ); - } - addArtifact( request.getArtifact(), repositories, request.getRepository() == null ); - } - - private Collection<String> getRepositoryKeys( RemoteRepository repository, Collection<String> contexts ) - { - Collection<String> keys = new HashSet<String>(); - - if ( contexts != null ) - { - for ( String context : contexts ) - { - keys.add( getRepositoryKey( repository, context ) ); - } - } - - return keys; - } - - private void addArtifact( Artifact artifact, Collection<String> repositories, boolean local ) - { - if ( artifact == null ) - { - throw new IllegalArgumentException( "artifact to register not specified" ); - } - String path = getPathForArtifact( artifact, local ); - File file = new File( getRepository().getBasedir(), path ); - addRepo( file, repositories ); - } - - private Properties readRepos( File artifactFile ) - { - File trackingFile = getTrackingFile( artifactFile ); - - Properties props = trackingFileManager.read( trackingFile ); - - return ( props != null ) ? props : new Properties(); - } - - private void addRepo( File artifactFile, Collection<String> repositories ) - { - Map<String, String> updates = new HashMap<String, String>(); - for ( String repository : repositories ) - { - updates.put( getKey( artifactFile, repository ), "" ); - } - - File trackingFile = getTrackingFile( artifactFile ); - - trackingFileManager.update( trackingFile, updates ); - } - - private File getTrackingFile( File artifactFile ) - { - return new File( artifactFile.getParentFile(), trackingFilename ); - } - - private String getKey( File file, String repository ) - { - return file.getName() + '>' + repository; - } - - private boolean isTracked( Properties props, File file ) - { - if ( props != null ) - { - String keyPrefix = file.getName() + '>'; - for ( Object key : props.keySet() ) - { - if ( key.toString().startsWith( keyPrefix ) ) - { - return true; - } - } - } - return false; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java deleted file mode 100644 index cfd2013..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.NoLocalRepositoryManagerException; -import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; - -/** - * Creates enhanced local repository managers for repository types {@code "default"} or {@code "" (automatic)}. Enhanced - * local repository manager is built upon the classical Maven 2.0 local repository structure but additionally keeps - * track of from what repositories a cached artifact was resolved. Resolution of locally cached artifacts will be - * rejected in case the current resolution request does not match the known source repositories of an artifact, thereby - * emulating physically separated artifact caches per remote repository. - */ -@Named( "enhanced" ) -public class EnhancedLocalRepositoryManagerFactory - implements LocalRepositoryManagerFactory, Service -{ - - private Logger logger = NullLoggerFactory.LOGGER; - - private float priority = 10; - - public EnhancedLocalRepositoryManagerFactory() - { - // enable no-arg constructor - } - - @Inject - EnhancedLocalRepositoryManagerFactory( LoggerFactory loggerFactory ) - { - setLoggerFactory( loggerFactory ); - } - - public LocalRepositoryManager newInstance( RepositorySystemSession session, LocalRepository repository ) - throws NoLocalRepositoryManagerException - { - if ( "".equals( repository.getContentType() ) || "default".equals( repository.getContentType() ) ) - { - return new EnhancedLocalRepositoryManager( repository.getBasedir(), session ).setLogger( logger ); - } - else - { - throw new NoLocalRepositoryManagerException( repository ); - } - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( LoggerFactory.class ) ); - } - - public EnhancedLocalRepositoryManagerFactory setLoggerFactory( LoggerFactory loggerFactory ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, EnhancedLocalRepositoryManager.class ); - return this; - } - - public float getPriority() - { - return priority; - } - - /** - * Sets the priority of this component. - * - * @param priority The priority. - * @return This component for chaining, never {@code null}. - */ - public EnhancedLocalRepositoryManagerFactory setPriority( float priority ) - { - this.priority = priority; - return this; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/FailChecksumPolicy.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/FailChecksumPolicy.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/FailChecksumPolicy.java deleted file mode 100644 index 4f3de45..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/FailChecksumPolicy.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.transfer.ChecksumFailureException; -import org.eclipse.aether.transfer.TransferResource; - -/** - * Implements {@link org.eclipse.aether.repository.RepositoryPolicy#CHECKSUM_POLICY_FAIL}. - */ -final class FailChecksumPolicy - extends AbstractChecksumPolicy -{ - - public FailChecksumPolicy( LoggerFactory loggerFactory, TransferResource resource ) - { - super( loggerFactory, resource ); - } - - public boolean onTransferChecksumFailure( ChecksumFailureException error ) - { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/LoggerFactoryProvider.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/LoggerFactoryProvider.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/LoggerFactoryProvider.java deleted file mode 100644 index 3d46490..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/LoggerFactoryProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; - -/** - * Helps Sisu-based applications to pick the right logger factory depending on the classpath. - */ -@Named -@Singleton -public class LoggerFactoryProvider - implements Provider<LoggerFactory> -{ - - @Inject - @Named( "slf4j" ) - private Provider<LoggerFactory> slf4j; - - public LoggerFactory get() - { - try - { - LoggerFactory factory = slf4j.get(); - if ( factory != null ) - { - return factory; - } - } - catch ( LinkageError e ) - { - // fall through - } - catch ( RuntimeException e ) - { - // fall through - } - return NullLoggerFactory.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java deleted file mode 100644 index 9202c4b..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.layout.RepositoryLayout; -import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory; -import org.eclipse.aether.transfer.NoRepositoryLayoutException; -import org.eclipse.aether.util.ConfigUtils; - -/** - * Provides a Maven-2 repository layout for repositories with content type {@code "default"}. - */ -@Named( "maven2" ) -public final class Maven2RepositoryLayoutFactory - implements RepositoryLayoutFactory -{ - - static final String CONFIG_PROP_SIGNATURE_CHECKSUMS = "aether.checksums.forSignature"; - - private float priority; - - public float getPriority() - { - return priority; - } - - /** - * Sets the priority of this component. - * - * @param priority The priority. - * @return This component for chaining, never {@code null}. - */ - public Maven2RepositoryLayoutFactory setPriority( float priority ) - { - this.priority = priority; - return this; - } - - public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepository repository ) - throws NoRepositoryLayoutException - { - if ( !"default".equals( repository.getContentType() ) ) - { - throw new NoRepositoryLayoutException( repository ); - } - boolean forSignature = ConfigUtils.getBoolean( session, false, CONFIG_PROP_SIGNATURE_CHECKSUMS ); - return forSignature ? Maven2RepositoryLayout.INSTANCE : Maven2RepositoryLayoutEx.INSTANCE; - } - - private static class Maven2RepositoryLayout - implements RepositoryLayout - { - - public static final RepositoryLayout INSTANCE = new Maven2RepositoryLayout(); - - private URI toUri( String path ) - { - try - { - return new URI( null, null, path, null ); - } - catch ( URISyntaxException e ) - { - throw new IllegalStateException( e ); - } - } - - public URI getLocation( Artifact artifact, boolean upload ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '/' ); - - path.append( artifact.getBaseVersion() ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.getClassifier().length() > 0 ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - if ( artifact.getExtension().length() > 0 ) - { - path.append( '.' ).append( artifact.getExtension() ); - } - - return toUri( path.toString() ); - } - - public URI getLocation( Metadata metadata, boolean upload ) - { - StringBuilder path = new StringBuilder( 128 ); - - if ( metadata.getGroupId().length() > 0 ) - { - path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); - - if ( metadata.getArtifactId().length() > 0 ) - { - path.append( metadata.getArtifactId() ).append( '/' ); - - if ( metadata.getVersion().length() > 0 ) - { - path.append( metadata.getVersion() ).append( '/' ); - } - } - } - - path.append( metadata.getType() ); - - return toUri( path.toString() ); - } - - public List<Checksum> getChecksums( Artifact artifact, boolean upload, URI location ) - { - return getChecksums( location ); - } - - public List<Checksum> getChecksums( Metadata metadata, boolean upload, URI location ) - { - return getChecksums( location ); - } - - private List<Checksum> getChecksums( URI location ) - { - return Arrays.asList( Checksum.forLocation( location, "SHA-1" ), Checksum.forLocation( location, "MD5" ) ); - } - - } - - private static class Maven2RepositoryLayoutEx - extends Maven2RepositoryLayout - { - - public static final RepositoryLayout INSTANCE = new Maven2RepositoryLayoutEx(); - - @Override - public List<Checksum> getChecksums( Artifact artifact, boolean upload, URI location ) - { - if ( isSignature( artifact.getExtension() ) ) - { - return Collections.emptyList(); - } - return super.getChecksums( artifact, upload, location ); - } - - private boolean isSignature( String extension ) - { - return extension.endsWith( ".asc" ); - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/NodeStack.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/NodeStack.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/NodeStack.java deleted file mode 100644 index b0e0cd3..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/NodeStack.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.util.Arrays; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.DependencyNode; - -/** - * @see DefaultDependencyCollector - */ -final class NodeStack -{ - - private DependencyNode[] nodes = new DependencyNode[96]; - - private int size; - - public DependencyNode top() - { - if ( size <= 0 ) - { - throw new IllegalStateException( "stack empty" ); - } - return nodes[size - 1]; - } - - public void push( DependencyNode node ) - { - if ( size >= nodes.length ) - { - DependencyNode[] tmp = new DependencyNode[size + 64]; - System.arraycopy( nodes, 0, tmp, 0, nodes.length ); - nodes = tmp; - } - nodes[size++] = node; - } - - public void pop() - { - if ( size <= 0 ) - { - throw new IllegalStateException( "stack empty" ); - } - size--; - } - - public int find( Artifact artifact ) - { - for ( int i = size - 1; i >= 0; i-- ) - { - DependencyNode node = nodes[i]; - - Artifact a = node.getArtifact(); - if ( a == null ) - { - break; - } - - if ( !a.getArtifactId().equals( artifact.getArtifactId() ) ) - { - continue; - } - if ( !a.getGroupId().equals( artifact.getGroupId() ) ) - { - continue; - } - if ( !a.getExtension().equals( artifact.getExtension() ) ) - { - continue; - } - if ( !a.getClassifier().equals( artifact.getClassifier() ) ) - { - continue; - } - /* - * NOTE: While a:1 and a:2 are technically different artifacts, we want to consider the path a:2 -> b:2 -> - * a:1 a cycle in the current context. The artifacts themselves might not form a cycle but their producing - * projects surely do. Furthermore, conflict resolution will always have to consider a:1 a loser (otherwise - * its ancestor a:2 would get pruned and so would a:1) so there is no point in building the sub graph of - * a:1. - */ - - return i; - } - - return -1; - } - - public int size() - { - return size; - } - - public DependencyNode get( int index ) - { - return nodes[index]; - } - - @Override - public String toString() - { - return Arrays.toString( nodes ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ObjectPool.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ObjectPool.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ObjectPool.java deleted file mode 100644 index 2307f7f..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/ObjectPool.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import java.util.Map; -import java.util.WeakHashMap; - -/** - * Pool of immutable object instances, used to avoid excessive memory consumption of (dirty) dependency graph which - * tends to have many duplicate artifacts/dependencies. - */ -class ObjectPool<T> -{ - - private final Map<Object, Reference<T>> objects = new WeakHashMap<Object, Reference<T>>( 256 ); - - public synchronized T intern( T object ) - { - Reference<T> pooledRef = objects.get( object ); - if ( pooledRef != null ) - { - T pooled = pooledRef.get(); - if ( pooled != null ) - { - return pooled; - } - } - - objects.put( object, new WeakReference<T>( object ) ); - return object; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponent.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponent.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponent.java deleted file mode 100644 index fc9ebeb..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponent.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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. - */ - -final class PrioritizedComponent<T> - implements Comparable<PrioritizedComponent<?>> -{ - - private final T component; - - private final Class<?> type; - - private final float priority; - - private final int index; - - public PrioritizedComponent( T component, Class<?> type, float priority, int index ) - { - this.component = component; - this.type = type; - this.priority = priority; - this.index = index; - } - - public T getComponent() - { - return component; - } - - public Class<?> getType() - { - return type; - } - - public float getPriority() - { - return priority; - } - - public boolean isDisabled() - { - return Float.isNaN( priority ); - } - - public int compareTo( PrioritizedComponent<?> o ) - { - int rel = ( isDisabled() ? 1 : 0 ) - ( o.isDisabled() ? 1 : 0 ); - if ( rel == 0 ) - { - rel = Float.compare( o.priority, priority ); - if ( rel == 0 ) - { - rel = index - o.index; - } - } - return rel; - } - - @Override - public String toString() - { - return priority + " (#" + index + "): " + String.valueOf( component ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponents.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponents.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponents.java deleted file mode 100644 index 3ec5613..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/PrioritizedComponents.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.eclipse.aether.ConfigurationProperties; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.util.ConfigUtils; - -/** - * Helps to sort pluggable components by their priority. - */ -final class PrioritizedComponents<T> -{ - - private static final String FACTORY_SUFFIX = "Factory"; - - private final Map<?, ?> configProps; - - private final boolean useInsertionOrder; - - private final List<PrioritizedComponent<T>> components; - - private int firstDisabled; - - public PrioritizedComponents( RepositorySystemSession session ) - { - this( session.getConfigProperties() ); - } - - PrioritizedComponents( Map<?, ?> configurationProperties ) - { - configProps = configurationProperties; - useInsertionOrder = - ConfigUtils.getBoolean( configProps, ConfigurationProperties.DEFAULT_IMPLICIT_PRIORITIES, - ConfigurationProperties.IMPLICIT_PRIORITIES ); - components = new ArrayList<PrioritizedComponent<T>>(); - firstDisabled = 0; - } - - public void add( T component, float priority ) - { - Class<?> type = getImplClass( component ); - int index = components.size(); - priority = useInsertionOrder ? -index : ConfigUtils.getFloat( configProps, priority, getConfigKeys( type ) ); - PrioritizedComponent<T> pc = new PrioritizedComponent<T>( component, type, priority, index ); - - if ( !useInsertionOrder ) - { - index = Collections.binarySearch( components, pc ); - if ( index < 0 ) - { - index = -index - 1; - } - else - { - index++; - } - } - components.add( index, pc ); - - if ( index <= firstDisabled && !pc.isDisabled() ) - { - firstDisabled++; - } - } - - private static Class<?> getImplClass( Object component ) - { - Class<?> type = component.getClass(); - // detect and ignore CGLIB-based proxy classes employed by Guice for AOP (cf. BytecodeGen.newEnhancer) - int idx = type.getName().indexOf( "$$" ); - if ( idx >= 0 ) - { - Class<?> base = type.getSuperclass(); - if ( base != null && idx == base.getName().length() && type.getName().startsWith( base.getName() ) ) - { - type = base; - } - } - return type; - } - - static String[] getConfigKeys( Class<?> type ) - { - List<String> keys = new ArrayList<String>(); - keys.add( ConfigurationProperties.PREFIX_PRIORITY + type.getName() ); - String sn = type.getSimpleName(); - keys.add( ConfigurationProperties.PREFIX_PRIORITY + sn ); - if ( sn.endsWith( FACTORY_SUFFIX ) ) - { - keys.add( ConfigurationProperties.PREFIX_PRIORITY + sn.substring( 0, sn.length() - FACTORY_SUFFIX.length() ) ); - } - return keys.toArray( new String[keys.size()] ); - } - - public boolean isEmpty() - { - return components.isEmpty(); - } - - public List<PrioritizedComponent<T>> getAll() - { - return components; - } - - public List<PrioritizedComponent<T>> getEnabled() - { - return components.subList( 0, firstDisabled ); - } - - public void list( StringBuilder buffer ) - { - for ( int i = 0; i < components.size(); i++ ) - { - if ( i > 0 ) - { - buffer.append( ", " ); - } - PrioritizedComponent<?> component = components.get( i ); - buffer.append( component.getType().getSimpleName() ); - if ( component.isDisabled() ) - { - buffer.append( " (disabled)" ); - } - } - } - - @Override - public String toString() - { - return components.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SafeTransferListener.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SafeTransferListener.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SafeTransferListener.java deleted file mode 100644 index 1ba8a37..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SafeTransferListener.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.transfer.AbstractTransferListener; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferListener; - -class SafeTransferListener - extends AbstractTransferListener -{ - - private final Logger logger; - - private final TransferListener listener; - - public static TransferListener wrap( RepositorySystemSession session, Logger logger ) - { - TransferListener listener = session.getTransferListener(); - if ( listener == null ) - { - return null; - } - return new SafeTransferListener( listener, logger ); - } - - protected SafeTransferListener( RepositorySystemSession session, Logger logger ) - { - this( session.getTransferListener(), logger ); - } - - private SafeTransferListener( TransferListener listener, Logger logger ) - { - this.listener = listener; - this.logger = logger; - } - - private void logError( TransferEvent event, Throwable e ) - { - String msg = "Failed to dispatch transfer event '" + event + "' to " + listener.getClass().getCanonicalName(); - logger.debug( msg, e ); - } - - @Override - public void transferInitiated( TransferEvent event ) - throws TransferCancelledException - { - if ( listener != null ) - { - try - { - listener.transferInitiated( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - - @Override - public void transferStarted( TransferEvent event ) - throws TransferCancelledException - { - if ( listener != null ) - { - try - { - listener.transferStarted( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - - @Override - public void transferProgressed( TransferEvent event ) - throws TransferCancelledException - { - if ( listener != null ) - { - try - { - listener.transferProgressed( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - - @Override - public void transferCorrupted( TransferEvent event ) - throws TransferCancelledException - { - if ( listener != null ) - { - try - { - listener.transferCorrupted( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - if ( listener != null ) - { - try - { - listener.transferSucceeded( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - - @Override - public void transferFailed( TransferEvent event ) - { - if ( listener != null ) - { - try - { - listener.transferFailed( event ); - } - catch ( RuntimeException e ) - { - logError( event, e ); - } - catch ( LinkageError e ) - { - logError( event, e ); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleDigest.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleDigest.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleDigest.java deleted file mode 100644 index 9b51e98..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleDigest.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * A simple digester for strings. - */ -class SimpleDigest -{ - - private MessageDigest digest; - - private long hash; - - public SimpleDigest() - { - try - { - digest = MessageDigest.getInstance( "SHA-1" ); - } - catch ( NoSuchAlgorithmException e ) - { - try - { - digest = MessageDigest.getInstance( "MD5" ); - } - catch ( NoSuchAlgorithmException ne ) - { - digest = null; - hash = 13; - } - } - } - - public void update( String data ) - { - if ( data == null || data.length() <= 0 ) - { - return; - } - if ( digest != null ) - { - try - { - digest.update( data.getBytes( "UTF-8" ) ); - } - catch ( UnsupportedEncodingException e ) - { - // broken JVM - } - } - else - { - hash = hash * 31 + data.hashCode(); - } - } - - public String digest() - { - if ( digest != null ) - { - StringBuilder buffer = new StringBuilder( 64 ); - - byte[] bytes = digest.digest(); - for ( byte aByte : bytes ) - { - int b = aByte & 0xFF; - - if ( b < 0x10 ) - { - buffer.append( '0' ); - } - - buffer.append( Integer.toHexString( b ) ); - } - - return buffer.toString(); - } - else - { - return Long.toHexString( hash ); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java deleted file mode 100644 index 97c7bba..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.io.File; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.LocalArtifactRegistration; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.LocalMetadataRegistration; -import org.eclipse.aether.repository.LocalMetadataRequest; -import org.eclipse.aether.repository.LocalMetadataResult; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.log.Logger; - -/** - * A local repository manager that realizes the classical Maven 2.0 local repository. - */ -class SimpleLocalRepositoryManager - implements LocalRepositoryManager -{ - - private final LocalRepository repository; - - public SimpleLocalRepositoryManager( File basedir ) - { - this( basedir, "simple" ); - } - - public SimpleLocalRepositoryManager( String basedir ) - { - this( ( basedir != null ) ? new File( basedir ) : null, "simple" ); - } - - SimpleLocalRepositoryManager( File basedir, String type ) - { - if ( basedir == null ) - { - throw new IllegalArgumentException( "base directory has not been specified" ); - } - repository = new LocalRepository( basedir.getAbsoluteFile(), type ); - } - - public SimpleLocalRepositoryManager setLogger( Logger logger ) - { - return this; - } - - public LocalRepository getRepository() - { - return repository; - } - - String getPathForArtifact( Artifact artifact, boolean local ) - { - StringBuilder path = new StringBuilder( 128 ); - - path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '/' ); - - path.append( artifact.getBaseVersion() ).append( '/' ); - - path.append( artifact.getArtifactId() ).append( '-' ); - if ( local ) - { - path.append( artifact.getBaseVersion() ); - } - else - { - path.append( artifact.getVersion() ); - } - - if ( artifact.getClassifier().length() > 0 ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - if ( artifact.getExtension().length() > 0 ) - { - path.append( '.' ).append( artifact.getExtension() ); - } - - return path.toString(); - } - - public String getPathForLocalArtifact( Artifact artifact ) - { - return getPathForArtifact( artifact, true ); - } - - public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) - { - return getPathForArtifact( artifact, false ); - } - - public String getPathForLocalMetadata( Metadata metadata ) - { - return getPath( metadata, "local" ); - } - - public String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ) - { - return getPath( metadata, getRepositoryKey( repository, context ) ); - } - - String getRepositoryKey( RemoteRepository repository, String context ) - { - String key; - - if ( repository.isRepositoryManager() ) - { - // repository serves dynamic contents, take request parameters into account for key - - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( repository.getId() ); - - buffer.append( '-' ); - - SortedSet<String> subKeys = new TreeSet<String>(); - for ( RemoteRepository mirroredRepo : repository.getMirroredRepositories() ) - { - subKeys.add( mirroredRepo.getId() ); - } - - SimpleDigest digest = new SimpleDigest(); - digest.update( context ); - for ( String subKey : subKeys ) - { - digest.update( subKey ); - } - buffer.append( digest.digest() ); - - key = buffer.toString(); - } - else - { - // repository serves static contents, its id is sufficient as key - - key = repository.getId(); - } - - return key; - } - - private String getPath( Metadata metadata, String repositoryKey ) - { - StringBuilder path = new StringBuilder( 128 ); - - if ( metadata.getGroupId().length() > 0 ) - { - path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); - - if ( metadata.getArtifactId().length() > 0 ) - { - path.append( metadata.getArtifactId() ).append( '/' ); - - if ( metadata.getVersion().length() > 0 ) - { - path.append( metadata.getVersion() ).append( '/' ); - } - } - } - - path.append( insertRepositoryKey( metadata.getType(), repositoryKey ) ); - - return path.toString(); - } - - private String insertRepositoryKey( String filename, String repositoryKey ) - { - String result; - int idx = filename.indexOf( '.' ); - if ( idx < 0 ) - { - result = filename + '-' + repositoryKey; - } - else - { - result = filename.substring( 0, idx ) + '-' + repositoryKey + filename.substring( idx ); - } - return result; - } - - public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ) - { - String path = getPathForArtifact( request.getArtifact(), false ); - File file = new File( getRepository().getBasedir(), path ); - - LocalArtifactResult result = new LocalArtifactResult( request ); - if ( file.isFile() ) - { - result.setFile( file ); - result.setAvailable( true ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalArtifactRegistration request ) - { - // noop - } - - @Override - public String toString() - { - return String.valueOf( getRepository() ); - } - - public LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ) - { - LocalMetadataResult result = new LocalMetadataResult( request ); - - String path; - - Metadata metadata = request.getMetadata(); - String context = request.getContext(); - RemoteRepository remote = request.getRepository(); - - if ( remote != null ) - { - path = getPathForRemoteMetadata( metadata, remote, context ); - } - else - { - path = getPathForLocalMetadata( metadata ); - } - - File file = new File( getRepository().getBasedir(), path ); - if ( file.isFile() ) - { - result.setFile( file ); - } - - return result; - } - - public void add( RepositorySystemSession session, LocalMetadataRegistration request ) - { - // noop - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java deleted file mode 100644 index 3c2cf6d..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManagerFactory.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.NoLocalRepositoryManagerException; -import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; - -/** - * Creates local repository managers for repository type {@code "simple"}. - */ -@Named( "simple" ) -public class SimpleLocalRepositoryManagerFactory - implements LocalRepositoryManagerFactory, Service -{ - - private Logger logger = NullLoggerFactory.LOGGER; - - private float priority; - - public SimpleLocalRepositoryManagerFactory() - { - // enable no-arg constructor - } - - @Inject - SimpleLocalRepositoryManagerFactory( LoggerFactory loggerFactory ) - { - setLoggerFactory( loggerFactory ); - } - - public LocalRepositoryManager newInstance( RepositorySystemSession session, LocalRepository repository ) - throws NoLocalRepositoryManagerException - { - if ( "".equals( repository.getContentType() ) || "simple".equals( repository.getContentType() ) ) - { - return new SimpleLocalRepositoryManager( repository.getBasedir() ).setLogger( logger ); - } - else - { - throw new NoLocalRepositoryManagerException( repository ); - } - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( LoggerFactory.class ) ); - } - - public SimpleLocalRepositoryManagerFactory setLoggerFactory( LoggerFactory loggerFactory ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, SimpleLocalRepositoryManager.class ); - return this; - } - - public float getPriority() - { - return priority; - } - - /** - * Sets the priority of this component. - * - * @param priority The priority. - * @return This component for chaining, never {@code null}. - */ - public SimpleLocalRepositoryManagerFactory setPriority( float priority ) - { - this.priority = priority; - return this; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java deleted file mode 100644 index 7b33f6e..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java +++ /dev/null @@ -1,240 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; -import java.nio.channels.OverlappingFileLockException; -import java.util.Map; -import java.util.Properties; - -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.NullLoggerFactory; - -/** - * Manages potentially concurrent accesses to a properties file. - */ -class TrackingFileManager -{ - - private Logger logger = NullLoggerFactory.LOGGER; - - public TrackingFileManager setLogger( Logger logger ) - { - this.logger = ( logger != null ) ? logger : NullLoggerFactory.LOGGER; - return this; - } - - public Properties read( File file ) - { - synchronized ( getLock( file ) ) - { - FileLock lock = null; - FileInputStream stream = null; - try - { - if ( !file.exists() ) - { - return null; - } - - stream = new FileInputStream( file ); - - lock = lock( stream.getChannel(), Math.max( 1, file.length() ), true ); - - Properties props = new Properties(); - props.load( stream ); - - return props; - } - catch ( IOException e ) - { - logger.warn( "Failed to read tracking file " + file, e ); - } - finally - { - release( lock, file ); - close( stream, file ); - } - } - - return null; - } - - public Properties update( File file, Map<String, String> updates ) - { - Properties props = new Properties(); - - synchronized ( getLock( file ) ) - { - File directory = file.getParentFile(); - if ( !directory.mkdirs() && !directory.exists() ) - { - logger.warn( "Failed to create parent directories for tracking file " + file ); - return props; - } - - RandomAccessFile raf = null; - FileLock lock = null; - try - { - raf = new RandomAccessFile( file, "rw" ); - lock = lock( raf.getChannel(), Math.max( 1, raf.length() ), false ); - - if ( file.canRead() ) - { - byte[] buffer = new byte[(int) raf.length()]; - - raf.readFully( buffer ); - - ByteArrayInputStream stream = new ByteArrayInputStream( buffer ); - - props.load( stream ); - } - - for ( Map.Entry<String, String> update : updates.entrySet() ) - { - if ( update.getValue() == null ) - { - props.remove( update.getKey() ); - } - else - { - props.setProperty( update.getKey(), update.getValue() ); - } - } - - ByteArrayOutputStream stream = new ByteArrayOutputStream( 1024 * 2 ); - - logger.debug( "Writing tracking file " + file ); - props.store( stream, "NOTE: This is an Aether internal implementation file" - + ", its format can be changed without prior notice." ); - - raf.seek( 0 ); - raf.write( stream.toByteArray() ); - raf.setLength( raf.getFilePointer() ); - } - catch ( IOException e ) - { - logger.warn( "Failed to write tracking file " + file, e ); - } - finally - { - release( lock, file ); - close( raf, file ); - } - } - - return props; - } - - private void release( FileLock lock, File file ) - { - if ( lock != null ) - { - try - { - lock.release(); - } - catch ( IOException e ) - { - logger.warn( "Error releasing lock for tracking file " + file, e ); - } - } - } - - private void close( Closeable closeable, File file ) - { - if ( closeable != null ) - { - try - { - closeable.close(); - } - catch ( IOException e ) - { - logger.warn( "Error closing tracking file " + file, e ); - } - } - } - - private Object getLock( File file ) - { - /* - * NOTE: Locks held by one JVM must not overlap and using the canonical path is our best bet, still another - * piece of code might have locked the same file (unlikely though) or the canonical path fails to capture file - * identity sufficiently as is the case with Java 1.6 and symlinks on Windows. - */ - try - { - return file.getCanonicalPath().intern(); - } - catch ( IOException e ) - { - logger.warn( "Failed to canonicalize path " + file + ": " + e.getMessage() ); - return file.getAbsolutePath().intern(); - } - } - - private FileLock lock( FileChannel channel, long size, boolean shared ) - throws IOException - { - FileLock lock = null; - - for ( int attempts = 8; attempts >= 0; attempts-- ) - { - try - { - lock = channel.lock( 0, size, shared ); - break; - } - catch ( OverlappingFileLockException e ) - { - if ( attempts <= 0 ) - { - throw (IOException) new IOException().initCause( e ); - } - try - { - Thread.sleep( 50 ); - } - catch ( InterruptedException e1 ) - { - Thread.currentThread().interrupt(); - } - } - } - - if ( lock == null ) - { - throw new IOException( "Could not lock file" ); - } - - return lock; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Utils.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Utils.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Utils.java deleted file mode 100644 index deb830d..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/Utils.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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 java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.impl.MetadataGenerator; -import org.eclipse.aether.impl.MetadataGeneratorFactory; -import org.eclipse.aether.impl.OfflineController; -import org.eclipse.aether.metadata.Metadata; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ResolutionErrorPolicy; -import org.eclipse.aether.resolution.ResolutionErrorPolicyRequest; -import org.eclipse.aether.transfer.RepositoryOfflineException; - -/** - * Internal utility methods. - */ -final class Utils -{ - - public static PrioritizedComponents<MetadataGeneratorFactory> sortMetadataGeneratorFactories( RepositorySystemSession session, - Collection<? extends MetadataGeneratorFactory> factories ) - { - PrioritizedComponents<MetadataGeneratorFactory> result = - new PrioritizedComponents<MetadataGeneratorFactory>( session ); - for ( MetadataGeneratorFactory factory : factories ) - { - result.add( factory, factory.getPriority() ); - } - return result; - } - - public static List<Metadata> prepareMetadata( List<? extends MetadataGenerator> generators, - List<? extends Artifact> artifacts ) - { - List<Metadata> metadatas = new ArrayList<Metadata>(); - - for ( MetadataGenerator generator : generators ) - { - metadatas.addAll( generator.prepare( artifacts ) ); - } - - return metadatas; - } - - public static List<Metadata> finishMetadata( List<? extends MetadataGenerator> generators, - List<? extends Artifact> artifacts ) - { - List<Metadata> metadatas = new ArrayList<Metadata>(); - - for ( MetadataGenerator generator : generators ) - { - metadatas.addAll( generator.finish( artifacts ) ); - } - - return metadatas; - } - - public static <T> List<T> combine( Collection<? extends T> first, Collection<? extends T> second ) - { - List<T> result = new ArrayList<T>( first.size() + second.size() ); - result.addAll( first ); - result.addAll( second ); - return result; - } - - public static int getPolicy( RepositorySystemSession session, Artifact artifact, RemoteRepository repository ) - { - ResolutionErrorPolicy rep = session.getResolutionErrorPolicy(); - if ( rep == null ) - { - return ResolutionErrorPolicy.CACHE_DISABLED; - } - return rep.getArtifactPolicy( session, new ResolutionErrorPolicyRequest<Artifact>( artifact, repository ) ); - } - - public static int getPolicy( RepositorySystemSession session, Metadata metadata, RemoteRepository repository ) - { - ResolutionErrorPolicy rep = session.getResolutionErrorPolicy(); - if ( rep == null ) - { - return ResolutionErrorPolicy.CACHE_DISABLED; - } - return rep.getMetadataPolicy( session, new ResolutionErrorPolicyRequest<Metadata>( metadata, repository ) ); - } - - public static void appendClassLoader( StringBuilder buffer, Object component ) - { - ClassLoader loader = component.getClass().getClassLoader(); - if ( loader != null && !loader.equals( Utils.class.getClassLoader() ) ) - { - buffer.append( " from " ).append( loader ); - } - } - - public static void checkOffline( RepositorySystemSession session, OfflineController offlineController, - RemoteRepository repository ) - throws RepositoryOfflineException - { - if ( session.isOffline() ) - { - offlineController.checkOffline( session, repository ); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-impl/src/main/java/org/eclipse/aether/internal/impl/WarnChecksumPolicy.java ---------------------------------------------------------------------- diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/WarnChecksumPolicy.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/WarnChecksumPolicy.java deleted file mode 100644 index b5e72ec..0000000 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/WarnChecksumPolicy.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.aether.internal.impl; - -/* - * 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.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.transfer.ChecksumFailureException; -import org.eclipse.aether.transfer.TransferResource; - -/** - * Implements {@link org.eclipse.aether.repository.RepositoryPolicy#CHECKSUM_POLICY_WARN}. - */ -final class WarnChecksumPolicy - extends AbstractChecksumPolicy -{ - - public WarnChecksumPolicy( LoggerFactory loggerFactory, TransferResource resource ) - { - super( loggerFactory, resource ); - } - - public boolean onTransferChecksumFailure( ChecksumFailureException exception ) - { - String msg = - "Could not validate integrity of download from " + resource.getRepositoryUrl() + resource.getResourceName(); - if ( logger.isDebugEnabled() ) - { - logger.warn( msg, exception ); - } - else - { - logger.warn( msg + ": " + exception.getMessage() ); - } - return true; - } - -}