use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class ChangePassword method changePassword.
/**
* Changes password for the user
*
* @param user User to change password for
* @param loginNamespace Login namespace
* @param oldPassword Old password for comparing
* @param newPassword New password
*/
public void changePassword(User user, String loginNamespace, String oldPassword, String newPassword) {
this.user = user;
this.loginNamespace = loginNamespace;
this.oldPassword = oldPassword;
this.newPassword = newPassword;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Changing password failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Password changed successfully.");
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.JsonPostClient in project perun by CESNET.
the class CreateCompleteService method createCompleteService.
/**
* Attempts to create a new Service including both ExecServices with dependency,
* it first tests the values and then submits them.
*
* @param name service Name
* @param scriptPath Path to the service script, default "./service_name"
* @param defaultDelay Delay in minutes when service is rescheduled (10 min is default)
* @param enabled TRUE if service should be enabled
*/
public void createCompleteService(final String name, final String scriptPath, final int defaultDelay, final boolean enabled) {
this.serviceName = name;
this.scriptPath = scriptPath;
this.defaultDelay = defaultDelay;
this.enabled = enabled;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating service " + serviceName + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service " + serviceName + " 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.JsonPostClient in project perun by CESNET.
the class CreateServicePackage method createServicePackage.
/**
* Attempts to create a new ServicesPackage, it first tests the values and then submits them.
*
* @param name service package name
* @param description service package description
*/
public void createServicePackage(final String name, final String description) {
this.packageName = name;
this.packageDescription = description;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating service package " + packageName + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service package " + packageName + " 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.JsonPostClient 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.JsonPostClient in project perun by CESNET.
the class DeleteServicePackage method deleteServicePackage.
/**
* Attempts to delete a service, tests values first
*
* @param packageId id of service to be deleted
*/
public void deleteServicePackage(final int packageId) {
this.packageId = packageId;
// test arguments
if (!this.testDeleting()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting service package: " + packageId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service package: " + packageId + " deleted !");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations