Exemplo n.º 1
0
  private void deleteUnwantedJobs(OctopusCollector collector) {

    List<OctopusApplication> deleteAppList = new ArrayList<>();
    Set<ObjectId> udId = new HashSet<>();
    udId.add(collector.getId());
    //		for (OctopusApplication app : octopusApplicationRepository.findByCollectorIdIn(udId)) {
    //			//            if (!collector.getUdeployServers().contains(app.getInstanceUrl()) ||
    //			//                    (!app.getCollectorId().equals(collector.getId()))) {
    //			//                deleteAppList.add(app);
    //			//            }
    //		}

    octopusApplicationRepository.delete(deleteAppList);
  }
Exemplo n.º 2
0
 /**
  * Clean up unused deployment collector items
  *
  * @param collector the {@link UDeployCollector}
  */
 @SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
 private void clean(OctopusCollector collector) {
   deleteUnwantedJobs(collector);
   Set<ObjectId> uniqueIDs = new HashSet<>();
   for (com.capitalone.dashboard.model.Component comp : dbComponentRepository.findAll()) {
     if (comp.getCollectorItems() == null || comp.getCollectorItems().isEmpty()) continue;
     List<CollectorItem> itemList = comp.getCollectorItems().get(CollectorType.Deployment);
     if (itemList == null) continue;
     for (CollectorItem ci : itemList) {
       if (ci == null) continue;
       uniqueIDs.add(ci.getId());
     }
   }
   List<OctopusApplication> appList = new ArrayList<>();
   Set<ObjectId> udId = new HashSet<>();
   udId.add(collector.getId());
   for (OctopusApplication app : octopusApplicationRepository.findByCollectorIdIn(udId)) {
     if (app != null) {
       app.setEnabled(uniqueIDs.contains(app.getId()));
       appList.add(app);
     }
   }
   octopusApplicationRepository.save(appList);
 }
Exemplo n.º 3
0
  private void addNewApplications(
      List<OctopusApplication> applications, OctopusCollector collector) {
    long start = System.currentTimeMillis();
    int count = 0;

    log("All apps", start, applications.size());
    for (OctopusApplication application : applications) {

      if (isNewApplication(collector, application)) {
        application.setCollectorId(collector.getId());
        application.setEnabled(false);
        application.setDescription(application.getApplicationName());
        try {
          octopusApplicationRepository.save(application);
        } catch (org.springframework.dao.DuplicateKeyException ce) {
          log("Duplicates items not allowed", 0);
        }
        count++;
      }
    }
    log("New apps", start, count);
  }
Exemplo n.º 4
0
 private List<OctopusApplication> enabledApplications(
     OctopusCollector collector, String instanceUrl) {
   return octopusApplicationRepository.findEnabledApplications(collector.getId(), instanceUrl);
 }
Exemplo n.º 5
0
 private boolean isNewApplication(OctopusCollector collector, OctopusApplication application) {
   return octopusApplicationRepository.findUDeployApplication(
           collector.getId(), octopusSettings.getUrl(), application.getApplicationId())
       == null;
 }