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.setup.initial;
35
36 import info.magnolia.cms.core.MgnlNodeType;
37 import info.magnolia.cms.core.SystemProperty;
38 import info.magnolia.cms.security.Realm;
39 import info.magnolia.module.delta.ArrayDelegateTask;
40 import info.magnolia.module.delta.BootstrapConditionally;
41 import info.magnolia.module.delta.BootstrapSingleModuleResource;
42 import info.magnolia.module.delta.BootstrapSingleResource;
43 import info.magnolia.module.delta.CheckOrCreatePropertyTask;
44 import info.magnolia.module.delta.CreateNodeTask;
45 import info.magnolia.module.delta.IsAuthorInstanceDelegateTask;
46 import info.magnolia.module.delta.ModuleFilesExtraction;
47 import info.magnolia.module.delta.MoveAndRenamePropertyTask;
48 import info.magnolia.module.delta.MoveNodeTask;
49 import info.magnolia.module.delta.NewPropertyTask;
50 import info.magnolia.module.delta.NodeExistsDelegateTask;
51 import info.magnolia.module.delta.PropertyExistsDelegateTask;
52 import info.magnolia.module.delta.RegisterModuleServletsTask;
53 import info.magnolia.module.delta.RemoveNodeTask;
54 import info.magnolia.module.delta.RemovePropertyTask;
55 import info.magnolia.module.delta.Task;
56 import info.magnolia.module.delta.WarnTask;
57 import info.magnolia.repository.RepositoryConstants;
58 import info.magnolia.setup.CoreModuleVersionHandler;
59
60 import java.util.Arrays;
61 import java.util.List;
62
63 import javax.jcr.ImportUUIDBehavior;
64
65 import org.apache.commons.codec.binary.Base64;
66 import org.apache.commons.lang.StringUtils;
67
68
69
70
71
72
73
74
75 public class GenericTasks {
76
77
78
79 public static List<Task> genericTasksForNewInstallation() {
80 final String areWeBootstrappingAuthorInstance = StringUtils.defaultIfEmpty(SystemProperty.getProperty(CoreModuleVersionHandler.BOOTSTRAP_AUTHOR_INSTANCE_PROPERTY), "true");
81 return Arrays.asList(
82
83 new NodeExistsDelegateTask("Server node", "Creates the server node in the config repository if needed.", RepositoryConstants.CONFIG, "/server", null,
84 new CreateNodeTask(null, null, RepositoryConstants.CONFIG, "/", "server", MgnlNodeType.NT_CONTENT)),
85
86
87 new NodeExistsDelegateTask("Modules node", "Creates the modules node in the config repository if needed.", RepositoryConstants.CONFIG, "/modules", null,
88 new CreateNodeTask(null, null, RepositoryConstants.CONFIG, "/", "modules", MgnlNodeType.NT_CONTENT)),
89
90 new BootstrapSingleResource("Bootstrap", "Bootstraps the new filter configuration", "/mgnl-bootstrap/core/config.server.filters.xml", ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW),
91
92 new BootstrapSingleResource("IPConfig rules changed",
93 "Updates the existing ip access rules to match the new configuration structure or bootstraps the new default configuration.",
94 "/mgnl-bootstrap/core/config.server.IPConfig.xml"),
95
96 new BootstrapSingleModuleResource("i18n content", "bootstrap the config", "config.server.i18n.content.xml"),
97 new BootstrapSingleModuleResource("i18n system", "bootstrap the config", "config.server.i18n.system.xml"),
98
99
100 new BootstrapSingleResource("New security configuration", "Install new configuration for security managers.", "/mgnl-bootstrap/core/config.server.security.xml"),
101 new BootstrapSingleResource("New rendering strategy for links", "Install new configuration for link resolving.", "/mgnl-bootstrap/core/config.server.rendering.linkManagement.xml"),
102
103 new BootstrapConditionally("MIME mappings", "Adds MIMEMappings to server config, if not already present.", "/mgnl-bootstrap/core/config.server.MIMEMapping.xml"),
104 new BootstrapConditionally("URI2Repository mappings", "Installs new configuration of URI2Repository mappings.", "/mgnl-bootstrap/core/config.server.URI2RepositoryMapping.xml", new UpdateURI2RepositoryMappings()),
105
106
107 new PropertyExistsDelegateTask("Cleanup", "Config property /server/defaultMailServer was unused.", "config", "/server", "defaultMailServer",
108 new RemovePropertyTask("", "", "config", "/server", "defaultMailServer")),
109
110
111 new CheckOrCreatePropertyTask("defaultExtension property", "Checks that the defaultExtension property exists in config:/server", "config", "/server", "defaultExtension", "html"),
112
113 new CheckOrCreatePropertyTask("admin property", "Checks that the admin property exists in config:/server", "config", "/server", "admin", areWeBootstrappingAuthorInstance),
114
115 new ArrayDelegateTask("defaultBaseUrl property",
116 new NewPropertyTask("defaultBaseUrl property", "Adds the new defaultBaseUrl property with a default value.", "config", "/server", "defaultBaseUrl", "http://localhost:8080/magnolia/"),
117 new WarnTask("defaultBaseUrl property", "Please set the config:/server/defaultBaseUrl property to a full URL to be used when generating absolute URLs for external systems.")
118 ),
119
120
121 new NodeExistsDelegateTask("Login configuration", "The login configuration was moved to filters configuration.", "config", "/server/login",
122 new ArrayDelegateTask("",
123 new LoginAuthTypePropertyMovedToFilter(),
124 new LoginFormPropertyMovedToFilter(),
125 new MoveAndRenamePropertyTask("unsecuredPath is now handled by the bypass mechanism.", "/server/login", "UnsecuredPath", "/server/filters/uriSecurity/bypasses/login", "pattern"),
126 new RemoveNodeTask("Login configuration changed", "Removes /server/login as it is not used anymore.", "config", "/server/login")
127 )),
128
129
130 new CreateNodeTask("Adds system folder node to users workspace", "Add system realm folder /system to users workspace.", RepositoryConstants.USERS, "/", Realm.REALM_SYSTEM.getName(), MgnlNodeType.NT_FOLDER),
131 new CreateNodeTask("Adds admin folder node to users workspace", "Add magnolia realm folder /admin to users workspace.", RepositoryConstants.USERS, "/", Realm.REALM_ADMIN.getName(), MgnlNodeType.NT_FOLDER),
132
133 new IsAuthorInstanceDelegateTask("URI permissions", "Introduction of URI-based security. All existing roles will have GET/POST permissions on /*.",
134 new AddURIPermissionsToAllRoles(true),
135 new AddURIPermissionsToAllRoles(false)),
136
137 new IsAuthorInstanceDelegateTask("Anonymous role", "Anonymous role must exist.",
138 new BootstrapConditionally("", "Author permissions", "/info/magnolia/setup/author/userroles.anonymous.xml"),
139 new BootstrapConditionally("", "Public permissions", "/info/magnolia/setup/public/userroles.anonymous.xml")),
140
141 new BootstrapConditionally("Superuser role", "Bootstraps the superuser role if needed.", "/mgnl-bootstrap/core/userroles.superuser.xml"),
142
143 new BootstrapConditionally("Anonymous user", "Anonymous user must exist in the system realm: will move the existing one or bootstrap it.",
144 RepositoryConstants.USERS, "/anonymous", "/mgnl-bootstrap/core/users.system.anonymous.xml",
145 new ArrayDelegateTask("",
146 new MoveNodeTask("", "", RepositoryConstants.USERS, "/anonymous", "/system/anonymous", false),
147 new NewPropertyTask("Anonymous user", "Anonymous user must have a password.", RepositoryConstants.USERS, "/system/anonymous", "pswd", new String(Base64.encodeBase64("anonymous".getBytes())))
148 )),
149
150 new BootstrapConditionally("Superuser user", "Superuser user must exist in the system realm: will move the existing one or bootstrap it.",
151 RepositoryConstants.USERS, "/superuser", "/mgnl-bootstrap/core/users.system.superuser.xml",
152 new MoveNodeTask("", "", RepositoryConstants.USERS, "/superuser", "/system/superuser", false)),
153
154
155 new ModuleFilesExtraction(),
156 new RegisterModuleServletsTask(),
157
158
159 new WarnIgnoredModuleFilters(),
160 new UpdateURIMappings()
161 );
162 }
163
164 }