-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from daniel-beck/SECURITY-3033
[SECURITY-3033] Submit POST requests as needed
- Loading branch information
Showing
9 changed files
with
250 additions
and
220 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
src/main/java/com/sonyericsson/hudson/plugins/rebuild/Root.java
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
src/main/java/com/sonyericsson/rebuild/AbstractRebuildAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.sonyericsson.rebuild; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import hudson.matrix.MatrixRun; | ||
import hudson.model.Action; | ||
import hudson.model.Item; | ||
import hudson.model.Job; | ||
import hudson.model.Queue; | ||
import hudson.model.Run; | ||
|
||
public abstract class AbstractRebuildAction implements Action { | ||
|
||
@Override | ||
public String getIconFileName() { | ||
if (isRebuildAvailable()) { | ||
return "clock.png"; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Method for checking whether the rebuild functionality would be available | ||
* for build. | ||
* | ||
* @return boolean | ||
*/ | ||
public boolean isRebuildAvailable() { | ||
Job project = getProject(); | ||
return project != null | ||
&& project.hasPermission(Item.BUILD) | ||
&& project.isBuildable() | ||
&& project instanceof Queue.Task | ||
&& !isMatrixRun() | ||
&& !isRebuildDisabled(); | ||
|
||
} | ||
|
||
// Jelly | ||
public abstract String getTaskUrl(); | ||
|
||
// Jelly | ||
public abstract boolean isRequiresPOST(); | ||
|
||
private boolean isRebuildDisabled() { | ||
RebuildSettings settings = getProject().getProperty(RebuildSettings.class); | ||
return settings != null && settings.getRebuildDisabled(); | ||
} | ||
|
||
/** | ||
* Method will return current project. | ||
* | ||
* @return currentProject. | ||
*/ | ||
public abstract Job<?, ?> getProject(); | ||
|
||
@CheckForNull | ||
protected abstract Run<?, ?> getRun(); | ||
|
||
/** | ||
* Method for checking whether current build is sub job(MatrixRun) of Matrix | ||
* build. | ||
* | ||
* @return boolean | ||
*/ | ||
public boolean isMatrixRun() { | ||
return getRun() instanceof MatrixRun; | ||
} | ||
} |
Oops, something went wrong.