📄 accredittable.java
字号:
// since it is not a valid alias
String aliasList = removeAliasFromList(alias,
(String) getValueAt(row, this.ALIASES));
((Vector) data.elementAt(row)).setElementAt(aliasList, this.ALIASES);
for (int i = 0; i < aliases.size(); i++)
{
Vector aliasVector = (Vector) aliases.elementAt(i);
String name = (String) aliasVector.elementAt(this.GROUP_NAME);
String masterName = (String) aliasVector.elementAt(this.MASTER_NAME);
if (name.equals(alias) && masterName.equals(userName))
{
aliases.remove(aliasVector);
if (data.contains(aliasVector))
{
data.remove(aliasVector);
}
}
}
fireTableDataChanged();
// complain
JOptionPane.showMessageDialog(null,
"Could not create alias " + alias + " for user " + userName
+ " because the alias is not unique.");
}
public void writeBackGroupAt(int row, boolean generateCpl,
boolean generateCl) throws NoSuchNodeException,
NotTextNodeException, SAXException, IOException
{
Exception error = null;
// If the user data loaded from the server did not contain an entry for the
// caller id blocking group, this contacts the provisioning server,
// determines the list of all known caller id blocking groups and
// defaults the value for this user to the first group on the list.
try
{
if (getValueAt(row,
this.CALLER_ID_BLOCKING_GROUP).equals("not loaded from xml"))
{
String[] groups = psInterface.getFeatureGroups("CallerIdBlocking");
if (groups != null)
{
if (groups.length > 0)
{
setValueAt(groups[0], row, CALLER_ID_BLOCKING_GROUP);
}
}
}
}
catch (Exception e)
{
// quietly suppress this exception
e.printStackTrace();
}
String userName = (String) getValueAt(row, GROUP_NAME);
// generate the alias files in the Aliases directory
String aliasesString = (String) getValueAt(row, ALIASES);
while (aliasesString.length() > 0)
{
String alias = aliasesString.substring(0, aliasesString.indexOf(";"));
aliasesString = aliasesString.substring(aliasesString.indexOf(";") + 1);
if (alias.equals(userName))
{
removeAliasFromVectors(alias, row);
}
else if (!psInterface.saveAlias(alias,
userName)) // try saving the alias file
{
removeAliasFromVectors(alias, row);
} // end if the alias was not unique
} // end for all aliases
Document doc = convertGroupAtToDocument(row);
if (generateCpl)
{
CplGenerator cplGen = new CplGenerator(psInterface.getConnection());
String cpl = "";
if (getValueAt(row, this.FORWARD_ALL_USER_SET).equals("ON"))
{
System.out.println("---TRACE---cfa set by user");
System.out.println("---TRACE---Building cpl for cfa with destination="
+ getValueAt(row, FORWARD_ALL_DESTINATION));
try
{
cpl = cplGen.buildCfaXML((String) getValueAt(row,
FORWARD_ALL_DESTINATION));
writeCpl((String) getValueAt(row, FORWARD_ALL_GROUP),
(String) getValueAt(row, GROUP_NAME), cpl);
}
catch (Exception ex)
{
// catch the exception, save it and throw it only once an attempt
// has been made to generate each of the cpl scripts
error = ex;
}
}
// call return
System.out.println("---TRACE--- generating call return cpl");
// the setfeat sould have been set to on in the convertUserToDocument function
if (getValueAt(row, this.CALL_RETURN_ADMIN_ENABLED).equals("true"))
{
String calledCpl = cplGen.buildCallReturnUserXML();
String callingCpl = cplGen.buildCallReturnUserCallingXML();
writeCallingAndCalledCpls( (String) getValueAt(row, this.CALL_RETURN_GROUP),
(String) getValueAt(row, this.GROUP_NAME),
callingCpl,
calledCpl );
}
// caller id blocking
System.out.println("---TRACE--- generating caller id blocking cpl");
if (getValueAt(row, this.CALLER_ID_BLOCKING_USER_SET).equals("ON"))
{
// only write cpl if feature is set on
cpl = cplGen.buildCallerIdBlockingXML();
writeCpl((String) getValueAt(row, this.CALLER_ID_BLOCKING_GROUP),
(String) getValueAt(row, this.GROUP_NAME), cpl);
}
// generate call blocking cpl
boolean block900 = false;
boolean blockLongDist = false;
if (getValueAt(row, BLOCK_900_ADMIN_ENABLED).equals("true"))
{
System.out.println("---TRACE---900 calls blocked by admin");
block900 = true;
}
else
{
if (getValueAt(row, BLOCK_900_USER_SET).equals("true"))
{
System.out.println("---TRACE---900 calls blocked by user");
block900 = true;
}
}
if (getValueAt(row, BLOCK_LONG_DISTANCE_ADMIN_ENABLED).equals("true"))
{
System.out.println("---TRACE---long distance calls blocked by admin");
blockLongDist = true;
}
else
{
if (getValueAt(row, BLOCK_LONG_DISTANCE_USER_SET).equals("true"))
{
System.out.println("---TRACE---long distance calls blocked by user");
blockLongDist = true;
}
}
if (block900 || blockLongDist)
{
System.out.println("Building cpl for clbl with block900=" + block900
+ " and blockLongDist=" + blockLongDist);
try
{
cpl = cplGen.buildClblXML(block900, blockLongDist, (String)getValueAt(row, UserTableModel.CALL_BLOCK_PREFIX));
writeCpl((String) getValueAt(row, CALL_BLOCK_GROUP),
(String) getValueAt(row, GROUP_NAME), cpl);
}
catch (Exception ex)
{
error = ex;
}
}
// generate call screening cpl
// The setfeat field for this feature is not actually in the vector used
// to display the table. So we need to get it from the dom which was
// created
NodeList css = dom.getElementsByTagName("cs");
if (css.getLength() > 0)
{
Element cs = (Element) css.item(0);
NodeList setfeats = cs.getElementsByTagName("setfeat");
if (setfeats.getLength() > 0)
{
Element setfeat = (Element) setfeats.item(0);
if (setfeat.hasChildNodes())
{
if (setfeat.getFirstChild().getNodeValue().equals("ON"))
{
System.out.println("Building cpl for cs");
try
{
cpl = cplGen.buildCsXML(convertGroupAtToDocument(row));
writeCpl((String) getValueAt(row, CALL_SCREEN_GROUP),
(String) getValueAt(row, GROUP_NAME), cpl);
}
catch (Exception ex)
{
error = ex;
}
}
}
}
}
boolean fna = false;
if (getValueAt(row, this.FORWARD_UNANSWERED_USER_SET).equals("true"))
{
System.out.println("---TRACE---forward no answer set by user");
fna = true;
}
boolean fb = false;
if (getValueAt(row, this.FORWARD_BUSY_USER_SET).equals("true"))
{
System.out.println("---TRACE---forward busy set by user");
fb = true;
}
if (fna || fb)
{
// write forward no answer, blocking cpl
String fnaDestination = (String) getValueAt(row,
this.FORWARD_UNANSWERED_DESTINATION);
String fbDestination = (String) getValueAt(row,
this.FORWARD_BUSY_DESTINATION);
String failureCause = (String) getValueAt(row, this.FAILURE_CASE);
System.out.println("Building cpl for fnab with username=" + userName
+ ", fna=" + fna + ", fnaDestination="
+ fnaDestination + ", fb=" + fb
+ ", fbDestination= " + fbDestination
+ "failureCause=" + failureCause);
try
{
cpl = cplGen.buildFnabXML(userName, fna, fnaDestination, fb,
fbDestination, failureCause);
writeCpl((String) getValueAt(row, this.FORWARD_BUSY_GROUP),
(String) getValueAt(row, GROUP_NAME), cpl);
}
catch (Exception ex)
{
error = ex;
}
}
} // end if generate cpl
if (generateCl)
{
ContactListGenerator clGen = new ContactListGenerator();
String called = clGen.buildCalledContactList(doc);
String calling = clGen.buildCallingContactList(doc);
psInterface.put("Contact_Lists_Called",
(String) getValueAt(row, this.GROUP_NAME), called);
psInterface.put("Contact_Lists_Calling",
(String) getValueAt(row, this.GROUP_NAME), calling);
}
// write back the user xml
psInterface.saveGroup(userName, doc);
if (error != null)
{
if (NoSuchNodeException.class.isInstance(error))
{
throw (NoSuchNodeException) error;
}
else if (NotTextNodeException.class.isInstance(error))
{
throw (NotTextNodeException) error;
}
else if (SAXException.class.isInstance(error))
{
throw (SAXException) error;
}
else if (IOException.class.isInstance(error))
{
throw (IOException) error;
}
}
}
private void writeCpl(String group, String userName, String cpl)
{
String[] paths = cplGen.getAddressArray(group);
if (paths == null)
{
System.out.println("---ERROR--- Could not get cpl destination paths for group "
+ group
+ "\n---ERROR--- Probably, the group does not exist in the ListOfFeatureServers"
+ "\n---ERROR--- Or there is no server configured for this feature.");
return;
}
String filename = userName + ".cpl";
String filegroup;
for (int i = 1; i < paths.length; i++)
{
filegroup = paths[i];
psInterface.put(filegroup, filename, cpl);
}
}
/**
* Write a user's calling and called CPL scripts of a Feature Group.
* For now, we assume the feature is a called feature, so we need
* to substitue "called" with "calling" in the file path when we
* write the calling CPL.
*/
private void writeCallingAndCalledCpls( String group,
String userName,
String callingCpl,
String calledCpl )
{
String[] calledPaths = cplGen.getAddressArray( group );
if( calledPaths == null )
{
System.out.println("---ERROR--- Could not get cpl destination paths for group "
+ group
+ "\n---ERROR--- Probably, the group does not exist in the ListOfFeatureServers"
+ "\n---ERROR--- Or there is no server configured for this feature.");
return;
}
String filename = userName + ".cpl";
String filegroup;
for (int i = 1; i < calledPaths.length; i++)
{
filegroup = calledPaths[i];
psInterface.put(filegroup, filename, calledCpl);
filegroup = calledPaths[i].replaceFirst( "Called", "Calling" );
psInterface.put( filegroup, filename, ca
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -