Disable adding and deleting nodes via URL
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 4 May 2015 08:36:16 +0000 (08:36 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 4 May 2015 08:36:16 +0000 (08:36 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8086 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java
org.argeo.cms/src/org/argeo/cms/CmsSession.java

index 1a08b6e5b9d0421f3feaa4c2b816ad5c4f1d8fb7..d3d4cbe90be035aa197e6e13e31a742d2c39f5c4 100644 (file)
@@ -118,14 +118,14 @@ abstract class AbstractCmsEntryPoint extends AbstractEntryPoint implements
         * with the obvious default folder type, nt:folder, conceptual equivalent of
         * an empty text file in an operating system. To be overridden.
         */
-       protected String getDefaultNewNodeType() {
-               return CmsTypes.CMS_TEXT;
-       }
+       // protected String getDefaultNewNodeType() {
+       // return CmsTypes.CMS_TEXT;
+       // }
 
        /** Default new folder type (used in mkdirs) is nt:folder. To be overridden. */
-       protected String getDefaultNewFolderType() {
-               return NodeType.NT_FOLDER;
-       }
+       // protected String getDefaultNewFolderType() {
+       // return NodeType.NT_FOLDER;
+       // }
 
        protected String getBaseTitle() {
                return factoryProperties.get(WebClient.PAGE_TITLE);
@@ -197,43 +197,42 @@ abstract class AbstractCmsEntryPoint extends AbstractEntryPoint implements
                try {
                        int firstSlash = state.indexOf('/');
                        if (firstSlash == 0) {
-                               if (!session.nodeExists(state))
-                                       node = addNode(session, state, null);
-                               else
+                               if (session.nodeExists(state))
                                        node = session.getNode(state);
+                               else
+                                       throw new CmsException("Data " + state + " does not exist");
                                page = "";
                        } else if (firstSlash > 0) {
                                String prefix = state.substring(0, firstSlash);
                                String path = state.substring(firstSlash);
-                               if (session.getWorkspace().getNodeTypeManager()
-                                               .hasNodeType(prefix)) {
-                                       String nodeType = prefix;
-                                       if (!session.nodeExists(path))
-                                               node = addNode(session, path, nodeType);
-                                       else {
-                                               node = session.getNode(path);
-                                               if (!node.isNodeType(nodeType))
-                                                       throw new CmsException("Node " + path
-                                                                       + " not of type " + nodeType);
-                                       }
-                               } else if ("delete".equals(prefix)) {
-                                       if (session.itemExists(path)) {
-                                               Node nodeToDelete = session.getNode(path);
-                                               // TODO "Are you sure?"
-                                               nodeToDelete.remove();
-                                               session.save();
-                                               log.debug("Deleted " + path);
-                                               navigateTo(previousState);
-                                       } else
-                                               throw new CmsException("Data " + path
-                                                               + " does not exist");
-                               } else {
-                                       if (session.itemExists(path))
-                                               node = session.getNode(path);
-                                       else
-                                               throw new CmsException("Data " + path
-                                                               + " does not exist");
-                               }
+                               // if (session.getWorkspace().getNodeTypeManager()
+                               // .hasNodeType(prefix)) {
+                               // String nodeType = prefix;
+                               // if (!session.nodeExists(path))
+                               // node = addNode(session, path, nodeType);
+                               // else {
+                               // node = session.getNode(path);
+                               // if (!node.isNodeType(nodeType))
+                               // throw new CmsException("Node " + path
+                               // + " not of type " + nodeType);
+                               // }
+                               // } else if ("delete".equals(prefix)) {
+                               // if (session.itemExists(path)) {
+                               // Node nodeToDelete = session.getNode(path);
+                               // // TODO "Are you sure?"
+                               // nodeToDelete.remove();
+                               // session.save();
+                               // log.debug("Deleted " + path);
+                               // navigateTo(previousState);
+                               // } else
+                               // throw new CmsException("Data " + path
+                               // + " does not exist");
+                               // } else {
+                               if (session.nodeExists(path))
+                                       node = session.getNode(path);
+                               else
+                                       throw new CmsException("Data " + path + " does not exist");
+                               // }
                                page = prefix;
                        } else {
                                node = getDefaultNode(session);
@@ -255,7 +254,6 @@ abstract class AbstractCmsEntryPoint extends AbstractEntryPoint implements
                                                + page + ", title=" + title + ")");
 
                        return title;
-
                } catch (Exception e) {
                        if (previousState.equals(""))
                                previousState = "~";
@@ -265,19 +263,18 @@ abstract class AbstractCmsEntryPoint extends AbstractEntryPoint implements
                }
        }
 
-       protected Node addNode(Session session, String path, String nodeType)
-                       throws RepositoryException {
-               return JcrUtils.mkdirs(session, path, nodeType != null ? nodeType
-                               : getDefaultNewNodeType(), getDefaultNewFolderType(), false);
-               // not saved, so that the UI can discard it later on
-       }
+       // protected Node addNode(Session session, String path, String nodeType)
+       // throws RepositoryException {
+       // return JcrUtils.mkdirs(session, path, nodeType != null ? nodeType
+       // : getDefaultNewNodeType(), getDefaultNewFolderType(), false);
+       // // not saved, so that the UI can discard it later on
+       // }
 
        protected Node getNode() {
                return node;
        }
 
-       @Override
-       public String getState() {
+       protected String getState() {
                return state;
        }
 
index 566b2821e80b9fdc590d131137b2f68ae2e5e26d..d36bed576217803264b1aad02a72a3643d3f7216 100644 (file)
@@ -13,8 +13,6 @@ public interface CmsSession {
        // NAVIGATION
        public void navigateTo(String state);
 
-       public String getState();
-
        // SECURITY
        public void authChange();