Remove usage of the now-redundant ExtractedContexts class, other misc cleanup
This commit is contained in:
+7
-7
@@ -79,13 +79,13 @@ public class SubjectCollectionProxy implements SubjectCollection {
|
||||
@Override
|
||||
public Map<Subject, Boolean> getAllWithPermission(String s) {
|
||||
// again, these methods will lazily load subjects.
|
||||
return (Map) handle.getAllWithPermission(s).thenApply(map -> {
|
||||
return map.entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> new SubjectProxy(service, e.getKey()),
|
||||
Map.Entry::getValue
|
||||
));
|
||||
}).join();
|
||||
return (Map) handle.getAllWithPermission(s)
|
||||
.thenApply(map -> map.entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> new SubjectProxy(service, e.getKey()),
|
||||
Map.Entry::getValue
|
||||
))
|
||||
).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+36
-48
@@ -73,13 +73,11 @@ public class SubjectDataProxy implements SubjectData {
|
||||
|
||||
@Override
|
||||
public boolean setPermission(Set<Context> contexts, String permission, Tristate value) {
|
||||
getHandle().thenCompose(handle -> {
|
||||
return handle.setPermission(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
permission,
|
||||
CompatibilityUtil.convertTristate(value)
|
||||
);
|
||||
});
|
||||
getHandle().thenCompose(handle -> handle.setPermission(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
permission,
|
||||
CompatibilityUtil.convertTristate(value)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,52 +95,44 @@ public class SubjectDataProxy implements SubjectData {
|
||||
|
||||
@Override
|
||||
public Map<Set<Context>, List<Subject>> getAllParents() {
|
||||
return (Map) getHandle().thenApply(handle -> {
|
||||
return handle.getAllParents().entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> CompatibilityUtil.convertContexts(e.getKey()),
|
||||
e -> e.getValue().stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList())
|
||||
)
|
||||
);
|
||||
}).join();
|
||||
return (Map) getHandle().thenApply(handle -> handle.getAllParents().entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> CompatibilityUtil.convertContexts(e.getKey()),
|
||||
e -> e.getValue().stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList())
|
||||
)
|
||||
)).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subject> getParents(Set<Context> contexts) {
|
||||
return (List) getHandle().thenApply(handle -> {
|
||||
return handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList());
|
||||
}).join();
|
||||
return (List) getHandle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList())).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addParent(Set<Context> contexts, Subject parent) {
|
||||
getHandle().thenCompose(handle -> {
|
||||
return handle.addParent(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
);
|
||||
});
|
||||
getHandle().thenCompose(handle -> handle.addParent(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeParent(Set<Context> contexts, Subject parent) {
|
||||
getHandle().thenCompose(handle -> {
|
||||
return handle.removeParent(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
);
|
||||
});
|
||||
getHandle().thenCompose(handle -> handle.removeParent(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -154,19 +144,17 @@ public class SubjectDataProxy implements SubjectData {
|
||||
|
||||
@Override
|
||||
public boolean clearParents(Set<Context> contexts) {
|
||||
;
|
||||
getHandle().thenCompose(handle -> handle.clearParents(CompatibilityUtil.convertContexts(contexts)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Set<Context>, Map<String, String>> getAllOptions() {
|
||||
return (Map) getHandle().thenApply(handle -> {
|
||||
return handle.getAllOptions().entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> CompatibilityUtil.convertContexts(e.getKey()),
|
||||
Map.Entry::getValue
|
||||
));
|
||||
}).join();
|
||||
return (Map) getHandle().thenApply(handle -> handle.getAllOptions().entrySet().stream()
|
||||
.collect(ImmutableCollectors.toImmutableMap(
|
||||
e -> CompatibilityUtil.convertContexts(e.getKey()),
|
||||
Map.Entry::getValue
|
||||
))).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+25
-43
@@ -78,81 +78,63 @@ public class SubjectProxy implements Subject {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Set<Context> contexts, String permission) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission).asBoolean();
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission).asBoolean()).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.getPermissionValue(ImmutableContextSet.empty(), permission).asBoolean();
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.getPermissionValue(ImmutableContextSet.empty(), permission).asBoolean()).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tristate getPermissionValue(Set<Context> contexts, String permission) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return CompatibilityUtil.convertTristate(handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission));
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> CompatibilityUtil.convertTristate(handle.getPermissionValue(CompatibilityUtil.convertContexts(contexts), permission))).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildOf(Subject parent) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.isChildOf(
|
||||
ImmutableContextSet.empty(),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
);
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.isChildOf(
|
||||
ImmutableContextSet.empty(),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
)).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildOf(Set<Context> contexts, Subject parent) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.isChildOf(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
);
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.isChildOf(
|
||||
CompatibilityUtil.convertContexts(contexts),
|
||||
service.newSubjectReference(
|
||||
parent.getContainingCollection().getIdentifier(),
|
||||
parent.getIdentifier()
|
||||
)
|
||||
)).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subject> getParents() {
|
||||
return (List) getHandle().thenApply(handle -> {
|
||||
return handle.getParents(ImmutableContextSet.empty()).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList());
|
||||
}).join();
|
||||
return (List) getHandle().thenApply(handle -> handle.getParents(ImmutableContextSet.empty()).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList())).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subject> getParents(Set<Context> contexts) {
|
||||
return (List) getHandle().thenApply(handle -> {
|
||||
return handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList());
|
||||
}).join();
|
||||
return (List) getHandle().thenApply(handle -> handle.getParents(CompatibilityUtil.convertContexts(contexts)).stream()
|
||||
.map(s -> new SubjectProxy(service, s))
|
||||
.collect(ImmutableCollectors.toImmutableList())).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getOption(Set<Context> contexts, String key) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.getOption(CompatibilityUtil.convertContexts(contexts), key);
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.getOption(CompatibilityUtil.convertContexts(contexts), key)).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getOption(String key) {
|
||||
return getHandle().thenApply(handle -> {
|
||||
return handle.getOption(ImmutableContextSet.empty(), key);
|
||||
}).join();
|
||||
return getHandle().thenApply(handle -> handle.getOption(ImmutableContextSet.empty(), key)).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user