From: Olivier Lamy Date: Fri, 7 Sep 2012 08:32:10 +0000 (+0000) Subject: simplify some log.debug as slf4j now supports varargs X-Git-Tag: archiva-1.4-M3~282 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fb741717d1a846092ecdac2ec20c6ce694dc0ab3;p=archiva.git simplify some log.debug as slf4j now supports varargs git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1381934 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java index 19fad186e..faa2e171f 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java @@ -235,12 +235,12 @@ public abstract class AbstractNexusRepositorySearch public void artifactError( ArtifactContext ac, Exception e ) { - log.debug( "artifactError " + ac.getArtifact().getPath(), e ); + log.debug( "artifactError {}", ac.getArtifact().getPath(), e ); } public void artifactDiscovered( ArtifactContext ac ) { - log.debug( "artifactDiscovered {}:", ac.getArtifact().getPath(), ac.getArtifactInfo() ); + log.debug( "artifactDiscovered {}:{}", ac.getArtifact().getPath(), ac.getArtifactInfo() ); } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 187391401..8fd1f0239 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -63,7 +63,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; @@ -80,7 +79,7 @@ import java.util.zip.ZipEntry; * @author Olivier Lamy * @since 1.4-M3 */ -@Service( "browseService#rest" ) +@Service ( "browseService#rest" ) public class DefaultBrowseService extends AbstractRestService implements BrowseService @@ -774,8 +773,7 @@ public class DefaultBrowseService throw new ArchivaRestServiceException( e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } - log.debug( "artifact: {}:{}:{}:{}:{} not found", - Arrays.asList( groupId, artifactId, version, classifier, type ).toArray( new String[5] ) ); + log.debug( "artifact: {}:{}:{}:{}:{} not found", groupId, artifactId, version, classifier, type ); // 404 ? return new ArtifactContent(); } diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java index 1d6d3fb96..33ca9723d 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java @@ -19,7 +19,6 @@ package org.apache.archiva.security; * under the License. */ -import com.google.common.collect.Lists; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; @@ -44,7 +43,7 @@ import java.util.List; /** * DefaultUserRepositories */ -@Service("userRepositories") +@Service ( "userRepositories" ) public class DefaultUserRepositories implements UserRepositories { @@ -120,11 +119,10 @@ public class DefaultUserRepositories catch ( AuthorizationException e ) { // swallow. - if ( log.isDebugEnabled() ) - { - log.debug( "Not authorizing '{}' for repository '{}': {}", - Lists.newArrayList( principal, repo.getId(), e.getMessage() ) ); - } + + log.debug( "Not authorizing '{}' for repository '{}': {}", principal, repo.getId(), + e.getMessage() ); + } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 0b3c3ea12..a4a56fafc 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -38,6 +38,16 @@ import org.apache.archiva.model.ArchivaRepositoryMetadata; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.policies.ProxyDownloadException; import org.apache.archiva.proxy.RepositoryProxyConnectors; +import org.apache.archiva.redback.authentication.AuthenticationException; +import org.apache.archiva.redback.authentication.AuthenticationResult; +import org.apache.archiva.redback.authorization.AuthorizationException; +import org.apache.archiva.redback.authorization.UnauthorizedException; +import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; +import org.apache.archiva.redback.policy.AccountLockedException; +import org.apache.archiva.redback.policy.MustChangePasswordException; +import org.apache.archiva.redback.system.SecuritySession; +import org.apache.archiva.redback.users.User; +import org.apache.archiva.redback.users.UserManager; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryException; @@ -76,17 +86,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.digest.ChecksumFile; import org.codehaus.plexus.digest.Digester; import org.codehaus.plexus.digest.DigesterException; -import org.apache.archiva.redback.authentication.AuthenticationException; -import org.apache.archiva.redback.authentication.AuthenticationResult; -import org.apache.archiva.redback.authorization.AuthorizationException; -import org.apache.archiva.redback.authorization.UnauthorizedException; -import org.apache.archiva.redback.policy.AccountLockedException; -import org.apache.archiva.redback.policy.MustChangePasswordException; -import org.apache.archiva.redback.system.SecuritySession; -import org.apache.archiva.redback.users.User; -import org.apache.archiva.redback.users.UserManager; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; @@ -112,7 +112,7 @@ import java.util.Set; /** * */ -@Service( "davResourceFactory#archiva" ) +@Service ( "davResourceFactory#archiva" ) public class ArchivaDavResourceFactory implements DavResourceFactory, Auditable { @@ -145,7 +145,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named( value = "repositoryProxyConnectors#default" ) + @Named ( value = "repositoryProxyConnectors#default" ) private RepositoryProxyConnectors connectors; /** @@ -175,7 +175,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named( value = "httpAuthenticator#basic" ) + @Named ( value = "httpAuthenticator#basic" ) private HttpAuthenticator httpAuth; @Inject @@ -208,7 +208,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named( value = "archivaTaskScheduler#repository" ) + @Named ( value = "archivaTaskScheduler#repository" ) private RepositoryArchivaTaskScheduler scheduler; private ApplicationContext applicationContext; @@ -559,12 +559,9 @@ public class ArchivaDavResourceFactory String event = ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE ) + PROXIED_SUFFIX; - if ( log.isDebugEnabled() ) - { - log.debug( "Proxied artifact '" + resourceFile.getName() + "' in repository '" - + managedRepository.getId() + "' (current user '" + activePrincipal - + "')" ); - } + log.debug( "Proxied artifact '{}' in repository '{}' (current user '{}')", + resourceFile.getName(), managedRepository.getId(), activePrincipal ); + triggerAuditEvent( request.getRemoteAddr(), archivaLocator.getRepositoryId(), logicalResource.getPath(), event, activePrincipal ); } @@ -696,7 +693,7 @@ public class ArchivaDavResourceFactory return ( proxiedFile != null ); } - + // Not any of the above? Then it's gotta be an artifact reference. try { @@ -710,11 +707,10 @@ public class ArchivaDavResourceFactory File proxiedFile = connectors.fetchFromProxies( managedRepository, artifact ); resource.setPath( managedRepository.toPath( artifact ) ); - if ( log.isDebugEnabled() ) - { - log.debug( "Proxied artifact '" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" - + artifact.getVersion() + "'" ); - } + + log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(), + artifact.getVersion() ); + return ( proxiedFile != null ); } } @@ -772,7 +768,7 @@ public class ArchivaDavResourceFactory Model model = null; try { - model = mavenXpp3Reader.read(reader); + model = mavenXpp3Reader.read( reader ); } finally { @@ -1051,11 +1047,10 @@ public class ArchivaDavResourceFactory catch ( DavException e ) { // TODO: review exception handling - if ( log.isDebugEnabled() ) - { - log.debug( "Skipping repository '" + managedRepository + "' for user '" - + activePrincipal + "': " + e.getMessage() ); - } + + log.debug( "Skipping repository '{}' for user '{}': {}", managedRepository, + activePrincipal, e.getMessage() ); + } } @@ -1075,11 +1070,10 @@ public class ArchivaDavResourceFactory catch ( UnauthorizedException e ) { // TODO: review exception handling - if ( log.isDebugEnabled() ) - { - log.debug( "Skipping repository '" + managedRepository + "' for user '" - + activePrincipal + "': " + e.getMessage() ); - } + + log.debug( "Skipping repository '{}' for user '{}': {}", managedRepository, + activePrincipal, e.getMessage() ); + } } } @@ -1259,11 +1253,9 @@ public class ArchivaDavResourceFactory catch ( UnauthorizedException e ) { // TODO: review exception handling - if ( log.isDebugEnabled() ) - { - log.debug( "Skipping repository '" + repository + "' for user '" + activePrincipal + "': " - + e.getMessage() ); - } + + log.debug( "Skipping repository '{}' for user '{}': {}", repository, activePrincipal, + e.getMessage() ); } } IndexingContext indexingContext = indexMerger.buildMergedIndex( authzRepos, true ); diff --git a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java index 40ffbff22..220b41202 100644 --- a/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java +++ b/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java @@ -22,22 +22,22 @@ package org.apache.archiva.reports.consumers; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.repository.MetadataRepository; -import org.apache.archiva.metadata.repository.MetadataRepositoryException; -import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; -import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; -import org.apache.archiva.reports.RepositoryProblemFacet; -import org.apache.commons.collections.CollectionUtils; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ConfigurationNames; import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.repository.MetadataRepository; +import org.apache.archiva.metadata.repository.MetadataRepositoryException; +import org.apache.archiva.metadata.repository.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.redback.components.registry.Registry; import org.apache.archiva.redback.components.registry.RegistryListener; +import org.apache.archiva.reports.RepositoryProblemFacet; +import org.apache.commons.collections.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; @@ -57,11 +57,9 @@ import java.util.List; * Search the artifact repository of known SHA1 Checksums for potential duplicate artifacts. *

