use of org.irods.jargon.extensions.datatyper.DataTypeResolutionService in project metalnx-web by irods-contrib.
the class PreviewPreparationController method getPreview.
/**
* Responds the preview/ request
*
* @param model
* @return the collection management template
* @throws DataGridConnectionRefusedException
* @throws JargonException
* @throws DataGridException
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getPreview(final Model model, @RequestParam("path") final String path, RedirectAttributes redirectAttributes) throws DataGridException {
logger.info("prepareForPreview for {} ::" + path);
String mimeType = null;
boolean permission = previewService.getPermission(path);
if (permission) {
try {
IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
DataTypeResolutionService dataTypeResolutionService = dataTypeResolutionServiceFactory.instanceDataTypeResolutionService(irodsAccount);
logger.info("dataTypeResolutionService created from factory:{}", dataTypeResolutionService);
logger.info("doing quick check for mime type");
mimeType = dataTypeResolutionService.quickMimeType(path);
logger.info("mimetype:{}", mimeType);
redirectAttributes.addAttribute("path", path);
redirectAttributes.addAttribute("mimeType", mimeType);
return "redirect:/preview/templateByMimeType";
} catch (JargonException e) {
logger.error("Could not retrieve data from path: {}", path, e);
throw new DataGridException(e.getMessage());
} catch (Exception e) {
logger.error("general exception generating preview", e);
throw new DataGridException(e.getLocalizedMessage());
}
} else {
return "collections/preview :: noPermission";
}
}
Aggregations