本文整理汇总了Java中org.entcore.common.service.VisibilityFilter类的典型用法代码示例。如果您正苦于以下问题:Java VisibilityFilter类的具体用法?Java VisibilityFilter怎么用?Java VisibilityFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VisibilityFilter类属于org.entcore.common.service包,在下文中一共展示了VisibilityFilter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import org.entcore.common.service.VisibilityFilter; //导入依赖的package包/类
@Override
public void authorize(HttpServerRequest request, Binding binding, UserInfos user, Handler<Boolean> handler) {
String sharedMethod = binding.getServiceMethod().replaceAll("\\.", "-");
String id = request.params().get(conf.getResourceIdLabel());
if (id != null && !id.trim().isEmpty()) {
List<DBObject> groups = new ArrayList<>();
groups.add(QueryBuilder.start("userId").is(user.getUserId())
.put(sharedMethod).is(true).get());
for (String gpId: user.getGroupsIds()) {
groups.add(QueryBuilder.start("groupId").is(gpId)
.put(sharedMethod).is(true).get());
}
QueryBuilder query = QueryBuilder.start("_id").is(id).or(
QueryBuilder.start("owner.userId").is(user.getUserId()).get(),
QueryBuilder.start("visibility").is(VisibilityFilter.PUBLIC.name()).get(),
QueryBuilder.start("visibility").is(VisibilityFilter.PROTECTED.name()).get(),
QueryBuilder.start("shared").elemMatch(
new QueryBuilder().or(groups.toArray(new DBObject[groups.size()])).get()).get()
);
MongoAppFilter.executeCountQuery(request, conf.getCollection(),
MongoQueryBuilder.build(query), 1, handler);
} else {
handler.handle(false);
}
}
示例2: retrieves
import org.entcore.common.service.VisibilityFilter; //导入依赖的package包/类
public void retrieves(List<String> ids, final JsonObject projection, UserInfos user, Handler<Either<String, JsonArray>> handler) {
QueryBuilder builder = QueryBuilder.start("_id").in(new HashSet<String>(ids));
if (user == null) {
builder.put("visibility").is(VisibilityFilter.PUBLIC.name());
}
mongo.find(ShareBigFiles.SHARE_BIG_FILE_COLLECTION, MongoQueryBuilder.build(builder),
null, projection, validResultsHandler(handler));
}
示例3: list
import org.entcore.common.service.VisibilityFilter; //导入依赖的package包/类
/**
* Lists every object associated with the user.
* @param request Client request.
*/
@Get("/list")
@SecuredAction(value = read_only, type = ActionType.AUTHENTICATED)
public void list(final HttpServerRequest request) {
UserUtils.getUserInfos(eb, request, new Handler<UserInfos>() {
@Override
public void handle(final UserInfos user) {
String filter = request.params().get("filter");
VisibilityFilter v = VisibilityFilter.ALL;
if (filter != null) {
try {
v = VisibilityFilter.valueOf(filter.toUpperCase());
} catch (IllegalArgumentException | NullPointerException e) {
v = VisibilityFilter.ALL;
if (log.isDebugEnabled()) {
log.debug("Invalid filter " + filter);
}
}
}
shareBigFileCrudService.list(v, user, new Handler<Either<String, JsonArray>>() {
@Override
public void handle(Either<String, JsonArray> event) {
if (event.isRight()) {
Renders.renderJson(request, event.right().getValue());
} else {
leftToResponse(request, event.left());
}
}
});
}
});
}