protected void writeAuditTrail(String strPath, String strUser, StringBuffer sbValues) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;
      ArrayList aListData = WUtil.strToAList(sbValues.toString(), false, "\n");
      StringBuffer sbData = sbValues;
      String strPnl = (this instanceof DisplayTemplate) ? "Data Template " : "Data Dir ";
      if (reader == null) {
        Messages.postDebug("Error opening file " + strPath);
        return;
      }

      try {
        while ((strLine = reader.readLine()) != null) {
          // if the line in the file is not in the arraylist,
          // then that line has been deleted
          if (!aListData.contains(strLine))
            WUserUtil.writeAuditTrail(new Date(), strUser, "Deleted " + strPnl + strLine);

          // remove the lines that are also in the file or those which
          // have been deleted.
          aListData.remove(strLine);
        }

        // Traverse through the remaining new lines in the arraylist,
        // and write it to the audit trail
        for (int i = 0; i < aListData.size(); i++) {
          strLine = (String) aListData.get(i);
          WUserUtil.writeAuditTrail(new Date(), strUser, "Added " + strPnl + strLine);
        }
        reader.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    /** Displays the labels and the values for the panel. */
    protected void displayPnlFields(HashMap hmPnl) {
      if (hmPnl == null || hmPnl.isEmpty()) return;

      Iterator keySetItr = hmPnl.keySet().iterator();
      String strLabel = "";
      String strValue = "";

      // if the file is empty, then create an empty set of textfields.
      if (hmPnl == null || hmPnl.isEmpty()) {
        displayNewTxf("", "");
        return;
      }

      Container container = getParent();
      if (container != null) container.setVisible(false);
      try {
        // Get each set of label and value, and display them.
        while (keySetItr.hasNext()) {
          strLabel = (String) keySetItr.next();
          strValue = (String) hmPnl.get(strLabel);

          displayNewTxf(strLabel, strValue);
        }

        if (container != null) container.setVisible(true);
        revalidate();
        repaint();
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
示例#3
0
  /** Write file with position and size of the login box */
  public static void writePersistence() {

    Messages.postDebug("LoginBox", "LoginBox.writePersistence");
    // If the panel has not been created, don't try to write a file
    if (position == null) return;

    String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel");

    FileWriter fw;
    PrintWriter os;
    try {
      File file = new File(filepath);
      fw = new FileWriter(file);
      os = new PrintWriter(fw);
      os.println("Login Panel");

      os.println(height);
      os.println(width);
      double xd = position.getX();
      int xi = (int) xd;
      os.println(xi);
      double yd = position.getY();
      int yi = (int) yd;
      os.println(yi);

      os.close();
    } catch (Exception er) {
      Messages.postError("Problem creating  " + filepath);
      Messages.writeStackTrace(er);
    }
  }
示例#4
0
  protected String getSampleName(String strDir, String strTray) {
    String strSampleName = "";
    String strSample;
    int nTray = 0;
    try {
      nTray = Integer.parseInt(strTray);
    } catch (Exception e) {
    }

    if (nTray <= 0) return strSampleName;

    String cmd =
        "SELECT loc_,studystatus from study WHERE (autodir=\'"
            + strDir
            + "\') AND (hostname=\'"
            + getHost()
            + "\')";
    // NB: bArrSample[0] is not used; array implicitly initialized false
    boolean[] bArrSample = new boolean[nTray + 1];
    m_dbResult = null;

    try {
      m_dbResult = getdbmanager().executeQuery(cmd);
    } catch (Exception e) {
      return strSampleName;
    }
    if (m_dbResult == null) return strSampleName;

    try {
      while (m_dbResult.next()) {
        strSample = m_dbResult.getString(1);
        int nSample = 0;
        nSample = Integer.parseInt(strSample);
        try {
          bArrSample[nSample] = true;
        } catch (IndexOutOfBoundsException ioobe) {
          Messages.postDebug("getSampleName: index out of bounds: " + nSample);
        }
      }
      for (int i = 1; i < bArrSample.length; i++) {
        if (!bArrSample[i]) {
          strSampleName = String.valueOf(i);
          break;
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
    return strSampleName;
  }
    /** Reads the file, and sets the label and the values in the hashmap. */
    protected void setHM(String strPath, HashMap hmPnl) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      boolean bFileEmpty = true;
      boolean bPart11Pnl = isPart11Pnl();
      boolean bDefaultFile = isDefaultFile();

      // if the file is empty, then create an empty set of textfields.
      if (reader == null) {
        // displayNewTxf("","");
        return;
      }

      String strLine = null;
      StringTokenizer strTok;

      try {
        // read the file, and create a new set of textfields,
        // with the values from the file.
        while ((strLine = reader.readLine()) != null) {
          String strLabel = "";
          String strValue = "";
          bFileEmpty = false;

          if (strLine.startsWith("#")
              || strLine.startsWith("@")
              || strLine.startsWith("%")
              || strLine.startsWith("\"@")) continue;

          if (strLine.startsWith("\"")) strTok = new StringTokenizer(strLine, "\"");
          else strTok = new StringTokenizer(strLine, File.pathSeparator + ",\n");

          if (!strTok.hasMoreTokens()) continue;

          strLabel = strTok.nextToken();

          // the format for the part11 Default file is a little different
          // only parse out the part11Dir, and don't display other defaults
          if (bPart11Pnl && bDefaultFile) {
            if (!strLabel.equalsIgnoreCase("part11Dir")) continue;
          }

          if (strTok.hasMoreTokens()) {
            while (strTok.hasMoreTokens()) {
              strValue += strTok.nextToken();
              if (strTok.hasMoreTokens()) strValue += " ";
            }
          }

          // append "/data/$name" to part11Dir
          if (bPart11Pnl && bDefaultFile && strLabel.equalsIgnoreCase("part11Dir")) {
            StringBuffer sbDir = new StringBuffer(strValue);
            if (sbDir.lastIndexOf(File.separator) < sbDir.length() - 1)
              sbDir.append(File.separator);
            sbDir.append("data" + File.separator + "$");
            sbDir.append(WGlobal.NAME);
            strValue = sbDir.toString();
          }

          // displayNewTxf(strLabel, strValue);
          if (strLabel != null && strLabel.trim().length() > 0) hmPnl.put(strLabel, strValue);
        }
        reader.close();
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
示例#6
0
  protected void enterLogin() {
    char[] password = m_passwordField.getPassword();
    String strUser = (String) m_cmbUser.getSelectedItem();
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    boolean blogin = WUserUtil.isOperatorNameok(strUser, false);
    if (blogin) {
      blogin = vnmrjPassword(strUser, password);
      if (!blogin) blogin = unixPassword(strUser, password);
    }
    if (blogin) {
      m_lblLogin.setForeground(Color.black);
      m_lblLogin.setText("Login Successful");
      m_lblLogin.setVisible(true);
      // Get the Email column string for access to the operator data
      String emStr = vnmr.util.Util.getLabel("_admin_Email");
      String stremail = WUserUtil.getOperatordata(strUser, emStr);

      // Get the Panel Level column string for access to the operator data
      String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level");
      String strPanel = WUserUtil.getOperatordata(strUser, plStr);

      if (stremail == null || stremail.equals("null")) stremail = "";
      try {
        Integer.parseInt(strPanel);
      } catch (Exception e) {
        strPanel = WGlobal.PANELLEVEL;
      }
      m_trayTimer.stop();
      Messages.postDebug(" Login: "******"appdir('reset','")
                .append(strUser)
                .append("','")
                .append(stremail)
                .append("',")
                .append(strPanel)
                .append(")")
                .toString());
        exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n");
      }
      setVisible(false);

      // Save the current position and size of this panel in case it
      // was changed
      Dimension size = getSize();
      width = size.width;
      height = size.height;
      position = getLocation();
      writePersistence();

      // Call the macro to update this operator's
      // ExperimentSelector_operatorName.xml file
      // from the protocols themselves.  This macro will
      // cause an update of the ES when it is finished

      // Util.getAppIF().sendToVnmr("updateExpSelector");

      // I am not sure why we need to force updates since updateExpSelector
      // should have caused an update by writing to ES_op.xml file.
      // However, it works better if we do the force update.
      // ExpSelector.setForceUpdate(true);
    } else {
      m_lblLogin.setForeground(DisplayOptions.getColor("Error"));
      // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>");
      m_lblLogin.setVisible(true);
    }
    setCursor(Cursor.getDefaultCursor());
  }