• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Restrict类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中be.objectify.deadbolt.java.actions.Restrict的典型用法代码示例。如果您正苦于以下问题:Java Restrict类的具体用法?Java Restrict怎么用?Java Restrict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Restrict类属于be.objectify.deadbolt.java.actions包,在下文中一共展示了Restrict类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: insertComment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result insertComment(Long eid, Long cid) {
    Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    if (exam.hasState(Exam.State.ABORTED, Exam.State.GRADED_LOGGED, Exam.State.ARCHIVED)) {
        return forbidden();
    }
    Comment comment = bindForm(Comment.class);
    AppUtil.setCreator(comment, getLoggedUser());
    comment.save();

    exam.setExamFeedback(comment);
    exam.save();

    return ok(comment);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:19,代码来源:ReviewController.java


示例2: downloadQuestionAttachment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN"), @Group("STUDENT")})
public Result downloadQuestionAttachment(Long id) {
    User user = getLoggedUser();
    Question question;
    if (user.hasRole("STUDENT", getSession())) {
        question = Ebean.find(Question.class).where()
                .idEq(id)
                .eq("examSectionQuestions.examSection.exam.creator", getLoggedUser())
                .findUnique();
    } else {
        question = Ebean.find(Question.class, id);
    }
    if (question == null || question.getAttachment() == null) {
        return notFound();
    }
    return serveAttachment(question.getAttachment());
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:AttachmentController.java


示例3: deleteQuestionAnswerAttachment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result deleteQuestionAnswerAttachment(Long qid, String hash) {
    User user = getLoggedUser();
    ExamSectionQuestion question;
    if (user.hasRole("STUDENT", getSession())) {
        question = Ebean.find(ExamSectionQuestion.class).where()
                .idEq(qid)
                .eq("examSection.exam.creator", getLoggedUser())
                .findUnique();
    } else {
        question = Ebean.find(ExamSectionQuestion.class, qid);
    }
    if (question != null && question.getEssayAnswer() != null && question.getEssayAnswer().getAttachment() != null) {
        EssayAnswer answer = question.getEssayAnswer();
        Attachment aa = answer.getAttachment();
        answer.setAttachment(null);
        answer.save();
        AppUtil.removeAttachmentFile(aa.getFilePath());
        aa.delete();
        return ok(answer);
    }
    return notFound();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:24,代码来源:AttachmentController.java


示例4: insertExamOwner

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result insertExamOwner(Long eid, Long uid) {

    final User owner = Ebean.find(User.class, uid);
    final Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound();
    }
    User user = getLoggedUser();
    if (!user.hasRole(Role.Name.ADMIN.toString(), getSession()) && !exam.isOwnedOrCreatedBy(user)) {
        return forbidden("sitnet_error_access_forbidden");
    }
    if (owner != null) {
        exam.getExamOwners().add(owner);
        exam.update();
        return ok();
    }
    return notFound();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ExamOwnerController.java


示例5: removeExamOwner

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result removeExamOwner(Long eid, Long uid) {

    final User owner = Ebean.find(User.class, uid);
    final Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound();
    }
    User user = getLoggedUser();
    if (!user.hasRole(Role.Name.ADMIN.toString(), getSession()) && !exam.isOwnedOrCreatedBy(user)) {
        return forbidden("sitnet_error_access_forbidden");
    }
    if (owner != null) {
        exam.getExamOwners().remove(owner);
        exam.update();
        return ok();
    }
    return notFound();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ExamOwnerController.java


示例6: insertSection

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result insertSection(Long id) {
    Exam exam = Ebean.find(Exam.class, id);
    if (exam == null) {
        return notFound();
    }
    User user = getLoggedUser();
    if (exam.isOwnedOrCreatedBy(user) || user.hasRole("ADMIN", getSession())) {
        ExamSection section = new ExamSection();
        section.setLotteryItemCount(1);
        section.setExam(exam);
        section.setSectionQuestions(Collections.emptySet());
        section.setSequenceNumber(exam.getExamSections().size());
        section.setExpanded(true);
        AppUtil.setCreator(section, user);
        section.save();
        return ok(section, PathProperties.parse("(*, sectionQuestions(*))"));
    } else {
        return forbidden("sitnet_error_access_forbidden");
    }
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:ExamSectionController.java


示例7: insertQuestion

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result insertQuestion(Long eid, Long sid, Integer seq, Long qid) {
    Exam exam = Ebean.find(Exam.class, eid);
    ExamSection section = Ebean.find(ExamSection.class, sid);
    Question question = Ebean.find(Question.class, qid);
    if (exam == null || section == null || question == null) {
        return notFound();
    }
    if (exam.getAutoEvaluationConfig() != null && question.getType() == Question.Type.EssayQuestion) {
        return forbidden("sitnet_error_autoevaluation_essay_question");
    }
    User user = getLoggedUser();
    if (!exam.isOwnedOrCreatedBy(user) && !user.hasRole("ADMIN", getSession())) {
        return forbidden("sitnet_error_access_forbidden");
    }
    // TODO: response payload should be trimmed down (use path properties)
    return insertQuestion(exam, section, question, user, seq)
            .orElse(ok(Json.toJson(section)));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ExamSectionController.java


示例8: listNoShows

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result listNoShows(Long eid) {
    List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class)
            .fetch("exam", "id, name, state, gradedTime, customCredit, trialCount")
            .fetch("exam.executionType")
            .fetch("reservation")
            .fetch("user", "id, firstName, lastName, email, userIdentifier")
            .fetch("exam.course", "code, credits")
            .fetch("exam.grade", "id, name")
            .where()
            .eq("exam.id", eid)
            .eq("reservation.noShow", true)
            .orderBy("reservation.endAt")
            .findList();
    if (enrolments == null) {
        return notFound();
    } else {
        return ok(enrolments);
    }
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:21,代码来源:ReviewController.java


示例9: updateUndistributedExamQuestion

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result updateUndistributedExamQuestion(Long esqId) {
    User user = getLoggedUser();
    ExpressionList<ExamSectionQuestion> query = Ebean.find(ExamSectionQuestion.class).where().idEq(esqId);
    if (user.hasRole("TEACHER", getSession())) {
        query = query.eq("examSection.exam.examOwners", user);
    }
    ExamSectionQuestion examSectionQuestion = query.findUnique();
    if (examSectionQuestion == null) {
        return forbidden("sitnet_error_access_forbidden");
    }
    Question question = Ebean.find(Question.class, examSectionQuestion.getQuestion().getId());
    if (question == null) {
        return notFound();
    }
    updateExamQuestion(examSectionQuestion, question);
    examSectionQuestion.update();
    return ok(examSectionQuestion);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ExamSectionController.java


示例10: removeStudentEnrolment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result removeStudentEnrolment(Long id) {
    User user = getLoggedUser();
    ExamEnrolment enrolment = Ebean.find(ExamEnrolment.class).where()
            .idEq(id)
            .ne("exam.executionType.type", ExamExecutionType.Type.PUBLIC.toString())
            .isNull("reservation")
            .disjunction()
            .eq("exam.state", Exam.State.DRAFT)
            .eq("exam.state", Exam.State.SAVED)
            .endJunction()
            .disjunction()
            .eq("exam.examOwners", user)
            .eq("exam.creator", user)
            .endJunction()
            .findUnique();
    if (enrolment == null) {
        return forbidden("sitnet_not_possible_to_remove_participant");
    }
    enrolment.delete();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:23,代码来源:EnrolmentController.java


示例11: activateExamRoom

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict(@Group({"ADMIN"}))
public CompletionStage<Result> activateExamRoom(Long id) throws MalformedURLException {

    ExamRoom room = Ebean.find(ExamRoom.class, id);
    if (room == null) {
        return wrapAsPromise(notFound());
    }
    room.setState(ExamRoom.State.ACTIVE.toString());
    room.update();

    if (room.getExternalRef() != null && IOP_ACTIVATED) {
        return externalApi.activateFacility(room.getId())
                .thenApplyAsync(response -> ok(Json.toJson(room)));
    } else {
        return wrapAsPromise(ok(Json.toJson(room)));
    }
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:RoomController.java


示例12: addRole

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result addRole(Long uid, String roleName) {
    User user = Ebean.find(User.class, uid);
    if (user == null) {
        return notFound("sitnet_user_not_found");
    }
    if (user.getRoles().stream().noneMatch((r) -> r.getName().equals(roleName))) {
        Role role = Ebean.find(Role.class).where().eq("name", roleName).findUnique();
        if (role == null) {
            return notFound("sitnet_role_not_found");
        }
        user.getRoles().add(role);
        user.update();
    }
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:UserController.java


示例13: getUsersByRole

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result getUsersByRole(String role) {

    List<User> users = Ebean.find(User.class)
            .where()
            .eq("roles.name", role)
            .orderBy("lastName")
            .findList();

    ArrayNode array = JsonNodeFactory.instance.arrayNode();
    for (User u : users) {
        ObjectNode part = Json.newObject();
        part.put("id", u.getId());
        part.put("name", String.format("%s %s", u.getFirstName(), u.getLastName()));
        array.add(part);
    }

    return ok(Json.toJson(array));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:UserController.java


示例14: updateAssessmentInfo

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER")})
public Result updateAssessmentInfo(Long id) {
    String info = request().body().asJson().get("assessmentInfo").asText();
    Optional<Exam>  option = Ebean.find(Exam.class).fetch("parent.creator")
            .where()
            .idEq(id)
            .eq("state", Exam.State.GRADED_LOGGED)
            .findOneOrEmpty();
    if (!option.isPresent()) {
        return notFound("sitnet_exam_not_found");
    }
    Exam exam = option.get();
    if (exam.getState() != Exam.State.GRADED_LOGGED || !isAllowedToModify(exam, getLoggedUser(), exam.getState())) {
        return forbidden("You are not allowed to modify this object");
    }
    exam.setAssessmentInfo(info);
    exam.update();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ReviewController.java


示例15: getParticipationsForExamAndUser

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result getParticipationsForExamAndUser(Long eid, Long uid) {
    List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
            .fetch("exam", "id, state")
            .fetch("exam.grade", "id, name")
            .where()
            .eq("user.id", uid)
            .eq("exam.parent.id", eid)
            .disjunction()
            .eq("exam.state", Exam.State.ABORTED)
            .eq("exam.state", Exam.State.GRADED)
            .eq("exam.state", Exam.State.GRADED_LOGGED)
            .eq("exam.state", Exam.State.ARCHIVED)
            .endJunction()
            .findList();
    return ok(participations);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:ReviewController.java


示例16: removeEnrolment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result removeEnrolment(Long id) {
    User user = getLoggedUser();
    ExamEnrolment enrolment;
    if (user.hasRole("STUDENT", getSession())) {
        enrolment = Ebean.find(ExamEnrolment.class).fetch("exam")
                .where().idEq(id).eq("user", user).findUnique();
    } else {
        enrolment = Ebean.find(ExamEnrolment.class).fetch("exam")
                .where().idEq(id).findUnique();
    }
    if (enrolment == null) {
        return notFound("enrolment not found");
    }
    // Disallow removing enrolments to private exams created automatically for student
    if (enrolment.getExam().isPrivate()) {
        return forbidden();
    }
    if (enrolment.getReservation() != null) {
        return forbidden("sitnet_cancel_reservation_first");
    }
    enrolment.delete();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:25,代码来源:EnrolmentController.java


示例17: updateComment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result updateComment(Long eid, Long cid) {
    Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    if (exam.hasState(Exam.State.ABORTED, Exam.State.GRADED_LOGGED, Exam.State.ARCHIVED)) {
        return forbidden();
    }
    Comment form = bindForm(Comment.class);
    Comment comment = Ebean.find(Comment.class).fetch("creator", "firstName, lastName").where().idEq(cid).findUnique();
    if (comment == null) {
        return notFound();
    }
    if (form.getComment() != null) {
        AppUtil.setModifier(comment, getLoggedUser());
        comment.setComment(form.getComment());
        comment.save();
        exam.setExamFeedback(comment);
        exam.save();
    }
    return ok(comment);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:24,代码来源:ReviewController.java


示例18: enrollExamInfo

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result enrollExamInfo(String code, Long id) {

    Exam exam = Ebean.find(Exam.class)
            .fetch("course")
            .fetch("course.organisation")
            .fetch("course.gradeScale")
            .fetch("gradeScale")
            .fetch("creator", "firstName, lastName, email")
            .fetch("examLanguages")
            .fetch("examOwners", "firstName, lastName")
            .fetch("examInspections")
            .fetch("examInspections.user")
            .fetch("examType")
            .fetch("executionType")
            .where()
            .eq("state", Exam.State.PUBLISHED)
            .eq("course.code", code)
            .idEq(id)
            .findUnique();

    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    return ok(exam);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:27,代码来源:EnrolmentController.java


示例19: createInspection

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result createInspection() {
    DynamicForm df = formFactory.form().bindFromRequest();
    Long examId = Long.parseLong(df.get("examId"));
    Exam exam = Ebean.find(Exam.class, examId);
    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    if (exam.getLanguageInspection() != null) {
        return forbidden("already sent for inspection");
    }
    if (!exam.getSubjectToLanguageInspection()) {
        return forbidden("not allowed to send for inspection");
    }
    LanguageInspection inspection = new LanguageInspection();
    User user = getLoggedUser();
    AppUtil.setCreator(inspection, user);
    inspection.setExam(exam);
    inspection.save();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:LanguageInspectionController.java


示例20: addInspectionComment

import be.objectify.deadbolt.java.actions.Restrict; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result addInspectionComment(Long id) {
    Exam exam = Ebean.find(Exam.class, id);
    if (exam == null) {
        return notFound("Inspection not found");
    }
    DynamicForm df = formFactory.form().bindFromRequest();
    InspectionComment ic = new InspectionComment();
    User user = getLoggedUser();
    AppUtil.setCreator(ic, user);
    AppUtil.setModifier(ic, user);
    ic.setComment(df.get("comment"));
    ic.setExam(exam);
    ic.save();
    return ok(ic, PathProperties.parse("(creator(firstName, lastName, email), created, comment)"));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:ReviewController.java



注:本文中的be.objectify.deadbolt.java.actions.Restrict类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BmobRecordManager类代码示例发布时间:2022-05-22
下一篇:
Java MorphlineCompilationException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap