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

📄 cplgenerator.java

📁 这是一个用java和xml编写的流媒体服务器管理软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  /**   *    */  public static String buildCallReturnUserXML()  {    return (FIRST_LINE + SECOND_LINE + CALL_RETURN_USER_STRING);  }  /**   *   */  public static String buildCallReturnUserCallingXML()  {    return (FIRST_LINE + SECOND_LINE + CALL_RETURN_USER_CALLING_STRING);  }  /**   *    */  public static String buildFeatureDisabledXML()  {    return (FIRST_LINE + SECOND_LINE + FEATURE_DISABLED_STRING);  }  /**   *    */  private Element getFirstElementChild(Element parent)  {    NodeList nodes = parent.getChildNodes();    for (int i = 0; i < nodes.getLength(); i++)    {      Node node = nodes.item(i);      if (node.getNodeType() == Node.ELEMENT_NODE)      {        return (Element) node;      }    }    System.out.println("getFirstElementChild returning null");    return null;  }  /**   * return the list of file paths for all features belonging   * to a particular group. Return null if the group is not   * in cplFilePaths.   * @return array of file path names   */  public static String[] getAddressArray(String groupName)  {    String filePath[] = null;    if (cplFilePaths == null)    {      return null;    }    for (int i = 0; i < cplFilePaths.length; i++)    {      filePath = cplFilePaths[i];      if (groupName.compareToIgnoreCase(filePath[0]) == 0)      {        return filePath;      }    }    return null;  }  /**   * Called at startup.   */  private static String[][] buildCplFilePaths()  {    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();    DocumentBuilder parser = null;    try    {      parser = dbf.newDocumentBuilder();      if (connection == null)      {        connection = AdministrativeLogin.getConnection();        if (connection == null)        {          System.out.println("ERROR: null connection in CPL generator");          System.out.println("Could not get one from the AdministrativeLogin either");          new Exception().printStackTrace();          return null;        }      }      BufferedReader response = connection.request("GET", SYSTEM_DIR,               LIST_OF_FEATURE_SERVERS_FILE);      fsDOM = parser.parse(new InputSource(response));    }    catch (IOException e1)    {      e1.printStackTrace();      return null;    }    catch (SAXException e2)    {      e2.printStackTrace();      return null;    }    catch (VPPException e3)    {      e3.printStackTrace();      return null;    }    catch (ParserConfigurationException e4)    {      e4.printStackTrace();      return null;    }    if (fsDOM == null)    {      System.out.println("required file ListOfFeatureServers missing");      new Exception().printStackTrace();      return null;    }    Vector pathArrayVector = new Vector();    Vector pathVector;    String pathArray[] = null;    Element rootElement = fsDOM.getDocumentElement();    NodeList featureNodes = rootElement.getElementsByTagName("serverType");    for (int i = 0; i < featureNodes.getLength(); i++)    {      // the pathVector holds the group name and all serverPaths in group      Element featureElement = (Element) (featureNodes.item(i));      // there must be one type per feature      String typeName = featureElement.getAttribute("value");      // eventually we need to replace this with an XML attribute      String callingCalledString;      if ((typeName.equals("ForwardNoAnswerBusy"))           || (typeName.equals("ForwardAllCalls"))           || (typeName.equals("CallScreening"))           || (typeName.equals("Voicemail"))           || (typeName.equals("CallReturn")))      {        callingCalledString = "Called";      }      else if ((typeName.equals("CallBlocking"))                || (typeName.equals("CallerIdBlocking")))      {        callingCalledString = "Calling";      }      else      {        System.out.println("Error: type name " + typeName                            + " not recognized");        return null;      }      // there may be zero or more groups per feature      NodeList groupNodes =         featureElement.getElementsByTagName("serverGroup");      for (int j = 0; j < groupNodes.getLength(); j++)      {        pathVector = new Vector();        String serverGroupName = null;        Element groupElement = (Element) (groupNodes.item(j));        serverGroupName = groupElement.getAttribute("value");        // the first thing in the vector is the group name        pathVector.add(serverGroupName);        // each additional entry in the vector is a pathname for that group        NodeList serverNodes = groupElement.getElementsByTagName("server");        for (int k = 0; k < serverNodes.getLength(); k++)        {          Element serverElement = (Element) (serverNodes.item(k));          String hostName = serverElement.getAttribute("host");          String portNumber = serverElement.getAttribute("port");          String serverPath = FEATURE_DIR + "_" + hostName + "_" + portNumber                   + "_" + callingCalledString;          pathVector.add(serverPath);          pathArray = new String[pathVector.size()];          pathVector.copyInto(pathArray);        }        if (pathVector.size() == 1)     // serverGroupName only        {          // no cpl will be generated for this group today.          System.out.println("Error: " + pathVector.firstElement()                              + " has no associated server");        }        else        {          pathArrayVector.add(pathArray);        }      }    }    if (pathArrayVector.isEmpty())    {      System.out.println("Error: no path information");      return null;    }    String allPathArrays[][] = new String[pathArrayVector.size()][];    pathArrayVector.copyInto(allPathArrays);    // take a look at what's in this mess    for (int n = 0; n < allPathArrays.length; n++)    {      String[] serverGroupPaths = allPathArrays[n];      if (serverGroupPaths == null)      {        System.out.println("serverGroupPaths is null");        new Exception().printStackTrace();      }      for (int p = 0; p < serverGroupPaths.length; p++)      {        System.out.println(serverGroupPaths[p]);      }    }    return allPathArrays;  }  /**   *    * @param con   */  public CplGenerator(VPPTransactionWrapper con)  {    connection = con;    init();  }  /**   * Set up the Element references we need.   */  private void init()  {    try    {      cplFilePaths = buildCplFilePaths();      fnabDOM = createDocument(FNAB_DOCUMENT);      Element rootElement = fnabDOM.getDocumentElement();      fnabIncomingLookupElement =         getFirstElementChild(getFirstElementChild(rootElement));      Element fnabSuccessElement =         getFirstElementChild(fnabIncomingLookupElement);      fnabProxyElement = getFirstElementChild(fnabSuccessElement);      fnabFailureElement = getFirstElementChild(fnabProxyElement);      fnabFailureLocationElement = getFirstElementChild(fnabFailureElement);      busyNode = buildNode(fnabDOM, BUSY_FRAGMENT, "busy");      fnabBusyLocationElement = (Element) busyNode.getFirstChild();      noAnswerNode = buildNode(fnabDOM, NO_ANSWER_FRAGMENT, "noanswer");      fnabNoAnswerLocationElement = (Element) noAnswerNode.getFirstChild();      cfaDOM = createDocument(CFA_DOCUMENT);      rootElement = cfaDOM.getDocumentElement();      cfaForwardElement =         getFirstElementChild(getFirstElementChild(rootElement));      clblDOM = createDocument(CLBL_DOCUMENT);      NodeList nodes = clblDOM.getElementsByTagName("outgoing");      Element outgoingElement = (Element) nodes.item(0);      if (outgoingElement == null)      {        throw new NoSuchNodeException("outgoing");      }      clblAddressSwitchElement = getFirstElementChild(outgoingElement);      clblDummyElement = getFirstElementChild(clblAddressSwitchElement);      csDOM = createDocument(CS_DOCUMENT);      nodes = csDOM.getElementsByTagName("incoming");      Element incomingElement = (Element) nodes.item(0);      if (incomingElement == null)      {        throw new NoSuchNodeException("incoming");      }      csAddressSwitchElement = getFirstElementChild(incomingElement);      csDummyElement = getFirstElementChild(csAddressSwitchElement);      blockLongDistanceFrag = buildDocumentFragment(clblDOM,               BLOCKLD_FRAGMENT);      block900Frag = buildDocumentFragment(clblDOM, BLOCK900_FRAGMENT);    }    catch (NoSuchNodeException e)    {      System.out.println(e.getMessage());      e.printStackTrace();    }  }  /**   *    */  protected Document createDocument(String rawXML)  {    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();    DocumentBuilder parser = null;    try    {      parser = dbf.newDocumentBuilder();    }    catch(ParserConfigurationException e)    {      e.printStackTrace();      return null;    }    StringReader reader = new StringReader(rawXML);    try    {      return parser.parse(new InputSource(reader));    }    catch (Exception e)    {      e.printStackTrace();      return null;    }  }  /**   *    */  private static String createXMLString(Node node)  {    String theXML = new XMLUtils().buildXMLString(node);    return (FIRST_LINE + SECOND_LINE + theXML);  }}

⌨️ 快捷键说明

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