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.rest.setup; |
35 |
|
|
36 |
|
import info.magnolia.module.DefaultModuleVersionHandler; |
37 |
|
import info.magnolia.module.InstallContext; |
38 |
|
import info.magnolia.module.delta.AddPermissionTask; |
39 |
|
import info.magnolia.module.delta.CheckAndModifyPropertyValueTask; |
40 |
|
import info.magnolia.module.delta.ConditionalDelegateTask; |
41 |
|
import info.magnolia.module.delta.Task; |
42 |
|
import info.magnolia.repository.RepositoryConstants; |
43 |
|
|
44 |
|
import java.util.ArrayList; |
45 |
|
import java.util.List; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
50 |
|
public class RestContentDeliveryModuleVersionHandler extends DefaultModuleVersionHandler { |
51 |
|
|
52 |
|
private final static String REST_DISPATCHER_SERVLET_PATH = "/server/filters/servlets/RestDispatcherServlet"; |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
54 |
1 |
@Override... |
55 |
|
protected List<Task> getExtraInstallTasks(InstallContext installContext) { |
56 |
1 |
List<Task> list = new ArrayList<>(); |
57 |
|
|
58 |
|
|
59 |
1 |
list.add(new AddPermissionTask("Update 'rest-editor' role", "Allow GET access to the REST interfaces residing under '/.rest/delivery/*' to role 'rest-editor'.", "rest-editor", "uri", "/.rest/delivery/*", 8, false)); |
60 |
1 |
list.add(new AddPermissionTask("Update 'rest-anonymous' role", "Allow GET access to the REST interfaces residing under '/.rest/delivery/*' to role 'rest-anonymous'.", "rest-anonymous", "uri", "/.rest/delivery/*", 8, false)); |
61 |
|
|
62 |
1 |
Task replaceRestServletClassTask = new CheckAndModifyPropertyValueTask("Replace dispatcher servlet", "Replace default dispatcher servlet with API-aware dispatcher servlet", RepositoryConstants.CONFIG, |
63 |
|
REST_DISPATCHER_SERVLET_PATH, "servletClass", "info.magnolia.rest.RestDispatcherServlet", "info.magnolia.rest.RestJerseyDispatcherServlet"); |
64 |
1 |
list.add(new ConditionalDelegateTask("Replace REST implementation", "Detect and replace REST implementation with simple test against loaded class.", replaceRestServletClassTask, null) { |
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
65 |
1 |
@Override... |
66 |
|
protected boolean condition(InstallContext installContext) { |
67 |
1 |
try { |
68 |
1 |
Class.forName("org.glassfish.jersey.servlet.ServletContainer"); |
69 |
|
} catch (ClassNotFoundException e) { |
70 |
1 |
return false; |
71 |
|
} |
72 |
0 |
return true; |
73 |
|
} |
74 |
|
}); |
75 |
1 |
return list; |
76 |
|
} |
77 |
|
} |