Пример #1
0
  private void setSvnCredential(CIJob job) throws JDOMException, IOException {
    S_LOGGER.debug("Entering Method CIManagerImpl.setSvnCredential");
    try {
      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String credentialFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CREDENTIAL_XML;
      if (debugEnabled) {
        S_LOGGER.debug("credentialFilePath ... " + credentialFilePath);
      }
      File credentialFile = new File(credentialFilePath);

      SvnProcessor processor = new SvnProcessor(credentialFile);

      //			DataInputStream in = new DataInputStream(new FileInputStream(credentialFile));
      //			while (in.available() != 0) {
      //				System.out.println(in.readLine());
      //			}
      //			in.close();

      processor.changeNodeValue("credentials/entry//userName", job.getUserName());
      processor.changeNodeValue("credentials/entry//password", job.getPassword());
      processor.writeStream(new File(Utility.getJenkinsHome() + File.separator + job.getName()));

      // jenkins home location
      String jenkinsJobHome = System.getenv(JENKINS_HOME);
      StringBuilder builder = new StringBuilder(jenkinsJobHome);
      builder.append(File.separator);

      processor.writeStream(new File(builder.toString() + CI_CREDENTIAL_XML));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into the catch block of CIManagerImpl.setSvnCredential "
              + e.getLocalizedMessage());
    }
  }
 private Document getXMLDocument(InputStream is) {
   SAXBuilder builder = new SAXBuilder();
   builder.setValidation(false);
   builder.setIgnoringElementContentWhitespace(true);
   Document doc = null;
   try {
     doc = builder.build(is);
   } catch (JDOMException e) {
     e.printStackTrace();
     System.exit(-1);
   } catch (IOException e) {
     e.printStackTrace();
     System.exit(-1);
   }
   return doc;
 }
Пример #3
0
 private void exitMenuItemWidgetSelected(SelectionEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
   getShell().dispose();
   System.exit(1);
 }
Пример #4
0
 public String getDate() {
   acctualTime = (System.currentTimeMillis() - beginTime) / 1000;
   return "Heure Virtuelle : Jour - "
       + getDay()
       + ", Heure - "
       + getHour()
       + ":"
       + getMin()
       + " ("
       + getSec()
       + ")";
 }
Пример #5
0
  private void setMailCredential(CIJob job) {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.setMailCredential");
    }
    try {
      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String mailFilePath = jenkinsTemplateDir + MAIL + HYPHEN + CREDENTIAL_XML;
      if (debugEnabled) {
        S_LOGGER.debug("configFilePath ... " + mailFilePath);
      }
      File mailFile = new File(mailFilePath);

      SvnProcessor processor = new SvnProcessor(mailFile);

      //			DataInputStream in = new DataInputStream(new FileInputStream(mailFile));
      //			while (in.available() != 0) {
      //				System.out.println(in.readLine());
      //			}
      //			in.close();

      // Mail have to go with jenkins running email address
      InetAddress ownIP = InetAddress.getLocalHost();
      processor.changeNodeValue(
          CI_HUDSONURL,
          HTTP_PROTOCOL
              + PROTOCOL_POSTFIX
              + ownIP.getHostAddress()
              + COLON
              + job.getJenkinsPort()
              + FORWARD_SLASH
              + CI
              + FORWARD_SLASH);
      processor.changeNodeValue("smtpAuthUsername", job.getSenderEmailId());
      processor.changeNodeValue("smtpAuthPassword", job.getSenderEmailPassword());
      processor.changeNodeValue("adminAddress", job.getSenderEmailId());

      // jenkins home location
      String jenkinsJobHome = System.getenv(JENKINS_HOME);
      StringBuilder builder = new StringBuilder(jenkinsJobHome);
      builder.append(File.separator);

      processor.writeStream(new File(builder.toString() + CI_MAILER_XML));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into the catch block of CIManagerImpl.setMailCredential "
              + e.getLocalizedMessage());
    }
  }
Пример #6
0
  public static void main(String[] args) {
    try {

      if (args.length != 3) {
        System.out.println("Usage: Coma-file CMDI-file XSLT-file");
      }
      Coma2CMDI transformer = new Coma2CMDI(args[0], args[1], args[2]);
      transformer.transform();
      System.exit(0);

    } catch (JDOMException ex) {
      Logger.getLogger(AddRecordingDurationsInComa.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
      Logger.getLogger(AddRecordingDurationsInComa.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Пример #7
0
 private Element mkTimeStampXML() {
   nanotime = System.currentTimeMillis();
   Element timestamp = new Element("timestamp").setText(Long.toString(nanotime));
   return timestamp;
 }
Пример #8
0
/**
 * Title:
 *
 * <p>Description:
 *
 * <p>Copyright: Copyright (c) 2004
 *
 * <p>Company: Pansoft
 *
 * @author Stephen Zhao
 * @version 1.0
 */
public class JCStoreManager {
  /** 常量 */
  private static final String FILE_NAME = "LocalRptCobj.xml";

  private static final String FILE_PATH =
      System.getProperty("user.home") + File.separator + "pansoft" + File.separator + FILE_NAME;

  private JCStoreTableModel mModel = new JCStoreTableModel();
  /** */
  public JCStoreManager() {
    load();
  }

  /** */
  public JCStoreTableModel getModel() {
    return mModel;
  }

  /** @param model */
  public void setModel(JCStoreTableModel model) {
    if (model != null) {
      mModel = model;
    }
  }

  /**
   * @param name
   * @param exp
   */
  public void addExpression(String name, JCExpression exp) {
    if (name != null && exp != null) {
      mModel.addExpression(name, exp);
    }
  }

  /**
   * @param id
   * @return
   */
  public JCExpression getExpression(String id) {
    if (id != null) {
      return mModel.getExpression(id);
    }
    return null;
  }

  /** @param name */
  public void removeExpression(String id) {
    if (id != null) {
      mModel.removeExpressioin(id);
    }
  }

  /** */
  public void save() {
    try {
      if (mModel != null) {
        JXMLBaseObject cobjXmlObj = mModel.toXml();
        String dataStr = cobjXmlObj.GetRootXMLString();
        FileOutputStream FOS = new FileOutputStream(FILE_PATH);
        FOS.write(dataStr.getBytes());
        FOS.flush();
        FOS.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  /** */
  public boolean load() {
    try {
      if (new File(FILE_PATH).exists()) {
        FileInputStream FIS = new FileInputStream(FILE_PATH);
        JXMLBaseObject cobjXmlObj = new JXMLBaseObject();
        cobjXmlObj.InitXMLStream(FIS);
        FIS.close();

        Vector exps = new Vector();
        Element rootElmt = cobjXmlObj.GetElementByName(JCStoreTableModel.ROOT_NAME);
        for (Iterator i = rootElmt.getChildren().iterator(); i.hasNext(); ) {
          Element crtElmt = (Element) i.next();
          JCExpression exp = new JCExpression();
          exp.mId = crtElmt.getAttributeValue("id", "");
          exp.mName = crtElmt.getAttributeValue("name", "");
          exp.mShowValue = crtElmt.getAttributeValue("show", "");
          exp.mStoreValue = crtElmt.getAttributeValue("store", "");
          exps.add(exp);
        }
        if (mModel != null) {
          mModel.setExpression(exps);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }
}
Пример #9
0
 public String getTimeXML() {
   acctualTime = (System.currentTimeMillis() - beginTime) / 1000;
   Document doc = getDoc();
   String xml = xmlToString(doc);
   return xml;
 }
Пример #10
0
 public Isotime() {
   beginTime = System.currentTimeMillis();
   System.out.println(getDate());
   // start();
 }