/** {@inheritDoc} */ public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException { try { JSONArray people = db.getJSONArray(PEOPLE_TABLE); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) { Person personObj = filterFields(person, fields, Person.class); Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID .toString()), fields); personObj.setAppData(appData); return ImmediateFuture.newInstance(personObj); } } throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found"); } catch (JSONException je) { throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je); } }
/** {@inheritDoc} */ public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException { if (id != null && AnonymousSecurityToken.ANONYMOUS_ID.equals(id.getUserId())) { Person anonymous = new PersonImpl(); anonymous.setId(AnonymousSecurityToken.ANONYMOUS_ID); anonymous.setName(new NameImpl(ANONYMOUS_NAME)); anonymous.setNickname(ANONYMOUS_NAME); return Futures.immediateFuture(anonymous); } try { JSONArray people = db.getJSONArray(PEOPLE_TABLE); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) { Person personObj = filterFields(person, fields, Person.class); Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID .toString()), fields); personObj.setAppData(appData); return Futures.immediateFuture(personObj); } } throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found"); } catch (JSONException je) { throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je); } }
/** {@inheritDoc} */ public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException { if (id != null && AnonymousSecurityToken.ANONYMOUS_ID.equals(id.getUserId())) { Person anonymous = new PersonImpl(); anonymous.setId(AnonymousSecurityToken.ANONYMOUS_ID); anonymous.setName(new NameImpl(ANONYMOUS_NAME)); anonymous.setNickname(ANONYMOUS_NAME); return Futures.immediateFuture(anonymous); } try { JSONArray people = db.getJSONArray(PEOPLE_TABLE); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) { Person personObj = filterFields(person, fields, Person.class); Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID .toString()), fields); personObj.setAppData(appData); return Futures.immediateFuture(personObj); } } throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found"); } catch (JSONException je) { throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je); } }
Map<String, Object> appData = getPersonAppData( person.getString(Person.Field.ID.toString()), fields); personObj.setAppData(appData);
Map<String, Object> appData = getPersonAppData( person.getString(Person.Field.ID.toString()), fields); personObj.setAppData(appData);
Map<String, Object> appData = getPersonAppData( person.getString(Person.Field.ID.toString()), fields); personObj.setAppData(appData);