Package models.resource

Examples of models.resource.Resource


        return ok();
    }

    public static Result unwatch(ResourceParam resourceParam) {
        User user = UserApp.currentUser();
        Resource resource = resourceParam.resource;

        if (user.isAnonymous()) {
            return forbidden("Anonymous cannot unwatch it.");
        }

        Watch.unwatch(user, resource);

        if (HttpUtil.isJSONPreferred(request())) {
            return ok();
        } else {
            String message = getUnwatchMessage(resource);

            if(!StringUtils.isEmpty(message)) {
                flash(utils.Constants.SUCCESS, message);
            }

            return redirect(RouteUtil.getUrl(resource.getType(), resource.getId()));
        }
    }
View Full Code Here


    }

    @Test
    public void watch() {
        // Given
        Resource resource = issue.asResource();
        project.refresh();
        project.setProjectScope(ProjectScope.PUBLIC);
        project.update();

        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.watch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, nonmember.id.toString())
        );

        // Then
View Full Code Here

    }

    @Test
    public void watchByAuthor() {
        // Given
        Resource resource = issue.asResource();

        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.watch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, author.id.toString())
        );

        // Then
View Full Code Here

    }

    @Test
    public void watchByAssignee() {
        // Given
        Resource resource = issue.asResource();

        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.watch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, assignee.id.toString())
        );

        // Then
View Full Code Here

    }

    @Test
    public void unwatch() {
        // Given
        Resource resource = issue.asResource();
        project.refresh();
        project.setProjectScope(ProjectScope.PUBLIC);
        project.update();


        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.unwatch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, nonmember.id.toString())
        );

        // Then
View Full Code Here

    }

    @Test
    public void unwatchByAuthor() {
        // Given
        Resource resource = issue.asResource();

        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.unwatch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, author.id.toString())
        );

        // Then
View Full Code Here

    }

    @Test
    public void unwatchByAssignee() {
        // Given
        Resource resource = issue.asResource();

        // When
        Result result = callAction(
                controllers.routes.ref.WatchApp.unwatch(resource.asParameter()),
                fakeRequest()
                        .withSession(UserApp.SESSION_USERID, assignee.id.toString())
        );

        // Then
View Full Code Here

     */
    @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();
                }

View Full Code Here

        super.delete();
    }

    @Override
    public Resource asResource() {
        return new Resource() {
            @Override
            public String getId() {
                return id.toString();
            }
View Full Code Here

        project.setLastPostingNumber(project.getLastPostingNumber());
        project.update();
    }

    public Resource labelsAsResource() {
        return new Resource() {

            @Override
            public String getId() {
                return id.toString();
            }
View Full Code Here

TOP

Related Classes of models.resource.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.