-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing clients to pass an empty list of children to assign #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,15 +212,20 @@ public void instantiateChild(RestObject childRestObj, RestObject fromTemplate, I | |
} | ||
|
||
@Override | ||
public void assign(List<? extends RestObject> childRestObjs) throws RestException { | ||
public void assign(List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException { | ||
RestSession<?> session = RestSession.getCurrentSession(); | ||
if (session != null) { | ||
session.assign(this, childRestObjs); | ||
session.assign(this, childRestObjs, objectType); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
} else { | ||
throw new RestException("Session not available in current thread"); | ||
} | ||
} | ||
|
||
@Override | ||
public void assign(List<? extends RestObject> childRestObjs) throws RestException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
assign(childRestObjs, null); | ||
} | ||
|
||
@Override | ||
public void assign(List<? extends RestObject> childRestObjs, boolean commit) throws RestException { | ||
RestSession<?> session = RestSession.getCurrentSession(); | ||
|
@@ -334,18 +339,29 @@ public void assign(RestSession<?> session, List<? extends RestObject> childRestO | |
|
||
@Override | ||
public void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, boolean commit) throws RestException { | ||
assign(session, childRestObjs, null, commit); | ||
} | ||
|
||
@Override | ||
public void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException { | ||
assign(session, childRestObjs, objectType, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
} | ||
|
||
@Override | ||
public void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType, boolean commit) throws RestException { | ||
// Make sure there are child objects passed in | ||
if (childRestObjs.isEmpty()) { | ||
if (childRestObjs.isEmpty() && objectType == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
throw new RestException("No child objects specified"); | ||
} | ||
|
||
|
||
// Extract IDs from the specified child objects | ||
List<String> ids = new ArrayList<String>(); | ||
for (RestObject restObject : childRestObjs) { | ||
ids.add(restObject.getId()); | ||
} | ||
|
||
Class<?> childRestObjClass = childRestObjs.get(0).getClass(); | ||
Class<?> childRestObjClass = objectType == null ? childRestObjs.get(0).getClass() : objectType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
ResponseEntity<RestObject[]> response = session.sendRequestWithRetry(HttpMethod.PUT, getResourceUrlForChildType(session, childRestObjClass), null, null, | ||
ids, BambouUtils.getArrayClass(this)); | ||
if (response.getStatusCode().series() == HttpStatus.Series.SUCCESSFUL) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,9 +203,14 @@ public void instantiateChild(RestObject restObj, RestObject childRestObj, RestOb | |
|
||
@Override | ||
public void assign(RestObject restObj, List<? extends RestObject> childRestObjs) throws RestException { | ||
restObj.assign(this, childRestObjs); | ||
assign(restObj, childRestObjs, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, this line should read: restObj.assign(this, childRestObjs) or restObj.assign(this, childRestObjs, null); |
||
} | ||
|
||
@Override | ||
public void assign(RestObject restObj, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException { | ||
restObj.assign(this, childRestObjs, objectType); | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
public void assign(RestObject restObj, List<? extends RestObject> childRestObjs, boolean commit) throws RestException { | ||
restObj.assign(this, childRestObjs, commit); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,9 +53,11 @@ public interface RestObjectOperations { | |
void instantiateChild(RestObject childRestObj, RestObject fromTemplate, Integer responseChoice, boolean commit) throws RestException; | ||
|
||
void assign(List<? extends RestObject> childRestObjs) throws RestException; | ||
|
||
void assign(List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
|
||
void assign(List<? extends RestObject> childRestObjs, boolean commit) throws RestException; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra spaces. Fairly minor :-) |
||
void fetch(RestSession<?> session) throws RestException; | ||
|
||
void save(RestSession<?> session) throws RestException; | ||
|
@@ -78,4 +80,8 @@ void instantiateChild(RestSession<?> session, RestObject childRestObj, RestObjec | |
void assign(RestSession<?> session, List<? extends RestObject> childRestObjs) throws RestException; | ||
|
||
void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, boolean commit) throws RestException; | ||
|
||
void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType, boolean commit) throws RestException; | ||
|
||
void assign(RestSession<?> session, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ public interface RestSessionOperations { | |
void assign(RestObject restObj, List<? extends RestObject> childRestObjs) throws RestException; | ||
|
||
void assign(RestObject restObj, List<? extends RestObject> childRestObjs, boolean commit) throws RestException; | ||
|
||
void assign(RestObject restObj, List<? extends RestObject> childRestObjs, Class<? extends RestObject> objectType) throws RestException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
|
||
<T extends RestObject> List<T> get(RestFetcher<T> fetcher) throws RestException; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For API backwards compatibility, the following method signature should still be supported:
public void assign(List<? extends RestObject> childRestObjs) throws RestException