package de.terrestris.shogun2.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import de.terrestris.shogun2.model.PersistentObject;

/**
 * This abstract service class provides basic CRUD functionality.
 * 
 * @author Nils Bühner
 * @see AbstractDaoService
 * 
 */
public abstract class AbstractCrudService<E extends PersistentObject> extends
		AbstractDaoService<E> {

	/**
	 * 
	 * @param e
	 * @return
	 */
	@Transactional(readOnly = false)
	public E saveOrUpdate(E e) {
		dao.saveOrUpdate(e);
		return e;
	}

	/**
	 * 
	 * @param id
	 * @return
	 */
	public E findById(Integer id) {
		return dao.findById(id);
	}

	/**
	 * 
	 * @return
	 */
	public List<E> findAll() {
		return dao.findAll();
	}

	/**
	 * 
	 * @param e
	 */
	@Transactional(readOnly = false)
	public void delete(E e) {
		dao.delete(e);
	}

}

@@ -57,16 +57,210 @@
 .List;%0A%0A
+import org.springframework.security.access.prepost.PostAuthorize;%0Aimport org.springframework.security.access.prepost.PostFilter;%0Aimport org.springframework.security.access.prepost.PreAuthorize;%0A
 import o
@@ -316,16 +316,16 @@
 tional;%0A
-
 %0Aimport 
@@ -674,32 +674,68 @@
 adOnly = false)%0A
+%09@PreAuthorize(%22isAuthenticated()%22)%0A
 %09public E saveOr
@@ -820,32 +820,87 @@
  * @return%0A%09 */%0A
+%09@PostAuthorize(%22hasPermission(returnObject, 'READ')%22)%0A
 %09public E findBy
@@ -974,16 +974,68 @@
 rn%0A%09 */%0A
+%09@PostFilter(%22hasPermission(filterObject, 'READ')%22)%0A
 %09public 
@@ -1105,21 +1105,67 @@
 param e%0A
-
 %09 */%0A
+%09@PreAuthorize(%22hasPermission(#e, 'DELETE')%22)%0A
 %09@Transa

Add basic security annotations to the CRUD service