Package org.apache.rave.model

Examples of org.apache.rave.model.Region


    }

    // returns a trusted Region object, either from the RegionRepository, or the
    // cached container list
    private Region getTrustedRegion(String regionId, List<Region> trustedRegionContainer) {
        Region region = null;
        if (trustedRegionContainer.isEmpty()) {
            region = regionRepository.get(regionId);
            trustedRegionContainer.add(region);
        } else {
            region = trustedRegionContainer.get(0);
View Full Code Here


    // checks to see if the Authentication object principal is the owner of the supplied region object
    // if trustedDomainObject is false, pull the entity from the database first to ensure
    // the model object is trusted and hasn't been modified
    private boolean isRegionOwner(Authentication authentication, Region region, List<Region> trustedRegionContainer, boolean trustedDomainObject) {
        Region trustedRegion = null;
        if (trustedDomainObject) {
            trustedRegion = region;
        } else {
            trustedRegion = getTrustedRegion(region.getId(), trustedRegionContainer);
        }
        return isRegionOwnerByUserId(authentication, trustedRegion.getPage().getOwnerId());
    }
View Full Code Here

            throw new IllegalArgumentException("unknown RaveSecurityContext type: " + raveSecurityContext.getType());
        }
    }

    private boolean isRegionMember(Authentication authentication, Region region, List<Region> trustedRegionContainer, boolean trustedDomainObject, boolean checkEditorStatus) {
        Region trustedRegion = null;
        if (trustedDomainObject) {
            trustedRegion = region;
        } else {
            trustedRegion = getTrustedRegion(region.getId(), trustedRegionContainer);
        }

        Page containerPage = trustedRegion.getPage();


        if (containerPage.getMembers() == null){
            return false;
        }
View Full Code Here

    @Test(expected = JspException.class)
    public void doStartTag_unsupportedWidget() throws JspException {
        replay(pageContext);

        RegionWidget regionWidget = new RegionWidgetImpl();
        Region region = new RegionImpl("25");
        WidgetImpl widget = new WidgetImpl("8");
        regionWidget.setWidgetId(widget.getId());
        regionWidget.setRegion(region);
        widget.setType("INVALID");
View Full Code Here

    @Test
    public void getPage_validId_export() {
        Page p = new PageImpl();
        p.setRegions(new ArrayList<Region>());
        p.setOwnerId("");
        Region region = new RegionImpl();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget w = new RegionWidgetImpl();
        w.setPreferences(new ArrayList<RegionWidgetPreference>());
        w.getPreferences().add(new RegionWidgetPreferenceImpl());
        region.getRegionWidgets().add(w);
        p.getRegions().add(region);

        expect(pageService.getPage(PAGE_ID)).andReturn(p).once();
        replay(pageService);
View Full Code Here

    @Autowired
    private JpaRegionConverter regionConverter;

    @Test
    public void noConversion() {
        Region region = new JpaRegion();
        assertThat(regionConverter.convert(region), is(sameInstance(region)));
    }
View Full Code Here

        assertThat(regionConverter.convert(region), is(sameInstance(region)));
    }

    @Test
    public void nullConversion() {
        Region template = null;
        assertThat(regionConverter.convert(template), is(nullValue()));
    }
View Full Code Here

    }


    @Test
    public void newRegion() {
        Region region = new RegionImpl("9");
        region.setLocked(false);
        region.setPage(new JpaPage());
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        region.setRenderOrder(9);

        JpaRegion converted = regionConverter.convert(region);
        assertThat(converted, is(not(sameInstance(region))));
        assertThat(converted, is(instanceOf(JpaRegion.class)));
        assertThat(converted.getRegionWidgets(), is(equalTo(region.getRegionWidgets())));
        assertThat(converted.getEntityId().toString(), is(equalTo(region.getId())));
        assertThat(converted.getId(), is(equalTo(region.getId())));
        assertThat(converted.getPage(), is(instanceOf(Page.class)));
        assertThat(converted.getRenderOrder(), is(equalTo(region.getRenderOrder())));
        assertThat(converted.isLocked(), is(equalTo(region.isLocked())));
    }
View Full Code Here

    public void removeWidgetFromPage_validWidget() {
        String WIDGET_ID = "1";
        String REGION_ID = "2";
        RegionWidget regionWidget = new RegionWidgetImpl(WIDGET_ID);
        regionWidget.setRegion(new RegionImpl(REGION_ID));
        Region region = new RegionImpl();

        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(regionWidget);
        regionWidgetRepository.delete(regionWidget);
        expectLastCall();
        replay(regionWidgetRepository);
        expect(regionRepository.get(REGION_ID)).andReturn(region);
        replay(regionRepository);

        Region result = pageService.removeWidgetFromPage(WIDGET_ID);
        verify(regionWidgetRepository);
        verify(regionRepository);
        assertThat(result, is(sameInstance(region)));
    }
View Full Code Here

    @Test(expected = UnsupportedOperationException.class)
    public void removeWidgetFromPage_lockedRegion() {
        String WIDGET_ID = "1";
        String REGION_ID = "2";
        Region region = new RegionImpl(REGION_ID);
        region.setLocked(true);
        RegionWidget regionWidget = new RegionWidgetImpl(WIDGET_ID);
        regionWidget.setRegion(region);

        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(regionWidget);
        regionWidgetRepository.delete(regionWidget);
View Full Code Here

TOP

Related Classes of org.apache.rave.model.Region

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.