diff options
author | Olivier Lamy <olamy@apache.org> | 2011-09-16 07:16:06 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-09-16 07:16:06 +0000 |
commit | 259220f86755bf66cd99916839ef751580ab177f (patch) | |
tree | cd83060cfb004c17cb65caa97f4487884d5e3819 | |
parent | 5ff9dab6350f682942d7f6621a70ff36c208f514 (diff) | |
download | archiva-259220f86755bf66cd99916839ef751580ab177f.tar.gz archiva-259220f86755bf66cd99916839ef751580ab177f.zip |
code formatting : NO CODE CHANGE
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171407 13f79535-47bb-0310-9956-ffa450edef68
14 files changed, 201 insertions, 201 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java index a4c38e627..41d0f32f3 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationListener.java @@ -20,7 +20,7 @@ package org.apache.maven.archiva.configuration; */ /** - * ConfigurationListener + * ConfigurationListener * * @version $Id$ */ @@ -29,5 +29,5 @@ public interface ConfigurationListener /** * Generic event point to notify components that something has happend in the configuration. */ - public void configurationEvent(ConfigurationEvent event); + public void configurationEvent( ConfigurationEvent event ); } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java index 044563524..06c5ce97a 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java @@ -59,13 +59,13 @@ import org.joda.time.format.ISODateTimeFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import javax.servlet.http.HttpServletResponse; /** */ @@ -265,8 +265,8 @@ public class ArchivaDavResource { parentPath = "/"; } - DavResourceLocator parentloc = locator.getFactory().createResourceLocator( locator.getPrefix(), - parentPath ); + DavResourceLocator parentloc = + locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath ); try { parent = factory.createResource( parentloc, session ); @@ -308,8 +308,7 @@ public class ArchivaDavResource // length of -1 is given for a chunked request or unknown length, in which case we accept what was uploaded if ( expectedContentLength >= 0 && expectedContentLength != actualContentLength ) { - String msg = - "Content Header length was " + expectedContentLength + " but was " + actualContentLength; + String msg = "Content Header length was " + expectedContentLength + " but was " + actualContentLength; log.debug( "Upload failed: {}", msg ); FileUtils.deleteQuietly( localFile ); @@ -319,8 +318,8 @@ public class ArchivaDavResource queueRepositoryTask( localFile ); log.debug( - "File '" + resource.getDisplayName() + ( exists ? "' modified " : "' created " ) + "(current user '" + - this.principal + "')" ); + "File '" + resource.getDisplayName() + ( exists ? "' modified " : "' created " ) + "(current user '" + + this.principal + "')" ); triggerAuditEvent( resource, exists ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE ); } @@ -334,8 +333,8 @@ public class ArchivaDavResource } else { - String msg = "Could not write member " + resource.getResourcePath() + " at " + getResourcePath() + - " as this is not a DAV collection"; + String msg = "Could not write member " + resource.getResourcePath() + " at " + getResourcePath() + + " as this is not a DAV collection"; log.debug( msg ); throw new DavException( HttpServletResponse.SC_BAD_REQUEST, msg ); } @@ -353,8 +352,8 @@ public class ArchivaDavResource if ( !item.startsWith( HIDDEN_PATH_PREFIX ) ) { String path = locator.getResourcePath() + '/' + item; - DavResourceLocator resourceLocator = locator.getFactory().createResourceLocator( - locator.getPrefix(), path ); + DavResourceLocator resourceLocator = + locator.getFactory().createResourceLocator( locator.getPrefix(), path ); DavResource resource = factory.createResource( resourceLocator, session ); if ( resource != null ) @@ -400,8 +399,8 @@ public class ArchivaDavResource triggerAuditEvent( member, AuditEvent.REMOVE_FILE ); } - log.debug( ( resource.isDirectory() ? "Directory '" : "File '" ) + member.getDisplayName() + - "' removed (current user '" + this.principal + "')" ); + log.debug( ( resource.isDirectory() ? "Directory '" : "File '" ) + member.getDisplayName() + + "' removed (current user '" + this.principal + "')" ); } catch ( IOException e ) { @@ -453,8 +452,8 @@ public class ArchivaDavResource triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.MOVE_FILE ); } - log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' moved to '" + - destination + "' (current user '" + this.principal + "')" ); + log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' moved to '" + + destination + "' (current user '" + this.principal + "')" ); } catch ( IOException e ) { @@ -490,8 +489,8 @@ public class ArchivaDavResource triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE ); } - log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' copied to '" + - destination + "' (current user '" + this.principal + "')" ); + log.debug( ( isCollection() ? "Directory '" : "File '" ) + getLocalResource().getName() + "' copied to '" + + destination + "' (current user '" + this.principal + "')" ); } catch ( IOException e ) { @@ -522,7 +521,7 @@ public class ArchivaDavResource public ActiveLock[] getLocks() { ActiveLock writeLock = getLock( Type.WRITE, Scope.EXCLUSIVE ); - return ( writeLock != null ) ? new ActiveLock[]{writeLock} : new ActiveLock[0]; + return ( writeLock != null ) ? new ActiveLock[]{ writeLock } : new ActiveLock[0]; } public ActiveLock lock( LockInfo lockInfo ) @@ -680,9 +679,8 @@ public class ArchivaDavResource } catch ( TaskQueueException e ) { - log.error( - "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName() + - "']." ); + log.error( "Unable to queue repository task to execute consumers on resource file ['" + localFile.getName() + + "']." ); } } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index 18b3a23ca..8d8082aad 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -25,6 +25,7 @@ import org.apache.archiva.audit.Auditable; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.security.ServletAuthenticator; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.jackrabbit.webdav.DavException; @@ -56,7 +57,6 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataMerge; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; -import org.apache.archiva.security.ServletAuthenticator; import org.apache.maven.archiva.webdav.util.MimeTypes; import org.apache.maven.archiva.webdav.util.RepositoryPathUtil; import org.apache.maven.archiva.webdav.util.WebdavMethodUtil; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java index 30c5335f7..93c97c0e8 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceLocator.java @@ -19,9 +19,9 @@ package org.apache.maven.archiva.webdav; * under the License. */ -import org.apache.jackrabbit.webdav.DavResourceLocator; -import org.apache.jackrabbit.webdav.DavLocatorFactory; import org.apache.jackrabbit.util.Text; +import org.apache.jackrabbit.webdav.DavLocatorFactory; +import org.apache.jackrabbit.webdav.DavResourceLocator; /** */ @@ -37,7 +37,7 @@ public class ArchivaDavResourceLocator private final String repositoryId; private final DavLocatorFactory davLocatorFactory; - + // retains the trailing '/' at the end of the path, which is used to determine if it is a // virtual repo browse request private final String origResourcePath; @@ -48,10 +48,10 @@ public class ArchivaDavResourceLocator this.prefix = prefix; this.repositoryId = repositoryId; this.davLocatorFactory = davLocatorFactory; - + String path = resourcePath; - - if (!resourcePath.startsWith("/")) + + if ( !resourcePath.startsWith( "/" ) ) { path = "/" + resourcePath; } @@ -66,15 +66,15 @@ public class ArchivaDavResourceLocator } href = hrefPrefix + escapedPath; - + this.origResourcePath = path; - + //Remove trailing slashes otherwise Text.getRelativeParent fails if ( resourcePath.endsWith( "/" ) && resourcePath.length() > 1 ) { path = resourcePath.substring( 0, resourcePath.length() - 1 ); } - + this.resourcePath = path; } @@ -116,7 +116,7 @@ public class ArchivaDavResourceLocator public String getHref( boolean isCollection ) { // avoid doubled trailing '/' for the root item - String suffix = ( isCollection && !isRootLocation() && !href.endsWith("/") ) ? "/" : ""; + String suffix = ( isCollection && !isRootLocation() && !href.endsWith( "/" ) ) ? "/" : ""; return href + suffix; } @@ -137,7 +137,7 @@ public class ArchivaDavResourceLocator /** * Computes the hash code from the href, which is built using the final fields prefix and resourcePath. - * + * * @return the hash code */ public int hashCode() @@ -148,7 +148,7 @@ public class ArchivaDavResourceLocator /** * Equality of path is achieved if the specified object is a <code>DavResourceLocator</code> object with the same * hash code. - * + * * @param obj the object to compare to * @return <code>true</code> if the 2 objects are equal; <code>false</code> otherwise */ diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSession.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSession.java index 0e85a3eea..ba82736a1 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSession.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSession.java @@ -19,35 +19,37 @@ package org.apache.maven.archiva.webdav; * under the License. */ -import java.util.HashSet; import org.apache.jackrabbit.webdav.DavSession; -public class ArchivaDavSession implements DavSession +import java.util.HashSet; + +public class ArchivaDavSession + implements DavSession { private final HashSet<String> lockTokens = new HashSet<String>(); - public void addLockToken(String token) + public void addLockToken( String token ) { - lockTokens.add(token); + lockTokens.add( token ); } - public String[] getLockTokens() + public String[] getLockTokens() { - return (String[]) lockTokens.toArray(new String[lockTokens.size()]); + return (String[]) lockTokens.toArray( new String[lockTokens.size()] ); } - public void removeLockToken(String token) + public void removeLockToken( String token ) { - lockTokens.remove(token); + lockTokens.remove( token ); } - public void removeReference(Object reference) + public void removeReference( Object reference ) { - throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException( "Not supported yet." ); } - public void addReference(Object reference) + public void addReference( Object reference ) { - throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException( "Not supported yet." ); } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java index 01d3fe91c..9872a2bd7 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java @@ -19,11 +19,11 @@ package org.apache.maven.archiva.webdav; * under the License. */ +import org.apache.archiva.security.ServletAuthenticator; import org.apache.jackrabbit.webdav.DavException; import org.apache.jackrabbit.webdav.DavServletRequest; import org.apache.jackrabbit.webdav.DavSessionProvider; import org.apache.jackrabbit.webdav.WebdavRequest; -import org.apache.archiva.security.ServletAuthenticator; import org.apache.maven.archiva.webdav.util.RepositoryPathUtil; import org.apache.maven.archiva.webdav.util.WebdavMethodUtil; import org.codehaus.plexus.redback.authentication.AuthenticationException; @@ -42,7 +42,7 @@ public class ArchivaDavSessionProvider private ServletAuthenticator servletAuth; private HttpAuthenticator httpAuth; - + public ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth ) { this.servletAuth = servletAuth; @@ -51,20 +51,20 @@ public class ArchivaDavSessionProvider public boolean attachSession( WebdavRequest request ) throws DavException - { + { final String repositoryId = RepositoryPathUtil.getRepositoryName( removeContextPath( request ) ); - + try { AuthenticationResult result = httpAuth.getAuthenticationResult( request, null ); - + //Create a dav session - request.setDavSession(new ArchivaDavSession()); - + request.setDavSession( new ArchivaDavSession() ); + return servletAuth.isAuthenticated( request, result ); } catch ( AuthenticationException e ) - { + { // safety check for MRM-911 String guest = UserManager.GUEST_USERNAME; try @@ -80,26 +80,26 @@ public class ArchivaDavSessionProvider catch ( UnauthorizedException ae ) { throw new UnauthorizedDavException( repositoryId, - "You are not authenticated and authorized to access any repository." ); + "You are not authenticated and authorized to access any repository." ); } - - throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); + + throw new UnauthorizedDavException( repositoryId, "You are not authenticated." ); } catch ( MustChangePasswordException e ) - { + { throw new UnauthorizedDavException( repositoryId, "You must change your password." ); } catch ( AccountLockedException e ) - { + { throw new UnauthorizedDavException( repositoryId, "User account is locked." ); - } + } } public void releaseSession( WebdavRequest request ) { - request.setDavSession(null); + request.setDavSession( null ); } - + private String removeContextPath( final DavServletRequest request ) { String path = request.getRequestURI(); @@ -109,5 +109,5 @@ public class ArchivaDavSessionProvider path = path.substring( ctx.length() ); } return path; - } + } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java index 47bd88d15..f5fb1d869 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java @@ -19,12 +19,6 @@ package org.apache.maven.archiva.webdav; * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import org.apache.jackrabbit.util.Text; import org.apache.jackrabbit.webdav.DavException; import org.apache.jackrabbit.webdav.DavResource; @@ -52,9 +46,14 @@ import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.ISODateTimeFormat; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * DavResource for virtual repositories - * */ public class ArchivaVirtualDavResource implements DavResource @@ -69,12 +68,12 @@ public class ArchivaVirtualDavResource private DavPropertySet properties; - private boolean propsInitialized = false; + private boolean propsInitialized = false; private static final String METHODS = "OPTIONS, GET, HEAD, POST, TRACE, PROPFIND, PROPPATCH, MKCOL"; - + private final List<File> localResources; - + public ArchivaVirtualDavResource( List<File> localResources, String logicalResource, MimeTypes mimeTypes, ArchivaDavResourceLocator locator, DavResourceFactory factory ) { @@ -88,7 +87,7 @@ public class ArchivaVirtualDavResource public void spool( OutputContext outputContext ) throws IOException { - if (outputContext.hasStream()) + if ( outputContext.hasStream() ) { Collections.sort( localResources ); List<File> localResourceFiles = new ArrayList<File>(); @@ -108,31 +107,31 @@ public class ArchivaVirtualDavResource public void addLockManager( LockManager arg0 ) { - + } public void addMember( DavResource arg0, InputContext arg1 ) throws DavException { - + } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public MultiStatusResponse alterProperties( List arg0 ) throws DavException - { + { return null; } public MultiStatusResponse alterProperties( DavPropertySet arg0, DavPropertyNameSet arg1 ) throws DavException - { + { return null; } public void copy( DavResource arg0, boolean arg1 ) throws DavException - { + { } @@ -143,12 +142,12 @@ public class ArchivaVirtualDavResource } public ActiveLock getLock( Type arg0, Scope arg1 ) - { + { return null; } public ActiveLock[] getLocks() - { + { return null; } @@ -156,7 +155,7 @@ public class ArchivaVirtualDavResource { return null; } - + public String getSupportedMethods() { return METHODS; @@ -168,7 +167,7 @@ public class ArchivaVirtualDavResource } public boolean hasLock( Type arg0, Scope arg1 ) - { + { return false; } @@ -178,7 +177,7 @@ public class ArchivaVirtualDavResource } public boolean isLockable( Type arg0, Scope arg1 ) - { + { return false; } @@ -191,31 +190,31 @@ public class ArchivaVirtualDavResource public void move( DavResource arg0 ) throws DavException { - + } public ActiveLock refreshLock( LockInfo arg0, String arg1 ) throws DavException - { + { return null; } public void removeMember( DavResource arg0 ) throws DavException { - + } public void unlock( String arg0 ) throws DavException { - + } public String getComplianceClass() { return COMPLIANCE_CLASS; - } + } public DavResourceLocator getLocator() { @@ -231,7 +230,7 @@ public class ArchivaVirtualDavResource { return locator.getHref( isCollection() ); } - + public DavResourceFactory getFactory() { return factory; @@ -240,12 +239,12 @@ public class ArchivaVirtualDavResource public String getDisplayName() { String resPath = getResourcePath(); - + return ( resPath != null ) ? Text.getName( resPath ) : resPath; } - + public DavSession getSession() - { + { return null; } @@ -277,7 +276,7 @@ public class ArchivaVirtualDavResource } public DavResource getCollection() - { + { DavResource parent = null; if ( getResourcePath() != null && !getResourcePath().equals( "/" ) ) { @@ -286,7 +285,8 @@ public class ArchivaVirtualDavResource { parentPath = "/"; } - DavResourceLocator parentloc = locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath ); + DavResourceLocator parentloc = + locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath ); try { // go back to ArchivaDavResourceFactory! @@ -299,7 +299,7 @@ public class ArchivaVirtualDavResource } return parent; } - + /** * Fill the set of properties */ @@ -328,7 +328,7 @@ public class ArchivaVirtualDavResource // Windows XP support properties.add( new DefaultDavProperty( DavPropertyName.ISCOLLECTION, "0" ) ); } - + // Need to get the ISO8601 date for properties DateTime dt = new DateTime( 0 ); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/BrowserRedirectException.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/BrowserRedirectException.java index bb8a3cc27..c05d406f8 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/BrowserRedirectException.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/BrowserRedirectException.java @@ -25,13 +25,14 @@ import javax.servlet.http.HttpServletResponse; /** */ -public class BrowserRedirectException extends DavException +public class BrowserRedirectException + extends DavException { final String location; - public BrowserRedirectException(String location) + public BrowserRedirectException( String location ) { - super(HttpServletResponse.SC_MOVED_PERMANENTLY); + super( HttpServletResponse.SC_MOVED_PERMANENTLY ); this.location = location; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/LogicalResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/LogicalResource.java index 2ac002a8b..b0931c8a6 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/LogicalResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/LogicalResource.java @@ -30,7 +30,7 @@ public class LogicalResource return path; } - public void setPath(String path) + public void setPath( String path ) { this.path = path; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/UnauthorizedDavException.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/UnauthorizedDavException.java index f92c9b4d7..30f8a3eed 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/UnauthorizedDavException.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/UnauthorizedDavException.java @@ -25,13 +25,14 @@ import javax.servlet.http.HttpServletResponse; /** */ -public class UnauthorizedDavException extends DavException +public class UnauthorizedDavException + extends DavException { final private String repositoryName; - public UnauthorizedDavException(String repositoryName, String message) + public UnauthorizedDavException( String repositoryName, String message ) { - super(HttpServletResponse.SC_UNAUTHORIZED, message); + super( HttpServletResponse.SC_UNAUTHORIZED, message ); this.repositoryName = repositoryName; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java index 6fd36c07c..5edb60e69 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/IndexWriter.java @@ -23,6 +23,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.jackrabbit.webdav.DavResource; import org.apache.jackrabbit.webdav.io.OutputContext; +import java.io.File; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -30,27 +32,25 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.io.PrintWriter; -import java.io.File; /** */ public class IndexWriter { private final String logicalResource; - + private final List<File> localResources; - + private final boolean isVirtual; - - public IndexWriter(DavResource resource, File localResource, String logicalResource) + + public IndexWriter( DavResource resource, File localResource, String logicalResource ) { this.localResources = new ArrayList<File>(); this.localResources.add( localResource ); this.logicalResource = logicalResource; this.isVirtual = false; } - + public IndexWriter( DavResource resource, List<File> localResources, String logicalResource ) { this.logicalResource = logicalResource; @@ -58,89 +58,89 @@ public class IndexWriter this.isVirtual = true; } - public void write(OutputContext outputContext) - { - outputContext.setModificationTime(new Date().getTime()); - outputContext.setContentType("text/html"); - outputContext.setETag(""); - if (outputContext.hasStream()) + public void write( OutputContext outputContext ) + { + outputContext.setModificationTime( new Date().getTime() ); + outputContext.setContentType( "text/html" ); + outputContext.setETag( "" ); + if ( outputContext.hasStream() ) { - PrintWriter writer = new PrintWriter(outputContext.getOutputStream()); - writeDocumentStart(writer); - writeHyperlinks(writer); - writeDocumentEnd(writer); + PrintWriter writer = new PrintWriter( outputContext.getOutputStream() ); + writeDocumentStart( writer ); + writeHyperlinks( writer ); + writeDocumentEnd( writer ); writer.flush(); writer.close(); - } + } } - private void writeDocumentStart(PrintWriter writer) + private void writeDocumentStart( PrintWriter writer ) { - writer.println("<html>"); - writer.println("<head>"); - writer.println("<title>Collection: /" + logicalResource + "</title>"); - writer.println("</head>"); - writer.println("<body>"); - writer.println("<h3>Collection: /" + logicalResource + "</h3>"); + writer.println( "<html>" ); + writer.println( "<head>" ); + writer.println( "<title>Collection: /" + logicalResource + "</title>" ); + writer.println( "</head>" ); + writer.println( "<body>" ); + writer.println( "<h3>Collection: /" + logicalResource + "</h3>" ); //Check if not root - if (logicalResource.length() > 0) + if ( logicalResource.length() > 0 ) { - File file = new File(logicalResource); + File file = new File( logicalResource ); String parentName = file.getParent() == null ? "/" : file.getParent(); - + //convert to unix path in case archiva is hosted on windows - parentName = StringUtils.replace(parentName, "\\", "/" ); + parentName = StringUtils.replace( parentName, "\\", "/" ); - writer.println("<ul>"); - writer.println("<li><a href=\"../\">" + parentName + "</a> <i><small>(Parent)</small></i></li>"); - writer.println("</ul>"); + writer.println( "<ul>" ); + writer.println( "<li><a href=\"../\">" + parentName + "</a> <i><small>(Parent)</small></i></li>" ); + writer.println( "</ul>" ); } - writer.println("<ul>"); + writer.println( "<ul>" ); } - private void writeDocumentEnd(PrintWriter writer) + private void writeDocumentEnd( PrintWriter writer ) { - writer.println("</ul>"); - writer.println("</body>"); - writer.println("</html>"); + writer.println( "</ul>" ); + writer.println( "</body>" ); + writer.println( "</html>" ); } - private void writeHyperlinks(PrintWriter writer) - { - if( !isVirtual ) + private void writeHyperlinks( PrintWriter writer ) + { + if ( !isVirtual ) { - for( File localResource : localResources ) + for ( File localResource : localResources ) { - List<File> files = new ArrayList<File>( Arrays.asList( localResource.listFiles() ) ); + List<File> files = new ArrayList<File>( Arrays.asList( localResource.listFiles() ) ); Collections.sort( files ); - + for ( File file : files ) { writeHyperlink( writer, file.getName(), file.isDirectory() ); } } } - else - { + else + { // virtual repository - filter unique directories Map<String, List<String>> uniqueChildFiles = new HashMap<String, List<String>>(); List<String> sortedList = new ArrayList<String>(); - for( File resource : localResources ) - { - List<File> files = new ArrayList<File>( Arrays.asList( resource.listFiles() ) ); + for ( File resource : localResources ) + { + List<File> files = new ArrayList<File>( Arrays.asList( resource.listFiles() ) ); for ( File file : files ) - { + { List<String> mergedChildFiles = new ArrayList<String>(); - if( uniqueChildFiles.get( file.getName() ) == null ) + if ( uniqueChildFiles.get( file.getName() ) == null ) { - mergedChildFiles.add( file.getAbsolutePath() ); + mergedChildFiles.add( file.getAbsolutePath() ); } else { mergedChildFiles = uniqueChildFiles.get( file.getName() ); - if( !mergedChildFiles.contains( file.getAbsolutePath() ) ) + if ( !mergedChildFiles.contains( file.getAbsolutePath() ) ) { mergedChildFiles.add( file.getAbsolutePath() ); } @@ -149,34 +149,34 @@ public class IndexWriter sortedList.add( file.getName() ); } } - + Collections.sort( sortedList ); List<String> written = new ArrayList<String>(); for ( String fileName : sortedList ) - { + { List<String> childFilesFromMap = uniqueChildFiles.get( fileName ); - for( String childFilePath : childFilesFromMap ) - { + for ( String childFilePath : childFilesFromMap ) + { File childFile = new File( childFilePath ); - if( !written.contains( childFile.getName() ) ) - { + if ( !written.contains( childFile.getName() ) ) + { written.add( childFile.getName() ); - writeHyperlink( writer, fileName, childFile.isDirectory() ); + writeHyperlink( writer, fileName, childFile.isDirectory() ); } } } } } - private void writeHyperlink(PrintWriter writer, String resourceName, boolean directory ) - { - if (directory) + private void writeHyperlink( PrintWriter writer, String resourceName, boolean directory ) + { + if ( directory ) { - writer.println("<li><a href=\"" + resourceName + "/\">" + resourceName + "</a></li>"); + writer.println( "<li><a href=\"" + resourceName + "/\">" + resourceName + "</a></li>" ); } else { - writer.println("<li><a href=\"" + resourceName + "\">" + resourceName + "</a></li>"); + writer.println( "<li><a href=\"" + resourceName + "\">" + resourceName + "</a></li>" ); } - } + } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/MimeTypes.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/MimeTypes.java index a9372a96e..f3e906e27 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/MimeTypes.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/MimeTypes.java @@ -39,25 +39,24 @@ import java.util.Map; import java.util.StringTokenizer; /** - * MimeTypes + * MimeTypes * * @version $Id: MimeTypes.java 7010 2007-10-25 23:35:02Z joakime $ - * */ -@Service("mimeTpes") +@Service( "mimeTpes" ) public class MimeTypes { private static final String DEFAULT_MIME_TYPE = "application/octet-stream"; private String resource = "org/apache/maven/archiva/webdav/util/mime.types"; - + private Map<String, String> mimeMap = new HashMap<String, String>(); private Logger log = LoggerFactory.getLogger( MimeTypes.class ); - + /** * Get the Mime Type for the provided filename. - * + * * @param filename the filename to obtain the mime type for. * @return a mime type String, or null if filename is null, has no extension, or no mime type is associated with it. */ @@ -74,8 +73,7 @@ public class MimeTypes } } - - if (value == null) + if ( value == null ) { value = DEFAULT_MIME_TYPE; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/RepositoryPathUtil.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/RepositoryPathUtil.java index 2b1c5d271..aa29cecc9 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/RepositoryPathUtil.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/RepositoryPathUtil.java @@ -19,42 +19,42 @@ package org.apache.maven.archiva.webdav.util; * under the License. */ -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; /** */ public class RepositoryPathUtil { - public static String getLogicalResource(final String href) + public static String getLogicalResource( final String href ) { String logicalResource = null; String requestPathInfo = StringUtils.defaultString( href ); //remove prefix ie /repository/blah becomes /blah - requestPathInfo = removePrefix(requestPathInfo); + requestPathInfo = removePrefix( requestPathInfo ); // Remove prefixing slash as the repository id doesn't contain it; if ( requestPathInfo.startsWith( "/" ) ) { requestPathInfo = requestPathInfo.substring( 1 ); - } + } int slash = requestPathInfo.indexOf( '/' ); if ( slash > 0 ) - { + { logicalResource = requestPathInfo.substring( slash ); - - if (logicalResource.endsWith( "/.." ) ) + + if ( logicalResource.endsWith( "/.." ) ) { logicalResource += "/"; } - + if ( logicalResource != null && logicalResource.startsWith( "//" ) ) { logicalResource = logicalResource.substring( 1 ); } - + if ( logicalResource == null ) { logicalResource = "/"; @@ -67,12 +67,12 @@ public class RepositoryPathUtil return logicalResource; } - public static String getRepositoryName(final String href) + public static String getRepositoryName( final String href ) { String requestPathInfo = StringUtils.defaultString( href ); //remove prefix ie /repository/blah becomes /blah - requestPathInfo = removePrefix(requestPathInfo); + requestPathInfo = removePrefix( requestPathInfo ); // Remove prefixing slash as the repository id doesn't contain it; if ( requestPathInfo.startsWith( "/" ) ) @@ -90,21 +90,21 @@ public class RepositoryPathUtil return requestPathInfo; } - private static String removePrefix(final String href) + private static String removePrefix( final String href ) { - String[] parts = StringUtils.split(href, '/'); - parts = (String[]) ArrayUtils.subarray(parts, 1, parts.length); - if (parts == null || parts.length == 0) + String[] parts = StringUtils.split( href, '/' ); + parts = (String[]) ArrayUtils.subarray( parts, 1, parts.length ); + if ( parts == null || parts.length == 0 ) { return "/"; } - - String joinedString = StringUtils.join(parts, '/'); - if( href.endsWith( "/" ) ) + + String joinedString = StringUtils.join( parts, '/' ); + if ( href.endsWith( "/" ) ) { joinedString = joinedString + "/"; } - + return joinedString; } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java index 70e055e6c..91a851b85 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java @@ -19,8 +19,8 @@ package org.apache.maven.archiva.webdav.util; * under the License. */ -import org.apache.commons.lang.StringUtils; import org.apache.archiva.security.ArchivaRoleConstants; +import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.List; @@ -28,7 +28,7 @@ import java.util.Locale; /** * WebdavMethodUtil - * + * * @version $Id: WebdavMethodUtil.java 5412 2007-01-13 01:18:47Z joakime $ */ public class WebdavMethodUtil |