public static void getUsers(final DataCallback<List<UserDto>> onFinish) { FindUsersRequest request = new FindUsersRequest(); GwtCommand command = new GwtCommand(FindUsersRequest.COMMAND); command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<FindUsersResponse>() { public void execute(FindUsersResponse response) { if (onFinish != null) { onFinish.execute(response.getUsers()); } } }); }
/** * Execute a GWT RPC command request, and return the response. These request come from the client, and the response * is sent back to the client. We use a {@link CommandDispatcher} to actually execute the command. */ public CommandResponse execute(GwtCommand request) { if (request != null) { return commandDispatcher.execute(request.getCommandName(), request.getCommandRequest(), request.getUserToken(), request.getLocale()); } return null; }
@UiHandler("generateExceptionButton") protected void onGenerateExceptionClicked(ClickEvent event) { EmptyCommandRequest request = new EmptyCommandRequest(); GwtCommand command = new GwtCommand(); command.setCommandName("command.GetSimpleExceptionCommand"); command.setCommandRequest(request); GeomajasServerExtension.getInstance().getCommandService() .execute(command, new AbstractCommandCallback<CommandResponse>() { @Override public void execute(CommandResponse response) { // don't do anything. An Exception will been thrown at // server-side } }); } }
/** * Logs the user out. * * @param callback * A possible callback to be executed when the logout has been done (successfully or not). Can be null. */ public void logout(final BooleanCallback callback) { GwtCommand command = new GwtCommand("command.Logout"); GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() { public void execute(CommandResponse response) { if (response instanceof SuccessCommandResponse) { SuccessCommandResponse successResponse = (SuccessCommandResponse) response; if (successResponse.isSuccess()) { userToken = null; Authentication.this.userId = null; if (callback != null) { callback.execute(true); } manager.fireEvent(new LogoutSuccessEvent()); } else { if (callback != null) { callback.execute(false); } manager.fireEvent(new LogoutFailureEvent()); } } } }); }
/** * Add a command and it's callbacks to the list of commands to retry after login. * * @param command * command to retry * @param deferred * callbacks for the command */ private void afterLogin(GwtCommand command, Deferred deferred) { String token = notNull(command.getUserToken()); if (!afterLoginCommands.containsKey(token)) { afterLoginCommands.put(token, new ArrayList<RetryCommand>()); } afterLoginCommands.get(token).add(new RetryCommand(command, deferred)); }
/** * Logs the user out. * * @param callback * A possible callback to be executed when the logout has been done (successfully or not). Can be null. */ public void logout(final BooleanCallback callback) { GwtCommand command = new GwtCommand(logoutCommandName); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<SuccessCommandResponse>() { public void execute(SuccessCommandResponse response) { if (response.isSuccess()) { userToken = null; Authentication.this.userId = null; if (callback != null) { callback.execute(true); } GwtCommandDispatcher.getInstance().logout(); manager.fireEvent(new LogoutSuccessEvent()); } else { if (callback != null) { callback.execute(false); } manager.fireEvent(new LogoutFailureEvent()); } } }); }
/** * Method which forces retry of a command after login. * <p/> * This method assumes the single threaded nature of JavaScript execution for correctness. * * @param command * command which needs to be retried * @param deferred * callbacks for the command */ private void handleLogin(GwtCommand command, Deferred deferred) { final String oldToken = notNull(command.getUserToken()); if (!afterLoginCommands.containsKey(oldToken)) { afterLoginCommands.put(oldToken, new ArrayList<RetryCommand>()); login(oldToken); } afterLogin(command, deferred); }
/** * Send a command to reload all dynamic layers. */ public static void reloadDynamicLayers() { ReloadDynamicLayersRequest request = new ReloadDynamicLayersRequest(); GwtCommand command = new GwtCommand(ReloadDynamicLayersRequest.COMMAND); command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command); }
GwtCommand command = new GwtCommand(logoutCommandName); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<SuccessCommandResponse>() {
/** * Execute a GWT RPC command request, and return the response. These request come from the client, and the response * is sent back to the client. We use a {@link CommandDispatcher} to actually execute the command. */ public CommandResponse execute(GwtCommand request) { if (request != null) { return commandDispatcher.execute(request.getCommandName(), request.getCommandRequest(), request.getUserToken(), request.getLocale()); } return null; }
authenticationFailed |= SECURITY_EXCEPTION_CLASS_NAME.equals(exception.getClassName()) && (ExceptionCode.CREDENTIALS_MISSING_OR_INVALID == exception.getExceptionCode() || isUndefinedToken(command.getUserToken()));
@Override public void getGroups(final DataCallback<List<TerritoryDto>> onFinish) { GetTerritoriesRequest request = new GetTerritoriesRequest(); GwtCommand command = new GwtCommand(GetTerritoriesRequest.COMMAND); command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetTerritoriesResponse>() { public void execute(GetTerritoriesResponse response) { if (onFinish != null) { onFinish.execute(response.getTerritories()); } } }); }
/** * Logs the user out. */ public static void logout() { GwtCommandDispatcher dispatcher = GwtCommandDispatcher.getInstance(); if (null != dispatcher.getUserToken()) { GwtCommand command = new GwtCommand(LogoutRequest.COMMAND); dispatcher.logout(); dispatcher.execute(command); } }
public void execute(PrintGetTemplateResponse response) { UrlBuilder url = new UrlBuilder(GWT.getHostPageBaseURL()); url.addPath(URL_PATH); url.addParameter(URL_DOCUMENT_ID, response.getDocumentId()); // url.addParameter(URL_NAME, (String) fileNameItem.getValue()); url.addParameter(URL_NAME, "mapPrinting.pdf"); url.addParameter(URL_TOKEN, command.getUserToken()); // TODO String downloadType = downloadTypeGroup.getValue() String downloadType = OPEN; if (SAVE.equals(downloadType)) { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_YES); // TODO Converted to pureGWT // String encodedUrl = url.toString(); // // create a hidden iframe to avoid popups ??? // HTMLPanel hiddenFrame = new HTMLPanel("<iframe src='" + encodedUrl // + "'+style='position:absolute;width:0;height:0;border:0'>"); // hiddenFrame.setVisible(false); // // addChild(hiddenFrame); } else { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_NO); String encodedUrl = url.toString(); com.google.gwt.user.client.Window.open(encodedUrl, "_blank", null); } } });
/** * {@see org.geomajas.plugin.deskmanager.command.manager.GetLayerModelsCommand}. * * @param onFinish callback called when layermodels are retrieved. */ public static void getLayerModels(final DataCallback<List<LayerModelDto>> onFinish) { GetLayerModelsRequest request = new GetLayerModelsRequest(); GwtCommand command = new GwtCommand(GetLayerModelsRequest.COMMAND); command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetLayerModelsResponse>() { public void execute(GetLayerModelsResponse response) { if (onFinish != null) { onFinish.execute(response.getLayerModels()); } } }); }
GwtCommand command = new GwtCommand("command.Logout"); GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() {
public void execute(PrintGetTemplateResponse response) { stopProgress(); UrlBuilder url = new UrlBuilder(GWT.getHostPageBaseURL()); url.addPath(URL_PATH); url.addParameter(URL_DOCUMENT_ID, response.getDocumentId()); url.addParameter(URL_NAME, (String) fileNameItem.getValue()); url.addParameter(URL_TOKEN, command.getUserToken()); if (SAVE.equals(downloadTypeGroup.getValue())) { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_YES); String encodedUrl = url.toString(); // create a hidden iframe to avoid popups ??? HTMLPanel hiddenFrame = new HTMLPanel("<iframe src='" + encodedUrl + "'+style='position:absolute;width:0;height:0;border:0'>"); hiddenFrame.setVisible(false); addChild(hiddenFrame); } else { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_NO); String encodedUrl = url.toString(); com.google.gwt.user.client.Window.open(encodedUrl, "_blank", null); } } });
/** * {@see org.geomajas.plugin.deskmanager.command.manager.GetClientLayersCommand}. * * @param onFinish callback called when system layers are retrieved. */ public static void getLayers(final DataCallback<GetClientLayersResponse> onFinish) { GetClientLayersRequest request = new GetClientLayersRequest(); GwtCommand command = new GwtCommand(GetClientLayersRequest.COMMAND); command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetClientLayersResponse>() { public void execute(GetClientLayersResponse response) { if (onFinish != null) { onFinish.execute(response); } } }); }
/** * Load the manager application. This will execute the InitializationCommand, and ask to select a valid user if * needed. * * @param tokenRequestHandler * the login handler. */ public void loadManagerApplication(final DeskmanagerTokenRequestHandler tokenRequestHandler) { GwtCommandDispatcher.getInstance().setTokenRequestHandler(tokenRequestHandler); //We execute the getgeodeskscommand because that is only accessible by the manager, we ignore the response. GwtCommand command = new GwtCommand(GetGeodesksRequest.COMMAND); final AbstractCommandCallback<GetGeodesksResponse> callback = new AbstractCommandCallback<GetGeodesksResponse>() { public void execute(GetGeodesksResponse response) { fireGeodeskInitialized(tokenRequestHandler.getProfile()); } }; GwtCommandDispatcher.getInstance().execute(command, callback); }
public void execute(PrintGetTemplateResponse response) { stopProgress(); UrlBuilder url = new UrlBuilder(Geomajas.getDispatcherUrl()); url.addPath(DISPATCHING_SERVICE); url.addParameter(URL_DOCUMENT_ID, response.getDocumentId()); url.addParameter(URL_NAME, (String) fileNameItem.getValue()); url.addParameter(URL_TOKEN, command.getUserToken()); if (SAVE.equals(downloadTypeGroup.getValue())) { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_YES); String encodedUrl = url.toString(); // create a hidden iframe to avoid popups ??? HTMLPanel hiddenFrame = new HTMLPanel("<iframe src='" + encodedUrl + "'+style='position:absolute;width:0;height:0;border:0'>"); hiddenFrame.setVisible(false); addChild(hiddenFrame); } else { url.addParameter(URL_DOWNLOAD, URL_DOWNLOAD_NO); String encodedUrl = url.toString(); com.google.gwt.user.client.Window.open(encodedUrl, "_blank", null); } } });