*/
/**
- * ConfigurationListener
+ * ConfigurationListener
*
* @version $Id$
*/
/**
* Generic event point to notify components that something has happend in the configuration.
*/
- public void configurationEvent(ConfigurationEvent event);
+ public void configurationEvent( ConfigurationEvent event );
}
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;
/**
*/
{
parentPath = "/";
}
- DavResourceLocator parentloc = locator.getFactory().createResourceLocator( locator.getPrefix(),
- parentPath );
+ DavResourceLocator parentloc =
+ locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath );
try
{
parent = factory.createResource( parentloc, session );
// 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 );
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 );
}
}
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 );
}
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 )
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 )
{
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 )
{
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 )
{
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 )
}
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()
+ + "']." );
}
}
}
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;
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;
* 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;
/**
*/
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;
this.prefix = prefix;
this.repositoryId = repositoryId;
this.davLocatorFactory = davLocatorFactory;
-
+
String path = resourcePath;
-
- if (!resourcePath.startsWith("/"))
+
+ if ( !resourcePath.startsWith( "/" ) )
{
path = "/" + resourcePath;
}
}
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;
}
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;
}
/**
* Computes the hash code from the href, which is built using the final fields prefix and resourcePath.
- *
+ *
* @return the hash code
*/
public int hashCode()
/**
* 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
*/
* 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." );
}
}
* 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;
private ServletAuthenticator servletAuth;
private HttpAuthenticator httpAuth;
-
+
public ArchivaDavSessionProvider( ServletAuthenticator servletAuth, HttpAuthenticator httpAuth )
{
this.servletAuth = servletAuth;
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
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();
path = path.substring( ctx.length() );
}
return path;
- }
+ }
}
* 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;
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
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 )
{
public void spool( OutputContext outputContext )
throws IOException
{
- if (outputContext.hasStream())
+ if ( outputContext.hasStream() )
{
Collections.sort( localResources );
List<File> localResourceFiles = new ArrayList<File>();
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
- {
+ {
}
}
public ActiveLock getLock( Type arg0, Scope arg1 )
- {
+ {
return null;
}
public ActiveLock[] getLocks()
- {
+ {
return null;
}
{
return null;
}
-
+
public String getSupportedMethods()
{
return METHODS;
}
public boolean hasLock( Type arg0, Scope arg1 )
- {
+ {
return false;
}
}
public boolean isLockable( Type arg0, Scope arg1 )
- {
+ {
return false;
}
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()
{
{
return locator.getHref( isCollection() );
}
-
+
public DavResourceFactory getFactory()
{
return factory;
public String getDisplayName()
{
String resPath = getResourcePath();
-
+
return ( resPath != null ) ? Text.getName( resPath ) : resPath;
}
-
+
public DavSession getSession()
- {
+ {
return null;
}
}
public DavResource getCollection()
- {
+ {
DavResource parent = null;
if ( getResourcePath() != null && !getResourcePath().equals( "/" ) )
{
{
parentPath = "/";
}
- DavResourceLocator parentloc = locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath );
+ DavResourceLocator parentloc =
+ locator.getFactory().createResourceLocator( locator.getPrefix(), parentPath );
try
{
// go back to ArchivaDavResourceFactory!
}
return parent;
}
-
+
/**
* Fill the set of properties
*/
// 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();
/**
*/
-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;
}
return path;
}
- public void setPath(String path)
+ public void setPath( String path )
{
this.path = path;
}
/**
*/
-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;
}
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;
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;
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() );
}
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>" );
}
- }
+ }
}
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.
*/
}
}
-
- if (value == null)
+ if ( value == null )
{
value = DEFAULT_MIME_TYPE;
}
* 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 = "/";
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( "/" ) )
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;
}
}
* 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;
/**
* WebdavMethodUtil
- *
+ *
* @version $Id: WebdavMethodUtil.java 5412 2007-01-13 01:18:47Z joakime $
*/
public class WebdavMethodUtil