public <T> T filterFields(JSONObject object, Set<String> fields, Class<T> clz) throws JSONException { if (!fields.isEmpty()) { // Create a copy with just the specified fields object = new JSONObject(object, fields.toArray(new String[fields .size()])); } return converter.convertToObject(object.toString(), clz); } }
public <T> T filterFields(JSONObject object, Set<String> fields, Class<T> clz) throws JSONException { if (!fields.isEmpty()) { // Create a copy with just the specified fields object = new JSONObject(object, fields.toArray(new String[fields .size()])); } String objectVal = object.toString(); if (authority != null) { objectVal = objectVal.replace("%origin%", authority.getOrigin()); } else { //provide default for junit tests objectVal = objectVal.replace("%origin%", "http://localhost:8080"); } return converter.convertToObject(objectVal, clz); } }
public <T> T filterFields(JSONObject object, Set<String> fields, Class<T> clz) throws JSONException { if (!fields.isEmpty()) { // Create a copy with just the specified fields object = new JSONObject(object, fields.toArray(new String[fields .size()])); } String objectVal = object.toString(); if (authority != null) { objectVal = objectVal.replace("%origin%", authority.getOrigin()); } else { //provide default for junit tests objectVal = objectVal.replace("%origin%", "http://localhost:8080"); } return converter.convertToObject(objectVal, clz); } }
public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try { return converter.convertToObject(getParameter(parameterName), dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try { return converter.convertToObject(getParameter(parameterName), dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getOptionalTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { return null; } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getOptionalTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { return null; } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getOptionalTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { return null; } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "missing data for " + parameterName); } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "missing data for " + parameterName); } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try { String json = getParameter(parameterName); if (json == null) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "missing data for " + parameterName); } return converter.convertToObject(json, dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); throw e; } }
try { clientJson = oauthDB.getJSONObject(clientId).getJSONObject("registration"); OAuth2Client client = converter.convertToObject(clientJson.toString(), OAuth2Client.class); client.setType(clientJson.getString("type").equals("public") ? ClientType.PUBLIC : ClientType.CONFIDENTIAL); clients.add(client); JSONObject authCodes = clientJS.getJSONObject("authorizationCodes"); for (String authCodeId : JSONObject.getNames(authCodes)) { OAuth2Code code = converter.convertToObject(authCodes .getJSONObject(authCodeId).toString(), OAuth2Code.class); code.setValue(authCodeId); JSONObject accessTokens = clientJS.getJSONObject("accessTokens"); for (String accessTokenId : JSONObject.getNames(accessTokens)) { OAuth2Code code = converter.convertToObject(accessTokens.getJSONObject(accessTokenId).toString(), OAuth2Code.class); code.setValue(accessTokenId); code.setClient(client);
try { clientJson = oauthDB.getJSONObject(clientId).getJSONObject("registration"); OAuth2Client client = converter.convertToObject(clientJson.toString(), OAuth2Client.class); client.setType(clientJson.getString("type").equals("public") ? ClientType.PUBLIC : ClientType.CONFIDENTIAL); clients.add(client); JSONObject authCodes = clientJS.getJSONObject("authorizationCodes"); for (String authCodeId : JSONObject.getNames(authCodes)) { OAuth2Code code = converter.convertToObject(authCodes .getJSONObject(authCodeId).toString(), OAuth2Code.class); code.setValue(authCodeId); JSONObject accessTokens = clientJS.getJSONObject("accessTokens"); for (String accessTokenId : JSONObject.getNames(accessTokens)) { OAuth2Code code = converter.convertToObject(accessTokens.getJSONObject(accessTokenId).toString(), OAuth2Code.class); code.setValue(accessTokenId); code.setClient(client);
return Futures.immediateFuture(converter.convertToObject(curPerson.toString(), Person.class));
return Futures.immediateFuture(converter.convertToObject(curPerson.toString(), Person.class));