use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class PageTreeTag method doStartTag.
@Override
public int doStartTag() throws JspException {
try {
IPageActionHelper helper = this.getHelper(this.isOnline());
ITreeNode root = this.getAllowedTreeRootNode(helper);
ValueStack stack = this.getStack();
stack.getContext().put(this.getVar(), root);
stack.setValue("#attr['" + this.getVar() + "']", root, false);
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
throw new JspException("Error during tag initialization", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class PageTreeTag method getAllowedTreeRootNode.
public ITreeNode getAllowedTreeRootNode(ITreeNodeBaseActionHelper helper) {
ITreeNode root = null;
try {
root = helper.getAllowedTreeRoot(this.getAllowedGroups());
if (this.isOnDemand()) {
Collection<String> allowedGroups = this.convertCollection(this.getAllowedGroups());
root = helper.getShowableTree(this.getTargetNodes(allowedGroups, helper), root, allowedGroups);
}
} catch (Throwable t) {
_logger.error("error in getAllowedTreeRootNode", t);
}
return root;
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestCategoryAction method testViewTree.
public void testViewTree() throws Throwable {
this.setUserOnSession("pageManagerCoach");
this.initAction("/do/Category", "viewTree");
String result = this.executeAction();
assertEquals("userNotAllowed", result);
this.setUserOnSession("admin");
this.initAction("/do/Category", "viewTree");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
CategoryAction action = (CategoryAction) this.getAction();
ITreeNode root = action.getTreeRootNode();
assertEquals(this._categoryManager.getRoot().getCode(), root.getCode());
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestPageTreeAction method checkTestViewTree_3_4.
private void checkTestViewTree_3_4() throws Throwable {
ITreeNode showableRoot = ((PageTreeAction) this.getAction()).getShowableTree();
assertEquals("homepage", showableRoot.getCode());
assertTrue(showableRoot instanceof TreeNodeWrapper);
ITreeNode[] children = ((TreeNodeWrapper) showableRoot).getChildren();
assertEquals(7, children.length);
boolean check = false;
for (int i = 0; i < children.length; i++) {
TreeNodeWrapper child = (TreeNodeWrapper) children[i];
if (child.getCode().equals("pagina_1")) {
assertEquals(2, child.getChildrenCodes().length);
assertEquals("pagina_11", child.getChildrenCodes()[0]);
assertEquals("pagina_12", child.getChildrenCodes()[1]);
check = true;
} else {
assertEquals(0, child.getChildrenCodes().length);
}
}
if (!check) {
fail();
}
}
use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.
the class TestPageTreeAction method testViewTree_2.
public void testViewTree_2() throws Throwable {
this.initAction("/do/Page", "viewTree");
this.setUserOnSession("pageManagerCustomers");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
ITreeNode root = ((PageTreeAction) this.getAction()).getAllowedTreeRootNode();
assertNotNull(root);
assertEquals(AbstractPortalAction.VIRTUAL_ROOT_CODE, root.getCode());
assertEquals(1, root.getChildrenCodes().length);
assertEquals("customers_page", root.getChildrenCodes()[0]);
ITreeNode showableRoot = ((PageTreeAction) this.getAction()).getShowableTree();
assertEquals(AbstractPortalAction.VIRTUAL_ROOT_CODE, showableRoot.getCode());
assertEquals(0, showableRoot.getChildrenCodes().length);
}
Aggregations