Improve directory edition
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / directory / DirectoryContentProvider.java
index f4afbdd538e7de7b12b93d0fa7bbb166873e01d3..8b6eb6bbd4b2d8e73413dfa5aaae82383f44a472 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.cms.CmsUserManager;
+import org.argeo.api.cms.directory.CmsUserManager;
+import org.argeo.api.cms.directory.HierarchyUnit;
+import org.argeo.api.cms.directory.UserDirectory;
 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,26 +92,33 @@ 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) {
                this.userManager = userManager;
        }
 
+       public CmsUserManager getUserManager() {
+               return userManager;
+       }
+
        UserManagerContent getRootContent(ProvidedSession session) {
                return new UserManagerContent(session);
        }
 
+       /*
+        * COMMON UTILITIES
+        */
        class UserManagerContent extends AbstractContent {
 
                public UserManagerContent(ProvidedSession session) {