예제 #1
1
 private CIJobStatus deleteCI(CIJob job, List<String> builds) throws PhrescoException {
   S_LOGGER.debug("Entering Method CIManagerImpl.deleteCI(CIJob job)");
   S_LOGGER.debug("Job name " + job.getName());
   cli = getCLI(job);
   String deleteType = null;
   List<String> argList = new ArrayList<String>();
   S_LOGGER.debug("job name " + job.getName());
   S_LOGGER.debug("Builds " + builds);
   if (CollectionUtils.isEmpty(builds)) { // delete job
     S_LOGGER.debug("Job deletion started");
     S_LOGGER.debug("Command " + FrameworkConstants.CI_JOB_DELETE_COMMAND);
     deleteType = DELETE_TYPE_JOB;
     argList.add(FrameworkConstants.CI_JOB_DELETE_COMMAND);
     argList.add(job.getName());
   } else { // delete Build
     S_LOGGER.debug("Build deletion started");
     deleteType = DELETE_TYPE_BUILD;
     argList.add(FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     argList.add(job.getName());
     StringBuilder result = new StringBuilder();
     for (String string : builds) {
       result.append(string);
       result.append(",");
     }
     String buildNos = result.substring(0, result.length() - 1);
     argList.add(buildNos);
     S_LOGGER.debug("Command " + FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     S_LOGGER.debug("Build numbers " + buildNos);
   }
   try {
     int status = cli.execute(argList);
     String message = deleteType + " deletion started in jenkins";
     if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
       deleteType = deleteType.substring(0, 1).toLowerCase() + deleteType.substring(1);
       message = "Error while deleting " + deleteType + " in jenkins";
     }
     S_LOGGER.debug("Delete CI Status " + status);
     S_LOGGER.debug("Delete CI Message " + message);
     return new CIJobStatus(status, message);
   } finally {
     if (cli != null) {
       try {
         cli.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       } catch (InterruptedException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       }
     }
   }
 }
예제 #2
0
  /** Reads the view from the specified uri. */
  @Override
  public void read(URI f, URIChooser chooser) throws IOException {
    try {
      final Drawing drawing = createDrawing();
      InputFormat inputFormat = drawing.getInputFormats().get(0);
      inputFormat.read(f, drawing, true);
      SwingUtilities.invokeAndWait(
          new Runnable() {

            @Override
            public void run() {
              view.getDrawing().removeUndoableEditListener(undo);
              view.setDrawing(drawing);
              view.getDrawing().addUndoableEditListener(undo);
              undo.discardAllEdits();
            }
          });
    } catch (InterruptedException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    } catch (InvocationTargetException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    }
  }
예제 #3
0
  private CIJobStatus buildJob(CIJob job) throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.buildJob(CIJob job)");
    }
    cli = getCLI(job);

    List<String> argList = new ArrayList<String>();
    argList.add(FrameworkConstants.CI_BUILD_JOB_COMMAND);
    argList.add(job.getName());
    try {
      int status = cli.execute(argList);
      String message = FrameworkConstants.CI_BUILD_STARTED;
      if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
        message = FrameworkConstants.CI_BUILD_STARTING_ERROR;
      }
      return new CIJobStatus(status, message);
    } finally {
      if (cli != null) {
        try {
          cli.close();
        } catch (IOException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        } catch (InterruptedException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        }
      }
    }
  }
예제 #4
0
 private void grabPixels(PixelGrabber grabber) {
   try {
     grabber.grabPixels();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   // if (grabber.getColorModel() != ColorModel.getRGBdefault()) {
   //	System.err.println("Warning: found other colormodel than default.");
   // }
 }
예제 #5
0
 public static void ensureLoaded(Image img) throws Exception {
   // System.err.println("In ensureloaded");
   mediatracker.addImage(img, 0);
   try {
     mediatracker.waitForAll();
     if (mediatracker.getErrorsAny() != null) {
       mediatracker.removeImage(img);
       throw new Exception("Error loading image");
     }
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   mediatracker.removeImage(img);
   // System.err.println("Out ensureloaded");
 }
예제 #6
0
  /** Clears the view. */
  @Override
  public void clear() {
    final Drawing newDrawing = createDrawing();
    try {
      SwingUtilities.invokeAndWait(
          new Runnable() {

            @Override
            public void run() {
              view.getDrawing().removeUndoableEditListener(undo);
              view.setDrawing(newDrawing);
              view.getDrawing().addUndoableEditListener(undo);
              undo.discardAllEdits();
            }
          });
    } catch (InvocationTargetException ex) {
      ex.printStackTrace();
    } catch (InterruptedException ex) {
      ex.printStackTrace();
    }
  }
예제 #7
0
  private CIJobStatus configureJob(CIJob job, String jobType) throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.createJob(CIJob job)");
    }
    try {
      cli = getCLI(job);
      List<String> argList = new ArrayList<String>();
      argList.add(jobType);
      argList.add(job.getName());

      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String configFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CONFIG_XML;
      if (debugEnabled) {
        S_LOGGER.debug("configFilePath ...  " + configFilePath);
      }

      File configFile = new File(configFilePath);
      ConfigProcessor processor = new ConfigProcessor(configFile);
      customizeNodes(processor, job);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      if (debugEnabled) {
        S_LOGGER.debug("argList " + argList.toString());
      }
      int result = cli.execute(argList, processor.getConfigAsStream(), System.out, baos);

      String message = "Job created successfully";
      if (result == -1) {
        byte[] byteArray = baos.toByteArray();
        message = new String(byteArray);
      }
      if (debugEnabled) {
        S_LOGGER.debug("message " + message);
      }
      // when svn is selected credential value has to set
      if (SVN.equals(job.getRepoType())) {
        setSvnCredential(job);
      }

      setMailCredential(job);
      return new CIJobStatus(result, message);
    } catch (IOException e) {
      throw new PhrescoException(e);
    } catch (JDOMException e) {
      throw new PhrescoException(e);
    } finally {
      if (cli != null) {
        try {
          cli.close();
        } catch (IOException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        } catch (InterruptedException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        }
      }
    }
  }