Skip to content

Commit

Permalink
rely on java8 default methods to avoid code duplication
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Sep 2, 2017
1 parent 4d60ca6 commit 30a927f
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 74 deletions.
14 changes: 0 additions & 14 deletions core/src/main/java/hudson/model/AbstractItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,20 +492,6 @@ public ACL getACL() {
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.
*/
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,6 @@ public ACL getACL() {
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.
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/model/MyViewsProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ public ACL getACL() {
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();
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/model/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,6 @@ public ACL getACL() {
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;

Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -1456,16 +1456,6 @@ public void writeWholeLogTo(@Nonnull OutputStream out) throws IOException, Inter
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
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -894,14 +894,6 @@ public boolean hasPermission(Authentication a, Permission permission) {
};
}

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.
*/
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/model/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,6 @@ public ACL getACL() {
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) {}
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/hudson/security/AccessControlled.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/slaves/Cloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ public ACL getACL() {
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.
*
Expand Down

0 comments on commit 30a927f

Please sign in to comment.