Search in sources :

Example 1 with DataGridRuleException

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;
}
Also used : DataGridRuleException(com.emc.metalnx.core.domain.exceptions.DataGridRuleException) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) JargonException(org.irods.jargon.core.exception.JargonException) IRODSRuleExecResult(org.irods.jargon.core.rule.IRODSRuleExecResult)

Example 2 with DataGridRuleException

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);
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) DataGridRuleException(com.emc.metalnx.core.domain.exceptions.DataGridRuleException) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridReplicateException(com.emc.metalnx.core.domain.exceptions.DataGridReplicateException) MultipartHttpServletRequest(org.springframework.web.multipart.MultipartHttpServletRequest) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataGridRuleException (com.emc.metalnx.core.domain.exceptions.DataGridRuleException)2 JargonException (org.irods.jargon.core.exception.JargonException)2 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 DataGridReplicateException (com.emc.metalnx.core.domain.exceptions.DataGridReplicateException)1 IRODSRuleExecResult (org.irods.jargon.core.rule.IRODSRuleExecResult)1 IRODSRuleExecResultOutputParameter (org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)1