Ejemplo n.º 1
0
 /**
  * Constructor writes an open tag to the writer
  *
  * @param xWriter de xml data wil be writen to this writer
  */
 public KielijstExportWriter(Writer xWriter) throws KOAException {
   try {
     this.xWriter = xWriter;
     xWriter.write(
         "<?xml version=\"1.0\" encoding=\""
             + TechnicalProps.getProperty(TechnicalProps.KL_EXPORT_XML_ENCODING)
             + "\"?>\n");
     xWriter.write("<result action=\"replace\" contenttype=\"kieslijst\">\n");
   } catch (IOException ioe) {
     String[] params = {"writer"};
     KOALogHelper.logErrorCode("KielijstExportWriter", ErrorConstants.ERR_IO, params, ioe);
     throw new KOADataBeheerException(KOADataBeheerException.IO_EXCETION, ioe);
   }
 }
Ejemplo n.º 2
0
 /**
  * The execute method on the Suspend command. This method is executed in the ejb command target.
  *
  * @throws CommandException necessary to fullfill abstract method signature
  * @throws EPlatformException thrown when the remote instance of the Controller can not be
  *     created.
  */
 public void execute()
     throws ie.ucd.srg.logica.eplatform.command.CommandException, EPlatformException {
   LogHelper.log(LogHelper.INFO, "[SuspendCommand.exeute] execute ");
   boolean bBackupFailed = false;
   try {
     /* init the variabeles */
     Hashtable htProps = new Hashtable();
     htProps.put(
         Context.INITIAL_CONTEXT_FACTORY,
         JNDIProperties.getProperty(JNDIProperties.CONTROLLER_CONTEXT_FACTORY));
     htProps.put(
         Context.PROVIDER_URL, JNDIProperties.getProperty(JNDIProperties.CONTROLLER_PROVIDER));
     /* init the context */
     InitialContext icContext = new InitialContext(htProps);
     /* lookup the controller */
     Object obj = icContext.lookup(JNDIProperties.getProperty(JNDIProperties.CONTROLLER_NAME));
     /* create the controller */
     ControllerHome xControllerHome =
         (ControllerHome) PortableRemoteObject.narrow(obj, ControllerHome.class);
     Controller xController = xControllerHome.create();
     // Verify pincodes. If validated then continue with change of state
     g_crCallResult = xController.checkPinCode(sPincode1, sPincode2);
     if (g_crCallResult.getResult() == CallResult.RESULT_OK) {
       // change state to suspended
       g_crCallResult = xController.suspend();
       try {
         /* Call script to backup database to removable medium */
         String sBackupPath = TechnicalProps.getProperty(TechnicalProps.BACKUP_SCRIPT);
         LogHelper.log(LogHelper.INFO, "[SuspendCommand.exeute] Start creating backup...");
         if (sBackupPath != null) {
           Process xProcess = Runtime.getRuntime().exec(sBackupPath);
           int iProcessRes = xProcess.waitFor();
           if (iProcessRes != 0) {
             bBackupFailed = true;
             KOALogHelper.log(
                 KOALogHelper.ERROR,
                 "Error executing script for backup to fs (suspend state) code = " + iProcessRes);
           } else {
             bBackupFailed = false;
             String sMessage =
                 ie.ucd.srg.logica.eplatform.error.ErrorMessageFactory.getErrorMessageFactory()
                     .getErrorMessage(ErrorConstants.CREATE_BACKUP_OK, null);
             KOALogHelper.audit(
                 KOALogHelper.INFO,
                 AuditEventListener.STATE_CHANGE,
                 "SuspendElection",
                 g_sUser,
                 sMessage);
             // set callresult for backup
             g_crCallResult.setBackupResult(sMessage);
             LogHelper.log(LogHelper.INFO, "[SuspendCommand.exeute] backup created OK...");
           }
         }
       } catch (java.lang.InterruptedException xInterruptedExc) {
         bBackupFailed = true;
         KOALogHelper.logErrorCode(
             "SuspendCommand.execute",
             ErrorConstants.UNABLE_TO_START_BACKUP_SCRIPT,
             null,
             xInterruptedExc);
       } catch (java.io.IOException xioExc) {
         bBackupFailed = true;
         String[] params = {"backupscript"};
         KOALogHelper.logErrorCode(
             "SuspendCommand.execute", ErrorConstants.ERR_IO, params, xioExc);
       }
     }
   } catch (NamingException ne) {
     String[] params = {"Controller"};
     KOALogHelper.logErrorCode("SuspendCommand.execute", ErrorConstants.ERR_NAMING, params, ne);
     throw new KOAException(ErrorConstants.COMMAND_SUSPEND_EXEC, ne);
   } catch (RemoteException re) {
     String[] params = {"Controller"};
     KOALogHelper.logErrorCode("SuspendCommand.execute", ErrorConstants.ERR_REMOTE, params, re);
     throw new KOAException(ErrorConstants.COMMAND_SUSPEND_EXEC, re);
   } catch (CreateException ce) {
     String[] params = {"Controller"};
     KOALogHelper.logErrorCode("SuspendCommand.execute", ErrorConstants.ERR_CREATE, params, ce);
     throw new KOAException(ErrorConstants.COMMAND_SUSPEND_EXEC, ce);
   } catch (KOAException koae) {
     KOALogHelper.logError("SuspendCommand.execute", "KOAException", koae);
     throw koae;
   }
   // Always perform the following code, to check if the backup was successful
   finally {
     if (bBackupFailed) {
       try {
         String sMessage =
             ie.ucd.srg.logica.eplatform.error.ErrorMessageFactory.getErrorMessageFactory()
                 .getErrorMessage(ErrorConstants.CREATE_BACKUP_ERROR, null);
         KOALogHelper.audit(
             KOALogHelper.ERROR,
             AuditEventListener.STATE_CHANGE,
             "SuspendElection",
             g_sUser,
             sMessage);
         g_crCallResult.setBackupResult(sMessage);
         LogHelper.log(
             LogHelper.ERROR,
             "[SuspendCommand.exeute] Error occured with result that back up is not created...");
       } catch (java.io.IOException ioe) {
         String[] params = {"Error message factory"};
         KOALogHelper.logErrorCode("SuspendCommand.execute", ErrorConstants.ERR_IO, params, ioe);
       }
     }
   }
 }