Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.Page$SubPageComparator


    }

    @Test
    public void save_null(){
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region item = new RegionImpl();
        item.setPage(page);
        regions.add(item);
        page.setRegions(regions);

        expect(template.get("1234L")).andReturn(page);
        expect(template.save(isA(Page.class))).andReturn(page);
        replay(template);
View Full Code Here


    }

    @Test
     public void delete(){
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region item = new RegionImpl("1111L");
        regions.add(item);
        page.setRegions(regions);

        expect(template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is("1111L"))))).andReturn(page);
        expect(template.save(isA(Page.class))).andReturn(page);
        replay(template);
View Full Code Here

        addNavItemsToModel(view, model, referringPageId, user, null);
        return view;
    }

    private String viewProfileCommon(User user, ModelMap model, String referringPageId){
        Page personProfilePage = pageService.getPersonProfilePage(user.getId());
        addAttributesToModel(model, user, referringPageId);

        model.addAttribute(ModelKeys.PAGE, personProfilePage);
        String view =  ViewNames.getPersonPageView(personProfilePage.getPageLayout().getCode());
        List<Person> friendRequests = userService.getFriendRequestsReceived(user.getUsername());
        addNavItemsToModel(view, model, referringPageId, user, friendRequests);
        return view;
    }
View Full Code Here

    }

    @Test (expected = IllegalStateException.class)
    public void delete_null(){
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region item = new RegionImpl();
        regions.add(item);
        page.setRegions(regions);

        repo.delete(item);
    }
View Full Code Here


    @Test
    public void getAllPersonProfilePages_userHasPersonPage() {
        List<Page> VALID_PAGES = new ArrayList<Page>();
        Page personPage = new PageImpl();
        VALID_PAGES.add(personPage);

        expect(pageRepository.getAllPages(VALID_USER_ID, PageType.PERSON_PROFILE)).andReturn(VALID_PAGES);
        replay(pageRepository,userService,pageTemplateRepository);
View Full Code Here

    }

    @Test
    public void getAllPersonProfilePages_noPersonPage() {
        List<Page> VALID_PAGES = new ArrayList<Page>();
        Page personPage = new PageImpl();
        PageTemplate pageTemplate = new PageTemplateImpl();
        UserImpl user = new UserImpl();

        expect(pageRepository.getAllPages(VALID_USER_ID, PageType.PERSON_PROFILE)).andReturn(VALID_PAGES);
        expect(userService.getUserById(isA(String.class))).andReturn(user).once();
View Full Code Here

    @Test
    public void addNewUserPage_noExistingPages() {
        final String PAGE_NAME = "my new page";
        final Long EXPECTED_RENDER_SEQUENCE = 1L;
        PageTemplate pageTemplate = new PageTemplateImpl() ;
        Page expectedPage = new PageImpl();
        expectedPage.setName(PAGE_NAME);
        expectedPage.setOwnerId(user.getId());
        expectedPage.setPageLayout(pageLayout);
        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));
        expectedPage.setPageType(PageType.USER);
        PageUser lPageUser = new PageUserImpl(user.getId(), expectedPage, EXPECTED_RENDER_SEQUENCE);
        List<PageUser> members = new ArrayList<PageUser>();
        members.add(lPageUser);
        expectedPage.setMembers(members);

        expect(userService.getAuthenticatedUser()).andReturn(user);
        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
        expect(pageTemplateRepository.getDefaultPage(PageType.USER)).andReturn(pageTemplate);
        expect(pageRepository.createPageForUser(user, pageTemplate)).andReturn(expectedPage);
        expect(pageRepository.getAllPages(user.getId(), PageType.USER)).andReturn(new ArrayList<Page>());

        replay(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);

        Page newPage = pageService.addNewUserPage(PAGE_NAME, PAGE_LAYOUT_CODE);
        assertThat(newPage.getMembers().get(0).getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
        assertThat(newPage.getName(), is(PAGE_NAME));
        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
        assertThat(newPage.getPageType(), is(PageType.USER));

        verify(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);
    }
View Full Code Here

    @Test
    public void addNewUserPage_noExistingPages_no_result_exception() {
        final String PAGE_NAME = "my new page";
        final Long EXPECTED_RENDER_SEQUENCE = 1L;

        Page expectedPage = new PageImpl();
        expectedPage.setName(PAGE_NAME);
        expectedPage.setOwnerId(user.getId());
        expectedPage.setPageLayout(pageLayout);
        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));
        expectedPage.setPageType(PageType.USER);

        expect(userService.getAuthenticatedUser()).andReturn(user);
        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
        expect(pageRepository.save(expectedPage)).andAnswer(new IAnswer<Page>() {
            @Override
            public Page answer() throws Throwable {
                return (Page)EasyMock.getCurrentArguments()[0];
            }
        });
        expect(pageTemplateRepository.getDefaultPage(PageType.USER)).andThrow(new NoResultException("No Result Exception"));

        expect(pageRepository.getAllPages(user.getId(), PageType.USER)).andReturn(new ArrayList<Page>());
        replay(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);

        Page newPage = pageService.addNewUserPage(PAGE_NAME, PAGE_LAYOUT_CODE);
        assertThat(newPage.getMembers().get(0).getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
        assertThat(newPage.getName(), is(PAGE_NAME));
        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
        assertThat(newPage.getPageType(), is(PageType.USER));

        verify(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);
    }
View Full Code Here

        this.widgetResolverService = widgetResolverService;
    }
   
    @Override
    public OmdlOutputAdapter exportOmdl(String pageId, String omdlUrl) {
        Page page = pageService.getPage(pageId);
        OmdlOutputAdapter omdl = new OmdlOutputAdapter(widgetService, userService);
        omdl.buildModel(page, omdlUrl, wookieUrl);
        return omdl;
    }
View Full Code Here

        return omdl;
    }

    @Override
    public Page importOmdl(MultipartFile multipartFile, String pageName) throws DuplicateItemException {
        Page page = null;
        OmdlInputAdapter omdlInputAdapter = new OmdlInputAdapter();
        File temp = null;
        String xml = null;
        try {
            if(multipartFile != null){
                if(multipartFile.getSize() > 0) {
                    String tempUploadFolder = System.getProperty("java.io.tmpdir");
                    temp = new File(tempUploadFolder, multipartFile.getOriginalFilename());
                    multipartFile.transferTo(temp);
                    xml =  FileUtils.readFileToString(temp);
                }
            }
        } catch (IllegalStateException e) {
            logger.error(e.getMessage());
            throw new RuntimeException(e);
        } catch (IOException e) {
            logger.error(e.getMessage());
            throw new RuntimeException(e);
        }

        Document root = initializeBuilder(xml);
        if(root != null){
            try {
                parseOmdlFile(root, omdlInputAdapter);
            } catch (BadOmdlXmlFormatException e) {
                logger.error(e.getMessage());
                throw new RuntimeException(e);
            }
        }
        page = pageService.addNewUserPage(pageName, omdlInputAdapter.getLayoutCode());
        switch (page.getRegions().size()){
        case 1:
            populateRegionWidgets(page, omdlInputAdapter.getAllUrls(), page.getRegions().get(0).getId());
            break;
        case 2:
            populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(1).getId());
            break;
        case 3:
            populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllCenterUrls(), page.getRegions().get(1).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(2).getId());
            break;
        case 4:
            populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllCenterUrls(), page.getRegions().get(1).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(2).getId());
            populateRegionWidgets(page, omdlInputAdapter.getAllUnknownUrls(), page.getRegions().get(3).getId());
            break;
        default:
            // there are no layouts with more than 4 regions at present
        }
        return page;
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.Page$SubPageComparator

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.