cancel
Showing results for 
Search instead for 
Did you mean: 

how to get all property using node service?

dharmraj
Confirmed Champ
Confirmed Champ
 Map<QName, Serializable> props = nodeService.getProperties(nodeRef);

in this call i am not getting cm:creator  value property .  i want cm:creator value also 

7 REPLIES 7

abhinavmishra14
World-Class Innovator
World-Class Innovator

It should return all the properties including auditable properties (cm:creator, cm:created, cm:modifier, cm:modified etc) as long as they are available

Look at the method here, it includes all the properties including auditable props.

 AuditablePropertiesEntity auditableProperties = node.getAuditableProperties();

public Map<QName, Serializable> getNodeProperties(Long nodeId)
{
Map<QName, Serializable> props = getNodePropertiesCached(nodeId);
// Create a shallow copy to allow additions
props = new HashMap<QName, Serializable>(props);

Node node = getNodeNotNull(nodeId, false);
// Handle sys:referenceable
ReferenceablePropertiesEntity.addReferenceableProperties(node, props);
// Handle sys:localized
LocalizedPropertiesEntity.addLocalizedProperties(localeDAO, node, props);
// Handle cm:auditable
if (hasNodeAspect(nodeId, ContentModel.ASPECT_AUDITABLE))
{
AuditablePropertiesEntity auditableProperties = node.getAuditableProperties();
if (auditableProperties == null)
{
auditableProperties = new AuditablePropertiesEntity();
}
props.putAll(auditableProperties.getAuditableProperties());
}

// Wrap to ensure that we only clone values if the client attempts to modify
// the map or retrieve values that might, themselves, be mutable
props = new ValueProtectingMap<QName, Serializable>(props, NodePropertyValue.IMMUTABLE_CLASSES);

// Done
if (isDebugEnabled)
{
logger.debug("Fetched properties for Node: \n" +
" Node: " + nodeId + "\n" +
" Props: " + props);
}
return props;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

private static Set<QName> auditablePropertyQNames;
static
{
auditablePropertyQNames = new HashSet<QName>(13);
auditablePropertyQNames.add(ContentModel.PROP_CREATOR);
auditablePropertyQNames.add(ContentModel.PROP_CREATED);
auditablePropertyQNames.add(ContentModel.PROP_MODIFIER);
auditablePropertyQNames.add(ContentModel.PROP_MODIFIED);
auditablePropertyQNames.add(ContentModel.PROP_ACCESSED);
}

Check the node in nodeBrowser to see if auditable properties are available. 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

there is not method 

Node node = getNodeNotNull(nodeId, false);

True, the above method is called from within nodeService.getProperties(nodeRef); I was just trying to show the inclusion of properties in the source code, just to show you that all the auditable properties are returned for sure.

Check this classes

org.alfresco.service.cmr.repository.NodeService.getProperties(NodeRef) >(calls)> org.alfresco.repo.node.db.DbNodeServiceImpl.getProperties(NodeRef) >(calls)> org.alfresco.repo.node.db.DbNodeServiceImpl.getPropertiesImpl(Pair<Long, NodeRef>) >(calls)> org.alfresco.repo.domain.node.AbstractNodeDAOImpl.getNodeProperties(Long)

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

dharmraj
Confirmed Champ
Confirmed Champ
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);  
this method is not returning all properties i have checked . there is any way to get
auditable properties

I am not really sure what's wrong in your case. But as mentioned earlier, there is no way nodeService.getProperties(nodeRef) would not return cm:creator and other auditable info. It should return auditable properties as long as they are available. Can you check the nodeRef in node browser to see if all the auditable metadata is available? These props are by default applied when you create/update a node as long as you have not disabled the auditable aspect using behavior filter. Share the screen shot of node browser if possible. 

I did a test at my end too and i can see the properties:

final Map<QName, Serializable> allProps = nodeService.getProperties(nodeRef);

System.out.println(allProps);

See the printed properties map:

{
{http://www.alfresco.org/model/content/1.0}creator=admin,
{http://www.alfresco.org/model/content/1.0}content=contentUrl=store://2019/8/20/16/31/9863f23d-edaf-4ba3-9511-0a971fe9bb7b.bin|mimetype=image/jpeg|size=94399|encoding=UTF-8|locale=en_US_|id=158,
{http://www.alfresco.org/model/system/1.0}store-identifier=SpacesStore,
{http://www.alfresco.org/model/content/1.0}versionLabel=1.0,
{http://www.alfresco.org/model/content/1.0}autoVersion=true,
{http://www.alfresco.org/model/content/1.0}versionType=MAJOR,
{http://www.alfresco.org/model/exif/1.0}pixelYDimension=442,
{http://www.alfresco.org/model/exif/1.0}model=TG-5,
{http://www.alfresco.org/model/content/1.0}autoVersionOnUpdateProps=false,
{http://www.alfresco.org/model/exif/1.0}fNumber=8.0,
{http://www.alfresco.org/model/content/1.0}taggable=null,
{http://www.alfresco.org/model/exif/1.0}manufacturer=OLYMPUS CORPORATION,
{http://www.alfresco.org/model/system/1.0}store-protocol=workspace,
{http://www.alfresco.org/model/system/1.0}node-dbid=747,
{http://www.alfresco.org/model/exif/1.0}pixelXDimension=590,
{http://www.alfresco.org/model/content/1.0}categories=null,
{http://www.alfresco.org/model/exif/1.0}focalLength=4.5,
{http://www.alfresco.org/model/content/1.0}created=Tue Aug 20 16:31:56 EDT 2019,
{http://www.alfresco.org/model/content/1.0}description=OLYMPUS DIGITAL CAMERA,
{http://www.alfresco.org/model/exif/1.0}dateTimeOriginal=Sun May 07 13:23:51 EDT 2017,
{http://www.alfresco.org/model/system/1.0}node-uuid=6c56ab03-9879-450c-840d-d37ea3d714c5,
{http://www.alfresco.org/model/content/1.0}name=1.jpeg,
{http://www.alfresco.org/model/content/1.0}initialVersion=true,
{http://www.alfresco.org/model/content/1.0}title=Test,
{http://www.alfresco.org/model/exif/1.0}flash=false,
{http://www.alfresco.org/model/exif/1.0}isoSpeedRatings=100,
{http://www.github.com/abhinavmishra14/model/demo/1.0}rating=null,
{http://www.alfresco.org/model/system/1.0}locale=en_US,
{http://www.alfresco.org/model/content/1.0}modifier=admin,
{http://www.alfresco.org/model/content/1.0}modified=Wed Aug 21 16:17:41 EDT 2019,
{http://www.alfresco.org/model/content/1.0}author=,
{http://www.alfresco.org/model/exif/1.0}exposureTime=0.005

}

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Abhinav Mishra‌  only these 4 property (Red marks) i am not getting other all i got in response . How to check behavior filter is disabled or not ?

First you need to make sure these properties are available or not. Check the node browser for the particular node you are trying. Also check if this is the case for all the nodes or just one nodeRef that you are trying.

If you are not seeing the auditable properties on all the nodes then probably check if you have implemented any behavior onCreateNode where auditable aspect is disabled. This could be a possible reason why auditable properties are not available on the nodes.

This is how auditable aspect could be disabled on an event:

behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);

You need to make sure that auditable properties are applied then only they can be retrieved.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)