use of com.emc.metalnx.core.domain.exceptions.DataGridRuleException in project metalnx-web by irods-contrib.
the class RuleServiceImpl method executeRule.
@Override
public Map<String, IRODSRuleExecResultOutputParameter> executeRule(String rule) throws DataGridRuleException, DataGridConnectionRefusedException {
if (rule == null || rule.isEmpty())
return null;
Map<String, IRODSRuleExecResultOutputParameter> ruleResultMap;
try {
IRODSRuleExecResult result = is.getRuleProcessingAO().executeRule(rule);
ruleResultMap = result.getOutputParameterResults();
} catch (JargonException e) {
String error = String.format("Could not execute rule %s: %s", rule, e.getMessage());
logger.error(error);
throw new DataGridRuleException(error);
}
return ruleResultMap;
}
use of com.emc.metalnx.core.domain.exceptions.DataGridRuleException in project metalnx-web by irods-contrib.
the class UploadController method upload.
@RequestMapping(value = "/", method = RequestMethod.POST, produces = { "text/plain" })
@ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> upload(final HttpServletRequest request) throws DataGridException {
logger.info("upload()");
String uploadMessage = "File Uploaded. ";
String errorType = "";
if (!(request instanceof MultipartHttpServletRequest)) {
logger.warn("Request is not a multipart request.");
uploadMessage = "Request is not a multipart request.";
errorType = FATAL;
return getUploadResponse(uploadMessage, errorType);
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile multipartFile = multipartRequest.getFile("file");
logger.info("multipartFile:{}", multipartFile);
boolean isRuleDeployment = Boolean.parseBoolean(multipartRequest.getParameter("ruleDeployment"));
boolean checksum = Boolean.parseBoolean(multipartRequest.getParameter("checksum"));
boolean replica = Boolean.parseBoolean(multipartRequest.getParameter("replica"));
boolean overwrite = Boolean.parseBoolean(multipartRequest.getParameter("overwriteDuplicateFiles"));
String resources = multipartRequest.getParameter("resources");
String resourcesToUpload = multipartRequest.getParameter("resourcesToUpload");
String destPath = multipartRequest.getParameter("uploadDestinationPath");
logger.info("parsed parameters...");
try {
if (isRuleDeployment) {
ruleDeploymentService.deployRule(multipartFile);
} else {
us.upload(multipartFile, destPath, checksum, replica, resources, resourcesToUpload, overwrite);
}
} catch (DataGridReplicateException e) {
uploadMessage += e.getMessage();
errorType = WARNING;
logger.warn("DataGridReplicateException during upload, will pass back as a warning", e);
} catch (DataGridRuleException e) {
uploadMessage += METADATA_EXTRACTION_FAILED_MSG;
errorType = WARNING;
logger.warn("DataGridRule exception extracting metadata, will pass back as warning", e);
} catch (DataGridException e) {
uploadMessage = e.getMessage();
errorType = FATAL;
logger.error("DataGridException uploading file", e);
logger.warn("DataGridException uplaoding file, will pass back as warning", e);
// throw e;
} catch (JargonException e) {
uploadMessage = e.getMessage();
errorType = FATAL;
logger.error("JargonException uploading file", e);
logger.warn("JargonException uplaoding file, will pass back as warning", e);
} catch (Throwable t) {
logger.error("unexpected exception in upload", t);
errorType = FATAL;
throw t;
}
return getUploadResponse(uploadMessage, errorType);
}
Aggregations