package ca.corefacility.bioinformatics.irida.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import ca.corefacility.bioinformatics.irida.model.event.ProjectEvent;
import ca.corefacility.bioinformatics.irida.model.project.Project;
import ca.corefacility.bioinformatics.irida.model.user.User;

/**
 * Service for reading and managing {@link ProjectEvent}s
 * 
 *
 */
public interface ProjectEventService extends CRUDService<Long, ProjectEvent> {

	/**
	 * Get the events for a given project
	 * 
	 * @param project
	 *            The project to get events for
	 * @param pageable
	 *            The page description
	 * @return A List of {@link ProjectEvent}s
	 */
	public Page<ProjectEvent> getEventsForProject(Project project, Pageable pageable);

	/**
	 * Get the events on all projects for a given user
	 * 
	 * @param user
	 *            The {@link User} to get events for
	 * @param pageable
	 *            The page description.
	 * @return A List of {@link ProjectEvent}s
	 */
	public Page<ProjectEvent> getEventsForUser(User user, Pageable pageable);

}

@@ -141,16 +141,144 @@
 ageable;
+%0Aimport org.springframework.security.access.prepost.PostFilter;%0Aimport org.springframework.security.access.prepost.PreAuthorize;
 %0A%0Aimport
@@ -833,32 +833,120 @@
 ectEvent%7Ds%0A%09 */%0A
+%09@PreAuthorize(%22hasAnyRole('ROLE_ADMIN') or hasPermission(#project, 'canReadProject')%22)%0A
 %09public Page%3CPro
@@ -1243,21 +1243,83 @@
 Event%7Ds%0A
-
 %09 */%0A
+%09@PostFilter(%22hasPermission(filterObject, 'canReadProject')%22)%0A
 %09public 

Add permissions to ProjectEventService.