Example usage for com.google.gwt.user.client Cookies getCookie

List of usage examples for com.google.gwt.user.client Cookies getCookie

Introduction

In this page you can find the example usage for com.google.gwt.user.client Cookies getCookie.

Prototype

public static String getCookie(String name) 

Source Link

Document

Gets the cookie associated with the given name.

Usage

From source file:com.gwtplatform.dispatch.client.DefaultSecurityCookieAccessor.java

License:Apache License

public String getCookieContent() {
    if (cookieName == null) {
        return null;
    }
    return Cookies.getCookie(cookieName);
}

From source file:com.hazelcast.monitor.client.HazelcastMonitor.java

License:Open Source License

private String getTextValue(String name, String defValue) {
    final String value = Cookies.getCookie(name);
    return value != null ? value : defValue;
}

From source file:com.ikon.frontend.client.Main.java

License:Open Source License

public void onModuleLoad() {
    Log.getLogger(DivLogger.class).getWidget().setVisible(false);
    Log.setUncaughtExceptionHandler();/*from   w w w. j  a v  a2  s  . c o m*/
    if (GWT.isProdMode()) {
        Log.setCurrentLogLevel(Log.LOG_LEVEL_OFF);
    } else {
        Log.setCurrentLogLevel(Log.LOG_LEVEL_DEBUG);
    }

    singleton = this;

    // All objects defined before singleton to use global reference.
    langHandlerExtensionList = new ArrayList<LanguageHandlerExtension>();

    // Saves repository context paths
    repositoryContext = new RepositoryContext();

    // Request parameter
    loc = WindowUtils.getLocation();

    // Capture web application context
    if (Cookies.getCookie("ctx") != null && !Cookies.getCookie("ctx").equals("")) {
        CONTEXT = Cookies.getCookie("ctx");
    } else {
        // Otherwise we try to guess
        CONTEXT = loc.getContext();
    }
    if (loc.getParameter("uuid") != null && !loc.getParameter("uuid").equals("")) {
        uuid = loc.getParameter("uuid");
    } else if (loc.getParameter("docPath") != null && !loc.getParameter("docPath").equals("")) {
        docPath = loc.getParameter("docPath");
        fldPath = Util.getParent(docPath);
    } else if (loc.getParameter("fldPath") != null && !loc.getParameter("fldPath").equals("")) {
        fldPath = loc.getParameter("fldPath");
    } else if (loc.getParameter("taskInstanceId") != null && !loc.getParameter("taskInstanceId").equals("")) {
        taskInstanceId = loc.getParameter("taskInstanceId");
    }

    // Try to capture lang parameter
    if (loc.getParameter("lang") != null && !loc.getParameter("lang").equals("")) {
        lang = loc.getParameter("lang");
    } else if (Cookies.getCookie("lang") != null && !Cookies.getCookie("lang").equals("")) {
        lang = Cookies.getCookie("lang");
    } else {
        // First we initialize language values
        lang = Util.getBrowserLanguage();
    }

    if (!uuid.equals("")) {
        repositoryService.getPathByUUID(uuid, new AsyncCallback<String>() {
            @Override
            public void onSuccess(String result) {
                final String path = result;
                folderService.isValid(path, new AsyncCallback<Boolean>() {
                    @Override
                    public void onSuccess(Boolean result) {
                        if (result.booleanValue()) {
                            fldPath = path;
                            loadTranslations();
                        } else {
                            documentService.isValid(path, new AsyncCallback<Boolean>() {
                                @Override
                                public void onSuccess(Boolean result) {
                                    if (result.booleanValue()) {
                                        docPath = path;
                                        fldPath = Util.getParent(path);
                                        loadTranslations();
                                    } else {
                                        mailService.isValid(path, new AsyncCallback<Boolean>() {
                                            @Override
                                            public void onSuccess(Boolean result) {
                                                if (result.booleanValue()) {
                                                    docPath = path;
                                                    fldPath = Util.getParent(path);
                                                    loadTranslations();
                                                } else {
                                                    loadTranslations(); // Should never arrive here
                                                }
                                            }

                                            @Override
                                            public void onFailure(Throwable caught) {
                                                loadTranslations();
                                            }
                                        });
                                    }
                                }

                                @Override
                                public void onFailure(Throwable caught) {
                                    loadTranslations();
                                }
                            });
                        }
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        loadTranslations();
                    }
                });
            }

            @Override
            public void onFailure(Throwable caught) {
                loadTranslations();
            }
        });
    } else {
        loadTranslations();
    }
}

