1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.admininterface;
35
36 import info.magnolia.cms.core.Content;
37 import info.magnolia.cms.core.HierarchyManager;
38 import info.magnolia.cms.core.NodeData;
39 import info.magnolia.cms.core.Path;
40 import info.magnolia.cms.exchange.ExchangeException;
41 import info.magnolia.cms.exchange.Syndicator;
42 import info.magnolia.cms.gui.control.ControlImpl;
43 import info.magnolia.cms.gui.control.Tree;
44 import info.magnolia.cms.gui.misc.Sources;
45 import info.magnolia.cms.i18n.Messages;
46 import info.magnolia.cms.i18n.MessagesManager;
47 import info.magnolia.cms.i18n.MessagesUtil;
48 import info.magnolia.cms.security.AccessDeniedException;
49 import info.magnolia.cms.servlets.CommandBasedMVCServletHandler;
50 import info.magnolia.cms.util.AlertUtil;
51 import info.magnolia.cms.util.ContentUtil;
52 import info.magnolia.cms.util.ExclusiveWrite;
53 import info.magnolia.commands.CommandsManager;
54 import info.magnolia.context.Context;
55 import info.magnolia.context.MgnlContext;
56 import info.magnolia.module.admininterface.commands.BaseActivationCommand;
57 import info.magnolia.objectfactory.Classes;
58
59 import java.io.IOException;
60 import java.util.Iterator;
61
62 import javax.jcr.PathNotFoundException;
63 import javax.jcr.PropertyType;
64 import javax.jcr.RepositoryException;
65 import javax.servlet.http.HttpServletRequest;
66 import javax.servlet.http.HttpServletResponse;
67
68 import org.apache.commons.chain.Command;
69 import org.apache.commons.lang.StringUtils;
70 import org.slf4j.Logger;
71 import org.slf4j.LoggerFactory;
72
73
74
75
76
77
78
79
80
81 public class AdminTreeMVCHandler extends CommandBasedMVCServletHandler {
82
83
84
85
86 protected static final String COMMAND_SHOW_TREE = "show";
87
88 protected static final String COMMAND_COPY_NODE = "copy";
89
90 protected static final String COMMAND_MOVE_NODE = "move";
91
92 protected static final String COMMAND_ACTIVATE = "activate";
93
94 protected static final String COMMAND_DEACTIVATE = "deactivate";
95
96 protected static final String COMMAND_CREATE_NODE = "createNode";
97
98 protected static final String COMMAND_DELETE_NODE = "delete";
99
100 protected static final String COMMAND_SAVE_VALUE = "saveValue";
101
102
103
104
105
106 protected static final String VIEW_TREE = "tree";
107
108 protected static final String VIEW_CREATE = "create";
109
110 protected static final String VIEW_VALUE = "value";
111
112 protected static final String VIEW_NOTHING = "nothing";
113
114 protected static final String VIEW_COPY_MOVE = "copymove";
115
116
117
118
119 private static Logger log = LoggerFactory.getLogger(AdminTreeMVCHandler.class);
120
121
122
123
124 protected Tree tree;
125
126
127
128
129 private String treeClass = Tree.class.getName();
130
131
132
133
134
135 private String configurationClass;
136
137
138
139
140 protected AdminTreeConfiguration configuration;
141
142 protected String newNodeName = "untitled";
143
144 protected String createItemType = Tree.ITEM_TYPE_NODEDATA;
145
146 protected String path;
147
148 protected String pathOpen;
149
150 protected String pathSelected;
151
152 protected String rootPath;
153
154
155
156
157 protected String displayValue;
158
159 protected String newPath;
160
161 private String repository;
162
163 private String i18nBasename;
164
165
166
167
168 protected boolean browseMode;
169
170 private boolean enableDeleteConfirmation = true;
171
172
173
174
175
176 public String getRepository() {
177 if (repository == null) {
178 repository = this.getName();
179 }
180 return repository;
181 }
182
183 public void setRepository(String repository) {
184 this.repository = repository;
185 }
186
187
188
189
190 public HierarchyManager getHierarchyManager() {
191 return MgnlContext.getHierarchyManager(this.getRepository());
192 }
193
194 public AdminTreeMVCHandler(String name, HttpServletRequest request, HttpServletResponse response) {
195 super(name, request, response);
196 }
197
198 @Override
199 public void init() {
200 super.init();
201
202 path = this.getRequest().getParameter("path");
203 if (StringUtils.isEmpty(path)) {
204 if(StringUtils.isNotEmpty(this.getRootPath())){
205 path = this.getRootPath();
206 }
207 else{
208 path = "/";
209 }
210 }
211
212 pathOpen = this.getRequest().getParameter("pathOpen");
213 pathSelected = this.getRequest().getParameter("pathSelected");
214
215 this.setBrowseMode(StringUtils.equals(this.getRequest().getParameter("browseMode"), "true"));
216 }
217
218
219
220
221
222 @Override
223 public String getCommand() {
224
225 if (StringUtils.isNotEmpty(super.getCommand())) {
226 return super.getCommand();
227 }
228
229 if (StringUtils.isNotEmpty(this.getRequest().getParameter("treeAction"))) {
230 int treeAction = Integer.parseInt(this.getRequest().getParameter("treeAction"));
231
232 if (treeAction == Tree.ACTION_COPY) {
233 return COMMAND_COPY_NODE;
234 }
235 if (treeAction == Tree.ACTION_MOVE) {
236 return COMMAND_MOVE_NODE;
237 }
238 if (treeAction == Tree.ACTION_ACTIVATE) {
239 return COMMAND_ACTIVATE;
240 }
241 if (treeAction == Tree.ACTION_DEACTIVATE) {
242 return COMMAND_DEACTIVATE;
243 }
244
245 return this.getRequest().getParameter("treeAction");
246 }
247
248
249 if (this.getRequest().getParameter("createItemType") != null) {
250 return COMMAND_CREATE_NODE;
251 }
252
253 if (this.getRequest().getParameter("deleteNode") != null) {
254 return COMMAND_DELETE_NODE;
255 }
256
257
258 if (this.getRequest().getParameter("saveName") != null
259 || this.getRequest().getParameter("saveValue") != null
260
261 || "true".equals(this.getRequest().getParameter("isNodeDataValue"))
262
263 || "true".equals(this.getRequest().getParameter("isNodeDataType"))) {
264 return COMMAND_SAVE_VALUE;
265 }
266
267 return COMMAND_SHOW_TREE;
268 }
269
270
271
272
273 @Override
274 protected Context getCommandContext(String commandName) {
275 Context context = MgnlContext.getInstance();
276
277
278 context.put(Context.ATTRIBUTE_REPOSITORY, this.getRepository());
279
280 if ("activate".equals(commandName) || "deactivate".equals(commandName)) {
281 context.put(BaseActivationCommand.ATTRIBUTE_SYNDICATOR, getActivationSyndicator(this.pathSelected));
282 if (this.pathSelected != null) {
283 try {
284 final String uuid = MgnlContext.getHierarchyManager(repository).getContent(this.pathSelected).getUUID();
285
286 context.put(Context.ATTRIBUTE_UUID, uuid);
287
288 final String realPath = MgnlContext.getSystemContext().getHierarchyManager(repository).getContentByUUID(uuid).getHandle();
289 context.put(Context.ATTRIBUTE_PATH, realPath);
290 } catch (RepositoryException e) {
291
292 log.error("Failed to retrieve content node [{}:{}].", this.repository, this.pathSelected);
293 }
294 }
295 } else if (this.pathSelected != null) {
296
297
298 context.put(Context.ATTRIBUTE_PATH, this.pathSelected);
299 }
300
301 return context;
302 }
303
304
305
306
307 @Override
308 protected Command findCommand(String commandName) {
309 Command cmd = super.findCommand(commandName);
310 if (cmd == null) {
311 cmd = CommandsManager.getInstance().getCommand(CommandsManager.DEFAULT_CATALOG, commandName);
312 }
313 return cmd;
314 }
315
316
317
318
319 @Override
320 protected String getViewNameAfterExecution(String commandName, Context ctx) {
321 return VIEW_TREE;
322 }
323
324
325
326
327 public String show() {
328 return VIEW_TREE;
329 }
330
331
332
333
334
335 public String createNode() {
336 getTree().setPath(path);
337 synchronized (ExclusiveWrite.getInstance()) {
338 String name = getTree().createNode(this.getNewNodeName(), createItemType);
339 setNewNodeName(name);
340 }
341 return VIEW_TREE;
342 }
343
344
345
346
347 public String copy() {
348 try {
349 synchronized (ExclusiveWrite.getInstance()) {
350 copyOrMove(Tree.ACTION_COPY);
351 }
352 }
353 catch (Exception e) {
354 log.error("can't copy", e);
355 AlertUtil.setMessage(MessagesManager.get("tree.error.copy") + " " + AlertUtil.getExceptionMessage(e));
356 }
357 return VIEW_COPY_MOVE;
358 }
359
360
361
362
363 public String move() {
364 try {
365 synchronized (ExclusiveWrite.getInstance()) {
366 copyOrMove(Tree.ACTION_MOVE);
367 }
368 }
369 catch (Exception e) {
370 log.error("can't move", e);
371 AlertUtil.setMessage(MessagesManager.get("tree.error.move") + " " + AlertUtil.getExceptionMessage(e));
372 }
373 return VIEW_COPY_MOVE;
374
375 }
376
377
378
379
380
381
382 private void copyOrMove(int action) throws ExchangeException, RepositoryException {
383 String pathClipboard = this.getRequest().getParameter("pathClipboard");
384 int pasteType = Integer.parseInt(this.getRequest().getParameter("pasteType"));
385 newPath = pasteNode(pathClipboard, pathSelected, pasteType, action);
386
387 if (pasteType == Tree.PASTETYPE_SUB) {
388 pathOpen = pathSelected;
389 }
390 else {
391
392 pathOpen = pathSelected.substring(0, pathSelected.lastIndexOf("/"));
393 }
394
395 pathSelected = null;
396 }
397
398 public void deleteNode(String parentPath, String label) throws ExchangeException, RepositoryException {
399 Content parentNode = getHierarchyManager().getContent(parentPath);
400 String path;
401 if (!parentPath.equals("/")) {
402 path = parentPath + "/" + label;
403 }
404 else {
405 path = "/" + label;
406 }
407 this.deactivateNode(path);
408 parentNode.delete(label);
409 parentNode.save();
410 }
411
412 public void deleteNode(String path) throws Exception {
413 String parentPath = StringUtils.substringBeforeLast(path, "/");
414 String label = StringUtils.substringAfterLast(path, "/");
415 deleteNode(parentPath, label);
416 }
417
418 public String delete() {
419 String deleteNode = this.getRequest().getParameter("deleteNode");
420 try {
421 synchronized (ExclusiveWrite.getInstance()) {
422 deleteNode(path, deleteNode);
423 }
424 }
425 catch (Exception e) {
426 log.error("can't delete", e);
427 AlertUtil.setMessage(MessagesManager.get("tree.error.delete") + " " + AlertUtil.getExceptionMessage(e));
428 }
429 return VIEW_TREE;
430 }
431
432
433
434
435
436
437
438 public Syndicator getActivationSyndicator(String path) {
439
440 return null;
441 }
442
443
444
445
446
447
448
449 public void deactivateNode(String path) throws ExchangeException, RepositoryException {
450 if (MgnlContext.getHierarchyManager(this.getRepository()).isNodeData(path)) {
451 return;
452 }
453 CommandsManager cm = CommandsManager.getInstance();
454
455 Command cmd = cm.getCommand(this.getName(), "deactivate");
456 if (cmd == null) {
457 cmd = cm.getCommand(CommandsManager.DEFAULT_CATALOG, "deactivate");
458 }
459
460 if (cmd == null) {
461 log.error("deactivate command not found, deactivation will not be performed");
462 return;
463 }
464
465 Context ctx = this.getCommandContext("deactivate");
466
467
468 ctx.setAttribute(Context.ATTRIBUTE_PATH, path, Context.LOCAL_SCOPE);
469 try {
470 cmd.execute(ctx);
471 }
472 catch (Exception e) {
473 throw new ExchangeException(e);
474 }
475
476 }
477
478 public Content copyMoveNode(String source, String destination, boolean move) throws ExchangeException,
479 RepositoryException {
480
481 final HierarchyManager hm = getHierarchyManager();
482 if (hm.isExist(destination)) {
483 String parentPath = StringUtils.substringBeforeLast(destination, "/");
484 String label = StringUtils.substringAfterLast(destination, "/");
485 label = Path.getUniqueLabel(getHierarchyManager(), parentPath, label);
486 destination = parentPath + "/" + label;
487 }
488 if (move) {
489 if (destination.indexOf(source + "/") == 0) {
490
491
492 return null;
493 }
494 try {
495 hm.moveTo(source, destination);
496 }
497 catch (Exception e) {
498
499 return null;
500 }
501 }
502 else {
503
504 hm.copyTo(source, destination);
505 }
506 Content newContent = hm.getContent(destination);
507 try {
508 newContent.updateMetaData();
509 if (!move) {
510
511 newContent.getMetaData().setUnActivated();
512 }
513 updateChildMetaData(move, newContent);
514 }
515 catch (Exception e) {
516 if (log.isDebugEnabled()) {
517 log.debug("Exception caught: " + e.getMessage(), e);
518 }
519 }
520 newContent.save();
521 return newContent;
522 }
523
524 private void updateChildMetaData(boolean move, Content newContent) throws RepositoryException, AccessDeniedException {
525
526 for (Iterator iter = newContent.getChildren().iterator(); iter.hasNext();) {
527 Content child = (Content) iter.next();
528 child.updateMetaData();
529 if (!move) {
530
531 child.getMetaData().setUnActivated();
532 }
533 updateChildMetaData(move, child);
534 }
535 }
536
537 public void moveNode(String source, String destination) throws ExchangeException, RepositoryException {
538 this.copyMoveNode(source, destination, true);
539 }
540
541 public void copyNode(String source, String destination) throws ExchangeException, RepositoryException {
542 this.copyMoveNode(source, destination, false);
543 }
544
545 public String renameNode(String newLabel) throws AccessDeniedException, ExchangeException, PathNotFoundException,
546 RepositoryException {
547 String returnValue;
548 String parentPath = StringUtils.substringBeforeLast(this.getPath(), "/");
549 newLabel = Path.getValidatedLabel(newLabel);
550
551
552 if (this.getPath().endsWith("/" + newLabel)) {
553 return newLabel;
554 }
555
556 String dest = parentPath + "/" + newLabel;
557 if (getHierarchyManager().isExist(dest)) {
558 newLabel = Path.getUniqueLabel(getHierarchyManager(), parentPath, newLabel);
559 dest = parentPath + "/" + newLabel;
560 }
561
562
563
564 log.info("Moving node from " + this.getPath() + " to " + dest);
565 if (getHierarchyManager().isNodeData(this.getPath())) {
566 Content parentPage = getHierarchyManager().getContent(parentPath);
567 NodeData newNodeData = parentPage.createNodeData(newLabel);
568 NodeData existingNodeData = getHierarchyManager().getNodeData(this.getPath());
569
570 final int type = existingNodeData.getType();
571 switch(type) {
572 case PropertyType.STRING:
573 newNodeData.setValue(existingNodeData.getString());
574 break;
575 case PropertyType.BOOLEAN:
576 newNodeData.setValue(existingNodeData.getBoolean());
577 break;
578 case PropertyType.LONG:
579 newNodeData.setValue(existingNodeData.getLong());
580 break;
581 case PropertyType.DOUBLE:
582 newNodeData.setValue(existingNodeData.getDouble());
583 break;
584 default:
585 log.warn("node type {} is not handled. Falling back to String type.", PropertyType.nameFromValue(type));
586 newNodeData.setValue(existingNodeData.getString());
587 }
588
589 existingNodeData.delete();
590 dest = parentPath;
591 }
592 else {
593 Content current = getHierarchyManager().getContent(this.getPath());
594 ContentUtil.rename(current, newLabel);
595 current.getParent().save();
596 }
597
598 Content newPage = getHierarchyManager().getContent(dest);
599 returnValue = newLabel;
600 newPage.updateMetaData();
601 newPage.save();
602
603 return returnValue;
604 }
605
606
607
608
609
610 public String saveValue() {
611 String saveName = this.getRequest().getParameter("saveName");
612 Tree tree = getTree();
613
614
615 boolean isNodeDataValue = "true".equals(this.getRequest().getParameter("isNodeDataValue"));
616
617
618 boolean isNodeDataType = "true".equals(this.getRequest().getParameter("isNodeDataType"));
619
620 String value = StringUtils.defaultString(this.getRequest().getParameter("saveValue"));
621 displayValue = StringUtils.EMPTY;
622
623 boolean isMeta = "true".equals(this.getRequest().getParameter("isMeta"));
624
625 boolean isLabel = "true".equals(this.getRequest().getParameter("isLabel"));
626
627 if (isNodeDataValue || isNodeDataType) {
628 tree.setPath(StringUtils.substringBeforeLast(path, "/"));
629 saveName = StringUtils.substringAfterLast(path, "/");
630 }
631 else {
632
633 tree.setPath(path);
634 }
635
636 if (isLabel) {
637 displayValue = rename(value);
638 }
639 else if (isNodeDataType) {
640 int type = Integer.valueOf(value).intValue();
641 synchronized (ExclusiveWrite.getInstance()) {
642 displayValue = tree.saveNodeDataType(saveName, type);
643 }
644 }
645 else {
646 synchronized (ExclusiveWrite.getInstance()) {
647 displayValue = tree.saveNodeData(saveName, value, isMeta);
648 }
649 }
650
651
652 displayValue = StringUtils.defaultString(this.getRequest().getParameter("displayValue"), value);
653
654 displayValue = encodeHTML(displayValue);
655
656 return VIEW_VALUE;
657 }
658
659 public String encodeHTML(String value){
660 value = value.replace("<", "<");
661 value = value.replace(">", ">");
662 return value;
663 }
664
665
666
667
668
669
670 protected String rename(String value) {
671 try {
672 synchronized (ExclusiveWrite.getInstance()) {
673 return renameNode(value);
674 }
675 }
676 catch (Exception e) {
677 log.error("can't rename", e);
678 AlertUtil.setMessage(MessagesManager.get("tree.error.rename") + " " + AlertUtil.getExceptionMessage(e));
679 }
680 return StringUtils.EMPTY;
681 }
682
683 public String pasteNode(String pathOrigin, String pathSelected, int pasteType, int action)
684 throws ExchangeException, RepositoryException {
685 boolean move = false;
686 if (action == Tree.ACTION_MOVE) {
687 move = true;
688 }
689 String label = StringUtils.substringAfterLast(pathOrigin, "/");
690 String slash = "/";
691 if (pathSelected.equals("/")) {
692 slash = StringUtils.EMPTY;
693 }
694 String destination = pathSelected + slash + label;
695 if (pasteType == Tree.PASTETYPE_SUB && action != Tree.ACTION_COPY && destination.equals(pathOrigin)) {
696
697 pasteType = Tree.PASTETYPE_LAST;
698 }
699 if (pasteType == Tree.PASTETYPE_SUB) {
700 destination = pathSelected + slash + label;
701 Content touchedContent = this.copyMoveNode(pathOrigin, destination, move);
702 if (touchedContent == null) {
703 return StringUtils.EMPTY;
704 }
705 return touchedContent.getHandle();
706
707 }
708 else if (pasteType == Tree.PASTETYPE_LAST) {
709
710 try {
711 Content touchedContent = getHierarchyManager().getContent(pathOrigin);
712 return touchedContent.getHandle();
713 }
714 catch (RepositoryException re) {
715 return StringUtils.EMPTY;
716 }
717 }
718 else {
719 try {
720
721 String nameSelected = StringUtils.substringAfterLast(pathSelected, "/");
722 String nameOrigin = StringUtils.substringAfterLast(pathOrigin, "/");
723 Content tomove = getHierarchyManager().getContent(pathOrigin);
724 Content selected = getHierarchyManager().getContent(pathSelected);
725
726
727 if (tomove.getParent().getHandle().equals(selected.getParent().getHandle())) {
728
729 if (move) {
730 tomove.getParent().orderBefore(nameOrigin, nameSelected);
731
732 tomove.updateMetaData();
733
734 tomove.getParent().save();
735 }
736 else {
737 Content newNode = this.copyMoveNode(pathOrigin, pathOrigin, move);
738 tomove.getParent().orderBefore(newNode.getName(), nameSelected);
739 tomove.getParent().save();
740 }
741
742 }
743 else {
744 String newOrigin = selected.getParent().getHandle() + "/" + nameOrigin;
745
746 if (newOrigin.startsWith("//")) {
747 newOrigin = StringUtils.removeStart(newOrigin, "/");
748 }
749 Content newNode = this.copyMoveNode(pathOrigin, newOrigin, move);
750
751 if (pasteType == Tree.PASTETYPE_ABOVE) {
752 newNode.getParent().orderBefore(newNode.getName(), nameSelected);
753 newNode.getParent().save();
754 }
755 }
756 return tomove.getHandle();
757 }
758 catch (RepositoryException re) {
759 re.printStackTrace();
760 log.error("Problem when pasting node", re);
761 return StringUtils.EMPTY;
762 }
763 }
764 }
765
766
767
768
769
770
771 @Override
772 public void renderHtml(String view) throws IOException {
773 StringBuffer html = new StringBuffer(500);
774
775
776 if (AlertUtil.isMessageSet()) {
777 html.append("<input type=\"hidden\" id=\"mgnlMessage\" value=\"");
778 html.append(ControlImpl.escapeHTML(AlertUtil.getMessage()));
779 html.append("\" />");
780 }
781
782 if (VIEW_TREE.equals(view) || VIEW_CREATE.equals(view) || VIEW_COPY_MOVE.equals(view)) {
783
784 if (!view.equals(VIEW_CREATE)) {
785 getTree().setPathOpen(pathOpen);
786 getTree().setPathSelected(pathSelected);
787 }
788
789
790 if (view.equals(VIEW_COPY_MOVE)) {
791
792
793 html.append("<input type=\"hidden\" id=\"mgnlSelectNode\" value=\"");
794 html.append(newPath);
795 html.append("\" />");
796 }
797
798 renderTree(html);
799 }
800
801
802 else if (view.equals(VIEW_VALUE)) {
803 html.append(displayValue);
804 }
805 this.getResponse().getWriter().print(html);
806 }
807
808
809
810
811
812 protected void renderTree(StringBuffer html) {
813 String mode = StringUtils.defaultString(this.getRequest().getParameter("treeMode"));
814 boolean snippetMode = mode.equals("snippet");
815 Tree tree = getTree();
816
817 tree.setJavascriptTree("mgnlTreeControl");
818 tree.setBrowseMode(this.isBrowseMode());
819
820 if (!snippetMode) {
821
822
823 html.append("<html>\n");
824 html.append("<head>\n");
825 html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
826 renderHeaderIncludes(html);
827 html.append("<title>Magnolia</title>\n");
828 html.append("</head>\n");
829 html.append("<body class=\"mgnlBgDark\">");
830 }
831
832 tree.setSnippetMode(snippetMode);
833 tree.setHeight(50);
834
835 tree.setPath(path);
836
837 this.getConfiguration().prepareTree(tree, this.isBrowseMode(), this.getRequest());
838 this.getConfiguration().prepareContextMenu(tree, this.isBrowseMode(), this.getRequest());
839 this.getConfiguration().prepareFunctionBar(tree, this.isBrowseMode(), this.getRequest());
840
841 if (!snippetMode) {
842 html.append("<div id=\"");
843 html.append(tree.getJavascriptTree());
844 html.append("_DivSuper\" style=\"display:block;\">");
845 }
846 html.append(tree.getHtml());
847 if (!snippetMode) {
848 html.append("</div>");
849 }
850
851 if (!snippetMode) {
852 html.append("</body></html>");
853 }
854 }
855
856
857
858
859 protected void renderHeaderIncludes(StringBuffer html) {
860 html.append(new Sources(this.getRequest().getContextPath()).getHtmlJs());
861 html.append(new Sources(this.getRequest().getContextPath()).getHtmlCss());
862 }
863
864 protected void setTree(Tree tree) {
865 this.tree = tree;
866 }
867
868 protected Tree getTree() {
869 if (tree == null) {
870 tree = Classes.quietNewInstance(getTreeClass(), getName(), getRepository());
871
872 if (tree == null) {
873
874 log.warn("The {} Tree class is probably using the deprecated (String name, String repository, HttpServletRequest request) constructor. Please use the (String name, String repository) constructor instead.", getTreeClass());
875 tree = Classes.quietNewInstance(this.getTreeClass(), getName(), getRepository(), getRequest());
876 }
877 tree.setRootPath(this.getRootPath());
878 }
879 return tree;
880 }
881
882
883 public String getNewNodeName() {
884 return this.newNodeName;
885 }
886
887
888 public void setNewNodeName(String newNodeName) {
889 this.newNodeName = newNodeName;
890 }
891
892 protected String getPath() {
893 return path;
894 }
895
896 protected String getPathSelected() {
897 return pathSelected;
898 }
899
900
901 public String getCreateItemType() {
902 return this.createItemType;
903 }
904
905
906 public void setCreateItemType(String createItemType) {
907 this.createItemType = createItemType;
908 }
909
910
911
912
913 public boolean isBrowseMode() {
914 return browseMode;
915 }
916
917
918
919
920 public void setBrowseMode(boolean browseMode) {
921 this.browseMode = browseMode;
922 }
923
924
925
926
927
928
929 public AdminTreeConfiguration getConfiguration() {
930 if (this.configuration == null) {
931 if (getConfigurationClass() == null) {
932 return null;
933 }
934 final AdminTreeConfiguration treeConfiguration = Classes.quietNewInstance(getConfigurationClass());
935 setConfiguration(treeConfiguration);
936 }
937 return this.configuration;
938 }
939
940
941
942
943 public void setConfiguration(AdminTreeConfiguration configuration) {
944 this.configuration = configuration;
945 final Messages messages = MessagesUtil.chainWithDefault(getI18nBasename());
946 configuration.setMessages(messages);
947 if (configuration instanceof AbstractTreeConfiguration) {
948 ((AbstractTreeConfiguration) configuration).setEnableDeleteConfirmation(isEnableDeleteConfirmation());
949 }
950 }
951
952 public String getConfigurationClass() {
953 return configurationClass;
954 }
955
956 public void setConfigurationClass(String configClass) {
957 this.configurationClass = configClass;
958 }
959
960 public String getTreeClass() {
961 return treeClass;
962 }
963
964 public void setTreeClass(String treeClass) {
965 this.treeClass = treeClass;
966 }
967
968 public String getI18nBasename() {
969 return i18nBasename;
970 }
971
972 public void setI18nBasename(String i18nBasename) {
973 this.i18nBasename = i18nBasename;
974 }
975
976 public String getRootPath() {
977 return rootPath;
978 }
979
980 public void setRootPath(String rootPath) {
981 this.rootPath = rootPath;
982 }
983
984 public boolean isEnableDeleteConfirmation() {
985 return enableDeleteConfirmation;
986 }
987
988 public void setEnableDeleteConfirmation(boolean enableConfirmation) {
989 this.enableDeleteConfirmation = enableConfirmation;
990 AdminTreeConfiguration conf = getConfiguration();
991 if (conf != null && conf instanceof AbstractTreeConfiguration) {
992 ((AbstractTreeConfiguration) conf).setEnableDeleteConfirmation(isEnableDeleteConfirmation());
993 }
994 }
995 }