Clover icon

Magnolia REST Services 2.1.3

  1. Project Clover database Fri Oct 25 2019 12:35:42 CEST
  2. Package info.magnolia.rest.service.setup

File RestServicesModuleVersionHandler.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
6
2
1
86
39
2
0.33
3
2
1

Classes

Class Line # Actions
RestServicesModuleVersionHandler 53 6 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /**
2    * This file Copyright (c) 2013-2018 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.rest.service.setup;
35   
36    import info.magnolia.cms.security.Permission;
37    import info.magnolia.module.DefaultModuleVersionHandler;
38    import info.magnolia.module.InstallContext;
39    import info.magnolia.module.delta.AddPermissionTask;
40    import info.magnolia.module.delta.ArrayDelegateTask;
41    import info.magnolia.module.delta.CheckAndModifyPropertyValueTask;
42    import info.magnolia.module.delta.DeltaBuilder;
43    import info.magnolia.module.delta.NodeExistsDelegateTask;
44    import info.magnolia.module.delta.Task;
45    import info.magnolia.repository.RepositoryConstants;
46   
47    import java.util.ArrayList;
48    import java.util.List;
49   
50    /**
51    * Module version handler for {@link info.magnolia.rest.service.RestServicesModule}.
52    */
 
53    public class RestServicesModuleVersionHandler extends DefaultModuleVersionHandler {
54   
 
55  3 toggle public RestServicesModuleVersionHandler() {
56  3 register(DeltaBuilder.update("1.1", "")
57    .addTask(new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands", "implementationClass", "info.magnolia.rest.service.command.v1.CommandEndpoint", "info.magnolia.rest.service.command.v2.CommandEndpoint"))
58    );
59  3 register(DeltaBuilder.update("2.0", "")
60    .addTask(new NodeExistsDelegateTask("Update activate command rest role to rest-editor", "/modules/rest-services/rest-endpoints/commands/enabledCommands/activate/access/roles",
61    new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands/enabledCommands/activate/access/roles", "rest", "rest", "rest-editor")))
62    .addTask(new NodeExistsDelegateTask("Update markAsDeleted command rest role to rest-editor", "/modules/rest-services/rest-endpoints/commands/enabledCommands/markAsDeleted/access/roles",
63    new CheckAndModifyPropertyValueTask("/modules/rest-services/rest-endpoints/commands/enabledCommands/markAsDeleted/access/roles", "rest", "rest", "rest-editor")))
64    );
65    }
66   
 
67  1 toggle @Override
68    protected List<Task> getExtraInstallTasks(InstallContext installContext) {
69  1 List<Task> list = new ArrayList<Task>();
70   
71    // We have to enable PUT/DELETE method in /server/IPConfig/allow-all.methods
72  1 list.add(new CheckAndModifyPropertyValueTask("Enable PUT method", "Enables PUT method in '/server/IPConfig/allow-all.methods'", RepositoryConstants.CONFIG, "/server/IPConfig/allow-all", "methods", "GET,POST", "GET,POST,PUT,DELETE"));
73   
74  1 list.add(new ArrayDelegateTask("Update 'rest-editor' role",
75    new AddPermissionTask("Update 'rest-editor' role", "Allows access to the REST API documentation interface residing under '/.rest/api-docs' in role 'rest-editor'.", "rest-editor", "uri", "/.rest/commands*", Permission.NONE, false),
76   
77    new AddPermissionTask("Update 'rest-editor' role", "Denies access to the 'nodes' endpoint.", "rest-editor", "uri", "/.rest/nodes*", Permission.NONE, false),
78    new AddPermissionTask("Update 'rest-editor' role", "Allows access to the 'nodes' endpoint for workspace 'website'.", "rest-editor", "uri", "/.rest/nodes/v1/website*", Permission.ALL, false),
79   
80    new AddPermissionTask("Update 'rest-editor' role", "Denies access to the 'properties' endpoint.", "rest-editor", "uri", "/.rest/properties*", Permission.NONE, false),
81    new AddPermissionTask("Update 'rest-editor' role", "Allows access to the 'nodes' properties for workspace 'website'.", "rest-editor", "uri", "/.rest/properties/v1/website*", Permission.ALL, false)
82    ));
83  1 return list;
84    }
85   
86    }