⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataaccredit.java

📁 这是一个用java和xml编写的流媒体服务器管理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * ====================================================================
 * The EMS Software License, Version 1.0
 *
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 *
 * This file describe some data for accredit xml file data
 *
 * ====================================================================
 *
 */

package vocal.data;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.JOptionPane;
import javax.swing.JFrame;

import java.io.BufferedReader;
import java.io.StringReader;
import java.util.Stack;
import java.util.Vector;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import org.w3c.dom.DocumentFragment;
import org.xml.sax.Attributes;
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;

import vocal.userEditor.ColumnInfo;
import vocal.userEditor.UserTableModel;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;

/**
 * This class creates a new node of the DOM tree and saves data
 * from the DOM to that new node. The new node is constructed
 * as a DataFragment, hence the name of the class.
 *
 * This class and its sublclass(es) implement the set of interfaces
 * used by the GUI to read and write data.
 *
 * The user may choose to create a new node, enter some data,
 * and then cancel the whole operation. For this reason, the
 * node is not actually inserted into the DOM tree until the
 * user has pressed the "Ok" button.
 *
 * Once this node has been saved for the first time (the user
 * pressed the Ok button) it is no longer valid to use this object
 * for saving further data changes. Thus the first save causes
 * an "invalid" flag to be set and any further calls to the object
 * will then throw an InvalidRequestException.
 */
public class DataAccredit extends DataGetSet implements HostPortData,
        FeatureData, MarshalData, GroupData, CdrData, RedirectData,
        TreeNodeTypes, DataDefaults
{

  // protected fields

  protected ConfigTree configTree = null;

  /**
   * This field is used as a validity check.
   * Once a DataFragment has been saved, there are no more
   * valid operations that can be performed on it,
   * so validity becomes false.
   */
  protected boolean isValid = true;

  /**
   * The node of the ConfigTree where this fragment will be inserted.
   */
  protected DefaultMutableTreeNode parentTreeNode;

  /**
   * The DOM node where this will be inserted.
   */
  protected Node parentNode;

  /**
   * The next node up the DOM.
   */
  protected Node grandparentNode;

  /**
   * The DocumentFragment that holds the data.
   */
  protected DocumentFragment fragment;
  
  /**
   * String that creates the Document Fragment for a PDP Server.
   */
  private static String PDP_SERVER_STRING =
    new String("<pdpServer host=\"none\" port=\"3288\">"
               + "<group value=\"none\"/>" + "<maxThreads value=\"8\"/>"
               + "<keepAliveTimer value=\"5000\"/>"
               + "<responseTime value=\"10000\"/>" + "</pdpServer>");

  
  /**
   * String that creates the Document Fragment for a DVR Client.
   */
  private static String ACCREDIT_OISP_STRING =
	  new String("<accredit>" + "<oisp>"
			  + "<featuregroup>ForwardAllCallsGroup</featuregroup>"
	          + "<forwardto>none</forwardto>" + "</cfa>"
	          + "<fnab enabled=\"false\"><setfeat>OFF</setfeat>"
	          + "<featuregroup>ForwardNoAnswerBusyGroup</featuregroup>"
	          + "<fna set=\"false\">" + "<forwardto>none</forwardto>" + "</fna>"
	          + "<cfb set=\"false\">" + "<forwardto>none</forwardto>" + "</cfb>"
	          + "</fnab>" + "<cs enabled=\"false\"><setfeat>OFF</setfeat>"
	          + "<featuregroup>CallScreeningGroup</featuregroup>" + "</cs>"
	          + "<clbl enabled=\"false\"><setfeat>OFF</setfeat>"
	          + "<prefix></prefix>"
	          + "<featuregroup>CallBlockingGroup</featuregroup>"
	          + "<nineHundredBlocked adminSet=\"false\" userSet=\"false\"></nineHundredBlocked>"
	          + "<longDistanceBlocked adminSet=\"false\" userSet=\"false\"></longDistanceBlocked>"
	          + "</clbl>" + "<callReturn enabled=\"false\"><setfeat>OFF</setfeat>"
	          + "<featuregroup>CallReturnGroup</featuregroup>" + "</callReturn>"
	          + "<callerIdBlocking enabled=\"false\"><setfeat>OFF</setfeat>"
	          + "<featuregroup>CallerIdBlockingGroup</featuregroup>"
	          + "</callerIdBlocking>"
	          + "<voicemail enabled =\"false\"><setfeat>OFF</setfeat>"
	          + "<featuregroup>VoiceMailGroup</featuregroup>" + "</voicemail>"
	          + "</oisp>"	          
	          + "</accredit>"	  
	  );
	  
	  


  private static Document dom;

  private static Vector dummyUser;

  private boolean isShowingAliases = false;
  private boolean aliasesLoadedFromServer = false;

  private Vector userColumnIndices = new Vector();
  private Vector adminColumnIndices = new Vector();

  private static ColumnInfo[] columns = new ColumnInfo[]
  {
    new ColumnInfo("Name", 175, UserTableModel.USER_NAME),
    new ColumnInfo("User Group", 175, UserTableModel.USER_GROUP),
    new ColumnInfo("IP", 173, UserTableModel.IP),
    new ColumnInfo("Marshal", 170, UserTableModel.MARSHAL),
    new ColumnInfo("Forward All Enabled", 150, UserTableModel.FORWARD_ALL_ADMIN_ENABLED),
    new ColumnInfo("Forward All Group", 150, UserTableModel.FORWARD_ALL_GROUP),
    new ColumnInfo("Forward All Set", 150, UserTableModel.FORWARD_ALL_USER_SET),
    new ColumnInfo("Forward All To", 150, UserTableModel.FORWARD_ALL_DESTINATION),
    new ColumnInfo("Forward Busy/No Ans Enabled", 150, UserTableModel.FORWARD_BUSY_ADMIN_ENABLED),
    new ColumnInfo("Forward Busy/No Ans Group", 150, UserTableModel.FORWARD_BUSY_GROUP),
    new ColumnInfo("Forward Busy Set", 150, UserTableModel.FORWARD_BUSY_USER_SET),
    new ColumnInfo("Forward Busy To", 150, UserTableModel.FORWARD_BUSY_DESTINATION),
    new ColumnInfo("Forward No Ans Set", 150, UserTableModel.FORWARD_UNANSWERED_USER_SET),
    new ColumnInfo("Forward No Ans To", 150, UserTableModel.FORWARD_UNANSWERED_DESTINATION),
    new ColumnInfo("Failure Case", 150, UserTableModel.FAILURE_CASE),
    new ColumnInfo("Call Screen Enabled", 150, UserTableModel.CALL_SCREEN_ADMIN_ENABLED),
    new ColumnInfo("Call Screen Group", 150, UserTableModel.CALL_SCREEN_GROUP),
    new ColumnInfo("Call Block Prefix", 150, UserTableModel.CALL_BLOCK_PREFIX),
    new ColumnInfo("Call Block Enabled", 150, UserTableModel.CALL_BLOCK_ADMIN_ENABLED),
    new ColumnInfo("Call Block Group", 150, UserTableModel.CALL_BLOCK_GROUP),
    new ColumnInfo("Long Distance Admin Block", 150, UserTableModel.BLOCK_LONG_DISTANCE_ADMIN_ENABLED),
    new ColumnInfo("Long Distance User Block", 150, UserTableModel.BLOCK_LONG_DISTANCE_USER_SET),
    new ColumnInfo("900 # Admin Block", 150, UserTableModel.BLOCK_900_ADMIN_ENABLED),
    new ColumnInfo("900 # User Block", 150, UserTableModel.BLOCK_900_USER_SET),
    new ColumnInfo("Call Return Enabled", 150, UserTableModel.CALL_RETURN_ADMIN_ENABLED),
    new ColumnInfo("Call Return Group", 150, UserTableModel.CALL_RETURN_GROUP),
    new ColumnInfo("Caller ID Block Enabled", 150, UserTableModel.CALLER_ID_BLOCKING_ADMIN_ENABLED),
    new ColumnInfo("Caller ID Group", 150, UserTableModel.CALLER_ID_BLOCKING_GROUP),
    new ColumnInfo("Caller ID Set", 150, UserTableModel.CALLER_ID_BLOCKING_USER_SET),
    new ColumnInfo("Authentication Type", 150, UserTableModel.AUTHENTICATION_TYPE),
    new ColumnInfo("Password", 150, UserTableModel.AUTHENTICATION_PASSWORD),
    new ColumnInfo("Static Reg Enabled", 150, UserTableModel.STATIC_REGISTRATION_ENABLED),
    new ColumnInfo("Terminating host", 150, UserTableModel.TERMINATING_HOST),
    new ColumnInfo("Terminating port", 150, UserTableModel.TERMINATING_PORT)
  };
  
  private static String DVR_CLIENT_STRING =
	  new String("<dvr host=\"000.000.000.000\" port=\"8001\">"
			  + "<hostname value=\"none\"/>"
              + "<group value=\"none\"/>"  
              +"<Camera1 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera2 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera3 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera4 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera5 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera6 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera8 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"</dvr>");
  /*
  private static String DVR_CLIENT_STRING =
	  new String("<dvr host=\"none\" port=\"8001\" hostname=\"none\">"
              + "<group value=\"none\"/>"  
              +"<Camera1 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera2 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera3 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera4 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera5 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera6 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"<Camera8 Preview=\"false\""
              +"	Alarm=\"false\""
              +"	Record=\"false\""
              +"        Control=\"false\""
              +"	Port=\"com1\""
              +"	Address=\"0\"/>"
              +"</dvr>");
   */
  /**
   * String that creates the Document Fragment for a PDP Server.
   */
  
  private static String ENV_CLIENT_STRING =
	  new String("<env host=\"none\" port=\"8002\">"
              + "<group value=\"none\"/>" + "<smokeAlarm value=\"8\"/>"
              + "<temperature value=\"25\"/>"
              + "<water value=\"100\"/>" + "</env>");
  
  /*
  private static String ENV_CLIENT_STRING =
	  new String("<env host=\"none\" port=\"3288\">"
              + "<group value=\"none\"/>" + "<maxThreads value=\"8\"/>"
              + "<keepAliveTimer value=\"5000\"/>"
              + "<responseTime value=\"10000\"/>" + "</env>");
  */
  /**
   * String that creates the Document Fragment for a Redirect Server.
   */
  private static String REDIRECT_SERVER_STRING =
    new String("<redirectServer host=\"none\" port=\"-1\">"
               + "<group value=\"none\"/>" + "<syncPort value=\"0\"/>"
               + "</redirectServer>");

  /**
   * String that creates the Document Fragment for a Heartbeat Server.
   */
  private static String HEARTBEAT_SERVER_STRING =
    new String("<heartbeatServer host=\"none\" port=\"0\">"
               + "<group value=\"none\"/>" + "</heartbeatServer>");

  /**
   * String that creates the Document Fragment for a Group.
   */
  protected static String GROUP_STRING =
    new String("<serverGroup value=\"none\"/>");

 // protected static String GROUP_STRING =
	//    new String("<clientGroup value=\"none\"/>");
  // Constructors

  /**
   * This constructor is used from the GUI to create a DataFragment
   * in sync with the ConfigTree.
   */
  public void DataFragment(int type, ConfigTree tree, DefaultMutableTreeNode node)
  {
    //super();

    configTree = tree;
    parentTreeNode = node;
    parentNode = configTree.getNode(parentTreeNode);
    grandparentNode = parentNode.getParentNode();

    Element parentElement = null;
    Element grandparentElement = null;

    try
    {
      parentElement = (Element) parentNode;
      grandparentElement = (Element) grandparentNode;
    }
    catch (ClassCastException e)
    {
      System.out.println("attempted to insert DataFragment in non-Element path: "
                         + grandparentNode.getNodeType() + " / "
                         + parentNode.getNodeType());
      e.printStackTrace();

    }

    localBuildDocumentFragment(type, parentElement, grandparentElement);
  }

  /**
   * This constructor is a last-minute add-on to support inserting
   * nodes that are not in sync with the ConfigTree. It is used for
   * processing the Deployment script.
   * The main difference is that there is no more reliance on
   * selection in the ConfigTree. Instead the constructor must
   * be pased the org.w3c.Node that is the parent of the one being built.
   */
  public void DataFragment(int type, Node aParentNode)
  {
    //super();

    parentNode = aParentNode;
    grandparentNode = parentNode.getParentNode();

    Element parentElement = null;
    Element grandparentElement = null;

    try
    {
      parentElement = (Element) parentNode;
      grandparentElement = (Element) grandparentNode;
    }
    catch (ClassCastException e)
    {
      System.out.println("attempted to insert DataFragment in non-Element path: "
                         + grandparentNode.getNodeType() + " / "
                         + parentNode.getNodeType());
      e.printStackTrace();

    }

    localBuildDocumentFragment(type, parentElement, grandparentElement);

  }

  /**
   *
   * @param type
   * @param parent
   * @param grandparent
   */
  protected void localBuildDocumentFragment(int type, Element parent,
          Element grandparent)
  {
    Document doc = parent.getOwnerDocument();

    switch (type)
    {
/*
      case FEATURE_SERVER:
      {
        fragment = buildDocumentFragment(doc, FEATURE_SERVER_STRING);

        getElement("type").setAttribute("value",
                   grandparent.getAttribute("value"));
        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", FEATURE_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }

      case MARSHAL_SERVER:
      {
        fragment = buildDocumentFragment(doc, MARSHAL_SERVER_STRING);

        getElement("type").setAttribute("value",
                   grandparent.getAttribute("value"));
        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", MARSHAL_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }

      case CDR_SERVER:
      {
        fragment = buildDocumentFragment(doc, CDR_SERVER_STRING);

        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", CDR_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }
*/
      case HEARTBEAT_SERVER:
      {
        fragment = buildDocumentFragment(doc, HEARTBEAT_SERVER_STRING);

        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", HEARTBEAT_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }

      case REDIRECT_SERVER:
      {
        fragment = buildDocumentFragment(doc, REDIRECT_SERVER_STRING);

        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", REDIRECT_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }

      case PDP_SERVER:
      {
        fragment = buildDocumentFragment(doc, PDP_SERVER_STRING);

        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", POLICY_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }
      /*
      case DVR_CLIENT:
      {
        fragment = buildDocumentFragment(doc, DVR_CLIENT_STRING);

        getElement("group").setAttribute("value",
                   parent.getAttribute("value"));

        Element rootElement = getRootElement();

        rootElement.setAttribute("fileDir", DVR_DIR);
        rootElement.setAttribute("fileType", Integer.toString(type));

        break;
      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -