use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class StringKeysResource method batchGet.
@RestMethod.BatchGet
public Map<String, Message> batchGet(Set<String> ids) {
Map<String, Message> batch = new HashMap<String, Message>();
Map<String, RestLiServiceException> errors = new HashMap<String, RestLiServiceException>();
for (String id : ids) {
Message g = _db.get(id);
if (g != null) {
batch.put(id, g);
} else {
errors.put(id, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
}
}
return new BatchResult<String, Message>(batch, errors);
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class StringKeysResource method search.
@Finder("search")
public List<Message> search(@PagingContextParam PagingContext ctx, @QueryParam("keyword") @Optional String keyword) {
keyword = keyword.toLowerCase();
List<Message> messages = new ArrayList<Message>();
int idx = 0;
int start = ctx.getStart();
int stop = start + ctx.getCount();
for (Message g : _db.values()) {
if (keyword == null || g.getMessage().toLowerCase().contains(keyword)) {
if (idx++ >= ctx.getStart()) {
messages.add(g);
}
if (idx == stop) {
break;
}
}
}
return messages;
}
use of com.linkedin.restli.examples.greetings.api.Message in project rest.li by linkedin.
the class StringKeysSubResource method addExample.
private void addExample(String parentKey, String subKey, String text) {
Message message = new Message();
message.setId(keyToString(parentKey, subKey));
message.setMessage(text);
message.setTone(Tone.SINCERE);
_db.put(keyToString(parentKey, subKey), message);
}
Aggregations