<commit_before>/**
 * Copyright  2001 The JA-SIG Collaborative.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the JA-SIG Collaborative
 *    (http://www.jasig.org/)."
 *
 * THIS SOFTWARE IS PROVIDED BY THE JA-SIG COLLABORATIVE "AS IS" AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JA-SIG COLLABORATIVE OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * formatted with JxBeauty (c) <EMAIL>
 */


package  org.jasig.portal.channels;

import  org.jasig.portal.*;
import  org.jasig.portal.utils.XSLT;
import  org.jasig.portal.services.LogService;
import  org.apache.xerces.dom.*;
import  org.w3c.dom.Node;
import  org.w3c.dom.Element;
import  org.w3c.dom.NodeList;
import  org.w3c.dom.Document;
import  org.xml.sax.DocumentHandler;
import  java.io.File;
import  java.net.URL;
import  java.util.*;


/**
 * Provides methods associated with subscribing to a channel.
 * This includes preview, listing all available channels
 * and placement on a users page.
 * @author <NAME>
 * @version $Revision$
 */
public class CSubscriber
    implements IPrivilegedChannel {
  IUserLayoutManager ulm;
  ChannelStaticData staticData = null;
  ChannelRuntimeData runtimeData = null;
  StylesheetSet set = null;
  IChannelRegistryStore chanReg = null;
  private static final String fs = File.separator;
  private static final String portalBaseDir = GenericPortalBean.getPortalBaseDir();
  String stylesheetDir = portalBaseDir + fs + "webpages" + fs + "stylesheets" + fs + "org" + fs + "jasig" + fs + "portal"
      + fs + "channels" + fs + "CSubscriber";
  // channel modes
  private static final int NONE = 0;
  private static final int BROWSE = 1;
  private static final int SUBSCRIBE = 2;
  private static final int SUBTO = 3;
  private static final int PREVIEW = 4;
  private int mode = NONE;
  private DocumentImpl userLayoutXML = null;
  private Document channelRegistry = null;
  private String action = null;
  private String categoryID = null;
  private String folderID = null;
  private String[] subIDs = null;               // contains the IDs of channels to be subscribed
  private boolean modified = false;             // modification flag
  private static final String regID = "top";                    // mark the top level of the categories

  /**
   * Construct a CSubscriber.
   */
  public CSubscriber () throws PortalException {
    this.staticData = new ChannelStaticData();
    this.runtimeData = new ChannelRuntimeData();
    this.set = new StylesheetSet(stylesheetDir + fs + "CSubscriber.ssl");
    this.set.setMediaProps(portalBaseDir + fs + "properties" + fs + "media.properties");
    // RDBMChannelRegistryStore should be retrieved in a different way!!
    this.chanReg = RdbmServices.getChannelRegistryStoreImpl();
  }

  /**
   * Get a handle on the UserLayoutManager
   * @param pcs portal control structures
   */
  public void setPortalControlStructures (PortalControlStructures pcs) {
    ulm = pcs.getUserLayoutManager();
  }

  /**
   * Returns channel runtime properties
   * @return handle to runtime properties
   */
  public ChannelRuntimeProperties getRuntimeProperties () {
    // Channel will always render, so the default values are ok
    return  new ChannelRuntimeProperties();
  }

  /**
   * Receive any events from the layout
   * @param ev layout event
   */
  public void receiveEvent (PortalEvent ev) {
  // no events for this channel
  }

  /**
   * Receive static channel data from the portal
   * @param sd static channel data
   */
  public void setStaticData (ChannelStaticData sd) {
    this.staticData = sd;
  }

  /**
   * Receives channel runtime data from the portal and processes actions
   * passed to it.  The names of these parameters are entirely up to the channel.
   * @param rd handle to channel runtime data
   */
  public void setRuntimeData (ChannelRuntimeData rd) throws PortalException {
    this.runtimeData = rd;
    String catID = null;
    //get fresh copies of both since we don't really know if changes have been made
    if (userLayoutXML == null)
      userLayoutXML = (DocumentImpl) ulm.getUserLayoutCopy();
    if(channelRegistry == null) {
        try {
	channelRegistry = chanReg.getChannelRegistryXML();
        } catch (java.sql.SQLException sqle) {
          LogService.instance().log(LogService.ERROR, sqle);<commit_msg>Changed catch from SQLException to Exception<commit_after>/**
 * Copyright  2001 The JA-SIG Collaborative.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the JA-SIG Collaborative
 *    (http://www.jasig.org/)."
 *
 * THIS SOFTWARE IS PROVIDED BY THE JA-SIG COLLABORATIVE "AS IS" AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE JA-SIG COLLABORATIVE OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * formatted with JxBeauty (c) <EMAIL>
 */


package  org.jasig.portal.channels;

import  org.jasig.portal.*;
import  org.jasig.portal.utils.XSLT;
import  org.jasig.portal.services.LogService;
import  org.apache.xerces.dom.*;
import  org.w3c.dom.Node;
import  org.w3c.dom.Element;
import  org.w3c.dom.NodeList;
import  org.w3c.dom.Document;
import  org.xml.sax.DocumentHandler;
import  java.io.File;
import  java.net.URL;
import  java.util.*;


/**
 * Provides methods associated with subscribing to a channel.
 * This includes preview, listing all available channels
 * and placement on a users page.
 * @author <NAME>
 * @version $Revision$
 */
public class CSubscriber
    implements IPrivilegedChannel {
  IUserLayoutManager ulm;
  ChannelStaticData staticData = null;
  ChannelRuntimeData runtimeData = null;
  StylesheetSet set = null;
  IChannelRegistryStore chanReg = null;
  private static final String fs = File.separator;
  private static final String portalBaseDir = GenericPortalBean.getPortalBaseDir();
  String stylesheetDir = portalBaseDir + fs + "webpages" + fs + "stylesheets" + fs + "org" + fs + "jasig" + fs + "portal"
      + fs + "channels" + fs + "CSubscriber";
  // channel modes
  private static final int NONE = 0;
  private static final int BROWSE = 1;
  private static final int SUBSCRIBE = 2;
  private static final int SUBTO = 3;
  private static final int PREVIEW = 4;
  private int mode = NONE;
  private DocumentImpl userLayoutXML = null;
  private Document channelRegistry = null;
  private String action = null;
  private String categoryID = null;
  private String folderID = null;
  private String[] subIDs = null;               // contains the IDs of channels to be subscribed
  private boolean modified = false;             // modification flag
  private static final String regID = "top";                    // mark the top level of the categories

  /**
   * Construct a CSubscriber.
   */
  public CSubscriber () throws PortalException {
    this.staticData = new ChannelStaticData();
    this.runtimeData = new ChannelRuntimeData();
    this.set = new StylesheetSet(stylesheetDir + fs + "CSubscriber.ssl");
    this.set.setMediaProps(portalBaseDir + fs + "properties" + fs + "media.properties");
    // RDBMChannelRegistryStore should be retrieved in a different way!!
    this.chanReg = RdbmServices.getChannelRegistryStoreImpl();
  }

  /**
   * Get a handle on the UserLayoutManager
   * @param pcs portal control structures
   */
  public void setPortalControlStructures (PortalControlStructures pcs) {
    ulm = pcs.getUserLayoutManager();
  }

  /**
   * Returns channel runtime properties
   * @return handle to runtime properties
   */
  public ChannelRuntimeProperties getRuntimeProperties () {
    // Channel will always render, so the default values are ok
    return  new ChannelRuntimeProperties();
  }

  /**
   * Receive any events from the layout
   * @param ev layout event
   */
  public void receiveEvent (PortalEvent ev) {
  // no events for this channel
  }

  /**
   * Receive static channel data from the portal
   * @param sd static channel data
   */
  public void setStaticData (ChannelStaticData sd) {
    this.staticData = sd;
  }

  /**
   * Receives channel runtime data from the portal and processes actions
   * passed to it.  The names of these parameters are entirely up to the channel.
   * @param rd handle to channel runtime data
   */
  public void setRuntimeData (ChannelRuntimeData rd) throws PortalException {
    this.runtimeData = rd;
    String catID = null;
    //get fresh copies of both since we don't really know if changes have been made
    if (userLayoutXML == null)
      userLayoutXML = (DocumentImpl) ulm.getUserLayoutCopy();
    if(channelRegistry == null) {
        try {
	channelRegistry = chanReg.getChannelRegistryXML();
        } catch (Exception e) {
          LogService.instance().log(LogService.ERROR, e);
{'fraction_non_alphanumeric': 0.0791295746785361, 'fraction_numerical': 0.0028774390792194945, 'mean_word_length': 3.517465475223396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2268017', 'n_tokens_mistral': 3172, 'n_tokens_neox': 3003, 'n_words': 1192}