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.geoserver.rest.security.AbstractAclController.java

protected void putMap(Map map) throws Exception {
    validateMap(map);/*w w  w.  j  ava 2  s. c o  m*/
    Set<Object> nonExisting = nonExistingKeys(map);

    if (!nonExisting.isEmpty()) {
        String msg = "Unknown rules: " + StringUtils.join(nonExisting.iterator(), ",");
        throw new RestException(msg, HttpStatus.CONFLICT);
    }

    for (Object entry : map.entrySet()) {
        Comparable rule = convertEntryToRule((Entry<String, String>) entry);
        // TODO, will not work for REST
        ruleDAO.removeRule(rule);
        ruleDAO.addRule(rule);
    }
    ruleDAO.storeRules();
}

From source file:org.kaaproject.kaa.server.control.ControlServerCTLSchemaIT.java

@Test
public void promoteScopeToTenantWithDependenciesInAppScopeTest() throws Exception {
    ApplicationDto application = createApplication(tenantAdminDto);
    loginTenantDeveloper(tenantDeveloperUser);

    CTLSchemaDto dep = createCTLSchema(ctlRandomFieldType(), CTL_DEFAULT_NAMESPACE, 1,
            tenantDeveloperDto.getTenantId(), application.getApplicationToken(), null, null);
    String fqn = dep.getMetaInfo().getFqn();
    int version = dep.getVersion();
    Map<String, String> fields = ImmutableMap.of("test", fqn);
    Set<FqnVersion> deps = ImmutableSet.of(new FqnVersion(fqn, version));
    CTLSchemaDto schema = createCTLSchema(ctlRandomFieldType(), CTL_DEFAULT_NAMESPACE, 1,
            tenantDeveloperDto.getTenantId(), application.getApplicationToken(), deps, fields);

    final CTLSchemaMetaInfoDto metaInfo = schema.getMetaInfo();

    checkRestErrorStatusCode(new TestRestCall() {
        @Override//from   ww w .ja  v a 2s  .co  m
        public void executeRestCall() throws Exception {
            client.promoteScopeToTenant(metaInfo.getApplicationId(), metaInfo.getFqn());
        }
    }, HttpStatus.CONFLICT);
}

From source file:org.springframework.xd.dirt.rest.RestControllerAdvice.java

@ResponseBody
@ExceptionHandler/*from ww  w  .  j  a  v  a  2s .c  om*/
@ResponseStatus(HttpStatus.CONFLICT)
public VndErrors onModuleAlreadyExistsException(ModuleAlreadyExistsException e) {
    String logref = logDebug(e);
    return new VndErrors(logref, e.getMessage());
}

From source file:org.talend.dataprep.api.service.command.folder.RemoveFolder.java

/**
 * Remove a folder/* w  ww. j a  va 2 s  .  c o  m*/
 *
 * @param id the folder id to remove.
 */
public RemoveFolder(final String id) {
    super(GenericCommand.DATASET_GROUP);
    execute(() -> onExecute(id));
    onError(e -> new TDPException(UNABLE_TO_DELETE_FOLDER, e, ExceptionContext.build()));
    on(OK).then((req, resp) -> getResponseEntity(HttpStatus.OK, resp));
    on(CONFLICT).then((req, resp) -> getResponseEntity(HttpStatus.CONFLICT, resp));
}

From source file:sg.ncl.DataController.java

private ResponseEntity<String> getStringResponseEntity(ExceptionState exceptionState) {
    switch (exceptionState) {
    case DATA_NOT_FOUND_EXCEPTION:
        log.warn("Dataset not found for uploading resource.");
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Dataset not found for uploading resource.");
    case DATA_RESOURCE_ALREADY_EXISTS_EXCEPTION:
        log.warn("Data resource already exist.");
        return ResponseEntity.status(HttpStatus.CONFLICT).body("Data resource already exist");
    case FORBIDDEN_EXCEPTION:
        log.warn("Uploading of dataset resource forbidden.");
        return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Uploading of dataset resource forbidden.");
    case UPLOAD_ALREADY_EXISTS_EXCEPTION:
        log.warn("Upload of data resource already exist.");
        return ResponseEntity.status(HttpStatus.CONFLICT).body("Upload of data resource already exist.");
    default://from w  ww. ja v a2  s .  c o m
        log.warn("Unknown exception while uploading resource.");
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body("Unknown exception while uploading resource.");
    }
}