Example usage for org.springframework.http HttpStatus CONFLICT

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

Introduction

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

Prototype

HttpStatus CONFLICT

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

Click Source Link

Document

409 Conflict .

Usage

From source file:org.terasoluna.gfw.functionaltest.app.codelist.CodeListController.java

@ExceptionHandler(BusinessException.class)
@ResponseStatus(HttpStatus.CONFLICT)
public ModelAndView handleBusinessException(BusinessException e) {
    ExtendedModelMap modelMap = new ExtendedModelMap();
    modelMap.addAttribute(e.getResultMessages());
    modelMap.addAttribute(setUpCodeListForm());
    return new ModelAndView("codelist/10_01_form", modelMap);
}

From source file:org.cloudfoundry.identity.uaa.oauth.ClientAdminEndpoints.java

@ExceptionHandler(ClientAlreadyExistsException.class)
public ResponseEntity<InvalidClientDetailsException> handleClientAlreadyExists(ClientAlreadyExistsException e) {
    incrementErrorCounts(e);/*from w  w w .ja  va2 s . c  o  m*/
    return new ResponseEntity<InvalidClientDetailsException>(new InvalidClientDetailsException(e.getMessage()),
            HttpStatus.CONFLICT);
}

From source file:de.zib.gndms.GORFX.service.TaskFlowServiceImpl.java

@RequestMapping(value = "/_{type}/_{id}/task", method = RequestMethod.PUT)
@Secured("ROLE_USER")
public ResponseEntity<Specifier<Facets>> createTask(@PathVariable String type, @PathVariable String id,
        @RequestParam(value = "quote", required = false) Integer quoteId, @RequestHeader("DN") String dn,
        @RequestHeader("WId") String wid) {

    HttpStatus hs = HttpStatus.NOT_FOUND;

    WidAux.initWid(wid);//from   w  w  w  .j  a v a2s .co m
    logger.debug("create task called");
    HttpHeaders headers = getHeader(type, id, "task", dn, wid);
    if (taskFlowProvider.exists(type)) {
        TaskFlowFactory tff = taskFlowProvider.getFactoryForTaskFlow(type);
        TaskFlow tf = tff.find(id);
        if (tf != null) {
            if (tf.getTaskling() != null)
                hs = HttpStatus.CONFLICT;
            else {
                tf.getOrder().setSecurityContextHolder(
                        new SpringSecurityContextHolder(SecurityContextHolder.getContext()));
                TaskAction ta;
                Taskling taskling;
                if (tf.hasQuotes()) {
                    logger.debug("submitting using quote: " + quoteId);
                    ta = tff.createAction((Quote) tf.getQuotes().get(quoteId == null ? 0 : quoteId));
                    taskling = submitTaskActionWithQuotes(quoteId, tf, ta, wid);
                } else {
                    ta = tff.createAction();
                    taskling = executorService.submitTaskAction(dao, ta, tf.getOrder(), wid);
                }
                hs = HttpStatus.CREATED;
                Specifier<Facets> spec = null;
                try {
                    spec = TaskClient.TaskServiceAux.getTaskSpecifier(taskClient, taskling.getId(), uriFactory,
                            taskFlowUriMap(type, id), dn);
                } catch (Exception e) {
                    logger.warn("Exception while getting task", e);
                }

                return new ResponseEntity<Specifier<Facets>>(spec, headers, hs);
            }
        }
    }
    logger.debug("Problem, returning " + hs.name());
    WidAux.removeWid();
    return new ResponseEntity<Specifier<Facets>>(null, headers, hs);
}

From source file:de.codecentric.batch.web.JobOperationsController.java

@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler({ UnexpectedJobExecutionException.class, JobInstanceAlreadyExistsException.class,
        JobInstanceAlreadyCompleteException.class })
public String handleAlreadyExists(Exception ex) {
    LOG.warn("JobInstance or JobExecution already exists.", ex);
    return ex.getMessage();
}

From source file:de.codecentric.batch.web.JobOperationsController.java

@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler({ JobExecutionAlreadyRunningException.class, JobExecutionAlreadyCompleteException.class,
        JobRestartException.class })
public String handleAlreadyRunningOrComplete(Exception ex) {
    LOG.warn("JobExecution already running or complete.", ex);
    return ex.getMessage();
}

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

@Override
@RequestMapping(value = "/_{subspace}/_{sliceKind}/_{slice}/files", method = RequestMethod.DELETE)
@Secured("ROLE_USER")
public ResponseEntity<Integer> deleteFiles(@PathVariable final String subspaceId,
        @PathVariable final String sliceKind, @PathVariable final String sliceId,
        @RequestHeader("DN") final String dn) {
    GNDMSResponseHeader headers = setHeaders(subspaceId, sliceKind, sliceId, dn);

    try {/*from   w  w  w  . j av a2  s . c o  m*/
        Subspace space = subspaceProvider.get(subspaceId);
        Slice slice = findSliceOfKind(subspaceId, sliceKind, sliceId);
        String path = space.getPathForSlice(slice);

        File f = new File(path);
        String[] fl = f.list();
        for (String s : fl) {
            String p = path + File.separatorChar + s;
            if (!directoryAux.deleteDirectory(dn, p)) {
                logger.warn("Some file in directory " + p + " could not be deleted.");
                return new ResponseEntity<Integer>(0, headers, HttpStatus.CONFLICT);
            }
        }
    } catch (NoSuchElementException ne) {
        logger.warn(ne.getMessage());
        return new ResponseEntity<Integer>(0, headers, HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<Integer>(0, headers, HttpStatus.OK);
}

From source file:de.qucosa.webapi.v1.DocumentResource.java

@ExceptionHandler(ResourceConflictException.class)
public ResponseEntity qucosaDocumentExceptionHandler(ResourceConflictException ex) throws XMLStreamException {
    log.error(ex.getMessage());//from  www.j ava2  s .com
    return errorResponse(ex.getMessage(), HttpStatus.CONFLICT);
}

From source file:de.codecentric.batch.web.JobOperationsController.java

@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler(JobExecutionNotRunningException.class)
public String handleNotRunning(Exception ex) {
    LOG.warn("JobExecution is not running.", ex);
    return ex.getMessage();
}

From source file:ca.intelliware.ihtsdo.mlds.web.rest.ApplicationResource.java

@Transactional
@RequestMapping(value = Routes.APPLICATION_REGISTRATION, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@RolesAllowed({ AuthoritiesConstants.USER })
@Timed//w w  w. ja  v a2  s  .  co  m
public @ResponseBody ResponseEntity<Application> submitApplication(@PathVariable long applicationId,
        @RequestBody JsonNode request) {
    PrimaryApplication application = (PrimaryApplication) applicationRepository.findOne(applicationId);
    if (application == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    application = saveApplicationFields(request, application);
    authorizationChecker.checkCanAccessApplication(application);

    // Mark application as submitted
    if (Objects.equal(application.getApprovalState(), ApprovalState.CHANGE_REQUESTED)) {
        application.setApprovalState(ApprovalState.RESUBMITTED);
    } else if (Objects.equal(application.getApprovalState(), ApprovalState.NOT_SUBMITTED)) {
        application.setApprovalState(ApprovalState.SUBMITTED);
    } else {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    }

    application.setSubmittedAt(Instant.now());
    applicationRepository.save(application);

    Affiliate affiliate = application.getAffiliate();
    affiliate.setCreator(application.getUsername());
    affiliate.setApplication(application);
    affiliate.setType(application.getType());
    affiliate.setHomeMember(application.getMember());

    {
        AffiliateDetails affiliateDetails = (AffiliateDetails) application.getAffiliateDetails().clone();
        affiliateDetailsResetter.detach(affiliateDetails);
        affiliate.setAffiliateDetails(affiliateDetails);
    }

    affiliateRepository.save(affiliate);

    applicationAuditEvents.logApprovalStateChange(application);

    if (application.getCommercialUsage() != null
            && Objects.equal(application.getCommercialUsage().getState(), UsageReportState.NOT_SUBMITTED)) {
        commercialUsageService.transitionCommercialUsageApproval(application.getCommercialUsage(),
                UsageReportTransition.SUBMIT);
    }

    return new ResponseEntity<Application>(application, HttpStatus.OK);
}

From source file:ca.intelliware.ihtsdo.mlds.web.rest.ApplicationResource.java

@Transactional
@RequestMapping(value = Routes.APPLICATION_REGISTRATION, method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@RolesAllowed({ AuthoritiesConstants.USER })
@Timed/*from w  w  w.j a  v a  2s.c om*/
public @ResponseBody ResponseEntity<Application> saveApplication(@PathVariable long applicationId,
        @RequestBody JsonNode request) {
    Application application = applicationRepository.findOne(applicationId);
    if (application == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    application = saveApplicationFields(request, application);
    authorizationChecker.checkCanAccessApplication(application);

    ApprovalState preApprovalState = application.getApprovalState();
    // Mark application as not submitted
    if (Objects.equal(application.getApprovalState(), ApprovalState.CHANGE_REQUESTED)) {
        application.setApprovalState(ApprovalState.CHANGE_REQUESTED);
    } else {
        application.setApprovalState(ApprovalState.NOT_SUBMITTED);
    }

    if (!Objects.equal(application.getApprovalState(), preApprovalState)) {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    }

    application.getAffiliate().setAffiliateDetails(application.getAffiliateDetails());

    applicationRepository.save(application);

    return new ResponseEntity<Application>(application, HttpStatus.OK);
}