public static void updatePlotColumns(List<String> plotCols, Session session) { try { makeSureSessionExistsInDB(session.getUser().getUserId()); Statement statement = conn.createStatement(); statement.executeUpdate("update sessions set vis='" + StringEscapeUtils.escapeJava(Joiner.on(',').join(plotCols)) + "'where id='" + cleanId(session.getUser().getUserId()) + "';"); } catch (SQLException e) { log.error(e.getMessage()); } }
public static void updateResultData(JSONObject data, Session session) { try { makeSureSessionExistsInDB(session.getUser().getUserId()); Statement statement = conn.createStatement(); statement.executeUpdate("update sessions set result='" + StringEscapeUtils.escapeJava(data.toString()) + "'where id='" + cleanId(session.getUser().getUserId()) + "';"); } catch (SQLException e) { log.error(e.getMessage()); } }
public static void updateDisplayText(String message, Session session) { try { makeSureSessionExistsInDB(session.getUser().getUserId()); Statement statement = conn.createStatement(); statement.executeUpdate("update sessions set display='" + StringEscapeUtils.escapeJava(message) + "' where id='" + cleanId(session.getUser().getUserId()) + "';"); } catch (SQLException e) { log.error(e.getMessage()); } }
private SpeechletResponse handleRequest(SpeechletRequest request, Session session) { try { if (! config.allowUser(session.getUser().getUserId())) { throw new SecurityException("User not in whitelist: " + session.getUser().getUserId()); } final ProxyResponse proxyResponse = postRequest(request, session); final SpeechletResponse response = buildResponse(proxyResponse.getSpeech()); response.setShouldEndSession(proxyResponse.isShouldEndSession()); return response; } catch (IOException e) { LOG.error("Error processing request", e); return buildResponse("Error communicating with remote proxy server"); } }
session.getUser().getUserId()).getJSONArray("sessions.result") .getString(0)); for (ColumnName axis : axes) {
/** * Saves the {@link ScoreKeeperGame} into the database. * * @param game */ public void saveScoreKeeperGame(ScoreKeeperGame game) { ScoreKeeperUserDataItem item = new ScoreKeeperUserDataItem(); item.setCustomerId(game.getSession().getUser().getUserId()); item.setGameData(game.getGameData()); dynamoDbClient.saveItem(item); } }
/** * Reads and returns the {@link ScoreKeeperGame} using user information from the session. * <p> * Returns null if the item could not be found in the database. * * @param session * @return */ public ScoreKeeperGame getScoreKeeperGame(Session session) { ScoreKeeperUserDataItem item = new ScoreKeeperUserDataItem(); item.setCustomerId(session.getUser().getUserId()); item = dynamoDbClient.loadItem(item); if (item == null) { return null; } return ScoreKeeperGame.newInstance(session, item.getGameData()); }
/** * Saves the {@link ScoreKeeperGame} into the database. * * @param game */ public void saveScoreKeeperGame(ScoreKeeperGame game) { ScoreKeeperUserDataItem item = new ScoreKeeperUserDataItem(); item.setCustomerId(game.getSession().getUser().getUserId()); item.setGameData(game.getGameData()); dynamoDbClient.saveItem(item); } }
/** * Reads and returns the {@link ScoreKeeperGame} using user information from the session. * <p> * Returns null if the item could not be found in the database. * * @param session * @return */ public ScoreKeeperGame getScoreKeeperGame(Session session) { ScoreKeeperUserDataItem item = new ScoreKeeperUserDataItem(); item.setCustomerId(session.getUser().getUserId()); item = dynamoDbClient.loadItem(item); if (item == null) { return null; } return ScoreKeeperGame.newInstance(session, item.getGameData()); }
@Override public SpeechletRequestEnvelope envelope(final AlexaRequest request) { final SystemState systemState = SystemState.builder() .withUser(session.getUser()) .withDevice(client.device) .withApiEndpoint(client.apiEndpoint) .withApplication(session.getApplication()).build(); final Context context = Context.builder().addState(systemState).build(); // ensure session is ready for another request (make an exception for session ended and launch requests) Validate.isTrue(!sessionClosed || AlexaSessionEndedRequest.class.isInstance(request) || AlexaLaunchRequest.class.isInstance(request), "Session already closed and not ready for another request."); return SpeechletRequestEnvelope.builder() .withRequest(request.getSpeechletRequest()) .withSession(request instanceof AlexaSessionStartedRequest ? getSessionWithIsNew() : session) .withVersion(AlexaClient.VERSION) .withContext(context) .build(); }
private Session getSessionWithIsNew() { return Session.builder() .withApplication(session.getApplication()) .withUser(session.getUser()) .withIsNew(true) .withSessionId(session.getSessionId()) .withAttributes(session.getAttributes()) .build(); }
Permissions permissions = session.getUser().getPermissions(); if (permissions == null) { log.info("The user hasn't authorized the skill. Sending a permissions card.");