use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class AddAdmin method addSecurityTeamAdmin.
/**
* Attempts to add a new admin to SecurityTeam, it first tests the values and then submits them.
*
* @param securityTeam where we want to add admin
* @param user User to be admin
*/
public void addSecurityTeamAdmin(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.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding " + user.getFullName() + " as manager failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User " + user.getFullName() + " added as manager 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 AddAdmin method addVoAdminGroup.
/**
* Attempts to add a new admin group to VO, it first tests the values and then submits them.
*
* @param vo where we want to add admin
* @param group Group to be admin
*/
public void addVoAdminGroup(final VirtualOrganization vo, final Group group) {
// store group id to user id to used unified check method
this.userId = (group != null) ? group.getId() : 0;
this.entityId = (vo != null) ? vo.getId() : 0;
this.entity = PerunEntity.VIRTUAL_ORGANIZATION;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding group " + group.getShortName() + " as manager failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " added as manager of " + vo.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(VO_JSON_URL, prepareJSONObjectForGroup());
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class AddAdmin method addFacilityAdmin.
/**
* Attempts to add a new admin to Facility, it first tests the values and then submits them.
*
* @param facility where we want to add admin
* @param user User to be admin
*/
public void addFacilityAdmin(final Facility facility, final User user) {
this.userId = (user != null) ? user.getId() : 0;
this.entityId = (facility != null) ? facility.getId() : 0;
this.entity = PerunEntity.FACILITY;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding " + user.getFullName() + " as manager failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User " + user.getFullName() + " added as manager of " + facility.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(FACILITY_JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class AddAdmin method addGroupAdmin.
/**
* Attempts to add a new admin to Group, it first tests the values and then submits them.
*
* @param group where we want to add admin
* @param user User to be admin
*/
public void addGroupAdmin(final Group group, final User user) {
this.userId = (user != null) ? user.getId() : 0;
this.entityId = (group != null) ? group.getId() : 0;
this.entity = PerunEntity.GROUP;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding " + user.getFullName() + " as manager failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User " + user.getFullName() + " added as manager of " + group.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(GROUP_JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.
the class AddAdmin method addVoAdmin.
/**
* Attempts to add a new admin to VO, it first tests the values and then submits them.
*
* @param vo where we want to add admin
* @param user User to be admin
*/
public void addVoAdmin(final VirtualOrganization vo, final User user) {
this.userId = (user != null) ? user.getId() : 0;
this.entityId = (vo != null) ? vo.getId() : 0;
this.entity = PerunEntity.VIRTUAL_ORGANIZATION;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Adding " + user.getFullName() + " as manager failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("User " + user.getFullName() + " added as manager of " + vo.getName());
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(VO_JSON_URL, prepareJSONObject());
}
Aggregations