Package models

Examples of models.Project.asResource()


        User user = User.find.byId(userId);
        Project project = Project.find.byId(projectId);
        EventType eventType = EventType.valueOf(eventTypeValue);

        Watch.watch(user, project.asResource());
        assertThat(user.getWatchingProjects().contains(project)).isTrue();
        assertThat(UserProjectNotification.isEnabledNotiType(user, project, eventType)).isTrue();

        FakeRequest request = fakeRequest("POST", "/noti/toggle/" + projectId + "/" + eventTypeValue)
                .withSession(UserApp.SESSION_USERID, String.valueOf(userId));
View Full Code Here


public class WatchProjectApp extends Controller {

    @IsAllowed(Operation.READ)
    public static Result watch(String userName, String projectName) {
        Project project = Project.findByOwnerAndProjectName(userName, projectName);
        Watch.watch(project.asResource());
        return ok();
    }

    @IsAllowed(Operation.READ)
    public static Result unwatch(String userName, String projectName) {
View Full Code Here

    }

    @IsAllowed(Operation.READ)
    public static Result unwatch(String userName, String projectName) {
        Project project = Project.findByOwnerAndProjectName(userName, projectName);
        Watch.unwatch(project.asResource());
        return ok();
    }

    public static Result toggle(Long projectId, String notificationType) {
        EventType notiType = EventType.valueOf(notificationType);
View Full Code Here

        User user = UserApp.currentUser();

        if(project == null) {
            return notFound(ErrorViews.NotFound.render("error.notfound.project"));
        }
        if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) {
            return forbidden(ErrorViews.Forbidden.render("error.forbidden", project));
        }
        if(!Watch.isWatching(user, project.asResource())) {
            return badRequest(Messages.get("error.notfound.watch"));
        }
View Full Code Here

            return notFound(ErrorViews.NotFound.render("error.notfound.project"));
        }
        if(!AccessControl.isAllowed(user, project.asResource(), Operation.READ)) {
            return forbidden(ErrorViews.Forbidden.render("error.forbidden", project));
        }
        if(!Watch.isWatching(user, project.asResource())) {
            return badRequest(Messages.get("error.notfound.watch"));
        }

        UserProjectNotification upn = UserProjectNotification.findOne(user, project, notiType);
        if(upn == null) { // make the EventType OFF, because default is ON.
View Full Code Here

            }
            return AccessLogger.log(context.request(),
                    forbidden(ErrorViews.NotFound.render("error.forbidden.or.notfound")), null);
        }

        if (!AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) {
            flash("failed", Messages.get("error.auth.unauthorized.waringMessage"));
            return AccessLogger.log(context.request(),
                    forbidden(ErrorViews.Forbidden.render("error.forbidden.or.notfound", context.request().path())), null);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.