use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class GenerateAccount method generateAccount.
/**
* Generates account in namespace with optional password
*
* @param namespace defined namespace
* @param pass password to set
* @param params optional params as map of attribute urn and string value
*/
public void generateAccount(String namespace, String pass, Map<String, String> params) {
this.namespace = namespace;
this.pass = pass;
this.params = params;
// test arguments
if (!this.testAdding()) {
return;
}
// final events
final JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating account failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Account created successfully.");
events.onFinished(jso);
}
;
@Override
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 RemoveSpecificUserOwner method removeServiceUser.
/**
* Removes connection between user and specific user
*
* @param user
* @param specificUser
*/
public void removeServiceUser(final User user, final User specificUser) {
this.user = user;
this.specificUser = specificUser;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing " + specificUser.getFullName() + " from user: " + user.getFullName() + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service identity: " + specificUser.getFullName() + " removed from 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 cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class RemoveUserExtSource method removeUserExtSource.
/**
* Attempts to remove user ext source from specified user
*
* @param userId ID of user, which should have his ext source reomved
* @param uesId ID of user ext source, which should be removed
*/
public void removeUserExtSource(final int userId, final int uesId) {
this.userId = userId;
this.uesId = uesId;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing UES: " + uesId + " from user: " + userId + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User Ext Source removed from user: " + userId);
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 RemoveDestination method removeDestination.
/**
* Attempts to remove a Destination from service and facility, it first tests the values and then
* submits them.
*
* @param destination destination string
* @param type type of destination
*/
public void removeDestination(final String destination, final String type) {
this.destination = destination;
this.type = type;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing destination" + destination + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Destination " + destination + " removed.");
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 UpdateServicePackage method updateServicePackage.
/**
* Attempts to update ServicesPackage, it first tests the values and then submits them.
*
* @param servicesPackage service package to update
*/
public void updateServicePackage(final ServicesPackage servicesPackage) {
this.servicesPackage = servicesPackage;
// test arguments
if (!this.testUpdating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating service package " + servicesPackage.getName() + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service package " + servicesPackage.getName() + " updated.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations