Bug 571599 - Cannot create preferences in Administration component

Change-Id: I02819990b42cbbbf518daf6891d5cd8c1e34e04f
Signed-off-by: Matthias Koller <m.koller@peak-solution.de>
diff --git a/nucleus/preferences/src/main/java/org/eclipse/mdm/preferences/controller/PreferenceService.java b/nucleus/preferences/src/main/java/org/eclipse/mdm/preferences/controller/PreferenceService.java
index 2e8d4a1..1e8337e 100644
--- a/nucleus/preferences/src/main/java/org/eclipse/mdm/preferences/controller/PreferenceService.java
+++ b/nucleus/preferences/src/main/java/org/eclipse/mdm/preferences/controller/PreferenceService.java
@@ -20,6 +20,7 @@
 import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
+import javax.annotation.security.DeclareRoles;
 import javax.ejb.SessionContext;
 import javax.ejb.Stateless;
 import javax.persistence.EntityManager;
@@ -41,6 +42,7 @@
  *
  */
 @Stateless
+@DeclareRoles("Admin")
 public class PreferenceService {
 	private static final Logger LOG = LoggerFactory.getLogger(PreferenceService.class);
 
@@ -124,9 +126,8 @@
 			em.flush();
 			return convert(pe);
 		} else {
-			throw new PreferenceException(
-					"Only users with role " + ADMIN_ROLE
-							+ " are allowed to save Preferences outside of the USER scope!");
+			throw new PreferenceException("Only users with role " + ADMIN_ROLE
+					+ " are allowed to save Preferences outside of the USER scope!");
 		}
 
 	}
@@ -145,9 +146,8 @@
 	}
 
 	private boolean isAllowed(Preference preference) {
-		return sessionContext.isCallerInRole(ADMIN_ROLE)
-				|| (preference.getUser() != null
-						&& preference.getUser().equalsIgnoreCase(sessionContext.getCallerPrincipal().getName()));
+		return sessionContext.isCallerInRole(ADMIN_ROLE) || (preference.getUser() != null
+				&& preference.getUser().equalsIgnoreCase(sessionContext.getCallerPrincipal().getName()));
 	}
 
 	private PreferenceMessage convert(Preference pe) {