use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class RemoveServices method removeService.
/**
* Attempts to remove service from resource
*
* @param serviceId ID of service which should be removed
* @param resourceId ID of resource where should be removed
*/
public void removeService(final int serviceId, final int resourceId) {
this.resourceId = resourceId;
this.serviceIds[0] = serviceId;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing service: " + serviceId + " from resource: " + resourceId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service: " + serviceId + " successfully removed from resource: " + resourceId);
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class GetMembers 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("userAttributesWithSearchingValues", attributesWithSearchingValues);
req.put("vo", new JSONNumber(voId));
// send request
JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Error while loading members.");
loaderImage.loadingError(error);
events.onError(error);
}
public void onLoadingStart() {
loaderImage.loadingStart();
session.getUiElements().setLogText("Loading members started.");
events.onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
loaderImage.loadingFinished();
setList(JsonUtils.<Member>jsoAsList(jso));
sortTable();
session.getUiElements().setLogText("Members loaded: " + list.size());
events.onFinished(jso);
}
});
js.sendData(JSON_URL, req);
return;
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class DeleteService method deleteService.
/**
* Attempts to delete a service, tests values first
*
* @param serviceId id of service to be deleted
*/
public void deleteService(final int serviceId) {
this.serviceId = serviceId;
// test arguments
if (!this.testDeleting()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting service: " + serviceId + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service : " + serviceId + " deleted !");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class HandleApplication method verifyApplication.
/**
* Verify application
*
* @param appId
*/
public void verifyApplication(int appId) {
this.appId = appId;
// test arguments
if (!this.testApplication()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Verifying application failed.");
events.onError(error);
}
@Override
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Application verified.");
events.onFinished(jso);
}
@Override
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL_VERIFY, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class HandleApplication method rejectApplication.
/**
* Reject application
*
* @param appId
* @param reason
*/
public void rejectApplication(int appId, String reason) {
this.appId = appId;
this.reason = reason;
// test arguments
if (!this.testApplication()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Rejecting application failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Application rejected.");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL_REJECT, prepareJSONObject());
}
Aggregations