Package org.apache.rave.portal.model

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


    @Test
    public void getWidgetsByOwner() {
        final int offset = 0;
        final int pageSize = 10;
        final User user = new User(5L);
        expect(userRepository.get(user.getEntityId())).andReturn(user);
        replay(userRepository);

        final List<Widget> widgets = new ArrayList();
        final Widget widget = new Widget(3L, "http://www.widgetsRus.com/");
        widgets.add(widget);

        expect(widgetRepository.getCountByOwner(user, offset, pageSize)).andReturn(widgets.size());
        expect(widgetRepository.getByOwner(user, offset, pageSize)).andReturn(widgets);
        replay(widgetRepository);

        SearchResult<Widget> result = widgetService.getWidgetsByOwner(user.getEntityId(), offset, pageSize);
        assertNotNull(result);
        assertEquals(offset, result.getOffset());
        assertEquals(pageSize, result.getPageSize());
        assertEquals(widgets, result.getResultSet());
View Full Code Here


     * @return the view name of the main store page
     */
    @RequestMapping(method = RequestMethod.GET, value = "tag")
    public String viewTagResult(Model model, @RequestParam long referringPageId, @RequestParam String keyword,
            @RequestParam(required = false, defaultValue = "0") int offset) {
        User user = userService.getAuthenticatedUser();
        widgetStoreModelHelper(model, referringPageId, user);
        model.addAttribute(ModelKeys.WIDGETS, widgetService.getWidgetsByTag(keyword, offset, getPageSize()));
        model.addAttribute(ModelKeys.OFFSET, offset);
        model.addAttribute(ModelKeys.SELECTED_TAG, keyword);
        return ViewNames.STORE;
View Full Code Here

    @RequestMapping(method = RequestMethod.GET, value = "category")
    public String viewCategoryResult(@RequestParam(required = true) long referringPageId,
            @RequestParam(required = true) long categoryId,
            @RequestParam(required = false, defaultValue = "0") int offset, Model model) {
        User authenticatedUser = userService.getAuthenticatedUser();
        widgetStoreModelHelper(model, referringPageId, authenticatedUser);
        if (categoryId > 0) {
            model.addAttribute(ModelKeys.WIDGETS, widgetService.getWidgetsByCategory(categoryId, offset, getPageSize()));
        } else {
            model.addAttribute(ModelKeys.WIDGETS, widgetService.getPublishedWidgets(offset, getPageSize()));
View Full Code Here

     * @return if successful the view name of the widget, otherwise the form
     */
    @RequestMapping(method = RequestMethod.POST, value = "widget/add")
    public String viewAddWidgetResult(@ModelAttribute Widget widget, BindingResult results, Model model,
            @RequestParam long referringPageId) {
        User user = userService.getAuthenticatedUser();
        widgetValidator.validate(widget, results);
        if (results.hasErrors()) {
            model.addAttribute(ModelKeys.WIDGET, widget);
            model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId);
            return ViewNames.ADD_WIDGET_FORM;
View Full Code Here

        //Replace the real restOperations instance with a mock -- otherwise the call for gadget metadata would fail since
        //we don't have a shindig server available to hit.
        ReflectionTestUtils.setField(metadataRepository, "restOperations", restOperations);

        //Setup a mock authenticated user
        final User authUser = new User(VALID_USER_ID, VALID_USER_NAME);
        AbstractAuthenticationToken auth = EasyMock.createNiceMock(AbstractAuthenticationToken.class);
        EasyMock.expect(auth.getPrincipal()).andReturn(authUser).anyTimes();
        EasyMock.replay(auth);

        SecurityContext context = new SecurityContextImpl();
View Full Code Here

        assertThat(service.getSupportedWidgetTypes().contains("OpenSocial"), is(true));
    }

    @Test
    public void renderOpenSocial() {
        Page page = new Page(1L, new User(VALID_USER_ID, VALID_USER_NAME));
        Region region = new Region(1L, page, 1);
        page.setRegions(Arrays.asList(region));

        Widget w = new Widget();
        w.setType("OpenSocial");
View Full Code Here

        return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
    }         
   
    @RequestMapping(value = "/page/view/{pageId}", method = RequestMethod.GET)
    public String view(@PathVariable Long pageId, Model model, HttpServletRequest request) {
        User user = userService.getAuthenticatedUser();
        logger.debug("attempting to get pageId {} for {}", pageId, user);
       
        List<Page> pages = getAllPagesForAuthenticatedUser();
        Page page = pageService.getPageFromList(pageId, pages);
        List<PageLayout> pageLayouts = pageLayoutService.getAllUserSelectable();
View Full Code Here

        addAttributesToModel(model, page, pages, pageLayouts);
        return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
    }
   
    private List<Page> getAllPagesForAuthenticatedUser() {
        User user = userService.getAuthenticatedUser();
        long userId = user.getEntityId();
        List<Page> pages = pageService.getAllUserPages(userId);
        if (pages.isEmpty()) {
            // create a new default page for the user
            logger.info("User {} does not have any pages - creating default page", user.getUsername());
            pageService.addNewDefaultUserPage(userId);
            // refresh the pages list which will now have the new page
            pages = pageService.getAllUserPages(userId);
        }
        return pages;
View Full Code Here

        newUser.setPassword(VALID_PASSWORD);
        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setEmail(VALID_EMAIL);
        newUser.setPageLayout(VALID_LAYOUT_CODE);
       
        User expectedUser = new User();
        expectedUser.setUsername(newUser.getUsername());
        expectedUser.setPassword(newUser.getPassword());
        expectedUser.setEmail(newUser.getEmail());
        expectedUser.setDefaultPageLayout(validPageLayout);
        expectedUser.setExpired(false);
        expectedUser.setLocked(false);
        expectedUser.setEnabled(true);               

        ReflectionTestUtils.setField(newAccountService, "passwordEncoder", passwordEncoder);

        expect(passwordEncoder.encode("valid.password")).andReturn("valid.password");
        expect(userService.getUserByUsername(VALID_USER)).andReturn(null);
View Full Code Here

        newUser.setPassword(VALID_PASSWORD);
        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setEmail("");
        newUser.setPageLayout(VALID_LAYOUT_CODE);

        User expectedUser = new User();
        expectedUser.setUsername(newUser.getUsername());
        expectedUser.setPassword(newUser.getPassword());
        expectedUser.setEmail(newUser.getEmail());
        expectedUser.setDefaultPageLayout(validPageLayout);
        expectedUser.setExpired(false);
        expectedUser.setLocked(false);
        expectedUser.setEnabled(true);

        ReflectionTestUtils.setField(newAccountService, "passwordEncoder", passwordEncoder);

        expect(passwordEncoder.encode("valid.password")).andReturn("valid.password");
        expect(userService.getUserByUsername(VALID_USER)).andReturn(null);
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.