use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class LockUnlockPublications method lockUnlockPublications.
/**
* Attempts to lock / unlock a Publication, it first tests the values and then submits them.
*
* @param lock true = lock / false = unlock
* @param publications list of pubs to update
*/
public void lockUnlockPublications(final boolean lock, final ArrayList<Publication> publications) {
this.publications = publications;
this.lock = lock;
// 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("Lock/Unlock publication failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Publications locked / unlocked.");
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 UpdateCategory method updateCategory.
/**
* Attempts to update a Category, it first tests the values and then submits them.
*
* @param category category to update
*/
public void updateCategory(Category category) {
this.id = category.getId();
this.name = category.getName();
this.rank = category.getRank();
// 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("Updating category " + name + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Category " + name + " updated.");
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 RemoveAdmin method removeSecurityTeamAdmin.
/**
* Attempts to remove admin from SecurityTeam, it first tests the values and then submits them.
*
* @param securityTeam where we want to remove admin from
* @param user User to be removed from admins
*/
public void removeSecurityTeamAdmin(final SecurityTeam securityTeam, final User user) {
this.userId = (user != null) ? user.getId() : 0;
this.entityId = (securityTeam != null) ? securityTeam.getId() : 0;
this.entity = PerunEntity.SECURITY_TEAM;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing " + user.getFullName() + " from managers failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User " + user.getFullName() + " removed form managers of " + securityTeam.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(SECURITY_JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class RemoveAdmin method removeGroupAdminGroup.
/**
* Attempts to remove admin group from Group, it first tests the values and then submits them.
*
* @param groupToAddAdminTo where we want to remove admin group from
* @param group Group to be removed from admins
*/
public void removeGroupAdminGroup(final Group groupToAddAdminTo, final Group group) {
// store group id to user id to used unified check method
this.userId = (group != null) ? group.getId() : 0;
this.entityId = (groupToAddAdminTo != null) ? groupToAddAdminTo.getId() : 0;
this.entity = PerunEntity.GROUP;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing group " + group.getShortName() + " from managers failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " removed from managers of " + groupToAddAdminTo.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(GROUP_JSON_URL, prepareJSONObjectForGroup());
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class RemoveAdmin method removeSecurityTeamAdminGroup.
/**
* Attempts to remove admin group from SecurityTeam, it first tests the values and then submits them.
*
* @param securityTeam where we want to remove admin from
* @param group Group to be removed from admins
*/
public void removeSecurityTeamAdminGroup(final SecurityTeam securityTeam, final Group group) {
// store group id to user id to used unified check method
this.userId = (group != null) ? group.getId() : 0;
this.entityId = (securityTeam != null) ? securityTeam.getId() : 0;
this.entity = PerunEntity.SECURITY_TEAM;
// test arguments
if (!this.testRemoving()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Removing group " + group.getShortName() + " from managers failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " removed from managers of " + securityTeam.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(SECURITY_JSON_URL, prepareJSONObjectForGroup());
}
Aggregations