Package org.jasig.portal.portlet.om

Examples of org.jasig.portal.portlet.om.IPortletDefinition


     * @param portletId
   * @return
   */
    public PortletDefinitionForm getPortletDefinitionForm(IPerson person, String portletId) {

        IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(portletId);

    // create the new form
    final PortletDefinitionForm form;
    if (def != null) {
        form = new PortletDefinitionForm(def);
        form.setId(def.getPortletDefinitionId().getStringId());
    }
    else {
        form = new PortletDefinitionForm();
    }

View Full Code Here


        }

        if (!form.isNew()) {
            // User must have the previous lifecycle permission
            // in AT LEAST ONE previous category as well
            IPortletDefinition def = this.portletDefinitionRegistry.getPortletDefinition(form.getId());
            Set<PortletCategory> categories = portletCategoryRegistry.getParentCategories(def);
            List<JsonEntityBean> categoryBeans = new ArrayList<JsonEntityBean>();
            for (PortletCategory cat : categories) {
                categoryBeans.add(new JsonEntityBean(cat));
            }
            if (!hasLifecyclePermission(publisher, def.getLifecycleState(), categoryBeans)) {
                logger.warn("User '" + publisher.getUserName() +
                        "' attempted to save the following portlet without the previous MANAGE permission:  " + form);
                throw new SecurityException("Not Authorized");
            }
        }

        if (form.isNew() || portletDefinitionRegistry.getPortletDefinition(form.getId()).getType().getId() != form.getTypeId()) {
            // User must have access to the selected CPD if s/he selected it in this interaction
            final int selectedTypeId = form.getTypeId();
            final PortletPublishingDefinition cpd = portletPublishingDefinitionDao.getChannelPublishingDefinition(selectedTypeId);
            final Map<IPortletType, PortletPublishingDefinition> allowableCpds = this.getAllowableChannelPublishingDefinitions(publisher);
            if (!allowableCpds.containsValue(cpd)) {
                logger.warn("User '" + publisher.getUserName() +
                        "' attempted to administer the following portlet without the selected " +
                        IPermission.PORTLET_MANAGER_SELECT_PORTLET_TYPE + " permission:  " + form);
                throw new SecurityException("Not Authorized");
            }
        }

    // create the group array from the form's group list
    IGroupMember[] groupMembers = new IGroupMember[form.getGroups().size()];
    for (int i = 0; i < groupMembers.length; i++) {
      JsonEntityBean bean = form.getGroups().get(i);
      EntityEnum entityEnum = EntityEnum.getEntityEnum(bean.getEntityTypeAsString());
      if (entityEnum.isGroup()) {
        groupMembers[i] = GroupService.findGroup(bean.getId());
      } else {
              groupMembers[i] = GroupService.getGroupMember(bean.getId(), entityEnum.getClazz());
       
      }
    }

        // create the category array from the form's category list
    PortletCategory[] categories = new PortletCategory[form.getCategories().size()];
    for (ListIterator<JsonEntityBean> iter = form.getCategories().listIterator(); iter.hasNext();) {
      String id = iter.next().getId();
      String iCatID = id.startsWith("cat") ? id.substring(3) : id;
      categories[iter.previousIndex()] = portletCategoryRegistry.getPortletCategory(iCatID);
    }

    IPortletDefinition portletDef = null;
    if (form.getId() == null) {
          final String fname = form.getFname();
          final String name = form.getName();
          final String title = form.getTitle();
          final String applicationId = form.getApplicationId();
          final String portletName = form.getPortletName();
          final boolean isFramework = form.isFramework();
         
          final IPortletType type = portletTypeRegistry.getPortletType(form.getTypeId());
        portletDef = portletDefinitionRegistry.createPortletDefinition(type, fname, name, title, applicationId, portletName, isFramework);
    } else {
      portletDef = portletDefinitionRegistry.getPortletDefinition(form.getId());
      }
      portletDef.setDescription(form.getDescription());
      portletDef.setFName(form.getFname());
      portletDef.setName(form.getName());
      portletDef.setTimeout(form.getTimeout());
      portletDef.setTitle(form.getTitle());
      portletDef.getPortletDescriptorKey().setWebAppName(form.getApplicationId());
      portletDef.getPortletDescriptorKey().setPortletName(form.getPortletName());
      portletDef.getPortletDescriptorKey().setFrameworkPortlet(form.isFramework());

      final IPortletType portletType = portletTypeRegistry.getPortletType(form.getTypeId());
      if (portletType == null) {
          throw new IllegalArgumentException("No IPortletType exists for ID " + form.getTypeId());
      }
      portletDef.setType(portletType);
     
      // Make parameters (NB:  these are different from preferences) in the
      // portletDef reflect the state of the form, in case any have changed.
    for (String key : form.getParameters().keySet()) {
      String value = form.getParameters().get(key).getValue();
      if (!StringUtils.isBlank(value)) {
          portletDef.addParameter(key, value);
      }
    }
      portletDef.addParameter(IPortletDefinition.EDITABLE_PARAM, Boolean.toString(form.isEditable()));
      portletDef.addParameter(IPortletDefinition.CONFIGURABLE_PARAM, Boolean.toString(form.isConfigurable()));
      portletDef.addParameter(IPortletDefinition.HAS_HELP_PARAM, Boolean.toString(form.isHasHelp()));
      portletDef.addParameter(IPortletDefinition.HAS_ABOUT_PARAM, Boolean.toString(form.isHasAbout()));

        // Now add portlet preferences
        List<IPortletPreference> preferenceList = new ArrayList<IPortletPreference>();
    for (String key : form.getPortletPreferences().keySet()) {
      List<String> prefValues = form.getPortletPreferences().get(key).getValue();
      if (prefValues != null && prefValues.size() > 0) {
        String[] values = prefValues.toArray(new String[prefValues.size()]);
        BooleanAttribute readOnly = form.getPortletPreferenceReadOnly().get(key);
        preferenceList.add(new PortletPreferenceImpl(key, readOnly.getValue(), values));
      }
    }
    portletDef.setPortletPreferences(preferenceList);

        // Lastly update the PortletDefinition's lifecycle state & lifecycle-related metadata
        updateLifecycleState(form, portletDef, publisher);

      portletPublishingService.savePortletDefinition(portletDef, publisher, Arrays.asList(categories), Arrays.asList(groupMembers));

      return this.getPortletDefinitionForm(publisher, portletDef.getPortletDefinitionId().getStringId());
  }
