package org.argeo.cms.internal.kernel;
-import static org.argeo.cms.internal.kernel.KernelConstants.WEBDAV_PRIVATE;
-import static org.argeo.cms.internal.kernel.KernelConstants.WEBDAV_PUBLIC;
-
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.logging.Log;
import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.AuthConstants;
-import org.argeo.jcr.ArgeoJcrConstants;
+import org.argeo.node.NodeConstants;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
Subject subject = new Subject();
LoginContext lc;
try {
- lc = new LoginContext(AuthConstants.LOGIN_CONTEXT_ANONYMOUS, subject);
+ lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_ANONYMOUS, subject);
lc.login();
return subject;
} catch (LoginException e) {
Thread.currentThread().setContextClassLoader(KernelUtils.class.getClassLoader());
LoginContext loginContext;
try {
- loginContext = new LoginContext(AuthConstants.LOGIN_CONTEXT_DATA_ADMIN);
+ loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN);
loginContext.login();
} catch (LoginException e1) {
throw new CmsException("Could not login as data admin", e1);
// if (log.isTraceEnabled())
// log.trace(userId + " : " + node.getPath());
StringBuilder buf = new StringBuilder();
- boolean isAnonymous = userId.equalsIgnoreCase(AuthConstants.ROLE_ANONYMOUS);
+ boolean isAnonymous = userId.equalsIgnoreCase(NodeConstants.ROLE_ANONYMOUS);
if (isAnonymous)
buf.append(WEBDAV_PUBLIC);
else
buf.append(WEBDAV_PRIVATE);
- // TODO convey repo alias vie repository properties
- return buf.append('/').append(ArgeoJcrConstants.ALIAS_NODE).append('/').append(node.getSession().getWorkspace().getName())
- .append(node.getPath()).toString();
+ Session session = node.getSession();
+ Repository repository = session.getRepository();
+ String cn;
+ if (repository.isSingleValueDescriptor(NodeConstants.CN)) {
+ cn = repository.getDescriptor(NodeConstants.CN);
+ } else {
+// log.warn("No cn defined in repository, using " + NodeConstants.NODE);
+ cn = NodeConstants.NODE;
+ }
+ return buf.append('/').append(cn).append('/').append(session.getWorkspace().getName()).append(node.getPath())
+ .toString();
}
public static String getCanonicalUrl(Node node, HttpServletRequest request) throws RepositoryException {