cancel
Showing results for 
Search instead for 
Did you mean: 

java-backed webscript get properties of node by workspace

xmlxml
Champ in-the-making
Champ in-the-making
i have workspace:  workspace://SpacesStore/e0776399-35a8-4b22-be03-7109a3086865
i want to get Properties of node with this workspace
please help me code demo
5 REPLIES 5

abarisone
Star Contributor
Star Contributor
Hi,
could you express your requirements more clearly?
What are you trying to do? And please tell us about your Alfresco configuration.

Regards,
Andrea

nickburch
Confirmed Champ
Confirmed Champ
You'll want to use the <a href="http://dev.alfresco.com/resource/docs/java/datamodel/org/alfresco/service/cmr/repository/NodeService...">NodeService</a> for most of this. Your code would be something like:


   // Make sure our node exists
   NodeRef nodeRef = new NodeRef("workspace://SpacesStore/e0776399-35a8-4b22-be03-7109a3086865");
   if (! nodeService.exists(nodeRef)) {
       throw new AlfrescoRuntimeException("Sorry, " + nodeRef + " doesn't exist");
   }

   // Fetch all the properties
   Map<QName, Serializable> props = nodeService.getProperties(nodeRef);

   // Fetch a few common properties
   String name = (String)props.get(ContentModel.PROP_NAME;
   String title = (String)props.get(ContentModel.PROP_TITLE);


That'll give you all the properties on the node, indexed by their QName.

Hi,

Where should I input this code snippet? At the alfresco explorer?


Regards,
JP




eric_soto
Champ in-the-making
Champ in-the-making
xmlxml,

I know a Java solution was requested but for anyone reading, in case a Javascript solution is preferred, you can try the following:


var node = utils.getNodeFromString("workspace://SpacesStore/e0776399-35a8-4b22-be03-7109a3086865");
var name = node.properties["cm:name"]);
var title = node.properties["cm:title"]);


Cheers,

vekariyakeyur
Champ in-the-making
Champ in-the-making
How to inject nodeService or get reference to nodeService in my current development project ?

The thing is that i want the node's any properties by it's name.
is there any api available for the same ?