Ejemplo n.º 1
1
  public static ComponentInComponent_c[] getManyCN_CICsOnR4202(
      Component_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new ComponentInComponent_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_CanNestComponentInComponentCanNest_R4202) {
      for (int i = 0; i < target.backPointer_CanNestComponentInComponentCanNest_R4202.size(); ++i) {
        ComponentInComponent_c source =
            (ComponentInComponent_c)
                target.backPointer_CanNestComponentInComponentCanNest_R4202.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      ComponentInComponent_c[] ret_set = new ComponentInComponent_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new ComponentInComponent_c[0];
    }
  }
Ejemplo n.º 2
1
  public static InformalArgument_c[] getManyMSG_IAsOnR1013(
      MessageArgument_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new InformalArgument_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      InformalArgument_c source =
          (InformalArgument_c) targets[i].backPointer_IsSubtypeInformalArgumentIsSubtype_R1013;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      InformalArgument_c[] ret_set = new InformalArgument_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new InformalArgument_c[0];
    }
  }
Ejemplo n.º 3
0
  public static ElementInMove_c[] getManyGD_EIMsOnR25(
      GraphicalElement_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null) return new ElementInMove_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(ElementInMove_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      synchronized (targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25) {
        for (int j = 0;
            j < targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25.size();
            ++j) {
          ElementInMove_c source =
              (ElementInMove_c) targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25.get(j);
          if (source != null && (test == null || test.evaluate(source))) {
            matches.add(source);
          }
        }
      }
    }
    if (matches.size() > 0) {
      ElementInMove_c[] ret_set = new ElementInMove_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new ElementInMove_c[0];
    }
  }
Ejemplo n.º 4
0
  public static ElementInMove_c[] getManyGD_EIMsOnR25(
      Model_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new ElementInMove_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_IsMovingElementInMoveIsMoving_R25) {
      for (int i = 0; i < target.backPointer_IsMovingElementInMoveIsMoving_R25.size(); ++i) {
        ElementInMove_c source =
            (ElementInMove_c) target.backPointer_IsMovingElementInMoveIsMoving_R25.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      ElementInMove_c[] ret_set = new ElementInMove_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new ElementInMove_c[0];
    }
  }
  public static InstanceStateMachine_c[] getManySM_ISMsOnR518(
      ModelClass_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new InstanceStateMachine_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();
    if (loadComponent) {
      // Containment Relation
      PersistableModelComponent[] pmcs = new PersistableModelComponent[targets.length];
      for (int i = 0; i < targets.length; i++) {
        pmcs[i] = targets[i].getPersistableComponent();
      }
      PersistenceManager.ensureAllChildInstancesLoaded(
          pmcs, modelRoot, InstanceStateMachine_c.class);
    }

    InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      InstanceStateMachine_c source =
          (InstanceStateMachine_c) targets[i].backPointer_InstanceStateMachine_R518;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      InstanceStateMachine_c[] ret_set = new InstanceStateMachine_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new InstanceStateMachine_c[0];
    }
  }
Ejemplo n.º 6
0
  public AllMultilevelCoefs(CoefArgs args) throws IOException {
    this.args = args;
    files = new Vector<File>();
    keys = new Vector<String>();
    coefs = new Vector<MultilevelCoefs>();

    File dir = args.dir();
    for (int i = 0; i < args.keys.length; i++) {
      keys.add(args.keys[i]);
      File f = CoefArgs.coefFile(dir, args.keys[i]);
      files.add(f);

      coefs.add(new MultilevelCoefs(f));
      System.out.println(String.format("Loaded: %s", args.keys[i]));
    }
  }
  public static BridgeInvocation_c[] getManyACT_BRGsOnR674(
      Bridge_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new BridgeInvocation_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(BridgeInvocation_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      synchronized (targets[i].backPointer_BridgeInvocation_R674) {
        for (int j = 0; j < targets[i].backPointer_BridgeInvocation_R674.size(); ++j) {
          BridgeInvocation_c source =
              (BridgeInvocation_c) targets[i].backPointer_BridgeInvocation_R674.get(j);
          if (source != null && (test == null || test.evaluate(source))) {
            matches.add(source);
          }
        }
      }
    }
    if (matches.size() > 0) {
      BridgeInvocation_c[] ret_set = new BridgeInvocation_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new BridgeInvocation_c[0];
    }
  }
Ejemplo n.º 8
0
  public static AssignToMember_c[] getManyACT_AIsOnR603(
      Statement_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new AssignToMember_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(AssignToMember_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      AssignToMember_c source =
          (AssignToMember_c) targets[i].backPointer_IsSubtypeAssignToMemberIsSubtype_R603;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      AssignToMember_c[] ret_set = new AssignToMember_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new AssignToMember_c[0];
    }
  }
