📄 usertablemodel.java
字号:
} 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.USER_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.USER_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, USER_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(convertUserAtToDocument(row)); writeCpl((String) getValueAt(row, CALL_SCREEN_GROUP), (String) getValueAt(row, USER_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, USER_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.USER_NAME), called); psInterface.put("Contact_Lists_Calling", (String) getValueAt(row, this.USER_NAME), calling); } // write back the user xml psInterface.saveUser(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, callingCpl ); } } public Vector loadUserAt(int row) throws SAXException, IOException, VPPException { Vector userData = (Vector) data.elementAt(row); // if there is one element in the data vector for the selected user, this // means that only the user's name has been loaded, not his xml file if (userData.size() <= 1) { // find the name of the user in the selected row String userName = (String) userData.elementAt(UserTableModel.USER_NAME); // load the user's xml file fron the pserver Document doc = psInterface.getUserNamed(userName); // convert the xml to a vector userData = convertUserToVector(doc); // save the vector in the appropriate row data.set(row, userData); fireTableDataChanged(); } return userData; } /** * Return a new vector which contains the "default" configuration for a * user. <p> This is used when adding a new user to the system */ public Vector getDummyUser() { return (Vector) dummyUser.clone(); } public Vector getUserAt(int row) { return (Vector) data.elementAt(row); } private Vector createAliasVector(String name, String masterName) { Vector alias = new Vector(this.MAX_COLUMN_ID); for (int j = 0; j <= this.MAX_COLUMN_ID; j++) { alias.addElement(""); } alias.set(this.USER_NAME, name); alias.set(this.IS_ALIAS, "true"); alias.set(this.MASTER_NAME, masterName); alias.set(this.MASTER_INDEX, null); return alias; } public void showAliases(boolean show) { isShowingAliases = show; if (show) { if (aliasesLoadedFromServer) { // if the aliases have been loaded from the server // add them to the main data vector for (int i = 0; i < aliases.size(); i++) { data.addElement(aliases.elementAt(i)); } this.fireTableDataChanged(); } else { // if the aliases have not been loaded from the server String[] aliasNames; try { aliasNames = psInterface.getAllAliasNames(); } catch (VPPNoSuchFileException e) { // there are no aliases defined - that's ok return; } for (int i = 0; i < aliasNames.length; i++) { try { // get the file for this alias String aliasXml = psInterface.getAliasNamed(aliasNames[i]); // get the master user name this alias belongs to String masterName = psInterface.getMasterUserNameFromXml(aliasXml); // create a new vector for this alias Vector alias = createAliasVector(aliasNames[i], masterName); // add the vector to the list of aliases and to the main data vector // If a new user was created along with some aliases, before others // were loaded from the server, these may have already been added to // the aliases vector boolean found = false; for (int j = 0; j < aliases.size(); j++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -