import java.util.TreeMap;
import java.util.TreeSet;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
import javax.xml.namespace.QName;
import org.argeo.api.acr.Content;
import org.argeo.api.cms.ux.CmsTheme;
import org.argeo.api.cms.ux.CmsUi;
import org.argeo.api.cms.ux.CmsView;
+import org.argeo.app.api.AppUserState;
import org.argeo.app.api.EntityConstants;
-import org.argeo.app.api.EntityNames;
+import org.argeo.app.api.EntityName;
import org.argeo.app.api.EntityType;
import org.argeo.app.api.RankedObject;
+import org.argeo.app.swt.ux.SwtAppLayer;
+import org.argeo.app.swt.ux.SwtAppUi;
+import org.argeo.app.ux.AppUi;
+import org.argeo.app.ux.SuiteUxEvent;
import org.argeo.cms.AbstractCmsApp;
-import org.argeo.cms.CmsUserManager;
import org.argeo.cms.LocaleUtils;
import org.argeo.cms.Localized;
import org.argeo.cms.acr.ContentUtils;
-import org.argeo.cms.jcr.CmsJcrUtils;
-import org.argeo.cms.jcr.acr.JcrContent;
import org.argeo.cms.swt.CmsSwtUtils;
import org.argeo.cms.swt.acr.SwtUiProvider;
import org.argeo.cms.swt.dialogs.CmsFeedback;
+import org.argeo.cms.util.LangUtils;
import org.argeo.cms.ux.CmsUxUtils;
import org.argeo.eclipse.ui.specific.UiContext;
-import org.argeo.jcr.JcrException;
-import org.argeo.util.LangUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.osgi.framework.Constants;
-import org.osgi.service.useradmin.User;
/** The Argeo Suite App. */
public class SuiteApp extends AbstractCmsApp implements CmsEventSubscriber {
// TODO use QName as key for byType
private Map<String, RankedObject<SwtUiProvider>> uiProvidersByPid = Collections.synchronizedMap(new HashMap<>());
private Map<String, RankedObject<SwtUiProvider>> uiProvidersByType = Collections.synchronizedMap(new HashMap<>());
- private Map<String, RankedObject<SuiteLayer>> layersByPid = Collections.synchronizedSortedMap(new TreeMap<>());
- private Map<String, RankedObject<SuiteLayer>> layersByType = Collections.synchronizedSortedMap(new TreeMap<>());
+ private Map<String, RankedObject<SwtAppLayer>> layersByPid = Collections.synchronizedSortedMap(new TreeMap<>());
+ private Map<String, RankedObject<SwtAppLayer>> layersByType = Collections.synchronizedSortedMap(new TreeMap<>());
- private CmsUserManager cmsUserManager;
+// private CmsUserManager cmsUserManager;
// TODO make more optimal or via CmsSession/CmsView
- private Map<String, SuiteUi> managedUis = new HashMap<>();
+ private Map<String, SwtAppUi> managedUis = new HashMap<>();
// ACR
private ContentRepository contentRepository;
-// private JcrContentProvider jcrContentProvider;
-
+ private AppUserState appUserState;
// JCR
// private Repository repository;
public void init(Map<String, Object> properties) {
- for (SuiteEvent event : SuiteEvent.values()) {
+ for (SuiteUxEvent event : SuiteUxEvent.values()) {
getCmsContext().getCmsEventBus().addEventSubscriber(event.topic(), this);
}
}
public void destroy(Map<String, Object> properties) {
- for (SuiteUi ui : managedUis.values())
+ for (SwtAppUi ui : managedUis.values())
if (!ui.isDisposed()) {
ui.getDisplay().syncExec(() -> ui.dispose());
}
CmsTheme theme = getTheme(uiName);
if (theme != null)
CmsSwtUtils.registerCmsTheme(uiParent.getShell(), theme);
- SuiteUi argeoSuiteUi = new SuiteUi(uiParent, SWT.INHERIT_DEFAULT);
+ SwtAppUi argeoSuiteUi = new SwtAppUi(uiParent, SWT.INHERIT_DEFAULT);
String uid = cmsView.getUid();
managedUis.put(uid, argeoSuiteUi);
argeoSuiteUi.addDisposeListener((e) -> {
public void refreshUi(CmsUi cmsUi, String state) {
try {
Content context = null;
- SuiteUi ui = (SuiteUi) cmsUi;
+ SwtAppUi ui = (SwtAppUi) cmsUi;
String uiName = Objects.toString(ui.getParent().getData(UI_NAME_PROPERTY), null);
if (uiName == null)
if (LOGIN.equals(state))
state = null;
if (ui.isLoginScreen()) {
-// if (state == null)
-// state = ui.getPostLoginState();
ui.setLoginScreen(false);
-// ui.setPostLoginState(null);
}
CmsSession cmsSession = cmsView.getCmsSession();
- if (ui.getUserDirNode() == null) {
+ if (ui.getUserDir() == null) {
// FIXME NPE on CMSSession when logging in from anonymous
if (cmsSession == null || cmsView.isAnonymous()) {
assert publicBasePath != null;
Content userDir = contentSession
.get(ContentUtils.SLASH + CmsConstants.SYS_WORKSPACE + publicBasePath);
ui.setUserDir(userDir);
-// ui.initSessions(getRepository(), publicBasePath);
} else {
-// Session adminSession = null;
-// try {
-// adminSession = CmsJcrUtils.openDataAdminSession(getRepository(), null);
-// Node userDirNode = SuiteUtils.getOrCreateCmsSessionNode(adminSession, cmsSession);
-// Content userDir = contentSession.get(CmsConstants.SYS_WORKSPACE + userDirNode.getPath());
-// ui.setUserDir(userDir);
-//// ui.initSessions(getRepository(), userDirNode.getPath());
-// } finally {
-// Jcr.logout(adminSession);
-// }
- Content userDir = contentSession.getSessionRunDir();
+ Content userDir = appUserState.getOrCreateSessionDir(contentSession, cmsSession);
ui.setUserDir(userDir);
+// Node userDirNode = jcrContentProvider.doInAdminSession((adminSession) -> {
+// Node node = SuiteUtils.getOrCreateCmsSessionNode(adminSession, cmsSession);
+// return node;
+// });
+// Content userDir = contentSession
+// .get(ContentUtils.SLASH + CmsConstants.SYS_WORKSPACE + userDirNode.getPath());
+// ui.setUserDir(userDir);
}
}
initLocale(cmsSession);
context = stateToNode(ui, state);
if (context == null)
- context = ui.getUserDirNode();
+ context = ui.getUserDir();
if (headerUiProvider != null)
refreshPart(headerUiProvider, ui.getHeader(), context);
ui.refreshBelowHeader(true);
for (String key : layersByPid.keySet()) {
- SuiteLayer layer = layersByPid.get(key).get();
+ SwtAppLayer layer = layersByPid.get(key).get();
ui.addLayer(key, layer);
}
return uiProvidersByPid.get(pid).get();
}
- private SuiteLayer findLayer(String pid) {
+ private SwtAppLayer findLayer(String pid) {
if (!layersByPid.containsKey(pid))
return null;
return layersByPid.get(pid).get();
if (content == null)
throw new IllegalArgumentException("A node should be provided");
- if (content instanceof JcrContent) {
- Node context = ((JcrContent) content).getJcrNode();
- try {
- // mixins
- Set<String> types = new TreeSet<>();
- for (NodeType mixinType : context.getMixinNodeTypes()) {
- String mixinTypeName = mixinType.getName();
- if (byType.containsKey(mixinTypeName)) {
- types.add(mixinTypeName);
- }
- for (NodeType superType : mixinType.getDeclaredSupertypes()) {
- if (byType.containsKey(superType.getName())) {
- types.add(superType.getName());
- }
- }
- }
- // primary node type
- NodeType primaryType = context.getPrimaryNodeType();
- String primaryTypeName = primaryType.getName();
- if (byType.containsKey(primaryTypeName)) {
- types.add(primaryTypeName);
- }
- for (NodeType superType : primaryType.getDeclaredSupertypes()) {
- if (byType.containsKey(superType.getName())) {
- types.add(superType.getName());
- }
- }
- // entity type
- if (context.isNodeType(EntityType.entity.get())) {
- if (context.hasProperty(EntityNames.ENTITY_TYPE)) {
- String entityTypeName = context.getProperty(EntityNames.ENTITY_TYPE).getString();
- if (byType.containsKey(entityTypeName)) {
- types.add(entityTypeName);
- }
- }
- }
-
-// if (context.getPath().equals("/")) {// root node
-// types.add("nt:folder");
+// boolean checkJcr = false;
+// if (checkJcr && content instanceof JcrContent) {
+// Node context = ((JcrContent) content).getJcrNode();
+// try {
+// // mixins
+// Set<String> types = new TreeSet<>();
+// for (NodeType mixinType : context.getMixinNodeTypes()) {
+// String mixinTypeName = mixinType.getName();
+// if (byType.containsKey(mixinTypeName)) {
+// types.add(mixinTypeName);
+// }
+// for (NodeType superType : mixinType.getDeclaredSupertypes()) {
+// if (byType.containsKey(superType.getName())) {
+// types.add(superType.getName());
+// }
+// }
+// }
+// // primary node type
+// NodeType primaryType = context.getPrimaryNodeType();
+// String primaryTypeName = primaryType.getName();
+// if (byType.containsKey(primaryTypeName)) {
+// types.add(primaryTypeName);
+// }
+// for (NodeType superType : primaryType.getDeclaredSupertypes()) {
+// if (byType.containsKey(superType.getName())) {
+// types.add(superType.getName());
+// }
+// }
+// // entity type
+// if (context.isNodeType(EntityType.entity.get())) {
+// if (context.hasProperty(EntityNames.ENTITY_TYPE)) {
+// String entityTypeName = context.getProperty(EntityNames.ENTITY_TYPE).getString();
+// if (byType.containsKey(entityTypeName)) {
+// types.add(entityTypeName);
+// }
+// }
+// }
+//
+// if (CmsJcrUtils.isUserHome(context) && byType.containsKey("nt:folder")) {// home node
+// types.add("nt:folder");
+// }
+//
+// if (types.size() == 0)
+// throw new IllegalArgumentException(
+// "No type found for " + context + " (" + listTypes(context) + ")");
+// String type = types.iterator().next();
+// if (!byType.containsKey(type))
+// throw new IllegalArgumentException("No component found for " + context + " with type " + type);
+// return byType.get(type).get();
+// } catch (RepositoryException e) {
+// throw new IllegalStateException(e);
// }
- if (CmsJcrUtils.isUserHome(context) && byType.containsKey("nt:folder")) {// home node
- types.add("nt:folder");
- }
-
- if (types.size() == 0)
- throw new IllegalArgumentException(
- "No type found for " + context + " (" + listTypes(context) + ")");
- String type = types.iterator().next();
- if (!byType.containsKey(type))
- throw new IllegalArgumentException("No component found for " + context + " with type " + type);
- return byType.get(type).get();
- } catch (RepositoryException e) {
- throw new IllegalStateException(e);
- }
-
- } else {
-
- List<QName> objectClasses = content.getContentClasses();
- Set<String> types = new TreeSet<>();
- for (QName cc : objectClasses) {
- String type = cc.getPrefix() + ":" + cc.getLocalPart();
- if (byType.containsKey(type))
- types.add(type);
- }
- if (types.size() == 0) {
- throw new IllegalArgumentException("No type found for " + content + " (" + objectClasses + ")");
- }
- String type = types.iterator().next();
- if (!byType.containsKey(type))
- throw new IllegalArgumentException("No component found for " + content + " with type " + type);
- return byType.get(type).get();
- // throw new UnsupportedOperationException("Content " +
- // content.getClass().getName() + " is not supported.");
+//
+// } else {
+ Set<String> types = new TreeSet<>();
+ if (content.hasContentClass(EntityType.entity.qName())) {
+ String type = content.attr(EntityName.type.qName());
+ if (type != null && byType.containsKey(type))
+ types.add(type);
}
- }
- private static String listTypes(Node context) {
- try {
- StringBuilder sb = new StringBuilder();
- sb.append(context.getPrimaryNodeType().getName());
- for (NodeType superType : context.getPrimaryNodeType().getDeclaredSupertypes()) {
- sb.append(' ');
- sb.append(superType.getName());
- }
-
- for (NodeType nodeType : context.getMixinNodeTypes()) {
- sb.append(' ');
- sb.append(nodeType.getName());
- if (nodeType.getName().equals(EntityType.local.get()))
- sb.append('/').append(context.getProperty(EntityNames.ENTITY_TYPE).getString());
- for (NodeType superType : nodeType.getDeclaredSupertypes()) {
- sb.append(' ');
- sb.append(superType.getName());
- }
- }
- return sb.toString();
- } catch (RepositoryException e) {
- throw new JcrException(e);
+ List<QName> objectClasses = content.getContentClasses();
+ for (QName cc : objectClasses) {
+ String type = cc.getPrefix() + ":" + cc.getLocalPart();
+ if (byType.containsKey(type))
+ types.add(type);
}
+ if (types.size() == 0) {
+ throw new IllegalArgumentException("No type found for " + content + " (" + objectClasses + ")");
+ }
+ String type = types.iterator().next();
+ if (!byType.containsKey(type))
+ throw new IllegalArgumentException("No component found for " + content + " with type " + type);
+ return byType.get(type).get();
+// }
}
+// private static String listTypes(Node context) {
+// try {
+// StringBuilder sb = new StringBuilder();
+// sb.append(context.getPrimaryNodeType().getName());
+// for (NodeType superType : context.getPrimaryNodeType().getDeclaredSupertypes()) {
+// sb.append(' ');
+// sb.append(superType.getName());
+// }
+//
+// for (NodeType nodeType : context.getMixinNodeTypes()) {
+// sb.append(' ');
+// sb.append(nodeType.getName());
+// if (nodeType.getName().equals(EntityType.local.get()))
+// sb.append('/').append(context.getProperty(EntityNames.ENTITY_TYPE).getString());
+// for (NodeType superType : nodeType.getDeclaredSupertypes()) {
+// sb.append(' ');
+// sb.append(superType.getName());
+// }
+// }
+// return sb.toString();
+// } catch (RepositoryException e) {
+// throw new JcrException(e);
+// }
+// }
+
@Override
public void setState(CmsUi cmsUi, String state) {
+ AppUi ui = (AppUi) cmsUi;
if (state == null)
return;
if (!state.startsWith("/")) {
- if (cmsUi instanceof SuiteUi) {
- SuiteUi ui = (SuiteUi) cmsUi;
- if (LOGIN.equals(state)) {
- String appTitle = "";
- if (ui.getTitle() != null)
- appTitle = ui.getTitle().lead();
- ui.getCmsView().stateChanged(state, appTitle);
- return;
- }
- Map<String, Object> properties = new HashMap<>();
- String layerId = HOME_STATE.equals(state) ? defaultLayerPid : state;
- properties.put(SuiteEvent.LAYER, layerId);
- properties.put(SuiteEvent.NODE_PATH, HOME_STATE);
- ui.getCmsView().sendEvent(SuiteEvent.switchLayer.topic(), properties);
+// if (cmsUi instanceof SwtAppUi) {
+// SwtAppUi ui = (SwtAppUi) cmsUi;
+ if (LOGIN.equals(state)) {
+ String appTitle = "";
+ if (ui.getTitle() != null)
+ appTitle = ui.getTitle().lead();
+ ui.getCmsView().stateChanged(state, appTitle);
+ return;
}
+ Map<String, Object> properties = new HashMap<>();
+ String layerId = HOME_STATE.equals(state) ? defaultLayerPid : state;
+ properties.put(SuiteUxEvent.LAYER, layerId);
+ properties.put(SuiteUxEvent.CONTENT_PATH, HOME_STATE);
+ ui.getCmsView().sendEvent(SuiteUxEvent.switchLayer.topic(), properties);
+// }
return;
}
- SuiteUi suiteUi = (SuiteUi) cmsUi;
- if (suiteUi.isLoginScreen()) {
-// suiteUi.setPostLoginState(state);
+// SwtAppUi suiteUi = (SwtAppUi) cmsUi;
+ if (ui.isLoginScreen()) {
return;
}
- Content node = stateToNode(suiteUi, state);
+ Content node = stateToNode(ui, state);
if (node == null) {
- suiteUi.getCmsView().navigateTo(HOME_STATE);
+ ui.getCmsView().navigateTo(HOME_STATE);
} else {
- suiteUi.getCmsView().sendEvent(SuiteEvent.switchLayer.topic(), SuiteEvent.eventProperties(node));
- suiteUi.getCmsView().sendEvent(SuiteEvent.refreshPart.topic(), SuiteEvent.eventProperties(node));
+ ui.getCmsView().sendEvent(SuiteUxEvent.switchLayer.topic(), SuiteUxEvent.eventProperties(node));
+ ui.getCmsView().sendEvent(SuiteUxEvent.refreshPart.topic(), SuiteUxEvent.eventProperties(node));
}
}
// TODO move it to an internal package?
- static String nodeToState(Content node) {
+ public static String nodeToState(Content node) {
return node.getPath();
}
- private Content stateToNode(SuiteUi suiteUi, String state) {
+ private Content stateToNode(CmsUi suiteUi, String state) {
if (suiteUi == null)
return null;
if (state == null || !state.startsWith("/"))
return null;
String path = state;
-// String path = state.substring(1);
-// String workspace;
-// if (path.equals("")) {
-// workspace = null;
-// path = "/";
-// } else {
-// int index = path.indexOf('/');
-// if (index == 0) {
-// log.error("Cannot interpret " + state);
-//// cmsView.navigateTo("~");
-// return null;
-// } else if (index > 0) {
-// workspace = path.substring(0, index);
-// path = path.substring(index);
-// } else {// index<0, assuming root node
-// workspace = path;
-// path = "/";
-// }
-// }
ProvidedSession contentSession = (ProvidedSession) CmsUxUtils.getContentSession(contentRepository,
suiteUi.getCmsView());
return contentSession.get(path);
-// Session session = jcrContentProvider.getJcrSession(contentSession, workspace);
-//// Session session = suiteUi.getSession(workspace);
-// if (session == null)
-// return null;
-// Node node = Jcr.getNode(session, path);
-// return node;
}
/*
public void onEvent(String topic, Map<String, Object> event) {
// Specific UI related events
- SuiteUi ui = getRelatedUi(event);
+ SwtAppUi ui = getRelatedUi(event);
if (ui == null)
return;
ui.getCmsView().runAs(() -> {
if (ui.getTitle() != null)
appTitle = ui.getTitle().lead() + " - ";
-// String currentLayerId = ui.getCurrentLayerId();
-// SuiteLayer currentLayer = currentLayerId != null ? layersByPid.get(currentLayerId).get() : null;
- if (SuiteUiUtils.isTopic(topic, SuiteEvent.refreshPart)) {
- Content node = getNode(ui, event);
+ if (SuiteUiUtils.isTopic(topic, SuiteUxEvent.refreshPart)) {
+ Content node = getContentFromEvent(ui, event);
if (node == null)
return;
SwtUiProvider uiProvider = findByType(uiProvidersByType, node);
- SuiteLayer layer = findByType(layersByType, node);
+ SwtAppLayer layer = findByType(layersByType, node);
ui.switchToLayer(layer, node);
layer.view(uiProvider, ui.getCurrentWorkArea(), node);
ui.getCmsView().stateChanged(nodeToState(node), appTitle + CmsUxUtils.getTitle(node));
- } else if (SuiteUiUtils.isTopic(topic, SuiteEvent.openNewPart)) {
- Content node = getNode(ui, event);
+ } else if (SuiteUiUtils.isTopic(topic, SuiteUxEvent.openNewPart)) {
+ Content node = getContentFromEvent(ui, event);
if (node == null)
return;
SwtUiProvider uiProvider = findByType(uiProvidersByType, node);
- SuiteLayer layer = findByType(layersByType, node);
+ SwtAppLayer layer = findByType(layersByType, node);
ui.switchToLayer(layer, node);
layer.open(uiProvider, ui.getCurrentWorkArea(), node);
ui.getCmsView().stateChanged(nodeToState(node), appTitle + CmsUxUtils.getTitle(node));
- } else if (SuiteUiUtils.isTopic(topic, SuiteEvent.switchLayer)) {
- String layerId = get(event, SuiteEvent.LAYER);
+ } else if (SuiteUiUtils.isTopic(topic, SuiteUxEvent.switchLayer)) {
+ String layerId = get(event, SuiteUxEvent.LAYER);
if (layerId != null) {
-// ui.switchToLayer(layerId, ui.getUserDir());
- SuiteLayer suiteLayer = findLayer(layerId);
+ SwtAppLayer suiteLayer = findLayer(layerId);
if (suiteLayer == null)
throw new IllegalArgumentException("No layer '" + layerId + "' available.");
Localized layerTitle = suiteLayer.getTitle();
// FIXME make sure we don't rebuild the work area twice
- Composite workArea = ui.switchToLayer(layerId, ui.getUserDirNode());
+ Composite workArea = ui.switchToLayer(layerId, ui.getUserDir());
String title = null;
if (layerTitle != null)
title = layerTitle.lead();
- Content nodeFromState = getNode(ui, event);
- if (nodeFromState != null && nodeFromState.getPath().equals(ui.getUserDirNode().getPath())) {
+ Content nodeFromState = getContentFromEvent(ui, event);
+ if (nodeFromState != null && nodeFromState.getPath().equals(ui.getUserDir().getPath())) {
// default layer view is forced
String state = defaultLayerPid.equals(layerId) ? "~" : layerId;
ui.getCmsView().stateChanged(state, appTitle + title);
suiteLayer.view(null, workArea, nodeFromState);
} else {
Content layerCurrentContext = suiteLayer.getCurrentContext(workArea);
- if (layerCurrentContext != null) {
+ if (layerCurrentContext != null && !layerCurrentContext.equals(ui.getUserDir())) {
// layer was already showing a context so we set the state to it
ui.getCmsView().stateChanged(nodeToState(layerCurrentContext),
appTitle + CmsUxUtils.getTitle(layerCurrentContext));
}
}
} else {
- Content node = getNode(ui, event);
+ Content node = getContentFromEvent(ui, event);
if (node != null) {
- SuiteLayer layer = findByType(layersByType, node);
+ SwtAppLayer layer = findByType(layersByType, node);
ui.switchToLayer(layer, node);
}
}
});
}
- private Content getNode(SuiteUi ui, Map<String, Object> event) {
+ protected Content getContentFromEvent(SwtAppUi ui, Map<String, Object> event) {
ProvidedSession contentSession = (ProvidedSession) CmsUxUtils.getContentSession(contentRepository,
ui.getCmsView());
- String path = get(event, SuiteEvent.CONTENT_PATH);
+ String path = get(event, SuiteUxEvent.CONTENT_PATH);
-// String nodePath = get(event, SuiteEvent.NODE_PATH);
- if (path != null && path.equals(HOME_STATE))
+ if (path != null && (path.equals(HOME_STATE) || path.equals("")))
return ui.getUserDir();
-// String workspace = get(event, SuiteEvent.WORKSPACE);
-
-// Session session = jcrContentProvider.getJcrSession(contentSession, workspace);
-//// Session session = ui.getSession(workspace);
Content node;
if (path == null) {
- // look for a user
- String username = get(event, SuiteEvent.USERNAME);
- if (username == null)
- return null;
- User user = cmsUserManager.getUser(username);
- if (user == null)
- return null;
- node = ContentUtils.roleToContent(cmsUserManager, contentSession, user);
-// LdapName userDn;
-// try {
-// userDn = new LdapName(user.getName());
-// } catch (InvalidNameException e) {
-// throw new IllegalArgumentException("Badly formatted username", e);
-// }
-// String userNodePath = SuiteUtils.getUserNodePath(userDn);
- // FIXME deal with home path
-// return null;
-// if (Jcr.itemExists(session, userNodePath))
-// node = Jcr.getNode(session, userNodePath);
-// else {
-// Session adminSession = null;
-// try {
-// adminSession = CmsJcrUtils.openDataAdminSession(getRepository(), workspace);
-// SuiteUtils.getOrCreateUserNode(adminSession, userDn);
-// } finally {
-// Jcr.logout(adminSession);
-// }
-// node = Jcr.getNode(session, userNodePath);
-// }
+ return null;
+// // look for a user
+// String username = get(event, SuiteUxEvent.USERNAME);
+// if (username == null)
+// return null;
+// User user = cmsUserManager.getUser(username);
+// if (user == null)
+// return null;
+// node = ContentUtils.roleToContent(cmsUserManager, contentSession, user);
} else {
node = contentSession.get(path);
}
return node;
}
- private SuiteUi getRelatedUi(Map<String, Object> eventProperties) {
+ private SwtAppUi getRelatedUi(Map<String, Object> eventProperties) {
return managedUis.get(get(eventProperties, CMS_VIEW_UID_PROPERTY));
}
Object value = eventProperties.get(key);
if (value == null)
return null;
-// throw new IllegalArgumentException("Property " + key + " must be set");
return value.toString();
}
}
}
-// public void addLayer(SuiteLayer layer, Map<String, Object> properties) {
-// if (!properties.containsKey(Constants.SERVICE_PID))
-// throw new IllegalArgumentException("A layer must have an ID");
-// String pid = (String) properties.get(Constants.SERVICE_PID);
-// List<String> types = properties.containsKey(EntityConstants.TYPE)
-// ? LangUtils.toStringList(properties.get(EntityConstants.TYPE))
-// : new ArrayList<>();
-// if (types.isEmpty()) {
-// RankedObject.putIfHigherRank(layersByPid, pid, layer, properties);
-// } else {
-// if (layersByPid.containsKey(pid)) {
-// RankedObject<SuiteLayer> current = layersByPid.get(pid);
-// List<String> currentTypes = current.getProperties().containsKey(EntityConstants.TYPE)
-// ? LangUtils.toStringList(current.getProperties().get(EntityConstants.TYPE))
-// : new ArrayList<>();
-// if (!types.containsAll(currentTypes)) {
-// throw new IllegalArgumentException("Higher-ranked layer " + pid + " contains only types " + types
-// + ", while it must override all " + currentTypes);
-// }
-// }
-// RankedObject.putIfHigherRank(layersByPid, pid, layer, properties);
-// for (String type : types)
-// RankedObject.putIfHigherRank(layersByType, type, layer, properties);
-// }
-// }
-
- public void addLayer(SuiteLayer layer, Map<String, Object> properties) {
+ public void addLayer(SwtAppLayer layer, Map<String, Object> properties) {
if (properties.containsKey(Constants.SERVICE_PID)) {
String pid = (String) properties.get(Constants.SERVICE_PID);
RankedObject.putIfHigherRank(layersByPid, pid, layer, properties);
}
}
- public void removeLayer(SuiteLayer layer, Map<String, Object> properties) {
+ public void removeLayer(SwtAppLayer layer, Map<String, Object> properties) {
if (properties.containsKey(Constants.SERVICE_PID)) {
String pid = (String) properties.get(Constants.SERVICE_PID);
if (layersByPid.containsKey(pid)) {
- if (layersByPid.get(pid).equals(new RankedObject<SuiteLayer>(layer, properties))) {
+ if (layersByPid.get(pid).equals(new RankedObject<SwtAppLayer>(layer, properties))) {
layersByPid.remove(pid);
}
}
List<String> types = LangUtils.toStringList(properties.get(EntityConstants.TYPE));
for (String type : types) {
if (layersByType.containsKey(type)) {
- if (layersByType.get(type).equals(new RankedObject<SuiteLayer>(layer, properties))) {
+ if (layersByType.get(type).equals(new RankedObject<SwtAppLayer>(layer, properties))) {
layersByType.remove(type);
}
}
}
}
- public void setCmsUserManager(CmsUserManager cmsUserManager) {
- this.cmsUserManager = cmsUserManager;
- }
-
-// protected Repository getRepository() {
-// return repository;
-// }
-//
-// public void setRepository(Repository repository) {
-// this.repository = repository;
+// public void setCmsUserManager(CmsUserManager cmsUserManager) {
+// this.cmsUserManager = cmsUserManager;
// }
- protected ContentRepository getContentRepository() {
- return contentRepository;
- }
+// protected ContentRepository getContentRepository() {
+// return contentRepository;
+// }
public void setContentRepository(ContentRepository contentRepository) {
this.contentRepository = contentRepository;
}
-// public void setJcrContentProvider(JcrContentProvider jcrContentProvider) {
-// this.jcrContentProvider = jcrContentProvider;
-// }
+ public void setAppUserState(AppUserState appUserState) {
+ this.appUserState = appUserState;
+ }
}