/**
   * POST /users : Creates a new user.
   *
   * <p>Creates a new user if the login and email are not already used, and sends an mail with an
   * activation link. The user needs to be activated on creation.
   *
   * @param managedUserVM the user to create
   * @return the ResponseEntity with status 201 (Created) and with body the new user, or with status
   *     400 (Bad Request) if the login or email is already in use
   * @throws URISyntaxException if the Location URI syntax is incorrect
   */
  @PostMapping("/users")
  @Timed
  @Secured(AuthoritiesConstants.ADMIN)
  public ResponseEntity<?> createUser(@RequestBody ManagedUserVM managedUserVM)
      throws URISyntaxException {
    log.debug("REST request to save User : {}", managedUserVM);

    // Lowercase the user login before comparing with database
    if (userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase()).isPresent()) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use"))
          .body(null);
    } else if (userRepository.findOneByEmail(managedUserVM.getEmail()).isPresent()) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert(
                  "userManagement", "emailexists", "Email already in use"))
          .body(null);
    } else {
      User newUser = userService.createUser(managedUserVM);
      mailService.sendCreationEmail(newUser);
      return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
          .headers(HeaderUtil.createAlert("userManagement.created", newUser.getLogin()))
          .body(newUser);
    }
  }
  /**
   * PUT /users : Updates an existing User.
   *
   * @param managedUserVM the user to update
   * @return the ResponseEntity with status 200 (OK) and with body the updated user, or with status
   *     400 (Bad Request) if the login or email is already in use, or with status 500 (Internal
   *     Server Error) if the user couldn't be updated
   */
  @PutMapping("/users")
  @Timed
  @Secured(AuthoritiesConstants.ADMIN)
  public ResponseEntity<ManagedUserVM> updateUser(@RequestBody ManagedUserVM managedUserVM) {
    log.debug("REST request to update User : {}", managedUserVM);
    Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
    if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert(
                  "userManagement", "emailexists", "E-mail already in use"))
          .body(null);
    }
    existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
    if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use"))
          .body(null);
    }
    userService.updateUser(
        managedUserVM.getId(),
        managedUserVM.getLogin(),
        managedUserVM.getFirstName(),
        managedUserVM.getLastName(),
        managedUserVM.getEmail(),
        managedUserVM.isActivated(),
        managedUserVM.getLangKey(),
        managedUserVM.getAuthorities());

    return ResponseEntity.ok()
        .headers(HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()))
        .body(new ManagedUserVM(userService.getUserWithAuthorities(managedUserVM.getId())));
  }
