Author: joakime
Date: Mon Oct 16 14:16:15 2006
New Revision: 464672
URL: http://svn.apache.org/viewvc?view=rev&rev=464672
Log:
* Fix NPE on webdav.
* Fix authorization on webdav.
* Fix http request context and path info for webdav.
Added:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
(with props)
Modified:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryMapping.java
Modified:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java?view=diff&rev=464672&r1=464671&r2=464672
==============================================================================
---
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java
(original)
+++
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java
Mon Oct 16 14:16:15 2006
@@ -114,6 +114,7 @@
catch ( ConfigurationStoreException e )
{
// TODO: should be a more pretty error to user. ;-)
+ // TODO: can we determine if the incoming request is a real user,
or just maven-wagon?
throw new ServletException( "Unable to obtain configuration.", e );
}
@@ -179,8 +180,6 @@
permission = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD;
}
- permission += "-" + repoconfig.getId();
-
boolean isAuthorized = securitySystem.isAuthorized(
securitySession, permission, repoconfig.getId() );
if ( !isAuthorized )
@@ -200,10 +199,18 @@
RepositoryMapping repo = getRepositoryMapping( repoconfig );
- response.setHeader( "Server",
- getServletContext().getServerInfo() + " Archiva :
" + DAVUtilities.SERVLET_SIGNATURE );
+ String serverInfo = "";
+ if ( getServletContext() != null )
+ {
+ if ( StringUtils.isNotEmpty( getServletContext().getServerInfo() )
)
+ {
+ serverInfo = getServletContext().getServerInfo();
+ }
+ }
+
+ response.setHeader( "Server", serverInfo + " Archiva : " +
DAVUtilities.SERVLET_SIGNATURE );
- DAVTransaction transaction = new DAVTransaction( request, response );
+ DAVTransaction transaction = new DAVTransaction( new
RepositoryRequest( request, repoconfig.getId() ), response );
try
{
repo.getDavProcessor().process( transaction );
Modified:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryMapping.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryMapping.java?view=diff&rev=464672&r1=464671&r2=464672
==============================================================================
---
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryMapping.java
(original)
+++
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryMapping.java
Mon Oct 16 14:16:15 2006
@@ -45,7 +45,7 @@
this.repositoryConfiguration = repoConfig;
File repoDir = new File(repositoryConfiguration.getDirectory());
this.davRepository = new DAVRepository( repoDir );
- this.davProcessor = new DAVProcessor(this.davRepository);
+ this.davProcessor = new DAVProcessor( this.davRepository );
this.davRepository.addListener(this);
}
Added:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java?view=auto&rev=464672
==============================================================================
---
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
(added)
+++
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
Mon Oct 16 14:16:15 2006
@@ -0,0 +1,76 @@
+package org.apache.maven.archiva.web.servlet.repository;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 it.could.webdav.DAVTransaction;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * RepositoryRequest
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryRequest
+ extends HttpServletRequestWrapper
+{
+ private String repoId;
+
+ public RepositoryRequest( HttpServletRequest request, String repoid )
+ {
+ super( request );
+ this.repoId = "";
+
+ if(repoid != null) {
+ this.repoId = repoid;
+ }
+ }
+
+ /**
+ * Adjust the path info value to remove reference to repoId.
+ * This is done to satisfy the needs of [EMAIL PROTECTED] DAVTransaction}
+ */
+ public String getPathInfo()
+ {
+ String pathInfo = super.getPathInfo();
+
+ if ( pathInfo == null )
+ {
+ return "";
+ }
+
+ if ( ( pathInfo.length() > 1 ) && ( pathInfo.charAt( 0 ) == '/' ) )
+ {
+ pathInfo = pathInfo.substring( 1 );
+ }
+
+ if ( pathInfo.startsWith( repoId ) )
+ {
+ pathInfo = pathInfo.substring( repoId.length() );
+ }
+
+ return pathInfo;
+ }
+
+ public String getServletPath()
+ {
+ return super.getServletPath() + "/" + this.repoId;
+ }
+
+}
Propchange:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryRequest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"