use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class AssignGroupToResources method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONObject jsonQuery = new JSONObject();
JSONArray array = new JSONArray();
for (int i = 0; i < resources.size(); i++) {
array.set(i, new JSONNumber(resources.get(i).getId()));
}
jsonQuery.put("resources", array);
jsonQuery.put("group", new JSONNumber(group.getId()));
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class GetUsers method retrieveData.
/**
* Retrieves data from RPC
*/
public void retrieveData() {
// empty
if (this.attributesToSearchBy.size() == 0) {
session.getUiElements().setLogText("No keywords.");
return;
}
// ok, start
loaderImage.loadingStart();
// build request
JSONObject attributesWithSearchingValues = new JSONObject();
for (Map.Entry<String, String> entry : attributesToSearchBy.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
attributesWithSearchingValues.put(name, new JSONString(value));
}
JSONObject req = new JSONObject();
req.put("attributesWithSearchingValues", attributesWithSearchingValues);
// send request
JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Error while loading users.");
loaderImage.loadingError(error);
events.onError(error);
}
public void onLoadingStart() {
loaderImage.loadingStart();
session.getUiElements().setLogText("Loading users started.");
events.onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
loaderImage.loadingFinished();
setList(JsonUtils.<User>jsoAsList(jso));
sortTable();
session.getUiElements().setLogText("Users loaded: " + list.size());
events.onFinished(jso);
}
});
js.sendData(JSON_URL, req);
return;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class RemoveGroupsFromResource method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONObject jsonQuery = new JSONObject();
JSONArray array = new JSONArray();
for (int i = 0; i < groups.size(); i++) {
array.set(i, new JSONNumber(groups.get(i).getId()));
}
jsonQuery.put("groups", array);
jsonQuery.put("resource", new JSONNumber(resource.getId()));
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class CreatePassword method validateCallJSON.
/**
* Prepares a JSON object for validation request.
*
* @return JSONObject the whole query
*/
private JSONObject validateCallJSON() {
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("user", new JSONNumber(userId));
jsonQuery.put("namespace", new JSONString(namespace));
jsonQuery.put("login", new JSONString(login));
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class FindUsersByIdsNotInRpc method retrieveData.
/**
* Retrieves data from RPC
*/
public void retrieveData() {
String[] ids = searchString.split(",");
if (ids.length == 0) {
return;
}
idsCount = ids.length;
onLoadingStart();
for (String id : ids) {
// trims the whitespace
id = id.trim();
try {
int idint = Integer.parseInt(id);
GetEntityById req = new GetEntityById(PerunEntity.USER, idint, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
idsFound++;
// add to result
int i = result.size();
result.set(i, new JSONObject(jso));
isFinished();
}
public void onError(PerunError err) {
idsFound++;
isFinished();
}
});
req.retrieveData();
} catch (Exception e) {
}
}
}
Aggregations