@Override public void execute(JobExecutionContext context) throws JobExecutionException { VerigreenLogger.get() .log( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format( "Branch Cleaner is running, deleting branches %s days old...", VerigreenNeededLogic.VerigreenMap.get("branchCleanDaysThreashold"))); deleteBranches(); }
@Override public void execute(JobExecutionContext arg0) throws JobExecutionException { VerigreenLogger.get() .log( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format( "Cache Cleaner is running, deleting items %s days old...", VerigreenNeededLogic.VerigreenMap.get("daysThreashold"))); deleteCommitItems(); }
protected void send(String subject, String messageText, String[] recipients, String signature) { try { EmailUtils.send( subject, messageText, recipients, "*****@*****.**", _mailServer, signature); } catch (MessagingException ex) { VerigreenLogger.get() .error( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format( "Failed sending email message [%s] to the following recipients: %s", messageText, Arrays.toString(recipients)), ex); } }
private List<String> branchesToBeDelete(List<String> branchesList) { List<String> result = new ArrayList<>(); Repository repo = null; Map<String, List<String>> branchesMap = new HashMap<>(); for (String branch : branchesList) { List<String> values = null; if (!branchesMap.containsKey(branch.subSequence(0, 10))) { values = new ArrayList<>(); values.add(branch); branchesMap.put(branch.subSequence(0, 10).toString(), values); } else if (!branchesMap.get(branch.subSequence(0, 10)).contains(branch)) { values = branchesMap.get(branch.subSequence(0, 10)); values.add(branch); branchesMap.put(branch.subSequence(0, 10).toString(), values); } } List<CommitItem> allBranches = CollectorApi.getCommitItemContainer().getAll(); for (CommitItem branch : allBranches) { if (branchesMap.containsKey(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10))) { branchesMap.remove(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10)); } } for (String key : branchesMap.keySet()) { result.addAll(branchesMap.get(key)); } try { repo = new FileRepository(VerigreenNeededLogic.properties.getProperty("git.repositoryLocation")); if (result.contains(repo.getBranch())) { _jgit.checkout(VerigreenNeededLogic.VerigreenMap.get("_protectedBranches"), false, false); } } catch (IOException e) { VerigreenLogger.get() .error( getClass().getName(), RuntimeUtils.getCurrentMethodName(), String.format( "Failed creating git repository for path [%s]", VerigreenNeededLogic.properties.getProperty("git.repositoryLocation")), e); } return result; }
public static CreateBranchRequest getCreateBranchRequest(BranchDescriptor branchDescriptor) { return RuntimeUtils.cast( getBean("createBranchRequest", CollectorApi.getCollectorAddress(), branchDescriptor)); }