From source file:com.lisedex.volinfoman.client.MainPagePresenter.java

License:Apache License

@Override
public void bind() {
    Log.debug("bind()");
    view.setContent(new HTMLPanel(LOADING_MESSAGE));

    userService.isAuthenticated(Cookies.getCookie(Volinfoman.SESSION_COOKIE), new AsyncCallback<Boolean>() {
        @Override// ww  w  . j a  v  a  2s  .  c  o  m
        public void onSuccess(Boolean result) {
            if (result.booleanValue() == true) {
                view.setContent(new HTMLPanel("<h1>AUTHENTICATED</h1>"));
            } else {
                view.setContent(new HTMLPanel(NOT_AUTHENTICATED_MESSAGE));
                Window.Location.replace(HOME_PAGE_URL);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            view.setContent(new HTMLPanel(RPC_FAILURE_MESSAGE));
        }
    });
}

From source file:com.moesol.gwt.maps.client.MapView.java

License:Open Source License

private GeodeticCoords recoverCenter(double defLng, double defLat) {
    String centerLng = Cookies.getCookie("centerLng");
    String centerLat = Cookies.getCookie("centerLat");
    if (centerLng == null || centerLat == null) {
        return new GeodeticCoords(defLng, defLat, AngleUnit.DEGREES);
    }//from w ww  .j a  v  a  2  s .  c  om
    try {
        double lng = Double.parseDouble(centerLng);
        double lat = Double.parseDouble(centerLat);
        return new GeodeticCoords(lng, lat, AngleUnit.DEGREES);
    } catch (NumberFormatException e) {
        return new GeodeticCoords(defLng, defLat, AngleUnit.DEGREES);
    }
}

From source file:com.nanosim.client.content.other.CwCookies.java

License:Apache License

/**
 * Retrieve the value of the existing cookie and put it into to value label.
 */// www  .j a v  a2  s . com
@NanosimSource
private void updateExstingCookie() {
    // Cannot update if there are no items
    if (existingCookiesBox.getItemCount() < 1) {
        cookieNameBox.setText("");
        cookieValueBox.setText("");
        return;
    }

    int selectedIndex = existingCookiesBox.getSelectedIndex();
    String cookieName = existingCookiesBox.getValue(selectedIndex);
    String cookieValue = Cookies.getCookie(cookieName);
    cookieNameBox.setText(cookieName);
    cookieValueBox.setText(cookieValue);
}

From source file:com.openkm.frontend.client.Main.java

License:Open Source License

public void onModuleLoad() {
    Log.getLogger(DivLogger.class).getWidget().setVisible(false);
    Log.setUncaughtExceptionHandler();/*from   ww w . j a  va2s .  c om*/

    if (GWT.isProdMode()) {
        Log.setCurrentLogLevel(Log.LOG_LEVEL_OFF);
    } else {
        Log.setCurrentLogLevel(Log.LOG_LEVEL_DEBUG);
    }

    singleton = this;

    // All objects defined before singleton to use global reference.
    langHandlerExtensionList = new ArrayList<LanguageHandlerExtension>();

    // Saves repository context paths
    repositoryContext = new RepositoryContext();

    // Request parameter
    loc = WindowUtils.getLocation();

    // Capture web application context
    if (Cookies.getCookie("ctx") != null && !Cookies.getCookie("ctx").equals("")) {
        CONTEXT = Cookies.getCookie("ctx");
    } else {
        // Otherwise we try to guess
        CONTEXT = loc.getContext();
    }

    if (loc.getParameter("uuid") != null && !loc.getParameter("uuid").equals("")) {
        uuid = loc.getParameter("uuid");
    } else if (loc.getParameter("docPath") != null && !loc.getParameter("docPath").equals("")) {
        docPath = loc.getParameter("docPath");
        fldPath = Util.getParent(docPath);
    } else if (loc.getParameter("fldPath") != null && !loc.getParameter("fldPath").equals("")) {
        fldPath = loc.getParameter("fldPath");
    } else if (loc.getParameter("mailPath") != null && !loc.getParameter("mailPath").equals("")) {
        fldPath = Util.getParent(loc.getParameter("mailPath"));
    } else if (loc.getParameter("taskInstanceId") != null && !loc.getParameter("taskInstanceId").equals("")) {
        taskInstanceId = loc.getParameter("taskInstanceId");
    }

    // Try to capture lang parameter
    if (loc.getParameter("lang") != null && !loc.getParameter("lang").equals("")) {
        lang = loc.getParameter("lang");
    } else if (Cookies.getCookie("lang") != null && !Cookies.getCookie("lang").equals("")) {
        lang = Cookies.getCookie("lang");
    } else {
        // First we initialize language values
        lang = Util.getBrowserLanguage();
    }

    if (!uuid.equals("")) {
        repositoryService.getPathByUUID(uuid, new AsyncCallback<String>() {
            @Override
            public void onSuccess(String result) {
                final String path = result;
                folderService.isValid(path, new AsyncCallback<Boolean>() {
                    @Override
                    public void onSuccess(Boolean result) {
                        if (result.booleanValue()) {
                            fldPath = path;
                            loadTranslations();
                        } else {
                            documentService.isValid(path, new AsyncCallback<Boolean>() {
                                @Override
                                public void onSuccess(Boolean result) {
                                    if (result.booleanValue()) {
                                        docPath = path;
                                        fldPath = Util.getParent(path);
                                        loadTranslations();
                                    } else {
                                        mailService.isValid(path, new AsyncCallback<Boolean>() {
                                            @Override
                                            public void onSuccess(Boolean result) {
                                                if (result.booleanValue()) {
                                                    docPath = path;
                                                    fldPath = Util.getParent(path);
                                                    loadTranslations();
                                                } else {
                                                    loadTranslations(); // Should never arrive here
                                                }
                                            }

                                            @Override
                                            public void onFailure(Throwable caught) {
                                                loadTranslations();
                                            }
                                        });
                                    }
                                }

                                @Override
                                public void onFailure(Throwable caught) {
                                    loadTranslations();
                                }
                            });
                        }
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        loadTranslations();
                    }
                });
            }

            @Override
            public void onFailure(Throwable caught) {
                loadTranslations();
            }
        });
    } else {
        loadTranslations();
    }
}

From source file:com.ponysdk.core.terminal.ui.PTCookies.java

License:Apache License

public PTCookies(final UIBuilder uiBuilder) {
    final Collection<String> cookieNames = Cookies.getCookieNames();
    final JSONArray cookies = new JSONArray();
    if (cookieNames != null) {
        int i = 0;
        for (final String cookie : cookieNames) {
            final JSONObject jsoObject = new JSONObject();
            jsoObject.put(ClientToServerModel.COOKIE_NAME.toStringValue(), new JSONString(cookie));
            jsoObject.put(ClientToServerModel.COOKIE_VALUE.toStringValue(),
                    new JSONString(Cookies.getCookie(cookie)));
            cookies.set(i++, jsoObject);
        }//  w  ww  .j  a  v  a2s  .  c om
    }

    final PTInstruction eventInstruction = new PTInstruction(getObjectID());
    eventInstruction.put(ClientToServerModel.COOKIES, cookies);
    uiBuilder.sendDataToServer(eventInstruction);
}

From source file:com.ponysdk.ui.terminal.CommunicationEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override/*from   w  w  w.ja v a 2  s  .c  o  m*/
        public void onUncaughtException(final Throwable e) {
            log.log(Level.SEVERE, "PonySDK has encountered an internal error : ", e);
            Window.alert("PonySDK has encountered an internal error : " + e.getMessage());
        }
    });

    try {

        final PTInstruction requestData = new PTInstruction();

        final JSONArray cookies = new JSONArray();

        // load all cookies at startup
        final Collection<String> cookieNames = Cookies.getCookieNames();
        if (cookieNames != null) {
            final int i = 0;
            for (final String cookie : cookieNames) {
                cookies.set(i, new JSONString(Cookies.getCookie(cookie)));
            }
        }

        requestData.put(APPLICATION.KEY, APPLICATION.KEY_.START);
        requestData.put(HISTORY.TOKEN, History.getToken());
        requestData.put(PROPERTY.COOKIE, cookies);

        final RequestCallback requestCallback = new RequestCallback() {

            @Override
            public void onDataReceived(final JSONObject data) {
                try {
                    final List<PTInstruction> instructions = new ArrayList<PTInstruction>();

                    if (data.containsKey(APPLICATION.VIEW_ID)) {
                        final long viewID = (long) data.get(APPLICATION.VIEW_ID).isNumber().doubleValue();
                        final JSONArray jsonArray = data.get(APPLICATION.INSTRUCTIONS).isArray();

                        for (int i = 0; i < jsonArray.size(); i++) {
                            instructions
                                    .add(new PTInstruction(jsonArray.get(i).isObject().getJavaScriptObject()));
                        }

                        uiBuilder = new UIBuilder(viewID, requestBuilder);
                        uiBuilder.init();
                        uiBuilder.update(instructions);
                        uiBuilder.hideLoadingMessageBox();
                    } else {
                        final JSONArray jsonArray = data.get(APPLICATION.INSTRUCTIONS).isArray();

                        for (int i = 0; i < jsonArray.size(); i++) {
                            instructions
                                    .add(new PTInstruction(jsonArray.get(i).isObject().getJavaScriptObject()));
                        }

                        uiBuilder.update(instructions);
                        uiBuilder.hideLoadingMessageBox();
                    }
                } catch (final RuntimeException exception) {
                    Window.alert("Loading application has failed #" + exception);
                }
            }

            @Override
            public void onError(final Throwable exception) {
                uiBuilder.onCommunicationError(exception);
            }
        };

        requestBuilder = new HttpRequestBuilder(requestCallback);
        requestBuilder.send(requestData.toString());

    } catch (final Exception e) {
        Window.alert("Loading application has failed #" + e);
    }
}

