Example usage for org.springframework.http HttpStatus ACCEPTED

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

Introduction

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

Prototype

HttpStatus ACCEPTED

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

Click Source Link

Document

202 Accepted .

Usage

From source file:org.nekorp.workflow.backend.security.controller.imp.UsuarioClienteWebControllerImp.java

/**{@inheritDoc}*/
@Override//w  ww.j  a  v  a  2  s.  c  om
@RequestMapping(value = "/{alias}", method = RequestMethod.DELETE)
public void borrar(@PathVariable final String alias, final HttpServletResponse response) {
    String buscar = StringUtils.lowerCase(alias);
    UsuarioClienteWeb resultado = usuarioClienteWebDAO.consultar(buscar);
    if (resultado == null) {
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;
    }
    usuarioClienteWebDAO.borrar(resultado);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:io.syndesis.runtime.credential.CredentialITCase.java

@Test
public void shouldInitiateCredentialFlow() throws UnsupportedEncodingException {
    final ResponseEntity<AcquisitionResponse> acquisitionResponse = post(
            "/api/v1/connectors/test-provider/credentials", Collections.singletonMap("returnUrl", "/ui#state"),
            AcquisitionResponse.class, tokenRule.validToken(), HttpStatus.ACCEPTED);

    assertThat(acquisitionResponse.hasBody()).as("Should present a acquisition response in the HTTP body")
            .isTrue();/* w  w w  .ja va  2  s .com*/

    final AcquisitionResponse response = acquisitionResponse.getBody();
    assertThat(response.getType()).isEqualTo(Type.OAUTH2);

    final String redirectUrl = response.getRedirectUrl();
    assertThat(redirectUrl).as("Should redirect to Salesforce and containthe correct callback URL")
            .startsWith("https://test/oauth2/authorize?client_id=testClientId&response_type=code&redirect_uri=")
            .contains(encode("/api/v1/credentials/callback", "ASCII"));

    final MultiValueMap<String, String> params = UriComponentsBuilder.fromHttpUrl(redirectUrl).build()
            .getQueryParams();

    final String state = params.getFirst("state");

    assertThat(state).as("state parameter should be set").isNotEmpty();

    final State responseStateInstruction = response.state();
    assertThat(responseStateInstruction).as("acquisition response should contain the state instruction")
            .isNotNull();
    assertThat(responseStateInstruction.persist()).isEqualByComparingTo(State.Persist.COOKIE);
    assertThat(responseStateInstruction.spec()).isNotEmpty();

    final CredentialFlowState credentialFlowState = clientSideState
            .restoreFrom(Cookie.valueOf(responseStateInstruction.spec()), CredentialFlowState.class);

    final CredentialFlowState expected = new OAuth2CredentialFlowState.Builder().key("test-state")
            .providerId("test-provider").build();

    assertThat(credentialFlowState).as("The flow state should be as expected")
            .isEqualToIgnoringGivenFields(expected, "returnUrl");
    final URI returnUrl = credentialFlowState.getReturnUrl();
    assertThat(returnUrl).isNotNull();
    assertThat(returnUrl.isAbsolute()).isTrue();
    assertThat(returnUrl.getPath()).isEqualTo("/ui");
    assertThat(returnUrl.getFragment()).isEqualTo("state");
}

From source file:com.sms.server.controller.AdminController.java

@RequestMapping(value = "/user", method = RequestMethod.PUT, headers = { "Content-type=application/json" })
@ResponseBody/*from ww  w  . ja  va2 s  .c  om*/
public ResponseEntity<String> updateDefaultUser(@RequestBody User update) {
    User user = userDao.getUserByUsername("admin");

    if (user == null) {
        return new ResponseEntity<>("Default user does not exist.", HttpStatus.BAD_REQUEST);
    }

    if (update.getPassword() != null) {
        user.setPassword(update.getPassword());
    }

    // Update database
    if (!userDao.updateUser(user, "admin")) {
        LogService.getInstance().addLogEntry(Level.ERROR, CLASS_NAME,
                "Error updating user '" + user.getUsername() + "'.", null);
        return new ResponseEntity<>("Error updating user details.", HttpStatus.INTERNAL_SERVER_ERROR);
    }

    LogService.getInstance().addLogEntry(Level.INFO, CLASS_NAME,
            "User '" + user.getUsername() + "' updated successfully.", null);
    return new ResponseEntity<>("User details updated successfully.", HttpStatus.ACCEPTED);
}

From source file:org.openbaton.nfvo.vnfm_reg.impl.receiver.VnfmReceiverRest.java

@RequestMapping(value = "vnfm-core-scale", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public NFVMessage scale(@RequestBody VnfmOrScalingMessage message)
        throws InterruptedException, ExecutionException, VimException, NotFoundException {
    return mapper.fromJson(vnfmManager.executeAction(message), OrVnfmGenericMessage.class);
}

From source file:org.openbaton.nfvo.api.RestVNFPackage.java

/**
 * Updates the VNFPackage/*from w  ww .  j  a va  2  s .  c o m*/
 *
 * @param vnfPackage_new : The VNFPackage to be updated
 * @param id : The id of the VNFPackage
 * @return VNFPackage The VNFPackage updated
 */
@RequestMapping(value = "{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public VNFPackage update(@RequestBody @Valid VNFPackage vnfPackage_new, @PathVariable("id") String id,
        @RequestHeader(value = "project-id") String projectId) {
    return vnfPackageManagement.update(id, vnfPackage_new, projectId);
}

From source file:org.createnet.raptor.auth.service.controller.DevicePermissionController.java

@RequestMapping(value = "/{deviceUuid}/permission", method = RequestMethod.PUT)
@ApiOperation(value = "Save user permissions on a device", notes = "", response = String.class, responseContainer = "List", nickname = "setPermissions")
public ResponseEntity<?> setPermission(@RequestBody PermissionRequestBatch body,
        @PathVariable("deviceUuid") String deviceUuid) {

    Device device = deviceService.getByUuid(deviceUuid);
    if (device == null) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Device not found");
    }/*from   w  w w  . ja va2 s  . co m*/

    User user = userService.getByUuid(body.user);
    if (user == null) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found");
    }

    List<Permission> permissions = body.permissions.stream().map((String s) -> {
        Permission p = RaptorPermission.fromLabel(s);
        if (p == null) {
            throw new PermissionNotFoundException("Permission not found ");
        }
        return p;
    }).distinct().collect(Collectors.toList());

    aclDeviceService.set(device, user, permissions);
    List<String> settedPermissions = RaptorPermission.toLabel(aclDeviceService.list(device, user));

    return ResponseEntity.status(HttpStatus.ACCEPTED).body(settedPermissions);
}

