use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class ApplicationFormPage method tryToFindUserByName.
/**
* Try to find user by name
*
* If user found, message box shown
*
* @param jso returned data
*/
private void tryToFindUserByName(JavaScriptObject jso) {
// try to find
JsonPostClient jspc = new JsonPostClient(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<Identity> users = JsonUtils.<Identity>jsoAsList(jso);
if (users != null && !users.isEmpty())
similarUsersFound(users);
}
});
JSONObject query = new JSONObject();
if (jso == null) {
// before app submission
jspc.sendData("registrarManager/checkForSimilarUsers", query);
} else {
// after app submission
query.put("voId", new JSONNumber(vo.getId()));
if (group != null) {
query.put("groupId", new JSONNumber(group.getId()));
} else {
query.put("groupId", new JSONNumber(0));
}
query.put("type", new JSONString(type));
jspc.sendData("registrarManager/checkForSimilarUsers", query);
}
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient 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.JsonPostClient in project perun by CESNET.
the class ForceGroupSynchronization method synchronizeGroup.
/**
* Immediately queues group for synchronization.
*
* @param groupId ID of group to be synchronized
*/
public void synchronizeGroup(final int groupId) {
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("group", new JSONNumber(groupId));
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Forcing synchronization of group " + groupId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Group " + groupId + " queued for synchronization!");
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.JsonPostClient in project perun by CESNET.
the class CopyOwners method copyFacilityOwners.
/**
* Attempts to copy owners from one facility to another
*
* @param sourceFacility ID of source facility to get owners from
* @param destinationFacility ID of destination facility to copy owners to
*/
public void copyFacilityOwners(int sourceFacility, int destinationFacility) {
this.sourceFacility = sourceFacility;
this.destinationFacility = destinationFacility;
// test arguments
if (!this.testCreating()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Copying facility owners failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Facility owners copied.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class DeleteFacility method deleteFacility.
/**
* Attempts to delete the facility.
* @param facilityId - ID of the facility which should be deleted
*/
public void deleteFacility(final int facilityId) {
this.facilityId = facilityId;
// test arguments
if (!this.testDeleting()) {
return;
}
// json object
JSONObject jsonQuery = prepareJSONObject();
// local events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting facility: " + facilityId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Faicility: " + facilityId + " sucessfully deleted.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// create request
JsonPostClient request = new JsonPostClient(newEvents);
request.sendData(JSON_URL, jsonQuery);
}
Aggregations