示例#3
0
 /** POST /account -> update the current user information. */
 @RequestMapping(
     value = "/account",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<String> saveAccount(@RequestBody UserDTO userDTO) {
   Optional<User> existingUser = userRepository.findOneByEmail(userDTO.getEmail());
   if (existingUser.isPresent()
       && (!existingUser.get().getLogin().equalsIgnoreCase(userDTO.getLogin()))) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "user-management", "emailexists", "Email already in use"))
         .body(null);
   }
   return userRepository
       .findOneByLogin(SecurityUtils.getCurrentUser().getUsername())
       .map(
           u -> {
             userService.updateUserInformation(
                 userDTO.getFirstName(),
                 userDTO.getLastName(),
                 userDTO.getEmail(),
                 userDTO.getLangKey());
             return new ResponseEntity<String>(HttpStatus.OK);
           })
       .orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
 }
 /** POST /evolutionPrescriptions -> Create a new evolutionPrescription. */
 @RequestMapping(
     value = "/episodes/{episode_id}/evolutionPrescriptions",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<EvolutionPrescription> createByEpisode(
     @PathVariable(value = "episode_id") Long episodeId,
     @RequestBody EvolutionPrescription evolutionPrescription)
     throws URISyntaxException {
   log.debug("REST request to save EvolutionPrescription : {}", evolutionPrescription);
   if (evolutionPrescription.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new evolutionPrescription cannot already have an ID")
         .body(null);
   }
   Episode episode = new Episode();
   episode.setId(episodeId);
   evolutionPrescription.setEpisode(episode);
   EvolutionPrescription result = evolutionPrescriptionRepository.save(evolutionPrescription);
   return ResponseEntity.created(
           new URI("/api/episodes/" + episodeId + "/evolutionPrescriptions/" + result.getId()))
       .headers(
           HeaderUtil.createEntityCreationAlert(
               "evolutionPrescription", result.getId().toString()))
       .body(result);
 }
示例#5
0
  /** POST /newss -> Create a new news. */
  @RequestMapping(
      value = "/newss",
      method = RequestMethod.POST,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity<News> createNews(@Valid @RequestBody News news) throws URISyntaxException {
    log.debug("REST request to save News : {}", news);
    if (news.getId() != null) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert(
                  "news", "idexists", "A new news cannot already have an ID"))
          .body(null);
    }
    News result = newsRepository.save(news);
    List<Subscription> subscriptions =
        subscriptionRepository
            .findAll()
            .stream()
            .filter(item -> (item.getIdMarketPlace().equals(result.getMarketPlace().getId())))
            .collect(Collectors.toList());
    String title = result.getMarketPlace().getName() + " vous a envoyé une News !";
    String content = result.getTitle() + "\n\n\n" + result.getContent();

    for (Subscription subscription : subscriptions) {
      mailService.sendEmail(subscription.getUser().getEmail(), title, content, false, false);
    }
    return ResponseEntity.created(new URI("/api/newss/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert("news", result.getId().toString()))
        .body(result);
  }
 /**
  * PUT /users : Updates an existing User.
  *
  * @param managedUserDTO the user to update
  * @return the ResponseEntity with status 200 (OK) and with body the updated user, or with status
  *     400 (Bad Request) if the login or email is already in use, or with status 500 (Internal
  *     Server Error) if the user couldnt be updated
  */
 @RequestMapping(
     value = "/users",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 @Transactional
 @Secured(AuthoritiesConstants.ADMIN)
 public ResponseEntity<ManagedUserDTO> updateUser(@RequestBody ManagedUserDTO managedUserDTO) {
   log.debug("REST request to update User : {}", managedUserDTO);
   Optional<User> existingUser = userRepository.findOneByEmail(managedUserDTO.getEmail());
   if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "userManagement", "emailexists", "E-mail already in use"))
         .body(null);
   }
   existingUser = userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase());
   if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use"))
         .body(null);
   }
   return userRepository
       .findOneById(managedUserDTO.getId())
       .map(
           user -> {
             user.setLogin(managedUserDTO.getLogin());
             user.setFirstName(managedUserDTO.getFirstName());
             user.setLastName(managedUserDTO.getLastName());
             user.setEmail(managedUserDTO.getEmail());
             user.setActivated(managedUserDTO.isActivated());
             user.setLangKey(managedUserDTO.getLangKey());
             Set<Authority> authorities = user.getAuthorities();
             authorities.clear();
             managedUserDTO
                 .getAuthorities()
                 .stream()
                 .forEach(authority -> authorities.add(authorityRepository.findOne(authority)));
             return ResponseEntity.ok()
                 .headers(
                     HeaderUtil.createAlert("userManagement.updated", managedUserDTO.getLogin()))
                 .body(new ManagedUserDTO(userRepository.findOne(managedUserDTO.getId())));
           })
       .orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
 }
  /**
   * POST /users : Creates a new user.
   *
   * <p>Creates a new user if the login and email are not already used, and sends an mail with an
   * activation link. The user needs to be activated on creation.
   *
   * @param managedUserDTO the user to create
   * @param request the HTTP request
   * @return the ResponseEntity with status 201 (Created) and with body the new user, or with status
   *     400 (Bad Request) if the login or email is already in use
   * @throws URISyntaxException if the Location URI syntaxt is incorrect
   */
  @RequestMapping(
      value = "/users",
      method = RequestMethod.POST,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  @Secured(AuthoritiesConstants.ADMIN)
  public ResponseEntity<?> createUser(
      @RequestBody ManagedUserDTO managedUserDTO, HttpServletRequest request)
      throws URISyntaxException {
    log.debug("REST request to save User : {}", managedUserDTO);

    // Lowercase the user login before comparing with database
    if (userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase()).isPresent()) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use"))
          .body(null);
    } else if (userRepository.findOneByEmail(managedUserDTO.getEmail()).isPresent()) {
      return ResponseEntity.badRequest()
          .headers(
              HeaderUtil.createFailureAlert(
                  "userManagement", "emailexists", "Email already in use"))
          .body(null);
    } else {
      User newUser = userService.createUser(managedUserDTO);
      String baseUrl =
          request.getScheme()
              + // "http"
              "://"
              + // "://"
              request.getServerName()
              + // "myhost"
              ":"
              + // ":"
              request.getServerPort()
              + // "80"
              request.getContextPath(); // "/myContextPath" or "" if deployed in root context
      mailService.sendCreationEmail(newUser, baseUrl);
      return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
          .headers(HeaderUtil.createAlert("userManagement.created", newUser.getLogin()))
          .body(newUser);
    }
  }
  @RequestMapping(value = "", method = RequestMethod.PUT)
  @JsonView(View.PrincipalWithManyToOne.class)
  public ResponseEntity<Offender> update(@Valid @RequestBody Offender teacher)
      throws URISyntaxException {
    if (!teacher.getType().equals(OffenderTypeEnum.TEACHER)) {
      return ResponseEntity.badRequest().header("Failure", "This is not a teacher").body(null);
    }

    return super.update(teacher);
  }
  /** POST /register -> register the user. */
  @RequestMapping(
      value = "/register",
      method = RequestMethod.POST,
      produces = MediaType.TEXT_PLAIN_VALUE)
  @Timed
  public ResponseEntity<?> registerAccount(
      @Valid @RequestBody UserDTO userDTO, HttpServletRequest request) {
    User user = userRepository.findOneByLogin(userDTO.getLogin());
    if (user != null) {
      return ResponseEntity.badRequest()
          .contentType(MediaType.TEXT_PLAIN)
          .body("login already in use");
    } else {
      if (userRepository.findOneByEmail(userDTO.getEmail()) != null) {
        return ResponseEntity.badRequest()
            .contentType(MediaType.TEXT_PLAIN)
            .body("e-mail address already in use");
      }
      user =
          userService.createUserInformation(
              userDTO.getLogin(),
              userDTO.getPassword(),
              userDTO.getFirstName(),
              userDTO.getLastName(),
              userDTO.getEmail().toLowerCase(),
              userDTO.getLangKey());
      String baseUrl =
          request.getScheme()
              + // "http"
              "://"
              + // "://"
              request.getServerName()
              + // "myhost"
              ":"
              + // ":"
              request.getServerPort(); // "80"

      mailService.sendActivationEmail(user, baseUrl);
      return new ResponseEntity<>(HttpStatus.CREATED);
    }
  }
 @RequestMapping(value = "${cerberus.route.authentication.refresh}", method = RequestMethod.GET)
 public ResponseEntity<?> authenticationRequest(HttpServletRequest request) {
   String token = request.getHeader(this.tokenHeader);
   String username = this.tokenUtils.getUsernameFromToken(token);
   CerberusUser user = (CerberusUser) this.userDetailsService.loadUserByUsername(username);
   if (this.tokenUtils.canTokenBeRefreshed(token, user.getLastPasswordReset())) {
     String refreshedToken = this.tokenUtils.refreshToken(token);
     return ResponseEntity.ok(new AuthenticationResponse(refreshedToken));
   } else {
     return ResponseEntity.badRequest().body(null);
   }
 }
  private ResponseEntity<?> checkErrors(String location) {
    String[] locationErrors = location.split(";");
    if (Character.isDigit(locationErrors[0].charAt(0))) {
      return ResponseEntity.badRequest()
          .headers(HeaderUtil.createFailureAlert("purchaseOrder", "PayPalError", location))
          .body("{\"error\":\"PayPalError\",\"detail\":\"" + location + "\"}");
      //            return new ResponseEntity<>(locationErrors[1],
      // HttpStatus.valueOf(Integer.valueOf(locationErrors[0])));

    }
    return null;
  }
示例#12
0
 /** POST /group -> Create a new group. */
 @RequestMapping(
     value = "/group",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@RequestBody Group group) throws URISyntaxException {
   log.debug("REST request to save Group : {}", group);
   if (group.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new group cannot already have an ID")
         .build();
   }
   groupRepository.save(group);
   return ResponseEntity.created(new URI("/api/group/" + group.getId())).build();
 }
示例#13
0
 /** POST /orderStatuss -> Create a new orderStatus. */
 @RequestMapping(
     value = "/orderStatuss",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@Valid @RequestBody OrderStatus orderStatus)
     throws URISyntaxException {
   log.debug("REST request to save OrderStatus : {}", orderStatus);
   if (orderStatus.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new orderStatus cannot already have an ID")
         .build();
   }
   orderStatusRepository.save(orderStatus);
   return ResponseEntity.created(new URI("/api/orderStatuss/" + orderStatus.getId())).build();
 }
示例#14
0
 /** POST /prices -> Create a new price. */
 @RequestMapping(
     value = "/prices",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@Valid @RequestBody Price price) throws URISyntaxException {
   log.debug("REST request to save Price : {}", price);
   if (price.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new price cannot already have an ID")
         .build();
   }
   priceRepository.save(price);
   priceSearchRepository.save(price);
   return ResponseEntity.created(new URI("/api/prices/" + price.getId())).build();
 }