Ejemplo n.º 9
0
  public static ComponentInComponent_c[] getManyCN_CICsOnR4202(
      Component_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new ComponentInComponent_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(ComponentInComponent_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      synchronized (targets[i].backPointer_CanNestComponentInComponentCanNest_R4202) {
        for (int j = 0;
            j < targets[i].backPointer_CanNestComponentInComponentCanNest_R4202.size();
            ++j) {
          ComponentInComponent_c source =
              (ComponentInComponent_c)
                  targets[i].backPointer_CanNestComponentInComponentCanNest_R4202.get(j);
          if (source != null && (test == null || test.evaluate(source))) {
            matches.add(source);
          }
        }
      }
    }
    if (matches.size() > 0) {
      ComponentInComponent_c[] ret_set = new ComponentInComponent_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new ComponentInComponent_c[0];
    }
  }
  public static TransientValueReference_c[] getManyV_TVLsOnR805(
      Variable_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new TransientValueReference_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_TransientValueReference_R805) {
      for (int i = 0; i < target.backPointer_TransientValueReference_R805.size(); ++i) {
        TransientValueReference_c source =
            (TransientValueReference_c) target.backPointer_TransientValueReference_R805.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      TransientValueReference_c[] ret_set = new TransientValueReference_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new TransientValueReference_c[0];
    }
  }
Ejemplo n.º 11
0
  public static DataTypeInPackage_c[] getManyS_DIPsOnR39(
      DataType_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new DataTypeInPackage_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(DataTypeInPackage_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      synchronized (targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39) {
        for (int j = 0;
            j < targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39.size();
            ++j) {
          DataTypeInPackage_c source =
              (DataTypeInPackage_c)
                  targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39.get(j);
          if (source != null && (test == null || test.evaluate(source))) {
            matches.add(source);
          }
        }
      }
    }
    if (matches.size() > 0) {
      DataTypeInPackage_c[] ret_set = new DataTypeInPackage_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new DataTypeInPackage_c[0];
    }
  }
  public static BridgeInvocation_c[] getManyACT_BRGsOnR674(
      Bridge_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new BridgeInvocation_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_BridgeInvocation_R674) {
      for (int i = 0; i < target.backPointer_BridgeInvocation_R674.size(); ++i) {
        BridgeInvocation_c source =
            (BridgeInvocation_c) target.backPointer_BridgeInvocation_R674.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      BridgeInvocation_c[] ret_set = new BridgeInvocation_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new BridgeInvocation_c[0];
    }
  }
  public static DescriptionQuery_c[] getManySQU_DEsOnR9600(
      Query_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new DescriptionQuery_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(DescriptionQuery_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      DescriptionQuery_c source =
          (DescriptionQuery_c) targets[i].backPointer_IsSubtypeDescriptionQueryIsSubtype_R9600;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      DescriptionQuery_c[] ret_set = new DescriptionQuery_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new DescriptionQuery_c[0];
    }
  }
  public static ComponentResultSet_c[] getManyPE_CRSsOnR8007(
      Component_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new ComponentResultSet_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_HoldsComponentResultSetHolds_R8007) {
      for (int i = 0; i < target.backPointer_HoldsComponentResultSetHolds_R8007.size(); ++i) {
        ComponentResultSet_c source =
            (ComponentResultSet_c) target.backPointer_HoldsComponentResultSetHolds_R8007.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      ComponentResultSet_c[] ret_set = new ComponentResultSet_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new ComponentResultSet_c[0];
    }
  }
Ejemplo n.º 15
0
  public static DataTypeInPackage_c[] getManyS_DIPsOnR39(
      DataTypePackage_c target, ClassQueryInterface_c test, boolean loadComponent) {
    if (target == null) return new DataTypeInPackage_c[0];

    ModelRoot modelRoot = target.getModelRoot();
    Vector matches = new Vector();
    synchronized (target.backPointer_ContainsDataTypeInPackageContains_R39) {
      for (int i = 0; i < target.backPointer_ContainsDataTypeInPackageContains_R39.size(); ++i) {
        DataTypeInPackage_c source =
            (DataTypeInPackage_c) target.backPointer_ContainsDataTypeInPackageContains_R39.get(i);
        if (source != null && (test == null || test.evaluate(source))) {

          matches.add(source);
        }
      }
    }

    if (matches.size() > 0) {
      DataTypeInPackage_c[] ret_set = new DataTypeInPackage_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new DataTypeInPackage_c[0];
    }
  }
  public static TransientValueReference_c[] getManyV_TVLsOnR801(
      Value_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {

    if (targets == null || targets.length == 0 || targets[0] == null)
      return new TransientValueReference_c[0];

    ModelRoot modelRoot = targets[0].getModelRoot();

    InstanceList instances = modelRoot.getInstanceList(TransientValueReference_c.class);

    Vector matches = new Vector();
    for (int i = 0; i < targets.length; i++) {
      TransientValueReference_c source =
          (TransientValueReference_c)
              targets[i].backPointer_IsSubtypeTransientValueReferenceIsSubtype_R801;
      if (source != null && (test == null || test.evaluate(source))) {
        matches.add(source);
      }
    }
    if (matches.size() > 0) {
      TransientValueReference_c[] ret_set = new TransientValueReference_c[matches.size()];
      matches.copyInto(ret_set);
      return ret_set;
    } else {
      return new TransientValueReference_c[0];
    }
  }
Ejemplo n.º 17
0
  public static void main(String[] args) {
    /*          */
    System.out.println("Testing remove");
    HashSet s = new HashSet();
    testCollection t = new testCollection(s);
    boolean r = t.testSizeRemove();
    System.out.println("In testing " + t.description);
    if (r) System.out.println("Test was satisfied");
    else System.out.println("Test was NOT satisfied");

    System.out.println("Testing HashSet");
    HashSet ss = new HashSet();
    testCollection tt = new testCollection(ss);
    r = tt.testEmptyNew();
    System.out.println("In testing " + tt.description);
    if (r) System.out.println("Test was satisfied");
    else System.out.println("Test was NOT satisfied");

    System.out.println("Testing Vector");
    Vector v = new Vector();
    t = new testCollection(v);
    r = t.testEmptyNew();
    System.out.println("In testing " + t.description);
    if (r) System.out.println("Test was satisfied");
    else System.out.println("Test was NOT satisfied");

    HashSet sss = new HashSet();
    testCollection ttt = new testCollection(sss);
    ttt.applyTests("HashSet");
    sss.add(new Object()); // test non empty
    ttt.applyTests("HashSet");
    v = new Vector();
    t = new testCollection(v);
    t.applyTests("Vector");
    v.add(new Object()); // test non empty
    t.applyTests("VectorNonEmpty");

    LinkedList li = new LinkedList();
    testList tl = new testList(li);
    tl.applyTests("LinkedList");

    v = new Vector();
    tl = new testList(v);
    tl.applyTests("Vector");
    v.add(new Object()); // test non empty
    tl.applyTests("VectorNonEmpty");
  }
Ejemplo n.º 18
0
  /**
   * Enumerate the methods of the Clob interface and get the list of methods present in the
   * interface
   *
   * @param LOB an instance of the Clob interface implementation
   */
  void buildMethodList(Object LOB) throws IllegalAccessException, InvocationTargetException {
    // If the given method throws the correct exception
    // set this to true and add it to the
    boolean valid = true;

    // create a list of the methods that fail the test
    Vector<Method> methodList = new Vector<Method>();

    // The class whose methods are to be verified
    Class clazz = Clob.class;

    // The list of the methods in the class that need to be invoked
    // and verified
    Method[] methods = clazz.getMethods();

    // Check each of the methods to ensure that
    // they throw the required exception
    for (int i = 0; i < methods.length; i++) {
      if (!checkIfExempted(methods[i])) {
        valid = checkIfMethodThrowsSQLException(LOB, methods[i]);

        // add the method to the list if the method does
        // not throw the required exception
        if (valid == false) methodList.add(methods[i]);

        // reset valid
        valid = true;
      }
    }

    if (!methodList.isEmpty()) {
      int c = 0;
      String failureMessage = "The Following methods don't throw " + "required exception - ";
      for (Method m : methodList) {
        c = c + 1;
        if (c == methodList.size() && c != 1) failureMessage += " & ";
        else if (c != 1) failureMessage += " , ";
        failureMessage += m.getName();
      }
      fail(failureMessage);
    }
  }
Ejemplo n.º 19
0
 public static Graphnode_c[] GraphnodeInstances(
     ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) {
   InstanceList instances = modelRoot.getInstanceList(Graphnode_c.class);
   Vector matches = new Vector();
   synchronized (instances) {
     for (int i = 0; i < instances.size(); ++i) {
       Graphnode_c x = (Graphnode_c) instances.get(i);
       if (test == null || test.evaluate(x)) {
         matches.add(x);
       }
     }
     if (matches.size() > 0) {
       Graphnode_c[] ret_set = new Graphnode_c[matches.size()];
       matches.copyInto(ret_set);
       return ret_set;
     } else {
       return new Graphnode_c[0];
     }
   }
 }
Ejemplo n.º 20
0
  private static Dictionary<String, Object> getDictionary(
      Map<String, Type> types, Map<String, Object> values) throws Exception {
    Hashtable<String, Object> ht = new Hashtable<String, Object>();
    for (Map.Entry<String, Object> e : values.entrySet()) {
      String key = e.getKey();
      Object value = e.getValue();

      Type type;
      if (types != null && (type = types.get(key)) != null) {

        if (type.scalar != null) {
          value = convert(value, type.scalar);
        } else if (type.vectorOf != null) {
          Collection<Object> coll = (Collection<Object>) value;
          Vector vector = new Vector();
          for (Object o : coll) {
            vector.add(convert(o, type.vectorOf));
          }
          value = vector;
        } else if (type.arrayOf != null) {
          if (value instanceof String && type.arrayOf.equals("byte")) {
            value = Base64.decodeBase64((String) value);
          } else {
            Collection<Object> coll = (Collection<Object>) value;
            Object array = Array.newInstance(getClass(type.arrayOf), coll.size());
            int n = 0;
            for (Object o : coll) {
              Array.set(array, n++, convert(o, type.arrayOf));
            }
            value = array;
          }
        } else {
          throw new IllegalArgumentException(
              "Key " + key + " has type but neither scalar, vectorOf, nor arrayOf is set");
        }
      }
      ht.put(key, value);
    }
    return ht;
  }
Ejemplo n.º 21
0
 public static InformalArgument_c[] InformalArgumentInstances(
     ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) {
   if (loadComponent) {
     PersistenceManager.ensureAllInstancesLoaded(modelRoot, InformalArgument_c.class);
   }
   InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class);
   Vector matches = new Vector();
   synchronized (instances) {
     for (int i = 0; i < instances.size(); ++i) {
       InformalArgument_c x = (InformalArgument_c) instances.get(i);
       if (test == null || test.evaluate(x)) {
         if (x.ensureLoaded(loadComponent)) matches.add(x);
       }
     }
     if (matches.size() > 0) {
       InformalArgument_c[] ret_set = new InformalArgument_c[matches.size()];
       matches.copyInto(ret_set);
       return ret_set;
     } else {
       return new InformalArgument_c[0];
     }
   }
 }
