Java 类com.codahale.metrics.annotation.Timed 实例源码

项目:cas-server-4.2.1    文件:AbstractCentralAuthenticationService.java   
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
项目:Armory    文件:UserResource.java   
/**
 * 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.
 * </p>
 *
 * @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(ENTITY_NAME, "userexists", "Login already in use"))
            .body(null);
    } else if (userRepository.findOneByEmail(managedUserVM.getEmail()).isPresent()) {
        return ResponseEntity.badRequest()
            .headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "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);
    }
}
项目:shoucang    文件:TagsController.java   
/**
 * 我的关注标签
 */
@RequestMapping(value = "/me/tags/following", method = GET)
@Timed
public String followed(Model model, @RequestParam(defaultValue = "1") int page) {
    Long userId = userService.getCurrentUserId();
    long size = tagService.countUserFollowedTags(userId);
    long pages = size / PAGE_SIZE + (size % PAGE_SIZE != 0 ? 1 : 0);
    page = page < 1 ? 1 : page - 1;

    List<Tag> tags = tagService.getUserTags(page, PAGE_SIZE, userId);

    model.addAttribute("tags", tags);
    model.addAttribute("page", page + 1);
    model.addAttribute("totalPages", pages);

    return "tags/followed_tags";
}
项目:springboot-shiro-cas-mybatis    文件:CentralAuthenticationServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
项目:verify-hub    文件:TransactionsConfigProxy.java   
@Timed
public ResourceLocation getAssertionConsumerServiceUri(String entityId, Optional<Integer> assertionConsumerServiceIndex) {

    ImmutableMap<String, String> queryParams = ImmutableMap.of();

    if (assertionConsumerServiceIndex.isPresent()) {
        queryParams = ImmutableMap.of(
                Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_INDEX_PARAM,
                assertionConsumerServiceIndex.get().toString());
    }
    final URI uri = getEncodedUri(Urls.ConfigUrls.TRANSACTIONS_ASSERTION_CONSUMER_SERVICE_URI_RESOURCE, queryParams, entityId);
    try {
        return resourceLocation.getUnchecked(uri);
    } catch (UncheckedExecutionException e) {
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
项目:qualitoast    文件:UserResource.java   
/**
 * 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 userDTO 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
 * @throws BadRequestAlertException 400 (Bad Request) if the login or email is already in use
 */
@PostMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<User> createUser(@Valid @RequestBody UserDTO userDTO) throws URISyntaxException {
    log.debug("REST request to save User : {}", userDTO);

    if (userDTO.getId() != null) {
        throw new BadRequestAlertException("A new user cannot already have an ID", "userManagement", "idexists");
        // Lowercase the user login before comparing with database
    } else if (userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).isPresent()) {
        throw new LoginAlreadyUsedException();
    } else if (userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).isPresent()) {
        throw new EmailAlreadyUsedException();
    } else {
        User newUser = userService.createUser(userDTO);
        mailService.sendCreationEmail(newUser);
        return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
            .headers(HeaderUtil.createAlert( "userManagement.created", newUser.getLogin()))
            .body(newUser);
    }
}
项目:outland    文件:GroupResource.java   
@DELETE
@Path("/{group}/access/services/{service_key}")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
@Timed(name = "removeService")
public Response removeService(
    @Auth AuthPrincipal authPrincipal,
    @PathParam("group") String groupKey,
    @PathParam("service_key") String serviceKey
) throws AuthenticationException {
  final long start = System.currentTimeMillis();

  final Optional<Group> maybe = findGroup(groupKey);

  if (maybe.isPresent()) {
    final Group group = maybe.get();
    accessControlSupport.throwUnlessGrantedFor(authPrincipal, group);
    final Group updated = groupService.removeServiceAccess(group, serviceKey);

    return headers.enrich(Response.ok(updated), start).build();
  }

  return headers.enrich(Response.status(404).entity(
      Problem.clientProblem(TITLE_NOT_FOUND, "", 404)), start).build();
}
项目:patient-portal    文件:UserResource.java   
/**
 * 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<UserDTO> updateUser(@Valid @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(ENTITY_NAME, "emailexists", "Email 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(ENTITY_NAME, "userexists", "Login already in use")).body(null);
    }
    Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);

    return ResponseUtil.wrapOrNotFound(updatedUser,
        HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()));
}
项目:shoucang    文件:PostsController.java   
@RequestMapping(value = "posts/new", method = RequestMethod.GET)
@Timed
public String newPosts(@RequestParam(defaultValue = "1") int page, Model model) {
    page = page < 1 ? 1 : page - 1;
    long size = newPostsService.size();
    long pages = size / PAGE_SIZE + (size % PAGE_SIZE != 0 ? 1 : 0);

    List<Post> posts = postListService.getNewPostsOfPage(page, PAGE_SIZE);


    model.addAttribute("page", page + 1);
    model.addAttribute("totalPages", pages);
    model.addAttribute("posts", posts);
    model.addAttribute("votes", voteService.getCurrentUserVoteMapFor(posts));
    model.addAttribute("counting", countingService.getPostListCounting(posts));

    return "posts/new";
}
项目:codemotion-2017-taller-de-jhipster    文件:AccountResource.java   
/**
 * POST  /account : update the current user information.
 *
 * @param userDTO the current user information
 * @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
 * @throws RuntimeException 500 (Internal Server Error) if the user login wasn't found
 */
 @PostMapping("/account")
 @Timed
 public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
     final String userLogin = SecurityUtils.getCurrentUserLogin();
     Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
     if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
         throw new EmailAlreadyUsedException();
     }
     Optional<User> user = userRepository.findOneByLogin(userLogin);
     if (!user.isPresent()) {
         throw new InternalServerErrorException("User could not be found");
     }
     userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
         userDTO.getLangKey(), userDTO.getImageUrl());
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:UserJWTController.java   
@PostMapping("/authenticate")
@Timed
public ResponseEntity<?> authorize(@Valid @RequestBody LoginDTO loginDTO, HttpServletResponse response) {

    UsernamePasswordAuthenticationToken authenticationToken =
        new UsernamePasswordAuthenticationToken(loginDTO.getUsername(), loginDTO.getPassword());

    try {
        Authentication authentication = this.authenticationManager.authenticate(authenticationToken);
        SecurityContextHolder.getContext().setAuthentication(authentication);
        boolean rememberMe = (loginDTO.isRememberMe() == null) ? false : loginDTO.isRememberMe();
        String jwt = tokenProvider.createToken(authentication, rememberMe);
        response.addHeader(JWTConfigurer.AUTHORIZATION_HEADER, "Bearer " + jwt);
        return ResponseEntity.ok(new JWTToken(jwt));
    } catch (AuthenticationException exception) {
        return new ResponseEntity<>(Collections.singletonMap("AuthenticationException",exception.getLocalizedMessage()), HttpStatus.UNAUTHORIZED);
    }
}
项目:sentry    文件:UserResource.java   
/**
 * 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("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()))
        .body(new ManagedUserVM(userService.getUserWithAuthorities(managedUserVM.getId())));
}
项目:verify-hub    文件:MatchingServiceResource.java   
@GET
@Timed
public Collection<MatchingServiceConfigEntityDataDto> getMatchingServices() {
    Collection<MatchingServiceConfigEntityDataDto> matchingServices = new ArrayList<>();
    for (TransactionConfigEntityData transactionConfigEntityData : transactionConfigEntityDataRepository.getAllData()) {

        MatchingServiceConfigEntityData matchingServiceConfigEntityData = matchingServiceConfigEntityDataRepository.getData(transactionConfigEntityData.getMatchingServiceEntityId()).get();
        matchingServices.add(new MatchingServiceConfigEntityDataDto(
                matchingServiceConfigEntityData.getEntityId(),
                matchingServiceConfigEntityData.getUri(),
                transactionConfigEntityData.getEntityId(),
                matchingServiceConfigEntityData.getHealthCheckEnabled(),
                matchingServiceConfigEntityData.getOnboarding(),
                matchingServiceConfigEntityData.getUserAccountCreationUri()));
    }
    return matchingServices;
}
项目:MTC_Labrat    文件:UserResource.java   
/**
 * 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<UserDTO> 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(ENTITY_NAME, "emailexists", "Email 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(ENTITY_NAME, "userexists", "Login already in use")).body(null);
    }
    Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);

    return ResponseUtil.wrapOrNotFound(updatedUser,
        HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
项目:buenojo    文件:PhotoLocationBeaconResource.java   
/**
 * GET  /photoLocationBeacons -> get all the photoLocationBeacons.
 */
@RequestMapping(value = "/photoLocationBeacons",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<PhotoLocationBeacon> getAllPhotoLocationBeacons(@RequestParam(required = false) String filter) {
    if ("exercise-is-null".equals(filter)) {
        log.debug("REST request to get all PhotoLocationBeacons where exercise is null");
        return StreamSupport
            .stream(photoLocationBeaconRepository.findAll().spliterator(), false)
            .filter(photoLocationBeacon -> photoLocationBeacon.getExercise() == null)
            .collect(Collectors.toList());
    }

    log.debug("REST request to get all PhotoLocationBeacons");
    return photoLocationBeaconRepository.findAll();
}
项目:codemotion-2017-taller-de-jhipster    文件:TaskResource.java   
/**
 * POST  /tasks : Create a new task.
 *
 * @param task the task to create
 * @return the ResponseEntity with status 201 (Created) and with body the new task, or with status 400 (Bad Request) if the task has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/tasks")
@Timed
public ResponseEntity<Task> createTask(@Valid @RequestBody Task task) throws URISyntaxException {
    log.debug("REST request to save Task : {}", task);
    if (task.getId() != null) {
        throw new BadRequestAlertException("A new task cannot already have an ID", ENTITY_NAME, "idexists");
    }
    if (!SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN)) {
        task.setUser(SecurityUtils.getCurrentUserLogin());
    }
    Task result = taskRepository.save(task);
    return ResponseEntity.created(new URI("/api/tasks/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
项目:buenojo    文件:EnrollmentResource.java   
/**
 * GET  /enrollments -> get all the enrollments.
 */
@RequestMapping(value = "/enrollments",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Enrollment> getAllEnrollments() {
    log.debug("REST request to get all Enrollments");
    return enrollmentRepository.findAll();
}
项目:xm-ms-entity    文件:LinkResource.java   
/**
 * GET  /links : get all the links.
 *
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and the list of links in body
 */
@GetMapping("/links")
@Timed
public ResponseEntity<List<Link>> getAllLinks(@ApiParam Pageable pageable) {
    log.debug("REST request to get a page of Links");
    Page<Link> page = linkService.findAll(pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/links");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
项目:devoxxus-jhipster-microservices-demo    文件:AccountResource.java   
/**
 * GET  /account : get the current user.
 *
 * @return the ResponseEntity with status 200 (OK) and the current user in body, or status 500 (Internal Server
 * Error) if the user couldn't be returned
 */
@GetMapping("/account")
@Timed
public ResponseEntity<UserDTO> getAccount() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    User user = (User) authentication.getPrincipal();
    UserDTO userDTO = new UserDTO(user.getUsername(),
        user.getAuthorities().stream()
            .map(authority -> authority.getAuthority()).collect(Collectors.toSet()));
    return new ResponseEntity<>(userDTO, HttpStatus.OK);
}
项目:TorgCRM-Server    文件:UserResource.java   
/**
 * GET /users : get all users.
 *
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and with body all users
 */
@GetMapping("/users")
@Timed
public ResponseEntity<List<UserDTO>> getAllUsers(Pageable pageable) {
    final Page<UserDTO> page = userService.getAllManagedUsers(pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
项目:xm-ms-entity    文件:XmEntityResource.java   
@DeleteMapping("/xm-entities/{idOrKey}/links/targets/{targetId}")
@Timed
public ResponseEntity<Void> deleteLinkTarget(@PathVariable String idOrKey, @PathVariable String targetId) {
    log.debug("REST request to delete link target {} for entity {}", targetId, idOrKey);
    xmEntityService.deleteLinkTarget(IdOrKey.of(idOrKey), targetId);
    return ResponseEntity.ok().build();
}
项目:TorgCRM-Server    文件:DepartmentResource.java   
/**
 * POST  /departments : Create a new department.
 *
 * @param departmentDTO the departmentDTO to create
 * @return the ResponseEntity with status 201 (Created) and with body the new departmentDTO, or with status 400 (Bad Request) if the department has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/departments")
@Timed
public ResponseEntity<DepartmentDTO> createDepartment(@RequestBody DepartmentDTO departmentDTO) throws URISyntaxException {
    log.debug("REST request to save Department : {}", departmentDTO);
    if (departmentDTO.getId() != null) {
        throw new BadRequestAlertException("A new department cannot already have an ID", ENTITY_NAME, "idexists");
    }
    DepartmentDTO result = departmentService.save(departmentDTO);
    return ResponseEntity.created(new URI("/api/departments/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
项目:Microservices-with-JHipster-and-Spring-Boot    文件:EntryResource.java   
/**
 * GET  /entries/:id : get the "id" entry.
 *
 * @param id the id of the entry to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the entry, or with status 404 (Not Found)
 */
@GetMapping("/entries/{id}")
@Timed
public ResponseEntity<Entry> getEntry(@PathVariable Long id) {
    log.debug("REST request to get Entry : {}", id);
    Entry entry = entryRepository.findOneWithEagerRelationships(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(entry));
}
项目:Code4Health-Platform    文件:UserResource.java   
/**
 * GET  /users/:login : get the "login" user.
 *
 * @param login the login of the user to find
 * @return the ResponseEntity with status 200 (OK) and with body the "login" user, or with status 404 (Not Found)
 */
@GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
public ResponseEntity<UserDTO> getUser(@PathVariable String login) {
    log.debug("REST request to get User : {}", login);
    return ResponseUtil.wrapOrNotFound(
        userService.getUserWithAuthoritiesByLogin(login)
            .map(UserDTO::new));
}
项目:verify-hub    文件:IdentityProviderResource.java   
@GET
@Path(Urls.ConfigUrls.ENABLED_IDENTITY_PROVIDERS_PARAM_PATH)
@Timed
@Deprecated
public Collection<String> getEnabledIdentityProviderEntityIdsPathParam(
        @PathParam(Urls.ConfigUrls.ENTITY_ID_PATH_PARAM) final Optional<String> transactionEntityId) {

    Collection<IdentityProviderConfigEntityData> matchingIdps = getIdentityProviderConfigEntityData(transactionEntityId);

    return Collections2.transform(matchingIdps, new IdpEntityIdExtractor());
}
项目:Code4Health-Platform    文件:OperinoResource.java   
/**
 * GET  /operinos/:id : get the "id" operino.
 *
 * @param id the id of the operino to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the operino, or with status 404 (Not Found)
 */
@GetMapping("/operinos/{id}")
@Timed
public ResponseEntity<Operino> getOperino(@PathVariable Long id) {
    log.debug("REST request to get Operino : {}", id);
    Operino operino = operinoService.verifyOwnershipAndGet(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(operino));
}
项目:codemotion-2017-taller-de-jhipster    文件:TaskResource.java   
/**
   * GET  /tasks/:id : get the "id" task.
   *
   * @param id the id of the task to retrieve
   * @return the ResponseEntity with status 200 (OK) and with body the task, or with status 404 (Not Found)
   */
  @GetMapping("/tasks/{id}")
  @Timed
  public ResponseEntity<Task> getTask(@PathVariable Long id) {
      log.debug("REST request to get Task : {}", id);
      Task task = taskRepository.findOne(id);
      if (task != null && !SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN)
    && !SecurityUtils.getCurrentUserLogin().equals(task.getUser())) {
    return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
      return ResponseUtil.wrapOrNotFound(Optional.ofNullable(task));
  }
项目:klask-io    文件:AccountResource.java   
/**
 * POST  /account/change_password : changes the current user's password
 *
 * @param password the new password
 * @return the ResponseEntity with status 200 (OK), or status 400 (Bad Request) if the new password is not strong enough
 */
@RequestMapping(value = "/account/change_password",
    method = RequestMethod.POST,
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<?> changePassword(@RequestBody String password) {
    if (!checkPasswordLength(password)) {
        return new ResponseEntity<>("Incorrect password", HttpStatus.BAD_REQUEST);
    }
    userService.changePassword(password);
    return new ResponseEntity<>(HttpStatus.OK);
}
项目:buenojo    文件:MultipleChoiceExerciseContainerResource.java   
/**
 * PUT  /multipleChoiceExerciseContainers -> Updates an existing multipleChoiceExerciseContainer.
 */
@RequestMapping(value = "/multipleChoiceExerciseContainers",
    method = RequestMethod.PUT,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<MultipleChoiceExerciseContainer> updateMultipleChoiceExerciseContainer(@Valid @RequestBody MultipleChoiceExerciseContainer multipleChoiceExerciseContainer) throws URISyntaxException {
    log.debug("REST request to update MultipleChoiceExerciseContainer : {}", multipleChoiceExerciseContainer);
    if (multipleChoiceExerciseContainer.getId() == null) {
        return createMultipleChoiceExerciseContainer(multipleChoiceExerciseContainer);
    }
    MultipleChoiceExerciseContainer result = multipleChoiceExerciseContainerRepository.save(multipleChoiceExerciseContainer);
    return ResponseEntity.ok()
        .headers(HeaderUtil.createEntityUpdateAlert("multipleChoiceExerciseContainer", multipleChoiceExerciseContainer.getId().toString()))
        .body(result);
}
项目:buenojo    文件:PhotoLocationExtraSatelliteImageResource.java   
/**
 * GET  /photoLocationExtraSatelliteImages/:id -> get the "id" photoLocationExtraSatelliteImage.
 */
@RequestMapping(value = "/photoLocationExtraSatelliteImages/{id}",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<PhotoLocationExtraSatelliteImage> getPhotoLocationExtraSatelliteImage(@PathVariable Long id) {
    log.debug("REST request to get PhotoLocationExtraSatelliteImage : {}", id);
    return Optional.ofNullable(photoLocationExtraSatelliteImageRepository.findOne(id))
        .map(photoLocationExtraSatelliteImage -> new ResponseEntity<>(
            photoLocationExtraSatelliteImage,
            HttpStatus.OK))
        .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
项目:TorgCRM-Server    文件:DealResource.java   
/**
 * POST  /deals : Create a new deal.
 *
 * @param dealDTO the dealDTO to create
 * @return the ResponseEntity with status 201 (Created) and with body the new dealDTO, or with status 400 (Bad Request) if the deal has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/deals")
@Timed
public ResponseEntity<DealDTO> createDeal(@RequestBody DealDTO dealDTO) throws URISyntaxException {
    log.debug("REST request to save Deal : {}", dealDTO);
    if (dealDTO.getId() != null) {
        throw new BadRequestAlertException("A new deal cannot already have an ID", ENTITY_NAME, "idexists");
    }
    DealDTO result = dealService.save(dealDTO);
    return ResponseEntity.created(new URI("/api/deals/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
项目:buenojo    文件:ExerciseTipResource.java   
/**
 * POST  /exerciseTips -> Create a new exerciseTip.
 */
@RequestMapping(value = "/exerciseTips",
        method = RequestMethod.POST,
        produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<ExerciseTip> createExerciseTip(@Valid @RequestBody ExerciseTip exerciseTip) throws URISyntaxException {
    log.debug("REST request to save ExerciseTip : {}", exerciseTip);
    if (exerciseTip.getId() != null) {
        return ResponseEntity.badRequest().header("Failure", "A new exerciseTip cannot already have an ID").body(null);
    }
    ExerciseTip result = exerciseTipRepository.save(exerciseTip);
    return ResponseEntity.created(new URI("/api/exerciseTips/" + result.getId()))
            .headers(HeaderUtil.createEntityCreationAlert("exerciseTip", result.getId().toString()))
            .body(result);
}
项目:buenojo    文件:TagResource.java   
/**
 * DELETE  /tags/:id -> delete the "id" tag.
 */
@RequestMapping(value = "/tags/{id}",
    method = RequestMethod.DELETE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Void> deleteTag(@PathVariable Long id) {
    log.debug("REST request to delete Tag : {}", id);
    tagRepository.delete(id);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert("tag", id.toString())).build();
}
项目:xm-ms-entity    文件:XmEntityResource.java   
@DeleteMapping("/xm-entities/self/links/targets/{targetId}")
@Timed
public ResponseEntity<Void> deleteSelfLinkTarget(@PathVariable String targetId) {
    log.debug("REST request to delete link target {} for self", targetId);
    xmEntityService.deleteSelfLinkTarget(targetId);
    return ResponseEntity.ok().build();
}
项目:buenojo    文件:HangManExerciseHintResource.java   
/**
 * GET  /hangManExercises -> get all the hangManExercises.
 */
@RequestMapping(value = "/hangManExerciseHints/container/{id}",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<HangManExercise> getAllHangManExercisesByContainer(@PathVariable Long id) {
    log.debug("REST request to get all HangManExercises");
    return hangManExerciseHintRepository.findByhangmanGameContainerId(id);
}
项目:spring-io    文件:BrandResource.java   
/**
 * DELETE  /brands/:id : delete the "id" brand.
 *
 * @param id the id of the brand to delete
 * @return the ResponseEntity with status 200 (OK)
 */
@DeleteMapping("/brands/{id}")
@Timed
public ResponseEntity<Void> deleteBrand(@PathVariable Long id) {
    log.debug("REST request to delete Brand : {}", id);
    brandService.delete(id);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
项目:spring-io    文件:SubCategoryResource.java   
/**
 * GET  /sub-categories : get all the subCategories.
 *
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and the list of subCategories in body
 */
@GetMapping("/sub-categories")
@Timed
public ResponseEntity<List<SubCategory>> getAllSubCategories(@ApiParam Pageable pageable) {
    log.debug("REST request to get a page of SubCategories");
    Page<SubCategory> page = subCategoryService.findAll(pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/sub-categories");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
项目:buenojo    文件:ExerciseResource.java   
/**
 * POST  /exercises -> Create a new exercise.
 */
@RequestMapping(value = "/exercises",
        method = RequestMethod.POST,
        produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<Exercise> createExercise(@Valid @RequestBody Exercise exercise) throws URISyntaxException {
    log.debug("REST request to save Exercise : {}", exercise);
    if (exercise.getId() != null) {
        return ResponseEntity.badRequest().header("Failure", "A new exercise cannot already have an ID").body(null);
    }
    Exercise result = exerciseRepository.save(exercise);
    return ResponseEntity.created(new URI("/api/exercises/" + result.getId()))
            .headers(HeaderUtil.createEntityCreationAlert("exercise", result.getId().toString()))
            .body(result);
}
项目:xm-ms-dashboard    文件:DashboardResource.java   
/**
 * POST  /dashboards : Create a new dashboard.
 *
 * @param dashboard the dashboard to create
 * @return the ResponseEntity with status 201 (Created) and with body the new dashboard, or with status 400 (Bad Request) if the dashboard has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/dashboards")
@Timed
public ResponseEntity<Dashboard> createDashboard(@Valid @RequestBody Dashboard dashboard) throws URISyntaxException {
    log.debug("REST request to save Dashboard : {}", dashboard);
    if (dashboard.getId() != null) {
        return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new dashboard cannot already have an ID")).body(null);
    }
    Dashboard result = dashboardService.save(dashboard);
    return ResponseEntity.created(new URI("/api/dashboards/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
项目:sentry    文件:AccountResource.java   
/**
 * POST   /account/reset_password/init : Send an e-mail to reset the password of the user
 *
 * @param mail the mail of the user
 * @return the ResponseEntity with status 200 (OK) if the e-mail was sent, or status 400 (Bad Request) if the e-mail address is not registered
 */
@PostMapping(path = "/account/reset_password/init",
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<?> requestPasswordReset(@RequestBody String mail) {
    return userService.requestPasswordReset(mail)
        .map(user -> {
            mailService.sendPasswordResetMail(user);
            return new ResponseEntity<>("e-mail was sent", HttpStatus.OK);
        }).orElse(new ResponseEntity<>("e-mail address not registered", HttpStatus.BAD_REQUEST));
}