Search in sources :

Example 31 with PerunError

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

Example 32 with PerunError

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

the class CreatePassword method createRandomPassword.

/**
	 * Create empty password for the user - random password is generated on KDC side
	 *
	 * @param userId user to set password for
	 * @param login used for validation only
	 * @param namespace defined login in namespace
	 */
public void createRandomPassword(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;
    }
    // final events
    final JsonCallbackEvents newEvents = 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) {
            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_RANDOM, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) 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) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 33 with PerunError

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

the class FindUsersByIdsNotInRpc method retrieveData.

/**
	 * Retrieves data from RPC
	 */
public void retrieveData() {
    String[] ids = searchString.split(",");
    if (ids.length == 0) {
        return;
    }
    idsCount = ids.length;
    onLoadingStart();
    for (String id : ids) {
        // trims the whitespace
        id = id.trim();
        try {
            int idint = Integer.parseInt(id);
            GetEntityById req = new GetEntityById(PerunEntity.USER, idint, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    idsFound++;
                    // add to result
                    int i = result.size();
                    result.set(i, new JSONObject(jso));
                    isFinished();
                }

                public void onError(PerunError err) {
                    idsFound++;
                    isFinished();
                }
            });
            req.retrieveData();
        } catch (Exception e) {
        }
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 34 with PerunError

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

the class RemoveRequiredAttribute method removeRequiredAttribute.

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

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Attribute ID: " + attributeId + " removed as required from 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 35 with PerunError

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

the class RemoveServiceFromServicesPackage method removeServiceFromServicesPackage.

/**
	 * Attempts to remove Service from services package, it first tests the values and then submits them.
	 *
	 * @param packageId ID of services package to remove service from
	 * @param serviceId ID of service to be removed from services package
	 */
public void removeServiceFromServicesPackage(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("Removing service from services package failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service removed from services package.");
            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