use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class GroupMembershipsResource3 method update.
/**
* @see AssociationResource#update
*/
@Override
public UpdateResponse update(ComplexResourceKey<GroupMembershipKey, GroupMembershipParam> id, PatchRequest<ComplexKeyGroupMembership> patch) {
ComplexKeyGroupMembership membership = fromGroupMembership(_app.getMembershipMgr().get(complexKeyToCompoundKey(id)));
try {
PatchApplier.applyPatch(membership, patch);
} catch (DataProcessingException e) {
return new UpdateResponse(S_400_BAD_REQUEST);
}
// validate(membership);
// we set groupID, memberID based on the URI
membership.setId(id.getKey());
_app.getMembershipMgr().save(toGroupMembership(membership));
return new UpdateResponse(S_204_NO_CONTENT);
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class MixedResource method update.
@Update
public Promise<UpdateResponse> update(Long key, Greeting entity) {
final SettablePromise<UpdateResponse> result = Promises.settable();
Runnable requestHandler = new Runnable() {
public void run() {
result.done(new UpdateResponse(HttpStatus.S_200_OK));
}
};
scheduler.schedule(requestHandler, DELAY, TimeUnit.MILLISECONDS);
return result;
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class StreamingGreetings method respondWithResponseAttachment.
private void respondWithResponseAttachment(final Callback<UpdateResponse> callback) {
if (getContext().responseAttachmentsSupported()) {
// Echo the bytes back from the header
final String headerValue = getContext().getRequestHeaders().get("getHeader");
final GreetingWriter greetingWriter = new GreetingWriter(ByteString.copy(headerValue.getBytes()));
final RestLiResponseAttachments streamingAttachments = new RestLiResponseAttachments.Builder().appendSingleAttachment(greetingWriter).build();
getContext().setResponseAttachments(streamingAttachments);
callback.onSuccess(new UpdateResponse(HttpStatus.S_200_OK));
}
callback.onError(new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "You must be able to receive attachments!"));
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class GroupMembershipsResource2 method batchUpdate.
/**
* @see com.linkedin.restli.server.resources.AssociationResourceTemplate#batchUpdate(com.linkedin.restli.server.BatchUpdateRequest)
*/
@Override
public BatchUpdateResult<CompoundKey, GroupMembership> batchUpdate(BatchUpdateRequest<CompoundKey, GroupMembership> entities) {
Map<CompoundKey, UpdateResponse> results = new HashMap<>();
for (Map.Entry<CompoundKey, GroupMembership> entry : entities.getData().entrySet()) {
CompoundKey id = entry.getKey();
GroupMembership membership = entry.getValue();
membership.setId(URIParamUtils.encodeKeyForBody(id, true, AllProtocolVersions.BASELINE_PROTOCOL_VERSION));
membership.setGroupID(((Integer) id.getPart(GROUP_ID)));
membership.setMemberID(((Integer) id.getPart(MEMBER_ID)));
_app.getMembershipMgr().save(membership);
results.put(id, new UpdateResponse(S_204_NO_CONTENT));
}
return new BatchUpdateResult<>(results);
}
use of com.linkedin.restli.server.UpdateResponse in project rest.li by linkedin.
the class GroupMembershipsResource2 method update.
/**
* @see AssociationResource#update
*/
@Override
public UpdateResponse update(CompoundKey id, PatchRequest<GroupMembership> patch) {
GroupMembership membership = _app.getMembershipMgr().get(id);
try {
PatchApplier.applyPatch(membership, patch);
} catch (DataProcessingException e) {
return new UpdateResponse(S_400_BAD_REQUEST);
}
validate(membership);
// we set groupID, memberID based on the URI
membership.setId(URIParamUtils.encodeKeyForBody(id, true, AllProtocolVersions.BASELINE_PROTOCOL_VERSION));
membership.setGroupID(getContext().getPathKeys().getAsInt(GROUP_ID));
membership.setMemberID(getContext().getPathKeys().getAsInt(MEMBER_ID));
_app.getMembershipMgr().save(membership);
return new UpdateResponse(S_204_NO_CONTENT);
}
Aggregations