/**
  * 获取ID数组,如果ID不存在则获取PATH数组。
  *
  * @param params 标签参数
  * @param siteIds 如果为null,则自动获取所有站点path
  * @return 如果不存在,则返回null。
  * @throws TemplateException
  */
 protected Integer[] getChannelIdsOrPaths(Map<String, TemplateModel> params, Integer[] siteIds)
     throws TemplateException {
   Integer[] ids = getChannelIds(params);
   if (ids != null) {
     return ids;
   }
   String[] paths = getChannelPaths(params);
   if (paths == null) {
     return null;
   }
   Set<Integer> set = new HashSet<Integer>();
   Channel channel;
   if (siteIds == null) {
     List<CmsSite> list = cmsSiteMng.getListFromCache();
     siteIds = new Integer[list.size()];
     int i = 0;
     for (CmsSite site : list) {
       siteIds[i++] = site.getId();
     }
   }
   for (Integer siteId : siteIds) {
     for (String path : paths) {
       channel = channelMng.findByPathForTag(path, siteId);
       if (channel != null) {
         set.add(channel.getId());
       }
     }
   }
   if (set.size() > 0) {
     return set.toArray(new Integer[set.size()]);
   } else {
     return null;
   }
 }
Beispiel #2
0
 public Set<Integer> getContriChannelIds(Integer siteId) {
   Set<Channel> channels = getContriChannels();
   Set<Integer> ids = new HashSet<Integer>();
   for (Channel c : channels) {
     if (c.getSite().getId().equals(siteId)) {
       ids.add(c.getId());
     }
   }
   return ids;
 }
 protected Integer[] getChannelIdsByPaths(String[] paths, Integer siteId) {
   Set<Integer> set = new HashSet<Integer>();
   Channel channel;
   for (String path : paths) {
     channel = channelMng.findByPathForTag(path, siteId);
     if (channel != null) {
       set.add(channel.getId());
     }
   }
   if (set.size() > 0) {
     return set.toArray(new Integer[set.size()]);
   } else {
     return null;
   }
 }
Beispiel #4
0
 public void addToContriChannels(Channel channel) {
   Set<Channel> channels = getContriChannels();
   if (channels == null) {
     channels = new TreeSet<Channel>(new PriorityComparator());
     setContriChannels(channels);
   }
   channels.add(channel);
   channel.getContriGroups().add(this);
 }