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.form.setup;
35
36 import javax.jcr.Node;
37 import javax.jcr.PathNotFoundException;
38 import javax.jcr.RepositoryException;
39 import javax.jcr.Session;
40
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 import info.magnolia.jcr.util.NodeUtil;
45 import info.magnolia.module.InstallContext;
46 import info.magnolia.module.delta.AbstractTask;
47 import info.magnolia.module.delta.TaskExecutionException;
48
49
50
51
52 public class UpdateConfirmHtmlTypeToCodeTask extends AbstractTask{
53
54 private static final Logger log = LoggerFactory.getLogger(UpdateConfirmHtmlTypeToCodeTask.class);
55
56 public UpdateConfirmHtmlTypeToCodeTask(String taskName, String taskDescription) {
57 super("Switch html type of confirm mail to code", "");
58 }
59
60 @Override
61 public void execute(InstallContext ctx) throws TaskExecutionException {
62 try{
63 Session session = ctx.getJCRSession("config");
64 if(session.itemExists("/modules/form/dialogs/form/tabConfirmEmail/confirmContentType/options/html")){
65 Node node = session.getNode("/modules/form/dialogs/form/tabConfirmEmail/confirmContentType/options/html");
66 node.getProperty("label").setValue("dialog.form.tabContactMail.contentType.option.code");
67 Node htmlNode = node.getNode("controls/html");
68 htmlNode.getProperty("controlType").setValue("editCode");
69 htmlNode.setProperty("language", "generic");
70 NodeUtil.renameNode(htmlNode, "code");
71 NodeUtil.renameNode(node, "code");
72 session.save();
73 }
74 } catch (PathNotFoundException e) {
75 log.error("Switch of confirm mail type from html to code failed due to missing node(s): ", e);
76 } catch (RepositoryException e) {
77 throw new TaskExecutionException(e.getMessage(), e);
78 }
79 }
80
81 }