use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class CreateAttribute method createAttributeDefinition.
/**
* Creates attribute definition in DB - make RPC call
*
* @param friendlyName name of new attribute
* @param description description of new attribute
* @param namespace namespace of new attribute
* @param type type of new attribute (core,def,opt,virt)
*/
public void createAttributeDefinition(final String displayName, final String friendlyName, final String description, final String namespace, final String type) {
this.displayName = displayName;
this.friendlyName = friendlyName;
this.description = description;
this.namespace = namespace;
this.type = type;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating attribute definition: " + friendlyName + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Attribute definition: " + friendlyName + " successfully created.");
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 DeleteExecService method deleteExecService.
/**
* Deletes Exec Service from DB
*
* @param serviceId id of exec service to be deleted
*/
public void deleteExecService(final int serviceId) {
this.execServiceId = serviceId;
// test arguments
if (!this.testArguments()) {
return;
}
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("execService", new JSONNumber(serviceId));
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting of ExecService: " + execServiceId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("ExecService: " + execServiceId + " deleted successfully.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class FreeDenialOfExecServiceOnFacility method freeDenialOfExecService.
/**
* Attempts to free denial of selected exec service on facility
*
* @param execServiceId
*/
public void freeDenialOfExecService(final int execServiceId) {
this.execServiceId = execServiceId;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Allowing of exec service " + execServiceId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Exec service " + execServiceId + " allowed on facility.");
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 RemoveDependency method removeDependency.
/**
* Remove dependency for exec service on another exec service
*
* @param execService remove dependency for
* @param dependsOn remove dependency on
*/
public void removeDependency(int execService, int dependsOn) {
this.execService = execService;
this.dependsOn = dependsOn;
if (!this.testArguments()) {
return;
}
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("execService", new JSONNumber(execService));
jsonQuery.put("dependantExecService", new JSONNumber(dependsOn));
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing dependancy failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Dependancy sucesfully removed!");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class BanExecServiceOnFacility method banExecService.
/**
* Attempts to ban selected exec service on facility
*
* @param execServiceId
*/
public void banExecService(final int execServiceId) {
this.execServiceId = execServiceId;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Blocking exec service " + execServiceId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Exec service " + execServiceId + " blocked on facility.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations