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

📄 accreditgroupmodel.java

📁 这是一个用java和xml编写的流媒体服务器管理软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:


		// Call blocking
		Element clblNode = null;
		NodeList nodeList = group.getElementsByTagName("clbl");

		if (nodeList.getLength() > 0) {
			clblNode = (Element) nodeList.item(0);
		}

		Element block900Node = null;
		Element blockLongDistNode = null;

		if (clblNode != null) {

			// 900 calls blocked
			nodeList = clblNode.getElementsByTagName("nineHundredBlocked");

			if (nodeList.getLength() > 0) {
				block900Node = (Element) nodeList.item(0);

				groupData.set(AccreditGroupModel.BLOCK_900_ADMIN_ENABLED,
						block900Node.getAttribute("adminSet"));
				groupData.set(AccreditGroupModel.BLOCK_900_USER_SET, block900Node
						.getAttribute("userSet"));
			}

			// long distance calls blocked
			nodeList = clblNode.getElementsByTagName("longDistanceBlocked");

			if (nodeList.getLength() > 0) {
				blockLongDistNode = (Element) nodeList.item(0);

				groupData.set(AccreditGroupModel.BLOCK_LONG_DISTANCE_ADMIN_ENABLED,
						blockLongDistNode.getAttribute("adminSet"));
				groupData.set(AccreditGroupModel.BLOCK_LONG_DISTANCE_USER_SET,
						blockLongDistNode.getAttribute("userSet"));
			}

			// feature group
			setFeatureGroup(groupData, CALL_BLOCK_GROUP, clblNode);

			// admin enabled
			groupData.set(AccreditGroupModel.CALL_BLOCK_ADMIN_ENABLED, clblNode
					.getAttribute("enabled"));

			// prefix
			nodeList = clblNode.getElementsByTagName("prefix");
			if (nodeList.getLength() > 0) {
				Node node = nodeList.item(0);
				if (node.hasChildNodes()) {
					String data = (String) node.getFirstChild().getNodeValue();
					groupData.set(AccreditGroupModel.CALL_BLOCK_PREFIX, data);
				} else {
					groupData.set(AccreditGroupModel.CALL_BLOCK_PREFIX, "");
				}
			}
		}

		// Call screening
		Element csNode = null;

		nodeList = group.getElementsByTagName("cs");

		if (nodeList.getLength() > 0) {
			csNode = (Element) nodeList.item(0);
		}

		if (csNode != null) {

			// feature group
			setFeatureGroup(groupData, CALL_SCREEN_GROUP, csNode);
			groupData.set(AccreditGroupModel.CALL_SCREEN_ADMIN_ENABLED, csNode
					.getAttribute("enabled"));

			// get the list of name,numbers for the call screening feature
			NodeList csList = csNode.getElementsByTagName("screenfrom");
			String screenFrom = "";

			for (int i = 0; i < csList.getLength(); i++) {
				Element screen = (Element) csList.item(i);

				screenFrom = screenFrom + screen.getAttribute("name");
				screenFrom = screenFrom + ",";
				screenFrom = screenFrom + screen.getAttribute("number");
				screenFrom = screenFrom + ";";
			}

			groupData.set(AccreditGroupModel.CALL_SCREEN_NUMBERS, screenFrom);
		}

		// forward all calls
		Element cfaNode = null;

		nodeList = group.getElementsByTagName("cfa");

		if (nodeList.getLength() > 0) {
			cfaNode = (Element) nodeList.item(0);
		}

		if (cfaNode != null) {
			setFeatureGroup(groupData, FORWARD_ALL_GROUP, cfaNode);
			setSetfeat(groupData, FORWARD_ALL_USER_SET, cfaNode);
			groupData.set(AccreditGroupModel.FORWARD_ALL_ADMIN_ENABLED, cfaNode
					.getAttribute("enabled"));

			// destination
			nodeList = cfaNode.getElementsByTagName("forwardto");

			if (nodeList.getLength() > 0) {
				Node node = nodeList.item(0);

				if (node.hasChildNodes()) {
					groupData.set(FORWARD_ALL_DESTINATION, node.getFirstChild()
							.getNodeValue());
				}
			}
		}

		// forward no-answer, busy calls
		Element fnabNode = null;

		nodeList = group.getElementsByTagName("fnab");

		if (nodeList.getLength() > 0) {
			fnabNode = (Element) nodeList.item(0);
		}

		if (fnabNode != null) {
			setFeatureGroup(groupData, FORWARD_BUSY_GROUP, fnabNode);
			groupData.set(AccreditGroupModel.FORWARD_BUSY_ADMIN_ENABLED, fnabNode
					.getAttribute("enabled"));

			// call forward busy destination
			nodeList = fnabNode.getElementsByTagName("cfb");

			if (nodeList.getLength() > 0) {
				Element cfbNode = (Element) nodeList.item(0);

				nodeList = cfbNode.getElementsByTagName("forwardto");

				if (nodeList.getLength() > 0) {
					Node node = nodeList.item(0);

					if (node.hasChildNodes()) {
						groupData.set(FORWARD_BUSY_DESTINATION, node
								.getFirstChild().getNodeValue());
					}
				}

				// call forward busy set
				groupData.set(AccreditGroupModel.FORWARD_BUSY_USER_SET, cfbNode
						.getAttribute("set"));
			}

			// call forward no answer destination
			nodeList = fnabNode.getElementsByTagName("fna");

			if (nodeList.getLength() > 0) {
				Element fnaNode = (Element) nodeList.item(0);

				nodeList = fnaNode.getElementsByTagName("forwardto");

				if (nodeList.getLength() > 0) {
					Node node = nodeList.item(0);

					if (node.hasChildNodes()) {
						groupData.set(FORWARD_UNANSWERED_DESTINATION, node
								.getFirstChild().getNodeValue());
					}
				}

				// call forwared no answer set
				groupData.set(AccreditGroupModel.FORWARD_UNANSWERED_USER_SET,
						fnaNode.getAttribute("set"));
			}
		}

		// load the list of aliases, if present
		String aliasesString = "";
		NodeList aliases = group.getElementsByTagName("aliases");

		if (aliases != null) {
			if (aliases.getLength() > 0) {
				Element aliasesElement = (Element) aliases.item(0);
				NodeList aliasList = aliasesElement
						.getElementsByTagName("alias");

				if (aliasList != null) {
					if (aliasList.getLength() > 0) {
						for (int i = 0; i < aliasList.getLength(); i++) {
							Element aliasElement = (Element) aliasList.item(i);
							String alias = aliasElement.getAttribute("value");

							aliasesString += alias + ";";
						}
					}
				}
			}
		}

		groupData.set(AccreditGroupModel.ALIASES, aliasesString);

		NodeList fcs = group.getElementsByTagName("failurecase");

		if (fcs.getLength() > 0) {
			Node fc = fcs.item(0);

			if (fc.hasChildNodes()) {
				groupData.set(FAILURE_CASE, fc.getFirstChild().getNodeValue());
			}
		}
/*
		// Authentication type and password
		NodeList authenticationTypes = user
				.getElementsByTagName("authenticationType");

		if (authenticationTypes.getLength() > 0) {
			Element authenticationType = (Element) authenticationTypes.item(0);
			String type = authenticationType.getAttribute("value");

			groupData.set(AUTHENTICATION_TYPE, type);

			NodeList authPasswords = authenticationType
					.getElementsByTagName("authenticationPassword");

			if (authPasswords.getLength() > 0) {
				Element authPassword = (Element) authPasswords.item(0);
				String pw = authPassword.getAttribute("value");

				groupData.set(AUTHENTICATION_PASSWORD, pw);
			}
		}

*/		

		// call return
		NodeList callReturns = group.getElementsByTagName("callReturn");

		if (callReturns.getLength() > 0) {
			Element callReturn = (Element) callReturns.item(0);
			String enabled = callReturn.getAttribute("enabled");

			groupData.set(AccreditGroupModel.CALL_RETURN_ADMIN_ENABLED, enabled);

			NodeList groups = callReturn.getElementsByTagName("featuregroup");

			if (groups.getLength() > 0) {
				Element user = (Element) groups.item(0);

				if (group.hasChildNodes()) {
					String groupName = user.getFirstChild().getNodeValue();

					groupData.set(AccreditGroupModel.CALL_RETURN_GROUP, groupName);
				}
			}
		}

		// caller id blocking
		NodeList idBlockings = group.getElementsByTagName("callerIdBlocking");

		if (idBlockings.getLength() > 0) {
			Element idBlocking = (Element) idBlockings.item(0);
			String enabled = idBlocking.getAttribute("enabled");

			groupData.set(AccreditGroupModel.CALLER_ID_BLOCKING_ADMIN_ENABLED,
					enabled);

			NodeList groups = idBlocking.getElementsByTagName("featuregroup");

			if (groups.getLength() > 0) {
				Element user = (Element) groups.item(0);

				if (group.hasChildNodes()) {
					String groupName = user.getFirstChild().getNodeValue();

					groupData.set(AccreditGroupModel.CALLER_ID_BLOCKING_GROUP,
							groupName);
				}
			}

			NodeList setFeats = idBlocking.getElementsByTagName("setfeat");

			if (setFeats.getLength() > 0) {
				Element setFeat = (Element) setFeats.item(0);

				if (setFeat.hasChildNodes()) {
					String set = setFeat.getFirstChild().getNodeValue();

					groupData.set(AccreditGroupModel.CALLER_ID_BLOCKING_USER_SET,
							set);
				}
			}
		}

		return groupData;
	}

	public void loadGroupNames() throws VPPNoSuchFileException {
		String[] names = psInterface.getAllUserNames();

		data = new Vector(names.length);

		Logger.swingLog("Adding users ...");

		for (int i = 0; i < names.length; i++) {
			Vector user = new Vector();

			user.addElement(names[i]);
			data.addElement(user);

			if (i % 1000 == 0) {
				Logger.swingLog("Adding user #" + i + " - " + names[i]);
			}
		}

		Logger.swingLog("Done adding users");

		fireTableDataChanged();
	}

	public void deleteUserAt(int row) throws VPPNoSuchFileException,
			IOException, SAXException, NoSuchNodeException,
			NotTextNodeException, VPPException {
		Vector user = (Vector) data.elementAt(row);
		String userName = (String) user.elementAt(this.GROUP_NAME);

		if (user.size() <= 1) {

			// if the data for this user was not loaded, need to load it first
			// to
			// find out what aliases are defined for this user so the alias xml
			// files
			// may be deleted as well
			user = loadUserAt(row);
		}

		boolean deleted;

		if (user.elementAt(this.IS_ALIAS).equals("true")) {
			deleted = deleteAlias(user);
		} else {
			deleted = deleteUser(user);
		}

		// remove the user from the table
		if (deleted) {
			// some aliases may have already been removed from the data vector,
			// which
			// may cause the position of this user to change -> need to find it
			// again

			int index = this.findMasterIndex(userName);
			data.removeElementAt(index);
			this.fireTableDataChanged();
		}
	}

	private boolean deleteAlias(Vector alias) throws IOException, SAXException,
			NotTextNodeException, NoSuchNodeException, VPPNoSuchFileException,
			VPPException {

		// find the master user for this alias
		String masterIndexString = (String) alias.elementAt(this.MASTER_INDEX);
		int masterIndex;

		if (masterIndexString != null) {
			masterIndex = Integer.parseInt(masterIndexString);
		} else {
			masterIndex = findMasterIndex((String) alias
					.elementAt(this.MASTER_NAME));

			alias.setElementAt(masterIndex + "", this.MASTER_INDEX);
		}

		// This is a bug. If the master index ends up -1, it means that the
		// master
		// user's vector could not be found. This situation should never arise
		// if
		// if the data is consistent. But since it has come up, this bit of code
		// is put in specifically to allow the alias to be deleted even if the
		// master
		// user cannot be found.
		if (masterIndex == -1) {
			if (JOptionPane
					.showConfirmDialog(
							null,
							"The master user for this alias was not found.\nYour user data is likely corrupted.\n\nDo you still want to delete this alias?",
							"ERROR", JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) {
				return false;
			}
		} else {

			// If the master user was found, modify it to remove the alias
			Vector masterUser = (Vector) data.elementAt(masterIndex);

			// modify the list of aliases for the master user to remove the
			// alias being
			// deleted
			// if the user has not been loaded yet, need to do that to access
			// the
			// aliases list
			if (masterUser.size() <= 1) {
				masterUser = loadUserAt(masterIndex);
			}

⌨️ 快捷键说明

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