protected String retrieveSessionId(HttpParameters parameters) { final String sessionId = parameters.get("sessionId"); if (null == sessionId) { throw new CommandParsingException("ERROR: No sessionId provided. Most likely your original newBrowserSession command failed."); } return sessionId; } }
protected Response forward(HttpParameters parameters, DynamicRemoteControlPool pool, EnvironmentManager environmentManager) throws IOException { final SeleneseCommand command; final Response response; LOGGER.info("Processing '" + parameters.toString() + "'"); try { command = new HttpCommandParser(parameters).parse(environmentManager); response = command.execute(pool); } catch (CommandParsingException e) { LOGGER.error("Failed to parse '" + parameters.toString() + "' : " + e.getMessage()); return new Response(e.getMessage()); } catch (NoSuchEnvironmentException e) { LOGGER.error("Could not find any remote control providing the '" + e.environment() + "' environment. Please make sure you started some remote controls which registered as offering this environment."); return new Response(e.getMessage()); } LOGGER.info("Responding with " + response.statusCode() + "/ '" + response.body() + "'"); return response; }
protected Response forward(HttpParameters parameters, DynamicRemoteControlPool pool, EnvironmentManager environmentManager) throws IOException { final SeleneseCommand command; final Response response; LOGGER.info("Processing '" + parameters.toString() + "'"); try { command = new HttpCommandParser(parameters).parse(environmentManager); response = command.execute(pool); } catch (CommandParsingException e) { LOGGER.error("Failed to parse '" + parameters.toString() + "' : " + e.getMessage()); return new Response(e.getMessage()); } catch (NoSuchEnvironmentException e) { LOGGER.error("Could not find any remote control providing the '" + e.environment() + "' environment. Please make sure you started some remote controls which registered as offering this environment."); return new Response(e.getMessage()); } catch (NoSuchSessionException e) { LOGGER.error(e.getMessage()); return new Response(e.getMessage()); } final String responseBody = response.body(); if (responseBody.length() > 128) { final int truncated = responseBody.length() - 128; LOGGER.info(String.format("Responding with %d / %s...[%d characters truncated]", response.statusCode(), responseBody.substring(0, 128), truncated)); } else { LOGGER.info(String.format("Responding with %d / %s", response.statusCode(), responseBody)); } return response; }
protected String retrieveSessionId(HttpParameters parameters) { final String sessionId = parameters.get("sessionId"); if (null == sessionId) { throw new CommandParsingException("ERROR: No sessionId provided. Most likely your original newBrowserSession command failed."); } return sessionId; } }
public SeleneseCommand parse(EnvironmentManager environmentManager) { final String command = parameters.get("cmd"); if (command.equals(NEW_BROWSER_SESSION)) { final Environment environment; final String environmentName; environmentName = parameters.get("1"); environment = environmentManager.environment(environmentName); if (null == environment) { throw new CommandParsingException("ERROR: Unknown environment '" + environmentName + "'"); } parameters.put("1", environment.browser()); return new NewBrowserSessionCommand(environment, parameters); } else if (command.equals(TEST_COMPLETE)) { return new TestCompleteCommand(retrieveSessionId(parameters), parameters); } else { return new SeleneseCommand(retrieveSessionId(parameters), parameters); } }
public SeleneseCommand parse(EnvironmentManager environmentManager) { final String command = parameters.get("cmd"); if (command.equals(NEW_BROWSER_SESSION)) { final Environment environment; final String environmentName; environmentName = parameters.get("1"); environment = environmentManager.environment(environmentName); if (null == environment) { throw new CommandParsingException("ERROR: Unknown environment '" + environmentName + "'"); } parameters.put("1", environment.browser()); return new NewBrowserSessionCommand(environment, parameters); } else if (command.equals(TEST_COMPLETE)) { return new TestCompleteCommand(retrieveSessionId(parameters), parameters); } else { return new SeleneseCommand(retrieveSessionId(parameters), parameters); } }