AnsweredAssumed Answered

How to check the type of a NodeRef

Question asked by cuchillo on Jan 21, 2010
Latest reply on Jan 21, 2010 by cuchillo
Hi there!

I have a web project. I am working on Alfresco source code. I am modifying the web-client package.
I have a org.alfresco.service.cmr.avmsync.AVMDifference instance.
From this instance I can get the path and link to the relative Node:

        AVMDifference diff = …
       String path = diff.getSourcePath();
       NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path);
        Node node = new Node(nodeRef);

Now I need to know the type of the node (directory or file) and if the node has been deleted or not.
In other words, I should retrieve the relative AVMNode instance from the path.

From an AVMNode instance I can get the type in this way:

      AVMNode avmNode = (AVMNode)node; // I try to cast
      int avmNodeType = avmNode.getDescriptor().getType(); //

avmNodeType can be:
    public static final int PLAIN_FILE = 0;
    public static final int LAYERED_FILE = 1;
    public static final int PLAIN_DIRECTORY = 2;
    public static final int LAYERED_DIRECTORY = 3;
    public static final int DELETED_NODE = 4;


I can't cast a Node variable to AVMNode variable.
Do you know how can I do it?
Maybe using the AVMDifference instance?
Maybe using the class org.alfresco.service.cmr.avm.AVMService?
Are there other ways?

Thanks in advance!
Best regards