+ if (NodeUtils.isUserHome(context) && byType.containsKey("nt:folder")) {// home node
+ types.add("nt:folder");
+ }
+
+ if (types.size() == 0)
+ throw new IllegalArgumentException("No type found for " + 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);
+ }
+ }
+
+ @Override
+ public void setState(Composite parent, String state) {
+ if (state == null || !state.startsWith("/"))
+ return;
+ SuiteUi suiteUi = (SuiteUi) parent;
+ Node node = stateToNode(suiteUi, state);
+ if (node == null) {
+ suiteUi.getCmsView().navigateTo("~");
+ } else {
+ suiteUi.getCmsView().sendEvent(SuiteEvent.switchLayer.topic(), SuiteEvent.eventProperties(node));
+ suiteUi.getCmsView().sendEvent(SuiteEvent.refreshPart.topic(), SuiteEvent.eventProperties(node));
+ }
+
+// CmsView cmsView = CmsView.getCmsView(parent);
+// if (cmsView.isAnonymous())
+// return;
+// Session session = null;
+// try {
+// if (state != null && state.startsWith("/")) {
+// 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;
+// } else if (index > 0) {
+// workspace = path.substring(0, index);
+// path = path.substring(index);
+// } else {// index<0, assuming root node
+// workspace = path;
+// path = "/";
+// }
+// }
+// session = cmsView.doAs(() -> Jcr.login(getRepository(), workspace));