📄 accredittable.java
字号:
/*
* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000 Vovida Networks, Inc. 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. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY 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.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
package vocal.userEditor;
import vocal.util.Logger;
import vocal.comm.VPPException;
import vocal.comm.VPPNoSuchFileException;
import vocal.data.XMLUtils;
import vocal.data.CplGenerator;
import vocal.data.ContactListGenerator;
import vocal.data.NoSuchNodeException;
import vocal.data.NotTextNodeException;
import javax.swing.table.AbstractTableModel;
import javax.swing.JOptionPane;
import java.util.Vector;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.DOMException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
class AccreditTable extends AbstractTableModel
{
// NOTE: these have to be in the same order as the columns displayed in the
// table in Editor.java. Also, any data elements that are not displayed in
// that table (such as the list of call screen numbers) must be entered here
// at the end, after those that are in the table.
public static final int GROUP_NAME = 0;
public static final int USER_GROUP = 1;
public static final int IP = 2;
public static final int USER_IDENTITY = 3;
public static final int USER_PASSWD = 4;
public static final int MARSHAL = 5;
public static final int FORWARD_ALL_ADMIN_ENABLED = 6;
public static final int FORWARD_ALL_GROUP = 7;
public static final int FORWARD_ALL_USER_SET = 8;
public static final int FORWARD_ALL_DESTINATION = 9;
public static final int FORWARD_BUSY_ADMIN_ENABLED = 10;
public static final int FORWARD_BUSY_GROUP = 11;
public static final int FORWARD_BUSY_USER_SET = 120;
public static final int FORWARD_BUSY_DESTINATION = 13;
public static final int FORWARD_UNANSWERED_USER_SET = 14;
public static final int FORWARD_UNANSWERED_DESTINATION =15;
public static final int FAILURE_CASE = 16;
public static final int CALL_SCREEN_ADMIN_ENABLED = 17;
public static final int CALL_SCREEN_GROUP = 18;
public static final int CALL_BLOCK_PREFIX = 19;
public static final int CALL_BLOCK_ADMIN_ENABLED = 20;
public static final int CALL_BLOCK_GROUP = 21;
public static final int BLOCK_LONG_DISTANCE_ADMIN_ENABLED = 22;
public static final int BLOCK_LONG_DISTANCE_USER_SET = 23;
public static final int BLOCK_900_ADMIN_ENABLED = 24;
public static final int BLOCK_900_USER_SET = 25;
public static final int CALL_RETURN_ADMIN_ENABLED = 26;
public static final int CALL_RETURN_GROUP = 27;
public static final int CALLER_ID_BLOCKING_ADMIN_ENABLED = 28;
public static final int CALLER_ID_BLOCKING_GROUP = 29;
public static final int CALLER_ID_BLOCKING_USER_SET = 30;
public static final int AUTHENTICATION_TYPE = 31;
public static final int AUTHENTICATION_PASSWORD = 32;
public static final int STATIC_REGISTRATION_ENABLED = 33;
public static final int TERMINATING_HOST = 34;
public static final int TERMINATING_PORT = 35;
public static final int PASSWORD = 36;
public static final int CALL_SCREEN_NUMBERS = 37;
public static final int IS_ALIAS = 38;
public static final int MASTER_NAME = 39;
public static final int MASTER_INDEX = 40;
public static final int ALIASES = 41;
public static final int MAX_COLUMN_ID = ALIASES;
private static BufferedReader sampleUserXML =
new BufferedReader(new StringReader("<user><name>1000</name>"
+ "<password>6f7d5634f65192a3b9c8479cee3b655</password>"
+ // it's "vovida"
"<ipaddr>000.000.000.000</ipaddr>"
+ "<identity>User</identity>"
+ "<userpassword>111111</userpassword>"
+ "<marshalgroup>UserAgentGroup</marshalgroup>"
+ "<staticRegistration value=\"false\">"
+ "<terminatingContactList>"
+ "<contact value=\"UserAgentGroup\"></contact>"
+ "<contact value=\"000.000.000.000:0000\"></contact>"
+ "</terminatingContactList>" + "</staticRegistration>"
+ "<authenticationType value=\"None\">"
+ "<authenticationPassword value=\"password\"></authenticationPassword>"
+ "</authenticationType>" + "<failurecase>unknown</failurecase>"
+ "<cfa enabled=\"false\"><setfeat>OFF</setfeat> "
+ "<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>"
+ "<userGroup>none</userGroup>" + "</user>"));
private static Document dom;
private static Vector dummyGroup;
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("Group", 175, GROUP_NAME),
new ColumnInfo("User Number", 175, USER_GROUP),
new ColumnInfo("DEVS", 173, IP),
new ColumnInfo("User Identity", 150, USER_IDENTITY),
new ColumnInfo("User Password", 150, USER_PASSWD),
new ColumnInfo("OISP", 170, MARSHAL),
new ColumnInfo("VECTOR", 150, FORWARD_ALL_ADMIN_ENABLED),
new ColumnInfo("VOD", 150, FORWARD_ALL_GROUP)
/*
new ColumnInfo("Forward All Set", 150, FORWARD_ALL_USER_SET),
new ColumnInfo("Forward All To", 150, FORWARD_ALL_DESTINATION),
new ColumnInfo("Forward Busy/No Ans Enabled", 150, FORWARD_BUSY_ADMIN_ENABLED),
new ColumnInfo("Forward Busy/No Ans Group", 150, FORWARD_BUSY_GROUP),
new ColumnInfo("Forward Busy Set", 150, FORWARD_BUSY_USER_SET),
new ColumnInfo("Forward Busy To", 150, FORWARD_BUSY_DESTINATION),
new ColumnInfo("Forward No Ans Set", 150, FORWARD_UNANSWERED_USER_SET),
new ColumnInfo("Forward No Ans To", 150, FORWARD_UNANSWERED_DESTINATION),
new ColumnInfo("Failure Case", 150, FAILURE_CASE),
new ColumnInfo("Call Screen Enabled", 150, CALL_SCREEN_ADMIN_ENABLED),
new ColumnInfo("Call Screen Group", 150, CALL_SCREEN_GROUP),
new ColumnInfo("Call Block Prefix", 150, CALL_BLOCK_PREFIX),
new ColumnInfo("Call Block Enabled", 150, CALL_BLOCK_ADMIN_ENABLED),
new ColumnInfo("Call Block Group", 150, CALL_BLOCK_GROUP),
new ColumnInfo("Long Distance Admin Block", 150, BLOCK_LONG_DISTANCE_ADMIN_ENABLED),
new ColumnInfo("Long Distance User Block", 150, BLOCK_LONG_DISTANCE_USER_SET),
new ColumnInfo("900 # Admin Block", 150, BLOCK_900_ADMIN_ENABLED),
new ColumnInfo("900 # User Block", 150, BLOCK_900_USER_SET),
new ColumnInfo("Call Return Enabled", 150, CALL_RETURN_ADMIN_ENABLED),
new ColumnInfo("Call Return Group", 150, CALL_RETURN_GROUP),
new ColumnInfo("Caller ID Block Enabled", 150, CALLER_ID_BLOCKING_ADMIN_ENABLED),
new ColumnInfo("Caller ID Group", 150, CALLER_ID_BLOCKING_GROUP),
new ColumnInfo("Caller ID Set", 150, CALLER_ID_BLOCKING_USER_SET),
new ColumnInfo("Authentication Type", 150, AUTHENTICATION_TYPE),
new ColumnInfo("Password", 150, AUTHENTICATION_PASSWORD),
new ColumnInfo("Static Reg Enabled", 150, STATIC_REGISTRATION_ENABLED),
new ColumnInfo("Terminating host", 150, TERMINATING_HOST),
new ColumnInfo("Terminating port", 150, TERMINATING_PORT)
*/
};
/**
* Stores the list of users (as a vector of vectors)
*/
private Vector data = new Vector();
/**
* Stores the list of aliases (as a vector of vectors). The each alias would
* be stored in a vector of the same form as the master user names.
*/
private Vector aliases = new Vector();
/**
* Handles communication with pServer
*/
PServerAccrInterface psInterface;
/**
* Used to find paths and generate cpl files
*/
private CplGenerator cplGen;
static
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = null;
try
{
parser = dbf.newDocumentBuilder();
}
catch(ParserConfigurationException e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Could not configure XML parser",
"ERROR", JOptionPane.ERROR_MESSAGE);
}
try
{
dom = parser.parse(new InputSource(sampleUserXML));
}
catch (Exception e)
{
// If this happens, there was an error parsing the hard coded sample user
// XML. That should never happen. It would suggest a coding error.
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Could not parse sample user XML",
"ERROR", JOptionPane.ERROR_MESSAGE);
}
}
public AccreditTable(PServerAccrInterface con)
{
psInterface = con;
dummyGroup = convertGroupToVector(dom);
userColumnIndices.add(new Integer(FORWARD_ALL_USER_SET));
userColumnIndices.add(new Integer(FORWARD_ALL_DESTINATION));
userColumnIndices.add(new Integer(FORWARD_BUSY_USER_SET));
userColumnIndices.add(new Integer(FORWARD_BUSY_DESTINATION));
userColumnIndices.add(new Integer(FORWARD_UNANSWERED_USER_SET));
userColumnIndices.add(new Integer(FORWARD_UNANSWERED_DESTINATION));
/*
userColumnIndices.add(new Integer(BLOCK_LONG_DISTANCE_USER_SET));
userColumnIndices.add(new Integer(BLOCK_900_USER_SET));
userColumnIndices.add(new Integer(CALLER_ID_BLOCKING_USER_SET));
adminColumnIndices.add(new Integer(FORWARD_ALL_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(FORWARD_ALL_GROUP));
adminColumnIndices.add(new Integer(FORWARD_BUSY_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(FORWARD_BUSY_GROUP));
adminColumnIndices.add(new Integer(FAILURE_CASE));
adminColumnIndices.add(new Integer(CALL_SCREEN_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(CALL_SCREEN_GROUP));
adminColumnIndices.add(new Integer(CALL_BLOCK_PREFIX));
adminColumnIndices.add(new Integer(CALL_BLOCK_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(CALL_BLOCK_GROUP));
adminColumnIndices.add(new Integer(BLOCK_LONG_DISTANCE_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(BLOCK_900_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(CALL_RETURN_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(CALL_RETURN_GROUP));
adminColumnIndices.add(new Integer(CALLER_ID_BLOCKING_ADMIN_ENABLED));
adminColumnIndices.add(new Integer(CALLER_ID_BLOCKING_GROUP));
adminColumnIndices.add(new Integer(AUTHENTICATION_TYPE));
adminColumnIndices.add(new Integer(AUTHENTICATION_PASSWORD));
adminColumnIndices.add(new Integer(STATIC_REGISTRATION_ENABLED));
adminColumnIndices.add(new Integer(TERMINATING_HOST));
adminColumnIndices.add(new Integer(TERMINATING_PORT));
*/
}
public Vector getUserColumnIndices()
{
return userColumnIndices;
}
public Vector getAdminColumnIndices()
{
return adminColumnIndices;
}
public void addGroup(Vector group)
{
data.addElement(group);
}
/*
public void addGroup(Document doc)
{
Vector group = convertGroupToVector(doc);
data.addElement(group);
}
*/
private Document convertGroupAtToDocument(int row)
{
return convertUserToDocument(getUserAt(row));
}
public static Document convertUserToDocument(Vector user)
{
dom.getElementsByTagName("name").item(0).getFirstChild().setNodeValue((String) user.elementAt(AccreditGroupModel.GROUP_NAME));
dom.getElementsByTagName("ipaddr").item(0).getFirstChild().setNodeValue((String) user.elementAt(UserTableModel.IP));
dom.getElementsByTagName("identity").item(0).getFirstChild().setNodeValue((String) user.elementAt(UserTableModel.USER_IDENTITY));
dom.getElementsByTagName("userpassword").item(0).getFirstChild().setNodeValue((String) user.elementAt(UserTableModel.USER_PASSWD));
dom.getElementsByTagName("marshalgroup").item(0).getFirstChild().setNodeValue((String) user.elementAt(UserTableModel.MARSHAL));
dom.getElementsByTagName("failurecase").item(0).getFirstChild().setNodeValue((String) user.elementAt(UserTableModel.FAILURE_CASE));
// caller id blocking
NodeList idBlockings = dom.getElementsByTagName("callerIdBlocking");
Element idBlocking = (Element) idBlockings.item(0);
idBlocking.setAttribute("enabled",
(String) user.elementAt(CALLER_ID_BLOCKING_ADMIN_ENABLED));
NodeList setfeats = idBlocking.getElementsByTagName("setfeat");
Element setfeat = (Element) setfeats.item(0);
setfeat.getFirstChild().setNodeValue((String) user.elementAt(CALLER_ID_BLOCKING_USER_SET));
NodeList groups = idBlocking.getElementsByTagName("featuregroup");
Element group = (Element) groups.item(0);
group.getFirstChild().setNodeValue((String) user.elementAt(CALLER_ID_BLOCKING_GROUP));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -