Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.User


    public void addOrDeleteUserDoesNotAffectAuthority() {
        Authority authority = authorityRepository.get(1L);
        Assert.assertNotNull("Existing authority", authority);

        int usercount = authority.getUsers().size();
        User user = new User();
        user.setUsername("dummy");
        authority.addUser(user);
        authorityRepository.save(authority);
        assertNull("Persisting an Authority does not persist an unknown user", repository.getByUsername("dummy"));
        Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());
View Full Code Here


        assertTrue(count > 1);
    }

    @Test
    public void removeUser() {
        User user = repository.get(USER_ID);
        assertNotNull(user);
        final TypedQuery<Page> pageQuery = manager.createNamedQuery("Page.getByUserId", Page.class);
        pageQuery.setParameter("userId", USER_ID);
        List<Page> pages = pageQuery.getResultList();
        assertFalse("User has pages", pages.isEmpty());
View Full Code Here

        assertTrue(publishedCount >= 2);
    }

    @Test
    public void getByOwner() {
        final User user = new User(2L);
        List<Widget> widgets = repository.getByOwner(user, 0, 10);
        assertEquals(1, widgets.size());
    }
View Full Code Here

        assertEquals(1, widgets.size());
    }

    @Test
    public void getCountByOwner() {
        final User user = new User(2L);
        assertEquals(1, repository.getCountByOwner(user, 0, 10));
    }
View Full Code Here

     * Create a widget script block
     * @param item the RegionWidget to create a script block for
     * @return the script block
     */
    private String getWidgetScript(RegionWidget item) {
        User user = userService.getAuthenticatedUser();
       
        //
        // For the shared data key we use the RegionWidget entity ID.
        //
        String sharedDataKey = String.valueOf(item.getEntityId());
View Full Code Here

    }

    @Override
    @Transactional
    public void deletePage(long pageId) {                   
        User user = userService.getAuthenticatedUser();
        // first delete the page       
        pageRepository.delete(pageRepository.get(pageId));
        // now re-sequence the page sequence numbers

        //TODO RAVE-237:  We should be able to delete these lines.  If there are gaps in the sequence numbers, then it will still
        //TODO RAVE-237:  return values in the correct order.  We only need to update sequences when there is a change in order
        List<Page> pages = pageRepository.getAllPages(user.getEntityId());
        updatePageRenderSequences(pages);
    }   
View Full Code Here

        }      
    }
   
    private Page doMovePage(long pageId, long moveAfterPageId) {
        // get the logged in user
        User user = userService.getAuthenticatedUser();

        // get the page to move and the page to move after
        Page movingPage = pageRepository.get(pageId);
        Page afterPage = null;
        int newIndex = 0;
       
        // check to see if we should move the page to beginning
        if (moveAfterPageId != MOVE_PAGE_DEFAULT_POSITION_INDEX) {
            afterPage = pageRepository.get(moveAfterPageId);
        }

        // get all of the user's pages
        // the pageRepository returns an un-modifiable list
        // so we need to create a modifyable arraylist
        List<Page> pages = new ArrayList<Page>(pageRepository.getAllPages(user.getEntityId()));

        // first remove it from the list        
        if (!pages.remove(movingPage)) {
            throw new RuntimeException("unable to find pageId " + pageId + " attempted to be moved for user " + user);
        }
View Full Code Here

        final String userPageLayout = newUser.getPageLayout();
        final String email = newUser.getEmail();

        throwExceptionIfUserExists(userName, email);
               
        User user=new User();
        user.setUsername(userName);
        user.setEmail(email);
        //This assumes we use the username for the salt.  If not, the code below will need to change.
        //See also applicationContext-security.xml
        String saltedHashedPassword=passwordEncoder.encodePassword(password,saltSource.getSalt(user));
        logger.debug("Salt Source: {}", saltSource.getSalt(user));
        user.setPassword(saltedHashedPassword);

        user.setExpired(false);
        user.setLocked(false);
        user.setEnabled(true);
        userService.registerNewUser(user);

        // Return the newly registered user and create a new default page for them   
        pageService.addNewDefaultPage(userService.getUserByUsername(user.getUsername()), userPageLayout);     
    }
View Full Code Here

        // Return the newly registered user and create a new default page for them   
        pageService.addNewDefaultPage(userService.getUserByUsername(user.getUsername()), userPageLayout);     
    }

    private void throwExceptionIfUserExists(String userName, String email) {
        User existingUser = userService.getUserByUsername(userName);
        if (existingUser != null) {
            throw new IllegalArgumentException("A user already exists for username " + userName);
        }
        existingUser = userService.getUserByEmail(email);
        if (existingUser != null) {
View Full Code Here

    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        log.debug("loadUserByUsername called with: " + username);
        final User user = userRepository.getByUsername(username);
        if(user == null) {
            throw new UsernameNotFoundException("User with username '" + username + "' was not found!");
        }
        return user;
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.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.