Search in sources :

Example 76 with JsonPostClient

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

the class GenerateAccount method generateAccount.

/**
	 * Generates account in namespace with optional password
	 *
	 * @param namespace defined namespace
	 * @param pass password to set
	 * @param params optional params as map of attribute urn and string value
	 */
public void generateAccount(String namespace, String pass, Map<String, String> params) {
    this.namespace = namespace;
    this.pass = pass;
    this.params = params;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // final events
    final JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Account created successfully.");
            events.onFinished(jso);
        }

        ;

        @Override
        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 77 with JsonPostClient

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

the class RemoveSpecificUserOwner method removeServiceUser.

/**
	 * Removes connection between user and specific user
	 *
	 * @param user
	 * @param specificUser
	 */
public void removeServiceUser(final User user, final User specificUser) {
    this.user = user;
    this.specificUser = specificUser;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing " + specificUser.getFullName() + " from user: " + user.getFullName() + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service identity: " + specificUser.getFullName() + " removed from user: " + user.getFullName());
            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 78 with JsonPostClient

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

the class RemoveUserExtSource method removeUserExtSource.

/**
	 * Attempts to remove user ext source from specified user
	 *
	 * @param userId ID of user, which should have his ext source reomved
	 * @param uesId ID of user ext source, which should be removed
	 */
public void removeUserExtSource(final int userId, final int uesId) {
    this.userId = userId;
    this.uesId = uesId;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User Ext Source removed from 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 79 with JsonPostClient

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

the class RemoveDestination method removeDestination.

/**
	 * Attempts to remove a Destination from service and facility, it first tests the values and then
	 * submits them.
	 *
	 * @param destination destination string
	 * @param type type of destination
	 */
public void removeDestination(final String destination, final String type) {
    this.destination = destination;
    this.type = type;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing destination" + destination + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Destination " + destination + " removed.");
            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 80 with JsonPostClient

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

the class UpdateServicePackage method updateServicePackage.

/**
	 * Attempts to update ServicesPackage, it first tests the values and then submits them.
	 *
	 * @param servicesPackage service package to update
	 */
public void updateServicePackage(final ServicesPackage servicesPackage) {
    this.servicesPackage = servicesPackage;
    // test arguments
    if (!this.testUpdating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating service package " + servicesPackage.getName() + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service package " + servicesPackage.getName() + " updated.");
            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

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