コード例 #1
0
ファイル: UserApp.java プロジェクト: bluemir/hive
 private static void collectDatum(
     List<Project> projects,
     List<Posting> postings,
     List<Issue> issues,
     List<PullRequest> pullRequests,
     List<Milestone> milestones,
     int daysAgo) {
   // collect all postings, issues, pullrequests and milesotnes that are contained in the projects.
   for (Project project : projects) {
     if (AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) {
       postings.addAll(Posting.findRecentlyCreatedByDaysAgo(project, daysAgo));
       issues.addAll(Issue.findRecentlyOpendIssuesByDaysAgo(project, daysAgo));
       pullRequests.addAll(PullRequest.findOpendPullRequestsByDaysAgo(project, daysAgo));
       milestones.addAll(Milestone.findOpenMilestones(project.id));
     }
   }
 }
コード例 #2
0
  @Override
  public final Result call(Context context) throws Throwable {
    PathParser parser = new PathParser(context);
    String ownerLoginId = parser.getOwnerLoginId();
    String projectName = parser.getProjectName();

    Project project = Project.findByOwnerAndProjectName(ownerLoginId, projectName);

    if (project == null) {
      return AccessLogger.log(
          context.request(), notFound(ErrorViews.NotFound.render("error.notfound.project")), null);
    }

    if (!AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) {
      return AccessLogger.log(
          context.request(), notFound(ErrorViews.NotFound.render("error.notfound.project")), null);
    }

    return call(project, context, parser);
  }
コード例 #3
0
ファイル: Attachment.java プロジェクト: jeonnoej/yobi
  /**
   * 이 객체를 리소스로 반환한다.
   *
   * <p>when: 권한검사시 사용
   *
   * @return 리소스
   */
  @Override
  public Resource asResource() {
    boolean isContainerProject = containerType.equals(ResourceType.PROJECT);
    final Project project;
    final Resource container;

    if (isContainerProject) {
      project = Project.find.byId(Long.parseLong(containerId));
      if (project == null) {
        throw new RuntimeException(messageForLosingProject());
      }
      container = project.asResource();
    } else {
      container = Resource.get(containerType, containerId);
      if (!(container instanceof GlobalResource)) {
        project = container.getProject();
        if (project == null) {
          throw new RuntimeException(messageForLosingProject());
        }
      } else {
        project = null;
      }
    }

    if (project != null) {
      return new Resource() {
        @Override
        public String getId() {
          return id.toString();
        }

        @Override
        public Project getProject() {
          return project;
        }

        @Override
        public ResourceType getType() {
          return ResourceType.ATTACHMENT;
        }

        @Override
        public Resource getContainer() {
          return container;
        }
      };
    } else {
      return new GlobalResource() {
        @Override
        public String getId() {
          return id.toString();
        }

        @Override
        public ResourceType getType() {
          return ResourceType.ATTACHMENT;
        }

        @Override
        public Resource getContainer() {
          return container;
        }
      };
    }
  }