Package org.ngrinder.model

Examples of org.ngrinder.model.User


    if (user.getRole().hasPermission(Permission.SWITCH_TO_ANYONE)) {
      for (User each : userService.getPagedAll(keywords, new PageRequest(0, 10))) {
        result.add(new UserSearchResult(each));
      }
    } else {
      User currUser = userService.getOne(user.getUserId());
      for (User each : currUser.getOwners()) {
        result.add(new UserSearchResult(each));
      }
    }
    return result;
  }
View Full Code Here


   */
  @RestAPI
  @PreAuthorize("hasAnyRole('A')")
  @RequestMapping("/api/{userId}/check_duplication")
  public HttpEntity<String> checkDuplication(@PathVariable String userId) {
    User user = userService.getOne(userId);
    return (user == null) ? successJsonHttpEntity() : errorJsonHttpEntity();
  }
View Full Code Here

    final List<User> followers = getFollowers(user.getFollowersStr());
    user.setFollowers(followers);
    if (user.getPassword() != null && StringUtils.isBlank(user.getPassword())) {
      user.setPassword(null);
    }
    final User existing = userRepository.findOneByUserId(user.getUserId());
    if (existing != null) {
      // First expire existing followers.
      final List<User> existingFollowers = existing.getFollowers();
      if (existingFollowers != null) {
        for (User eachFollower : existingFollowers) {
          userCache.evict(eachFollower.getUserId());
        }
      }
      user = existing.merge(user);
    }
    User createdUser = userRepository.save(user);
    // Then expires new followers so that new followers info can be loaded.
    for (User eachFollower : followers) {
      userCache.evict(eachFollower.getUserId());
    }
    prepareUserEnv(createdUser);
View Full Code Here

  private List<User> getFollowers(String followersStr) {
    List<User> newShareUsers = new ArrayList<User>();
    String[] userIds = StringUtils.split(StringUtils.trimToEmpty(followersStr), ',');
    for (String userId : userIds) {
      User shareUser = userRepository.findOneByUserId(userId.trim());
      if (shareUser != null) {
        newShareUsers.add(shareUser);
      }
    }
    return newShareUsers;
View Full Code Here

   */
  @SuppressWarnings("SpringElInspection")
  @Transactional
  @CacheEvict(value = "users", key = "#userId")
  public void delete(String userId) {
    User user = getOne(userId);
    List<PerfTest> deletePerfTests = perfTestService.deleteAll(user);
    userRepository.delete(user);
    for (PerfTest perfTest : deletePerfTests) {
      FileUtils.deleteQuietly(config.getHome().getPerfTestDirectory(perfTest));
    }
View Full Code Here

  public User createUser(User user) {
    encodePassword(user);
    Date createdDate = new Date();
    user.setCreatedDate(createdDate);
    user.setLastModifiedDate(createdDate);
    User createdUser = getOne(ControllerConstants.NGRINDER_INITIAL_ADMIN_USERID);
    user.setCreatedUser(createdUser);
    user.setLastModifiedUser(createdUser);
    return saveWithoutPasswordEncoding(user);
  }
View Full Code Here

   */
  @RestAPI
  @RequestMapping("/api/{userId}/check_duplication")
  public HttpEntity<String> checkDuplicationForRegistration(@PathVariable String userId) {
    checkTrue(config.isSignUpEnabled(), "Access to this url is not allowed when sign up is disabled");
    User user = userService.getOne(userId);
    return (user == null) ? successJsonHttpEntity() : errorJsonHttpEntity();
  }
View Full Code Here

   * Test method for
   * {@link net.grinder.util.ReflectionUtil#getFieldValue(java.lang.Object, java.lang.String)} .
   */
  @Test
  public void testGetFieldValue() {
    User testUser = new User();
    testUser.setUserId("TMP_UID");
    String rtnUid = (String) ReflectionUtils.getFieldValue(testUser, "userId");
    assertThat(rtnUid, is("TMP_UID"));
  }
View Full Code Here

  public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = getAuthentication(request, response);
    String timezone = request.getParameter("user_timezone");
    String language = request.getParameter("native_language");
    SecuredUser securedUser = (SecuredUser) auth.getPrincipal();
    User user = securedUser.getUser();
    User existingUser = userRepository.findOneByUserId(user.getUserId());
    if (existingUser != null) {
      user = existingUser;
    }
    user.setTimeZone(timezone);
    user.setUserLanguage(language);
View Full Code Here

      if (object instanceof BaseModel
          && (springContext.isServletRequestContext() || springContext.isUnitTestContext())) {
        BaseModel<?> model = (BaseModel<?>) object;
        Date lastModifiedDate = new Date();
        model.setLastModifiedDate(lastModifiedDate);
        User currentUser = userContext.getCurrentUser();
        model.setLastModifiedUser(userRepository.findOne(currentUser.getId()));

        if (!model.exist() || model.getCreatedUser() == null) {
          model.setCreatedDate(lastModifiedDate);
          User factualUser = currentUser.getFactualUser();
          model.setCreatedUser(userRepository.findOne(factualUser.getId()));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.ngrinder.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.