aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-24 01:50:16 (EST)
committerWinston Prakash2011-12-01 20:47:21 (EST)
commit3da45d7b91833e640203c83eeae8473437b539cf (patch)
tree75b66095488034e9fb97aca4d563eb94ee6ca472
parentacd3bf67afab8b2410424beae65d0382c1860fea (diff)
downloadorg.eclipse.hudson.core-3da45d7b91833e640203c83eeae8473437b539cf.zip
org.eclipse.hudson.core-3da45d7b91833e640203c83eeae8473437b539cf.tar.gz
org.eclipse.hudson.core-3da45d7b91833e640203c83eeae8473437b539cf.tar.bz2
Implement method for unlinking cascading project from parents. Improve linkCascadingProject method
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/Functions.java23
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java13
2 files changed, 25 insertions, 11 deletions
diff --git a/hudson-core/src/main/java/hudson/Functions.java b/hudson-core/src/main/java/hudson/Functions.java
index 2bca767..50fbfbf 100644
--- a/hudson-core/src/main/java/hudson/Functions.java
+++ b/hudson-core/src/main/java/hudson/Functions.java
@@ -1372,6 +1372,21 @@ public class Functions {
}
/**
+ * Recursively unlink specified project from cascading hierarchy.
+ *
+ * @param cascadingProject cascading project to start from.
+ * @param projectToUnlink project that should be unlinked.
+ */
+ public static void unlinkCascadingProject(Job cascadingProject, String projectToUnlink) {
+ if (null != cascadingProject && null != projectToUnlink) {
+ cascadingProject.removeCascadingChild(projectToUnlink);
+ if (cascadingProject.hasCascadingProject()) {
+ unlinkCascadingProject(cascadingProject.getCascadingProject(), projectToUnlink);
+ }
+ }
+ }
+
+ /**
* Links cascading project to children project. Method updates all parent cascading projects starting
* from the specified cascadingProject.
*
@@ -1381,12 +1396,10 @@ public class Functions {
@SuppressWarnings("unchecked")
public static void linkCascadingProjectsToChild(Job cascadingProject, String childProjectName){
if(cascadingProject != null){
- cascadingProject.addCascadingChildren(childProjectName);
- if(cascadingProject.getCascadingProjectName() !=null){
- linkCascadingProjectsToChild(Functions.getItemByName(Hudson.getInstance().getAllItems(cascadingProject.getClass()),
- cascadingProject.getCascadingProjectName()), childProjectName);
+ cascadingProject.addCascadingChild(childProjectName);
+ if(cascadingProject.hasCascadingProject()){
+ linkCascadingProjectsToChild(cascadingProject.getCascadingProject(), childProjectName);
}
}
}
}
-
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 9b9f69f..9d256a5 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -335,19 +335,19 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
/**
* Adds cascading child project name.
*
- * @param cascadingChildrenName cascading children project name.
+ * @param cascadingChildName cascading child project name.
*/
- public void addCascadingChildren(String cascadingChildrenName) {
- cascadingChildrenNames.add(cascadingChildrenName);
+ public void addCascadingChild(String cascadingChildName) {
+ cascadingChildrenNames.add(cascadingChildName);
}
/**
* Remove cascading child project name.
*
- * @param cascadingChildrenName cascading children project name.
+ * @param cascadingChildName cascading child project name.
*/
- public void removeCascadingChildren(String cascadingChildrenName) {
- cascadingChildrenNames.remove(cascadingChildrenName);
+ public void removeCascadingChild(String cascadingChildName) {
+ cascadingChildrenNames.remove(cascadingChildName);
}
@Override
@@ -1546,6 +1546,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* Remove cascading project data and mark all project properties as non-overridden
*/
private void clearCascadingProject() {
+ Functions.unlinkCascadingProject(cascadingProject, name);
this.cascadingProject = null;
this.cascadingProjectName = null;
for (IProjectProperty property : jobProperties.values()) {