View Full Code Here

            logger.warn("User '" + person.getUserName() "' attempted to remove portlet '" +
                                form.getFname() + "' without the proper MANAGE permission");
            throw new SecurityException("Not Authorized");
        }

        IPortletDefinition def = portletDefinitionRegistry.getPortletDefinition(form.getId());
        portletDefinitionRegistry.deletePortletDefinition(def);

    }
View Full Code Here

            final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
            if (portletEntity == null) {
                throw new IllegalArgumentException("No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId);
            }
           
            final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
            final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
            final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
           
            final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
            statelessPortletWindowDataMap.storeWindow(portletWindowData);
           
View Full Code Here

        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
        if (portletEntity == null) {
            return null;
        }
       
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinition.getPortletDefinitionId());
        if (portletDescriptor == null) {
            return null;
        }
       
        final IPortletWindow portletWindow = new PortletWindowImpl(portletDescriptor, portletEntity, portletWindowData);
View Full Code Here

                transientEventBuffer.add(transientFolder);

                //append channel element iff subscribeId describes a transient channel, and not a regular layout channel
                final String subscribeId = this.userLayoutManager.getFocusedId();
                if (null != subscribeId && !subscribeId.equals("") && this.userLayoutManager.isTransientChannel(subscribeId)) {
                    IPortletDefinition chanDef = null;
                    try {
                        chanDef = this.userLayoutManager.getChannelDefinition(subscribeId);
                    }
                    catch (Exception e) {
                        this.logger.error("Could not obtain IChannelDefinition for subscribe id: " + subscribeId, e);
                    }
                   
                    if (chanDef != null) {
                        //TODO Move IChannelDefinition/IPortletDefinition -> StAX events code somewhere reusable
                        final Collection<Attribute> channelAttrs = new LinkedList<Attribute>();
                        channelAttrs.add(EVENT_FACTORY.createAttribute("ID", subscribeId));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("typeID", Integer.toString(chanDef.getType().getId())));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("hidden", "false"));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("unremovable", "true"));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("name", chanDef.getName()));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("description", chanDef.getDescription()));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("title", chanDef.getTitle()));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("chanID", chanDef.getPortletDefinitionId().getStringId()));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("fname", chanDef.getFName()));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("timeout", Integer.toString(chanDef.getTimeout())));
                        channelAttrs.add(EVENT_FACTORY.createAttribute("transient", "true"));

                        final StartElement startChannel = EVENT_FACTORY.createStartElement(prefix, namespaceURI, IUserLayoutManager.CHANNEL, channelAttrs.iterator(), null);
                        transientEventBuffer.offer(startChannel);

                        // add channel parameter elements
                        for(final IPortletDefinitionParameter parm : chanDef.getParameters())
                        {
                            final Collection<Attribute> parameterAttrs = new LinkedList<Attribute>();
                            parameterAttrs.add(EVENT_FACTORY.createAttribute("name",parm.getName()));
                            parameterAttrs.add(EVENT_FACTORY.createAttribute("value",parm.getValue()));
View Full Code Here

        }
       
        return this.getTransactionOperations().execute(new TransactionCallback<AggregatedPortletMapping>() {
            @Override
            public AggregatedPortletMapping doInTransaction(TransactionStatus status) {
                final IPortletDefinition portletDefinition = portletDefinitionDao.getPortletDefinitionByFname(fname);
                final String name;
                if (portletDefinition != null) {
                    name = portletDefinition.getName();
                }
                else {
                    name = fname;
                }
               
View Full Code Here

    /* (non-Javadoc)
     * @see org.jasig.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletApplicationDescriptor(org.jasig.portal.portlet.om.IPortletDefinitionId)
     */
    @Override
    public PortletApplicationDefinition getParentPortletApplicationDescriptor(IPortletDefinitionId portletDefinitionId) {
        final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
        if (portletDefinition == null) {
            return null;
        }
       
        final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
View Full Code Here

    /* (non-Javadoc)
     * @see org.jasig.portal.portlet.registry.IPortletDefinitionRegistry#getParentPortletDescriptor(org.jasig.portal.portlet.om.IPortletDefinitionId)
     */
    @Override
    public PortletDefinition getParentPortletDescriptor(IPortletDefinitionId portletDefinitionId) {
        final IPortletDefinition portletDefinition = this.getPortletDefinition(portletDefinitionId);
        if (portletDefinition == null) {
            return null;
        }
       
        final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(portletDefinition);
View Full Code Here

         */
        try
        {
          IPortletDefinitionRegistry registry = PortletDefinitionRegistryLocator.getPortletDefinitionRegistry();
            int pubId = Integer.parseInt(getChannelPublishId());
            IPortletDefinition def = registry.getPortletDefinition(getChannelPublishId());
            IPortletDefinitionParameter parm = def.getParameter(parameterName);

            if (parm == null) // ad-hoc parm so delete
            {
                parameters.remove(parameterName);
            }
View Full Code Here

TOP

Related Classes of org.jasig.portal.portlet.om.IPortletDefinition

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.