cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the type of a NodeRef

cuchillo
Champ in-the-making
Champ in-the-making
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
Stefano
1 REPLY 1

cuchillo
Champ in-the-making
Champ in-the-making
Done it!

You can retrieve the type of the node finding its AVMNodeDescriptor value.
It is enough to call these methods:
org.alfresco.service.cmr.avm.AVMService.lookup()
org.alfresco.service.cmr.avm.AVMService.getDirectoryListing()

You have to pass the node path as parameter.

See you next time!
Stefano