aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-24 01:47:53 (EST)
committerWinston Prakash2011-12-01 20:47:21 (EST)
commitacd3bf67afab8b2410424beae65d0382c1860fea (patch)
tree43ae9b4806841654c05c84f55069128a06908c9a
parent91605c7703287f1962989883ed2ee288e8e21907 (diff)
downloadorg.eclipse.hudson.core-acd3bf67afab8b2410424beae65d0382c1860fea.zip
org.eclipse.hudson.core-acd3bf67afab8b2410424beae65d0382c1860fea.tar.gz
org.eclipse.hudson.core-acd3bf67afab8b2410424beae65d0382c1860fea.tar.bz2
Added cascadingChildrenNames set and appropriate methods.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/Functions.java19
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java38
2 files changed, 57 insertions, 0 deletions
diff --git a/hudson-core/src/main/java/hudson/Functions.java b/hudson-core/src/main/java/hudson/Functions.java
index e2adbe1..2bca767 100644
--- a/hudson-core/src/main/java/hudson/Functions.java
+++ b/hudson-core/src/main/java/hudson/Functions.java
@@ -1370,4 +1370,23 @@ public class Functions {
});
return templates.iterator().hasNext() ? templates.iterator().next() : null;
}
+
+ /**
+ * Links cascading project to children project. Method updates all parent cascading projects starting
+ * from the specified cascadingProject.
+ *
+ * @param cascadingProject cascadingProject.
+ * @param childProjectName the name of child project name.
+ */
+ @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);
+ }
+ }
+ }
}
+
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index be07e24..9b9f69f 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -18,6 +18,7 @@
package hudson.model;
import hudson.Functions;
+import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.hudson.api.model.project.property.AxisListProjectProperty;
import org.eclipse.hudson.api.model.project.property.BaseProjectProperty;
import org.eclipse.hudson.api.model.project.property.BooleanProjectProperty;
@@ -179,6 +180,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
private String cascadingProjectName;
/**
+ * The list with the names of children cascading projects. Required to avoid cyclic references and
+ * to prohibition parent project "delete" action in case it has cascading children projects.
+ */
+ private Set<String> cascadingChildrenNames = new CopyOnWriteArraySet<String>();
+
+ /**
* Selected cascadingProject for this job.
*/
protected transient JobT cascadingProject;
@@ -316,6 +323,33 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return (SCMProjectProperty) getProperty(key, SCMProjectProperty.class);
}
+ /**
+ * Returns list of cascading children project names.
+ *
+ * @return list of cascading children project names.
+ */
+ public Set<String> getCascadingChildrenNames() {
+ return cascadingChildrenNames;
+ }
+
+ /**
+ * Adds cascading child project name.
+ *
+ * @param cascadingChildrenName cascading children project name.
+ */
+ public void addCascadingChildren(String cascadingChildrenName) {
+ cascadingChildrenNames.add(cascadingChildrenName);
+ }
+
+ /**
+ * Remove cascading child project name.
+ *
+ * @param cascadingChildrenName cascading children project name.
+ */
+ public void removeCascadingChildren(String cascadingChildrenName) {
+ cascadingChildrenNames.remove(cascadingChildrenName);
+ }
+
@Override
public synchronized void save() throws IOException {
if (null == allowSave) {
@@ -359,6 +393,9 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
for (JobProperty p : properties)
p.setOwner(this);
+ if(cascadingChildrenNames == null){
+ cascadingChildrenNames = new CopyOnWriteArraySet<String>();
+ }
buildProjectProperties();
}
@@ -1471,6 +1508,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
this.cascadingProjectName = cascadingProjectName;
this.cascadingProject = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()),
cascadingProjectName);
+ Functions.linkCascadingProjectsToChild(cascadingProject, name);
for (IProjectProperty property : jobProperties.values()) {
if (property instanceof ExternalProjectProperty) {
property.setOverridden(((ExternalProjectProperty) property).isModified());