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.blossom.paragraph;
35
36 import java.io.IOException;
37 import javax.jcr.RepositoryException;
38 import javax.servlet.http.HttpServletRequest;
39 import javax.servlet.http.HttpServletResponse;
40
41 import info.magnolia.cms.core.Content;
42 import info.magnolia.module.admininterface.DialogHandlerManager;
43 import info.magnolia.module.admininterface.DialogMVCHandler;
44 import info.magnolia.module.admininterface.dialogs.ConfiguredDialog;
45 import info.magnolia.module.blossom.BlossomModule;
46 import info.magnolia.module.blossom.dialog.BlossomConfiguredDialog;
47 import info.magnolia.module.blossom.dialog.BlossomDialogDescription;
48 import info.magnolia.module.blossom.dialog.BlossomDialogRegistry;
49
50
51
52
53
54
55
56
57
58
59 public class BackwardsCompatibleBlossomDialog extends ConfiguredDialog {
60
61 private DialogMVCHandler dialogHandler;
62
63 public BackwardsCompatibleBlossomDialog(String name, HttpServletRequest request, HttpServletResponse response, Content configNode) throws RepositoryException {
64 super(name, request, response, configNode);
65
66 BlossomParagraphRegistry paragraphRegistry = BlossomModule.getParagraphRegistry();
67 BlossomParagraphDescription paragraph = paragraphRegistry.getParagraph(getStorageNode());
68
69 String dialogName = paragraph.getDialogName();
70 BlossomDialogRegistry dialogRegistry = BlossomModule.getDialogRegistry();
71 BlossomDialogDescription dialogDescription = dialogRegistry.getDialogDescription(dialogName);
72 if (dialogDescription != null) {
73 dialogHandler = new BlossomConfiguredDialog(dialogName, request, response, configNode, dialogDescription.getFactoryMetaData());
74 } else {
75 dialogHandler = DialogHandlerManager.getInstance().getDialogHandler(dialogName, request, response);
76 }
77 }
78
79 public String getCommand() {
80 if (dialogHandler != null)
81 return dialogHandler.getCommand();
82 return super.getCommand();
83 }
84
85 public String execute(String command) {
86 if (dialogHandler != null)
87 return dialogHandler.execute(command);
88 return super.execute(command);
89 }
90
91 public void renderHtml(String view) throws IOException {
92 if (dialogHandler != null)
93 dialogHandler.renderHtml(view);
94 else
95 super.renderHtml(view);
96 }
97 }