Search in sources :

Example 1 with ValidatePreferredEmailChange

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

the class WebGui method checkIfMailVerification.

/**
 * Check if URL parameters contains data for mail verification and display different GUI instead.
 *
 * @return TRUE if parameters are contained and valid in URL, FALSE otherwise.
 */
public boolean checkIfMailVerification() {
    // Trigger validation if necessary
    if (Location.getParameterMap().keySet().contains("token") && Location.getParameterMap().keySet().contains("u")) {
        String verifyToken = Location.getParameter("token");
        String verifyU = Location.getParameter("u");
        if (verifyToken != null && !verifyToken.isEmpty() && verifyU != null && !verifyU.isEmpty() && JsonUtils.checkParseInt(verifyU)) {
            ValidatePreferredEmailChange call = new ValidatePreferredEmailChange(verifyToken, Integer.parseInt(verifyU), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    BasicOverlayType over = jso.cast();
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>" + "The email address: <i>" + (SafeHtmlUtils.fromString(over.getString())).asString() + "</i></h2><h2>was verified and set as your preferred email.</h2>");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    body.add(ft);
                }

                @Override
                public void onLoadingStart() {
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    ft.setWidget(0, 0, new AjaxLoaderImage());
                    body.add(ft);
                }

                @Override
                public void onError(PerunError error) {
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.deleteIcon()) + "<h2>Your new email address couldn't be verified !</h2>");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    if (error == null) {
                        ft.setHTML(1, 0, "Request timeout exceeded.");
                        ft.getFlexCellFormatter().setStyleName(1, 0, "serverResponseLabelError");
                    } else {
                        // display raw message
                        ft.setHTML(1, 0, "<strong>" + error.getErrorInfo() + "</strong>");
                    }
                    ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    body.add(ft);
                }
            });
            call.retrieveData();
        }
        return true;
    }
    return false;
}
Also used : ValidatePreferredEmailChange(cz.metacentrum.perun.webgui.json.usersManager.ValidatePreferredEmailChange) JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType) PerunError(cz.metacentrum.perun.webgui.model.PerunError) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 ValidatePreferredEmailChange (cz.metacentrum.perun.webgui.json.usersManager.ValidatePreferredEmailChange)1 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)1 PerunError (cz.metacentrum.perun.webgui.model.PerunError)1 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)1