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

📄 generate.java

📁 SIP(Session Initiation Protocol)是由IETF定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }      }/**      //generate contact lists      if (generateCplAndCl)      {        generateContactLists(userName, doc);      }**/    }//end for userCount users    long stopTime = System.currentTimeMillis();    System.out.println("Generated " + numUsr + " users");    System.out.println("Stop time = " + new Date(stopTime));    long elapsedTime = stopTime-startTime;    System.out.println("Elapsed time = " + elapsedTime + " ms");   }  private static void setFeatureGroup(Element node, int goupIndex, Vector groupList)  {    try    {      Node group = XMLUtils.getChildByName(node,"featuregroup");      group.getChildNodes().item(0).setNodeValue((String)groupList.elementAt(goupIndex)); //set the group name in the dom    }    catch (Exception e)    {      System.out.println("Could not set feature group for fnab because: " + e);      e.printStackTrace();    }  }  private static Document generateUser(String userName)  {    long startTime = System.currentTimeMillis();    System.out.println("Start time for user " + userName + " = " + new Date(startTime));    Document doc = parser.getDocument(); //get handle of document    //replace the user name with the generated name    NodeList names = doc.getElementsByTagName("name");    Node name = names.item(0); //only one name should exist   	NodeList children = name.getChildNodes();    Node nameString = children.item(0); //the text node which is the contents of the <name> element    nameString.setNodeValue(userName);    NodeList fnabs = doc.getElementsByTagName("fnab");    Node fnab = fnabs.item(0);    //if the server was provisioned with some fnab groups    int groupIndex = 0;    if (fnabGroups.size() > 0)    {      //set the feature group for forward-no answer-busy to one of the groups that exist on this server      groupIndex = random.nextInt(fnabGroups.size()); //select a group at random      setFeatureGroup((Element)fnab, groupIndex, fnabGroups);    }    if (cfaGroups.size() > 0)    {      //set the feature group for forward-all calls      NodeList cfas = doc.getElementsByTagName("cfa");      Node cfa = cfas.item(0);      setFeatureGroup((Element)cfa, 0, cfaGroups);    }    if (csGroups.size() > 0)    {      //set the feature group for call screening      NodeList css = doc.getElementsByTagName("cs");      Node cs = css.item(0);      setFeatureGroup((Element)cs, 0, csGroups);    }    if (clblGroups.size() > 0)    {      //set the feature group for call blocking      NodeList clbls = doc.getElementsByTagName("clbl");      Node clbl = clbls.item(0);      setFeatureGroup((Element)clbl, 0, clblGroups);    }    if (vmGroups.size() > 0)    {      NodeList vms = doc.getElementsByTagName("voicemail");      Node vm = vms.item(0);      setFeatureGroup((Element)vm,0,vmGroups);    }    if (callReturnGroups.size() > 0)    {      NodeList crs = doc.getElementsByTagName("callReturn");      Node cr = crs.item(0);      setFeatureGroup((Element)cr,0,callReturnGroups);    }    if (callerIdBlockGroups.size() > 0)    {      NodeList cibs = doc.getElementsByTagName("callerIdBlocking");      Node cib = cibs.item(0);      setFeatureGroup((Element)cib,0,callerIdBlockGroups);    }    boolean fnaSet = random.nextBoolean();    //select whether forward-no answer is enabled    try    {      Element fna = XMLUtils.getChildByName((Element)fnab,"fna");      String set = new Boolean(fnaSet).toString(); //select value at raondom      fna.setAttribute("set", set);    }    catch (Exception e)    {      System.out.println("Could not set fna status because: ");      e.printStackTrace();    }    //select whether forward-busy is enabled    boolean cfbSet = random.nextBoolean();    try    {      Element cfb = XMLUtils.getChildByName((Element)fnab,"cfb");      String set = new Boolean(cfbSet).toString(); //select value at raondom      cfb.setAttribute("set", set);    }    catch (Exception e)    {      System.out.println("Could not set cfb status because: ");      e.printStackTrace();    }    long stopTime = System.currentTimeMillis();    System.out.println("Stop time for user " + userName + " = " + new Date(stopTime));    long elapsedTime = stopTime - startTime;    System.out.println("Elapsed time for xml generation = " + elapsedTime);/**    if (generateCplAndCl)    {      if (fnabGroups.size() > 0)      {        //generate cpl for fnab        try        {          String cpl = gen.buildFnabXML(userName,fnaSet,fnaDestination,cfbSet,cfbDestination,failureCause);          generateCpl((String)fnabGroups.elementAt(groupIndex),userName,cpl);        }        catch (Exception e)        {          System.out.println("Could not generate fnab cpl because");          e.printStackTrace();        }      }**///The following is commented out because for now, do not generate cpl for//features which are not turned on and the only feature which may be on now//is the forward-no-answer-blocking feature/**      //generate cpl for cfa      try      {        String cpl = gen.buildCfaXML(cfaDestination);        generateCpl((String)cfaGroups.elementAt(0),userName,cpl);      }      catch (Exception e)      {        System.out.println("Could not generate cfa cpl because");        e.printStackTrace();      }      //generate cpl for clbl      try      {        String cpl = gen.buildClblXML(nineHundredBlocked,longDistanceBlocked);        generateCpl((String)clblGroups.elementAt(0),userName,cpl);      }      catch (Exception e)      {        System.out.println("Could not generate clbl cpl because");        e.printStackTrace();      }      //generate cpl for cs      try      {        String cpl = gen.buildCsXML(doc);        generateCpl((String)csGroups.elementAt(0),userName,cpl);      }      catch (Exception e)      {        System.out.println("Could not generate cs cpl because");        e.printStackTrace();      }**///    }    return doc;  } //end method generateUser  private static void getGroups()  {    SAXParser parser = new SAXParser();    parser.setContentHandler(new DefaultHandler()    {      private String currentType = "";      public void startElement(String ignore1, String ignore2,        String rawName, Attributes attr)      {        if (rawName.equals("serverType"))        {          currentType = attr.getValue("value");        }        else if (rawName.equals("serverGroup"))        {          if (currentType.equals("ForwardAllCalls"))          {System.out.println("---TRACE--- cfa group = " +  attr.getValue("value"));            cfaGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("ForwardNoAnswerBusy"))          {System.out.println("---TRACE--- fnab group = " +  attr.getValue("value"));            fnabGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("CallBlocking"))          {System.out.println("---TRACE--- clbl group = " +  attr.getValue("value"));            clblGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("CallScreening"))          {System.out.println("---TRACE--- cs group = " +  attr.getValue("value"));            csGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("Voicemail"))          {System.out.println("---TRACE--- vm group = " +  attr.getValue("value"));            vmGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("CallReturn"))          {System.out.println("---TRACE--- CallReturn group = " +  attr.getValue("value"));            callReturnGroups.addElement(attr.getValue("value"));          }          else if (currentType.equals("CallerIdBlocking"))          {System.out.println("---TRACE--- CallerIdBlocking group = " +  attr.getValue("value"));            callerIdBlockGroups.addElement(attr.getValue("value"));          }        }      }    });    try    {      BufferedReader response = connection.request("GET", "SystemConfiguration", "ListOfFeatureServers");      parser.parse(new InputSource(response));    }    catch (Exception e)    {      System.out.println("Could not parse ListOfFeatureServers because:");      e.printStackTrace();    } } //end method getGroups/**  private static void generateCpl(String group, String userName, String cpl)  {    String [] paths = gen.getAddressArray(group);    for (int i=1; i<paths.length; i++)    {      String group = paths[i];			String filename = userName + ".cpl";      if (writeToLocalFile)      {        connection.doPut(group.substring(1),filename,cpl,VPPTransaction.WRITE_TO_FILE);      }      else      {        connection.doPut(group, filename, cpl);      }    }  }**//**  private static void generateContactLists(String userName, Document doc)  {    //generate and save contact lists    ContactListGenerator contactListGen = new ContactListGenerator();    String called = contactListGen.buildCalledContactList(doc);    String calling = contactListGen.buildCallingContactList(doc);    if (writeToLocalFile)    {      connection.doPut("Contact_Lists_Called", userName, called,VPPTransaction.WRITE_TO_FILE);      connection.doPut("Contact_Lists_Calling", userName, calling,VPPTransaction.WRITE_TO_FILE);    }    else    {      connection.doPut("Contact_Lists_Called", userName, called, VPPTransaction.WRITE_TO_PSERVER);      connection.doPut("Contact_Lists_Calling", userName", calling,VPPTransaction.WRITE_TO_PSERVER);    }  } //end method generateContactLists**/}

⌨️ 快捷键说明

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