use of com.google.gwt.core.client.JavaScriptObject 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());
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class RequestPreferredEmailChange method requestChange.
/**
* Request change of preferred email
*
* @param user
* @param email
*/
public void requestChange(final User user, final String email) {
this.user = user;
this.email = email;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Requesting change of preferred email failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Request to change preferred email was submitted.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class SetLogin method setLogin.
/**
* Set new login for user
*
* @param user
* @param namespace
* @param login
*/
public void setLogin(final User user, final String namespace, final String login) {
this.user = user;
this.userId = user.getId();
this.login = login;
this.namespace = namespace;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding login to user: " + user.getFullName() + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Login successfully added to user: " + user.getFullName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class UpdateNameTitles method updateUserTitles.
/**
* Updates user details
* @param user User with updated details
*/
public void updateUserTitles(User user) {
if (user == null) {
UiElements.generateAlert("Parameter error", "User to update can't be null");
return;
}
// OBJECT
JSONObject oldUser = new JSONObject(user);
// RECONSTRUCT OBJECT
JSONObject newUser = new JSONObject();
newUser.put("id", oldUser.get("id"));
newUser.put("firstName", oldUser.get("firstName"));
newUser.put("middleName", oldUser.get("middleName"));
newUser.put("lastName", oldUser.get("lastName"));
newUser.put("titleBefore", oldUser.get("titleBefore"));
newUser.put("titleAfter", oldUser.get("titleAfter"));
newUser.put("serviceUser", oldUser.get("serviceUser"));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("user", newUser);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating user failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
User u = jso.cast();
session.getUiElements().setLogSuccessText("User " + u.getFullNameWithTitles() + " 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.core.client.JavaScriptObject in project perun by CESNET.
the class AddDestinationsByHostsOnFacility method addDestinationByHosts.
/**
* Attempts to add new Destination to services and facility, it first tests the values and then
* submits them.
*
* @param services list of services to have destinations by hosts added
*/
public void addDestinationByHosts(ArrayList<Service> services) {
this.services = services;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding destination for facility: " + facility.getName() + " failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Destination for facility: " + facility.getName() + " added.");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations