Skip to content

Commit

Permalink
refact: removed not needed type constructor from NamedAccessObject, r…
Browse files Browse the repository at this point in the history
…euse it for IndividualAccessObject
  • Loading branch information
litvinovg committed Dec 14, 2023
1 parent 5bc7c76 commit b6a04c1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
package edu.cornell.mannlib.vitro.webapp.auth.objects;

import java.util.Optional;

import edu.cornell.mannlib.vitro.webapp.auth.attributes.AccessObjectType;

public class IndividualAccessObject extends AccessObject {

private final String uri;
public class IndividualAccessObject extends NamedAccessObject {

public IndividualAccessObject(String uri) {
this.uri = uri;
super(uri);
}

@Override
public AccessObjectType getType() {
return AccessObjectType.INDIVIDUAL;
}

@Override
public Optional<String> getUri() {
if (uri == null) {
return Optional.empty();
}
return Optional.of(uri);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@
*/
public class NamedAccessObject extends AccessObject {
private final String uri;
private AccessObjectType type;

public NamedAccessObject() {
this.uri = "";
this.type = AccessObjectType.NAMED_OBJECT;
}

public NamedAccessObject(String uri, AccessObjectType type) {
this.uri = uri;
this.type = type;
}

public NamedAccessObject(String uri) {
this.uri = uri;
this.type = AccessObjectType.NAMED_OBJECT;
}

@Override
Expand Down Expand Up @@ -61,7 +53,7 @@ public String toString() {

@Override
public AccessObjectType getType() {
return type;
return AccessObjectType.NAMED_OBJECT;
}

private static String getShortName(String entityUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public String getUri() {

private SimplePermission(String uri) {
this.uri = SimplePermission.NS + uri;
NamedAccessObject ao = new NamedAccessObject(this.uri, AccessObjectType.NAMED_OBJECT);
NamedAccessObject ao = new NamedAccessObject(this.uri);
this.ACTION = new SimpleAuthorizationRequest(ao, AccessOperation.EXECUTE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private AuthorizationRequest getActionsForPage( VitroRequest vreq ) throws Excep
if (StringUtils.isBlank(uri)) {
continue;
}
NamedAccessObject ao = new NamedAccessObject(uri, AccessObjectType.NAMED_OBJECT);
NamedAccessObject ao = new NamedAccessObject(uri);
auth = auth.and( new SimpleAuthorizationRequest(ao, AccessOperation.EXECUTE));
}
return auth;
Expand Down

0 comments on commit b6a04c1

Please sign in to comment.