]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.jcr/src/org/argeo/jcr/fs/JcrBasicfileAttributes.java
Improve logging
[lgpl/argeo-commons.git] / org.argeo.jcr / src / org / argeo / jcr / fs / JcrBasicfileAttributes.java
index e59abbc70a8a1fc1f65556c4208b7946eb2c5b96..92d9152d9231c1f043d5d21bcdf71319b6b86e29 100644 (file)
@@ -17,6 +17,8 @@ public class JcrBasicfileAttributes implements NodeFileAttributes {
        private FileTime EPOCH = FileTime.fromMillis(0);
 
        public JcrBasicfileAttributes(Node node) {
+               if (node == null)
+                       throw new JcrFsException("Node underlying the attributes cannot be null");
                this.node = node;
        }
 
@@ -63,7 +65,10 @@ public class JcrBasicfileAttributes implements NodeFileAttributes {
        @Override
        public boolean isDirectory() {
                try {
-                       return node.isNodeType(NodeType.NT_FOLDER);
+                       if (node.isNodeType(NodeType.NT_FOLDER))
+                               return true;
+                       // all other non file nodes
+                       return !(node.isNodeType(NodeType.NT_FILE) || node.isNodeType(NodeType.NT_LINKED_FILE));
                } catch (RepositoryException e) {
                        throw new JcrFsException("Cannot check if directory", e);
                }
@@ -88,7 +93,7 @@ public class JcrBasicfileAttributes implements NodeFileAttributes {
                if (isRegularFile()) {
                        Binary binary = null;
                        try {
-                               binary = node.getNode(Property.JCR_DATA).getProperty(Property.JCR_CONTENT).getBinary();
+                               binary = node.getNode(Property.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
                                return binary.getSize();
                        } catch (RepositoryException e) {
                                throw new JcrFsException("Cannot check size", e);