Example usage for org.springframework.data.rest.webmvc.json.patch PatchException PatchException

List of usage examples for org.springframework.data.rest.webmvc.json.patch PatchException PatchException

Introduction

In this page you can find the example usage for org.springframework.data.rest.webmvc.json.patch PatchException PatchException.

Prototype

public PatchException(String message, Exception e) 

Source Link

Usage

From source file:org.dspace.app.rest.repository.WorkspaceItemRestRepository.java

private void evaluatePatch(Context context, HttpServletRequest request, WorkspaceItem source,
        WorkspaceItemRest wsi, String section, Operation op) {
    SubmissionConfig submissionConfig = submissionConfigReader
            .getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
    for (int stepNum = 0; stepNum < submissionConfig.getNumberOfSteps(); stepNum++) {

        SubmissionStepConfig stepConfig = submissionConfig.getStep(stepNum);

        if (section.equals(stepConfig.getId())) {
            /*//from ww w  . jav a  2s  . co m
             * First, load the step processing class (using the current
             * class loader)
             */
            ClassLoader loader = this.getClass().getClassLoader();
            Class stepClass;
            try {
                stepClass = loader.loadClass(stepConfig.getProcessingClassName());

                Object stepInstance = stepClass.newInstance();

                if (stepInstance instanceof AbstractRestProcessingStep) {
                    // load the JSPStep interface for this step
                    AbstractRestProcessingStep stepProcessing = (AbstractRestProcessingStep) stepClass
                            .newInstance();
                    stepProcessing.doPreProcessing(context, source);
                    stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source,
                            op);
                    stepProcessing.doPostProcessing(context, source);
                } else {
                    throw new PatchBadRequestException("The submission step class specified by '"
                            + stepConfig.getProcessingClassName()
                            + "' does not extend the class org.dspace.submit.AbstractProcessingStep!"
                            + " Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
                }

            } catch (Exception e) {
                log.error(e.getMessage(), e);
                throw new PatchException("Error processing the patch request", e);
            }
        }
    }
}