@Transactional(readOnly = true)
 public SorPerson findByPersonIdAndSorIdentifier(
     final Long personId, final String sorSourceIdentifier) {
   try {
     return this.personRepository.findByPersonIdAndSorIdentifier(personId, sorSourceIdentifier);
   } catch (final Exception e) {
     logger.debug(e.getMessage(), e);
     return null;
   }
 }
Beispiel #2
0
 public void executeCommand(String cmd, String LogName1, String dir) throws Exception {
   Runtime run = Runtime.getRuntime();
   Process pr = null;
   log.info("Executing the command and getting the log file...");
   StringBuffer sb = new StringBuffer(30000);
   try {
     pr = run.exec(cmd);
     log.info(cmd + " executed successfully!!!");
   } catch (Exception e) {
     log.info(cmd + " couldn't be executed with error message: " + e.getMessage());
   }
   InputStream is = null;
   is = pr.getInputStream();
   int c = 0;
   try {
     while ((c = is.read()) != -1) {
       sb.append((char) c);
     }
   } catch (Exception e) {
     log.info("There is an exception: While appending in the file " + e.getMessage());
     e.printStackTrace();
   } finally {
     if (is != null) {
       try {
         is.close();
       } catch (Exception localException) {
         log.info("There is an exception: " + localException.getMessage());
         localException.printStackTrace();
       }
     }
   }
   try {
     File filename = new File(dir, LogName1);
     FileUtil.writeToTextFile(sb.toString(), filename);
     log.info("process comp.." + pr.waitFor());
   } catch (Exception e) {
     log.info("Problem while writing log to a log file with error stack " + e.getMessage());
   }
   pr = null;
 }
  private void register() throws IOException {
    Log.info("Registering with " + registrar);
    FromHeader fromHeader = getFromHeader();
    Address fromAddress = fromHeader.getAddress();

    // Request URI
    SipURI requestURI = null;
    try {
      requestURI = addressFactory.createSipURI(null, registrar);

    } catch (ParseException e) {
      throw new IOException("Bad registrar address:" + registrar + " " + e.getMessage());
    }
    // requestURI.setPort(registrarPort);

    try {
      requestURI.setTransportParam(sipProvider.getListeningPoint().getTransport());

    } catch (ParseException e) {
      throw new IOException(
          sipProvider.getListeningPoint().getTransport()
              + " is not a valid transport! "
              + e.getMessage());
    }

    CallIdHeader callIdHeader = sipProvider.getNewCallId();
    CSeqHeader cSeqHeader = null;

    try {
      cSeqHeader = headerFactory.createCSeqHeader(1, Request.REGISTER);
    } catch (ParseException e) {
      // Should never happen
      throw new IOException("Corrupt Sip Stack " + e.getMessage());
    } catch (InvalidArgumentException e) {
      // Should never happen
      throw new IOException("The application is corrupt ");
    }

    ToHeader toHeader = null;
    try {
      String proxyWorkAround = System.getProperty("com.sun.mc.softphone.REGISTRAR_WORKAROUND");

      if (proxyWorkAround != null && proxyWorkAround.toUpperCase().equals("TRUE")) {

        SipURI toURI = (SipURI) (requestURI.clone());
        toURI.setUser(System.getProperty("user.name"));

        toHeader = headerFactory.createToHeader(addressFactory.createAddress(toURI), null);
      } else {
        toHeader = headerFactory.createToHeader(fromAddress, null);
      }
    } catch (ParseException e) {
      throw new IOException(
          "Could not create a To header for address:"
              + fromHeader.getAddress()
              + " "
              + e.getMessage());
    }

    ArrayList viaHeaders = getLocalViaHeaders();
    MaxForwardsHeader maxForwardsHeader = getMaxForwardsHeader();
    Request request = null;

    try {
      request =
          messageFactory.createRequest(
              requestURI,
              Request.REGISTER,
              callIdHeader,
              cSeqHeader,
              fromHeader,
              toHeader,
              viaHeaders,
              maxForwardsHeader);
    } catch (ParseException e) {
      throw new IOException("Could not create the register request! " + e.getMessage());
    }

    ExpiresHeader expHeader = null;

    for (int retry = 0; retry < 2; retry++) {
      try {
        expHeader = headerFactory.createExpiresHeader(expires);
      } catch (InvalidArgumentException e) {
        if (retry == 0) {
          continue;
        }
        throw new IOException(
            "Invalid registrations expiration parameter - " + expires + " " + e.getMessage());
      }
    }

    request.addHeader(expHeader);
    ContactHeader contactHeader = getRegistrationContactHeader();
    request.addHeader(contactHeader);

    try {
      SipURI routeURI =
          (SipURI) addressFactory.createURI("sip:" + proxyCredentials.getProxy() + ";lr");
      RouteHeader routeHeader =
          headerFactory.createRouteHeader(addressFactory.createAddress(routeURI));
      request.addHeader(routeHeader);

    } catch (Exception e) {

      Log.error("Creating registration route error ", e);
    }

    ClientTransaction regTrans = null;
    try {
      regTrans = sipProvider.getNewClientTransaction(request);
    } catch (TransactionUnavailableException e) {
      throw new IOException(
          "Could not create a register transaction!\n"
              + "Check that the Registrar address is correct! "
              + e.getMessage());
    }

    try {
      sipCallId = callIdHeader.getCallId();
      sipServerCallback.addSipListener(sipCallId, this);
      registerRequest = request;
      regTrans.sendRequest();

      Log.debug("Sent register request " + registerRequest);

      if (expires > 0) {
        scheduleReRegistration();
      }
    } catch (Exception e) {
      throw new IOException("Could not send out the register request! " + e.getMessage());
    }

    this.registerRequest = request;
  }
Beispiel #4
0
  public void declareJshell(
      String dir,
      String filename,
      String[] srv,
      String[] username,
      String[] password,
      String host,
      String owner,
      String servergrp)
      throws SQLException, ClassNotFoundException, UnknownHostException {

    int count = srv.length;

    DBConnection conn = new DBConnection();
    // conn.callConnection("192.168.8.81", "d2he");
    log.info("Connecting....");
    try {
      conn.callConnection(ip, sid);
      log.info("Congrats!!! Connected!!!");
    } catch (Exception e) {
      log.info("Connection error with stack " + e.getMessage());
    }
    RunDemo[] t = new RunDemo[count];
    String filename1 = "";
    filename1 = dir + filename;
    for (int i = 0; i < count; i++) {
      t[i] = new RunDemo();
      String[] serverList = srv[i].split(",");
      String logName = filename + "_" + serverList[0] + "_log";
      String sql =
          "INSERT INTO patcheventlog(SERVERNAME,hostname,FILENAME,LOGFILE,startime,owner,servergrp,hosting) VALUES ('"
              + serverList[1]
              + "','"
              + host
              + "','"
              + filename1
              + "','"
              + dir
              + logName
              + "',SYSDATE,'"
              + owner
              + "','"
              + servergrp
              + "','"
              + serverList[0]
              + "')";
      t[i].setStr(
          "sqlplus -L "
              + username[i]
              + "/"
              + password[i]
              + "@"
              + serverList[1]
              + ":"
              + serverList[2]
              + "/"
              + serverList[3]
              + " @"
              + filename1);
      t[i].setLogName(logName);
      t[i].setDirectory(dir);
      t[i].setPatchtype("manualpatch");
      try {
        conn.UpdateQuery(sql);
        log.info("Inserted into the table data with query " + sql);
      } catch (Exception e) {
        log.info(
            "The data can't be inserted into table with " + e.getMessage() + " sql query " + sql);
      }
      new Thread(t[i]).start();
    }
  }