Link to home
Start Free TrialLog in
Avatar of AlbertObille
AlbertObille

asked on

Agent hang up in Lotus 6 Client

Hi!

I still have problems on my Java Agent running on Lotus Notes 6. It was called in our database and access another database to verify if the item in our database is already fix on ther database. The database is on server and the agent was run through onEvent. I tried to check the settings for Java Agent but still it doesnt work.

You can use this link:
http://oldlook.experts-exchange.com/questions/20758986/Problem-In-Lotus-Notes-6.html#9506399

Thank you for your time. I really need the fixes for this problem or else my boss will kick me out of the office.


Hope for your response soon. Thanks!

Avatar of Bozzie4
Bozzie4
Flag of Belgium image

Can you give source code, or more information ?

cheers,

Tom
Avatar of qwaletee
qwaletee

What do you mean by "onEvents?"  Please be specific as to how the agent is executed.  I can't tell from this whether the agent runs client side, or server side, and if client side, via user action or in the background, and if background (client or server) what evcent or schedule kicks it off.

R6, by the way, offers server-side debugging.  I know it works for LotusScript agents, I do npot know if it works for Java.
http://www-10.lotus.com/ldd/today.nsf/9148b29c86ffdcd385256658007aaa0f/ef1565a0b202808285256c94004fd0fb?OpenDocument

...
My unrestricted agent does not run (Notes/Domino 6 only)
You may have an agent that was signed by an unrestricted signer and that runs fine in R5, but after editing it with Domino Designer 6, the agent stops running. In this case, check the security tab of the Agent Properties box to see the runtime security setting:

Agent Properties security tab

An agent that has not been edited with Domino Designer 6 runs on a Domino 6 server with the rights of the signer just as it would in R5. So in the case of an unrestricted signer, the agent runs with unrestricted rights. But if the agent is edited by Domino Designer 6, the default setting is “Do not allow restricted operations” (the safer setting). If you want to perform unrestricted operations in the agent after you have edited it with Domino Designer 6, you need to explicitly set this security setting.
...

cheers,

Tom
Avatar of AlbertObille

ASKER

Here are the codes of my Java Agent.

I tried already the security settings of the Java Agent Itself but it still doesnt work.
Kindly please review my codes. thanks.


The agent runs only once the command was executed.
SaveClientAction.java

import java.io.*;
import java.text.*;
import java.util.*;

public class SaveClientAction extends PrintStream {
    static OutputStream logfile;
    static PrintStream oldStdout;
    static PrintStream oldStderr;

    /**
     *
     * Constructor for instantiating the super class.
     *
     * @param ps      java.io.PrintStream object.
     *
     */
     
    SaveClientAction(PrintStream ps) {
    super(ps);
    }

    /**
     *
     * Method to start copying stdout and stderr to the log file.
     *
     */

    public static synchronized void start(ProcessMessage pm) throws IOException {
      // Save old settings.
     pm.appendText("inside start save");
      oldStdout = System.out;
      oldStderr = System.err;
   
      // Create/Open logfile.
      pm.appendText("before new PrintStream");
      logfile = new PrintStream(
              new BufferedOutputStream(
              new FileOutputStream("cmvcAction.log", true)));
                    pm.appendText("\nafter new PrintStream");

      // Start redirecting the output.
            pm.appendText("before new save client action system out");
      //System.setOut(new SaveClientAction(System.out, pm));
           pm.appendText("before new save client action system err");
      //System.setErr(new SaveClientAction(System.err, pm));
    }


    /**
     *
     * Method to stop writing to log file and restore the original settings.
     *
     */

