@SuppressWarnings("unchecked")
@Remote
public void openDocument(@RequestParam("version") String version, @RequestParam("nodeId") NodeRef nodeRef,
@RequestParam("forceDownload") boolean forceDownload, Context context) {
CMContent node = repositoryService.fetch(CMContent.class, nodeRef);
if (!StringUtils.equals(version, "current")) {
node = node.getVersion(version);
}
if (forceDownload) {
// response.put("url", node.getDownloadUrl());
// response.put("name", node.getName());
} else {
String name = node.getName();
String mimeType = serviceRegistry.getMimetypeService().guessMimetype(name);
HierarchicalConfiguration configuration = configService.getConfig(ConfigurationConfig.class)
.getConfiguration();
List<String> inlineMimeTypes = configuration.getList("inline-openable/type");
boolean inline = inlineMimeTypes.contains(mimeType);
String url = inline ? node.getContentUrl() : node.getDownloadUrl();
// response.put("inline", inline);
// response.put("url", url);
// response.put("name", name);
}
}