Introduce CMS-specific user APIs, based at this stage on OSGi UserAdmin
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / directory / DirectoryContentProvider.java
index f4a416aa7bdfefcf38faf4126f249c4bca3638c8..9af83a33072bf2fc56695beae5e992942b15fff4 100644 (file)
@@ -7,18 +7,18 @@ import java.util.List;
 
 import javax.xml.namespace.QName;
 
+import org.argeo.api.acr.ArgeoNamespace;
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentName;
 import org.argeo.api.acr.ContentNotFoundException;
-import org.argeo.api.acr.CrName;
 import org.argeo.api.acr.spi.ContentProvider;
 import org.argeo.api.acr.spi.ProvidedContent;
 import org.argeo.api.acr.spi.ProvidedSession;
+import org.argeo.api.cms.directory.HierarchyUnit;
+import org.argeo.api.cms.directory.UserDirectory;
 import org.argeo.cms.CmsUserManager;
 import org.argeo.cms.acr.AbstractContent;
 import org.argeo.cms.acr.ContentUtils;
-import org.argeo.osgi.useradmin.UserDirectory;
-import org.argeo.util.directory.HierarchyUnit;
 import org.osgi.service.useradmin.User;
 
 public class DirectoryContentProvider implements ContentProvider {
@@ -48,7 +48,8 @@ public class DirectoryContentProvider implements ContentProvider {
                        }
                }
                if (userDirectory == null)
-                       throw new ContentNotFoundException("Cannot find user directory " + userDirectoryName);
+                       throw new ContentNotFoundException(session, mountPath + "/" + relativePath,
+                                       "Cannot find user directory " + userDirectoryName);
                if (segments.size() == 1) {
                        return new DirectoryContent(session, this, userDirectory);
                } else {
@@ -71,7 +72,8 @@ public class DirectoryContentProvider implements ContentProvider {
                        }
                        HierarchyUnit hierarchyUnit = userDirectory.getHierarchyUnit(pathWithinUserDirectory);
                        if (hierarchyUnit == null)
-                               throw new ContentNotFoundException(
+                               throw new ContentNotFoundException(session,
+                                               mountPath + "/" + relativePath + "/" + pathWithinUserDirectory,
                                                "Cannot find " + pathWithinUserDirectory + " within " + userDirectoryName);
                        return new HierarchyUnitContent(session, this, hierarchyUnit);
                }
@@ -90,16 +92,16 @@ public class DirectoryContentProvider implements ContentProvider {
 
        @Override
        public String getNamespaceURI(String prefix) {
-               if (CrName.LDAP_DEFAULT_PREFIX.equals(prefix))
-                       return CrName.LDAP_NAMESPACE_URI;
-               throw new IllegalArgumentException("Only prefix " + CrName.LDAP_DEFAULT_PREFIX + " is supported");
+               if (ArgeoNamespace.LDAP_DEFAULT_PREFIX.equals(prefix))
+                       return ArgeoNamespace.LDAP_NAMESPACE_URI;
+               throw new IllegalArgumentException("Only prefix " + ArgeoNamespace.LDAP_DEFAULT_PREFIX + " is supported");
        }
 
        @Override
        public Iterator<String> getPrefixes(String namespaceURI) {
-               if (CrName.LDAP_NAMESPACE_URI.equals(namespaceURI))
-                       return Collections.singletonList(CrName.LDAP_DEFAULT_PREFIX).iterator();
-               throw new IllegalArgumentException("Only namespace URI " + CrName.LDAP_NAMESPACE_URI + " is supported");
+               if (ArgeoNamespace.LDAP_NAMESPACE_URI.equals(namespaceURI))
+                       return Collections.singletonList(ArgeoNamespace.LDAP_DEFAULT_PREFIX).iterator();
+               throw new IllegalArgumentException("Only namespace URI " + ArgeoNamespace.LDAP_NAMESPACE_URI + " is supported");
        }
 
        public void setUserManager(CmsUserManager userManager) {