Search in sources :

Example 16 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class AddGroupUnion method createGroupUnion.

public void createGroupUnion(final Group result, final Group operand) {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("resultGroup", new JSONNumber(result.getId()));
    jsonQuery.put("operandGroup", new JSONNumber(operand.getId()));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating group union with result group " + result.getId() + " and operand group " + operand.getId() + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group union with result group " + result.getId() + " and operand group " + operand.getId() + " successfully created!");
            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 17 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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 18 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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 19 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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 20 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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)

Aggregations

PerunError (cz.metacentrum.perun.webgui.model.PerunError)177 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)173 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)167 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)126 JSONObject (com.google.gwt.json.client.JSONObject)55 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)36 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)36 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)30 ArrayList (java.util.ArrayList)30 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)21 JSONNumber (com.google.gwt.json.client.JSONNumber)17 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)16 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)11 Attribute (cz.metacentrum.perun.webgui.model.Attribute)10 HashMap (java.util.HashMap)10 JSONString (com.google.gwt.json.client.JSONString)8 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)8