Ejemplo n.º 22
0
  public static void main(String[] args) throws Exception {
    boolean isInteractive = false;
    classUrl = MynaInstaller.class.getResource("MynaInstaller.class").toString();
    isJar = (classUrl.indexOf("jar") == 0);
    if (!isJar) {
      System.err.println("Installer can only be run from inside a Myna distribution war file");
      System.exit(1);
    }

    Thread.sleep(1000);

    Console console = System.console();
    String response = null;
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();
    options.addOption(
        "c", "context", true, "Webapp context. Must Start with \"/\" Default: " + webctx);
    options.addOption("h", "help", false, "Displays help.");
    options.addOption(
        "w",
        "webroot",
        true,
        "Webroot to use. Will be created if webroot/WEB-INF does not exist. Default: " + webroot);
    options.addOption(
        "l",
        "logfile",
        true,
        "Log file to use. Will be created if it does not exist. Default: ./<context>.log");
    options.addOption(
        "s",
        "servername",
        true,
        "Name of this instance. Will also be the name of the init script. Defaults to either \"myna\" or the value of <context> if defined");
    // options.addOption( "P", "purpose", true, "Purpose of the Server, such as DEV,PROD,TRAIN, etc.
    // Defaults to DEV" );

    options.addOption("p", "port", true, "HTTP port. Set to 0 to disable HTTP. Default: " + port);
    options.addOption(
        "sp", "ssl-port", true, "SSL (HTTPS) port. Set to 0 to disable SSL, Default: 0");

    options.addOption(
        "ks", "keystore", true, "keystore path. Default: <webroot>/WEB-INF/myna/myna_keystore");
    options.addOption("ksp", "ks-pass", true, "keystore password. Default: " + ksPass);
    options.addOption("ksa", "ks-alias", true, "certificate alias. Default: " + ksAlias);

    modeOptions.add("upgrade");
    modeOptions.add("install");
    options.addOption(
        "m",
        "mode",
        true,
        "Mode: one of "
            + modeOptions.toString()
            + ". \n"
            + "\"upgrade\": Upgrades myna installation in webroot and exits. "
            + "\"install\": Unpacks to webroot, and installs startup files");
    options.addOption(
        "u",
        "user",
        true,
        "User to own and run the Myna installation. Only applies to unix installs. Default: nobody");

    HelpFormatter formatter = new HelpFormatter();

    String cmdSyntax = "java -jar myna-X.war -m <mode> [options]";
    try {
      CommandLine line = parser.parse(options, args);
      Option option;
      if (args.length == 0) {
        formatter.printHelp(cmdSyntax, options);
        response = console.readLine("\nContinue with Interactive Install? (y/N)");
        if (response.toLowerCase().equals("y")) {
          isInteractive = true;

        } else System.exit(1);
      }
      // Help
      if (line.hasOption("help")) {
        formatter.printHelp(cmdSyntax, options);
        System.exit(1);
      }
      // mode
      if (line.hasOption("mode")) {
        mode = line.getOptionValue("mode");
        if (!modeOptions.contains(mode)) {
          System.err.println(
              "Invalid Arguments.  Reason: Mode must be in " + modeOptions.toString());
          formatter.printHelp(cmdSyntax, options);
          System.exit(1);
        }
      } else if (isInteractive) {
        option = options.getOption("mode");
        console.printf("\n" + option.getDescription());

        do {
          response = console.readLine("\nEnter " + option.getLongOpt() + "(" + mode + "): ");
          if (!response.isEmpty()) mode = response;
        } while (!modeOptions.contains(mode));
      }
      // webroot
      if (line.hasOption("webroot")) {
        webroot = line.getOptionValue("webroot");
      } else if (isInteractive) {
        option = options.getOption("webroot");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + webroot + "): ");
        if (!response.isEmpty()) webroot = response;
      }
      // port
      if (line.hasOption("port")) {
        port = Integer.parseInt(line.getOptionValue("port"));
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("port");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + port + "): ");
        if (!response.isEmpty()) port = Integer.parseInt(response);
      }
      // context
      if (line.hasOption("context")) {
        webctx = line.getOptionValue("context");

      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("context");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + webctx + "): ");
        if (!response.isEmpty()) webctx = response;
      }
      if (!webctx.startsWith("/")) {
        webctx = "/" + webctx;
      }
      // servername (depends on context)
      if (!webctx.equals("/")) {
        serverName = webctx.substring(1);
      }
      if (line.hasOption("servername")) {
        serverName = line.getOptionValue("servername");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("servername");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + serverName + "): ");
        if (!response.isEmpty()) serverName = response;
      }
      // user
      if (line.hasOption("user")) {
        user = line.getOptionValue("user");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("user");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + user + "): ");
        if (!response.isEmpty()) user = response;
      }
      // logfile
      logFile = "myna.log";
      if (!webctx.equals("/")) {
        logFile = webctx.substring(1) + ".log";
      }
      if (line.hasOption("logfile")) {
        logFile = line.getOptionValue("logfile");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("logfile");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "path(" + logFile + "): ");
        if (!response.isEmpty()) logFile = response;
      }

      // ssl-port
      if (line.hasOption("ssl-port")) {
        sslPort = Integer.parseInt(line.getOptionValue("ssl-port"));
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("ssl-port");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + sslPort + "): ");
        if (!response.isEmpty()) sslPort = Integer.parseInt(response);
      }
      // ks-pass
      if (line.hasOption("ks-pass")) {
        ksPass = line.getOptionValue("ks-pass");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("ks-pass");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + ksPass + "): ");
        if (!response.isEmpty()) ksPass = response;
      }
      // ks-alias
      if (line.hasOption("ks-alias")) {
        ksAlias = line.getOptionValue("ks-alias");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("ks-alias");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + ksAlias + "): ");
        if (!response.isEmpty()) ksAlias = response;
      }
      // keystore
      String appBase = new File(webroot).getCanonicalPath();
      if (keystore == null) {
        keystore = appBase + "/WEB-INF/myna/myna_keystore";
      }
      if (line.hasOption("keystore")) {
        keystore = line.getOptionValue("keystore");
      } else if (isInteractive && mode.equals("install")) {
        option = options.getOption("keystore");
        console.printf("\n" + option.getDescription());
        response = console.readLine("\nEnter " + option.getLongOpt() + "(" + keystore + "): ");
        if (!response.isEmpty()) keystore = response;
      }

      javaOpts = line.getArgList();
    } catch (ParseException exp) {
      System.err.println("Invalid Arguments.	Reason: " + exp.getMessage());

      formatter.printHelp(cmdSyntax, options);
      System.exit(1);
    }

    if (isInteractive) {
      System.out.println("\nProceeed with the following settings?:\n");
      System.out.println("mode        = " + mode);
      System.out.println("webroot     = " + webroot);
      if (mode.equals("install")) {
        System.out.println("port        = " + port);
        System.out.println("context     = " + webctx);
        System.out.println("servername  = " + serverName);
        System.out.println("user        = "******"logfile     = " + logFile);
        System.out.println("ssl-port    = " + sslPort);
        System.out.println("ks-pass     = "******"ks-alias    = " + ksAlias);
        System.out.println("keystore    = " + keystore);
      }
      response = console.readLine("Continue? (Y/n)");
      if (response.toLowerCase().equals("n")) System.exit(1);
    }
    File wrFile = new File(webroot);
    webroot = wrFile.toString();
    if (mode.equals("install")) {
      adminPassword = console.readLine("\nCreate an Admin password for this installation: ");
    }
    // unpack myna if necessary
    if (!wrFile.exists() || mode.equals("upgrade") || mode.equals("install")) {
      upgrade(wrFile);
    }

    if (mode.equals("install")) {
      File propertiesFile = new File(wrFile.toURI().resolve("WEB-INF/classes/general.properties"));
      FileInputStream propertiesFileIS = new FileInputStream(propertiesFile);
      Properties generalProperties = new Properties();
      generalProperties.load(propertiesFileIS);
      propertiesFileIS.close();
      if (!adminPassword.isEmpty()) {
        org.jasypt.util.password.StrongPasswordEncryptor cryptTool =
            new org.jasypt.util.password.StrongPasswordEncryptor();
        generalProperties.setProperty("admin_password", cryptTool.encryptPassword(adminPassword));
      }
      generalProperties.setProperty("instance_id", serverName);

      generalProperties.store(
          new java.io.FileOutputStream(propertiesFile), "Myna General Properties");

      String javaHome = System.getProperty("java.home");
      webroot = new File(webroot).getCanonicalPath();
      if (serverName.length() == 0) serverName = "myna";
      if (java.lang.System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) {
        if (!new File(logFile).isAbsolute()) {
          logFile = new File(wrFile.toURI().resolve("WEB-INF/" + logFile)).toString();
        }
        File templateFile =
            new File(
                wrFile.toURI().resolve("WEB-INF/myna/install/windows/update_myna_service.cmd"));

        String initScript =
            FileUtils.readFileToString(templateFile)
                .replaceAll("\\{webctx\\}", webctx)
                .replaceAll("\\{server\\}", Matcher.quoteReplacement(serverName))
                .replaceAll("\\{webroot\\}", Matcher.quoteReplacement(webroot))
                .replaceAll("\\{logfile\\}", Matcher.quoteReplacement(logFile))
                .replaceAll("\\{javahome\\}", Matcher.quoteReplacement(javaHome))
                .replaceAll("\\{port\\}", new Integer(port).toString())
                .replaceAll("\\{sslPort\\}", new Integer(sslPort).toString())
                .replaceAll("\\{keystore\\}", Matcher.quoteReplacement(keystore))
                .replaceAll("\\{ksPass\\}", Matcher.quoteReplacement(ksPass))
                .replaceAll("\\{ksAlias\\}", Matcher.quoteReplacement(ksAlias));

        File scriptFile =
            new File(wrFile.toURI().resolve("WEB-INF/myna/install/update_myna_service.cmd"));

        FileUtils.writeStringToFile(scriptFile, initScript);

        // Runtime.getRuntime().exec("cmd /c start " + scriptFile.toString()).waitFor();

        System.out.println(
            "\nInstalled Service 'Myna App Server " + serverName + "' the following settings:\n");
        System.out.println(
            "\nInit script '" + scriptFile + "' created with the following settings:\n");
        System.out.println("memory=256MB");
        System.out.println("serverName=" + serverName);
        System.out.println("javaHome=" + javaHome);
        System.out.println("context=" + webctx);
        System.out.println("port=" + port);
        System.out.println("myna_home=" + webroot);
        System.out.println("logfile=" + logFile);

        System.out.println("sslPort=" + sslPort);
        System.out.println("keyStore=" + keystore);
        System.out.println("ksPass="******"ksAlias=" + ksAlias);

        System.out.println(
            "\nEdit and and run the command file in " + scriptFile + " to update this service");

      } else {
        String curUser = java.lang.System.getProperty("user.name");
        if (!curUser.equals("root")) {
          System.out.println("Install mode must be run as root.");
          System.exit(1);
        }

        if (!new File(logFile).isAbsolute()) {
          logFile = new File(wrFile.toURI().resolve("WEB-INF/" + logFile)).toString();
        }
        File templateFile =
            new File(wrFile.toURI().resolve("WEB-INF/myna/install/linux/init_script"));
        String initScript =
            FileUtils.readFileToString(templateFile)
                .replaceAll("\\{webctx\\}", webctx)
                .replaceAll("\\{server\\}", serverName)
                .replaceAll("\\{user\\}", user)
                .replaceAll("\\{webroot\\}", webroot)
                .replaceAll("\\{javahome\\}", javaHome)
                .replaceAll("\\{logfile\\}", logFile)
                .replaceAll("\\{port\\}", new Integer(port).toString())
                .replaceAll("\\{sslPort\\}", new Integer(sslPort).toString())
                .replaceAll("\\{keystore\\}", keystore)
                .replaceAll("\\{ksPass\\}", ksPass)
                .replaceAll("\\{ksAlias\\}", ksAlias);

        File scriptFile = new File(wrFile.toURI().resolve("WEB-INF/myna/install/" + serverName));

        FileUtils.writeStringToFile(scriptFile, initScript);

        if (new File("/etc/init.d").exists()) {

          exec("chown  -R " + user + " " + webroot);
          exec("chown root " + scriptFile.toString());
          exec("chmod 700 " + scriptFile.toString());
          exec("cp " + scriptFile.toString() + " /etc/init.d/");

          System.out.println(
              "\nInit script '/etc/init.d/"
                  + serverName
                  + "' created with the following settings:\n");
        } else {
          System.out.println(
              "\nInit script '" + scriptFile + "' created with the following settings:\n");
        }

        System.out.println("user="******"memory=256MB");
        System.out.println("server=" + serverName);
        System.out.println("context=" + webctx);
        System.out.println("port=" + port);
        System.out.println("myna_home=" + webroot);
        System.out.println("logfile=" + logFile);

        System.out.println("sslPort=" + sslPort);
        System.out.println("keyStore=" + keystore);
        System.out.println("ksPass="******"ksAlias=" + ksAlias);

        System.out.println("\nEdit this file to customize startup behavior");
      }
    }
  }
