- // for the time being we systematically open a session, in order to make sure
- // that home is initialised
- 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));
+ 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));
+//
+// Node node = session.getNode(path);
+//
+// cmsView.sendEvent(SuiteEvent.switchLayer.topic(), SuiteEvent.eventProperties(node));
+// cmsView.sendEvent(SuiteEvent.refreshPart.topic(), SuiteEvent.eventProperties(node));
+// }
+// } catch (RepositoryException e) {
+// log.error("Cannot load state " + state, e);
+// cmsView.navigateTo("~");
+// } finally {
+// JcrUtils.logoutQuietly(session);
+// }
+ }
+
+ private String nodeToState(Node node) {
+ return '/' + Jcr.getWorkspaceName(node) + Jcr.getPath(node);
+ }