From source file:com.ponysdk.ui.terminal.PonySDK.java

License:Apache License

@Export
public void start() {
    log("starting...");

    try {/*from www. ja va2  s . c  o  m*/

        Long viewID = null;
        final Storage storage = Storage.getSessionStorageIfSupported();
        if (storage != null) {
            final String v = storage.getItem(APPLICATION.VIEW_ID);
            if (v != null && !v.isEmpty())
                viewID = Long.parseLong(v);
        }
        final PTInstruction requestData = new PTInstruction();

        final JSONArray cookies = new JSONArray();

        // load all cookies at startup
        final Collection<String> cookieNames = Cookies.getCookieNames();
        if (cookieNames != null) {
            int i = 0;
            for (final String cookie : cookieNames) {
                final JSONObject jsoObject = new JSONObject();
                jsoObject.put(PROPERTY.KEY, new JSONString(cookie));
                jsoObject.put(PROPERTY.VALUE, new JSONString(Cookies.getCookie(cookie)));
                cookies.set(i++, jsoObject);
            }
        }

        requestData.put(APPLICATION.KEY, APPLICATION.KEY_.START);
        requestData.put(APPLICATION.SEQ_NUM, 0);
        requestData.put(HISTORY.TOKEN, History.getToken());
        requestData.put(PROPERTY.COOKIES, cookies);

        if (viewID != null)
            requestData.put(APPLICATION.VIEW_ID, viewID);

        final RequestCallback requestCallback = new RequestCallback() {

            @Override
            public void onDataReceived(final JSONObject data) {
                try {
                    if (data.containsKey(APPLICATION.VIEW_ID)) {
                        applicationViewID = (long) data.get(APPLICATION.VIEW_ID).isNumber().doubleValue();

                        if (storage != null)
                            storage.setItem(APPLICATION.VIEW_ID, Long.toString(applicationViewID));

                        uiBuilder.init(applicationViewID, requestBuilder);
                    }

                    uiBuilder.update(data);

                } catch (final RuntimeException exception) {
                    log.log(Level.SEVERE,
                            "Failed to process data with error #" + exception.getMessage() + ", data: " + data,
                            exception);
                }
            }

            @Override
            public void onError(final Throwable exception) {
                uiBuilder.onCommunicationError(exception);
            }

        };

        requestBuilder = newRequestBuilder(requestCallback);
        requestBuilder.send(requestData.toString());

    } catch (final Exception e) {
        log.log(Level.SEVERE, "Loading application has failed #" + e.getMessage(), e);
    }
}