Ejemplo n.º 23
0
  // Information needed to get a single file:
  // BASE_PATH, FILE_ID, TIMESTAMP_START, TIMESTAMP_STOP, SOURCE, FILESYSTEM
  private static Vector<Path> getFile(
      FileSystem fs, Hashtable<String, String> config, dbutil db_util) throws Exception {
    Long latestVersion = latestVersion(config, db_util);

    try {
      config.put("timestamp_start", config.get("timestamp_start"));
      config.put("timestamp_real", latestVersion.toString());
      config.put("timestamp_stop", latestVersion.toString());
    } catch (Exception E) {
      logger.error("Tryign to get file that is impossible to generate: " + getFullPath(config));
      return null;
    }
    if (Integer.parseInt(config.get("timestamp_start"))
        > Integer.parseInt(config.get("timestamp_stop"))) {
      return null;
    }
    logger.debug(
        "Getting DB for timestamp "
            + config.get("timestamp_start")
            + " to "
            + config.get("timestamp_stop"));

    String final_result = getFullPath(config);

    String temp_path_base =
        config.get("local_temp_path")
            + "_"
            + config.get("task_id")
            + "_"
            + config.get("run_id")
            + "/";
    Path newPath = new Path(final_result + "*");
    Vector<Path> ret_path = new Vector<Path>();
    String lockName = lock(final_result.replaceAll("/", "_"));
    if (fs.globStatus(newPath).length != 0) {
      ret_path.add(newPath);
      unlock(lockName);
      config.put("full_file_name", final_result);
      return ret_path;
    } else {
      if (!config.get("source").equals("local")) {
        config.put("temp_path_base", temp_path_base);

        config.put("timestamp_start", config.get("timestamp_start"));
        config.put("timestamp_real", latestVersion.toString());
        config.put("timestamp_stop", latestVersion.toString());

        Class<?> sourceClass =
            Class.forName("org.gestore.plugin.source." + config.get("source") + "Source");
        Method process_data = sourceClass.getMethod("process", Hashtable.class, FileSystem.class);
        Object processor = sourceClass.newInstance();
        Object retVal;
        try {
          retVal = process_data.invoke(processor, config, fs);
        } catch (InvocationTargetException E) {
          Throwable exception = E.getTargetException();
          logger.error("Unable to call method in child class: " + exception.toString());
          exception.printStackTrace(System.out);
          unlock(lockName);
          return null;
        }
        FileStatus[] files = (FileStatus[]) retVal;
        if (files == null) {
          logger.error("Error getting files, no files returned");
          return null;
        }

        for (FileStatus file : files) {
          Path cur_file = file.getPath();
          Path cur_local_path = new Path(temp_path_base + config.get("file_id"));
          String suffix = getSuffix(config.get("file_id"), cur_file.getName());
          cur_local_path = cur_local_path.suffix(suffix);
          Path res_path = new Path(new String(final_result + suffix));
          logger.debug("Moving file" + cur_file.toString() + " to " + res_path.toString());
          if (config.get("copy").equals("true")) {
            fs.moveFromLocalFile(cur_file, res_path);
          } else {
            fs.rename(cur_file, res_path);
          }
        }

        config.put("full_file_name", final_result);
      }
    }
    unlock(lockName);
    return ret_path;
  }
