Search in sources :

Example 21 with JsonPostClient

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

the class DeleteSecurityTeam method deleteSecurityTeam.

/**
	 * Attempts to delete Security Team, it first tests the values and then submits them.
	 *
	 * @param securityTeamId ID of SecurityTeam to be deleted
	 * @param force true for force delete
	 */
public void deleteSecurityTeam(final int securityTeamId, final boolean force) {
    this.securityTeamId = securityTeamId;
    this.force = force;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting Security Team: " + securityTeamId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Security Team " + securityTeamId + " deleted.");
            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 22 with JsonPostClient

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

the class SendInvitation method inviteUser.

/**
	 * Send request to invite user
	 */
public void inviteUser(String email, String name, String language) {
    if (email == null || email.isEmpty()) {
        UiElements.generateAlert("Input error", "Email address to send invitation to is empty.");
        return;
    }
    if (!JsonUtils.isValidEmail(email)) {
        UiElements.generateAlert("Input error", "Email address format is not valid.");
        return;
    }
    /*
		if (name == null || name.isEmpty()) {
			UiElements.generateAlert("Input error", "Name of user to invite can't be empty.");
			return;
		}
		*/
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User invited.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // query
    JSONObject query = new JSONObject();
    query.put("voId", new JSONNumber(voId));
    if (groupId != 0) {
        query.put("groupId", new JSONNumber(groupId));
    }
    if (name != null && !name.isEmpty())
        query.put("name", new JSONString(name));
    query.put("email", new JSONString(email));
    if (language != null && !language.isEmpty()) {
        query.put("language", new JSONString(language));
    } else {
        query.put("language", new JSONObject(null));
    }
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, query);
}
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) JSONString(com.google.gwt.json.client.JSONString)

Example 23 with JsonPostClient

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

the class UpdateFormItems method updateFormItems.

/**
	 * Updates form items in DB by passed list of them
	 *
	 * @param formItems
	 */
public void updateFormItems(ArrayList<ApplicationFormItem> formItems) {
    this.formItems = formItems;
    ;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Form items 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)

Example 24 with JsonPostClient

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

the class CreatePassword method validateAndSetUserExtSources.

/**
	 * Validates password and sets user ext sources
	 *
	 * @param userId user to set password for
	 * @param login used for validation only
	 * @param namespace defined login in namespace
	 */
public void validateAndSetUserExtSources(int userId, String login, String namespace) {
    this.userId = userId;
    this.namespace = namespace;
    this.login = login;
    // test arguments
    String errorMsg = "";
    if (userId == 0) {
        errorMsg += "<p>User ID can't be 0.";
    }
    if (namespace.isEmpty()) {
        errorMsg += "<p>Namespace can't be empty.";
    }
    if (login.isEmpty()) {
        errorMsg += "<p>Login to create password for can't be empty.";
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while creating password.", new HTML(errorMsg), true);
        c.show();
        return;
    }
    JsonPostClient jspc = new JsonPostClient(events);
    jspc.sendData(JSON_URL_VALIDATE_AND_SET_USER_EXT_SOURCE, validateCallJSON());
}
Also used : JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) JSONString(com.google.gwt.json.client.JSONString)

Example 25 with JsonPostClient

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

the class CreatePassword method createPassword.

/**
	 * Changes password for the user
	 *
	 * @param userId user to set password for
	 * @param login used for validation only
	 * @param namespace defined login in namespace
	 * @param pass password to set
	 */
public void createPassword(int userId, String login, String namespace, String pass) {
    this.userId = userId;
    this.namespace = namespace;
    this.pass = pass;
    this.login = login;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // final events
    final JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

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

        ;
    };
    // validate event
    JsonCallbackEvents validateEvent = new JsonCallbackEvents() {

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

        ;

        @Override
        public void onFinished(JavaScriptObject jso) {
            JsonPostClient jspc = new JsonPostClient(newEvents);
            jspc.sendData(JSON_URL_VALIDATE_AND_SET_USER_EXT_SOURCE, validateCallJSON());
        }

        ;

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

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(validateEvent);
    jspc.sendData(JSON_URL_RESERVE, 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