aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-21 03:27:00 (EST)
committerWinston Prakash2011-12-01 20:46:47 (EST)
commit11c04674ce6323043e685db1d67618263d4858ed (patch)
tree79a90e685d9bf955617201440f2ba021af01771a
parent3370d67d0b13abead11b2f116971d0fa6b20c704 (diff)
downloadorg.eclipse.hudson.core-11c04674ce6323043e685db1d67618263d4858ed.zip
org.eclipse.hudson.core-11c04674ce6323043e685db1d67618263d4858ed.tar.gz
org.eclipse.hudson.core-11c04674ce6323043e685db1d67618263d4858ed.tar.bz2
Implement common interfaces for Job, AbstractProject, FreeStyleProject
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/FreeStyleProject.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/IAbstractProject.java123
-rw-r--r--hudson-core/src/main/java/hudson/model/IFreeStyleProject.java32
-rw-r--r--hudson-core/src/main/java/hudson/model/IJob.java51
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java2
6 files changed, 209 insertions, 3 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 0e43d43..2b985d3 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -111,7 +111,7 @@ import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
* @author Kohsuke Kawaguchi
* @see AbstractBuild
*/
-public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Job<P,R> implements BuildableItem {
+public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Job<P,R> implements BuildableItem, IAbstractProject {
/**
* {@link SCM} associated with the project.
diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
index dca60ca..af15e55 100644
--- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java
@@ -31,7 +31,7 @@ import javax.servlet.ServletException;
*
* @author Kohsuke Kawaguchi
*/
-public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem {
+public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> implements TopLevelItem, IFreeStyleProject {
/**
* See {@link #setCustomWorkspace(String)}.
*
diff --git a/hudson-core/src/main/java/hudson/model/IAbstractProject.java b/hudson-core/src/main/java/hudson/model/IAbstractProject.java
new file mode 100644
index 0000000..147c8e2
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/model/IAbstractProject.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ *
+ * Copyright (c) 2011 Oracle Corporation.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Nikita Levyankov
+ *
+ *******************************************************************************/
+package hudson.model;
+
+import hudson.scm.SCM;
+import hudson.triggers.Trigger;
+import hudson.triggers.TriggerDescriptor;
+import java.util.Map;
+
+/**
+ * Interface that reflects common methods for AbstractProject model
+ * <p/>
+ * Date: 9/15/11
+ *
+ * @author Nikita Levyankov
+ */
+public interface IAbstractProject extends IJob {
+ /**
+ * Returns template name if project based on template, null otherwise..
+ *
+ * @return template name.
+ */
+ String getTemplateName();
+
+ /**
+ * Returns configured SCM for project,
+ *
+ * @return {@link SCM} instance
+ */
+ SCM getScm();
+
+ /**
+ * Returns map of triggers.
+ *
+ * @return {@link Map}.
+ */
+ Map<TriggerDescriptor, Trigger> getTriggers();
+
+ /**
+ * Gets the specific trigger, should be null if the property is not configured for this job.
+ *
+ * @param clazz class of trigger
+ * @return T
+ */
+ <T extends Trigger> T getTrigger(Class<T> clazz);
+
+ /**
+ * Checks whether workspace should be cleaned before build
+ *
+ * @return boolean value
+ */
+ boolean isCleanWorkspaceRequired();
+
+ /**
+ * Indicates whether build should be blocked while downstream project is building.
+ *
+ * @return true if yes, false - otherwise.
+ */
+ boolean blockBuildWhenDownstreamBuilding();
+
+ /**
+ * Indicates whether build should be blocked while upstream project is building.
+ *
+ * @return true if yes, false - otherwise.
+ */
+ boolean blockBuildWhenUpstreamBuilding();
+
+ /**
+ * Checks whether scmRetryCount is configured
+ *
+ * @return true if yes, false - otherwise.
+ */
+ boolean hasCustomScmCheckoutRetryCount();
+
+ /**
+ * Returns scm checkout retry count.
+ *
+ * @return int value.
+ */
+ int getScmCheckoutRetryCount();
+
+ /**
+ * Returns project quiet period.
+ *
+ * @return int value.
+ */
+ int getQuietPeriod();
+
+ /**
+ * If this project is configured to be always built on this node,
+ * return that {@link Node}. Otherwise null.
+ *
+ * @return {@link Label} instance.
+ */
+ Label getAssignedLabel();
+
+ /**
+ * Gets the textual representation of the assigned label as it was entered by the user.
+ *
+ * @return string
+ */
+ String getAssignedLabelString();
+
+ /**
+ * Gets whether this project is using the advanced affinity chooser UI.
+ *
+ * @return true - advanced chooser, false - simple textfield.
+ */
+ //TODO this method is UI only. Investigate how-to remove it from model.
+ boolean isAdvancedAffinityChooser();
+}
diff --git a/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java b/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
new file mode 100644
index 0000000..06795e6
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ *
+ * Copyright (c) 20011 Oracle Corporation.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Nikita Levyankov
+ *
+ *******************************************************************************/
+package hudson.model;
+
+/**
+ * FreeStyle project interface.
+ * <p/>
+ * Date: 9/15/11
+ *
+ * @author Nikita Levyankov
+ */
+public interface IFreeStyleProject extends IAbstractProject {
+
+ /**
+ * Returns user-specified workspace directory, or null if it's up to Hudson
+ *
+ * @return string representation of directory.
+ */
+ String getCustomWorkspace();
+}
diff --git a/hudson-core/src/main/java/hudson/model/IJob.java b/hudson-core/src/main/java/hudson/model/IJob.java
new file mode 100644
index 0000000..c7f4c49
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/model/IJob.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ *
+ * Copyright (c) 20011 Oracle Corporation.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Nikita Levyankov
+ *
+ *******************************************************************************/
+package hudson.model;
+
+import hudson.tasks.LogRotator;
+import java.util.Map;
+
+/**
+ * Interface that represents Job.
+ * <p/>
+ * Date: 9/15/11
+ *
+ * @author Nikita Levyankov
+ */
+public interface IJob<T> {
+ /**
+ * @return whether the name of this job can be changed by user.
+ */
+ boolean isNameEditable();
+
+ /**
+ * Returns the log rotator for this job, or null if none.
+ *
+ * @return {@link LogRotator} instance.
+ */
+ LogRotator getLogRotator();
+
+ /**
+ * @return true if this instance supports log rotation configuration.
+ */
+ boolean supportsLogRotator();
+
+ /**
+ * Gets all the job properties configured for this job.
+ *
+ * @return Map of properties.
+ */
+ Map<JobPropertyDescriptor, JobProperty<?>> getProperties();
+}
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index c2f56fc..c5a4efa 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -102,7 +102,7 @@ import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
* @author Nikita Levyankov
*/
public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, RunT>>
- extends AbstractItem implements ExtensionPoint, StaplerOverridable {
+ extends AbstractItem implements ExtensionPoint, StaplerOverridable, IJob {
private static transient final String HUDSON_BUILDS_PROPERTY_KEY = "HUDSON_BUILDS";
/**
* Next build number. Kept in a separate file because this is the only