use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class AddUserExtSource method addUserExtSource.
/**
* Attempts to add new user ext source to specified user
*
* @param userId ID of user, which should get this external source
* @param login login of user in external source
* @param extSource object of external source from Perun
* @param loa level of assurance
*/
public void addUserExtSource(final int userId, final String login, final ExtSource extSource, int loa) {
this.loa = loa;
this.userId = userId;
this.login = login;
this.extSource = extSource;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding UES to user: " + userId + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User Ext Source added to 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 CreateService method createService.
/**
* Attempts to create a new Service, it first tests the values and then submits them.
*
* @param name service Name
*/
public void createService(final String name) {
this.serviceName = name;
// 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 SetLogin method setLogin.
/**
* Set new login for user
*
* @param userId
* @param namespace
* @param login
*/
public void setLogin(final int userId, final String namespace, final String login) {
this.userId = userId;
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: " + userId + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Login successfully added to 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 AddRequiredAttribute method addRequiredAttribute.
/**
* Attempts to add required attribute to specified service
*
* @param serviceId ID of service to get new required attribute
* @param attributeId ID of attribute def. which will be added as required
*/
public void addRequiredAttribute(final int serviceId, final int attributeId) {
this.serviceId = serviceId;
this.attributeId = attributeId;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding required attribute ID: " + attributeId + " to service ID: " + serviceId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Attribute ID: " + attributeId + " set as required to service ID: " + serviceId);
;
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 AddServiceToServicesPackage method addServiceToServicesPackage.
/**
* Attempts to add new Service to service package, it first tests the values and then submits them.
*
* @param packageId ID of services package to add service to
* @param serviceId ID of service to be added to services package
*/
public void addServiceToServicesPackage(int packageId, int serviceId) {
this.serviceId = serviceId;
this.packageId = packageId;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding service to services package failed.");
if (error != null && error.getName().equals("ServiceAlreadyAssignedException")) {
UiElements.generateError(error, "Service is already assigned", "Service is already assigned to this services package.");
} else {
JsonErrorHandler.alertBox(error);
}
// custom events
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service added to services package.");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
// custom error handling
jspc.setHidden(true);
jspc.sendData(JSON_URL, prepareJSONObject());
}
Aggregations