Expand my Community achievements bar.

SOLVED

How to convert a Node to a Resource?

Avatar

Level 7

Basically I am looking for the reverse of:

    Node node = resource.adaptTo(Node.class)

How can this be done?

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

You can do this by using the AdapterManager OSGi service and:

adapterManager.getAdapter(node, Resource.class);

Regards,

Justin

View solution in original post

2 Replies

Avatar

Level 6

You can do - 

String nodePath = resource.getPath();

Node node = session.getNode(nodePath);

Avatar

Correct answer by
Employee

Hi,

You can do this by using the AdapterManager OSGi service and:

adapterManager.getAdapter(node, Resource.class);

Regards,

Justin