}
public NodeInterface storeNode(final DataContainer receivedData) throws FrameworkException {
final SecurityContext securityContext = SecurityContext.getSuperUserInstance();
final NodeDataContainer receivedNodeData = (NodeDataContainer) receivedData;
final String typeName = receivedNodeData.getType();
final Class nodeType = config.getNodeEntityClass(typeName);
if (nodeType == null) {
logger.log(Level.SEVERE, "Unknown entity type {0}", typeName);
return null;
}
final PropertyMap properties = PropertyMap.databaseTypeToJavaType(securityContext, nodeType, receivedNodeData.getProperties());
final String uuid = receivedNodeData.getSourceNodeId();
NodeInterface newOrExistingNode = null;
final NodeInterface existingCandidate = app.nodeQuery().and(GraphObject.id, uuid).includeDeletedAndHidden().getFirst();
if (existingCandidate != null && existingCandidate instanceof NodeInterface) {
newOrExistingNode = (NodeInterface) existingCandidate;
// merge properties
((Syncable) newOrExistingNode).updateFromPropertyMap(properties);
} else {
// create
newOrExistingNode = app.create(nodeType, properties);
}
idMap.put(receivedNodeData.getSourceNodeId(), newOrExistingNode.getUuid());
return newOrExistingNode;
}