From source file:org.nekorp.workflow.backend.controller.imp.AutoControllerImp.java

@Override
@RequestMapping(value = "/{numeroSerie}", method = RequestMethod.DELETE)
public void borrarAuto(@PathVariable final String numeroSerie, final HttpServletResponse response) {
    Auto dato = this.autoDAO.consultar(this.stringStandarizer.standarize(numeroSerie));
    if (dato == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;//from www  . ja v a2 s .  c  o m
    }
    autoDAO.borrar(dato);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java

/**
 * This operation updates the Network Service Descriptor (NSD)
 *
 * @param networkServiceDescriptor : the Network Service Descriptor to be updated
 * @param id : the id of Network Service Descriptor
 * @return networkServiceDescriptor: the Network Service Descriptor updated
 *//*from w w w .  j a v  a2  s.com*/
@RequestMapping(value = "{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public NetworkServiceDescriptor update(@RequestBody @Valid NetworkServiceDescriptor networkServiceDescriptor,
        @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) {
    return networkServiceDescriptorManagement.update(networkServiceDescriptor, projectId);
}

From source file:org.nekorp.workflow.backend.controller.imp.EventoControllerImp.java

@Override
@RequestMapping(value = "/{idEvento}", method = RequestMethod.DELETE)
public void borrarEvento(@PathVariable final Long idServicio, @PathVariable final Long idEvento,
        final HttpServletResponse response) {
    if (!idServicioValido(idServicio)) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;/*  ww  w .j av  a 2  s  .  co  m*/
    }
    Evento dato = eventoDAO.consultar(idServicio, idEvento);
    if (dato == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;
    }
    eventoDAO.borrar(idServicio, dato);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:org.fineract.module.stellar.StellarBridgeTestHelpers.java

public static void makePayment(final String fromTenant, final String fromTenantApiKey, final String toTenant,
        final String assetCode, final BigDecimal transferAmount) {
    makePaymentExpectStatus(fromTenant, fromTenantApiKey, toTenant, assetCode, transferAmount,
            HttpStatus.ACCEPTED);
}