/** * This is a Class Constructor Creates a new Product Role object with the basic product role * requirements * * @author Heba Elsherif * @param projectID id of the project of the product role * @param name name of the product role * @param description description of the product role * @return void */ public ProductRole(long projectId, String name, String description) { this.deleted = false; this.name = name; this.description = description; this.project = Project.findById(projectId); this.Tasks = new ArrayList<Task>(); }
/** * Checks if a certain product role name exists in a certain project . * * @author Heba Elsherif * @param name the name of a product role. * @param projectId the project id that the product role belongs to. * @return boolean value indecating if the product role name already exists or no. */ public static boolean hasUniqueName(String name, long projectId) { Project project = Project.findById(projectId); for (int i = 0; i < project.productRoles.size(); i++) { if (project.productRoles.get(i).name.equalsIgnoreCase(name) && !project.productRoles.get(i).deleted) { return false; } } return true; }
public static void project(Long id) { Project project = Project.findById(id); Long UID = Long.parseLong(Session.current().get("user_id")); User u = User.findById(UID); if (project.canBeSeenBy(u)) { render(project); } else { projects(); } }
public static void editMapAndSave(Long id) { Project project = Project.findById(id); project.companies.get("zenexity").name = "Coucou"; project.save(); show(id); }
public static void show(Long id) { Project project = Project.findById(id); render(project); }
@Before static void checkAccess() throws Throwable { User u = getUser(); if (u.isRoot()) return; Access access = getActionAnnotation(Access.class); if (access != null) { db(request.url + ": " + access); for (AccessType a : access.value()) { boolean hasPermission = PermissionService.hasInheritedAccess(u, Podbase.getInstance(), a); if (!hasPermission) redirectToLogin(); } } ModelAccess modelAccess = getActionAnnotation(ModelAccess.class); if (modelAccess != null) { db(request.url + ": " + modelAccess); PermissionedModel model = params.get("project", PermissionedModel.class); if (model != null && !model.isPersistent()) model = null; if (model == null && params.get("projectId", Long.class) != null) model = Project.findById(params.get("projectId", Long.class)); if (model == null) model = params.get("model", PermissionedModel.class); if (model != null && !model.isPersistent()) model = null; if (model == null) { Path path = params.get("path", Path.class); if (path != null) model = PathService.projectForPath(path); } db(" Security Model: " + model); if (model == null) redirectToLogin(); Set<AccessType> projectAccessSet = PermissionService.getResolvedAccess(u, model); for (AccessType a : modelAccess.value()) { boolean hasPermission = projectAccessSet.contains(a); if (!hasPermission) redirectToLogin("You do not have view permission for " + model.toString()); } } PaperAccess paperAccess = getActionAnnotation(PaperAccess.class); if (paperAccess != null) { db(request.url + ": " + paperAccess); Paper paper = params.get("paper", Paper.class); if (paper == null && params.get("paperId", Long.class) != null) paper = Paper.findById(params.get("paperId", Long.class)); if (paper == null) { ImageSet set = params.get("imageset", ImageSet.class); if (set != null) paper = set.paper; } db(" Security Model: " + paper); if (paper == null) redirectToLogin(); for (AccessType a : paperAccess.value()) { boolean hasPermission = PermissionService.hasInheritedAccess(u, paper, a); if (!hasPermission) redirectToLogin(); } } }