Search in sources :

Example 11 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class DeleteGroup method deleteGroup.

/**
	 * Delete a group from VO in DB
	 *
	 * @param groupId ID of group to be deleted
	 */
public void deleteGroup(final int groupId) {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("group", new JSONNumber(groupId));
    jsonQuery.put("force", new JSONNumber(1));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting group " + groupId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group " + groupId + " successfully deleted!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 12 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class RemoveSecurityTeam method removeSecurityTeam.

/**
	 * Attempts to remove security team from facility, it first tests the values and then submits them.
	 *
	 * @param facility ID of facility which should have security team remove
	 * @param secTeam ID of SecurityTeam to be removed from facility
	 */
public void removeSecurityTeam(final int facility, final int secTeam) {
    this.facility = facility;
    this.secTeam = secTeam;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing SecurityTeam " + secTeam + " from facility " + facility + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("SecurityTeam " + secTeam + " removed from facility " + facility);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 13 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class UpdateFacility method updateFacility.

/**
	 * Updates facility details
	 *
	 * @param fac Facility with updated details
	 */
public void updateFacility(Facility fac) {
    if (fac == null) {
        UiElements.generateAlert("Error updating facility", "Facility to update can't be null.");
        return;
    }
    // GROUP OBJECT
    JSONObject oldFacility = new JSONObject(fac);
    // RECONSTRUCT OBJECT
    JSONObject newFacility = new JSONObject();
    newFacility.put("id", oldFacility.get("id"));
    newFacility.put("name", oldFacility.get("name"));
    newFacility.put("description", oldFacility.get("description"));
    newFacility.put("type", oldFacility.get("type"));
    newFacility.put("beanName", oldFacility.get("beanName"));
    newFacility.put("createdAt", oldFacility.get("createdAt"));
    newFacility.put("createdBy", oldFacility.get("createdBy"));
    newFacility.put("modifiedAt", oldFacility.get("modifiedAt"));
    newFacility.put("modifiedBy", oldFacility.get("modifiedBy"));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", newFacility);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating facility failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            Facility fac = jso.cast();
            session.getUiElements().setLogSuccessText("Facility " + fac.getName() + " successfully updated!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError) Facility(cz.metacentrum.perun.webgui.model.Facility)

Example 14 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class BanExecServiceOnFacility method banExecService.

/**
	 * Attempts to ban selected exec service on facility
	 *
	 * @param execServiceId
	 */
public void banExecService(final int execServiceId) {
    this.execServiceId = execServiceId;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Blocking exec service " + execServiceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Exec service " + execServiceId + " blocked on facility.");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 15 with JsonPostClient

use of cz.metacentrum.perun.webgui.json.JsonPostClient in project perun by CESNET.

the class AssignSecurityTeam method assignSecurityTeam.

/**
	 * Attempts to add security team to facility, it first tests the values and then submits them.
	 *
	 * @param facility ID of facility which should have security team added
	 * @param secTeam ID of SecurityTeam to be added to facility
	 */
public void assignSecurityTeam(final int facility, final int secTeam) {
    this.facility = facility;
    this.secTeam = secTeam;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding SecurityTeam " + secTeam + " to facility " + facility + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("SecurityTeam " + secTeam + " added to facility " + facility);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Aggregations

JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)150 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)149 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)149 PerunError (cz.metacentrum.perun.webgui.model.PerunError)126 JSONObject (com.google.gwt.json.client.JSONObject)50 JSONNumber (com.google.gwt.json.client.JSONNumber)18 JSONString (com.google.gwt.json.client.JSONString)6 HTML (com.google.gwt.user.client.ui.HTML)3 Publication (cz.metacentrum.perun.webgui.model.Publication)3 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)3 Group (cz.metacentrum.perun.webgui.model.Group)2 User (cz.metacentrum.perun.webgui.model.User)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JSONArray (com.google.gwt.json.client.JSONArray)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 Image (com.google.gwt.user.client.ui.Image)1 Facility (cz.metacentrum.perun.webgui.model.Facility)1 Identity (cz.metacentrum.perun.webgui.model.Identity)1 Member (cz.metacentrum.perun.webgui.model.Member)1