Skip to content
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

LPS-123100 Not needed since it will fallback to 0 if the key is not found #2817

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -102,7 +102,8 @@ private List<InfoFieldValue<Object>> _getBlogsEntryInfoFieldValues(

if (themeDisplay != null) {
WebImage smallWebImage = new WebImage(
blogsEntry.getSmallImageURL(themeDisplay));
blogsEntry.getSmallImageURL(themeDisplay),
blogsEntry.getSmallImageFileEntryId());

smallWebImage.setAlt(blogsEntry.getSmallImageAlt());

Expand All @@ -112,7 +113,8 @@ private List<InfoFieldValue<Object>> _getBlogsEntryInfoFieldValues(
smallWebImage));

WebImage coverWebImage = new WebImage(
blogsEntry.getCoverImageURL(themeDisplay));
blogsEntry.getCoverImageURL(themeDisplay),
blogsEntry.getCoverImageFileEntryId());

coverWebImage.setAlt(blogsEntry.getCoverImageAlt());

Expand Down
Expand Up @@ -170,7 +170,8 @@ private List<InfoFieldValue<Object>> _getFileEntryInfoFieldValues(
WebImage fileURLWebImage = new WebImage(
_dlURLHelper.getDownloadURL(
fileEntry, fileEntry.getFileVersion(), null,
StringPool.BLANK));
StringPool.BLANK),
fileEntry.getFileEntryId());

fileURLWebImage.setAlt(fileEntry.getTitle());

Expand Down Expand Up @@ -231,7 +232,8 @@ private List<InfoFieldValue<Object>> _getFileEntryInfoFieldValues(
}

WebImage imagePreviewURLWebImage = new WebImage(
_dlURLHelper.getImagePreviewURL(fileEntry, null));
_dlURLHelper.getImagePreviewURL(fileEntry, null),
fileEntry.getFileEntryId());

imagePreviewURLWebImage.setAlt(fileEntry.getTitle());

Expand Down
Expand Up @@ -173,7 +173,8 @@ private WebImage _getWebImage(JSONObject jsonObject) {
WebImage webImage = new WebImage(
_dlURLHelper.getDownloadURL(
fileEntry, fileEntry.getFileVersion(), null,
StringPool.BLANK));
StringPool.BLANK),
fileEntry.getFileEntryId());

webImage.setAlt(jsonObject.getString("alt"));

Expand Down
Expand Up @@ -267,20 +267,15 @@ else if (_fragmentEntryProcessorHelper.isMappedCollection(
fragmentEntryProcessorContext.getLocale());
}

if (Objects.equals(
fragmentEntryProcessorContext.getMode(),
FragmentEntryLinkConstants.EDIT)) {
JSONObject configJSONObject = JSONUtil.merge(
editableValueJSONObject.getJSONObject("config"),
mappedValueConfigJSONObject);

editableElementParser.replace(
element, value,
editableValueJSONObject.getJSONObject("config"));
}
else {
JSONObject configJSONObject = JSONUtil.merge(
editableValueJSONObject.getJSONObject("config"),
mappedValueConfigJSONObject);
editableElementParser.replace(element, value, configJSONObject);

editableElementParser.replace(element, value, configJSONObject);
if (!Objects.equals(
fragmentEntryProcessorContext.getMode(),
FragmentEntryLinkConstants.EDIT)) {

String mapperType = configJSONObject.getString(
"mapperType", element.attr("type"));
Expand Down
Expand Up @@ -66,6 +66,7 @@ public JSONObject getFieldTemplateConfigJSONObject(
String fieldName, Locale locale, Object fieldValue) {

String alt = StringPool.BLANK;
long fileEntryId = 0;

if (fieldValue == null) {
alt = StringUtil.replace(
Expand All @@ -75,6 +76,7 @@ else if (fieldValue instanceof JSONObject) {
JSONObject fieldValueJSONObject = (JSONObject)fieldValue;

alt = fieldValueJSONObject.getString("alt");
fileEntryId = fieldValueJSONObject.getLong("fileEntryId");
}
else if (fieldValue instanceof WebImage) {
WebImage webImage = (WebImage)fieldValue;
Expand All @@ -88,9 +90,15 @@ else if (fieldValue instanceof WebImage) {

alt = infoLocalizedValue.getValue();
}

fileEntryId = webImage.getFileEntryId();
}

return JSONUtil.put("alt", alt);
return JSONUtil.put(
"alt", alt
).put(
"fileEntryId", fileEntryId
);
}

@Override
Expand Down Expand Up @@ -163,7 +171,7 @@ public void replace(
try {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);

fileEntryId = jsonObject.getLong("fileEntryId", 0);
fileEntryId = jsonObject.getLong("fileEntryId");
value = jsonObject.getString("url");
}
catch (JSONException jsonException) {
Expand All @@ -172,6 +180,9 @@ public void replace(
value = StringPool.BLANK;
}
}
else {
fileEntryId = configJSONObject.getLong("fileEntryId");
}

value = value.trim();

Expand Down
Expand Up @@ -212,6 +212,11 @@ public Object getMappedCollectionValue(

value = contentAccessor.getContent();
}
else if (value instanceof WebImage) {
WebImage webImage = (WebImage)value;

return webImage.toJSONObject();
}

return formatMappedValue(
value, fragmentEntryProcessorContext.getLocale());
Expand Down
Expand Up @@ -32,6 +32,12 @@ public WebImage(String url) {
_url = url;
}

public WebImage(String url, long fileEntryId) {
this(url);

_fileEntryId = fileEntryId;
}

public String getAlt() {
if (_altInfoLocalizedValue != null) {
return _altInfoLocalizedValue.getValue(LocaleUtil.getDefault());
Expand All @@ -46,6 +52,10 @@ public String getAlt() {
return Optional.ofNullable(_altInfoLocalizedValue);
}

public long getFileEntryId() {
return _fileEntryId;
}

public String getUrl() {
return _url;
}
Expand All @@ -72,8 +82,11 @@ public JSONObject toJSONObject(Locale locale) {
JSONObject jsonObject = JSONUtil.put("url", _url);

if (_altInfoLocalizedValue != null) {
jsonObject = jsonObject.put(
"alt", _altInfoLocalizedValue.getValue(locale));
jsonObject.put("alt", _altInfoLocalizedValue.getValue(locale));
}

if (_fileEntryId > 0) {
jsonObject.put("fileEntryId", _fileEntryId);
}

return jsonObject;
Expand All @@ -85,6 +98,7 @@ public String toString() {
}

private InfoLocalizedValue<String> _altInfoLocalizedValue;
private long _fileEntryId;
private final String _url;

}
@@ -1 +1 @@
version 1.2.0
version 1.3.0