Ejemplo n.º 24
0
 public void addChild(Keyword keyword) {
   if (!children.contains(keyword)) children.add(keyword);
 }
Ejemplo n.º 25
0
  /** used by preParse */
  private static String preParseOnce(String s, FormulaManager fm) {
    // convert to lower case
    String l = s.toLowerCase();

    // scan entire string
    int len = l.length();
    boolean letter = false;
    String ns = "";
    for (int i = 0; i < len; i++) {
      if (!letter && i < len - 1 && l.substring(i, i + 2).equals("d(")) {
        // convert d(x)/d(y) notation to standard derive(x, y) notation
        i += 2;
        int s1 = i;
        for (int paren = 1; paren > 0; i++) {
          // check for correct syntax
          if (i >= len) return s;
          char c = l.charAt(i);
          if (c == '(') paren++;
          if (c == ')') paren--;
        }
        int e1 = i - 1;
        // check for correct syntax
        if (i > len - 3 || !l.substring(i, i + 3).equals("/d(")) return s;
        i += 3;
        int s2 = i;
        for (int paren = 1; paren > 0; i++) {
          // check for correct syntax
          if (i >= len) return s;
          char c = l.charAt(i);
          if (c == '(') paren++;
          if (c == ')') paren--;
        }
        int e2 = i - 1;
        ns = ns + "derive(" + s.substring(s1, e1) + "," + s.substring(s2, e2) + ")";
        i--;
      } else if (!letter && i < len - 4 && l.substring(i, i + 5).equals("link(")) {
        // evaluate link(code) notation and replace with link variable
        i += 5;
        int s1 = i;
        try {
          while (l.charAt(i) != '(') i++;
        } catch (ArrayIndexOutOfBoundsException exc) {
          // incorrect syntax
          return s;
        }
        i++;
        int e1 = i - 1;
        int s2 = i;
        for (int paren = 2; paren > 1; i++) {
          // check for correct syntax
          if (i >= len) return s;
          char c = l.charAt(i);
          if (c == '(') paren++;
          if (c == ')') paren--;
        }
        int e2 = i - 1;
        // check for correct syntax
        if (i >= len || l.charAt(i) != ')') return s;
        String prestr = s.substring(s1, e1) + "(";
        String str = prestr;

        // parse method's arguments; determine if they are Data or RealType
        String sub = s.substring(s2, e2);
        StringTokenizer st = new StringTokenizer(sub, ",", false);
        boolean first = true;
        Vector v = new Vector();
        while (st.hasMoreTokens()) {
          String token = st.nextToken();
          if (first) first = false;
          else str = str + ",";
          RealType rt = RealType.getRealTypeByName(token);
          String sv = (rt == null ? "visad.Data" : "visad.RealType");
          v.add(sv);
          str = str + sv;
        }
        str = str + ")";

        // obtain Method object
        Method[] meths = FormulaUtil.stringsToMethods(new String[] {str});

        if (meths[0] == null) {
          // attempt to identify any matching methods by compressing
          // some or all of the arguments into array form
          int vlen = v.size();
          Vector vstrs = new Vector();
          for (int iv = 0; iv < vlen; iv++) {
            String si = (String) v.elementAt(iv);
            int lv = iv;
            String sl;
            while (lv < vlen) {
              sl = (String) v.elementAt(lv++);
              if (!sl.equals(si)) {
                break;
              }
              str = prestr;
              first = true;
              for (int j = 0; j < vlen; j++) {
                if (first) first = false;
                else str = str + ",";
                String sj = (String) v.elementAt(j);
                str = str + sj;
                if (iv == j) {
                  str = str + "[]";
                  j = lv - 1;
                }
              }
              str = str + ")";
              vstrs.add(str);
            }
          }
          String[] strlist = new String[vstrs.size()];
          vstrs.toArray(strlist);
          meths = FormulaUtil.stringsToMethods(strlist);
          int found = -1;
          for (int j = 0; j < meths.length && found < 0; j++) {
            if (meths[j] != null) found = j;
          }
          if (found >= 0) meths[0] = meths[found];
          else {
            // could not find a matching method
            return s;
          }
        }

        // store method object in a link variable
        String link = "link" + (++linkNum);
        try {
          fm.setThing(link, new VMethod(meths[0]));
        }
        // catch any errors setting the link variable
        catch (FormulaException exc) {
          return s;
        } catch (VisADException exc) {
          return s;
        } catch (RemoteException exc) {
          return s;
        }
        ns = ns + "linkx(" + link + "," + s.substring(s2, e2) + ")";
      } else if (!letter) {
        int j = i;
        char c = l.charAt(j++);
        while (j < len && ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))) {
          c = l.charAt(j++);
        }
        // check for end-of-string
        if (j == len) return ns + s.substring(i, len);
        if (c == '[') {
          // convert x[y] notation to standard getSample(x, y) notation
          int k = j;
          for (int paren = 1; paren > 0; k++) {
            // check for correct syntax
            if (k >= len) return s;
            c = l.charAt(k);
            if (c == '[') paren++;
            if (c == ']') paren--;
          }
          ns = ns + "getSample(" + s.substring(i, j - 1) + "," + s.substring(j, k - 1) + ")";
          i = k - 1;
        } else ns = ns + s.charAt(i);
      } else {
        // append character to new string
        ns = ns + s.charAt(i);
      }
      char c = (i < len) ? l.charAt(i) : '\0';
      letter = (c >= 'a' && c <= 'z');
    }
    return ns;
  }