示例#15
0
 /** POST /codingSessions -> Create a new codingSession. */
 @RequestMapping(
     value = "/codingSessions",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@RequestBody CodingSession codingSession)
     throws URISyntaxException {
   log.debug("REST request to save CodingSession : {}", codingSession);
   if (codingSession.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new codingSession cannot already have an ID")
         .build();
   }
   codingSessionRepository.save(codingSession);
   return ResponseEntity.created(new URI("/api/codingSessions/" + codingSession.getId())).build();
 }
 /** POST /customers -> Create a new customer. */
 @RequestMapping(
     value = "/customers",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Customer> create(@Valid @RequestBody Customer customer)
     throws URISyntaxException {
   log.debug("REST request to save Customer : {}", customer);
   if (customer.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new customer cannot already have an ID")
         .body(null);
   }
   Customer result = customerRepository.save(customer);
   return ResponseEntity.created(new URI("/api/customers/" + customer.getId())).body(result);
 }
示例#17
0
 /** POST /socios -> Create a new socio. */
 @RequestMapping(
     value = "/socios",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Socio> create(@Valid @RequestBody Socio socio) throws URISyntaxException {
   log.debug("REST request to save Socio : {}", socio);
   if (socio.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new socio cannot already have an ID")
         .body(null);
   }
   Socio result = socioRepository.save(socio);
   return ResponseEntity.created(new URI("/api/socios/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("socio", result.getId().toString()))
       .body(result);
 }
示例#18
0
 /** POST /books -> Create a new book. */
 @RequestMapping(
     value = "/books",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Book> createBook(@RequestBody Book book) throws URISyntaxException {
   log.debug("REST request to save Book : {}", book);
   if (book.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new book cannot already have an ID")
         .body(null);
   }
   Book result = bookRepository.save(book);
   return ResponseEntity.created(new URI("/api/books/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("book", result.getId().toString()))
       .body(result);
 }
示例#19
0
 /** POST /teams -> Create a new team. */
 @RequestMapping(
     value = "/teams",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Team> createTeam(@Valid @RequestBody Team team) throws URISyntaxException {
   log.debug("REST request to save Team : {}", team);
   if (team.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new team cannot already have an ID")
         .body(null);
   }
   Team result = teamRepository.save(team);
   return ResponseEntity.created(new URI("/api/teams/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("team", result.getId().toString()))
       .body(result);
 }
示例#20
0
 /** POST /roles -> Create a new role. */
 @RequestMapping(
     value = "/roles",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Role> createRole(@Valid @RequestBody Role role) throws URISyntaxException {
   log.debug("REST request to save Role : {}", role);
   if (role.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new role cannot already have an ID")
         .body(null);
   }
   Role result = roleRepository.save(role);
   roleSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/roles/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("role", result.getId().toString()))
       .body(result);
 }
 /** POST /clinicHistorys -> Create a new clinicHistory. */
 @RequestMapping(
     value = "/clinicHistorys",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<ClinicHistory> create(@RequestBody ClinicHistory clinicHistory)
     throws URISyntaxException {
   log.debug("REST request to save ClinicHistory : {}", clinicHistory);
   if (clinicHistory.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new clinicHistory cannot already have an ID")
         .body(null);
   }
   ClinicHistory result = clinicHistoryRepository.save(clinicHistory);
   return ResponseEntity.created(new URI("/api/clinicHistorys/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("clinicHistory", result.getId().toString()))
       .body(result);
 }
示例#22
0
 /** POST /accountings -> Create a new accounting. */
 @RequestMapping(
     value = "/accountings",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Accounting> createAccounting(@RequestBody Accounting accounting)
     throws URISyntaxException {
   log.debug("REST request to save Accounting : {}", accounting);
   if (accounting.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new accounting cannot already have an ID")
         .body(null);
   }
   Accounting result = accountingRepository.save(accounting);
   return ResponseEntity.created(new URI("/api/accountings/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("accounting", result.getId().toString()))
       .body(result);
 }
示例#23
0
 /** POST /users -> Create a new user. */
 @RequestMapping(
     value = "/users",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 @Secured(AuthoritiesConstants.ADMIN)
 public ResponseEntity<User> createUser(@RequestBody User user) throws URISyntaxException {
   log.debug("REST request to save User : {}", user);
   if (user.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new user cannot already have an ID")
         .body(null);
   }
   User result = userRepository.save(user);
   return ResponseEntity.created(new URI("/api/users/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("user", result.getId().toString()))
       .body(result);
 }
 /** POST /reponse_joueurs -> Create a new reponse_joueur. */
 @RequestMapping(
     value = "/reponse_joueurs",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Reponse_joueur> createReponse_joueur(
     @RequestBody Reponse_joueur reponse_joueur) throws URISyntaxException {
   log.debug("REST request to save Reponse_joueur : {}", reponse_joueur);
   if (reponse_joueur.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new reponse_joueur cannot already have an ID")
         .body(null);
   }
   Reponse_joueur result = reponse_joueurRepository.save(reponse_joueur);
   return ResponseEntity.created(new URI("/api/reponse_joueurs/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("reponse_joueur", result.getId().toString()))
       .body(result);
 }
 @RequestMapping(
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE,
     consumes = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<?> addTask(@RequestBody Task task) {
   if (taskService.findByTaskTitle(task.getTitle()) != null) {
     LOGGER.warn("title '" + task.getTitle() + "' already in use!");
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "task-managament", "taskexists", "Title already in use"))
         .body(null);
   } else {
     taskService.save(task);
     LOGGER.info("Task '" + task.getTitle() + "' has been added");
     return ResponseEntity.ok().build();
   }
 }
示例#26
0
 /** POST /environments -> Create a new environment. */
 @RequestMapping(
     value = "/environments",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Environment> createEnvironment(@Valid @RequestBody Environment environment)
     throws URISyntaxException {
   log.debug("REST request to save Environment : {}", environment);
   if (environment.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new environment cannot already have an ID")
         .body(null);
   }
   Environment result = environmentRepository.save(environment);
   environmentSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/environments/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("environment", result.getId().toString()))
       .body(result);
 }
 /** POST /proveedoress -> Create a new proveedores. */
 @RequestMapping(
     value = "/proveedoress",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<ProveedoresDTO> createProveedores(
     @Valid @RequestBody ProveedoresDTO proveedoresDTO) throws URISyntaxException {
   log.debug("REST request to save Proveedores : {}", proveedoresDTO);
   if (proveedoresDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new proveedores cannot already have an ID")
         .body(null);
   }
   Proveedores proveedores = proveedoresMapper.proveedoresDTOToProveedores(proveedoresDTO);
   Proveedores result = proveedoresRepository.save(proveedores);
   return ResponseEntity.created(new URI("/api/proveedoress/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("proveedores", result.getId().toString()))
       .body(proveedoresMapper.proveedoresToProveedoresDTO(result));
 }
示例#28
0
 /** POST /fases -> Create a new fase. */
 @RequestMapping(
     value = "/fases",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<FaseDTO> create(@RequestBody FaseDTO faseDTO) throws URISyntaxException {
   log.debug("REST request to save Fase : {}", faseDTO);
   if (faseDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new fase cannot already have an ID")
         .body(null);
   }
   Fase fase = faseMapper.faseDTOToFase(faseDTO);
   Fase result = faseRepository.save(fase);
   faseSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/fases/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("fase", result.getId().toString()))
       .body(faseMapper.faseToFaseDTO(result));
 }
示例#29
0
 /** POST /specialitys -> Create a new speciality. */
 @RequestMapping(
     value = "/specialitys",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Speciality> createSpeciality(@Valid @RequestBody Speciality speciality)
     throws URISyntaxException {
   log.debug("REST request to save Speciality : {}", speciality);
   if (speciality.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new speciality cannot already have an ID")
         .body(null);
   }
   Speciality result = specialityRepository.save(speciality);
   specialitySearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/specialitys/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("speciality", result.getId().toString()))
       .body(result);
 }
 /** POST /ordenCompras -> Create a new ordenCompra. */
 @RequestMapping(
     value = "/ordenCompras",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<OrdenCompraDTO> createOrdenCompra(
     @Valid @RequestBody OrdenCompraDTO ordenCompraDTO) throws URISyntaxException {
   log.debug("REST request to save OrdenCompra : {}", ordenCompraDTO);
   if (ordenCompraDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new ordenCompra cannot already have an ID")
         .body(null);
   }
   OrdenCompra ordenCompra = ordenCompraMapper.ordenCompraDTOToOrdenCompra(ordenCompraDTO);
   OrdenCompra result = ordenCompraRepository.save(ordenCompra);
   return ResponseEntity.created(new URI("/api/ordenCompras/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("ordenCompra", result.getId().toString()))
       .body(ordenCompraMapper.ordenCompraToOrdenCompraDTO(result));
 }