Example usage for org.springframework.http HttpStatus FORBIDDEN

List of usage examples for org.springframework.http HttpStatus FORBIDDEN

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus FORBIDDEN.

Prototype

HttpStatus FORBIDDEN

To view the source code for org.springframework.http HttpStatus FORBIDDEN.

Click Source Link

Document

403 Forbidden .

Usage

From source file:de.steilerdev.myVerein.server.controller.admin.DivisionManagementController.java

/**
 * This function gathers the complete division tree that the user is administrating. The function is invoked by GETting the URI /api/admin/division/divisionTree.
 * @param currentUser The currently logged in user.
 * @return An HTTP response with a status code. In case of success a list of tree nodes, that represent the division tree, are bundled with the status code, otherwise just the error code is returned.
 *//*from w  w  w .jav a 2s . c  o  m*/
@RequestMapping(value = "divisionTree", produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<TreeNode>> getDivisionTree(@CurrentUser User currentUser) {
    logger.trace("[" + currentUser + "]  Gathering the division tree");
    List<Division> divisions = getOptimizedSetOfAdministratedDivisions(currentUser);
    if (divisions != null) {
        if (!divisions.isEmpty()) {
            List<TreeNode> divisionTree = new ArrayList<>();
            divisions.parallelStream().forEach(div -> divisionTree.add(getSubTree(div)));
            if (divisionTree.isEmpty()) {
                logger.warn("[" + currentUser + "]  The division tree is empty");
                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
            } else {
                logger.debug("[" + currentUser + "]  Returning the division tree");
                return new ResponseEntity<>(divisionTree, HttpStatus.OK);
            }
        } else {
            logger.warn("[" + currentUser
                    + "]  The optimized set of administrated divisions for the user is empty");
            return new ResponseEntity<>(HttpStatus.FORBIDDEN);
        }
    } else {
        logger.warn("[" + currentUser + "]  Unable to find divisions for the user");
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}

From source file:de.zib.gndms.dspace.service.SliceServiceImpl.java

@Override
@RequestMapping(value = "/_{subspaceId}/_{sliceKindId}/_{sliceId}/_{fileName:.*}", method = RequestMethod.POST)
@Secured("ROLE_USER")
public ResponseEntity<Integer> setFileContent(@PathVariable final String subspaceId,
        @PathVariable final String sliceKindId, @PathVariable final String sliceId,
        @PathVariable final String fileName, @RequestParam("file") final MultipartFile file,
        @RequestHeader("DN") final String dn) {
    GNDMSResponseHeader headers = setHeaders(subspaceId, sliceKindId, sliceId, dn);

    try {//from  w ww .  j a  v a2 s.c o  m
        Subspace space = subspaceProvider.get(subspaceId);
        Slice slice = findSliceOfKind(subspaceId, sliceKindId, sliceId);
        String path = space.getPathForSlice(slice);
        File newFile = new File(path + File.separatorChar + fileName);

        if (newFile.exists()) {
            logger.warn("File " + newFile + "will be overwritten. ");
        }

        final long sliceMaxSize = slice.getTotalStorageSize();
        long sliceSize = sliceProvider.getDiskUsage(subspaceId, sliceId);
        if (sliceSize >= sliceMaxSize)
            throw new IOException(
                    "Slice " + sliceId + " has reached maximum size of " + sliceMaxSize + " Bytes");

        file.transferTo(newFile);

        //DataOutputStream dos = new DataOutputStream(new FileOutputStream(newFile));

        //dos.write(file.getBytes());
        //dos.close();
        return new ResponseEntity<Integer>(0, headers, HttpStatus.OK);
    } catch (NoSuchElementException ne) {
        logger.warn(ne.getMessage(), ne);
        return new ResponseEntity<Integer>(0, headers, HttpStatus.NOT_FOUND);
    } catch (FileNotFoundException e) {
        logger.warn(e.getMessage(), e);
        return new ResponseEntity<Integer>(0, headers, HttpStatus.FORBIDDEN);
    } catch (IOException e) {
        logger.warn(e.getMessage(), e);
        return new ResponseEntity<Integer>(0, headers, HttpStatus.FORBIDDEN);
    }
}

From source file:de.zib.gndms.dspace.service.SliceServiceImpl.java

@Override
@RequestMapping(value = "/_{subspaceId}/_{sliceKindId}/_{sliceId}/_{fileName:.*}", method = RequestMethod.DELETE)
@Secured("ROLE_USER")
public ResponseEntity<Integer> deleteFile(@PathVariable final String subspaceId,
        @PathVariable final String sliceKindId, @PathVariable final String sliceId,
        @PathVariable final String fileName, @RequestHeader("DN") final String dn) {
    GNDMSResponseHeader headers = setHeaders(subspaceId, sliceKindId, sliceId, dn);

    try {//from   ww  w. java 2s .  c  o  m
        Subspace space = subspaceProvider.get(subspaceId);
        Slice slice = findSliceOfKind(subspaceId, sliceKindId, sliceId);
        String path = space.getPathForSlice(slice);

        if (directoryAux.deleteDirectory(dn, path + File.separator + fileName)) {
            return new ResponseEntity<Integer>(0, headers, HttpStatus.OK);
        } else {
            logger.warn("File " + path + " could not be deleted.");
            return new ResponseEntity<Integer>(0, headers, HttpStatus.FORBIDDEN);
        }
    } catch (NoSuchElementException ne) {
        logger.warn(ne.getMessage(), ne);
        return new ResponseEntity<Integer>(0, headers, HttpStatus.NOT_FOUND);
    }
}

From source file:de.steilerdev.myVerein.server.controller.admin.DivisionManagementController.java

/**
 * This function moves the selected division (and all subdivisions) to a new parent. The function evaluates if the user is allowed to perform this action.
 * @param selectedDivision The division that needs to be moved.
 * @param newParent The new parent for the division.
 * @param currentUser The currently logged in user.
 * @return An HTTP response with a status code. If an error occurred an error message is bundled into the response, otherwise a success message is available.
 *//*from  w w  w. ja va 2s  .com*/
private ResponseEntity<String> changeDivisionParent(Division selectedDivision, Division newParent,
        User currentUser) {
    logger.debug("Changing layout: " + selectedDivision.getName() + " moved to parent " + newParent.getName());

    //The moved node and the target need to be administrated by the user. The nodes should not be root nodes of the user's administration.
    if (currentUser.isAllowedToAdministrate(newParent, divisionRepository)
            && currentUser.isAllowedToAdministrate(selectedDivision, divisionRepository)) {
        logger.debug("Changing structure.");
        updateSubtree(selectedDivision, newParent);
        logger.debug("Successfully changed structure");
        return new ResponseEntity<>("Successfully updated division tree", HttpStatus.OK);
    } else {
        logger.warn("The user " + currentUser.getEmail() + " is not allowed to move the node");
        return new ResponseEntity<>("You are not allowed to move the node", HttpStatus.FORBIDDEN);
    }
}

From source file:de.hska.ld.content.controller.DocumentControllerIntegrationTest.java

@Test
public void removeUserPermissions() throws Exception {
    // create userA
    User userA = CoreUtil.newUser();/*w  ww  . j a v a 2s  .  co  m*/
    HttpResponse responseA = UserSession.admin().post(RESOURCE_USER, userA);
    Assert.assertEquals(HttpStatus.CREATED, ResponseHelper.getStatusCode(responseA));
    UserSession userASession = new UserSession();
    userASession = userASession.login(userA.getUsername(), DEFAULT_PASSWORD);

    // create userB
    User userB = CoreUtil.newUser();
    HttpResponse responseB = UserSession.admin().post(RESOURCE_USER, userB);
    Assert.assertEquals(HttpStatus.CREATED, ResponseHelper.getStatusCode(responseB));
    userB = ResponseHelper.getBody(responseB, User.class);
    UserSession userBSession = new UserSession();
    Assert.assertNotNull(userB);
    userBSession = userBSession.login(userB.getUsername(), DEFAULT_PASSWORD);

    // userA adds document
    HttpResponse addDocument = userASession.post(RESOURCE_DOCUMENT, document);
    Assert.assertEquals(HttpStatus.CREATED, ResponseHelper.getStatusCode(addDocument));
    Document respondedDocument = ResponseHelper.getBody(addDocument, Document.class);
    Assert.assertNotNull(respondedDocument);
    Assert.assertNotNull(respondedDocument.getId());

    // userA removes permission for userB
    HttpResponse removePermission = userASession
            .delete(RESOURCE_DOCUMENT + "/" + respondedDocument.getId() + "/access/users/" + userB.getId());
    Assert.assertEquals(HttpStatus.OK, ResponseHelper.getStatusCode(removePermission));

    // userB should not be able to READ
    HttpResponse readDocument = userBSession.get(RESOURCE_DOCUMENT + "/" + respondedDocument.getId());
    Assert.assertEquals(HttpStatus.FORBIDDEN, ResponseHelper.getStatusCode(readDocument));

    // userB should not be able to WRITE
    HttpResponse updateDocument = userBSession.put(RESOURCE_DOCUMENT + "/" + respondedDocument.getId(),
            respondedDocument);
    Assert.assertEquals(HttpStatus.FORBIDDEN, ResponseHelper.getStatusCode(updateDocument));
}

From source file:org.craftercms.profile.services.ProfileServiceIT.java

@Test
@DirtiesContext//from w w  w  .  j a  v  a  2 s. c o  m
public void testUpdateAttributes() throws Exception {
    // Update a bunch attributes
    Profile profile = profileService.createProfile(DEFAULT_TENANT, AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD1,
            AVASQUEZ_EMAIL1, false, AVASQUEZ_ROLES1, null, VERIFICATION_URL);
    Map<String, Object> attributes = new HashMap<>();
    try {
        Map<String, Object> subscriptions = new HashMap<>();
        subscriptions.put("frequency", JDOE_SUBSCRIPTIONS_FREQUENCY);
        subscriptions.put("autoWatch", JDOE_SUBSCRIPTIONS_AUTO_WATCH);
        subscriptions.put("targets", JDOE_SUBSCRIPTIONS_TARGETS);

        attributes.put("subscriptions", subscriptions);

        profile = profileService.updateAttributes(profile.getId().toString(), attributes);
        attributes = profile.getAttributes();

        assertNotNull(attributes);
        assertEquals(1, attributes.size());

        subscriptions = (Map<String, Object>) attributes.get("subscriptions");

        assertNotNull(subscriptions);
        assertEquals(3, subscriptions.size());
        assertEquals(JDOE_SUBSCRIPTIONS_FREQUENCY, subscriptions.get("frequency"));
        assertEquals(JDOE_SUBSCRIPTIONS_AUTO_WATCH, subscriptions.get("autoWatch"));
        assertEquals(JDOE_SUBSCRIPTIONS_TARGETS, subscriptions.get("targets"));

        accessTokenIdResolver.setAccessTokenId(RANDOM_APP_ACCESS_TOKEN_ID);

        // Unallowed updates should be rejected
        try {
            profileService.updateAttributes(profile.getId().toString(), attributes);
            fail("Exception " + ProfileRestServiceException.class.getName() + " expected");
        } catch (ProfileRestServiceException e) {
            assertEquals(HttpStatus.FORBIDDEN, e.getStatus());
            assertEquals(ErrorCode.ACTION_DENIED, e.getErrorCode());
        }
    } finally {
        profileService.deleteProfile(profile.getId().toString());
    }
}

From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.SpringApiClientImplIntegrationTest.java

/**
 * Tests {@link SpringApiClientImpl#getMyChannels} in the case where HTTP response code 403 Forbidden is returned.
 * This can occur if the requesting API user is not permitted to access the requested BrightTALK Channel.
 *//*from   w w w.  j  a va 2  s.  c  o m*/
@Test
public void getChannelSubscribersWhenAuthorisationFails() {
    int channelId = 1;
    String expectedTemplateRequestUrl = this.apiClient.getApiServiceBaseUri()
            + ChannelSubscribersResource.RELATIVE_URI_TEMPLATE;
    String expectedRequestUrl = new UriTemplate(expectedTemplateRequestUrl).expand(channelId).toString();

    ApiError apiError = new ApiError("NotAuthorisedForChannel",
            "Not authorised for channel [" + channelId + "].");
    String responseBody = apiErrorToXml(apiError);

    // Configure mock API service to respond to API call with a canned collection of API resources read from file
    this.mockReportingApiService.expect(method(HttpMethod.GET)).andExpect(requestTo(expectedRequestUrl))
            .andRespond(
                    withStatus(HttpStatus.FORBIDDEN).body(responseBody).contentType(MediaType.APPLICATION_XML));

    try {
        this.apiClient.getChannelSubscribers(channelId, null, null, null, null);
        fail("Expected exception to be thrown.");
    } catch (ApiErrorResponseException e) {
        assertThat(e.getStatusCode(), is(HttpStatus.FORBIDDEN.value()));
        assertThat(e.getApiError(), is(apiError));
    }

    this.mockReportingApiService.verify();
}

From source file:org.craftercms.profile.services.ProfileServiceIT.java

@Test
@DirtiesContext/*  w w w  .  j  a  v a2  s  .c  om*/
public void testDeleteAttributes() throws Exception {
    Profile profile = profileService.createProfile(DEFAULT_TENANT, AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD1,
            AVASQUEZ_EMAIL1, false, AVASQUEZ_ROLES1, null, VERIFICATION_URL);
    Map<String, Object> attributes = new HashMap<>();
    try {
        Map<String, Object> subscriptions = new HashMap<>();
        subscriptions.put("frequency", JDOE_SUBSCRIPTIONS_FREQUENCY);
        subscriptions.put("autoWatch", JDOE_SUBSCRIPTIONS_AUTO_WATCH);
        subscriptions.put("targets", JDOE_SUBSCRIPTIONS_TARGETS);

        attributes.put("subscriptions", subscriptions);

        profileService.updateAttributes(profile.getId().toString(), attributes);

        accessTokenIdResolver.setAccessTokenId(RANDOM_APP_ACCESS_TOKEN_ID);

        // Unallowed deletes should be rejected
        try {
            profileService.removeAttributes(profile.getId().toString(), Arrays.asList("subscriptions"));
            fail("Exception " + ProfileRestServiceException.class.getName() + " expected");
        } catch (ProfileRestServiceException e) {
            assertEquals(HttpStatus.FORBIDDEN, e.getStatus());
            assertEquals(ErrorCode.ACTION_DENIED, e.getErrorCode());
        }

        accessTokenIdResolver.setAccessTokenId(ADMIN_CONSOLE_ACCESS_TOKEN_ID);

        // Delete an attribute
        profile = profileService.removeAttributes(profile.getId().toString(), Arrays.asList("subscriptions"));
        attributes = profile.getAttributes();

        assertNotNull(attributes);
        assertEquals(0, attributes.size());
    } finally {
        profileService.deleteProfile(profile.getId().toString());
    }
}

From source file:org.eclipse.cft.server.core.internal.client.CloudFoundryServerBehaviour.java

/**
 * Called by getClient(...) to prompt the user and reacquire token with
 * passcode, if an exception occurs while connecting with SSO
 *//*from   w ww .  ja v  a 2s. c o m*/
private void reestablishSsoSessionIfNeeded(CloudFoundryException e, CloudFoundryServer cloudServer)
        throws CoreException {
    // Status Code: 401 / Description = Invalid Auth Token, or;
    // Status Code: 403 / Description: Access token denied.
    if (cloudServer.isSso()
            && (e.getStatusCode() == HttpStatus.UNAUTHORIZED || e.getStatusCode() == HttpStatus.FORBIDDEN)) {
        boolean result = CloudFoundryPlugin.getCallback().ssoLoginUserPrompt(cloudServer);
        if (client != null) {
            // Success: another thread has established the client.
            return;
        }

        if (result) {
            // Client is null but the login did succeed, so recreate w/ new
            // token stored in server
            CloudCredentials credentials = CloudUtil.createSsoCredentials(cloudServer.getPasscode(),
                    cloudServer.getToken());
            client = createClientWithCredentials(cloudServer.getUrl(), credentials,
                    cloudServer.getCloudFoundrySpace(), cloudServer.isSelfSigned());
            return;
        }
    }

    // Otherwise, rethrow the exception
    throw e;

}

From source file:com.ephesoft.dcma.webservice.util.WebServiceHelper.java

/**
 * Method to extract all required fields and process request.
 * //from  w  ww.j a v  a2 s .  co  m
 * @param req {@link HttpServletRequest} the request header for web service hit.
 * @throws InternalServerException
 * @throws ValidationException
 */
public void processCopyBatchClass(final HttpServletRequest req)
        throws InternalServerException, ValidationException {
    String respStr = WebServiceConstants.EMPTY_STRING;
    String workingDir = WebServiceConstants.EMPTY_STRING;
    if (req instanceof DefaultMultipartHttpServletRequest) {
        try {
            final String webServiceFolderPath = batchSchemaService.getWebServicesFolderPath();
            workingDir = WebServiceUtil.createWebServiceWorkingDir(webServiceFolderPath);
            final DefaultMultipartHttpServletRequest multiPartRequest = (DefaultMultipartHttpServletRequest) req;
            final MultiValueMap<String, MultipartFile> fileMap = multiPartRequest.getMultiFileMap();
            LOGGER.info("Retreiving xml file.");
            if (respStr.isEmpty()) {
                String xmlFileName = WebServiceConstants.EMPTY_STRING;
                xmlFileName = getXMLFile(workingDir, multiPartRequest, fileMap);
                WebServiceParams webServiceParams = null;
                final File xmlFile = new File(workingDir + File.separator + xmlFileName);
                if (xmlFile.exists()) {
                    LOGGER.info("Input xml file found, retrieving the parameters from it.");
                    final FileInputStream inputStream = new FileInputStream(xmlFile);
                    final Source source = XMLUtil.createSourceFromStream(inputStream);
                    webServiceParams = (WebServiceParams) batchSchemaDao.getJAXB2Template().getJaxb2Marshaller()
                            .unmarshal(source);
                } else {
                    createAndThrowMissingXmlException(WebServiceConstants.INPUT_XML_NOT_FOUND_CODE,
                            WebServiceConstants.INPUT_XML_NOT_FOUND_MESSAGE);
                }
                final List<Param> paramList = webServiceParams.getParams().getParam();
                if (paramList == null || paramList.isEmpty()) {
                    final HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
                    final RestError restError = new RestError(status,
                            WebServiceConstants.PARAMETER_XML_INCORRECT_CODE,
                            WebServiceConstants.PARAMETER_XML_INCORRECT_MESSAGE,
                            WebServiceConstants.PARAMETER_XML_INCORRECT_MESSAGE
                                    + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                            WebServiceConstants.DEFAULT_URL);
                    LOGGER.error(status + WebServiceConstants.PARAMETER_XML_INCORRECT_MESSAGE);
                    throw new ValidationException(WebServiceConstants.PARAMETER_XML_INCORRECT_MESSAGE,
                            restError);
                } else {
                    LOGGER.info("Initializing input parameters.");
                    String batchClassName = WebServiceConstants.EMPTY_STRING;
                    String batchClassDescription = WebServiceConstants.EMPTY_STRING;
                    String batchClassPriority = WebServiceConstants.EMPTY_STRING;
                    String uncFolderName = WebServiceConstants.EMPTY_STRING;
                    String batchClassIdentifier = WebServiceConstants.EMPTY_STRING;
                    String gridWorkflow = WebServiceConstants.EMPTY_STRING;
                    for (final Param param : paramList) {
                        if ((WebServiceConstants.BATCH_CLASS_NAME).equalsIgnoreCase(param.getName())) {
                            batchClassName = param.getValue().trim();
                            LOGGER.info("Batch class name entered is :" + batchClassName);
                            continue;
                        }
                        if ((WebServiceConstants.BATCH_CLASS_DESCRIPTION).equalsIgnoreCase(param.getName())) {
                            batchClassDescription = param.getValue().trim();
                            LOGGER.info("Batch class description given is :" + batchClassDescription);
                            continue;
                        }
                        if ((WebServiceConstants.BATCH_CLASS_PRIORITY).equalsIgnoreCase(param.getName())) {
                            batchClassPriority = param.getValue().trim();
                            LOGGER.info("Batch class priority entered is :" + batchClassPriority);
                            continue;
                        }
                        if ((WebServiceConstants.BATCH_UNC_FOLDER_NAME).equalsIgnoreCase(param.getName())) {
                            uncFolderName = param.getValue().trim();
                            LOGGER.info("UNC folder path entered is : " + uncFolderName);
                            continue;
                        }
                        if ((WebServiceConstants.COPY_BATCH_CLASS_IDENTIFIER)
                                .equalsIgnoreCase(param.getName())) {
                            batchClassIdentifier = param.getValue().trim();
                            LOGGER.info("Batch class identifier used for copying batch class is :"
                                    + batchClassIdentifier);
                            continue;
                        }
                        if ((WebServiceConstants.IS_GRIDWORKFLOW).equalsIgnoreCase(param.getName())) {
                            gridWorkflow = param.getValue().trim();
                            LOGGER.info("Grid workflow is :" + gridWorkflow);
                            continue;
                        }
                    }
                    // Validation for batch class creation parameters
                    // provided.
                    LOGGER.info("Validating parameters.");
                    respStr = validateCreateBatchClassParameters(batchClassName, batchClassDescription,
                            batchClassPriority, uncFolderName, batchClassIdentifier, gridWorkflow);
                    // verify for unique entries for batch class and unc
                    // folders.
                    if (respStr.isEmpty()) {
                        respStr = validateBatchClassAndUNC(batchClassName, uncFolderName, batchClassIdentifier);
                        if (respStr.isEmpty()) {
                            // After validation creating batch class.
                            Set<String> superAdminGroups = userConnectivityService.getAllSuperAdminGroups();
                            if (superAdminGroups != null && !superAdminGroups.isEmpty()) {
                                performBatchClassCreation(batchClassName, batchClassDescription,
                                        batchClassPriority, uncFolderName, batchClassIdentifier,
                                        superAdminGroups.toArray()[0].toString());
                                BatchClass batchClass = batchClassService
                                        .getBatchClassbyUncFolder(uncFolderName);
                                List<BatchClassGroups> assignedRoles = new ArrayList<BatchClassGroups>();
                                BatchClassGroups bcGrup = new BatchClassGroups();
                                bcGrup.setBatchClass(batchClass);
                                for (int itr = 1; itr < superAdminGroups.size(); itr++) {
                                    bcGrup.setGroupName(superAdminGroups.toArray()[itr].toString());
                                }
                                assignedRoles.add(bcGrup);
                                // batchClass.setAssignedGroups(assignedRoles);
                                batchClassService.saveOrUpdate(batchClass);
                                // JIRA-BUG-ID-11125
                                deploymentService.createAndDeployProcessDefinition(batchClass, false);
                            } else {
                                respStr = "Error in retreving admin groups.Please check user-connectivity settings.";
                                final HttpStatus status = HttpStatus.FORBIDDEN;
                                final RestError restError = new RestError(status,
                                        WebServiceConstants.ADMIN_ROLES_NOT_FOUND, respStr,
                                        WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                                        WebServiceConstants.DEFAULT_URL);
                                LOGGER.error(
                                        "Error in retreving admin groups.Please check user-connectivity settings"
                                                + status);
                                throw new ValidationException(respStr, restError);
                            }
                        } else {
                            final HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY;
                            final RestError restError = new RestError(status,
                                    WebServiceConstants.VALIDATION_EXCEPTION_CODE, respStr,
                                    WebServiceConstants.VALIDATION_EXCEPTION_MESSAGE
                                            + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                                    WebServiceConstants.DEFAULT_URL);
                            LOGGER.error(respStr + WebServiceConstants.HTTP_STATUS + status);
                            throw new ValidationException(respStr, restError);
                        }
                    } else {
                        final HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY;
                        final RestError restError = new RestError(status,
                                WebServiceConstants.VALIDATION_EXCEPTION_CODE, respStr,
                                WebServiceConstants.CLASS_WEB_SERVICE_UTILITY, WebServiceConstants.DEFAULT_URL);
                        LOGGER.error("Error in Validating Input XML " + respStr + status);
                        throw new ValidationException(respStr, restError);
                    }
                }
            }
        } catch (org.xml.sax.SAXParseException Ex) {
            respStr = "Error in Parsing Input XML.Please try again";
            final RestError restError = new RestError(HttpStatus.UNPROCESSABLE_ENTITY,
                    WebServiceConstants.INPUT_XML_NOT_ABLE_TO_PARSE_CODE, respStr,
                    WebServiceConstants.INPUT_XML_NOT_ABLE_TO_PARSE_MESSAGE
                            + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                    WebServiceConstants.DEFAULT_URL);
            LOGGER.error("Error response at server:" + respStr);
            throw new ValidationException(respStr, restError);
        } catch (final FileNotFoundException fe) {
            respStr = "Input XMl file is not found.Please try again";
            final RestError restError = new RestError(HttpStatus.NOT_FOUND,
                    WebServiceConstants.INPUT_XML_NOT_FOUND_CODE, respStr,
                    WebServiceConstants.INPUT_XML_NOT_FOUND_MESSAGE
                            + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                    WebServiceConstants.DEFAULT_URL);
            LOGGER.error("Error response at server:" + respStr + fe);
            throw new ValidationException(WebServiceConstants.INTERNAL_SERVER_ERROR_MESSAGE, restError);
        } catch (ValidationException validationException) {
            throw validationException;
        } catch (InternalServerException validationException) {
            throw validationException;
        } catch (final Exception exception) {
            final HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
            respStr = WebServiceConstants.INTERNAL_SERVER_ERROR_MESSAGE + exception;
            final RestError restError = new RestError(status, WebServiceConstants.INTERNAL_SERVER_ERROR_CODE,
                    respStr, respStr + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY,
                    WebServiceConstants.DEFAULT_URL);
            LOGGER.error("Error response at server:" + respStr + exception);
            throw new InternalServerException(respStr, restError);
        } finally {
            if (!workingDir.isEmpty()) {
                FileUtils.deleteDirectoryAndContentsRecursive(new File(workingDir).getParentFile());
            }
        }
    } else {
        final HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY;
        final RestError restError = new RestError(status, WebServiceConstants.VALIDATION_EXCEPTION_CODE,
                WebServiceConstants.INPUT_FILES_NOT_FOUND_MESSAGE,
                respStr + WebServiceConstants.CLASS_WEB_SERVICE_UTILITY, WebServiceConstants.DEFAULT_URL);
        LOGGER.error(respStr + WebServiceConstants.HTTP_STATUS + status);
        throw new ValidationException(respStr, restError);
    }
}