Search in sources :

Example 81 with JsonPostClient

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

the class AddUserExtSource method addUserExtSource.

/**
	 * Attempts to add new user ext source to specified user
	 *
	 * @param userId ID of user, which should get this external source
	 * @param login login of user in external source
	 * @param extSource object of external source from Perun
	 * @param loa level of assurance
	 */
public void addUserExtSource(final int userId, final String login, final ExtSource extSource, int loa) {
    this.loa = loa;
    this.userId = userId;
    this.login = login;
    this.extSource = extSource;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding UES to user: " + userId + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User Ext Source added to user: " + userId);
            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 82 with JsonPostClient

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

the class CreateService method createService.

/**
	 * Attempts to create a new Service, it first tests the values and then submits them.
	 *
	 * @param name service Name
	 */
public void createService(final String name) {
    this.serviceName = name;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating service " + serviceName + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service " + serviceName + " created.");
            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 83 with JsonPostClient

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

the class SetLogin method setLogin.

/**
	 * Set new login for user
	 *
	 * @param userId
	 * @param namespace
	 * @param login
	 */
public void setLogin(final int userId, final String namespace, final String login) {
    this.userId = userId;
    this.login = login;
    this.namespace = namespace;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding login to user: " + userId + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Login successfully added to user: " + userId);
            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 84 with JsonPostClient

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

the class AddRequiredAttribute method addRequiredAttribute.

/**
	 * Attempts to add required attribute to specified service
	 *
	 * @param serviceId ID of service to get new required attribute
	 * @param attributeId ID of attribute def. which will be added as required
	 */
public void addRequiredAttribute(final int serviceId, final int attributeId) {
    this.serviceId = serviceId;
    this.attributeId = attributeId;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding required attribute ID: " + attributeId + " to service ID: " + serviceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Attribute ID: " + attributeId + " set as required to service ID: " + serviceId);
            ;
            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 85 with JsonPostClient

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

the class AddServiceToServicesPackage method addServiceToServicesPackage.

/**
	 * Attempts to add new Service to service package, it first tests the values and then submits them.
	 *
	 * @param packageId ID of services package to add service to
	 * @param serviceId ID of service to be added to services package
	 */
public void addServiceToServicesPackage(int packageId, int serviceId) {
    this.serviceId = serviceId;
    this.packageId = packageId;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding service to services package failed.");
            if (error != null && error.getName().equals("ServiceAlreadyAssignedException")) {
                UiElements.generateError(error, "Service is already assigned", "Service is already assigned to this services package.");
            } else {
                JsonErrorHandler.alertBox(error);
            }
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service added to services package.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    // custom error handling
    jspc.setHidden(true);
    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

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