tweaking the abstraction a bit so that this can be used not just with Build but all the other Actionable objects

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7729 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-03-14 06:05:43 +00:00
1 parent 35362e9dab
commit 3e8750699e
5 files changed
+27 -5

No files matched your search

@@ -13,6 +13,7 @@ import hudson.model.TaskThread;
import hudson.model.BuildBadgeAction;
import hudson.model.TaskThread.ListenerAndText;
import hudson.security.Permission;
import hudson.security.ACL;
import hudson.util.Iterators;
import hudson.widgets.HistoryWidget;
import hudson.widgets.HistoryWidget.Adapter;
@@ -121,6 +122,10 @@ public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>>
*/
public abstract T getBuild();
protected ACL getACL() {
return getBuild().getACL();
}
public final String getIconFileName() {
return "redo.gif";
}
@@ -156,7 +161,7 @@ public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>>
@QueryParameter("redeploy.id") final String id,
@QueryParameter("redeploy.url") final String repositoryUrl,
@QueryParameter("redeploy.uniqueVersion") final boolean uniqueVersion) throws ServletException, IOException {
getBuild().checkPermission(REDEPLOY);
getACL().checkPermission(REDEPLOY);
File logFile = new File(getBuild().getRootDir(),"maven-deployment."+records.size()+".log");
final Record record = new Record(repositoryUrl, logFile.getName());
+6 -1
View File
@@ -11,6 +11,7 @@ import static hudson.Util.combine;
import hudson.XmlFile;
import hudson.security.Permission;
import hudson.security.PermissionGroup;
import hudson.security.ACL;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
import hudson.model.listeners.RunListener;
@@ -568,8 +569,12 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
}
public void checkPermission(Permission p) {
getACL().checkPermission(p);
}
public ACL getACL() {
// for now, don't maintain ACL per run, and do it at project level
getParent().checkPermission(p);
return getParent().getACL();
}
/**
@@ -9,6 +9,7 @@ import java.lang.ref.WeakReference;
import java.io.IOException;
import hudson.security.Permission;
import hudson.security.ACL;
/**
* Partial {@link Action} implementation for those who kick some
@@ -33,9 +34,15 @@ public abstract class TaskAction extends AbstractModelObject implements Action {
*/
protected transient WeakReference<LargeText> log;
/**
* Gets the permission object that represents the permission to perform this task.
*/
protected abstract Permission getPermission();
protected abstract AbstractBuild getBuild();
/**
* Gets the {@link ACL} against which the permissions are checked.
*/
protected abstract ACL getACL();
public WeakReference<LargeText> getLog() {
return log;
@@ -68,7 +75,7 @@ public abstract class TaskAction extends AbstractModelObject implements Action {
* Clears the error status.
*/
public synchronized void doClearError(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
getBuild().checkPermission(getPermission());
getACL().checkPermission(getPermission());
if(workerThread!=null && !workerThread.isAlive())
workerThread = null;
@@ -3,6 +3,7 @@ package hudson.scm;
import hudson.model.AbstractBuild;
import hudson.model.TaskAction;
import hudson.security.Permission;
import hudson.security.ACL;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -42,6 +43,10 @@ public abstract class AbstractScmTagAction extends TaskAction {
return build;
}
protected ACL getACL() {
return build.getACL();
}
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
req.getView(this,chooseAction()).forward(req,rsp);
}
@@ -111,7 +111,7 @@ public class SubversionTagAction extends AbstractScmTagAction {
* Invoked to actually tag the workspace.
*/
public synchronized void doSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
getBuild().checkPermission(getPermission());
getACL().checkPermission(getPermission());
Map<SvnInfo,String> newTags = new HashMap<SvnInfo,String>();