Suite user administration.
[gpl/argeo-suite.git] / org.argeo.suite.ui / src / org / argeo / suite / ui / SuiteEvent.java
1 package org.argeo.suite.ui;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import javax.jcr.Node;
7
8 import org.argeo.cms.ui.util.CmsEvent;
9 import org.argeo.jcr.Jcr;
10 import org.osgi.service.useradmin.User;
11
12 /** Events specific to Argeo Suite. */
13 public enum SuiteEvent implements CmsEvent {
14         openNewPart, refreshPart, switchLayer;
15
16         public final static String LAYER = "layer";
17         public final static String NODE_ID = "nodeId";
18         public final static String USERNAME = "username";
19         public final static String WORKSPACE = "workspace";
20
21         public String getTopicBase() {
22                 return "argeo/suite/ui";
23         }
24
25         public static Map<String, Object> eventProperties(Node node) {
26                 Map<String, Object> properties = new HashMap<>();
27                 properties.put(NODE_ID, Jcr.getIdentifier(node));
28                 properties.put(WORKSPACE, Jcr.getWorkspaceName(node));
29                 return properties;
30         }
31
32         public static Map<String, Object> eventProperties(User user) {
33                 Map<String, Object> properties = new HashMap<>();
34                 properties.put(USERNAME, user.getName());
35                 return properties;
36         }
37 }