use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class AbstractFilter method compose.
/**
* Returns composition of two masks. This method does not modify any of the parameters
* and returned mask is new object. Composition is achieved by invoking separate data
* processing. If there was an error during mask composition, then null is returned.
*
* @param mask1 first mask
* @param mask2 second mask
* @return composed masks or null if there was an error during composition fast-fail
* mode
*/
private DataMap compose(String fieldName, DataMap mask1, DataMap mask2) {
// precondition:
assert mask2 != null;
assert mask1 != null;
try {
final DataMap clone = mask1.copy();
new DataComplexProcessor(new MaskComposition(), mask2, clone).run(true);
return clone;
} catch (CloneNotSupportedException e) {
onError(fieldName, "could not clone mask: %1$s, exception: %2$s", mask1, e);
} catch (DataProcessingException e) {
onError(fieldName, "error composing mask %1$s with %2$s, exception: %3$s", mask1, mask2, e);
}
return null;
}
use of com.linkedin.data.transform.DataProcessingException 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);
}
use of com.linkedin.data.transform.DataProcessingException 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.data.transform.DataProcessingException in project rest.li by linkedin.
the class SimpleResourceUnderCollectionResource method update.
/**
* Updates the greeting.
*/
@Override
public UpdateResponse update(PatchRequest<Greeting> patchRequest) {
Long key = this.getContext().getPathKeys().get("subgreetingsId");
if (TONES.containsKey(key)) {
try {
Greeting patched = new Greeting();
PatchApplier.applyPatch(patched, patchRequest);
TONES.put(key, patched.getTone());
return new UpdateResponse(HttpStatus.S_204_NO_CONTENT);
} catch (DataProcessingException e) {
return new UpdateResponse((HttpStatus.S_400_BAD_REQUEST));
}
} else {
return new UpdateResponse(HttpStatus.S_404_NOT_FOUND);
}
}
use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class StringKeysResource method update.
@RestMethod.PartialUpdate
public UpdateResponse update(String key, PatchRequest<Message> patch) {
Message g = _db.get(key);
if (g == null) {
return new UpdateResponse(HttpStatus.S_404_NOT_FOUND);
}
try {
PatchApplier.applyPatch(g, patch);
} catch (DataProcessingException e) {
return new UpdateResponse(HttpStatus.S_400_BAD_REQUEST);
}
_db.put(key, g);
return new UpdateResponse(HttpStatus.S_204_NO_CONTENT);
}
Aggregations