Ejemplo n.º 26
0
 public void add(PluggableEditor ed, int index) {
   // add(ed.getName(), ed.getDisplayComponent()); // wierd array bounds error thrown here?
   insertTab(ed.getName(), ed.getIcon(), ed.getDisplayComponent(), ed.getToolTip(), index);
   activeEditors.add(index, ed);
 }
Ejemplo n.º 27
0
 /**
  * ********************************************************************* * Modifiers to the
  * CMIObjective Data. SCOs should not invoke these * methods. SCOs should call LMSSetValue()
  * **********************************************************************
  */
 public void setObjectives(CMIObjectiveData objective, int index) {
   objectives.add(index, objective);
 } // end of setObjectives
Ejemplo n.º 28
0
  /**
   * ************************************************************************ * * Method: performSet
   * * Input: CMIRequest theRequest - tokenized LMSSetValue() request * DMErrorManager dmErroMgr -
   * Error Manager * Output: none * * Description: This method takes the necessary steps to process
   * * an LMSSetValue() request *
   * *************************************************************************
   */
  public void performSet(CMIRequest theRequest, DMErrorManager dmErrorMgr) {
    if (true) {
      System.out.println("CMIObjectives::performSet()");
    }

    // The next token must be an array.  If not throw
    // an exception for this request.
    int index = -1;

    // Get the next token off of the request
    String token = theRequest.getNextToken();

    if (true) {
      System.out.println("Token being processed: " + token);
    }

    // Check to see if next token is an array index.  For
    // a LMSSetValue() this is true
    try {
      // Try to convert the token to the index
      Integer tmpInt = new Integer(token);
      index = tmpInt.intValue();

      // Get the Objective Data at position of the index
      CMIObjectiveData tmpObj = (CMIObjectiveData) objectives.elementAt(index);

      // An objective existed at the given index.
      // Invoke the performSet() on the Objective Data
      tmpObj.performSet(theRequest, dmErrorMgr);

      // replace the old ObjectiveData with the newly set Objective
      // Data.
      objectives.set(index, tmpObj);
    } catch (NumberFormatException nfe) {
      if (theRequest.isAKeywordRequest() == true) {
        dmErrorMgr.recKeyWordError(token);
      } else {
        if (true) {
          // Invalid parameter passed to LMSSetValue()
          System.out.println("Error - Data Model Element not implemented");
          System.out.println(
              "Invalid data model element: "
                  + theRequest.getRequest()
                  + " passed to LMSSetValue()");
        }

        // Notify error manager
        dmErrorMgr.recNotImplementedError(theRequest);
      }
    } catch (ArrayIndexOutOfBoundsException e) {
      if (true) {
        System.out.println("First time setting the Objective Data");
      }

      if (index <= objectives.size()) {
        // A new Objective Data.
        CMIObjectiveData objData = new CMIObjectiveData();

        // Invoke performSet() on the new Objective Data
        objData.performSet(theRequest, dmErrorMgr);

        // Place the Objective data into the vector at the
        // index position
        objectives.add(index, objData);
      } else {
        dmErrorMgr.SetCurrentErrorCode("201");
      }
    }

    // Done processing.  Let CMIRequest object know the processing
    // of the LMSGetValue() is done.
    theRequest.done();

    return;
  } // end of performSet