@Override public void addMetadata(CallingContext context, Map<String, String> values, Boolean overwrite) { if ((values == null) || values.isEmpty()) return; Map<String, String> metadata = context.getMetadata(); if (metadata == null) metadata = new HashMap<String, String>(); for (String key : values.keySet()) { if (!overwrite && metadata.containsKey(key)) { throw RaptureExceptionFactory.create( HttpURLConnection.HTTP_BAD_REQUEST, key + " exists and overwrite was disallowed"); } metadata.put(key, values.get(key)); } context.setMetadata(metadata); getEphemeralRepo() .addToStage( RaptureConstants.OFFICIAL_STAGE, "session/" + context.getContext(), JacksonUtil.jsonFromObject(context), false); }