I am developing a Neo4j server extension using the Neo4j Framework provided by Graphaware.
I want in my response to send the following object (simplified so that you can see the attributes) :
public class DiffResult {
private Node fileOrFolder;
private Node originalContent;
private Path path;
}
The problem is that the Node object cannot be rendered by Jackson. I have seen a NodeRepresentation class somewhare but I also don't know how to use it properly with my Spring MVC Controller.
I want my nodes to be serialized like in the Neo4j REST Api (cf documentation: http://neo4j.com/docs/stable/rest-api-nodes.html#rest-api-get-node)
I also show you the controller I am using (also simplified).
@Controller
@RequestMapping("/diff")
public class FileSpaceDiffApi {
private final GraphDatabaseService database;
@Autowired
public FileSpaceDiffApi(GraphDatabaseService database) {
this.database = database;
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public List<DiffResult> diff(@QueryParam("fileSpaceId") Long fileSpaceId, @QueryParam("since") Long since) {
List<DiffResult> results = new ArrayList<DiffResult>();
Transaction tx = database.beginTx();
try {
Node startNode = database.getNodeById(fileSpaceId);
DiffResult diffResult = new DiffResult();
diffResult.setFileOrFolder(startNode);
results.add(diffResult);
tx.success();
}
finally {
tx.close();
}
return results;
}
}
Ideally I'd also like to be able to render the Path in JSON.