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.tools.setup; |
35 |
|
|
36 |
|
import static info.magnolia.nodebuilder.Ops.*; |
37 |
|
|
38 |
|
import info.magnolia.cms.security.Permission; |
39 |
|
import info.magnolia.jcr.util.NodeTypes; |
40 |
|
import info.magnolia.module.DefaultModuleVersionHandler; |
41 |
|
import info.magnolia.module.InstallContext; |
42 |
|
import info.magnolia.module.delta.AddPermissionTask; |
43 |
|
import info.magnolia.module.delta.CheckAndModifyPropertyValueTask; |
44 |
|
import info.magnolia.module.delta.Task; |
45 |
|
import info.magnolia.nodebuilder.task.ErrorHandling; |
46 |
|
import info.magnolia.nodebuilder.task.NodeBuilderTask; |
47 |
|
import info.magnolia.repository.RepositoryConstants; |
48 |
|
import info.magnolia.rest.tools.SwaggerRestDispatcherServlet; |
49 |
|
import info.magnolia.rest.RestDispatcherServlet; |
50 |
|
|
51 |
|
import java.util.ArrayList; |
52 |
|
import java.util.List; |
53 |
|
|
54 |
|
import com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider; |
55 |
|
import com.wordnik.swagger.jaxrs.listing.ResourceListingProvider; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.2 |
|
60 |
|
public class RestToolsModuleVersionHandler extends DefaultModuleVersionHandler { |
61 |
|
|
62 |
|
private final static String REST_DISPATCHER_SERVLET_PATH = "/server/filters/servlets/RestDispatcherServlet"; |
63 |
|
private final static String PATH_TO_REST_INTEGRATION_MODULE = "/modules/rest-integration"; |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
65 |
1 |
@Override... |
66 |
|
protected List<Task> getExtraInstallTasks(InstallContext installContext) { |
67 |
1 |
List<Task> list = new ArrayList<Task>(); |
68 |
|
|
69 |
1 |
list.add(new CheckAndModifyPropertyValueTask("Replace dispatcher servlet", "Replace default dispatcher servlet with API-aware dispatcher servlet", RepositoryConstants.CONFIG, |
70 |
|
REST_DISPATCHER_SERVLET_PATH, "servletClass", RestDispatcherServlet.class.getName(), SwaggerRestDispatcherServlet.class.getName())); |
71 |
|
|
72 |
|
|
73 |
1 |
list.add(new AddPermissionTask("Update 'rest' role", "Allows access to the REST API documentation interface residing under '/.rest/api-docs' in role 'rest'.", "rest", "uri", "/.rest/api-docs*", Permission.ALL, false)); |
74 |
|
|
75 |
|
|
76 |
1 |
list.add(new NodeBuilderTask("Add additional providers", "Adds additional providers to rest-integration module config (needed for API documentation)", ErrorHandling.logging, |
77 |
|
RepositoryConstants.CONFIG, PATH_TO_REST_INTEGRATION_MODULE + "/config", |
78 |
|
getNode("additionalProviders").then( |
79 |
|
addNode("apiDeclarationProvider", NodeTypes.ContentNode.NAME).then( |
80 |
|
addProperty("providerClass", ApiDeclarationProvider.class.getName()) |
81 |
|
), |
82 |
|
addNode("resourceListingProvider", NodeTypes.ContentNode.NAME).then( |
83 |
|
addProperty("providerClass", ResourceListingProvider.class.getName()) |
84 |
|
) |
85 |
|
) |
86 |
|
)); |
87 |
|
|
88 |
1 |
return list; |
89 |
|
} |
90 |
|
|
91 |
|
} |