/
GrantRole.java
115 lines (95 loc) · 2.7 KB
/
GrantRole.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* OpenKM, Open Document Management System (http://www.openkm.com)
* Copyright (c) 2006-2017 Paco Avila & Josep Llort
* <p>
* No bytes were intentionally harmed during the development of this application.
* <p>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.openkm.automation.action;
import java.util.Map;
import com.openkm.automation.Action;
import com.openkm.automation.AutomationUtils;
import com.openkm.dao.NodeBaseDAO;
import com.openkm.dao.bean.Automation;
import net.xeoh.plugins.base.annotations.PluginImplementation;
/**
* GrantRole
*
* @author jllort
*/
@PluginImplementation
public class GrantRole implements Action {
@Override
public void executePre(Map<String, Object> env, Object... params) throws Exception {
}
@Override
public void executePost(Map<String, Object> env, Object... params) throws Exception {
String role = AutomationUtils.getString(0, params);
Integer permissions = AutomationUtils.getInteger(1, params);
String uuid = AutomationUtils.getUuid(env);
if (uuid != null && role != null && !role.isEmpty()) {
NodeBaseDAO.getInstance().grantRolePermissions(uuid, role, permissions, false);
}
}
@Override
public boolean hasPost() {
return true;
}
@Override
public boolean hasPre() {
return false;
}
@Override
public String getName() {
return "GrantRole";
}
@Override
public String getParamType00() {
return Automation.PARAM_TYPE_TEXT;
}
@Override
public String getParamSrc00() {
return Automation.PARAM_SOURCE_EMPTY;
}
@Override
public String getParamDesc00() {
return "Role name";
}
@Override
public String getParamType01() {
return Automation.PARAM_TYPE_INTEGER;
}
@Override
public String getParamSrc01() {
return Automation.PARAM_SOURCE_EMPTY;
}
@Override
public String getParamDesc01() {
return "Privileges";
}
@Override
public String getParamType02() {
return Automation.PARAM_TYPE_EMPTY;
}
@Override
public String getParamSrc02() {
return Automation.PARAM_SOURCE_EMPTY;
}
@Override
public String getParamDesc02() {
return "";
}
}