Skip to content
Permalink
Browse files
auth: add resource schema (#117)
Change-Id: I69c9216755fee88baf3d873ef83481bcb7ed94c4
  • Loading branch information
javeme committed Mar 3, 2021
1 parent d0e99b2 commit 77c01aa1f7e2986e8fd1a7cfed45768888aefe9c
Showing 1 changed file with 8 additions and 14 deletions.
@@ -45,7 +45,9 @@ public enum HugeResourceType {

EDGE_LABEL,

INDEX_LABEL,
INDEX_LABEL, // include create/rebuild/delete index

SCHEMA,

META,

@@ -61,34 +63,26 @@ public enum HugeResourceType {

ROOT;

public boolean match(HugeResourceType type) {
if (this == type || this == ROOT ||
(this == ALL && type.ordinal() <= ALL.ordinal())) {
return true;
}
return this == type;
}

public boolean isGraph() {
int ord = this.ordinal();
return VERTEX.ordinal() <= ord && ord <= EDGE.ordinal();
}

public boolean isSchema() {
int ord = this.ordinal();
return PROPERTY_KEY.ordinal() <= ord && ord <= INDEX_LABEL.ordinal();
return PROPERTY_KEY.ordinal() <= ord && ord <= SCHEMA.ordinal();
}

public boolean isUsers() {
public boolean isAuth() {
int ord = this.ordinal();
return GRANT.ordinal() <= ord && ord <= TARGET.ordinal();
}

public boolean isGrantOrUser() {
return this == GRANT && this == USER_GROUP;
return this == GRANT || this == USER_GROUP;
}

public boolean isAny() {
return this == ALL || this == ROOT;
public boolean isRepresentative() {
return this == ROOT || this == ALL || this == SCHEMA;
}
}

0 comments on commit 77c01aa

Please sign in to comment.