use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class RemoveSecurityTeam method removeSecurityTeam.
/**
* Attempts to remove security team from facility, it first tests the values and then submits them.
*
* @param facility ID of facility which should have security team remove
* @param secTeam ID of SecurityTeam to be removed from facility
*/
public void removeSecurityTeam(final int facility, final int secTeam) {
this.facility = facility;
this.secTeam = secTeam;
// test arguments
if (!this.testAdding()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing SecurityTeam " + secTeam + " from facility " + facility + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("SecurityTeam " + secTeam + " removed from facility " + facility);
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class UpdateFacility method updateFacility.
/**
* Updates facility details
*
* @param fac Facility with updated details
*/
public void updateFacility(Facility fac) {
if (fac == null) {
UiElements.generateAlert("Error updating facility", "Facility to update can't be null.");
return;
}
// GROUP OBJECT
JSONObject oldFacility = new JSONObject(fac);
// RECONSTRUCT OBJECT
JSONObject newFacility = new JSONObject();
newFacility.put("id", oldFacility.get("id"));
newFacility.put("name", oldFacility.get("name"));
newFacility.put("description", oldFacility.get("description"));
newFacility.put("type", oldFacility.get("type"));
newFacility.put("beanName", oldFacility.get("beanName"));
newFacility.put("createdAt", oldFacility.get("createdAt"));
newFacility.put("createdBy", oldFacility.get("createdBy"));
newFacility.put("modifiedAt", oldFacility.get("modifiedAt"));
newFacility.put("modifiedBy", oldFacility.get("modifiedBy"));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("facility", newFacility);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating facility failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
Facility fac = jso.cast();
session.getUiElements().setLogSuccessText("Facility " + fac.getName() + " successfully updated!");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class BanExecServiceOnFacility method prepareJSONObject.
/**
* Prepares a JSON object
*
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("facility", new JSONNumber(facilityId));
jsonQuery.put("service", new JSONNumber(execServiceId));
return jsonQuery;
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class AssignSecurityTeam method assignSecurityTeam.
/**
* Attempts to add security team to facility, it first tests the values and then submits them.
*
* @param facility ID of facility which should have security team added
* @param secTeam ID of SecurityTeam to be added to facility
*/
public void assignSecurityTeam(final int facility, final int secTeam) {
this.facility = facility;
this.secTeam = secTeam;
// test arguments
if (!this.testAdding()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding SecurityTeam " + secTeam + " to facility " + facility + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("SecurityTeam " + secTeam + " added to facility " + facility);
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.json.client.JSONObject in project perun by CESNET.
the class DeleteResourceTag method prepareJSONObject.
/**
* Prepares a JSON object
* @return JSONObject the whole query
*/
private JSONObject prepareJSONObject() {
JSONObject jsonQuery = new JSONObject();
JSONObject jsonTag = new JSONObject(tag);
JSONObject newJsonTag = new JSONObject();
newJsonTag.put("id", jsonTag.get("id"));
newJsonTag.put("tagName", jsonTag.get("tagName"));
newJsonTag.put("voId", jsonTag.get("voId"));
jsonQuery.put("resourceTag", newJsonTag);
return jsonQuery;
}
Aggregations