]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ria/SecurityAPI.js
Prepare next development cycle
[lgpl/argeo-commons.git] / ria / SecurityAPI.js
1 qx.Class.define("org.argeo.security.ria.SecurityAPI", {
2 extend : qx.core.Object,
3 statics : {
4
5 DEFAULT_CONTEXT : "/org.argeo.security.webapp",
6
7 USERS_LIST_SERVICE : "getUsersList.security",
8 USER_EXISTS_SERVICE : "userExists.security",
9 DELETE_USER_SERVICE : "deleteUser.security",
10 GET_USER_DETAILS_SERVICE : "getUserDetails.security",
11 CREATE_USER_SERVICE : "createUser.security",
12 UPDATE_USER_PASS_SERVICE : "updateUserPassword.security",
13
14 ROLES_LIST_SERVICE : "getRolesList.security",
15 GET_USERS_ROLE_SERVICE : "getUsersForRole.security",
16 CREATE_ROLE_SERVICE : "createRole.security",
17 DELETE_ROLE_SERVICE : "deleteRole.security",
18
19 UPDATE_USER_ROLE_LNK_SERVICE : "updateUserRoleLink.security",
20 CREATE_NATURE_SERVICE : "createUserNature.security",
21 DELETE_NATURE_SERVICE : "deleteUserNature.security",
22 UPDATE_NATURE_SERVICE : "updateUserNature.security",
23
24 /**
25 * Standard Request getter
26 * @param serviceName {String} The name of the service to call (without base context)
27 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
28 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
29 * @return {qx.io.remote.Request}
30 */
31 getServiceRequest : function(serviceName) {
32 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
33 return serviceManager.getRequest(
34 org.argeo.security.ria.SecurityAPI.DEFAULT_CONTEXT + "/" + serviceName,
35 "GET",
36 "application/json");
37 },
38
39 parseOptionalArguments : function(request, argumentsArray, startIndex){
40 if(argumentsArray.length <= startIndex) return;
41 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
42 for(var i=startIndex;i<argumentsArray.length;i++){
43 var argument = argumentsArray[i];
44 if(qx.lang.Array.isArray(argument)){
45 serviceManager.attachILoadStatusables(request, argument);
46 }else if(typeof argument == "string"){
47 serviceManager.attachReloadEventType(request, argument);
48 }
49 }
50 },
51
52 /**
53 * @return {qx.io.remote.Request}
54 */
55 getListUsersService : function(){
56 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.USERS_LIST_SERVICE);
57 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
58 return req;
59 },
60
61 /**
62 * @return {qx.io.remote.Request}
63 */
64 getUserExistsService : function(userName){
65 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.USER_EXISTS_SERVICE);
66 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
67 req.addParameter("userName", userName);
68 return req;
69 },
70
71 /**
72 * @return {qx.io.remote.Request}
73 */
74 getDeleteUserService : function(userName){
75 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.DELETE_USER_SERVICE);
76 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
77 req.addParameter("userName", userName);
78 return req;
79 },
80
81 /**
82 * @return {qx.io.remote.Request}
83 */
84 getUserDetailsService : function(userName){
85 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.GET_USER_DETAILS_SERVICE);
86 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
87 req.addParameter("userName", userName);
88 return req;
89 },
90
91 /**
92 * @return {qx.io.remote.Request}
93 */
94 getCreateUserService : function(userName){
95 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.CREATE_USER_SERVICE);
96 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
97 req.addParameter("userName", userName);
98 return req;
99 },
100
101 /**
102 * @return {qx.io.remote.Request}
103 */
104 getUpdateUserPassService : function(userName, userPassword){
105 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.UPDATE_USER_PASS_SERVICE);
106 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
107 req.addParameter("userName", userName);
108 req.addParameter("userPassword", userPassword);
109 return req;
110 },
111
112 /**
113 * @return {qx.io.remote.Request}
114 */
115 getListRolesService : function(){
116 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.ROLES_LIST_SERVICE);
117 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
118 return req;
119 },
120
121 /**
122 * @return {qx.io.remote.Request}
123 */
124 getUsersForRolesService : function(){
125 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.GET_USERS_ROLE_SERVICE);
126 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
127 return req;
128 },
129
130 /**
131 * @return {qx.io.remote.Request}
132 */
133 getCreateRoleService : function(roleName){
134 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.CREATE_ROLE_SERVICE);
135 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
136 return req;
137 },
138
139 /**
140 * @return {qx.io.remote.Request}
141 */
142 getDeleteRoleService : function(roleName){
143 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.DELETE_ROLE_SERVICE);
144 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
145 return req;
146 },
147
148 /**
149 * @return {qx.io.remote.Request}
150 */
151 getUpdateUserRoleLinkService : function(roleName, userName){
152 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.UPDATE_USER_ROLE_LNK_SERVICE);
153 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
154 req.addParameter("roleName", roleName);
155 req.addParameter("userName", userName);
156 return req;
157 },
158
159 /**
160 * @return {qx.io.remote.Request}
161 */
162 getCreateNatureService : function(natureData){
163 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.CREATE_NATURE_SERVICE);
164 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
165 req.addParameter("natureData", natureData);
166 return req;
167 },
168
169 /**
170 * @return {qx.io.remote.Request}
171 */
172 getDeleteNatureService : function(natureUuid){
173 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.DELETE_NATURE_SERVICE);
174 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
175 req.addParamter("natureUuid", natureUuid);
176 return req;
177 },
178
179 /**
180 * @return {qx.io.remote.Request}
181 */
182 getUpdateNatureService : function(natureUuid, natureData){
183 var req = org.argeo.security.ria.SecurityAPI.getServiceRequest(org.argeo.security.ria.SecurityAPI.UPDATE_NATURE_SERVICE);
184 org.argeo.security.ria.SecurityAPI.parseOptionalArguments(req, arguments, 1);
185 req.addParamter("natureUuid", natureUuid);
186 req.addParameter("natureData", natureData);
187 return req;
188 }
189 }
190 });