Package org.jasig.portal.channel

Examples of org.jasig.portal.channel.IChannelDefinition


                throw new Exception("'Label' must be specified.");
            }
            // now get pub ID of target channel
            IChannelRegistryStore crs =
                ChannelRegistryStoreFactory.getChannelRegistryStoreImpl();
            IChannelDefinition chanDef = crs.getChannelDefinition(fname);
            int pubId = chanDef.getId();
           
            // next build the URL for the link
            String url =
                UPFileSpec.buildUPFile(
                    UPFileSpec.RENDER_METHOD,
View Full Code Here


    {
        IChannelRegistryStore crs = ChannelRegistryStoreFactory
                .getChannelRegistryStoreImpl();
        id = id.startsWith("chan") ? id.substring(4) : id;
        int pubId = Integer.parseInt(id);
        IChannelDefinition def = null;
        try
        {
            def = crs.getChannelDefinition(pubId);
        } catch (Exception e)
        {
            throw new PortalException("unable.to.load.channel.definition "
                    + id, e);
        }
        return def.getParameters();
    }
View Full Code Here

        // (3) Restore chanID attributes on <channel> elements...
        for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//channel").iterator(); it.hasNext();) {
            org.dom4j.Element c = it.next();
            final String fname = c.valueOf("@fname");
            IChannelDefinition cd = this.channelRegistryStore.getChannelDefinition(fname);
            if (cd == null) {
                throw new IllegalArgumentException("No published channel for fname=" + fname + " referenced by layout for " + ownerUsername);
            }
            c.addAttribute("chanID", String.valueOf(cd.getId()));
        }
       
        // (2) Restore locale info...
        // (This step doesn't appear to be needed for imports)
