Skip to content
Permalink
Browse files

Merge pull request #2 from jglick/RunAction2-JENKINS-20950

[JENKINS-20950] Use RunAction2
  • Loading branch information
rsandell committed Dec 13, 2013
2 parents 2842fd9 + 9bd3d38 commit 60e54b20648e205cff20cb5fd154b81ea827813c
@@ -3,9 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version>
<!-- which version of Jenkins is this plugin built against? -->
<relativePath>pom.xml</relativePath>
<version>1.509.3</version>
</parent>

<groupId>com.sonyericsson.hudson.plugins.metadata</groupId>
@@ -168,7 +168,7 @@ public int httpStatus() {
if (action != null) {
container = action;
} else if (createContainer) {
action = new MetadataBuildAction(buildByNumber);
action = new MetadataBuildAction();
buildByNumber.addAction(action);
container = action;
} else {
@@ -55,7 +55,7 @@ public void onCompleted(AbstractBuild build, TaskListener listener) {
logger.entering(BuildContributorsController.class.getName(), "onCompleted({0})", build);
MetadataBuildAction action = build.getAction(MetadataBuildAction.class);
if (action == null) {
action = new MetadataBuildAction(build);
action = new MetadataBuildAction();
build.addAction(action);
}
listener.getLogger().println(Messages.BuildContributorsController_LogMessage_Collecting());
@@ -91,7 +91,7 @@ public void onStarted(AbstractBuild build, TaskListener listener) {
}
MetadataBuildAction action = build.getAction(MetadataBuildAction.class);
if (action == null) {
action = new MetadataBuildAction(build);
action = new MetadataBuildAction();
build.addAction(action);
}

@@ -28,7 +28,6 @@
import com.sonyericsson.hudson.plugins.metadata.Messages;
import com.sonyericsson.hudson.plugins.metadata.model.values.MetadataValue;
import com.sonyericsson.hudson.plugins.metadata.model.values.ParentUtil;
import hudson.model.Action;
import hudson.model.Hudson;
import hudson.model.Run;
import hudson.security.ACL;
@@ -38,6 +37,7 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import jenkins.model.RunAction2;

/**
* Holds the meta data for a run.
@@ -47,17 +47,12 @@
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value = "UG_SYNC_SET_UNSYNC_GET",
justification = "It is synchronized")
public class MetadataBuildAction implements Action, MetadataContainer<MetadataValue> {
public class MetadataBuildAction implements RunAction2, MetadataContainer<MetadataValue> {

private Run run;
private transient Run run;
private List<MetadataValue> values;

/**
* Standard constructor.
*
* @param run The run that this action is added to.
* @param values the meta data for this run.
*/
@Deprecated
public MetadataBuildAction(Run run, List<MetadataValue> values) {
this.run = run;
if (values == null) {
@@ -66,11 +61,7 @@ public MetadataBuildAction(Run run, List<MetadataValue> values) {
this.values = values;
}

/**
* Standard constructor.
*
* @param run The run that this action is added to.
*/
@Deprecated
public MetadataBuildAction(Run run) {
this(run, null);
}
@@ -97,6 +88,16 @@ public String getUrlName() {
return Constants.COMMON_URL_NAME;
}

@Override
public void onAttached(Run<?,?> r) {
this.run = r;
}

@Override
public void onLoad(Run<?,?> r) {
this.run = r;
}

/**
* The run that this action is added to.
*
@@ -363,7 +363,6 @@ public void testGetContainerNoMetadataOnBuildCreate() throws Exception {

MetadataParent container = CliUtils.getContainer(null, "theJob", 1, true);
assertNotNull(container);
assertSame(build, Whitebox.getInternalState(container, "run"));
verify(build).addAction(isA(MetadataBuildAction.class));
}

@@ -94,7 +94,7 @@ public void testFilterACL() throws Exception {
hudson.addView(view);

WebClient web = createWebClient();
Page page = web.goTo("/view/Test/api/json", "application/javascript");
Page page = web.goTo("/view/Test/api/json", "application/json");
JSONObject json = (JSONObject)JSONSerializer.toJSON(page.getWebResponse().getContentAsString());
//Just to test that we can find both in an open installation.
assertTrue(json.has("jobs"));
@@ -108,7 +108,7 @@ public void testFilterACL() throws Exception {
web = createWebClient();
web = web.login("testuser");

page = web.goTo("/view/Test/api/json", "application/javascript");
page = web.goTo("/view/Test/api/json", "application/json");
json = (JSONObject)JSONSerializer.toJSON(page.getWebResponse().getContentAsString());
//Does it still applies to secured projects?
assertTrue(json.has("jobs"));

0 comments on commit 60e54b2

Please sign in to comment.
You can’t perform that action at this time.