aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-25 02:37:06 (EST)
committerWinston Prakash2011-12-01 20:47:33 (EST)
commit69e40b63fa40f4c7ae3301950b7acb7700ee0349 (patch)
treebec329d3a12036fe7fb426dfe9e67907041dc83c
parent933e807d16ee302fae29dde40a31718a1fa7063f (diff)
downloadorg.eclipse.hudson.core-69e40b63fa40f4c7ae3301950b7acb7700ee0349.zip
org.eclipse.hudson.core-69e40b63fa40f4c7ae3301950b7acb7700ee0349.tar.gz
org.eclipse.hudson.core-69e40b63fa40f4c7ae3301950b7acb7700ee0349.tar.bz2
A few fixes.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/BaseBuildableProject.java6
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java15
-rw-r--r--hudson-core/src/main/java/hudson/util/CascadingUtil.java31
3 files changed, 34 insertions, 18 deletions
diff --git a/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java b/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
index f6dd8c4..64d2376 100644
--- a/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
+++ b/hudson-core/src/main/java/hudson/model/BaseBuildableProject.java
@@ -193,14 +193,12 @@ public abstract class BaseBuildableProject<P extends BaseBuildableProject<P,B>,B
/**
* Removes a publisher from this project, if it's active.
*
- * @deprecated as of 1.290
- * Use {@code getPublishersList().remove(x)}
* @param publisher publisher.
* @throws java.io.IOException exception.
*/
- //TODO investigate, whether we can move this method to parent or completer remove it
public void removePublisher(Descriptor<Publisher> publisher) throws IOException {
- getPublishersList().remove(publisher);
+ removeProjectProperty(publisher.getJsonSafeClassName());
+ save();
}
/**
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index dedf882..849bf1f 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -235,11 +235,26 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
}
}
+ /**
+ * Returns project properties.
+ *
+ * @return project properties.
+ */
+ @SuppressWarnings({"unchecked"})
public Map<String, IProjectProperty> getProjectProperties() {
return MapUtils.unmodifiableMap(jobProperties);
}
/**
+ * Removes project property.
+ *
+ * @param key property key.
+ */
+ public void removeProjectProperty(String key){
+ jobProperties.remove(key);
+ }
+
+ /**
* Put map of job properties to existing ones.
*
* @param projectProperties new properties map.
diff --git a/hudson-core/src/main/java/hudson/util/CascadingUtil.java b/hudson-core/src/main/java/hudson/util/CascadingUtil.java
index 22b822e..d62c590 100644
--- a/hudson-core/src/main/java/hudson/util/CascadingUtil.java
+++ b/hudson-core/src/main/java/hudson/util/CascadingUtil.java
@@ -64,7 +64,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link import org.eclipse.hudson.api.model.IProjectProperty} instance or null.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static IProjectProperty getProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, null);
@@ -77,7 +77,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.StringProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static StringProjectProperty getStringProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, StringProjectProperty.class);
@@ -90,7 +90,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.BaseProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static BaseProjectProperty getBaseProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, BaseProjectProperty.class);
@@ -103,7 +103,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.ExternalProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static ExternalProjectProperty getExternalProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, ExternalProjectProperty.class);
@@ -116,7 +116,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.CopyOnWriteListProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static CopyOnWriteListProjectProperty getCopyOnWriteListProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, CopyOnWriteListProjectProperty.class);
@@ -129,7 +129,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.ResultProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static ResultProjectProperty getResultProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, ResultProjectProperty.class);
@@ -142,7 +142,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.BooleanProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static BooleanProjectProperty getBooleanProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, BooleanProjectProperty.class);
@@ -155,7 +155,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.IntegerProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static IntegerProjectProperty getIntegerProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, IntegerProjectProperty.class);
@@ -168,7 +168,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.LogRotatorProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static LogRotatorProjectProperty getLogRotatorProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, LogRotatorProjectProperty.class);
@@ -181,7 +181,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.DescribableListProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static DescribableListProjectProperty getDescribableListProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, DescribableListProjectProperty.class);
@@ -194,7 +194,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.AxisListProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static AxisListProjectProperty getAxesListProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, AxisListProjectProperty.class);
@@ -207,7 +207,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.SCMProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static SCMProjectProperty getScmProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, SCMProjectProperty.class);
@@ -220,7 +220,7 @@ public class CascadingUtil {
* @param currentJob job that should be analyzed.
* @param key key.
* @return {@link org.eclipse.hudson.api.model.project.property.TriggerProjectProperty} instance.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
public static TriggerProjectProperty getTriggerProjectProperty(Job currentJob, String key) {
return getProjectProperty(currentJob, key, TriggerProjectProperty.class);
@@ -234,10 +234,13 @@ public class CascadingUtil {
* @param clazz required property class.
* If class is not null and property was not found, property of given class will be created.
* @return {@link org.eclipse.hudson.api.model.IProjectProperty} instance or null.
- * @throws NullPointerException if currentJob is null.
+ * @throws IllegalArgumentException if currentJob is null.
*/
@SuppressWarnings("unchecked")
public static <T extends IProjectProperty> T getProjectProperty(Job currentJob, String key, Class<T> clazz) {
+ if(currentJob == null){
+ throw new IllegalArgumentException("Job cannot be null");
+ }
IProjectProperty t = (IProjectProperty) currentJob.getProjectProperties().get(key);
if (null == t && null != clazz) {
try {