/*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Enumeration;
import java.util.Properties;
+import java.util.StringTokenizer;
import javax.jcr.Repository;
import javax.jcr.RepositoryFactory;
private final static Log log = LogFactory
.getLog(MultipleRepositoryHandlerMapping.class);
- // private final static String MKCOL = "MKCOL";
+ private final static String MKCOL = "MKCOL";
private ConfigurableApplicationContext applicationContext;
private ServletContext servletContext;
}
String pathInfo = request.getPathInfo();
-
- // tokenize path
- // List<String> tokens = JcrUtils.tokenize(pathInfo);
- // String[] tokens = extractPrefix(pathInfo);
-
- // check if repository can be found
- // if (tokens[0] == null || (tokens[1] == null && tokens[0].equals("")))
- // return null;
-
- // MKCOL on repository or root node doesn't make sense
- // if ((tokens.size() == 1 || tokens.size() == 2)
- // && request.getMethod().equals(MKCOL))
- // return null;
-
- // String repositoryAlias = extractRepositoryName(tokens);
String repositoryAlias = extractRepositoryAlias(pathInfo);
if (repositoryAlias.equals(""))
return null;
+
+ // MKCOL on repository or root node doesn't make sense
+ // and causes issues
+ if (request.getMethod().equals(MKCOL)) {
+ StringTokenizer st = new StringTokenizer(pathInfo, "/");
+ if (!st.hasMoreTokens())
+ return null;
+ st.nextToken();// repository
+ if (!st.hasMoreTokens())
+ return null;
+ st.nextToken();// workspace
+ if (!st.hasMoreTokens())
+ return null;
+ }
+
request.setAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS,
repositoryAlias);
String pathPrefix = request.getServletPath() + '/' + repositoryAlias;