private void outputItem(XmlWriter out, String name, String value, boolean endTag)
     throws IOException {
   out.tag("item").attr("name", name).attr("value", value);
   if (endTag) {
     out.endTag();
   }
 }
 private void outputAttributesRoute(XmlWriter out, String name) throws IOException {
   outputItemClass(out, "ie.ncl.vivato.router.AttributesRoute");
   outputPropertyClass(out, "java.util.ArrayList", "attributes");
   outputItemClass(out, "ie.ncl.vivato.router.AttributesRoute$Attribute");
   outputProperty(out, "criteria", "userfield1");
   outputProperty(out, "value", name + INSTANCE_GATEWAY_SUFFIX);
   out.endTag();
   out.endTag();
   outputPropertyClass(out, "java.util.ArrayList", "destinations");
   outputComponent(out, name + INSTANCE_GATEWAY_SUFFIX);
   out.endTag();
   out.endTag();
 }
 private void outputAlertFindInstanceRouterApp(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.VivatoApplication", INSTANCE_ROUTER_APPLICATION);
   outputProperty(out, "messageService", "provato-envious-service");
   outputProperty(out, "description", "");
   outputProperty(out, "destination", "InstanceRouter");
   outputPropertyClass(out, "ie.ncl.vivato.messaging.soap.SoapClientInterface", "clientInterface");
   out.endTag();
   outputProperty(out, "dialingDomain", "provato-dialingdomain-default");
   outputProperty(out, "lastApplicationDatabase", "provato-lastapplication-database");
   outputProperty(out, "correlationIdEnabled", "true");
   outputProperty(out, "correlationIdExpirySeconds", "0");
   out.endTag();
 }
 private void outputMessageDatabase(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.messagedatabase.MessageDatabase", "provato-message-database");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "runExpiryEverySeconds", "3600");
   out.endTag();
 }
 private void outputTransactionLog(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.transactionlog.TransactionLog", "provato-transaction-log");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "runExpiryEverySeconds", "3600");
   out.endTag();
 }
 private void outputHibernateReceiptDatabase(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.receiptdatabase.HibernateReceiptDatabase", "provato-receipt-database");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "runExpiryEverySeconds", "3600");
   out.endTag();
 }
 private void outputRetryPolicy(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.messaging.RetryPolicy", "provato-retrypolicy-default");
   outputPropertyClass(out, "java.util.Properties", "policy");
   outputItem(out, "Too many messages in queue", "5,60,300,1800,3600");
   out.endTag();
   out.endTag();
 }
 private void outputLoggingComponent(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.LoggingComponent", "provato-logging");
   outputProperty(out, "debugLogging", "true");
   outputProperty(out, "logFolderRelative", "../logs");
   outputProperty(out, "vivatoSettings", "provato-settings");
   out.endTag();
 }
  private void outputInstance(XmlWriter out, int code, String name) throws IOException {
    String appName = name + code;

    outputComponentClass(out, "ie.ncl.vivato.VivatoApplication", appName);
    outputProperty(out, "messageService", "provato-envious-service");
    outputProperty(out, "description", "");
    outputProperty(out, "destination", "mBloxDirectPlus");
    outputPropertyClass(out, "ie.ncl.vivato.messaging.soap.SoapClientInterface", "clientInterface");
    out.endTag();
    outputProperty(out, "dialingDomain", "provato-dialingdomain-default");
    outputProperty(out, "lastApplicationDatabase", "provato-lastapplication-database");
    outputProperty(out, "correlationIdEnabled", "true");
    outputProperty(out, "correlationIdDatabase", "provato-correlationid-database");
    outputProperty(out, "correlationIdExpirySeconds", "0");
    out.endTag();
    outputComponentClass(
        out,
        "ie.ncl.vivato.gateway.provato.InterProvatoGateway",
        appName + INSTANCE_GATEWAY_SUFFIX);
    outputProperty(out, "messageService", "provato-envious-service");
    outputProperty(out, "licenses", "provato-licenses");
    outputProperty(out, "receiptDatabase", "provato-receipt-database");
    outputProperty(out, "lastNetworkDatabase", "provato-lastnetwork-database");
    outputPropertyClass(out, "java.util.Properties", "properties");
    out.endTag();
    outputProperty(out, "destination", appName);
    outputProperty(out, "description", "");
    outputProperty(out, "receiptDatabaseGroup", appName + INSTANCE_GATEWAY_SUFFIX);
    outputProperty(out, "sendingEnrouteMessages", "false");
    outputProperty(out, "connectAtStartup", "true");
    outputProperty(out, "reconnectEverySeconds", "300");
    outputProperty(out, "throttleMaximumPerHour", "0");
    outputProperty(out, "transactionLogValue", "");
    outputProperty(out, "dialingDomain", "provato-dialingdomain-default");
    outputProperty(out, "emailAlerts", "provato-emailalerts-default");
    outputProperty(out, "mediaMessageParser", "provato-mediamessageparser");
    outputProperty(out, "retryPolicy", "provato-retrypolicy-default");
    outputProperty(out, "removeSourceAddressesMT", "false");
    outputProperty(out, "originalMessageStoredInReceiptDatabase", "false");
    outputProperty(
        out,
        "serverUrl",
        "http://localhost:8080/provato/inter/" + appName + INSTANCE_GATEWAY_SUFFIX);
    outputProperty(out, "applicationName", "");
    out.endTag();
  }
 private void outputLongMessageReassembler(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.sms.LongMessageReassembler", "provato-longmessagereceive");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "minutesExpiry", "10");
   outputProperty(out, "runExpiryEverySeconds", "3600");
   out.endTag();
 }
 private void outputDialingDomain(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.DialingDomain", "provato-dialingdomain-default");
   outputProperty(out, "internationalCode", "1");
   outputProperty(out, "internationalDirectDialingCode", "011");
   outputProperty(out, "nationalDirectDialingCode", "1");
   outputProperty(out, "minNationalNumberLength", "6");
   out.endTag();
 }
 private void outputEnviousVivatoMessageService(XmlWriter out) throws IOException {
   outputComponentClass(
       out,
       "ie.ncl.vivato.messaging.envious.EnviousVivatoMessageService",
       "provato-envious-service");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "licensesComponent", "provato-licenses");
   out.endTag();
 }
 private void outputEmailAlerts(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.EmailAlerts", "provato-emailalerts-default");
   outputProperty(out, "smtpHost", "{MTA_VIP_NAME}");
   outputProperty(out, "from", "{NOTIFY_M1_FROM}");
   outputProperty(out, "to", "{NOTIFY_M1_RECIPIENTS}");
   outputProperty(out, "cc", "");
   outputProperty(out, "enabled", "true");
   out.endTag();
 }
 private void outputSimpleDataSourceComponent(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.database.SimpleDataSourceComponent", "provato-datasource");
   outputProperty(out, "dialect", "MySQL");
   outputProperty(out, "driverClass", "com.mysql.jdbc.Driver");
   outputProperty(out, "url", "jdbc:mysql://{DB_HOSTNAME}/{DB_NAME}");
   outputProperty(out, "username", "{DB_USERNAME}");
   outputProperty(out, "password", "{DB_PASSWORD}");
   out.endTag();
 }
 private void outputCorrelationIdDatabase(XmlWriter out) throws IOException {
   outputComponentClass(
       out,
       "ie.ncl.vivato.database.correlationid.CorrelationIdDatabase",
       "provato-correlationid-database");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "runExpiryEverySeconds", "600");
   outputProperty(out, "enabled", "true");
   out.endTag();
 }
 private void outputLastNetworkDatabase(XmlWriter out) throws IOException {
   outputComponentClass(
       out,
       "ie.ncl.vivato.database.lastnetwork.LastNetworkDatabase",
       "provato-lastnetwork-database");
   outputProperty(out, "dataSource", "provato-datasource");
   outputProperty(out, "entryExpirySeconds", "604800");
   outputProperty(out, "runExpiryEverySeconds", "3600");
   outputProperty(out, "enabled", "true");
   out.endTag();
 }
 private void outputMmsServerComponent(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.mms.mm1.MmsMm1ServerComponent", "provato-mms-mm1");
   outputProperty(out, "mmscUrlBase", "http://localhost:8080/provato/mmsc/");
   outputProperty(out, "messageDatabase", "provato-message-database");
   outputProperty(out, "hoursExpiry", "168");
   outputProperty(out, "cacheManager", "provato-caches");
   outputProperty(out, "mediaMessageParser", "provato-mediamessageparser");
   outputProperty(out, "receiptForWapPush", "false");
   outputProperty(out, "receiptForFetch", "true");
   outputProperty(out, "messageService", "provato-envious-service");
   out.endTag();
 }
  void doOutput(Map<Integer, String> instanceMap) throws IOException {
    XmlWriter out = null;
    try {
      OutputStreamWriter stream = new OutputStreamWriter(new FileOutputStream(m_outputFile));
      stream.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
      out = new XmlWriter(stream, true, true);
      outputHeader(out);
      outputInboundRouter(out, instanceMap);
      outputAlertFindInstanceRouterApp(out);
      outputInstances(out, instanceMap);
      outputRouterAppToInstancesRouter(out, instanceMap);
      outputMbloxGateways(out);
      outputVivatoConsoleSettings(out);
      outputCorrelationIdDatabase(out);
      outputSimpleDataSourceComponent(out);
      outputDialingDomain(out);
      outputEmailAlerts(out);
      outputEnviousVivatoMessageService(out);
      outputVivatoFailureRecovery(out);
      outputLastApplicationDatabase(out);
      outputLastNetworkDatabase(out);
      outputLoggingComponent(out);
      outputLongMessageReassembler(out);
      outputMediaMessageParser(out);
      outputMessageDatabase(out);
      outputVivatoMessageContentHandler(out);
      outputMmsServerComponent(out);
      outputMmsOverWmlComponent(out);
      outputHibernateReceiptDatabase(out);
      outputRetryPolicy(out);
      outputTransactionLog(out);
      outputWebserverComponent(out);
      outputFooter(out);

    } finally {
      if (out != null) {
        out.close();
      }
    }
  }
 private void outputRouterAppToInstancesRouter(XmlWriter out, Map<Integer, String> instanceMap)
     throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.router.Router", "InstanceRouter");
   outputProperty(out, "messageService", "provato-envious-service");
   outputProperty(out, "lastNetworkDatabase", "provato-lastnetwork-database");
   outputProperty(out, "lastApplicationDatabase", "provato-lastapplication-database");
   outputProperty(out, "direction", "outbound");
   outputPropertyClass(out, "ie.ncl.vivato.router.DefaultRoute", "defaultRoute");
   outputPropertyClass(out, "java.util.ArrayList", "destinations");
   outputComponent(out, "mBloxDirectPlus");
   out.endTag();
   out.endTag();
   outputProperty(out, "description", "");
   outputPropertyClass(out, "java.util.ArrayList", "routeTable");
   for (Iterator<Integer> iter = instanceMap.keySet().iterator(); iter.hasNext(); ) {
     Integer id = iter.next();
     String instanceName = instanceMap.get(id);
     outputAttributesRoute(out, instanceName + id);
   }
   out.endTag();
   out.endTag();
 }
 private void outputInboundRouter(XmlWriter out, Map<Integer, String> instanceMap)
     throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.router.Router", "AlertFindInboundRouter");
   outputProperty(out, "messageService", "provato-envious-service");
   outputProperty(out, "lastNetworkDatabase", "provato-lastnetwork-database");
   outputProperty(out, "lastApplicationDatabase", "provato-lastapplication-database");
   outputProperty(out, "direction", "inbound");
   outputPropertyClass(out, "ie.ncl.vivato.router.DefaultRoute", "defaultRoute");
   outputPropertyClass(out, "java.util.ArrayList", "destinations");
   outputComponent(out, INSTANCE_ROUTER_APPLICATION);
   out.endTag();
   out.endTag();
   outputProperty(out, "description", "content-based router");
   outputPropertyClass(out, "java.util.ArrayList", "routeTable");
   outputItemClass(out, "ie.ncl.vivato.router.AttributesRoute");
   outputPropertyClass(out, "java.util.ArrayList", "attributes");
   outputItemClass(out, "ie.ncl.vivato.router.AttributesRoute$Attribute");
   outputProperty(out, "criteria", "firstword");
   outputProperty(out, "value", "msg1");
   out.endTag();
   out.endTag();
   outputPropertyClass(out, "java.util.ArrayList", "destinations");
   outputComponent(out, INSTANCE_ROUTER_APPLICATION);
   out.endTag();
   out.endTag();
   outputItemClass(out, "ie.ncl.vivato.router.DeliveryReceiptRoute");
   outputPropertyClass(out, "java.util.ArrayList", "destinations");
   outputComponent(out, INSTANCE_ROUTER_APPLICATION);
   for (Iterator<Integer> iter = instanceMap.keySet().iterator(); iter.hasNext(); ) {
     Integer code = iter.next();
     String instanceName = instanceMap.get(code);
     outputComponent(out, instanceName + code);
   }
   out.endTag();
   out.endTag();
   out.endTag();
   out.endTag();
 }
 private void outputMmsOverWmlComponent(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.mms.wml.MmsOverWmlComponent", "provato-mmsoverwml");
   outputProperty(out, "wmlUrlBase", "http://localhost:8080/provato/mmsoverwml/");
   outputProperty(out, "messageDatabase", "provato-message-database");
   outputProperty(out, "cacheManager", "provato-caches");
   outputProperty(out, "mediaMessageParser", "provato-mediamessageparser");
   outputProperty(out, "hoursExpiry", "168");
   outputProperty(out, "receiptForWapPush", "false");
   outputProperty(out, "receiptForFetchWml", "true");
   outputProperty(out, "messageService", "provato-envious-service");
   outputProperty(out, "anchorLinkAroundImages", "true");
   outputProperty(out, "generateReplyLink", "true");
   out.endTag();
 }
 void outputHeader(XmlWriter out) throws IOException {
   out.tag("vivato");
 }
 private void outputItemClass(XmlWriter out, String sClass) throws IOException {
   out.tag("item").attr("class", sClass);
 }
 private void outputPropertyClass(XmlWriter out, String sClass, String name) throws IOException {
   out.tag("property").attr("class", sClass).attr("name", name);
 }
 private void outputComponent(XmlWriter out, String value) throws IOException {
   out.tag("component").attr("value", value).endTag();
 }
 private void outputComponentClass(XmlWriter out, String sClass, String name) throws IOException {
   out.tag("component").attr("class", sClass).attr("name", name);
 }
 private void outputWebserverComponent(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.standalone.WebserverComponent", "provato-web");
   outputProperty(out, "port", "8080");
   outputProperty(out, "vivatoSettings", "provato-settings");
   out.endTag();
 }
 private void outputVivatoFailureRecovery(XmlWriter out) throws IOException {
   outputComponentClass(out, "ie.ncl.vivato.VivatoFailureRecovery", "provato-failure-recovery");
   outputProperty(out, "checkEverySeconds", "0");
   out.endTag();
 }
 private void outputMediaMessageParser(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.message.MediaMessageParser", "provato-mediamessageparser");
   outputProperty(out, "messageContentHandler", "provato-messagecontenthandler");
   out.endTag();
 }
 private void outputVivatoMessageContentHandler(XmlWriter out) throws IOException {
   outputComponentClass(
       out, "ie.ncl.vivato.message.VivatoMessageContentHandler", "provato-messagecontenthandler");
   outputProperty(out, "cacheManager", "provato-caches");
   out.endTag();
 }