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.demoproject.setup;
35
36 import javax.jcr.Node;
37 import javax.jcr.RepositoryException;
38 import javax.jcr.Session;
39
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
42
43 import info.magnolia.jcr.util.PropertyUtil;
44 import info.magnolia.module.InstallContext;
45 import info.magnolia.module.delta.AbstractTask;
46 import info.magnolia.module.delta.TaskExecutionException;
47
48
49
50
51 public class UpdatePurConfirmationEmailTypeTask extends AbstractTask{
52
53 private static final Logger log = LoggerFactory.getLogger(UpdatePurConfirmationEmailTypeTask.class);
54
55 public UpdatePurConfirmationEmailTypeTask(String taskName, String taskDescription) {
56 super("PUR content update", "Updates confirmation e-mail of PUR forms with mail type for proper mail processing");
57 }
58
59 @Override
60 public void execute(InstallContext installContext) throws TaskExecutionException {
61 try{
62 Session session = installContext.getJCRSession("website");
63 updateNode(session, "/demo-project/members-area/password-reminder/content/0");
64 updateNode(session, "/demo-project/members-area/registration/content/0");
65 updateNode(session, "/demo-features/modules/public-user-registration/PURRegistration/content/0");
66 updateNode(session, "/demo-features/modules/public-user-registration/PURUpdate/content/0");
67 updateNode(session, "/demo-features/modules/public-user-registration/PURPassword/content/0");
68 session.save();
69 }catch(RepositoryException e){
70 installContext.error(e.getMessage(), e);
71 }
72 }
73
74 private void updateNode(Session session, String absPath) throws RepositoryException {
75 if (!session.nodeExists(absPath)) {
76 log.warn("Path '{}' do not exist. No update of the confirmation email performed", absPath);
77 return;
78 }
79 Node node = session.getNode(absPath);
80 node.setProperty("confirmMailType", "html");
81 node.getProperty("confirmContentType").setValue("code");
82 if (node.hasProperty("confirmContentTypehtml")) {
83 PropertyUtil.renameProperty(node.getProperty("confirmContentTypehtml"), "confirmContentTypecode");
84 }
85 }
86 }