Package org.apache.rave.model

Examples of org.apache.rave.model.Widget


            }
        }
    }

    private void updateRegionWidget(RegionWidget source) {
        Widget widget = repository.get(source.getWidgetId());
        if (widget == null) {
            throw new IllegalArgumentException("Could not retrieve widget for RegionWidget " + source.getId());
        }
        source.setType(widget.getType());
        source.setWidgetUrl(widget.getUrl());
    }
View Full Code Here


        }
        return page;
    }

    private void populateRegionWidgets(Page page, List<OmdlWidgetReference> widgetReferences, String regionId ){
        Widget raveWidget = null;
        for (OmdlWidgetReference widgetReference : widgetReferences){
            // try to find if the widget is already installed in rave by its identifier (should be the rave widget url)
            logger.info("Found OMDL widget reference ("+widgetReference.getWidgetIdentifier()+")");
            raveWidget = widgetService.getWidgetByUrl(widgetReference.getWidgetIdentifier());
           
            // If not found download and install to widget container, then to rave.
            if(raveWidget==null){
                String providerType = widgetReference.getRaveWidgetTypeFromFormatType();
                if(!providerType.equals(null)){
                    try {
                        Widget resolvedWidget = widgetResolverService.resolveAndDownloadWidgetMetadata(widgetReference.getWidgetLink(), providerType);
                        if(resolvedWidget!=null){
                            // Check again in case the OMDL id attribute is not the same as the one found in the href attribute
                            if(widgetService.getWidgetByUrl(resolvedWidget.getUrl())==null){
                                raveWidget = widgetResolverService.addWidget(resolvedWidget);
                                logger.info("Widget added to rave. ("+raveWidget.getUrl()+")");
                            }else{
                                logger.info("Widget was already added to rave. ("+resolvedWidget.getUrl()+")");
                            }
                        }
                    } catch (Exception e) {
                        logger.error("Problem installing widget: "+ e.getMessage());
                        throw new RuntimeException(e);
View Full Code Here

     * (non-Javadoc)
     * @see org.apache.rave.portal.service.WidgetResolverService#resolveWidgetMetadata(java.lang.String, java.lang.String)
     */
    @Override
    public Widget resolveAndDownloadWidgetMetadata(String url, String type) throws Exception{
        Widget widget = null;
        // check for namespaces in the the type element
        if(type.contains("#")){
            String[] deNamespacedType = type.split("#");
            if(deNamespacedType.length > 0){
                type = deNamespacedType[1];
View Full Code Here

    }

    // returns a trusted Widget object, either from the WidgetRepository, or the
    // cached container list
    private Widget getTrustedWidget(String widgetId, List<Widget> trustedWidgetContainer) {
        Widget widget;
        if (trustedWidgetContainer.isEmpty()) {
            widget = widgetRepository.get(widgetId);
            trustedWidgetContainer.add(widget);
        } else {
            widget = trustedWidgetContainer.get(0);
View Full Code Here

    // the model object is trusted and hasn't been modified
    private boolean isWidgetOwner(Authentication authentication, Widget widget, List<Widget> trustedWidgetContainer, boolean trustedDomainObject) {
        if (widget.getOwnerId() == null) {
            return false;
        }
        Widget trustedWidget;
        if (trustedDomainObject) {
            trustedWidget = widget;
        } else {
            trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
        }
        return isWidgetOwnerById(authentication, trustedWidget.getOwnerId());
    }
View Full Code Here

    private boolean isWidgetOwnerById(Authentication authentication, String userId) {
        return ((User)authentication.getPrincipal()).getId().equals(userId);
    }

    private boolean isPublishedWidget(Widget widget, List<Widget> trustedWidgetContainer, boolean trustedDomainObject) {
        Widget trustedWidget;
        if (trustedDomainObject) {
            trustedWidget = widget;
        } else {
            trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
        }
        return WidgetStatus.PUBLISHED.equals(trustedWidget.getWidgetStatus());
    }
View Full Code Here

    public Widget getWidget(String id) throws Exception {
        if (getStoreUrl() == null) throw new Exception("External marketplace URL not configured");
        String url = getStoreUrl() + DETAIL;
        url = url.replace("${ID}", id);
        WidgetMarketplaceWidgetResult widgetResult = getRestJsonTemplate().getForObject(url, WidgetMarketplaceWidgetResult.class);
        Widget widget = widgetResult.getWidget();
        return widget;
    }
View Full Code Here

        this.date = OmdlModelUtils.getDate();
        this.layout = OmdlModelUtils.getOmdlLayoutForExport(page.getPageLayout().getCode());
        widgetsList = new ArrayList<OmdlWidget>();
        for(int i=0;i<page.getRegions().size(); i++){
            for(int j=0;j<page.getRegions().get(i).getRegionWidgets().size();j++){
                 Widget widget = widgetService.getWidget(page.getRegions().get(i).getRegionWidgets().get(j).getWidgetId());
                 omdlWidget = new OmdlWidget();
                 omdlWidget.setUrl(widget.getUrl());
                 omdlWidget.setLink(createLinkElement(widget.getType(), widget.getUrl()));
                 // figure out what positioning to use for this widget
                 String position = OmdlModelUtils.getPositionString(i+1, page.getRegions().size(), j+1,
                         page.getRegions().get(i).getRegionWidgets().size());
                 if(position != null && position !=""){
                     omdlWidget.setPosition(position);
View Full Code Here

        assertFalse("No validation errors", errors.hasErrors());
    }

    @Test
    public void testValidationFailsOnEmptyValues() {
        Widget widget = new WidgetImpl();
        Errors errors = new BindException(widget, WIDGET);

        widgetValidator.validate(widget, errors);

        assertEquals(4, errors.getErrorCount());
View Full Code Here

        widget.setTitle(VALID_TITLE);
        widget.setType(VALID_TYPE);
        widget.setDescription(VALID_DESCRIPTION);
        widget.setUrl(existingUrl);

        Widget newWidget = new WidgetImpl();
        newWidget.setTitle(VALID_TITLE);
        newWidget.setType(VALID_TYPE);
        newWidget.setDescription(VALID_DESCRIPTION);
        newWidget.setUrl(existingUrl);
        Errors errors = new BindException(newWidget, WIDGET);

        expect(widgetService.getWidgetByUrl(existingUrl)).andReturn(widget);
        replay(widgetService);
View Full Code Here

TOP

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

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.