* TODO: no need for this to be a scanner - we can just query the database / content repository to get a full list - * - * */ -@Service( "knownRepositoryContentConsumer#duplicate-artifacts" ) -@Scope( "prototype" ) +@Service ( "knownRepositoryContentConsumer#duplicate-artifacts" ) +@Scope ( "prototype" ) public class DuplicateArtifactsConsumer extends AbstractMonitoredConsumer implements KnownRepositoryContentConsumer, RegistryListener @@ -92,7 +90,6 @@ public class DuplicateArtifactsConsumer /** * FIXME: can be of other types - * */ @Inject private RepositorySessionFactory repositorySessionFactory; @@ -105,10 +102,9 @@ public class DuplicateArtifactsConsumer /** * FIXME: needs to be selected based on the repository in question - * */ @Inject - @Named( value = "repositoryPathTranslator#maven2" ) + @Named ( value = "repositoryPathTranslator#maven2" ) private RepositoryPathTranslator pathTranslator; private RepositorySession repositorySession; @@ -201,16 +197,15 @@ public class DuplicateArtifactsConsumer for ( ArtifactMetadata dupArtifact : results ) { String id = path.substring( path.lastIndexOf( "/" ) + 1 ); - if ( dupArtifact.getId().equals( id ) - && dupArtifact.getNamespace().equals( originalArtifact.getNamespace() ) - && dupArtifact.getProject().equals( originalArtifact.getProject() ) - && dupArtifact.getVersion().equals( originalArtifact.getVersion() ) ) + if ( dupArtifact.getId().equals( id ) && dupArtifact.getNamespace().equals( + originalArtifact.getNamespace() ) && dupArtifact.getProject().equals( + originalArtifact.getProject() ) && dupArtifact.getVersion().equals( + originalArtifact.getVersion() ) ) { // Skip reference to itself. - if ( log.isDebugEnabled() ) - { - log.debug( "Not counting duplicate for artifact " + dupArtifact + " for path " + path ); - } + + log.debug( "Not counting duplicate for artifact {} for path {}", dupArtifact, path ); + continue; }