1 package com.edf.gde.ejb;
3 import com.edf.gde.common.PermissionManager;
4 import java.util.HashMap;
6 import javax.annotation.PostConstruct;
7 import javax.ejb.Singleton;
8 import javax.ejb.LocalBean;
9 import javax.persistence.EntityManager;
10 import javax.persistence.PersistenceContext;
17 public class ApplicationEJB {
23 @PersistenceContext(unitName = "GDE-ejbPU")
24 private EntityManager em;
26 private Map<Long, Long> userFiles;
27 private PermissionManager permissionManager;
34 userFiles = new HashMap<>();
35 permissionManager = new PermissionManager();
43 * @return true if file is locked, false if file is already locked by
46 public boolean lockFile(long userId, long fileId) {
47 if (userFiles.containsKey(fileId)) {
48 if (userFiles.get(fileId) == userId) {
53 userFiles.put(fileId, userId);
58 * Try to unlock a file
63 public boolean unlockFile(long userId, long fileId) {
64 if (userFiles.containsKey(fileId)) {
65 if (userFiles.get(fileId) == userId) {
66 userFiles.remove(fileId);
73 public PermissionManager getPermissionManager() {
74 return permissionManager;
77 private void loadPermissions() {