Package org.apache.jetspeed.om.portlet

Examples of org.apache.jetspeed.om.portlet.PortletDefinition


    {
        List list = new LinkedList();
        Iterator portlets = registry.getAllPortletDefinitions().iterator();
        while ( portlets.hasNext() )
        {
            PortletDefinition portlet = (PortletDefinition)portlets.next();
            PortletApplication app = (PortletApplication)portlet.getApplication();
            String appName = app.getName();
            if ( appName == null )
                continue;
            if ( ! appName.equals( "jetspeed-layouts" ) )
                continue;

            String uniqueName = appName + "::" + portlet.getPortletName();
            list.add( new LayoutInfoImpl( uniqueName,
                      portlet.getDisplayNameText( request.getLocale() ),
                      portlet.getDescriptionText( request.getLocale() ) ) );

        }
        return list;
    }
View Full Code Here


        else
            portlets = searchEngine.search(filter).getResults().iterator();
       
        while (portlets.hasNext())
        {
            PortletDefinition portlet = null;
            if (filter == null)
                portlet = (PortletDefinition)portlets.next();
            else
                portlet = this.getPortletFromParsedObject((ParsedObject)portlets.next());
           
            if (portlet == null)
                continue;
           
            // Do not display Jetspeed Layout Applications
            PortletApplication pa = (PortletApplication)portlet.getApplication();
            if (pa.isLayoutApplication())
                continue;
                
            // SECURITY filtering
            String uniqueName = pa.getName() + "::" + portlet.getPortletName();
            if (securityAccessController.checkPortletAccess(portlet, JetspeedActions.MASK_VIEW))
            {
                InitParam param = portlet.getInitParam(PORTLET_ICON);
                String image;
                if (param != null)
                {
                    //String relativeImagePath = param.getValue();
                    //String context = muta.getWebApplicationDefinition().getContextRoot();
                    // Have to use a supported icon in jetspeed, otherwise image can be out of skew
                    image = "images/portlets/" + param.getParamValue();
                }
                else
                {                                       
                    image = "images/portlets/applications-internet.png";
                }
               

                PortletInfo portInfo=new PortletInfo(uniqueName,
                    StringEscapeUtils.escapeXml(portlet.getDisplayNameText(locale)),
                        StringEscapeUtils.escapeXml(portlet.getDescriptionText(locale)), image);
               
                list.add(portInfo);
            }
        }           
        Collections.sort(list, this);
View Full Code Here

        while (pi.hasNext())
        {
            JSPortlet portlet = (JSPortlet) pi.next();
      if (pa != null)
      {
                PortletDefinition pd = pa.getPortlet(portlet.getName());
                if (pd != null)
                {
                    importPD(app, portlet, pd, settings, log);
                }
            }
View Full Code Here

        JSApplication jsApplication = null;
        /**
         * while more PAs for each portletDef list:entityMan:getPortletEntity(pd)
         */
        Iterator pi = pa.getPortlets().iterator();
        PortletDefinition pd = null;
        JSPortlets portlets = new JSPortlets();
        while (pi.hasNext())
        {
            try
            {
                pd = (PortletDefinition) pi.next();
                JSPortlet p = exportPD(pd, settings, log);
                if (p != null)
                {
                    log.debug("--processed PA " + pa.getName() + " with pd=" + pd.getPortletName());
                    portlets.add(p);
                }
                else
                    log.debug("--processed PA " + pa.getName() + " with NULL pd=" + pd.getPortletName());
            }
            catch (Exception e)
            {
                throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] { "PortletDefinition", e.getMessage() }),
                                              e);
View Full Code Here

        String portletName = PortletRegistryHelper.parsePortletName(name);

        Criteria c = new Criteria();
        c.addEqualTo("app.name", appName);
        c.addEqualTo("portletName", portletName);
        PortletDefinition def = (PortletDefinition) getPersistenceBrokerTemplate().getObjectByQuery(
        QueryFactory.newQuery(PortletDefinitionImpl.class, c));
        if (def != null && def.getApplication() == null)
        {
            final String msg = "getPortletDefinitionByIdentifier() returned a PortletDefinition that has no parent PortletApplication.";
            throw new IllegalStateException(msg);
        }
View Full Code Here

        {
            //System.out.println("%%% portlet remote removed " + key);           
            RegistryPortletCache.cacheRemoveQuiet((String)key, (RegistryCacheObjectWrapper)element);
            if (listeners != null && !listeners.isEmpty())
            {
                PortletDefinition pd = this.getPortletDefinitionByUniqueName((String)key);
                if (pd != null)
                {
                    for (int ix=0; ix < listeners.size(); ix++)
                    {
                        RegistryEventListener listener = listeners.get(ix);
View Full Code Here

        {
            throw new FailedToStorePortletDefinitionException("Cannot clone to portlet named " + newPortletName + ", name already exists");
        }

        // create new portlet in source portlet application
        PortletDefinition copy = source.getApplication().addPortlet(newPortletName);
       
        // First set display name
       
        DisplayName displayName = copy.addDisplayName(JetspeedLocale.getDefaultLocale().getLanguage());
        displayName.setDisplayName(newPortletName);
       
        // And, then, copy all attributes
       
        copy.setPortletClass(source.getPortletClass());
        copy.setResourceBundle(source.getResourceBundle());
        copy.setPreferenceValidatorClassname(source.getPreferenceValidatorClassname());
        copy.setExpirationCache(source.getExpirationCache());
        copy.setCacheScope(source.getCacheScope());
       
        for (LocalizedField field : source.getMetadata().getFields())
        {
            copy.getMetadata().addField(field.getLocale(), field.getName(), field.getValue());
        }
       
        copy.setJetspeedSecurityConstraint(source.getJetspeedSecurityConstraint());
       
        for (Description desc : source.getDescriptions())
        {
            Description copyDesc = copy.addDescription(desc.getLang());
            copyDesc.setDescription(desc.getDescription());
        }

        for (InitParam initParam : source.getInitParams())
        {
            InitParam copyInitParam = copy.addInitParam(initParam.getParamName());
            copyInitParam.setParamValue(initParam.getParamValue());
           
            for (Description desc : initParam.getDescriptions())
            {
                Description copyDesc = copyInitParam.addDescription(desc.getLang());
                copyDesc.setDescription(desc.getDescription());
            }
        }
       
        for (EventDefinitionReference eventDefRef : source.getSupportedProcessingEvents())
        {
            copy.addSupportedProcessingEvent(eventDefRef.getQName());
        }

        for (EventDefinitionReference eventDefRef : source.getSupportedPublishingEvents())
        {
            copy.addSupportedPublishingEvent(eventDefRef.getQName());
        }
       
        for (SecurityRoleRef secRoleRef : source.getSecurityRoleRefs())
        {
            SecurityRoleRef copySecRoleRef = copy.addSecurityRoleRef(secRoleRef.getRoleName());
            copySecRoleRef.setRoleLink(secRoleRef.getRoleLink());
           
            for (Description desc : secRoleRef.getDescriptions())
            {
                Description copyDesc = copySecRoleRef.addDescription(desc.getLang());
                copyDesc.setDescription(desc.getDescription());
            }
        }
       
        for (Supports supports : source.getSupports())
        {
            Supports copySupports = copy.addSupports(supports.getMimeType());
           
            for (String portletMode : supports.getPortletModes())
            {
                copySupports.addPortletMode(portletMode);
            }
           
            for (String windowState : supports.getWindowStates())
            {
                copySupports.addWindowState(windowState);
            }
        }
       
        for (Language language : source.getLanguages())
        {
            Language copyLanguage = copy.addLanguage(language.getLocale());
            copyLanguage.setTitle(language.getTitle());
            copyLanguage.setShortTitle(language.getShortTitle());
            copyLanguage.setKeywords(language.getKeywords());
            copyLanguage.setSupportedLocale(language.isSupportedLocale());
        }
       
        for (ContainerRuntimeOption runtimeOption : source.getContainerRuntimeOptions())
        {
            ContainerRuntimeOption copyRuntimeOption = copy.addContainerRuntimeOption(runtimeOption.getName());
           
            for (String value : runtimeOption.getValues())
            {
                copyRuntimeOption.addValue(value);
            }
        }
       
        copy.getSupportedPublicRenderParameters().addAll(source.getSupportedPublicRenderParameters());
       
        //savePortletDefinition(copy);
        try
        {
            updatePortletApplication(source.getApplication());
        }
        catch (RegistryException e)
        {
            throw new FailedToStorePortletDefinitionException(e);
        }
        for (Preference pref : source.getPortletPreferences().getPortletPreferences())
        {
            Preference copyPref = copy.addDescriptorPreference(pref.getName());
            copyPref.setReadOnly(pref.isReadOnly());
           
            for (String value : pref.getValues())
            {
                copyPref.addValue(value);
View Full Code Here

                if (StringUtils.isBlank(uniqueName))
                {
                    continue;
                }
               
                PortletDefinition pd = portletRegistry.getPortletDefinitionByUniqueName(uniqueName);
               
                if (pd != null && securityAccessController.checkPortletAccess(pd, JetspeedActions.MASK_VIEW))
                {
                    searchedPortletDefinitions.add(pd);
                }
            }
           
            Collection<PortletDefinition> filteredPortletDefinitions = filterPortletDefinitionsBySecurityAccess(searchedPortletDefinitions, JetspeedActions.MASK_VIEW, servletRequest);
            pdBeans.setTotalSize(filteredPortletDefinitions.size());
           
            for (PortletDefinition pd : (Collection<PortletDefinition>) PaginationUtils.subCollection(filteredPortletDefinitions, beginIndex, maxResults))
            {
                pdBeanList.add(new PortletDefinitionBean(pd));
            }
        }
        else
        {
            if (StringUtils.isBlank(applicationName) && StringUtils.isBlank(definitionName))
            {
                Collection<PortletDefinition> pds = filterPortletDefinitionsBySecurityAccess(portletRegistry.getAllPortletDefinitions(), JetspeedActions.MASK_VIEW, servletRequest);
                pdBeans.setTotalSize(pds.size());
               
                for (PortletDefinition pd : (Collection<PortletDefinition>) PaginationUtils.subCollection(pds, beginIndex, maxResults))
                {
                    pdBeanList.add(new PortletDefinitionBean(pd));
                }
            }
            else
            {
                PortletApplication pa = portletRegistry.getPortletApplication(applicationName, true);
               
                if (pa != null)
                {
                    if (StringUtils.isBlank(definitionName))
                    {
                        Collection<PortletDefinition> pds = filterPortletDefinitionsBySecurityAccess(pa.getPortlets(), JetspeedActions.MASK_VIEW, servletRequest);
                        pdBeans.setTotalSize(pds.size());
                       
                        for (PortletDefinition pd : (List<PortletDefinition>) PaginationUtils.subCollection(pds, beginIndex, maxResults))
                        {
                            pdBeanList.add(new PortletDefinitionBean(pd));
                        }
                    }
                    else
                    {
                        PortletDefinition pd = pa.getPortlet(definitionName);
                       
                        if (pd != null && securityAccessController.checkPortletAccess(pd, JetspeedActions.MASK_VIEW))
                        {
                            pdBeanList.add(new PortletDefinitionBean(pd));
                            pdBeans.setTotalSize(1);
View Full Code Here

            @Override
            public IDataProvider<DescriptionBean> getDataProvider()
            {
                PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
                PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
                PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());

                final InitParam param = def.getInitParam(initParam.getParamName());

                List<DescriptionBean> list = new ArrayList<DescriptionBean>();

                for (Description description : param.getDescriptions())
                {
                    list.add(new DescriptionBean(description));
                }

                return new ListDataProvider<DescriptionBean>(list);
            }
           
            @Override
            protected Button saveButton(String componentId)
            {
                return new Button(componentId)
                {

                    @Override
                    public void onSubmit()
                    {
                        PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
                        PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
                        PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());
                        if (newLocale != null && newDescription != null)
                        {
                            InitParam param = def.getInitParam(initParam.getParamName());
                            Locale locale = new Locale(newLocale);
                            Description targetDescription = null;
                           
                            for (Description description : param.getDescriptions())
                            {
                                if (description.getLocale().equals(locale))
                                {
                                    targetDescription = description;
                                    break;
                                }
                            }
                           
                            if (targetDescription == null)
                            {
                                targetDescription = param.addDescription(newLocale);
                            }
                           
                            targetDescription.setDescription(newDescription);
                           
                            newLocale = null;
                            newDescription = null;
                        }

                        FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
                       
                        try
                        {
                            registry.savePortletDefinition(def);
                            StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveOK", this, null, new Object [] { paNodeBean.getName() } );
                            feed.info(resModel.getString());
                        }
                        catch (RegistryException e)
                        {
                            logger.error("Failed to save portlet definition.", e);
                            StringResourceModel resModel = new StringResourceModel("pam.details.action.status.portlet.saveFailure", this, null, new Object [] { paNodeBean.getName(), e.getMessage() } );
                            feed.info(resModel.getString());
                        }
                    }
                };
            }

            @Override
            public void delete(IModel<DescriptionBean>[] fields)
            {
                FeedbackPanel feed = (FeedbackPanel) getPage().get("feedback");
               
                try
                {
                    PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
                    PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
                    PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());
                    InitParam initParam = def.getInitParam(name);
                   
                    if (initParam != null)
                    {
                        for (Iterator<Description> it = initParam.getDescriptions().iterator(); it.hasNext(); )
                        {
View Full Code Here

    @Override
    public void delete(IModel<InitParam>[] fields)
    {
        PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
        PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
        PortletDefinition def = PortletApplicationUtils.getPortletOrClone(app, paNodeBean.getName());

        Iterator<InitParam> it = def.getInitParams().iterator();
        while (it.hasNext())
        {
            InitParam initParam = it.next();
            String paramName = initParam.getParamName();
           
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.portlet.PortletDefinition

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.