提交 5552fa54 编写于 作者: D Daniel Beck 提交者: GitHub

Merge pull request #2999 from ndeloof/java8default

rely on java8 default methods to avoid code duplication
......@@ -492,20 +492,6 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
/**
* Short for {@code getACL().checkPermission(p)}
*/
public void checkPermission(Permission p) {
getACL().checkPermission(p);
}
/**
* Short for {@code getACL().hasPermission(p)}
*/
public boolean hasPermission(Permission p) {
return getACL().hasPermission(p);
}
/**
* Save the settings to a file.
*/
......
......@@ -332,14 +332,6 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
public void checkPermission(Permission permission) {
getACL().checkPermission(permission);
}
public boolean hasPermission(Permission permission) {
return getACL().hasPermission(permission);
}
/**
* If the computer was offline (either temporarily or not),
* this method will return the cause.
......
......@@ -185,14 +185,6 @@ public class MyViewsProperty extends UserProperty implements ModifiableViewGroup
return user.getACL();
}
public void checkPermission(Permission permission) throws AccessDeniedException {
getACL().checkPermission(permission);
}
public boolean hasPermission(Permission permission) {
return getACL().hasPermission(permission);
}
///// Action methods /////
public String getDisplayName() {
return Messages.MyViewsProperty_DisplayName();
......
......@@ -509,14 +509,6 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
public final void checkPermission(Permission permission) {
getACL().checkPermission(permission);
}
public final boolean hasPermission(Permission permission) {
return getACL().hasPermission(permission);
}
public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException {
if (form==null) return null;
......
......@@ -1456,16 +1456,6 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
return new Api(this);
}
@Override
public void checkPermission(@Nonnull Permission p) {
getACL().checkPermission(p);
}
@Override
public boolean hasPermission(@Nonnull Permission p) {
return getACL().hasPermission(p);
}
@Override
public ACL getACL() {
// for now, don't maintain ACL per run, and do it at project level
......
......@@ -894,14 +894,6 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
};
}
public void checkPermission(Permission permission) {
getACL().checkPermission(permission);
}
public boolean hasPermission(Permission permission) {
return getACL().hasPermission(permission);
}
/**
* With ADMINISTER permission, can delete users with persisted data but can't delete self.
*/
......
......@@ -579,14 +579,6 @@ public abstract class View extends AbstractModelObject implements AccessControll
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
public void checkPermission(Permission p) {
getACL().checkPermission(p);
}
public boolean hasPermission(Permission p) {
return getACL().hasPermission(p);
}
/** @deprecated Does not work properly with moved jobs. Use {@link ItemListener#onLocationChanged} instead. */
@Deprecated
public void onJobRenamed(Item item, String oldName, String newName) {}
......
......@@ -42,11 +42,15 @@ public interface AccessControlled {
/**
* Convenient short-cut for {@code getACL().checkPermission(permission)}
*/
void checkPermission(@Nonnull Permission permission) throws AccessDeniedException;
default void checkPermission(@Nonnull Permission permission) throws AccessDeniedException {
getACL().checkPermission(permission);
}
/**
* Convenient short-cut for {@code getACL().hasPermission(permission)}
*/
boolean hasPermission(@Nonnull Permission permission);
default boolean hasPermission(@Nonnull Permission permission) {
return getACL().hasPermission(permission);
}
}
......@@ -128,14 +128,6 @@ public abstract class Cloud extends Actionable implements ExtensionPoint, Descri
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
public final void checkPermission(Permission permission) {
getACL().checkPermission(permission);
}
public final boolean hasPermission(Permission permission) {
return getACL().hasPermission(permission);
}
/**
* Provisions new {@link Node}s from this cloud.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册