Пример #1
0
 private void writeJsonJobs(ApplicationInfo appInfo, List<CIJob> jobs, String status)
     throws PhrescoException {
   try {
     if (jobs == null) {
       return;
     }
     Gson gson = new Gson();
     List<CIJob> existingJobs = getJobs(appInfo);
     if (CI_CREATE_NEW_JOBS.equals(status) || existingJobs == null) {
       existingJobs = new ArrayList<CIJob>();
     }
     existingJobs.addAll(jobs);
     FileWriter writer = null;
     File ciJobFile = new File(getCIJobPath(appInfo));
     String jobJson = gson.toJson(existingJobs);
     writer = new FileWriter(ciJobFile);
     writer.write(jobJson);
     writer.flush();
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
Пример #2
0
 private boolean adaptExistingJobs(ApplicationInfo appInfo) {
   try {
     CIJob existJob = getJob(appInfo);
     S_LOGGER.debug("Going to get existing jobs to relocate!!!!!");
     if (existJob != null) {
       S_LOGGER.debug("Existing job found " + existJob.getName());
       boolean deleteExistJob = deleteCIJobFile(appInfo);
       Gson gson = new Gson();
       List<CIJob> existingJobs = new ArrayList<CIJob>();
       existingJobs.addAll(Arrays.asList(existJob));
       FileWriter writer = null;
       File ciJobFile = new File(getCIJobPath(appInfo));
       String jobJson = gson.toJson(existingJobs);
       writer = new FileWriter(ciJobFile);
       writer.write(jobJson);
       writer.flush();
       S_LOGGER.debug("Existing job moved to new type of project!!");
     }
     return true;
   } catch (Exception e) {
     S_LOGGER.debug("It is already adapted !!!!! ");
   }
   return false;
 }