View Full Code Here

        String type = ls.getType();
        if (type != null && type.startsWith(Constants.LEGACY_NS))
            type = Constants.NS + type.substring(Constants.LEGACY_NS.length());

  if (ls.isChannel()) {
    IChannelDefinition channelDef = channelRegistryStore.getChannelDefinition(ls.getChanId());
    if (channelDef != null && channelApproved(channelDef.getApprovalDate())) {
        if (localeAware) {
            channelDef.setLocale(ls.getLocale()); // for i18n by Shoji
            }
      structure = channelDef.getDocument(doc, channelPrefix + ls.getStructId());
    } else {
        // Create an error channel if channel is missing or not approved
        String missingChannel = "Unknown";
        if (channelDef != null) {
            missingChannel = channelDef.getName();
        }
        structure = MissingChannelDefinition.INSTANCE.getDocument(doc, channelPrefix + ls.getStructId(),
                "The '" + missingChannel + "' channel is no longer available. " +
                "Please remove it from your layout.",
                ErrorCode.CHANNEL_MISSING_EXCEPTION.getCode());
View Full Code Here

                }
            }
            NodeList parameters = node.getChildNodes();
            if (parameters != null && isChannel)
            {
                IChannelDefinition channelDef = channelRegistryStore.getChannelDefinition(chanId);
                for (int i = 0; i < parameters.getLength(); i++)
                {
                    if (parameters.item(i).getNodeName().equals("parameter"))
                    {
                        Element parmElement = (Element) parameters.item(i);
                        NamedNodeMap nm = parmElement.getAttributes();
                        String parmName = nm.getNamedItem("name").getNodeValue();
                        String parmValue = nm.getNamedItem("value").getNodeValue();
                        Node override = nm.getNamedItem("override");

                        // if no override specified then default to allowed
                        if (override != null
                            && !override.getNodeValue().equals("yes"))
                        {
                            // can't override
                        } else
                        {
                            // override only for adhoc or if diff from chan def
                            IChannelParameter cp = channelDef.getParameter(parmName);
                            if (cp == null || !cp.getValue().equals(parmValue))
                            {
                                parmStmt.clearParameters();
                                parmStmt.setInt(1, saveStructId);
                                parmStmt.setString(2, parmName);
View Full Code Here

        processGroupsRecursively(memberGroup, owner, categoryE);
      } else {
        IEntity channelDefMember = (IEntity)member;
        int channelPublishId = CommonUtils.parseInt(channelDefMember.getKey());
        if ( channelPublishId > 0 ) {
         IChannelDefinition channelDef = crs.getChannelDefinition(channelPublishId);
         if (channelDef != null) {
          // Make sure channel is approved
          Date approvalDate = channelDef.getApprovalDate();
          if (approvalDate != null && approvalDate.before(now)) {
            Element channelDefE = channelDef.getDocument(owner, "chan" + channelPublishId);
            channelDefE = (Element)owner.importNode(channelDefE, true);
           
            if (channelDefE.getAttribute("ID") != null)
                channelDefE.setIdAttribute("ID", true);
           
View Full Code Here

    // Reset the channel registry cache
    channelRegistryCache.remove(CHANNEL_REGISTRY_CACHE_KEY);
    // Remove the channel
    String sChannelPublishId = channelID.startsWith("chan") ? channelID.substring(4) : channelID;
    int channelPublishId = Integer.parseInt(sChannelPublishId);
    IChannelDefinition channelDef = crs.getChannelDefinition(channelPublishId);
    crs.disapproveChannelDefinition(channelDef);

    // Record that a channel has been deleted
    EventPublisherLocator.getApplicationEventPublisher().publishEvent(new RemovedChannelDefinitionPortalEvent(channelDef, person, channelDef));
  }
View Full Code Here

   * @param chanId
   * @return
   */
  public ChannelDefinitionForm getChannelDefinitionForm(int chanId) {
   
    IChannelDefinition def = channelRegistryStore.getChannelDefinition(chanId);
   
    // create the new form
    final ChannelDefinitionForm form;
    if (def != null) {
        final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinition(def.getId());
        form = new ChannelDefinitionForm(def, portletDefinition);
        form.setId(def.getId());
    }
    else {
        form = new ChannelDefinitionForm();
    }
   
View Full Code Here

      String iCatID = id.startsWith("cat") ? id.substring(3) : id;
      categories[iter.previousIndex()] = channelRegistryStore
          .getChannelCategory(iCatID);
    }

      IChannelDefinition channelDef = channelRegistryStore.getChannelDefinition(form.getId());
      if (channelDef == null) {
          final String fname = form.getFname();
          final String clazz = form.getJavaClass();
          final String name = form.getName();
          final String title = form.getTitle();
          final int typeId = form.getTypeId();
         
        channelDef = channelRegistryStore.newChannelDefinition(typeId, fname, clazz, name, title);
      }
      channelDef.setDescription(form.getDescription());
      channelDef.setEditable(form.isEditable());
      channelDef.setFName(form.getFname());
      channelDef.setHasAbout(form.isHasAbout());
      channelDef.setHasHelp(form.isHasHelp());
      channelDef.setIsSecure(form.isSecure());
      channelDef.setJavaClass(form.getJavaClass());
      channelDef.setName(form.getName());
      channelDef.setTimeout(form.getTimeout());
      channelDef.setTitle(form.getTitle());
     
      Date now = new Date();

    int order = form.getLifecycleState().getOrder();
   
    if (form.getId() < 0) {
     
      if (order >= ChannelLifecycleState.APPROVED.getOrder()) {
        channelDef.setApproverId(publisher.getID());
        channelDef.setApprovalDate(now);
      }
     
      if (order >= ChannelLifecycleState.PUBLISHED.getOrder()) {
          channelDef.setPublisherId(publisher.getID());
          if (channelDef.getPublishDate() == null) {
            channelDef.setPublishDate(now);
          }
      } else if (form.getPublishDate() != null) {
        channelDef.setPublishDate(form.getPublishDateTime());
        channelDef.setPublisherId(publisher.getID());
      }

      if (order >= ChannelLifecycleState.EXPIRED.getOrder()) {
          channelDef.setExpirerId(publisher.getID());
          if (channelDef.getExpirationDate() == null) {
            channelDef.setExpirationDate(now);
          }
      } else if (form.getExpirationDate() != null) {
        channelDef.setExpirationDate(form.getExpirationDateTime());
        channelDef.setExpirerId(publisher.getID());
      }
     
    }
   
    // if we're updating a channel
    else {

      if (order >= ChannelLifecycleState.APPROVED.getOrder()) {
        if (channelDef.getApproverId() < 0) {
          channelDef.setApproverId(publisher.getID());
        }
        if (channelDef.getApprovalDate() == null) {
          channelDef.setApprovalDate(now);
        }
      } else {
        channelDef.setApprovalDate(null);
        channelDef.setApproverId(-1);
      }
     
      if (order >= ChannelLifecycleState.PUBLISHED.getOrder()) {
        if (channelDef.getPublisherId() < 0) {
          channelDef.setPublisherId(publisher.getID());
        }
        if (channelDef.getPublishDate() == null) {
          channelDef.setPublishDate(now);
        }
      } else if (form.getPublishDate() != null) {
        channelDef.setPublishDate(form.getPublishDate());
        if (channelDef.getPublisherId() < 0) {
          channelDef.setPublisherId(publisher.getID());
        }
      } else {
        channelDef.setPublishDate(null);
        channelDef.setPublisherId(-1);
      }
     
      if (order >= ChannelLifecycleState.EXPIRED.getOrder()) {
        if (channelDef.getExpirerId() < 0) {
          channelDef.setExpirerId(publisher.getID());
        }
        if (channelDef.getExpirationDate() == null) {
          channelDef.setExpirationDate(now);
        }
      } else if (form.getExpirationDate() != null) {
        channelDef.setExpirationDate(form.getExpirationDate());
        if (channelDef.getExpirerId() < 0) {
          channelDef.setExpirerId(publisher.getID());
        }
      } else {
        channelDef.setExpirationDate(null);
        channelDef.setExpirerId(-1);
      }
     
    }

     
      final IChannelType channelType = channelRegistryStore.getChannelType(form.getTypeId());
      if (channelType == null) {
          throw new IllegalArgumentException("No IChannelType exists for ID " + form.getTypeId());
      }
      channelDef.setType(channelType);
     
      // add channel parameters
    List<IPortletPreference> preferenceList = new ArrayList<IPortletPreference>();
    for (String key : form.getParameters().keySet()) {
      String value = form.getParameters().get(key).getValue();
      if (!StringUtils.isBlank(value)) {
        boolean override = false;
        if (form.getParameterOverrides().containsKey(key)) {
          override = form.getParameterOverrides().get(key).getValue();
        }
        if (key.startsWith("PORTLET.")) {
          preferenceList.add(new PortletPreferenceImpl(key, !override, new String[]{value}));
        } else {
          channelDef.addParameter(key, value, override);
        }
      }
    }
   
    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()]);
        boolean readOnly = true;
        if (form.getPortletPreferencesOverrides().containsKey(key)) {
          readOnly = !form.getPortletPreferencesOverrides().get(key).getValue();
        }
        preferenceList.add(new PortletPreferenceImpl(key, readOnly, values));
      }
    }
   
    final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinition(channelDef.getId());
    final IPortletPreferences portletPreferences = portletDefinition.getPortletPreferences();
    portletPreferences.setPortletPreferences(preferenceList);
     
      channelPublishingService.saveChannelDefinition(channelDef, publisher, categories, groupMembers);

      return this.getChannelDefinitionForm(channelDef.getId());
  }
View Full Code Here

   *
   * @param channelID the channel ID
   * @param person the person removing the channel
   */
  public void removePortletRegistration(int channelId, IPerson person) {
    IChannelDefinition channelDef = channelRegistryStore.getChannelDefinition(channelId);
    channelPublishingService.removeChannelDefinition(channelDef, person);
  }
View Full Code Here

TOP

Related Classes of org.jasig.portal.channel.IChannelDefinition

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.