    public static synchronized void stop(ProcessMessage pm) {
    pm.appendText("\nSTART CLIENT SOTP");
    System.setOut(oldStdout);                   // after the message above, it hangs up here.
    System.setErr(oldStderr);
        try {
            logfile.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        pm.appendText("\nFINISH CLIENT SOTP");
    }

    /**
     *
     * Overrides the write method of super class.
     *
     * @param b            character to write.
     *
     */

    public void write(int b) {
        try {
          logfile.write(b);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(b);
    }

    /**
     *
     * Overrides the write method of super class.
     *
     * @param buf[]      array of bytes to write.
     * @param off      offset.
     * @param len      length.
     *
     */

    public void write(byte buf[], int off, int len) {
        try {
          logfile.write(buf, off, len);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(buf, off, len);
    }
}

SaveClientError.java

import java.io.*;
import java.text.*;
import java.util.*;

public class SaveClientError extends PrintStream {
    static OutputStream logfile;
    static PrintStream oldStdout;
    static PrintStream oldStderr;


    /**
     *
     * Constructor for instantiating the super class.
     *
     * @param ps      java.io.PrintStream object.
     *
     */
     
    SaveClientError(PrintStream ps) {
      super(ps);
    }


    /**
     *
     * Method to start copying stdout and stderr to the log file.
     *
     */

    public static void start() throws IOException {
      // Save old settings.
      oldStdout = System.out;
      oldStderr = System.err;
   
      // Create/Open logfile.
      logfile = new PrintStream(
              new BufferedOutputStream(
              new FileOutputStream("cmvcError.log", true)));

      // Start redirecting the output.
      System.setOut(new SaveClientError(System.out));
      System.setErr(new SaveClientError(System.err));
    }

    /**
     *
     * Method to stop writing to log file and restore the original settings.
     *
     */

    public static void stop() {
    //      pm.appendText("\nstarting saveclient error stop");
      System.setOut(oldStdout);
      System.setErr(oldStderr);
        try {
          logfile.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
//pm.appendText("\nFINISHES STOP");
    }


    /**
     *
     * Overrides the write method of super class.
     *
     * @param b            character to write.
     *
     */

    public void write(int b) {
        try {
          logfile.write(b);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(b);
    }


    /**
     *
     * Overrides the write method of super class.
     *
     * @param buf[]      array of bytes to write.
     * @param off      offset.
     * @param len      length.
     *
     */

    public void write(byte buf[], int off, int len) {
        try {
          logfile.write(buf, off, len);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(buf, off, len);
    }
}

UserPasswordProfile.java


public class UserPasswordProfile {
      public UserPasswordProfile() {

      }
      
}
I don't see a NotesMain anywhere in your code.  That's the entry point the agent manager's JVM uses.
Hello guys!

here is the complete source code of my agent. Please gave me feedback for this. In R5, I encountered warnings about the deprecated classes but in R6, it doesnt have warnings. It just hangs up. Please help me..... Thank you in advance


CMVCAgent.java

import java.io.IOException;
import java.util.Date;

import lotus.domino.*;

public class CMVCAgent extends AgentBase {                              
      public void NotesMain() {

            try {
                  Session session = getSession();
                  
                  String action = session.getEnvironmentString("action", false);
                  String cmvcNo = session.getEnvironmentString("cmvcNo", false);
                  String family = session.getEnvironmentString("family", false);
                  String unid = session.getEnvironmentString("unid", false);
                  String authMethod = session.getEnvironmentString("PA_CMVC_AUTH_METHOD", false);
                  
                  AgentContext agentContext = session.getAgentContext();
                  Database db = agentContext.getCurrentDatabase();
                  String serverName = db.getServer();
                  System.out.println(serverName);
                  Document doc = db.getProfileDocument("FileName Profile", null);
                  String projectDb = doc.getItemValueString("profiletxtTMSFile");
                  String cmvcDb = doc.getItemValueString("profiletxtPRFile");
                                    
                  Name user = session.getUserNameObject();
                  doc = db.getProfileDocument("CMVCUserInformation", user.getAbbreviated());
                  String userName = doc.getItemValueString("DB2UserName");
                  String passwd = doc.getItemValueString("DB2Password");
                  boolean isToProcess = false;
                  boolean isToSave = false;
                  
                  if (authMethod.equals("pw")) {                  
                        if (userName == null || userName.equals("")) {
                              PasswordFrame pwFrame = new PasswordFrame();
                              userName = pwFrame.getUserName();
                              passwd = pwFrame.getPassword();
                              System.out.println(userName + " " + passwd);
                              isToProcess = pwFrame.isToProcess();
                              isToSave = pwFrame.isToSave();
                        } else if (passwd == null || passwd.equals("")) {
                              PasswordFrame pwFrame = new PasswordFrame(userName);
                              userName = pwFrame.getUserName();
                              passwd = pwFrame.getPassword();
                              System.out.println(userName + " " + passwd);
                              isToProcess = pwFrame.isToProcess();
                              isToSave = pwFrame.isToSave();
                        } else {
                              isToProcess = true;
                        }
                  } else {
                        isToProcess = true;
                  }
                  
                  if (isToProcess == true) {
                        if (action.equals("open") || action.equals("view")) {
                              new MainProcess(userName, passwd, action, cmvcNo, family, null, null, authMethod, serverName, cmvcDb, projectDb, session);
                        } else if (action.equals("note") || action.equals("cancel") || action.equals("reopen")) {
                              new RemarksFrame(userName, passwd, action, cmvcNo, family, authMethod, serverName, cmvcDb, projectDb);
                        } else if (action.equals("verify")) {
                              new VerifyFrame(userName, passwd, action, cmvcNo, family, unid, authMethod,  serverName, cmvcDb, projectDb);
                        }
                  }
                  
                  if (isToSave == true) {
                        if (doc != null) {
                              Item userItem = doc.replaceItemValue("DB2UserName", userName);
                              userItem.setEncrypted(true);
                              Item passItem = doc.replaceItemValue("DB2Password", passwd);
                              passItem.setEncrypted(true);
                              doc.encrypt();
                              doc.save(true);
                        }
                  }
            } catch (NotesException nx) {

                  try {
                     SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("NotesMain Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } catch (Exception e) {
                  e.printStackTrace();
            }
      }
}


CommandProcessor.java      

import java.io.IOException;
import java.util.Date;
import java.util.Vector;

public class CommandProcessor {
    private Vector cmvcData = new Vector();
    private Vector cmvcErrData = new Vector();
    private boolean isError;

    /**
     *
     * Constructor for executing the CMVC Commands and storing the unparsed data.
     *
     * @param dosCommand      Command to be used by a process.
     * @param remarks            String passed to the {@link ibmpa.cmvc.streams.OutputStreamThread} Class.
     *
     */

      public CommandProcessor(String dosCommand, String remarks) {
            try {
                  Runtime runtime = Runtime.getRuntime();
                  Process cmvcProcess = runtime.exec(dosCommand);
                  new ErrorStreamThread(cmvcProcess.getErrorStream(), cmvcErrData).start();
                  new InputStreamThread(cmvcProcess.getInputStream(), cmvcData).start();
                  new OutputStreamThread(cmvcProcess.getOutputStream(), remarks).start();
                  cmvcProcess.waitFor();

                  synchronized (cmvcData) {
                     if (cmvcData.size() == 0)
                          isError = true;
                        }
                  } catch (Exception ex) {
                            try {
                           SaveClientError.start();
                           System.out.println(new Date());
                           System.out.println("CommandProcessor Exception: " + ex);
                           SaveClientError.stop();
                      } catch (IOException iox) {
                           System.out.println(iox);
                        }
                 }
               }

    /**
     *
     * Method for determining if error occurred.
     *
     * @return boolean - if true then error, if false then data is valid.
     *
     */

    public boolean isError() {
        return isError;
    }


    /**
     *
     * Method for getting CMVC DB2 Data.
     *
     * @return java.util.List object - unparsed data.
     *
     */

    public Vector getCmvcData() {
        synchronized (cmvcData) {
            return cmvcData;
        }
    }


    /**
     *
     * Method for getting the CMVC DB2 Error Data.
     *
     * @return java.util.List object - error data.
     *
     */

    public Vector getCmvcErrData() {
        synchronized (cmvcErrData) {
            return cmvcErrData;
        }
    }
}

DataProcessor.java

import java.util.Vector;

public class DataProcessor {
    private String cmvcNo;
    private String state;
    private String abstrak;
    private String family;
    private String release;
    private String phaseFound;
    private String severity;
    private String prefix;
    private String symptom;
    private String component;
    private String brand;
    private String targetDate;
    private String targetState;
    private String envName;

    private String lastUpdate;

    private String problemRemarks;    
    private String remarksHistory;

    private String openDate;
    private String workingDate;
    private String returnDate;
    private String cancelDate;
    private String verifyDate;
    private String closeDate;

    private String openedBy;
     private String workedBy;
    private String returnedBy;
    private String canceledBy;
    private String verifiedBy;
    private String closedBy;

    private String ownerLogin;
    private String ownerName;
    private String originName;
    private String originArea;

    // addendum
    private String reference;
    private String duplicate;
    private String age;
    private String answer;
    private String level;
    private String assignDate;
    private String responseDate;
    private String endDate;
    private String ownerArea;
    private String remoteName;
    private String remoteFamily;
    private String phaseInject;
    private String priority;
    private String target;
    private String source;

      // @PC
    private String originLogin;      

    /**
     *
     * Constructor for initializing CMVC number and family.
     *
     * @param cmvcNo      CMVC number.
     * @param family      CMVC family.
     *
     */

    public DataProcessor(String cmvcNo, String family) {
        this.cmvcNo = cmvcNo;
        this.family = family;
    }


    /**
     *
     * Method for setting the fields in a Notes CMVC document.
     *
     * @param doc      Stub object wrapping a Notes Document object.
     *
     */

    public void setDoc(NotesCMVCDocument doc) {
        doc.setName(cmvcNo);
        doc.setFamily(family);
        doc.setPrefix(prefix);
        doc.setAbstract(abstrak);
        doc.setSeverity(severity);
        doc.setState(state);
        doc.setTargetDate(targetDate);
        doc.setTargetState(targetState);
        doc.setComponent(component);
        doc.setRelease(release);
        doc.setSymptom(symptom);
        doc.setPhaseFound(phaseFound);
        doc.setBrand(brand);
        doc.setEnvName(envName);
        doc.setRemarksHistory(remarksHistory);
        doc.setLastUpdate(lastUpdate);
        doc.setOpenDate(openDate);
        doc.setWorkingDate(workingDate);
        doc.setReturnDate(returnDate);
        doc.setCancelDate(cancelDate);
        doc.setVerifyDate(verifyDate);
        doc.setCloseDate(closeDate);
        doc.setOpenedBy(openedBy);
        doc.setWorkedBy(workedBy);
        doc.setReturnedBy(returnedBy);
        doc.setCanceledBy(canceledBy);
        doc.setVerifiedBy(verifiedBy);
        doc.setClosedBy(closedBy);

        doc.setOwnerLogin(ownerLogin);
        doc.setOwnerName(ownerName);
        doc.setOriginName(originName);
        doc.setOriginArea(originArea);

        doc.setReference(reference);
        doc.setDuplicate(duplicate);
        doc.setAge(age);
        doc.setAnswer(answer);
        doc.setLevel(level);
        doc.setAssignDate(assignDate);
        doc.setResponseDate(responseDate);
        doc.setEndDate(endDate);
        doc.setOwnerArea(ownerArea);
        doc.setRemoteName(remoteName);
        doc.setRemoteFamily(remoteFamily);
        doc.setPhaseInject(phaseInject);
        doc.setPriority(priority);
        doc.setTarget(target);
        doc.setSource(source);

           // @PC
        doc.setOriginLogin(originLogin);           
    }


    /**
     *
     * Method for loading the date fields in a Notes CMVC Document.
     *
     * @param doc      Stub object wrapping a Notes Document object.
     *
     */

    public void loadDates(NotesCMVCDocument doc) {
        doc.setName(cmvcNo);
        doc.setFamily(family);
        doc.loadDates();
        openDate = (doc.getOpenDate() == null) ? "" : doc.getOpenDate();
        workingDate = (doc.getWorkingDate() == null) ? "" : doc.getWorkingDate();
        returnDate = (doc.getReturnDate() == null) ? "" : doc.getReturnDate();
        cancelDate = (doc.getCancelDate() == null) ? "" : doc.getCancelDate();
        verifyDate = (doc.getVerifyDate() == null) ? "" : doc.getVerifyDate();
        closeDate = (doc.getCloseDate() == null) ? "" : doc.getCloseDate();
        openedBy = (doc.getOpenedBy() == null) ? "" : doc.getOpenedBy();
        workedBy = (doc.getWorkedBy() == null) ? "" : doc.getWorkedBy();
        returnedBy = (doc.getReturnedBy() == null) ? "" : doc.getReturnedBy();
        canceledBy = (doc.getCanceledBy() == null) ? "" : doc.getCanceledBy();
        verifiedBy = (doc.getVerifiedBy() == null) ? "" : doc.getVerifiedBy();
        closedBy = (doc.getClosedBy() == null) ? "" : doc.getClosedBy();
    }


    /**
     *
     * Method for parsing the data from a {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     * @param cmvcData      unparsed data from CMVC DB2.
     *
     */

    public void parseRetrievedDoc(Vector cmvcData) {
        String str = (String) cmvcData.elementAt(1);
        str = str.substring(14);
        prefix = str.trim();
        str = (String) cmvcData.elementAt(3);
        str = str.substring(14);
        reference = str.trim();
        str = (String) cmvcData.elementAt(4);
        str = str.substring(14);
        abstrak = str.trim();
        str = (String) cmvcData.elementAt(5);
        str = str.substring(14);
        duplicate = str.trim();
        str = (String) cmvcData.elementAt(7);
        str = str.substring(14);
        state = str.trim();
        str = (String) cmvcData.elementAt(8);
        str = str.substring(14);
        severity = str.trim();
        str = (String) cmvcData.elementAt(9);
        str = str.substring(14);
        age = str.trim();
        str = (String) cmvcData.elementAt(11);
        str = str.substring(14, 40);
        component = str.trim();
        str = (String) cmvcData.elementAt(11);
        str = str.substring(56);
        answer = str.trim();
        str = (String) cmvcData.elementAt(12);
        str = str.substring(14);
        release = str.trim();
        str = (String) cmvcData.elementAt(13);
        str = str.substring(14);
        envName = str.trim();
        str = (String) cmvcData.elementAt(14);
        str = str.substring(14);
        level = str.trim();
        str = (String) cmvcData.elementAt(16);
        str = str.substring(56);
        assignDate = str.trim();
        str = (String) cmvcData.elementAt(17);
        str = str.substring(14, 40);
        lastUpdate = str.trim();
        str = (String) cmvcData.elementAt(17);
        str = str.substring(56);
        responseDate = str.trim();
        str = (String) cmvcData.elementAt(18);
        str = str.substring(14);
        endDate = str.trim();
        str = (String) cmvcData.elementAt(20);
        str = str.substring(14, 40);
        ownerLogin = str.trim();

            // @PC
        str = (String) cmvcData.elementAt(20);
        str = str.substring(56);
        originLogin = str.trim();
     
        str = (String) cmvcData.elementAt(21);
        str = str.substring(14, 40);
        ownerName = str.trim();
        str = (String) cmvcData.elementAt(21);
        str = str.substring(56);
        originName = str.trim();
        str = (String) cmvcData.elementAt(22);
        str = str.substring(14, 40);
        ownerArea = str.trim();
        str = (String) cmvcData.elementAt(22);
        str = str.substring(56);
        originArea = str.trim();
        str = (String) cmvcData.elementAt(24);
        str = str.substring(14, 40);
        remoteName = str.trim();
        str = (String) cmvcData.elementAt(24);
        str = str.substring(56);
        remoteFamily = str.trim();
        str = (String) cmvcData.elementAt(25);
        str = str.substring(14);
        symptom = str.trim();
        str = (String) cmvcData.elementAt(26);
        str = str.substring(14);
        phaseFound = str.trim();
        str = (String) cmvcData.elementAt(27);
        str = str.substring(14);
        phaseInject = str.trim();
        str = (String) cmvcData.elementAt(28);
        str = str.substring(14);
        priority = str.trim();
        str = (String) cmvcData.elementAt(29);
        str = str.substring(14);
        target = str.trim();
        str = (String) cmvcData.elementAt(30);
        str = str.substring(14);
        source = str.trim();            
        str = (String) cmvcData.elementAt(31);
        str = str.substring(14);
        targetDate = str.trim();
        str = (String) cmvcData.elementAt(32);
        str = str.substring(14);
        targetState = str.trim();
        str = (String) cmvcData.elementAt(33);
        str = str.substring(14);
        brand = str.trim();
           

        for (int i = 41; i < cmvcData.size(); i++) {
            str = (String) cmvcData.elementAt(i);;
            if (str.equals(""))
                continue;
            if (str.startsWith("duplicate defects:"))
                break;
            if (str.length() < 40)
                continue;
            String dateStr = str.substring(4, 23);
            String action = str.substring(25, 40).trim();
            String userStr = str.substring(41).trim();
            if (action.equals("open")) {
                if (openDate.equals("")) {
                    openDate = dateStr;
                    openedBy = userStr;
                } else if (openDate.compareTo(dateStr) > 0) {
                    openDate = dateStr;
                    openedBy = userStr;
                }
            } else if (action.equals("accept")) {
                if (workingDate.equals("")) {
                    workingDate = dateStr;
                    workedBy = userStr;
                } else if (workingDate.compareTo(dateStr) > 0) {
                    workingDate = dateStr;
                    workedBy = userStr;
                }
            } else if (action.equals("return")) {
                if (returnDate.compareTo(dateStr) < 0) {
                    returnDate = dateStr;
                    returnedBy = userStr;
                }
            } else if (action.equals("cancel")) {
                if (cancelDate.compareTo(dateStr) < 0) {
                    cancelDate = dateStr;
                    canceledBy = userStr;
                }
            } else if (action.equals("verify")) {
                if (verifyDate.compareTo(dateStr) < 0) {
                    verifyDate = dateStr;
                    verifiedBy = userStr;
                }
            } else if (action.equals("close")) {
                if (closeDate.compareTo(dateStr) < 0) {
                    closeDate = dateStr;
                    closedBy = userStr;
                }
            }
        }

        str = "";
        for (int i = 34; i < cmvcData.size(); i++) {
            str += (String) cmvcData.elementAt(i) + "~";
        }

        byte[] b = str.getBytes();
        int length = (b.length > 32000) ? 32000 : b.length;
        remarksHistory = new String(b, 0, length);
    }


    /**
     *
     * Method for parsing the new CMVC number taken from CMVC DB2 System after opening a CMVC.
     *
     * @param cmvcData      unparsed data from CMVC DB2.
     * @return String object - new CMVC number.
     *
     */

    public String parseNewCMVCNo(Vector cmvcData) {
        String str = (String) cmvcData.elementAt(1);
        str = str.substring(25, str.indexOf('.')).trim();

        return str;
    }


    /**
     *
     * Method for changing the CMVC number after verify-rejecting a CMVC.
     *
     * @param cmvcNo      old CMVC number.
     * @return String object - new CMVC number.
     *
     */

    public String parseNewCMVCNo(String cmvcNo) {
        int startIndex;
        if ((startIndex = cmvcNo.lastIndexOf("f_")) != -1) {
            String str = cmvcNo.substring(startIndex + 2, cmvcNo.length());
            int newNo = Integer.parseInt(str);
            cmvcNo = cmvcNo.substring(0, startIndex + 2) + (newNo + 1);
            this.cmvcNo = cmvcNo;
            return cmvcNo;
        } else {
            cmvcNo = cmvcNo + "f_1";
            this.cmvcNo = cmvcNo;
            return cmvcNo;
        }
    }


    /**
     *
     * Method for transforming a set of CMVC fields into a command String for opening a CMVC record.
     *
     * @param component            Component/Categories field in Notes CMVC document.
     * @param abstrak            Abstract/Subject field in Notes CMVC document.
     * @param release            Release/Product field in Notes CMVC document.
     * @param prefix            Prefix field in Notes CMVC document.
     * @param severity            Severity field in Notes CMVC document.
     * @param symptom            Symptom field in Notes CMVC document.
     * @param phaseFound      Phase field in Notes CMVC document.
     * @param brand            Brand field in Notes CMVC document.
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */

    public String openCMVCString(String component, String abstrak,
                                 String release, String prefix,
                                 String severity, String symptom,
                                 String phaseFound, String brand) {
        String str = "defect -open -family \"" + family +
                               "\" -component \"" + component +
                               "\" -remarks -" +
                                 " -abstract \"" + abstrak +
                               "\" -release \"" + release +
                               "\" -prefix \"" + prefix +
                               "\" -severity \"" + severity +
                               "\" -symptom \"" + symptom +
                               "\" -phasefound \"" + phaseFound +
                               "\" -brand \"" + brand +
                               "\"";
        return str;
    }


    /**
     *
     * Method for returning command String for viewing a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */

    public String viewCMVCString() {
        String str = "defect -long -view " + cmvcNo + " -family " + family;
        return str;
    }


    /**
     *
     * Method for returning command String for canceling a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */
 
    public String cancelCMVCString() {
        String str = "defect -cancel " + cmvcNo + " -family " + family +
                     " -remarks -";
        return str;
    }


    /**
     *
     * Method for returning command String for reopening a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */

    public String reopenCMVCString() {
        String str = "defect -reopen " + cmvcNo + " -family " + family +
                     " -remarks -";
        return str;
    }


    /**
     *
     * Method for returning command String for verify-rejecting a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */
     
    public String verifyOpenCMVCString() {
        String str = "verifycm -reject -defect " + cmvcNo + " -family " + family +
                                     " -remarks -";
        return str;
    }


    /**
     *
     * Method for returning command String for verify-closing a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */

    public String verifyCloseCMVCString() {
        String str = "verifycm -accept -defect " + cmvcNo + " -family " + family +
                                     " -remarks -";
        return str;
    }


    /**
     *
     * Method for returning command String for noting a CMVC record.
     *
     * @return String object - Command String for {@link ibmpa.cmvc.CommandProcessor} Object.
     *
     */

    public String addCMVCRemarksString() {
        String str = "defect -note " + cmvcNo + " -family " + family +
                           " -remarks -";
        return str;
    }


    /**
     *
     * Method for getting the last update of a CMVC record.
     *
     * @return String object - date of last update of CMVC record.
     *
     */

    public String getLastUpdate() {
        return lastUpdate;
    }
}






Entry.java

import java.io.IOException;
import java.util.Date;
import java.util.Vector;
import lotus.domino.*;

public class Entry {
      private String product = "Unspecified";
      private String area = "Unspecified";
      private String serverName;
      private String projectDb;
      
      public Entry(String serverName, String projectDb) {
            this.serverName = serverName;
            this.projectDb = projectDb;
      }
      
    /**
     *
     * Method for searching problem area given product name and component.
     *
     */

      public void searchProduct(String release) {
            try {
                  NotesThread.sinitThread();
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, projectDb);
                  DocumentCollection dc = db.search("Form=\"CMVCProfile\"");      
                  Document doc = dc.getFirstDocument();

                  if (doc != null) {
                        Item item = doc.getFirstItem("releasename");
                        Vector releases = item.getValues();
                        item = doc.getFirstItem("productname");
                        Vector products = item.getValues();

                        int count = 0;
                        for (int i = 0; i < releases.size(); i++) {
                              if (release.equals(releases.elementAt(i))) {
                                    count++;
                                    product = (String) products.elementAt(i);
                              }
                              if (count > 1) {
                                    break;
                              }
                        }

                        if (count != 1) {
                              product = "Unspecified";
                        }
                  }
            } catch (NotesException nx) {  
                  try {
                        SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("Entry Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } finally {
                  NotesThread.stermThread();
            }
      }

     /**
     *
     * Method for searching problem area given product name and component.
     *
     */

   
      public void searchProblemArea(String product, String component) {
            this.product = product;
            try {
                  NotesThread.sinitThread();
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, projectDb);              
                  DocumentCollection dc = db.search("form=\"Components\" & (productname=\"" + product + "\" | productname=\"Common\")");
                  Document doc = dc.getFirstDocument();

                  while (doc != null) {
                        Item item = doc.getFirstItem("componentname");
                        Vector components = item.getValues();
                        item = doc.getFirstItem("area");
                        Vector areas = item.getValues();
   
                        if (components.contains(component) == true) {
                              int idx = components.indexOf(component);
                              area = (String) areas.elementAt(idx);
                              break;
                        }
                        doc = dc.getNextDocument();
                   }
            } catch (NotesException nx) {
                  try {
                        SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("Entry Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } finally {
                  NotesThread.stermThread();
            }
      }

    public String getProduct() {
        return product;
    }

    public String getArea() {
        return area;
    }
}

ErrorStreamThread.java

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Vector;


public class ErrorStreamThread extends Thread {
    private InputStream errStream;
    private Vector cmvcErrData;


    /**
     *
     * Constructor for initializing the error stream and List object.
     *
     * @param errStream            java.io.InputStream object.
     * @param cmvcErrData      java.util.Vector object.
     *
     */

    public ErrorStreamThread(InputStream errStream, Vector cmvcErrData) {
        this.errStream = errStream;
        this.cmvcErrData = cmvcErrData;
    }

    /**
     *
     * Method for starting the thread.
     *
     */

    public void run() {
        try {
            BufferedReader err = new BufferedReader(new InputStreamReader(errStream));        
            String str = null;        
            synchronized (cmvcErrData) {
                while ((str = err.readLine()) != null) {
                    cmvcErrData.addElement(str);
                }
            }
        } catch (java.io.IOException e) {
            System.out.println(e);  
        }
    }
}

InputStreamThread.java

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Vector;

public class InputStreamThread extends Thread {
    private InputStream inStream;
    private Vector cmvcData;


    /**
     *
     * Constructor for initializing the input stream and List object.
     *
     * @param inStream      java.io.InputStream object.
     * @param cmvcData      java.util.Vector object.
     *
     */

    public InputStreamThread(InputStream inStream, Vector cmvcData) {
        this.inStream = inStream;
        this.cmvcData = cmvcData;
    }


    /**
     *
     * Method for starting the thread.
     *
     */

    public void run() {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(inStream));
            String str = null;
            synchronized (cmvcData) {
                while ((str = in.readLine()) != null) {
                    cmvcData.addElement(str);
                }
            }
        } catch (java.io.IOException e) {
            System.out.println(e);
        }
    }
}


MainProcess.java

import java.io.IOException;
import java.util.Date;
import java.util.Vector;
import lotus.domino.*;

public class MainProcess {
      NotesCMVCDocument doc;
      DataProcessor data;
      CommandProcessor comProc;
      ProcessMessage processMessage;
// @PC 02192002 deleted on purpose
//      MessageDialog messageDialog;
      String userName;
      String password;
      String action;
      String cmvcNo;
      String family;
      String remark;
      String unid;
      String authMethod;
      Session SessionTemp;


    /**
     *
     * Constructor for executing the CMVC functions.
     *
     * @param args      Array of String objects for command and fields.
     *
     */

      public MainProcess(String userName, String password, String action, String cmvcNo, String family, String remark, String unid, String authMethod, String serverName, String cmvcDb, String projectDb, Session SessionTemp) {
            this.userName = userName;
            this.password = password;
            this.action = action;
            this.cmvcNo = cmvcNo;
            this.family = family;
            this.remark = remark;
            this.unid = unid;
            this.authMethod = authMethod;

            try {
                  // create a window for displaying the progress of transaction.
                  processMessage = new ProcessMessage("CMVC Transaction Message");
                  
// @PC 02192002 deleted on purpose                  
//                  messageDialog = new MessageDialog(processMessage);
                  
                  doc = new NotesCMVCDocument(serverName, cmvcDb, projectDb);    // create a Notes CMVC Document.
                  data = new DataProcessor(cmvcNo, family);    // create a CMVC DB2 Data Processor.

                  if (authMethod != null && authMethod.equals("pw")) {
                        processMessage.appendText("User " + userName + " is logging in...");

                     // log in to CMVC DB2 System.
                     comProc = new CommandProcessor("cmvclog -in " + userName + " -noprompt " + password +
                                               " -family " + family, "");
                        if (comProc.isError() == true) {
                          if (comProc.getCmvcErrData().isEmpty() == false) {
                                    throw new CMVCException(showCMVCError(comProc.getCmvcErrData()));
                              }
                        }

                        processMessage.appendText("ok\n");
                  }

                  processMessage.appendText("\nTransaction Processing...\n");
                  processMessage.appendText("Please wait...\n" + action);
                  
                  
                  // OPEN CMVC OPERATION
                  if (action.equals("open")) {
                        doc.loadData(cmvcNo);    // get the Data from Domino to open to CMVC DB2 System.
     
                        String component = doc.getComponent();
                     String problemRemarks = doc.getProblemRemark();
                     String abstrak = doc.getAbstract();
                     String release = doc.getRelease();
                     String prefix = doc.getPrefix();
                     String severity = doc.getSeverity();
                     String symptom = doc.getSymptom();
                     String phaseFound = doc.getPhaseFound();
                     String brand = doc.getBrand();
               
                     processMessage.appendText("Opening a CMVC to DB2...\n");
                     String dosCommand = data.openCMVCString(component, abstrak, release,
                                                    prefix, severity, symptom,
                                                    phaseFound, brand);
                     // open a CMVC to DB2
                     comProc = new CommandProcessor(dosCommand, problemRemarks);
                     logOperation(dosCommand, processMessage);    // log the action.

                        if (comProc.isError() == true) {
                              throw new CMVCException(showCMVCError(comProc.getCmvcErrData()));
                        } else {
                           processMessage.appendText("Retrieving the new CMVC Number...\n");
                          String newCmvcNo = data.parseNewCMVCNo(comProc.getCmvcData());
                          doc.updateNewNum(newCmvcNo, cmvcNo);
                          data = new DataProcessor(newCmvcNo, family);
                          viewCMVC(processMessage, data, doc);
                     }

                  // VIEW CMVC OPERATION
                  } else if (action.equals("view")) {
                     viewCMVC(processMessage, data, doc);

                  // CANCEL CMVC OPERATION
                  } else if (action.equals("cancel")) {
                     processMessage.appendText("Canceling the CMVC in DB2...\n");
                     String dosCommand = data.cancelCMVCString();
                     comProc = new CommandProcessor(dosCommand, remark);
                     logOperation(dosCommand,processMessage);    // log the action.                        
                     cleanup(processMessage, data, comProc, doc, "\nThe CMVC has been canceled in DB2.\n\n");

                  // REOPEN CMVC OPERATION
                  } else if (action.equals("reopen")) {
                     processMessage.appendText("Reopening the CMVC in DB2...\n");
                     String dosCommand = data.reopenCMVCString();
                     comProc = new CommandProcessor(dosCommand, remark);
                     logOperation(dosCommand,processMessage);    // log the action.
                     cleanup(processMessage, data, comProc, doc, "\nThe CMVC has been reopened in DB2.\n\n");

                  // ACCEPT CMVC OPERATION
                  } else if (action.equals("accept")) {
                     processMessage.appendText("Verify accepting the CMVC in DB2...\n");
                     String dosCommand = data.verifyCloseCMVCString();
                     comProc = new CommandProcessor(dosCommand, remark);
                     logOperation(dosCommand,processMessage);    // log the action.
                     cleanup(processMessage, data, comProc, doc, "\nThe CMVC has been verify accepted in DB2.\n\n");

                  // REJECT CMVC OPERATION
                } else if (action.equals("reject")) {
                     processMessage.appendText("Verify rejecting the CMVC in DB2...\n");
                     String dosCommand = data.verifyOpenCMVCString();
                     comProc = new CommandProcessor(dosCommand, remark);
                     logOperation(dosCommand,processMessage);    // log the action.
                     if (comProc.isError() == true) {
                           throw new CMVCException(showCMVCError(comProc.getCmvcErrData()));
                     } else {
                          processMessage.appendText("Updating spawned CMVC Number to Domino...\n");
                          doc.updateNewNum(data.parseNewCMVCNo(cmvcNo), unid);
                          data = new DataProcessor(data.parseNewCMVCNo(cmvcNo), family);
      
                          do {
                              comProc = new CommandProcessor(data.viewCMVCString(), "");
                              processMessage.appendText("Refreshing the CMVC from DB2 1...\n");
                          } while (comProc.isError() == true);

                          saveData(processMessage, data, comProc, doc);
                        }

                  // NOTE CMVC OPERATION
                  } else if (action.equals("note")) {
                     processMessage.appendText("Noting the CMVC in DB2...\n");
                     String dosCommand = data.addCMVCRemarksString();
                     comProc = new CommandProcessor(dosCommand, remark);
                     logOperation(dosCommand, processMessage);    // log the action.
                     cleanup(processMessage, data, comProc, doc, "\nThe CMVC has been noted in DB2.\n\n");
                  }

// @PC 02192002 deleted on purpose, changed to ...
//                  messageDialog.showMessage("Transaction processed successfully.\n\nPlease refresh document from view (F9).", "CMVC");
                  processMessage.appendText("\nTransaction processed successfully.\n\nPlease refresh document from view (F9).\n\n");

            } catch (CMVCException cx) {
                  
            } catch (Exception e) {
                try {
                     SaveClientError.start();
                     System.out.println(new Date());
                     System.out.println("CMVCMain Exception: " + e);
                     //e.printStackTrace();
                     SaveClientError.stop();
                     
// @PC 02192002 deleted on purpose                     
//                     messageDialog.showMessage( "Transaction failed! Please send " +
//                                              "cmvcError.log in <Notes> directory to TEMS " +
//                                              "Development Team for technical support.",
//                                             "CMVC Java Error");
                      try
                        {
                          SessionTemp.setEnvironmentVar("JavaResult", "FALSE", false);
                        }
                      catch (Exception me)
                        {
                          me.printStackTrace();
                        }
                        
                     processMessage.appendText("Transaction failed! Please send cmvcError.log in <Notes> " +
                                                                                    "directory to TEMS Development Team for technical support.");

                  } catch (IOException iox) {
                     System.out.println(iox);
                }
           }
            processMessage.dispose();    
//            messageDialog.dispose();
      }


    /**
     *
     * Method for displaying the error message from CMVC DB2 System in a window.
     *
     * @param error      Error message from DB2.
     *
     */

    // Method for displaying error messages sent by the CMVC DB2 System.
    private String showCMVCError(Vector error) {
        String str = "";
        for (int i = 0; i < error.size(); i++) {
            str += (String) error.elementAt(i) + "\n";
        }

// @PC 02192002 deleted on purpose        
//        messageDialog.showMessage("Transaction failed!\n\n" + str, "CMVC DB2 Error Message");
            processMessage.appendText("Transaction failed!\n\n" + str);
        return str;
    }

    // Method for logging operations done to CMVC DB2 System by the user.
    private void logOperation(String operation, ProcessMessage pm) throws java.io.IOException {
          pm.appendText("inside logoperation before saveclientaction start\n");
        SaveClientAction.start(pm);
                  pm.appendText("inside logoperation after saveclientaction start\n");
        System.out.print(new Date());
        System.out.println("\t" + operation);
                  pm.appendText("inside logoperation before saveclientaction stop\n");
        SaveClientAction.stop(pm);
                  pm.appendText("inside logoperationafter saveclientaction stop\n");
    }

    // Method for saving data to Domino Server.
    private void saveData(ProcessMessage pm, DataProcessor dp, CommandProcessor cp, NotesCMVCDocument doc) {
        pm.appendText("Saving data to Domino...\n");
        dp.loadDates(doc);
        dp.parseRetrievedDoc(cp.getCmvcData());
        dp.setDoc(doc);
        doc.storeData();
    }

    // Method for viewing a CMVC in DB2 System.
    private void viewCMVC(ProcessMessage pm, DataProcessor dp, NotesCMVCDocument doc) throws IOException, CMVCException {
        pm.appendText("Refreshing the CMVC from DB22 in viewcmvc...\n");
        String dosCommand = dp.viewCMVCString();
pm.appendText("After doscommand" + dosCommand);
        CommandProcessor comProc = new CommandProcessor(dosCommand, "");
        pm.appendText("After new command processor");
        logOperation(dosCommand, pm);    // log the action.
                pm.appendText("After dos command");

        if (comProc.isError() == true) {
            throw new CMVCException(showCMVCError(comProc.getCmvcErrData()));
        } else {
                      pm.appendText("Before save data");
            saveData(pm, dp, comProc, doc);
                    pm.appendText("After save data");
        }
    }

    // Method for cleaning up after an operation to CMVC DB2.
    private void cleanup(ProcessMessage pm, DataProcessor dp, CommandProcessor cp,
                         NotesCMVCDocument doc, String message) throws java.io.IOException, CMVCException {
        if (cp.isError() == true) {
            if (cp.getCmvcErrData().isEmpty() == false) {
                throw new CMVCException(showCMVCError(cp.getCmvcErrData()));
            } else {
                pm.appendText(message);
                viewCMVC(pm, dp, doc);
            }              
        }
    }

      class CMVCException extends Exception {
            CMVCException(String message) {
                  super(message);
            }
      }
}


MessageDialog.java

import java.awt.Button;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.Rectangle;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MessageDialog extends Dialog implements ActionListener {
      TextArea textArea;
      
      public MessageDialog(Frame window) {
            super(window, true);
            Panel p1 = new Panel();
            textArea = new TextArea();
            p1.add(textArea);
            Panel p2 = new Panel();
            p2.setLayout(new FlowLayout());
            Button okButton = new Button("OK");
            p2.add(okButton);
            okButton.addActionListener(this);
            add("Center", p1);
            add("South", p2);
      }
      
      public void actionPerformed(ActionEvent evt) {
            setVisible(false);            
      }
      
      public void showMessage(String message, String title) {
            setTitle(title);
            textArea.append(message);
            pack();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Rectangle rect = getBounds();
            setLocation((screenSize.width-rect.width)/2,(screenSize.height-rect.height)/2);
            setVisible(true);      
      }
}

NotesCMVCDocument.java

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Properties;
import lotus.domino.*;

public class NotesCMVCDocument {
      // metadata
      String serverName;
      String cmvcDb;
      String projectDb;
      
    // Document data
    protected String cmvcNo;
    protected String state;
    protected String abstrak;
    protected String family;
    protected String release;
    protected String phaseFound;
    protected String severity;
    protected String prefix;
    protected String symptom;
    protected String component;
    protected String brand;
    protected String targetDate;
    protected String targetState;
    protected String envName;
   
    private String problemRemark;
    protected String remarksHistory;
    protected String lastUpdate;

    protected String openDate;
    protected String workingDate;
    protected String returnDate;
    protected String cancelDate;
    protected String verifyDate;
    protected String closeDate;

    protected String openedBy;
    protected String workedBy;
    protected String returnedBy;
    protected String canceledBy;
    protected String verifiedBy;
    protected String closedBy;

    protected String ownerLogin;
    protected String ownerName;
    protected String originName;
    protected String originArea;

    // addendum
    protected String reference;
    protected String duplicate;
    protected String age;
    protected String answer;
    protected String level;
    protected String assignDate;
    protected String responseDate;
    protected String endDate;
    protected String ownerArea;
    protected String remoteName;
    protected String remoteFamily;
    protected String phaseInject;
    protected String priority;
    protected String target;
    protected String source;

      // @PC
    protected String originLogin;

      public NotesCMVCDocument (String serverName, String cmvcDb, String projectDb) {
            this.serverName = serverName;
            this.cmvcDb = cmvcDb;
            this.projectDb = projectDb;
            System.out.println(cmvcDb);
       }

    /**
     *
     * Method for storing data to Notes CMVC database.
     * @return boolean - true if data were stored in database.
     *
     */
     
      public void storeData() {
            try {
                  NotesThread.sinitThread();
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, cmvcDb);
                  DocumentCollection dc = db.search("Form=\"CMVC\" & CMVC_No=\"" + cmvcNo + "\" & familyalias=\"" + family + "\"");
                  Document doc = dc.getFirstDocument();
       
                  while (doc != null) {
                        System.out.println("store doc " + cmvcNo);
                     if (component.equals(doc.getItemValueString("Categories")) == false) {
                          Entry entry = new Entry(serverName, projectDb);
                              entry.searchProblemArea(doc.getItemValueString("kw_product"), component);
                              doc.replaceItemValue("kw_problem_area", entry.getArea());
                        }
                        doc.replaceItemValue("kw_prefix", prefix);
                        doc.replaceItemValue("Subject", abstrak);
                        doc.replaceItemValue("kw_severity", severity);
                        doc.replaceItemValue("kw_state", state);
                        doc.replaceItemValue("date_fixTargetDate", targetDate);
                        doc.replaceItemValue("kw_fix_target_state", targetState);
                        doc.replaceItemValue("Categories", component);
                        doc.replaceItemValue("kw_release", release);
                        doc.replaceItemValue("kw_symptom", symptom);
                        doc.replaceItemValue("kw_phase", phaseFound);
                        doc.replaceItemValue("kw_brand", brand);
                        doc.replaceItemValue("lastUpdate", lastUpdate);
                        doc.replaceItemValue("txt_history", "");
                        replaceHistory(doc);
                        doc.replaceItemValue("opendate", openDate);
                        doc.replaceItemValue("workingdate", workingDate);
                        doc.replaceItemValue("returndate", returnDate);
                        doc.replaceItemValue("canceldate", cancelDate);
                        doc.replaceItemValue("verifydate", verifyDate);
                        doc.replaceItemValue("closedate", closeDate);
                        doc.replaceItemValue("openedby", openedBy);
                        doc.replaceItemValue("workedby", workedBy);
                        doc.replaceItemValue("returnedby", returnedBy);
                        doc.replaceItemValue("canceledby", canceledBy);
                        doc.replaceItemValue("verifiedby", verifiedBy);
                        doc.replaceItemValue("closedby", closedBy);  
                        doc.replaceItemValue("developerLogin", ownerLogin);
                        doc.replaceItemValue("developer", ownerName);
                        doc.replaceItemValue("txt_reference", reference);
                        doc.replaceItemValue("txt_duplicate", duplicate);
                        doc.replaceItemValue("txt_age", age);
                        doc.replaceItemValue("txt_answer", answer);
                        doc.replaceItemValue("txt_envName", envName);
                        doc.replaceItemValue("txt_level", level);
                        doc.replaceItemValue("txt_assignDate", assignDate);
                        doc.replaceItemValue("txt_responseDate", responseDate);
                        doc.replaceItemValue("txt_endDate", endDate);
                        doc.replaceItemValue("txt_ownerArea", ownerArea);
                        doc.replaceItemValue("txt_remoteName", remoteName);
                        doc.replaceItemValue("txt_remoteFamily", remoteFamily);
                        doc.replaceItemValue("txt_phaseInject", phaseInject);
                        doc.replaceItemValue("txt_priority", priority);
                        doc.replaceItemValue("txt_target", target);
                        doc.replaceItemValue("txt_source", source);

                        // @PC                        
                        doc.replaceItemValue("OriginLogin", originLogin);
                        doc.replaceItemValue("OriginArea", originArea);
                        doc.replaceItemValue("OriginName", originName);
                        // add 012702
                        doc.replaceItemValue("kw_location", originArea);
                        
                        doc.save(true);
                        doc = dc.getNextDocument();
                  }
            } catch (NotesException nx) {
                  try {
                     SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("NotesDocument Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } finally {
                  NotesThread.stermThread();      
            }
      }

      private void replaceHistory(Document doc) throws NotesException {
            RichTextItem history = (RichTextItem) doc.getFirstItem("txt_History");
            int startIndex = 0;
            int endIndex;
            while ((endIndex = remarksHistory.indexOf("~", startIndex)) != -1) {
                history.appendText(remarksHistory.substring(startIndex, endIndex));
                history.addNewLine();
                startIndex = endIndex + 1;
            }
      }
      
      public void loadDates() {
            try {
                  System.out.println("initializing notesthread");
                  NotesThread.sinitThread();
                  System.out.println("creating a new session");
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, cmvcDb);
                  DocumentCollection dc = db.search("Form=\"CMVC\" & CMVC_No=\"" + cmvcNo + "\" & familyalias=\"" + family + "\"");
                  Document doc = dc.getFirstDocument();
       
                  while (doc != null) {
                        System.out.println("load dates ok");
                        openDate = doc.getItemValueString("opendate");
                        workingDate = doc.getItemValueString("workingdate");
                        returnDate = doc.getItemValueString("returndate");
                        cancelDate = doc.getItemValueString("canceldate");
                        verifyDate = doc.getItemValueString("verifydate");
                        closeDate = doc.getItemValueString("closedate");
                        openedBy = doc.getItemValueString("openedby");
                        workedBy = doc.getItemValueString("workedby");
                        returnedBy = doc.getItemValueString("returnedby");
                        canceledBy = doc.getItemValueString("canceledby");
                        verifiedBy = doc.getItemValueString("verifiedby");
                        closedBy = doc.getItemValueString("closedby");
                        doc = dc.getNextDocument();
                  }
            } catch (NotesException nx) {
                  try {
                        SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("NotesDocument Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } finally {
                  NotesThread.stermThread();      
            }
      }
      
      public void updateNewNum(String cmvcNo, String unid) {
            try {
                  NotesThread.sinitThread();
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, cmvcDb);
               Document doc = db.getDocumentByUNID(unid);
                        if (doc != null) {
                          doc.replaceItemValue("CMVC_No", cmvcNo);
                         doc.save(true);
                    }
            } catch (NotesException nx) {
                try {
                     SaveClientError.start();
                    System.out.println(new Date());
                    System.out.println("NotesDocument Exception: " + nx.id + " " + nx.text);
                    SaveClientError.stop();
               } catch (IOException iox) {
                    System.out.println(iox);
               }
            } finally {
                  NotesThread.stermThread();
            }
      }
   
      public void loadData(String unid) {
            try {
                  System.out.println(unid);
                  NotesThread.sinitThread();
                  Session session = NotesFactory.createSession();
                  Database db = session.getDatabase(serverName, cmvcDb);
                  System.out.println(serverName + " " + cmvcDb);
               Document doc = db.getDocumentByUNID(unid);
               if (doc != null) {
                     problemRemark = (new ProblemRemark(doc)).toString();
                    abstrak = doc.getItemValueString("Subject");
                    release = doc.getItemValueString("kw_release");
                    phaseFound = doc.getItemValueString("kw_phase");
                    severity = doc.getItemValueString("kw_severity");
                    prefix = doc.getItemValueString("kw_prefix");
                    symptom = doc.getItemValueString("kw_symptom");
                    component = doc.getItemValueString("Categories");
                    brand = doc.getItemValueString("kw_brand");
                  }
            } catch (NotesException nx) {
                  try {
                     SaveClientError.start();
                    System.out.println(new Date());
                    System.out.println("NotesDocument Exception: " + nx.id + " " + nx.text);
                    SaveClientError.stop();
               } catch (IOException iox) {
                    System.out.println(iox);
                }
            } finally {
                  NotesThread.stermThread();
            }
      }

    public void setName(String name) {
        cmvcNo = name;
    }

    public void setFamily(String family) {
        this.family = family;
    }

    public void setState(String state) {
        this.state = state;
    }

    public void setAbstract(String abstrak) {
        this.abstrak = abstrak;
    }
 
    public void setRelease(String release) {
        this.release = release;
    }

    public void setPhaseFound(String phaseFound) {
        this.phaseFound = phaseFound;
    }

    public void setSeverity(String severity) {
        this.severity = severity;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public void setSymptom(String symptom) {
        this.symptom = symptom;
    }

    public void setComponent(String comp) {
        this.component = comp;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public void setTargetDate(String fixDate) {
        this.targetDate = fixDate;
    }

    public void setTargetState(String targetState) {
        this.targetState = targetState;
    }

    public void setRemarksHistory(String remarksHistory) {
        this.remarksHistory = remarksHistory;
    }

    public void setOwnerLogin(String ownerLogin) {
        this.ownerLogin = ownerLogin;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public void setOriginName(String originName) {
        this.originName = originName;
    }

    public void setOriginArea(String originArea) {
        this.originArea = originArea;
    }

    public void setLastUpdate(String lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    // addendum
    public void setReference(String reference) {
        this.reference = reference;
    }

    public void setDuplicate(String duplicate) {
        this.duplicate = duplicate;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public void setEnvName(String envName) {
        this.envName = envName;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public void setAssignDate(String assignDate) {
        this.assignDate = assignDate;
    }

    public void setResponseDate(String responseDate) {
        this.responseDate = responseDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public void setOwnerArea(String ownerArea) {
        this.ownerArea = ownerArea;
    }

    public void setRemoteName(String remoteName) {
        this.remoteName = remoteName;
    }

    public void setRemoteFamily(String remoteFamily) {
        this.remoteFamily = remoteFamily;
    }

    public void setPhaseInject(String phaseInject) {
        this.phaseInject = phaseInject;
    }

    public void setPriority(String priority) {
        this.priority = priority;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public void setSource(String source) {
        this.source = source;
    }
   
    // @PC
    public void setOriginLogin(String originLogin) {
        this.originLogin = originLogin;
    }

    // dates
    public void setOpenDate(String openDate) {
        this.openDate = openDate;
    }

    public void setWorkingDate(String workingDate) {
        this.workingDate = workingDate;
    }

    public void setReturnDate(String returnDate) {
        this.returnDate = returnDate;
    }

    public void setCancelDate(String cancelDate) {
        this.cancelDate = cancelDate;
    }

    public void setVerifyDate(String verifyDate) {
        this.verifyDate = verifyDate;
    }

    public void setCloseDate(String closeDate) {
        this.closeDate = closeDate;
    }

    public String getOpenDate() {
        return openDate;
    }

    public String getWorkingDate() {
        return workingDate;
    }

    public String getReturnDate() {
        return returnDate;
    }

    public String getCancelDate() {
        return cancelDate;
    }

    public String getVerifyDate() {
        return verifyDate;
    }

    public String getCloseDate() {
        return closeDate;
    }

    public void setOpenedBy(String openedBy) {
        this.openedBy = openedBy;
    }

    public void setWorkedBy(String workedBy) {
        this.workedBy = workedBy;
    }

    public void setReturnedBy(String returnedBy) {
        this.returnedBy = returnedBy;
    }

    public void setCanceledBy(String canceledBy) {
        this.canceledBy = canceledBy;
    }

    public void setVerifiedBy(String verifiedBy) {
        this.verifiedBy = verifiedBy;
    }

    public void setClosedBy(String closedBy) {
        this.closedBy = closedBy;
    }

    public String getOpenedBy() {
        return openedBy;
    }

    public String getWorkedBy() {
        return workedBy;
    }

    public String getReturnedBy() {
        return returnedBy;
    }

    public String getCanceledBy() {
        return canceledBy;
    }

    public String getVerifiedBy() {
        return verifiedBy;
    }

    public String getClosedBy() {
        return closedBy;
    }


    public String getProblemRemark() {
        return problemRemark;
    }

    // open data
    public String getAbstract() {
        return abstrak;
    }
 
    public String getRelease() {
        return release;
    }

    public String getPhaseFound() {
        return phaseFound;
    }

    public String getSeverity() {
        return severity;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getSymptom() {
        return symptom;
    }

    public String getComponent() {
        return component;
    }

    public String getBrand() {
        return brand;
    }  
}





OutputStreamThread.java

import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class OutputStreamThread extends Thread {
    private OutputStream outStream;
    private String data;


    /**
     *
     * Constructor for initializing the output stream and string to be written.
     *
     * @param outStream      java.io.OutputStream object.
     * @param data      java.lang.String object.
     *
     */

    public OutputStreamThread(OutputStream outStream, String data) {
        this.outStream = outStream;
        this.data = data;
    }


    /**
     *
     * Method for starting the thread.
     *
     */

    public void run() {
        try {
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));
            for (int i = 0; i < data.length(); i++) {
                if ((data.charAt(i) == '\\') && (data.charAt(i+1) == 'n')) {
                    out.write('\n');
                    i++;
                } else if ((data.charAt(i) == '\\') && (data.charAt(i+1) == 't')) {
                    out.write('\t');
                    i++;
                } else {
                    out.write(data.charAt(i));
                }
            }
            out.write('\u001A');
            out.close();
        } catch (java.io.IOException e) {
            System.out.println(e);
        }
    }
}

PasswordFrame.java

import java.awt.Button;
import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Font;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.util.Date;
import lotus.domino.*;

public class PasswordFrame extends Frame implements ActionListener, WindowListener {
      boolean isUserSet;
      boolean isToSave = false;
      boolean isToProcess = false;
      String userStr;
      String passStr;
      TextField userName;
      TextField password;
      Checkbox saveEntry;
      Button okButton;
      Button cancelButton;
      
      public PasswordFrame() {
            Panel p1 = new Panel();
            p1.setLayout(new BorderLayout());
            Label label1 = new Label("UserName:", Label.RIGHT);
            label1.setFont(new Font("Arial", Font.BOLD, 14));
            Label label2 = new Label(" ");
            label2.setFont(new Font("Arial", Font.PLAIN, 1));
            Label label3 = new Label("Password:", Label.RIGHT);
            label3.setFont(new Font("Arial", Font.BOLD, 14));
            p1.add("North", label1);
            p1.add("Center", label2);
            p1.add("South", label3);
            Panel p2 = new Panel();
            p2.setLayout(new BorderLayout());
            userName = new TextField(20);
            userName.setFont(new Font("Arial", Font.PLAIN, 14));
            Label emptyLabel = new Label(" ");
            emptyLabel.setFont(new Font("Arial", Font.PLAIN, 1));
            password = new TextField(20);
            password.setFont(new Font("Arial", Font.PLAIN, 14));
            password.setEchoChar('*');
            p2.add("North", userName);
            p2.add("Center", emptyLabel);
            p2.add("South", password);
            Panel p3 = new Panel();
            p3.add(p1);
            p3.add(p2);
            p3.setBackground(Color.lightGray);
            add("Center", p3);
            Panel p4 = new Panel();
            saveEntry = new Checkbox("Save Username and Password");
            saveEntry.setFont(new Font("Arial", Font.PLAIN, 14));
            p4.setBackground(Color.lightGray);
            p4.add(saveEntry);
            add("South", p4);
            Panel p5 = new Panel();
            p5.setLayout(new BorderLayout());
            okButton = new Button("OK");
            okButton.setFont(new Font("Arial", Font.PLAIN, 14));
            Label emptyLabel2 = new Label(" ");
            emptyLabel2.setFont(new Font("Arial", Font.PLAIN, 4));
            cancelButton = new Button("Cancel");
            cancelButton.setFont(new Font("Arial", Font.PLAIN, 14));
            okButton.addActionListener(this);
            cancelButton.addActionListener(this);
            p5.add("North", okButton);
            p5.add("Center", emptyLabel2);
            p5.add("South", cancelButton);
            p5.setBackground(Color.lightGray);
            Panel p6 = new Panel();
            p6.setBackground(Color.lightGray);
            p6.add(p5);
            add("East", p6);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-400)/2,(screenSize.height-150)/2,400,150);
            addWindowListener(this);
            setTitle("CMVC Login");
            setResizable(false);
            setVisible(true);
      }

      public PasswordFrame(String userName) {
            this();
            this.userName.setText(userName);
      }
      
      public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == okButton) {
                  setVisible(false);
                  setUserPassword();
                  dispose();
            } else if (source == cancelButton) {
                  cancelAction();
                  dispose();
            }            
      }
      
      public void windowOpened(WindowEvent e) {}
      
      public void windowClosing(WindowEvent e) {
            dispose();
      }

      public void windowClosed(WindowEvent e) {}
   
      public void windowIconified(WindowEvent e) {}

      public void windowDeiconified(WindowEvent e) {}

      public void windowActivated(WindowEvent e) {}

      public void windowDeactivated(WindowEvent e) {}
      
      private synchronized void setUserPassword() {
            if (saveEntry.getState() == true) {
                  isToSave = true;
            }
            userStr = userName.getText();
            passStr = password.getText();
            isUserSet = true;
            isToProcess = true;
            notifyAll();
      }
      
      private synchronized void cancelAction() {
            isUserSet = true;
            notifyAll();
      }
      
      public synchronized String getUserName() {
            while (isUserSet == false) {
                  try {
                        wait();      
                  } catch (InterruptedException iex) {}
            }
            return userStr;
      }
      
      public synchronized String getPassword() {
            while (isUserSet == false) {
                  try {
                        wait();      
                  } catch (InterruptedException iex) {}
            }
            return passStr;
      }

      public boolean isToSave() {
            return isToSave;
      }

      public boolean isToProcess() {
            return isToProcess;
      }
      
      /*private void saveUserPassword() {
            try {
                  //NotesThread.sinitThread();
                  //Session session = NotesFactory.createSession();
                  //Database db = session.getDatabase(serverName, cmvcDb);
                  //db.open();
                    
                  
            } catch (NotesException nx) {
                  try {
                     SaveClientError.start();
                        System.out.println(new Date());
                        System.out.println("PasswordFrame Exception: " + nx.id + " " + nx.text);
                        SaveClientError.stop();
                  } catch (IOException iox) {
                        System.out.println(iox);
                  }
            } finally {
                  NotesThread.stermThread();      
            }
      }*/
}

ProblemRemark.java

import lotus.domino.*;

public class ProblemRemark {
    String string;


    /**
     *
     * Constructor for formatting the Problem Remarks fields into Java String.
     *
     * @param doc      Notes Document object.
     *
     */

    public ProblemRemark(Document doc) throws NotesException {
        string = "PROBLEM DESCRIPTION:\n" +
                 doc.getItemValueString("rtxt_Problem_Description") + "\n\n" +

                    "< Observed symptom ?  >" + "\n" +
                    (doc.getItemValueString("txt_Observed_Symptoms") == null ? "" : doc.getItemValueString("txt_Observed_Symptoms")) + "\n\n" +

                    "< Error message/code ? > " + "\n" +
                    (doc.getItemValueString("txt_Error_Message") == null ? "" : doc.getItemValueString("txt_Error_Message")) + "\n\n" +
                    
                    "< Conditions to reproduce ?  >" + "\n" +
                    (doc.getItemValueString("txt_Conditions_Rep") == null ? "" : doc.getItemValueString("txt_Conditions_Rep")) + "\n\n" +

                    "< Expected Behavior ? >" + "\n" +
                    (doc.getItemValueString("txt_Expected_Behavior") == null ? "" : doc.getItemValueString("txt_Expected_Behavior")) + "\n\n" +

                    "< How to Recover ? >" + "\n" +
                    (doc.getItemValueString("txt_Recover") == null ? "" : doc.getItemValueString("txt_Recover")) + "\n\n" +

                    "< Other Information >" + "\n" +
                    (doc.getItemValueString("txt_Other_Info") == null ? "" : doc.getItemValueString("txt_Other_Info")) + "\n\n" +                   

//                    "What is the actual symptom seen ? " + "\n" +
//                    (doc.getItemValueString("txt_Actual_Symptoms") == null ? "" : doc.getItemValueString("txt_Actual_Symptoms")) + "\n" +

//                    "What is mandatory condition to recreate ? " + "\n" +
//                    (doc.getItemValueString("txt_Mandatory_Condition") == null ? "" : doc.getItemValueString("txt_Mandatory_Condition")) + "\n\n" +
                    
                 "VERIFICATION:\n" +
                 "ITEM\t\tYES / NO\tREMARK\n" +

                 "Frequency : " +
                 (doc.getItemValueString("kw_Frequency") == null ? "" : doc.getItemValueString("kw_Frequency")) +
                 " (\"S\" olid / \"I\" intermittent)\n" +
                 
                 "Unique to EUT ?\t" +
                 (doc.getItemValueString("kw_unique_eut") == null ? "" : doc.getItemValueString("kw_unique_eut")) + "\t" +
                 (doc.getItemValueString("txt_unique_eut") == null ? "" : doc.getItemValueString("txt_unique_eut")) + "\n" +

                 "Unique to Configuration ?\t" +
                 (doc.getItemValueString("kw_unique_config") == null ? "" : doc.getItemValueString("kw_unique_config")) + "\t" +
                 (doc.getItemValueString("txt_unique_config") == null ? "" : doc.getItemValueString("txt_unique_config")) + "\n" +

                 "Unique to OS ?\t" +
                 (doc.getItemValueString("kw_unique_os") == null ? "" : doc.getItemValueString("kw_unique_os")) + "\t" +
                 (doc.getItemValueString("txt_unique_os") == null ? "" : doc.getItemValueString("txt_unique_os")) + "\n" +

                 "Unique to Product ?\t" +
                 (doc.getItemValueString("kw_unique_product") == null ? "" : doc.getItemValueString("kw_unique_product")) + "\t" +
                 (doc.getItemValueString("txt_unique_product") == null ? "" : doc.getItemValueString("txt_unique_product")) + "\n" +

// @PC
// removed this lines!
//                 "Unique to IBM ?\t" +
//                 (doc.getItemValueString("kw_unique_industry") == null ? "" : doc.getItemValueString("kw_unique_industry")) + "\t" +
//                 (doc.getItemValueString("txt_unique_industry") == null ? "" : doc.getItemValueString("txt_unique_industry")) + "\n\n" +
//
                 "Unique to Current Version ?\t" +
                 (doc.getItemValueString("kw_unique_current") == null ? "" : doc.getItemValueString("kw_unique_current")) + "\t" +
                 (doc.getItemValueString("txt_unique_current") == null ? "" : doc.getItemValueString("txt_unique_current")) + "\n\n" +


                 "OTHER\n\n" +
                 (doc.getItemValueString("rtxt_Problem_Verification") == null ? "" : doc.getItemValueString("rtxt_Problem_Verification")) + "\n\n" +

                 "[RE-CREATION PROCEDURE]\n\n" +
                 (doc.getItemValueString("rtxt_Recreation_proc") == null ? "" : doc.getItemValueString("rtxt_Recreation_proc")) + "\n\n" +

                 "MISC. INFORMATION:\n\n" +

                 "(reviewed by " +
                 (doc.getItemValueString("txt_reviewed_by_copy") == null ? "" : doc.getItemValueString("txt_reviewed_by_copy")) + ")\n" +

// @PC changed the position of this lines
//                "Frequency : " +
//                 (doc.getItemValueString("kw_Frequency") == null ? "" : doc.getItemValueString("kw_Frequency")) +
//                 " (\"S\" olid / \"I\" intermittent)\n" +

                 "Test item : " +
                 (doc.getItemValueString("txt_Test_Item_copy") == null ? "" : doc.getItemValueString("txt_Test_Item_copy")) + "\n" +

                 "Test case : " +
                 (doc.getItemValueString("txt_Test_case_copy") == null ? "" : doc.getItemValueString("txt_Test_case_copy")) + "\n\n" +

                 "Suspective area  : " +
                 (doc.getItemValueString("kw_suspective_area") == null ? "" : doc.getItemValueString("kw_suspective_area")) + "\n" +

                 "Suspective reason : " +
                 (doc.getItemValueString("txt_suspective_reason") == null ? "" : doc.getItemValueString("txt_suspective_reason")) + "\n\n" +
 
                 "[H/W]\n" +
                 "H/W level : " +
                 (doc.getItemValueString("txt_HW_level") == null ? "" : doc.getItemValueString("txt_HW_level")) + "\n" +

                 "S/N  : " +
                 (doc.getItemValueString("txt_SN") == null ? "" : doc.getItemValueString("txt_SN")) + "\n" +

                 "CPU  : " +
                 (doc.getItemValueString("txt_CPU") == null ? "" : doc.getItemValueString("txt_CPU")) + "\n" +

                 "LCD  : " +
                 (doc.getItemValueString("txt_LCD") == null ? "" : doc.getItemValueString("txt_LCD")) + "\n" +

                 "HDD  : " +
                 (doc.getItemValueString("txt_HDD") == null ? "" : doc.getItemValueString("txt_HDD")) + " GB\n" +

                 "Memory  : " +
                 (doc.getItemValueString("txt_Memory") == null ? "" : doc.getItemValueString("txt_Memory")) + "MB\n" +

                 "2nd Drive : " +
                 (doc.getItemValueString("txt_CDROM_model") == null ? "" : doc.getItemValueString("txt_CDROM_model")) + "\n" +

// @PC
// removed this lines!
//                 "MPEG  : " +
//                 (doc.getItemValueString("txt_MPEG") == null ? "" : doc.getItemValueString("txt_MPEG")) + "\n" +
//
//                 "Peripheral : " +
//                 (doc.getItemValueString("txt_Peripheral") == null ? "" : doc.getItemValueString("txt_Peripheral")) + "\n\n\n" +


                 "[S/W]\n" +
                 "ROM  : " +
                 (doc.getItemValueString("txt_ROM") == null ? "" : doc.getItemValueString("txt_ROM")) + "\n" +

                 "H8  : " +
                 (doc.getItemValueString("txt_H8") == null ? "" : doc.getItemValueString("txt_H8")) + "\n" +

                 "OS  : " +
                 (doc.getItemValueString("txt_OS") == null ? "" : doc.getItemValueString("txt_OS")) + "\n" +

                 "CSD  : " +
                 (doc.getItemValueString("txt_CSD") == null ? "" : doc.getItemValueString("txt_CSD")) + "\n" +

                 "Patch  : " +
                 (doc.getItemValueString("txt_Patch") == null ? "" : doc.getItemValueString("txt_Patch")) + "\n" +

                 "Utility  : " +
                 (doc.getItemValueString("txt_Utility_driver") == null ? "" : doc.getItemValueString("txt_Utility_driver")) + "\n" +

                 "Video  : " +
                 (doc.getItemValueString("txt_Video_driver") == null ? "" : doc.getItemValueString("txt_Video_driver")) + "\n" +

                 "Audio   : " +
                 (doc.getItemValueString("txt_Audio_driver") == null ? "" : doc.getItemValueString("txt_Audio_driver")) + "\n" +

// @PC
// removed this lines!
//                 "PCMCIA  : " +
//                 (doc.getItemValueString("txt_PCMCIA_driver") == null ? "" : doc.getItemValueString("txt_PCMCIA_driver")) + "\n" +
//
//                 "IR  : " +
//                 (doc.getItemValueString("txt_IR_driver") == null ? "" : doc.getItemValueString("txt_IR_driver")) + "\n" +

                 "Modem  : " +
                 (doc.getItemValueString("txt_Modem_driver") == null ? "" : doc.getItemValueString("txt_Modem_driver")) + "\n" +

                 "Capture  : " +
                 (doc.getItemValueString("txt_Capture_driver") == null ? "" : doc.getItemValueString("txt_Capture_driver")) + "\n" +

// @PC
// removed this lines!
//                 "MPEG  : " +
//                 (doc.getItemValueString("txt_MPEG_driver") == null ? "" : doc.getItemValueString("txt_MPEG_driver")) + "\n" +
//
//                 "CDROM  : " +
//                 (doc.getItemValueString("txt_CDROM_driver") == null ? "" : doc.getItemValueString("txt_CDROM_driver")) + "\n" +
//
//                 "DVD  : " +
//                 (doc.getItemValueString("txt_DVD_driver") == null ? "" : doc.getItemValueString("txt_DVD_driver")) + "\n" +


                 "Wireless Driver : " +
                 (doc.getItemValueString("txt_Wireless_driver") == null ? "" : doc.getItemValueString("txt_Wireless_driver")) + "\n" +

                 "Ethernet Driver : " +
                 (doc.getItemValueString("txt_Ethernet_driver") == null ? "" : doc.getItemValueString("txt_Ethernet_driver")) + "\n" +

                 "CDC [EDC/MDC/BDC] : " +
                 (doc.getItemValueString("txt_CDC_driver") == null ? "" : doc.getItemValueString("txt_CDC_driver")) + "\n" +

                 "Hotkey Features : " +
                 (doc.getItemValueString("txt_Hotkey_Features") == null ? "" : doc.getItemValueString("txt_Hotkey_Features")) + "\n" +

                 "CMD IDE Driver : " +
                 (doc.getItemValueString("txt_CMD_IDE_Driver") == null ? "" : doc.getItemValueString("txt_CMD_IDE_Driver")) + "\n" +

                 "Package Manager : " +
                 (doc.getItemValueString("txt_Package_Manager") == null ? "" : doc.getItemValueString("txt_Package_Manager")) + "\n" +

                 "Access Connections : " +
                 (doc.getItemValueString("txt_Access_Connections") == null ? "" : doc.getItemValueString("txt_Access_Connections")) + "\n" +


                 "Others  : " +
                 (doc.getItemValueString("txt_Others") == null ? "" : doc.getItemValueString("txt_Others")) + "\n\n\n" +

                 "[PARAMETER]\n" +
                 "BIOS Setting : " +
                 (doc.getItemValueString("txt_BIOS_setting") == null ? "" : doc.getItemValueString("txt_BIOS_setting")) + "\n" +

                 "OS  Setting : " +
                 (doc.getItemValueString("txt_OS_setting") == null ? "" : doc.getItemValueString("txt_OS_setting"));

// @PC moved to another position
//                 "[RE-CREATION PROCEDURE]\n" +
//                 (doc.getItemValueString("rtxt_Recreation_proc") == null ? "" : doc.getItemValueString("rtxt_Recreation_proc")); // + "\n\n\n" +

                 //"[OTHER]\n" +
                 //(doc.getItemValueString("txt_other") == null ? "" : doc.getItemValueString("txt_other"));
    }


    /**
     *
     * Method for getting the String equivalent of Problem Remarks.
     *
     */

    public String toString() {
        return string;
    }
}

ProcessMessage.java

import java.awt.Dimension;
import java.awt.Font;
import java.awt.ScrollPane;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class ProcessMessage extends java.awt.Frame implements WindowListener {
    TextArea textArea;

    /**
     *
     * Constructor for executing the display.
     *
     * @param title      Window title.
     *
     */

    public ProcessMessage(String title) {
        textArea = new TextArea();

        textArea.setFont(new Font("Arial", Font.PLAIN, 12));
        //textArea.setLineWrap(true);
        //textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        ScrollPane areaScrollPane = new ScrollPane();
        areaScrollPane.add(textArea);
        areaScrollPane.setSize(new Dimension(600, 200));
       


        add(areaScrollPane);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-640)/2,(screenSize.height-480)/2,640,240);

        addWindowListener(this);
            setTitle(title);
        setVisible(true);
    }

    public void appendText(String message) {
        textArea.append(message);
    }

      public void windowOpened(WindowEvent e) {}
      
      public void windowClosing(WindowEvent e) {
            dispose();
      }

    public void windowClosed(WindowEvent e) {}
   
    public void windowIconified(WindowEvent e) {}

    public void windowDeiconified(WindowEvent e) {}

    public void windowActivated(WindowEvent e) {}

    public void windowDeactivated(WindowEvent e) {}
}

RemarksFrame.java

import java.awt.Button;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Font;
import java.awt.Label;
import java.awt.Panel;
import java.awt.ScrollPane;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import lotus.domino.*;

public class RemarksFrame extends Frame implements ActionListener, WindowListener {
      Button okButton;
      Button cancelButton;
      TextArea textArea;
      String userName;
      String password;
      String action;
      String cmvcNo;
      String family;
      String authMethod;
      String serverName;
      String cmvcDb;
      String projectDb;

    /**
     *
     * Constructor for executing the display.
     *
     * @param title      Window title.
     *
     */

      public RemarksFrame(String userName, String password, String action, String cmvcNo, String family, String authMethod, String serverName, String cmvcDb, String projectDb) {
            this.userName = userName;
            this.password = password;
            this.action = action;
            this.cmvcNo = cmvcNo;
            this.family = family;
            this.authMethod = authMethod;
            this.serverName = serverName;
            this.cmvcDb = cmvcDb;
            this.projectDb = projectDb;
           textArea = new TextArea();
            Panel p1 = new Panel();
            p1.setLayout(new BorderLayout());
            Label label1 = new Label("Action:", Label.RIGHT);
            Label label2 = new Label("CMVC No.:", Label.RIGHT);
            p1.add("Center", label1);
            p1.add("South", label2);
            Panel p2 = new Panel();
            p2.setLayout(new BorderLayout());
            Label label3 = new Label(action);
            Label label4 = new Label(cmvcNo);
            label3.setFont(new Font("Arial", Font.BOLD, 12));
            label4.setFont(new Font("Arial", Font.BOLD, 12));
            p2.add("Center", label3);
            p2.add("South", label4);
            Panel p3 = new Panel();
            p3.add(p1);
            p3.add(p2);
            p3.setBackground(Color.lightGray);
            add("North", p3);
            textArea.setFont(new Font("Arial", Font.PLAIN, 12));
            ScrollPane areaScrollPane = new ScrollPane();
            areaScrollPane.add(textArea);
            areaScrollPane.setSize(new Dimension(600, 440));
            add("Center", areaScrollPane);
            Panel p4 = new Panel();
            okButton = new Button("    OK    ");
            cancelButton = new Button("Cancel");
            okButton.addActionListener(this);
            cancelButton.addActionListener(this);
            p4.add(okButton);
            p4.add(new Label(" "));
            p4.add(cancelButton);
            p4.setBackground(Color.lightGray);
            add("South", p4);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-640)/2,(screenSize.height-480)/2,640,480);
            addWindowListener(this);
            setTitle("CMVC Operation");
            setVisible(true);
      }

      public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == okButton) {
                  setVisible(false);
//                  new MainProcess(userName, password, action, cmvcNo, family, textArea.getText(), null, authMethod, serverName, cmvcDb, projectDb);
                  new MainProcess(userName, password, action, cmvcNo, family, textArea.getText(), null, authMethod, serverName, cmvcDb, projectDb, null);
                  dispose();
            } else if (source == cancelButton) {
                  dispose();
            }            
      }
      
      public void windowOpened(WindowEvent e) {}
      
      public void windowClosing(WindowEvent e) {
            dispose();
      }

      public void windowClosed(WindowEvent e) {}
   
      public void windowIconified(WindowEvent e) {}

      public void windowDeiconified(WindowEvent e) {}

      public void windowActivated(WindowEvent e) {}

      public void windowDeactivated(WindowEvent e) {}
}

SaveClientAction.java

import java.io.*;
import java.text.*;
import java.util.*;

public class SaveClientAction extends PrintStream {
    static OutputStream logfile;
    static PrintStream oldStdout;
    static PrintStream oldStderr;

    /**
     *
     * Constructor for instantiating the super class.
     *
     * @param ps      java.io.PrintStream object.
     *
     */
     
    SaveClientAction(PrintStream ps) {
    super(ps);
    }

    /**
     *
     * Method to start copying stdout and stderr to the log file.
     *
     */

    public static synchronized void start(ProcessMessage pm) throws IOException {
      // Save old settings.
     pm.appendText("inside start save");
      oldStdout = System.out;
      oldStderr = System.err;
   
      // Create/Open logfile.
      pm.appendText("before new PrintStream");
      logfile = new PrintStream(
              new BufferedOutputStream(
              new FileOutputStream("cmvcAction.log", true)));
                    pm.appendText("\nafter new PrintStream");

      // Start redirecting the output.
            pm.appendText("before new save client action system out");
      //System.setOut(new SaveClientAction(System.out, pm));
           pm.appendText("before new save client action system err");
      //System.setErr(new SaveClientAction(System.err, pm));
    }


    /**
     *
     * Method to stop writing to log file and restore the original settings.
     *
     */

    public static synchronized void stop(ProcessMessage pm) {
    pm.appendText("\nSTART CLIENT SOTP");
    System.setOut(oldStdout);                  
    System.setErr(oldStderr);
        try {
            logfile.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        pm.appendText("\nFINISH CLIENT SOTP");
    }

    /**
     *
     * Overrides the write method of super class.
     *
     * @param b            character to write.
     *
     */

    public void write(int b) {
        try {
          logfile.write(b);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(b);
    }

    /**
     *
     * Overrides the write method of super class.
     *
     * @param buf[]      array of bytes to write.
     * @param off      offset.
     * @param len      length.
     *
     */

    public void write(byte buf[], int off, int len) {
        try {
          logfile.write(buf, off, len);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(buf, off, len);
    }
}

SaveClientError.java

import java.io.*;
import java.text.*;
import java.util.*;

public class SaveClientError extends PrintStream {
    static OutputStream logfile;
    static PrintStream oldStdout;
    static PrintStream oldStderr;


    /**
     *
     * Constructor for instantiating the super class.
     *
     * @param ps      java.io.PrintStream object.
     *
     */
     
    SaveClientError(PrintStream ps) {
      super(ps);
    }


    /**
     *
     * Method to start copying stdout and stderr to the log file.
     *
     */

    public static void start() throws IOException {
      // Save old settings.
      oldStdout = System.out;
      oldStderr = System.err;
   
      // Create/Open logfile.
      logfile = new PrintStream(
              new BufferedOutputStream(
              new FileOutputStream("cmvcError.log", true)));

      // Start redirecting the output.
      System.setOut(new SaveClientError(System.out));
      System.setErr(new SaveClientError(System.err));
    }

    /**
     *
     * Method to stop writing to log file and restore the original settings.
     *
     */

    public static void stop() {
    //      pm.appendText("\nstarting saveclient error stop");
      System.setOut(oldStdout);
      System.setErr(oldStderr);
        try {
          logfile.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
//pm.appendText("\nFINISHES STOP");
    }


    /**
     *
     * Overrides the write method of super class.
     *
     * @param b            character to write.
     *
     */

    public void write(int b) {
        try {
          logfile.write(b);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(b);
    }


    /**
     *
     * Overrides the write method of super class.
     *
     * @param buf[]      array of bytes to write.
     * @param off      offset.
     * @param len      length.
     *
     */

    public void write(byte buf[], int off, int len) {
        try {
          logfile.write(buf, off, len);
        } catch (Exception e) {
            e.printStackTrace();
            setError();
        }
        super.write(buf, off, len);
    }
}

UserPasswordProfile.java


public class UserPasswordProfile {
      public UserPasswordProfile() {

      }
      
}


VerifyFrame.java

import java.awt.Button;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Font;
import java.awt.Label;
import java.awt.Panel;
import java.awt.ScrollPane;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import lotus.domino.*;

public class VerifyFrame extends Frame implements ActionListener, WindowListener {
      Button okButton;
      Button cancelButton;
      Choice result;
      TextArea textArea;
      String userName;
      String password;
      String action;
      String cmvcNo;
      String family;
      String unid;
      String authMethod;
      String serverName;
      String cmvcDb;
      String projectDb;
      
    /**
     *
     * Constructor for executing the display.
     *
     * @param title      Window title.
     *
     */

      public VerifyFrame(String userName, String password, String action, String cmvcNo, String family, String unid, String authMethod, String serverName, String cmvcDb, String projectDb) {
            this.userName = userName;
            this.password = password;
            this.action = action;
            this.cmvcNo = cmvcNo;
            this.family = family;
            this.unid = unid;
            this.authMethod = authMethod;
            this.serverName = serverName;
            this.cmvcDb = cmvcDb;
            this.projectDb = projectDb;
           textArea = new TextArea();
            Panel p1 = new Panel();
            p1.setLayout(new BorderLayout());
            Label label1 = new Label("Action:", Label.RIGHT);
            Label label2 = new Label("CMVC No.:", Label.RIGHT);
            Label label3 = new Label("Result:", Label.RIGHT);
            p1.add("North", label1);
            p1.add("Center", label2);
            p1.add("South", label3);
            Panel p2 = new Panel();
            p2.setLayout(new BorderLayout());
            Label label4 = new Label(action);
            Label label5 = new Label(cmvcNo);
            result = new Choice();
            result.add("PASS");
            result.add("FAIL");
            label4.setFont(new Font("Arial", Font.BOLD, 12));
            label5.setFont(new Font("Arial", Font.BOLD, 12));
            p2.add("North", label4);
            p2.add("Center", label5);
            p2.add("South", result);
            Panel p3 = new Panel();
            p3.add(p1);
            p3.add(p2);
            p3.setBackground(Color.lightGray);
            add("North", p3);
            textArea.setFont(new Font("Arial", Font.PLAIN, 12));
            ScrollPane areaScrollPane = new ScrollPane();
            areaScrollPane.add(textArea);
            areaScrollPane.setSize(new Dimension(600, 440));
            add("Center", areaScrollPane);
            Panel p4 = new Panel();
            okButton = new Button("    OK    ");
            cancelButton = new Button("Cancel");
            okButton.addActionListener(this);
            cancelButton.addActionListener(this);
            p4.add(okButton);
            p4.add(new Label(" "));
            p4.add(cancelButton);
            p4.setBackground(Color.lightGray);
            add("South", p4);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-640)/2,(screenSize.height-480)/2,640,480);
            addWindowListener(this);
            setTitle("CMVC Operation");
            setVisible(true);
      }

      public void actionPerformed(ActionEvent evt) {
            Object source = evt.getSource();
            if (source == okButton) {
                  setVisible(false);
                  String verifyResult = result.getSelectedItem();
                  if (verifyResult.equals("PASS")) {
//                        new MainProcess(userName, password, "accept", cmvcNo, family, "Verification Result: PASS\n\n" + textArea.getText(), null, authMethod, serverName, cmvcDb, projectDb);
                        new MainProcess(userName, password, "accept", cmvcNo, family, "Verification Result: PASS\n\n" + textArea.getText(), null, authMethod, serverName, cmvcDb, projectDb, null);
                  } else if (verifyResult.equals("FAIL")) {
//                        new MainProcess(userName, password, "reject", cmvcNo, family, "Verification Result: FAIL\n\n" + textArea.getText(), unid, authMethod, serverName, cmvcDb, projectDb);
                        new MainProcess(userName, password, "reject", cmvcNo, family, "Verification Result: FAIL\n\n" + textArea.getText(), unid, authMethod, serverName, cmvcDb, projectDb, null);
                  }
                  dispose();
            } else if (source == cancelButton) {
                  dispose();
            }            
      }
      
      public void windowOpened(WindowEvent e) {}
      
      public void windowClosing(WindowEvent e) {
            dispose();
      }

      public void windowClosed(WindowEvent e) {}
   
      public void windowIconified(WindowEvent e) {}

      public void windowDeiconified(WindowEvent e) {}

      public void windowActivated(WindowEvent e) {}

      public void windowDeactivated(WindowEvent e) {}
}
ASKER CERTIFIED SOLUTION
Avatar of qwaletee
qwaletee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial