-
Notifications
You must be signed in to change notification settings - Fork 470
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
Issue rest multiple binaries #13472
Issue rest multiple binaries #13472
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 |
---|---|---|
|
@@ -320,6 +320,7 @@ public Response unlockContent(@Context HttpServletRequest request, | |
throws DotDataException, DotSecurityException, JSONException { | ||
|
||
InitDataObject initData = webResource.init(params, true, request, false, null); | ||
|
||
Map<String, String> paramsMap = initData.getParamsMap(); | ||
String callback = paramsMap.get(RESTParams.CALLBACK.getValue()); | ||
String language = paramsMap.get(RESTParams.LANGUAGE.getValue()); | ||
|
@@ -705,6 +706,9 @@ private Response multipartPUTandPOST(HttpServletRequest request, HttpServletResp | |
|
||
Map<String, Object> map = new HashMap<String, Object>(); | ||
List<String> usedBinaryFields = new ArrayList<String>(); | ||
String binaryFieldsInput = null; | ||
List<String> binaryFields = new ArrayList<>(); | ||
|
||
for (BodyPart part : multipart.getBodyParts()) { | ||
ContentDisposition cd = part.getContentDisposition(); | ||
String name = cd != null && cd.getParameters().containsKey("name") ? cd.getParameters() | ||
|
@@ -714,6 +718,21 @@ private Response multipartPUTandPOST(HttpServletRequest request, HttpServletResp | |
.equals("json")) { | ||
try { | ||
processJSON(contentlet, part.getEntityAs(InputStream.class)); | ||
try { | ||
binaryFieldsInput = | ||
webResource.processJSON(part.getEntityAs(InputStream.class)).get("binary_fields") | ||
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. |
||
.toString(); | ||
} catch (NullPointerException npe) { | ||
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. |
||
} | ||
if (UtilMethods.isSet(binaryFieldsInput)) { | ||
if (!binaryFieldsInput.contains(",")) { | ||
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. |
||
binaryFields.add(binaryFieldsInput); | ||
} else { | ||
for (String binaryFieldSplit : binaryFieldsInput.split(",")) { | ||
binaryFields.add(binaryFieldSplit.trim()); | ||
} | ||
} | ||
} | ||
} catch (JSONException e) { | ||
|
||
Logger.error(this.getClass(), "Error processing JSON for Stream", e); | ||
|
@@ -794,7 +813,11 @@ private Response multipartPUTandPOST(HttpServletRequest request, HttpServletResp | |
String fieldName = ff.getFieldContentlet(); | ||
if (fieldName.startsWith("binary") | ||
&& !usedBinaryFields.contains(fieldName)) { | ||
contentlet.setBinary(ff.getVelocityVarName(), tmp); | ||
String fieldVarName = ff.getVelocityVarName(); | ||
if (binaryFields.size() > 0) { | ||
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. |
||
fieldVarName = binaryFields.remove(0); | ||
} | ||
contentlet.setBinary(fieldVarName, tmp); | ||
usedBinaryFields.add(fieldName); | ||
break; | ||
} | ||
|
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.