use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class AnnotatedComplexKeysResource method update.
@RestMethod.PartialUpdate
public Promise<UpdateResponse> update(final ComplexResourceKey<TwoPartKey, TwoPartKey> key, final PatchRequest<Message> patch) {
final SettablePromise<UpdateResponse> result = Promises.settable();
final Runnable requestHandler = new Runnable() {
public void run() {
try {
_dataProvider.partialUpdate(key, patch);
result.done(new UpdateResponse(HttpStatus.S_204_NO_CONTENT));
} catch (DataProcessingException e) {
result.done(new UpdateResponse(HttpStatus.S_400_BAD_REQUEST));
}
}
};
_scheduler.schedule(requestHandler, DELAY, TimeUnit.MILLISECONDS);
return result;
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class AutomaticValidationDemoResource method batchUpdate.
@RestMethod.BatchUpdate
public BatchUpdateResult<Integer, ValidationDemo> batchUpdate(final BatchUpdateRequest<Integer, ValidationDemo> entities) {
Map<Integer, UpdateResponse> results = new HashMap<>();
Map<Integer, RestLiServiceException> errors = new HashMap<>();
for (Map.Entry<Integer, ValidationDemo> entry : entities.getData().entrySet()) {
Integer key = entry.getKey();
ValidationDemo entity = entry.getValue();
results.put(key, new UpdateResponse(HttpStatus.S_204_NO_CONTENT));
}
return new BatchUpdateResult<>(results, errors);
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class ChainedTyperefResource method batchUpdate.
@Override
public BatchUpdateResult<CompoundKey, Greeting> batchUpdate(BatchUpdateRequest<CompoundKey, Greeting> entities) {
Set<CompoundKey> keys = entities.getData().keySet();
Map<CompoundKey, UpdateResponse> responseMap = new HashMap<>();
Map<CompoundKey, RestLiServiceException> errorMap = new HashMap<>();
for (CompoundKey key : keys) {
responseMap.put(key, new UpdateResponse(HttpStatus.S_201_CREATED));
}
return new BatchUpdateResult<>(responseMap);
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class ComplexKeysDataProvider method batchUpdate.
public BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> batchUpdate(BatchUpdateRequest<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entities) {
final Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, UpdateResponse> results = new HashMap<>();
final Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, RestLiServiceException> errors = new HashMap<>();
for (Map.Entry<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entry : entities.getData().entrySet()) {
if (_db.containsKey(keyToString(entry.getKey().getKey()))) {
_db.put(keyToString(entry.getKey().getKey()), entry.getValue());
results.put(entry.getKey(), new UpdateResponse(HttpStatus.S_200_OK));
} else {
errors.put(entry.getKey(), new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
}
}
return new BatchUpdateResult<>(results, errors);
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class AlbumResource method update.
// update an existing photo with given entity
@Override
public UpdateResponse update(Long key, Album entity) {
final Album currPhoto = _db.getData().get(key);
if (currPhoto == null) {
return new UpdateResponse(HttpStatus.S_404_NOT_FOUND);
}
// disallow changing entity ID and URN
if (entity.hasId() || entity.hasUrn()) {
throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "Album ID is not acceptable in request");
}
// make sure the ID in the entity is consistent with the key in the database
entity.setId(key);
entity.setUrn(String.valueOf(key));
_db.getData().put(key, entity);
return new UpdateResponse(HttpStatus.S_204_NO_CONTENT);
}
Aggregations