diff --git a/modules/apps/asset/asset-list-service/src/main/java/com/liferay/asset/list/internal/asset/entry/provider/AssetListAssetEntryProviderImpl.java b/modules/apps/asset/asset-list-service/src/main/java/com/liferay/asset/list/internal/asset/entry/provider/AssetListAssetEntryProviderImpl.java
index c368b12d100093..616979eb5aa1e4 100644
--- a/modules/apps/asset/asset-list-service/src/main/java/com/liferay/asset/list/internal/asset/entry/provider/AssetListAssetEntryProviderImpl.java
+++ b/modules/apps/asset/asset-list-service/src/main/java/com/liferay/asset/list/internal/asset/entry/provider/AssetListAssetEntryProviderImpl.java
@@ -205,9 +205,10 @@ protected AssetEntryQuery getAssetEntryQuery(
properties.fastLoad(assetListEntry.getTypeSettings(segmentsEntryId));
- _setCategoriesAndTags(
+ _setCategoriesAndKeywordsAndTags(
assetListEntry, assetEntryQuery, properties,
- _getAssetCategoryIds(properties), _getAssetTagNames(properties));
+ _getAssetCategoryIds(properties), _getKeywords(properties),
+ _getAssetTagNames(properties));
long[] groupIds = GetterUtil.getLongValues(
StringUtil.split(
@@ -369,6 +370,35 @@ private static String[] _getAssetTagNames(UnicodeProperties properties) {
return allAssetTagNames;
}
+ private static String[] _getKeywords(UnicodeProperties properties) {
+ String[] allKeywords = new String[0];
+
+ for (int i = 0; true; i++) {
+ String[] queryValues = StringUtil.split(
+ properties.getProperty("queryValues" + i, null));
+
+ if (ArrayUtil.isEmpty(queryValues)) {
+ break;
+ }
+
+ boolean queryContains = GetterUtil.getBoolean(
+ properties.getProperty("queryContains" + i, StringPool.BLANK));
+ boolean queryAndOperator = GetterUtil.getBoolean(
+ properties.getProperty(
+ "queryAndOperator" + i, StringPool.BLANK));
+ String queryName = properties.getProperty(
+ "queryName" + i, StringPool.BLANK);
+
+ if (!Objects.equals(queryName, "keywords") && queryContains &&
+ (queryAndOperator || (queryValues.length == 1))) {
+
+ allKeywords = queryValues;
+ }
+ }
+
+ return allKeywords;
+ }
+
private long[] _filterAssetCategoryIds(long[] assetCategoryIds) {
List assetCategoryIdsList = new ArrayList<>();
@@ -593,16 +623,21 @@ private List _search(
return Collections.emptyList();
}
- private void _setCategoriesAndTags(
+ private void _setCategoriesAndKeywordsAndTags(
AssetListEntry assetListEntry, AssetEntryQuery assetEntryQuery,
UnicodeProperties properties, long[] overrideAllAssetCategoryIds,
- String[] overrideAllAssetTagNames) {
+ String[] overrideAllKeywords, String[] overrideAllAssetTagNames) {
long[] allAssetCategoryIds = new long[0];
long[] anyAssetCategoryIds = new long[0];
long[] notAllAssetCategoryIds = new long[0];
long[] notAnyAssetCategoryIds = new long[0];
+ String[] allKeywords = new String[0];
+ String[] anyKeywords = new String[0];
+ String[] notAllKeywords = new String[0];
+ String[] notAnyKeywords = new String[0];
+
String[] allAssetTagNames = new String[0];
String[] anyAssetTagNames = new String[0];
String[] notAllAssetTagNames = new String[0];
@@ -640,6 +675,20 @@ else if (!queryContains && queryAndOperator) {
notAnyAssetCategoryIds = assetCategoryIds;
}
}
+ else if (Objects.equals(queryName, "keywords")) {
+ if (queryContains && queryAndOperator) {
+ allKeywords = queryValues;
+ }
+ else if (queryContains && !queryAndOperator) {
+ anyKeywords = queryValues;
+ }
+ else if (!queryContains && queryAndOperator) {
+ notAllKeywords = queryValues;
+ }
+ else {
+ notAnyKeywords = queryValues;
+ }
+ }
else {
if (queryContains && queryAndOperator) {
allAssetTagNames = queryValues;
@@ -664,6 +713,12 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setAllCategoryIds(allAssetCategoryIds);
+ if (overrideAllKeywords != null) {
+ allKeywords = overrideAllKeywords;
+ }
+
+ assetEntryQuery.setAllKeywords(allKeywords);
+
if (overrideAllAssetTagNames != null) {
allAssetTagNames = overrideAllAssetTagNames;
}
@@ -679,6 +734,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setAnyCategoryIds(anyAssetCategoryIds);
+ assetEntryQuery.setAnyKeywords(anyKeywords);
+
long[] anyAssetTagIds = _assetTagLocalService.getTagIds(
siteGroupId, anyAssetTagNames);
@@ -686,6 +743,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setNotAllCategoryIds(notAllAssetCategoryIds);
+ assetEntryQuery.setNotAllKeywords(notAllKeywords);
+
for (String assetTagName : notAllAssetTagNames) {
long[] notAllAssetTagIds = _assetTagLocalService.getTagIds(
new long[] {siteGroupId}, assetTagName);
@@ -695,6 +754,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setNotAnyCategoryIds(notAnyAssetCategoryIds);
+ assetEntryQuery.setNotAnyKeywords(notAnyKeywords);
+
long[] notAnyAssetTagIds = _assetTagLocalService.getTagIds(
siteGroupId, notAnyAssetTagNames);
diff --git a/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/display/context/EditAssetListDisplayContext.java b/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/display/context/EditAssetListDisplayContext.java
index 9e40f461ec9061..c5c8421fd8453a 100644
--- a/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/display/context/EditAssetListDisplayContext.java
+++ b/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/display/context/EditAssetListDisplayContext.java
@@ -276,6 +276,30 @@ public JSONArray getAutoFieldRulesJSONArray() {
ruleJSONObject.put("selectedItems", selectedItems);
}
+ else if (Objects.equals(queryName, "keywords")) {
+ queryValues = ParamUtil.getString(
+ _httpServletRequest, "keywords" + queryLogicIndex,
+ queryValues);
+
+ String[] keywords = StringUtil.split(queryValues, " ");
+
+ if (ArrayUtil.isEmpty(keywords)) {
+ continue;
+ }
+
+ List> selectedItems = new ArrayList<>();
+
+ for (String keyword : keywords) {
+ HashMap selectedCategory = new HashMap<>();
+
+ selectedCategory.put("label", keyword);
+ selectedCategory.put("value", keyword);
+
+ selectedItems.add(selectedCategory);
+ }
+
+ ruleJSONObject.put("selectedItems", selectedItems);
+ }
else {
queryValues = ParamUtil.getString(
_httpServletRequest, "queryCategoryIds" + queryLogicIndex,
diff --git a/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/portlet/action/UpdateAssetListEntryDynamicMVCActionCommand.java b/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/portlet/action/UpdateAssetListEntryDynamicMVCActionCommand.java
index 44bbb65fd5e1d0..1dbc274ae89515 100644
--- a/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/portlet/action/UpdateAssetListEntryDynamicMVCActionCommand.java
+++ b/modules/apps/asset/asset-list-web/src/main/java/com/liferay/asset/list/web/internal/portlet/action/UpdateAssetListEntryDynamicMVCActionCommand.java
@@ -116,6 +116,10 @@ protected AssetQueryRule getQueryRule(
values = ParamUtil.getStringValues(
actionRequest, "queryTagNames" + index);
}
+ else if (name.equals("keywords")) {
+ values = ParamUtil.getStringValues(
+ actionRequest, "keywords" + index);
+ }
else {
values = ParamUtil.getStringValues(
actionRequest, "queryCategoryIds" + index);
diff --git a/modules/apps/asset/asset-list-web/src/main/resources/META-INF/resources/js/AutoField.soy b/modules/apps/asset/asset-list-web/src/main/resources/META-INF/resources/js/AutoField.soy
index 14f8f0fb7c3273..a9293ecbfb2bb9 100644
--- a/modules/apps/asset/asset-list-web/src/main/resources/META-INF/resources/js/AutoField.soy
+++ b/modules/apps/asset/asset-list-web/src/main/resources/META-INF/resources/js/AutoField.soy
@@ -137,6 +137,7 @@
>
+
@@ -152,6 +153,19 @@
{param selectedItems: $rule.selectedItems ?: [] /}
{param vocabularyIds: $vocabularyIds /}
{/call}
+ {elseif $rule.type == 'keywords'}
+
+
+
+
+
{else}
{call com.liferay.asset.taglib.AssetTagsSelector.render}
{param eventName: $namespace + 'selectTag' /}
diff --git a/modules/apps/asset/asset-publisher-api/src/main/java/com/liferay/asset/publisher/util/AssetPublisherHelper.java b/modules/apps/asset/asset-publisher-api/src/main/java/com/liferay/asset/publisher/util/AssetPublisherHelper.java
index 7b9854e656dda1..86018a2f1fe081 100644
--- a/modules/apps/asset/asset-publisher-api/src/main/java/com/liferay/asset/publisher/util/AssetPublisherHelper.java
+++ b/modules/apps/asset/asset-publisher-api/src/main/java/com/liferay/asset/publisher/util/AssetPublisherHelper.java
@@ -98,6 +98,12 @@ public AssetEntryQuery getAssetEntryQuery(
String[] overrideAllAssetTagNames)
throws PortalException;
+ public AssetEntryQuery getAssetEntryQuery(
+ PortletPreferences portletPreferences, long groupId, Layout layout,
+ long[] overrideAllAssetCategoryIds, String[] overrideAllKeywords,
+ String[] overrideAllAssetTagNames)
+ throws PortalException;
+
public List getAssetEntryResults(
SearchContainer searchContainer, AssetEntryQuery assetEntryQuery,
Layout layout, PortletPreferences portletPreferences,
@@ -134,6 +140,8 @@ public long[] getGroupIds(
PortletPreferences portletPreferences, long scopeGroupId,
Layout layout);
+ public String[] getKeywords(PortletPreferences portletPreferences);
+
public String getScopeId(Group group, long scopeGroupId);
}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/display/context/AssetPublisherDisplayContext.java b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/display/context/AssetPublisherDisplayContext.java
index 386ea4424d1de9..439c30e8ca1e3b 100644
--- a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/display/context/AssetPublisherDisplayContext.java
+++ b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/display/context/AssetPublisherDisplayContext.java
@@ -246,6 +246,33 @@ public String[] getAllAssetTagNames() {
return _allAssetTagNames;
}
+ public String[] getAllKeywords() {
+ if (_allKeywords != null) {
+ return _allKeywords;
+ }
+
+ _allKeywords = new String[0];
+
+ String keyword = ParamUtil.getString(_httpServletRequest, "keyword");
+
+ String selectionStyle = getSelectionStyle();
+
+ if (selectionStyle.equals("dynamic")) {
+ _allKeywords = _assetPublisherHelper.getKeywords(
+ _portletPreferences);
+ }
+
+ if (Validator.isNotNull(keyword) &&
+ !ArrayUtil.contains(_allKeywords, keyword)) {
+
+ _allKeywords = ArrayUtil.append(_allKeywords, keyword);
+ }
+
+ _allKeywords = ArrayUtil.distinct(_allKeywords, new StringComparator());
+
+ return _allKeywords;
+ }
+
public long getAssetCategoryId() {
if (_assetCategoryId != null) {
return _assetCategoryId;
@@ -335,7 +362,7 @@ assetListEntry, _getSegmentsEntryIds(),
_assetEntryQuery = _assetPublisherHelper.getAssetEntryQuery(
_portletPreferences, _themeDisplay.getScopeGroupId(),
_themeDisplay.getLayout(), getAllAssetCategoryIds(),
- getAllAssetTagNames());
+ getAllKeywords(), getAllAssetTagNames());
}
_assetEntryQuery.setEnablePermissions(isEnablePermissions());
@@ -547,6 +574,30 @@ public JSONArray getAutoFieldRulesJSONArray() {
ruleJSONObject.put("selectedItems", selectedItems);
}
+ else if (Objects.equals(queryName, "keywords")) {
+ queryValues = ParamUtil.getString(
+ _httpServletRequest, "keywords" + queryLogicIndex,
+ queryValues);
+
+ String[] keywords = StringUtil.split(queryValues, " ");
+
+ if (ArrayUtil.isEmpty(keywords)) {
+ continue;
+ }
+
+ List> selectedItems = new ArrayList<>();
+
+ for (String keyword : keywords) {
+ HashMap selectedCategory = new HashMap<>();
+
+ selectedCategory.put("label", keyword);
+ selectedCategory.put("value", keyword);
+
+ selectedItems.add(selectedCategory);
+ }
+
+ ruleJSONObject.put("selectedItems", selectedItems);
+ }
else {
queryValues = ParamUtil.getString(
_httpServletRequest, "queryCategoryIds" + queryLogicIndex,
@@ -1891,6 +1942,7 @@ private long[] _getSegmentsEntryIds() {
private Integer _abstractLength;
private long[] _allAssetCategoryIds;
private String[] _allAssetTagNames;
+ private String[] _allKeywords;
private Boolean _anyAssetType;
private Long _assetCategoryId;
private final AssetEntryActionRegistry _assetEntryActionRegistry;
diff --git a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/portlet/action/AssetPublisherConfigurationAction.java b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/portlet/action/AssetPublisherConfigurationAction.java
index b134c19d462031..ce18c2ddb90bc9 100644
--- a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/portlet/action/AssetPublisherConfigurationAction.java
+++ b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/portlet/action/AssetPublisherConfigurationAction.java
@@ -463,6 +463,10 @@ protected AssetQueryRule getQueryRule(
values = ParamUtil.getStringValues(
actionRequest, "queryTagNames" + index);
}
+ else if (name.equals("keywords")) {
+ values = ParamUtil.getStringValues(
+ actionRequest, "keywords" + index);
+ }
else {
values = ParamUtil.getStringValues(
actionRequest, "queryCategoryIds" + index);
diff --git a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/util/AssetPublisherHelperImpl.java b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/util/AssetPublisherHelperImpl.java
index c0954a2a6d6c2e..a90dbc277eb178 100644
--- a/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/util/AssetPublisherHelperImpl.java
+++ b/modules/apps/asset/asset-publisher-web/src/main/java/com/liferay/asset/publisher/web/internal/util/AssetPublisherHelperImpl.java
@@ -366,13 +366,26 @@ public AssetEntryQuery getAssetEntryQuery(
String[] overrideAllAssetTagNames)
throws PortalException {
+ return getAssetEntryQuery(
+ portletPreferences, groupId, layout, overrideAllAssetCategoryIds,
+ null, overrideAllAssetTagNames);
+ }
+
+ @Override
+ public AssetEntryQuery getAssetEntryQuery(
+ PortletPreferences portletPreferences, long groupId, Layout layout,
+ long[] overrideAllAssetCategoryIds, String[] overrideAllKeywords,
+ String[] overrideAllAssetTagNames)
+ throws PortalException {
+
long[] groupIds = getGroupIds(portletPreferences, groupId, layout);
AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
- _setCategoriesAndTags(
+ _setCategoriesAndKeywordsAndTags(
assetEntryQuery, portletPreferences, groupIds,
- overrideAllAssetCategoryIds, overrideAllAssetTagNames);
+ overrideAllAssetCategoryIds, overrideAllKeywords,
+ overrideAllAssetTagNames);
assetEntryQuery.setGroupIds(groupIds);
@@ -491,8 +504,7 @@ public String[] getAssetTagNames(PortletPreferences portletPreferences) {
String queryName = portletPreferences.getValue(
"queryName" + i, StringPool.BLANK);
- if (!Objects.equals(queryName, "assetCategories") &&
- queryContains &&
+ if (Objects.equals(queryName, "assetTags") && queryContains &&
(queryAndOperator || (queryValues.length == 1))) {
allAssetTagNames = queryValues;
@@ -731,6 +743,37 @@ public long[] getGroupIds(
return ArrayUtil.toLongArray(groupIds);
}
+ @Override
+ public String[] getKeywords(PortletPreferences portletPreferences) {
+ String[] allKeywords = new String[0];
+
+ for (int i = 0; true; i++) {
+ String[] queryValues = portletPreferences.getValues(
+ "queryValues" + i, null);
+
+ if (ArrayUtil.isEmpty(queryValues)) {
+ break;
+ }
+
+ boolean queryContains = GetterUtil.getBoolean(
+ portletPreferences.getValue(
+ "queryContains" + i, StringPool.BLANK));
+ boolean queryAndOperator = GetterUtil.getBoolean(
+ portletPreferences.getValue(
+ "queryAndOperator" + i, StringPool.BLANK));
+ String queryName = portletPreferences.getValue(
+ "queryName" + i, StringPool.BLANK);
+
+ if (Objects.equals(queryName, "keywords") && queryContains &&
+ (queryAndOperator || (queryValues.length == 1))) {
+
+ allKeywords = queryValues;
+ }
+ }
+
+ return allKeywords;
+ }
+
@Override
public String getScopeId(Group group, long scopeGroupId) {
String key = null;
@@ -1092,16 +1135,21 @@ private void _removeAndStoreSelection(
portletPreferences.store();
}
- private void _setCategoriesAndTags(
+ private void _setCategoriesAndKeywordsAndTags(
AssetEntryQuery assetEntryQuery, PortletPreferences portletPreferences,
long[] scopeGroupIds, long[] overrideAllAssetCategoryIds,
- String[] overrideAllAssetTagNames) {
+ String[] overrideAllKeywords, String[] overrideAllAssetTagNames) {
long[] allAssetCategoryIds = new long[0];
long[] anyAssetCategoryIds = new long[0];
long[] notAllAssetCategoryIds = new long[0];
long[] notAnyAssetCategoryIds = new long[0];
+ String[] allKeywords = new String[0];
+ String[] anyKeywords = new String[0];
+ String[] notAllKeywords = new String[0];
+ String[] notAnyKeywords = new String[0];
+
String[] allAssetTagNames = new String[0];
String[] anyAssetTagNames = new String[0];
String[] notAllAssetTagNames = new String[0];
@@ -1140,6 +1188,20 @@ else if (!queryContains && queryAndOperator) {
notAnyAssetCategoryIds = assetCategoryIds;
}
}
+ else if (Objects.equals(queryName, "keywords")) {
+ if (queryContains && queryAndOperator) {
+ allKeywords = queryValues;
+ }
+ else if (queryContains && !queryAndOperator) {
+ anyKeywords = queryValues;
+ }
+ else if (!queryContains && queryAndOperator) {
+ notAllKeywords = queryValues;
+ }
+ else {
+ notAnyKeywords = queryValues;
+ }
+ }
else {
if (queryContains && queryAndOperator) {
allAssetTagNames = queryValues;
@@ -1164,6 +1226,12 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setAllCategoryIds(allAssetCategoryIds);
+ if (overrideAllKeywords != null) {
+ allKeywords = overrideAllKeywords;
+ }
+
+ assetEntryQuery.setAllKeywords(allKeywords);
+
if (overrideAllAssetTagNames != null) {
allAssetTagNames = overrideAllAssetTagNames;
}
@@ -1181,6 +1249,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setAnyCategoryIds(anyAssetCategoryIds);
+ assetEntryQuery.setAnyKeywords(anyKeywords);
+
long[] anyAssetTagIds = _assetTagLocalService.getTagIds(
siteGroupIds, anyAssetTagNames);
@@ -1188,6 +1258,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setNotAllCategoryIds(notAllAssetCategoryIds);
+ assetEntryQuery.setNotAllKeywords(notAllKeywords);
+
for (String assetTagName : notAllAssetTagNames) {
long[] notAllAssetTagIds = _assetTagLocalService.getTagIds(
siteGroupIds, assetTagName);
@@ -1197,6 +1269,8 @@ else if (!queryContains && queryAndOperator) {
assetEntryQuery.setNotAnyCategoryIds(notAnyAssetCategoryIds);
+ assetEntryQuery.setNotAnyKeywords(notAnyKeywords);
+
long[] notAnyAssetTagIds = _assetTagLocalService.getTagIds(
siteGroupIds, notAnyAssetTagNames);
diff --git a/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/js/AutoField.soy b/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/js/AutoField.soy
index f242dfe3c27bbb..c3231e626e09c5 100644
--- a/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/js/AutoField.soy
+++ b/modules/apps/asset/asset-publisher-web/src/main/resources/META-INF/resources/js/AutoField.soy
@@ -125,6 +125,7 @@
@@ -140,6 +141,19 @@
{param selectedItems: $rule.selectedItems ?: [] /}
{param vocabularyIds: $vocabularyIds /}
{/call}
+ {elseif $rule.type == 'keywords'}
+
+
+
+
+
{else}
{call com.liferay.asset.taglib.AssetTagsSelector.render}
{param eventName: $namespace + 'selectTag' /}
diff --git a/modules/apps/asset/asset-tags-selector-web/src/main/java/com/liferay/asset/tags/selector/web/internal/display/context/AssetTagsSelectorDisplayContext.java b/modules/apps/asset/asset-tags-selector-web/src/main/java/com/liferay/asset/tags/selector/web/internal/display/context/AssetTagsSelectorDisplayContext.java
index 5a56631954f92a..324f3177529cad 100644
--- a/modules/apps/asset/asset-tags-selector-web/src/main/java/com/liferay/asset/tags/selector/web/internal/display/context/AssetTagsSelectorDisplayContext.java
+++ b/modules/apps/asset/asset-tags-selector-web/src/main/java/com/liferay/asset/tags/selector/web/internal/display/context/AssetTagsSelectorDisplayContext.java
@@ -43,9 +43,17 @@ public AssetTagsSelectorDisplayContext(
RenderRequest renderRequest, RenderResponse renderResponse,
HttpServletRequest httpServletRequest) {
+ this(renderRequest, renderResponse, httpServletRequest, true);
+ }
+
+ public AssetTagsSelectorDisplayContext(
+ RenderRequest renderRequest, RenderResponse renderResponse,
+ HttpServletRequest httpServletRequest, boolean rowChecker) {
+
_renderRequest = renderRequest;
_renderResponse = renderResponse;
_httpServletRequest = httpServletRequest;
+ _rowChecker = rowChecker;
}
public String getEventName() {
@@ -71,6 +79,18 @@ public String getOrderByType() {
return _orderByType;
}
+ public PortletURL getPortletURL() {
+ PortletURL portletURL = _renderResponse.createRenderURL();
+
+ portletURL.setParameter("eventName", getEventName());
+ portletURL.setParameter("groupIds", StringUtil.merge(_getGroupIds()));
+ portletURL.setParameter("mvcPath", _getMvcPath());
+ portletURL.setParameter(
+ "selectedTagNames", StringUtil.merge(getSelectedTagNames()));
+
+ return portletURL;
+ }
+
public String[] getSelectedTagNames() {
if (ArrayUtil.isNotEmpty(_selectedTagNames)) {
return _selectedTagNames;
@@ -92,7 +112,7 @@ public SearchContainer getTagsSearchContainer() {
WebKeys.THEME_DISPLAY);
SearchContainer tagsSearchContainer = new SearchContainer(
- _renderRequest, _getPortletURL(), null, "there-are-no-tags");
+ _renderRequest, getPortletURL(), null, "there-are-no-tags");
String orderByCol = _getOrderByCol();
@@ -111,8 +131,10 @@ public SearchContainer getTagsSearchContainer() {
tagsSearchContainer.setOrderByType(orderByType);
- tagsSearchContainer.setRowChecker(
- new EntriesChecker(_renderRequest, _renderResponse));
+ if (_rowChecker) {
+ tagsSearchContainer.setRowChecker(
+ new EntriesChecker(_renderRequest, _renderResponse));
+ }
int tagsCount = AssetTagServiceUtil.getTagsCount(
themeDisplay.getScopeGroupId(), _getKeywords());
@@ -160,6 +182,17 @@ private String _getKeywords() {
return _keywords;
}
+ private String _getMvcPath() {
+ if (Validator.isNotNull(_mvcPath)) {
+ return _mvcPath;
+ }
+
+ _mvcPath = ParamUtil.getString(
+ _httpServletRequest, "mvcPath", "/view.jsp");
+
+ return _mvcPath;
+ }
+
private String _getOrderByCol() {
if (Validator.isNotNull(_orderByCol)) {
return _orderByCol;
@@ -171,24 +204,16 @@ private String _getOrderByCol() {
return _orderByCol;
}
- private PortletURL _getPortletURL() {
- PortletURL portletURL = _renderResponse.createRenderURL();
-
- portletURL.setParameter("eventName", getEventName());
- portletURL.setParameter(
- "selectedTagNames", StringUtil.merge(getSelectedTagNames()));
-
- return portletURL;
- }
-
private String _eventName;
private long[] _groupIds;
private final HttpServletRequest _httpServletRequest;
private String _keywords;
+ private String _mvcPath;
private String _orderByCol;
private String _orderByType;
private final RenderRequest _renderRequest;
private final RenderResponse _renderResponse;
+ private final boolean _rowChecker;
private String[] _selectedTagNames;
private SearchContainer _tagsSearchContainer;
diff --git a/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/init.jsp b/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/init.jsp
index 5e3abfb56ab501..bf2aa616ead08e 100644
--- a/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/init.jsp
+++ b/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/init.jsp
@@ -28,6 +28,9 @@ page import="com.liferay.portal.kernel.dao.search.SearchContainer" %><%@
page import="com.liferay.portal.kernel.json.JSONFactoryUtil" %><%@
page import="com.liferay.portal.kernel.util.HtmlUtil" %>
+<%@ page import="java.util.HashMap" %><%@
+page import="java.util.Map" %>
+
diff --git a/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/select_single.jsp b/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/select_single.jsp
new file mode 100644
index 00000000000000..1af2a5844ba498
--- /dev/null
+++ b/modules/apps/asset/asset-tags-selector-web/src/main/resources/META-INF/resources/select_single.jsp
@@ -0,0 +1,68 @@
+<%--
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+--%>
+
+<%@ include file="/init.jsp" %>
+
+<%
+assetTagsSelectorDisplayContext = new AssetTagsSelectorDisplayContext(renderRequest, renderResponse, request, false);
+%>
+
+
+
+
+
+
+
+ <%
+ Map data = new HashMap();
+
+ data.put("entityid", tag.getTagId());
+ data.put("entityname", tag.getName());
+ %>
+
+
+
+ <%= HtmlUtil.escape(tag.getName()) %>
+
+
+
+
+
+
+
+
+
+ const Util = Liferay.Util;
+
+ Util.selectEntityHandler('#selectAssetTagFm', '<%= HtmlUtil.escapeJS(assetTagsSelectorDisplayContext.getEventName()) %>', true);
+
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/.lfrbuild-portal b/modules/apps/asset/asset-vocabularies-selector-web/.lfrbuild-portal
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/bnd.bnd b/modules/apps/asset/asset-vocabularies-selector-web/bnd.bnd
new file mode 100644
index 00000000000000..c8bb8fd8ba6e08
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/bnd.bnd
@@ -0,0 +1,11 @@
+Bundle-Name: Liferay Asset Vocabularies Selector Web
+Bundle-SymbolicName: com.liferay.asset.vocabularies.selector.web
+Bundle-Version: 3.0.0
+Provide-Capability:\
+ soy;\
+ type="asset-vocabularies-selector-web";\
+ version:Version="${Bundle-Version}"
+Require-Capability:\
+ osgi.extender;\
+ filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/soy))"
+Web-ContextPath: /asset-vocabularies-selector-web
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/build.gradle b/modules/apps/asset/asset-vocabularies-selector-web/build.gradle
new file mode 100644
index 00000000000000..6864906bd01128
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/build.gradle
@@ -0,0 +1,14 @@
+dependencies {
+ compileOnly group: "com.liferay.portal", name: "com.liferay.portal.impl", version: "default"
+ compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "default"
+ compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "default"
+ compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.1"
+ compileOnly group: "javax.servlet.jsp", name: "javax.servlet.jsp-api", version: "2.3.1"
+ compileOnly group: "org.apache.felix", name: "org.apache.felix.http.servlet-api", version: "1.1.2"
+ compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
+ compileOnly project(":apps:frontend-taglib:frontend-taglib")
+ compileOnly project(":apps:frontend-taglib:frontend-taglib-soy")
+ compileOnly project(":apps:portal:portal-upgrade-api")
+ compileOnly project(":core:petra:petra-lang")
+ compileOnly project(":core:petra:petra-string")
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/package.json b/modules/apps/asset/asset-vocabularies-selector-web/package.json
new file mode 100644
index 00000000000000..d760af906a5c46
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/package.json
@@ -0,0 +1,16 @@
+{
+ "dependencies": {
+ "frontend-js-web": "*",
+ "metal": "2.16.8",
+ "metal-component": "2.16.8",
+ "metal-soy": "2.16.8",
+ "metal-state": "2.16.8"
+ },
+ "name": "asset-vocabularies-selector-web",
+ "scripts": {
+ "build": "liferay-npm-scripts build",
+ "checkFormat": "liferay-npm-scripts check",
+ "format": "liferay-npm-scripts fix"
+ },
+ "version": "3.0.0"
+}
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/contants/AssetVocabulariesSelectorPortletKeys.java b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/contants/AssetVocabulariesSelectorPortletKeys.java
new file mode 100644
index 00000000000000..5a445a5963d567
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/contants/AssetVocabulariesSelectorPortletKeys.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.asset.vocabularies.selector.web.internal.contants;
+
+/**
+ * @author Raymond Augé
+ */
+public class AssetVocabulariesSelectorPortletKeys {
+
+ public static final String ASSET_VOCABULARIES_SELECTOR =
+ "com_liferay_asset_vocabularies_selector_web_portlet_" +
+ "AssetVocabulariesSelectorPortlet";
+
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/display/context/AssetVocabulariesSelectorDisplayContext.java b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/display/context/AssetVocabulariesSelectorDisplayContext.java
new file mode 100644
index 00000000000000..70c60b70dc8a71
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/display/context/AssetVocabulariesSelectorDisplayContext.java
@@ -0,0 +1,183 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.asset.vocabularies.selector.web.internal.display.context;
+
+import com.liferay.asset.kernel.model.AssetVocabulary;
+import com.liferay.asset.kernel.service.AssetVocabularyLocalService;
+import com.liferay.asset.kernel.service.AssetVocabularyService;
+import com.liferay.petra.string.StringBundler;
+import com.liferay.petra.string.StringPool;
+import com.liferay.portal.kernel.exception.PortalException;
+import com.liferay.portal.kernel.json.JSONArray;
+import com.liferay.portal.kernel.json.JSONFactory;
+import com.liferay.portal.kernel.json.JSONObject;
+import com.liferay.portal.kernel.language.Language;
+import com.liferay.portal.kernel.model.Group;
+import com.liferay.portal.kernel.service.GroupLocalService;
+import com.liferay.portal.kernel.theme.ThemeDisplay;
+import com.liferay.portal.kernel.util.Html;
+import com.liferay.portal.kernel.util.ParamUtil;
+import com.liferay.portal.kernel.util.Validator;
+import com.liferay.portal.kernel.util.WebKeys;
+
+import java.util.List;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author Raymond Augé
+ */
+public class AssetVocabulariesSelectorDisplayContext {
+
+ public AssetVocabulariesSelectorDisplayContext(
+ RenderRequest renderRequest, RenderResponse renderResponse,
+ HttpServletRequest httpServletRequest) {
+
+ _renderRequest = renderRequest;
+ _renderResponse = renderResponse;
+ _httpServletRequest = httpServletRequest;
+ _assetVocabularyService =
+ (AssetVocabularyService)renderRequest.getAttribute(
+ "assetVocabularyService");
+ _assetVocabularyLocalService =
+ (AssetVocabularyLocalService)renderRequest.getAttribute(
+ "assetVocabularyLocalService");
+ _groupLocalService = (GroupLocalService)renderRequest.getAttribute(
+ "groupLocalService");
+ _html = (Html)renderRequest.getAttribute("html");
+ _jsonFactory = (JSONFactory)renderRequest.getAttribute("jsonFactory");
+ _language = (Language)renderRequest.getAttribute("language");
+ }
+
+ public String getEventName() {
+ if (Validator.isNotNull(_eventName)) {
+ return _eventName;
+ }
+
+ _eventName = ParamUtil.getString(
+ _httpServletRequest, "eventName",
+ _renderResponse.getNamespace() + "selectVocabulary");
+
+ return _eventName;
+ }
+
+ public String getSelectedVocabularies() {
+ if (_selectedVocabularies != null) {
+ return _selectedVocabularies;
+ }
+
+ _selectedVocabularies = ParamUtil.getString(
+ _httpServletRequest, "selectedVocabularies");
+
+ return _selectedVocabularies;
+ }
+
+ public JSONArray getVocabulariesJSONArray() throws Exception {
+ JSONArray jsonArray = _jsonFactory.createJSONArray();
+
+ ThemeDisplay themeDisplay =
+ (ThemeDisplay)_httpServletRequest.getAttribute(
+ WebKeys.THEME_DISPLAY);
+
+ long[] groupIds = getGroupIds(themeDisplay);
+
+ List vocabularies =
+ _assetVocabularyService.getGroupsVocabularies(groupIds);
+
+ for (AssetVocabulary vocabulary : vocabularies) {
+ JSONObject jsonObject = _jsonFactory.createJSONObject();
+
+ jsonObject.put(
+ "icon", "vocabularies"
+ ).put(
+ "id", vocabulary.getVocabularyId()
+ ).put(
+ "key", vocabulary.getName()
+ ).put(
+ "name", getVocabularyTitle(vocabulary.getVocabularyId())
+ );
+
+ if (getSelectedVocabularies().contains(
+ String.valueOf(vocabulary.getVocabularyId()))) {
+
+ jsonObject.put("selected", true);
+ }
+
+ jsonArray.put(jsonObject);
+ }
+
+ return jsonArray;
+ }
+
+ public String getVocabularyTitle(long vocabularyId) throws PortalException {
+ ThemeDisplay themeDisplay = (ThemeDisplay)_renderRequest.getAttribute(
+ WebKeys.THEME_DISPLAY);
+
+ AssetVocabulary assetVocabulary =
+ _assetVocabularyLocalService.fetchAssetVocabulary(vocabularyId);
+
+ StringBundler sb = new StringBundler(5);
+
+ String title = assetVocabulary.getTitle(themeDisplay.getLocale());
+
+ sb.append(_html.escape(title));
+
+ sb.append(StringPool.SPACE);
+ sb.append(StringPool.OPEN_PARENTHESIS);
+
+ if (assetVocabulary.getGroupId() == themeDisplay.getCompanyGroupId()) {
+ sb.append(_language.get(_httpServletRequest, "global"));
+ }
+ else {
+ Group group = _groupLocalService.fetchGroup(
+ assetVocabulary.getGroupId());
+
+ sb.append(group.getDescriptiveName(themeDisplay.getLocale()));
+ }
+
+ sb.append(StringPool.CLOSE_PARENTHESIS);
+
+ return sb.toString();
+ }
+
+ private long[] getGroupIds(ThemeDisplay themeDisplay) {
+ if (_groupIds != null) {
+ return _groupIds;
+ }
+
+ return _groupIds = ParamUtil.getLongValues(
+ _httpServletRequest, "groupIds",
+ new long[] {
+ themeDisplay.getCompanyGroupId(), themeDisplay.getScopeGroupId()
+ });
+ }
+
+ private final AssetVocabularyLocalService _assetVocabularyLocalService;
+ private final AssetVocabularyService _assetVocabularyService;
+ private String _eventName;
+ private long[] _groupIds;
+ private final GroupLocalService _groupLocalService;
+ private final Html _html;
+ private final HttpServletRequest _httpServletRequest;
+ private final JSONFactory _jsonFactory;
+ private final Language _language;
+ private final RenderRequest _renderRequest;
+ private final RenderResponse _renderResponse;
+ private String _selectedVocabularies;
+
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorBrowserPortletProvider.java b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorBrowserPortletProvider.java
new file mode 100644
index 00000000000000..87b8555ebfd7ac
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorBrowserPortletProvider.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.asset.vocabularies.selector.web.internal.portlet;
+
+import com.liferay.asset.vocabularies.selector.web.internal.contants.AssetVocabulariesSelectorPortletKeys;
+import com.liferay.portal.kernel.portlet.BasePortletProvider;
+import com.liferay.portal.kernel.portlet.BrowsePortletProvider;
+
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * @author Raymond Augé
+ */
+@Component(
+ immediate = true,
+ property = "model.class.name=com.liferay.asset.kernel.model.AssetVocabulary",
+ service = BrowsePortletProvider.class
+)
+public class AssetVocabulariesSelectorBrowserPortletProvider
+ extends BasePortletProvider implements BrowsePortletProvider {
+
+ @Override
+ public String getPortletName() {
+ return AssetVocabulariesSelectorPortletKeys.ASSET_VOCABULARIES_SELECTOR;
+ }
+
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorPortlet.java b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorPortlet.java
new file mode 100644
index 00000000000000..f3066f64c5fa22
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/portlet/AssetVocabulariesSelectorPortlet.java
@@ -0,0 +1,161 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.asset.vocabularies.selector.web.internal.portlet;
+
+import com.liferay.asset.kernel.model.AssetVocabulary;
+import com.liferay.asset.kernel.service.AssetVocabularyLocalService;
+import com.liferay.asset.kernel.service.AssetVocabularyService;
+import com.liferay.asset.vocabularies.selector.web.internal.contants.AssetVocabulariesSelectorPortletKeys;
+import com.liferay.portal.kernel.json.JSONArray;
+import com.liferay.portal.kernel.json.JSONFactory;
+import com.liferay.portal.kernel.json.JSONFactoryUtil;
+import com.liferay.portal.kernel.json.JSONObject;
+import com.liferay.portal.kernel.json.JSONUtil;
+import com.liferay.portal.kernel.language.Language;
+import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
+import com.liferay.portal.kernel.service.GroupLocalService;
+import com.liferay.portal.kernel.theme.ThemeDisplay;
+import com.liferay.portal.kernel.util.GetterUtil;
+import com.liferay.portal.kernel.util.Html;
+import com.liferay.portal.kernel.util.ParamUtil;
+import com.liferay.portal.kernel.util.WebKeys;
+
+import java.io.IOException;
+
+import java.util.List;
+
+import javax.portlet.Portlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+/**
+ * @author Raymond Augé
+ */
+@Component(
+ immediate = true,
+ property = {
+ "com.liferay.portlet.add-default-resource=true",
+ "com.liferay.portlet.css-class-wrapper=portlet-asset-vocabularies-selector",
+ "com.liferay.portlet.header-portlet-css=/css/tree.css",
+ "com.liferay.portlet.private-request-attributes=false",
+ "com.liferay.portlet.private-session-attributes=false",
+ "com.liferay.portlet.render-weight=50",
+ "com.liferay.portlet.system=true",
+ "com.liferay.portlet.use-default-template=true",
+ "javax.portlet.display-name=Asset Vocabularies Selector",
+ "javax.portlet.init-param.template-path=/META-INF/resources/",
+ "javax.portlet.init-param.view-template=/view.jsp",
+ "javax.portlet.name=" + AssetVocabulariesSelectorPortletKeys.ASSET_VOCABULARIES_SELECTOR,
+ "javax.portlet.resource-bundle=content.Language",
+ "javax.portlet.security-role-ref=guest,power-user,user"
+ },
+ service = Portlet.class
+)
+public class AssetVocabulariesSelectorPortlet extends MVCPortlet {
+
+ @Override
+ public void serveResource(
+ ResourceRequest resourceRequest, ResourceResponse resourceResponse)
+ throws IOException, PortletException {
+
+ String resourceID = GetterUtil.getString(
+ resourceRequest.getResourceID());
+
+ if (resourceID.equals("getVocabularies")) {
+ JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
+
+ ThemeDisplay themeDisplay =
+ (ThemeDisplay)resourceRequest.getAttribute(
+ WebKeys.THEME_DISPLAY);
+
+ long[] groupIds = getGroupIds(resourceRequest, themeDisplay);
+
+ List vocabularies =
+ _assetVocabularyService.getGroupsVocabularies(groupIds);
+
+ for (AssetVocabulary vocabulary : vocabularies) {
+ JSONObject jsonObject = JSONUtil.put(
+ "icon", "vocabularies"
+ ).put(
+ "id", vocabulary.getVocabularyId()
+ ).put(
+ "key", vocabulary.getName()
+ ).put(
+ "name", vocabulary.getTitle(themeDisplay.getLocale())
+ );
+
+ jsonArray.put(jsonObject);
+ }
+
+ writeJSON(resourceRequest, resourceResponse, jsonArray.toString());
+ }
+ else {
+ super.serveResource(resourceRequest, resourceResponse);
+ }
+ }
+
+ @Override
+ protected void doDispatch(
+ RenderRequest renderRequest, RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ renderRequest.setAttribute(
+ "assetVocabularyLocalService", _assetVocabularyLocalService);
+ renderRequest.setAttribute(
+ "assetVocabularyService", _assetVocabularyService);
+ renderRequest.setAttribute("groupLocalService", _groupLocalService);
+ renderRequest.setAttribute("html", _html);
+ renderRequest.setAttribute("jsonFactory", _jsonFactory);
+ renderRequest.setAttribute("language", _language);
+
+ super.doDispatch(renderRequest, renderResponse);
+ }
+
+ private long[] getGroupIds(
+ PortletRequest portletRequest, ThemeDisplay themeDisplay) {
+
+ return ParamUtil.getLongValues(
+ portletRequest, "groupIds",
+ new long[] {
+ themeDisplay.getCompanyGroupId(), themeDisplay.getScopeGroupId()
+ });
+ }
+
+ @Reference
+ private AssetVocabularyLocalService _assetVocabularyLocalService;
+
+ @Reference
+ private AssetVocabularyService _assetVocabularyService;
+
+ @Reference
+ private GroupLocalService _groupLocalService;
+
+ @Reference
+ private Html _html;
+
+ @Reference
+ private JSONFactory _jsonFactory;
+
+ @Reference
+ private Language _language;
+
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/upgrade/AssetVocabulariesSelectorWebUpgrade.java b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/upgrade/AssetVocabulariesSelectorWebUpgrade.java
new file mode 100644
index 00000000000000..decc4fa14d55f5
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/java/com/liferay/asset/vocabularies/selector/web/internal/upgrade/AssetVocabulariesSelectorWebUpgrade.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+package com.liferay.asset.vocabularies.selector.web.internal.upgrade;
+
+import com.liferay.portal.kernel.upgrade.DummyUpgradeStep;
+import com.liferay.portal.upgrade.registry.UpgradeStepRegistrator;
+
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * @author Raymond Augé
+ */
+@Component(immediate = true, service = UpgradeStepRegistrator.class)
+public class AssetVocabulariesSelectorWebUpgrade
+ implements UpgradeStepRegistrator {
+
+ @Override
+ public void register(Registry registry) {
+ registry.register("0.0.0", "1.0.0", new DummyUpgradeStep());
+ }
+
+}
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/css/tree.scss b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/css/tree.scss
new file mode 100644
index 00000000000000..8b4cf79c6d52b8
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/css/tree.scss
@@ -0,0 +1,145 @@
+$navigation-color: #869cad;
+$spacer: 1rem;
+
+.select-vocabulary-filter {
+ background: #fff;
+ border-bottom: 1px solid #dee2e6;
+ margin-bottom: $spacer * 1.5;
+ padding: $spacer * 0.75;
+}
+
+.vocabulary-tree {
+ .card {
+ border: 1px solid #e7e7ed;
+ box-shadow: none;
+ color: #6b6c7e;
+ margin-bottom: 0;
+
+ &:hover {
+ background-color: #f7f8f9;
+ border-color: #cdced9;
+ color: #272833;
+ }
+
+ &:focus {
+ box-shadow: 0 0 0 2px white, 0 0 0 4px #80afff;
+ color: #272833;
+ }
+ }
+
+ .card-row-padded {
+ padding: 8px 12px;
+ }
+
+ .selected .card {
+ background-color: #80acff;
+ border-color: #80acff;
+ color: #272833;
+ }
+
+ .disabled {
+ .card,
+ .card:hover,
+ .card:focus {
+ background-color: #e7e7ed;
+ border: 1px solid #e7e7ed;
+ box-shadow: none;
+ color: #272833;
+ cursor: not-allowed;
+ outline: none;
+ }
+ }
+
+ .treeview {
+ margin-left: -15px;
+
+ @media (min-width: 768px) {
+ margin-left: -54px;
+ }
+ }
+
+ .treeview-node {
+ margin-bottom: 0.5rem;
+ position: relative;
+ }
+
+ .treeview-node-main {
+ float: none;
+ margin-bottom: 15px;
+ padding-left: 15px;
+ position: relative;
+
+ &:not(.disabled) {
+ cursor: pointer;
+ }
+
+ @media (min-width: 768px) {
+ margin-bottom: 24px;
+ padding-left: 24px;
+ }
+ }
+
+ .treeview-nodes {
+ border-left: 2px solid $navigation-color;
+ list-style: none;
+ margin-left: 15px;
+ padding-left: 0;
+
+ .treeview-nodes {
+ border-left-style: dashed;
+ border-left-width: 1px;
+ }
+
+ @media (min-width: 768px) {
+ margin-left: 54px;
+ }
+ }
+
+ .treeview-node-name {
+ margin-left: 2px;
+ }
+
+ .treeview-node-toggler {
+ background-color: $navigation-color;
+ border-radius: 3px;
+ display: inline-block;
+ height: 14px;
+ left: 0;
+ margin-left: -8px;
+ margin-top: -8px;
+ position: absolute;
+ text-align: center;
+ top: 50%;
+ width: 14px;
+
+ &:before {
+ color: #fff;
+ content: '+';
+ display: block;
+ line-height: 11px;
+
+ .win & {
+ line-height: 14px;
+ }
+ }
+ }
+
+ .treeview-node-wrapper > .treeview-nodes {
+ display: none;
+ }
+
+ .expanded {
+ > .treeview-node-main > .treeview-node-toggler:before {
+ content: '-';
+ font-size: 21px;
+
+ .win & {
+ line-height: 11px;
+ }
+ }
+
+ > .treeview-nodes {
+ display: block;
+ }
+ }
+}
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init-ext.jsp b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init-ext.jsp
new file mode 100644
index 00000000000000..bd7e580a414ba1
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init-ext.jsp
@@ -0,0 +1,15 @@
+<%--
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+--%>
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init.jsp b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init.jsp
new file mode 100644
index 00000000000000..8e4f15824ac7b2
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/init.jsp
@@ -0,0 +1,39 @@
+<%--
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+--%>
+
+<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
+
+<%@ taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend" %><%@
+taglib uri="http://liferay.com/tld/soy" prefix="soy" %><%@
+taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
+
+<%@ page import="com.liferay.asset.vocabularies.selector.web.internal.display.context.AssetVocabulariesSelectorDisplayContext" %><%@
+page import="com.liferay.portal.kernel.util.HtmlUtil" %>
+
+<%@ page import="java.util.HashMap" %><%@
+page import="java.util.Map" %>
+
+
+
+
+
+
+
+<%
+AssetVocabulariesSelectorDisplayContext assetVocabulariesSelectorDisplayContext = new AssetVocabulariesSelectorDisplayContext(renderRequest, renderResponse, request);
+%>
+
+<%@ include file="/init-ext.jsp" %>
\ No newline at end of file
diff --git a/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/js/SelectVocabulary.es.js b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/js/SelectVocabulary.es.js
new file mode 100644
index 00000000000000..5df7bcf7c5cbb0
--- /dev/null
+++ b/modules/apps/asset/asset-vocabularies-selector-web/src/main/resources/META-INF/resources/js/SelectVocabulary.es.js
@@ -0,0 +1,188 @@
+/**
+ * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ */
+
+import 'frontend-taglib/cards_treeview/CardsTreeview.es';
+import 'metal';
+import 'metal-component';
+import {PortletBase} from 'frontend-js-web';
+import Soy from 'metal-soy';
+import {Config} from 'metal-state';
+
+import templates from './SelectVocabulary.soy';
+
+/**
+ * KeyBoardEvent enter key
+ * @review
+ * @type {!string}
+ */
+
+const ENTER_KEY = 'Enter';
+
+/**
+ * SelectVocabulary
+ *
+ * This component shows a list of available vocabularies to move content in and
+ * allows to filter them by searching.
+ */
+
+class SelectVocabulary extends PortletBase {
+ /**
+ * Filters deep nested nodes based on a filtering value
+ *
+ * @type {Array.
-
+
-
-
- function(val, fieldNode, ruleValue) {
- return (val != A.one('#publicVirtualHost').val());
- }
-
-
+ <%
+ for (Map.Entry
entry : publicVirtualHosts.entrySet()) {
+ String hostName = entry.getKey();
+
+ String hostLocale = Validator.isNotNull(entry.getValue()) ? entry.getValue() : StringPool.BLANK;
+ %>
+
+
+
+ <%
+ }
+ %>
+
+
+
+
+
+ <%
+ for (Map.Entry
entry : privateVirtualHosts.entrySet()) {
+ String hostName = entry.getKey();
+
+ String hostLocale = Validator.isNotNull(entry.getValue()) ? entry.getValue() : StringPool.BLANK;
+ %>
+
+
+
+ <%
+ }
+ %>
+
+
<%
LayoutSet stagingPublicLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet(stagingGroupId, false);
- String stagingPublicVirtualHost = ParamUtil.getString(request, "stagingPublicVirtualHost", stagingPublicLayoutSet.getVirtualHostname());
+ TreeMap stagingPublicVirtualHosts = stagingPublicLayoutSet.getVirtualHostnames();
+
+ if (stagingPublicVirtualHosts.size() == 0) {
+ stagingPublicVirtualHosts.put(StringPool.BLANK, StringPool.BLANK);
+ }
%>
-
+
+
+ <%
+ for (Map.Entry
entry : stagingPublicVirtualHosts.entrySet()) {
+ String hostName = entry.getKey();
+
+ String hostLocale = Validator.isNotNull(entry.getValue()) ? entry.getValue() : StringPool.BLANK;
+ %>
+
+
+
+ <%
+ }
+ %>
+
+
<%
LayoutSet stagingPrivateLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet(stagingGroupId, true);
- String stagingPrivateVirtualHost = ParamUtil.getString(request, "stagingPrivateVirtualHost", stagingPrivateLayoutSet.getVirtualHostname());
+ TreeMap stagingPrivateVirtualHosts = stagingPrivateLayoutSet.getVirtualHostnames();
+
+ if (stagingPrivateVirtualHosts.size() == 0) {
+ stagingPrivateVirtualHosts.put(StringPool.BLANK, StringPool.BLANK);
+ }
%>
-
-
- function(val, fieldNode, ruleValue) {
- return (val != A.one('#stagingPublicVirtualHost').val());
- }
-
-
+
+
+ <%
+ for (Map.Entry
entry : stagingPrivateVirtualHosts.entrySet()) {
+ String hostName = entry.getKey();
+
+ String hostLocale = Validator.isNotNull(entry.getValue()) ? entry.getValue() : StringPool.BLANK;
+ %>
+
+
+
+ <%
+ }
+ %>
+
+
+
+ new Liferay.AutoFields(
+ {
+ contentBox: '#publicVirtualHostFields',
+ namespace: ''
+ }
+ ).render();
+
+ new Liferay.AutoFields(
+ {
+ contentBox: '#privateVirtualHostFields',
+ namespace: ''
+ }
+ ).render();
+
+
+ new Liferay.AutoFields(
+ {
+ contentBox: '#stagingPublicVirtualHostFields',
+ namespace: ''
+ }
+ ).render();
+
+ new Liferay.AutoFields(
+ {
+ contentBox: '#stagingPrivateVirtualHostFields',
+ namespace: ''
+ }
+ ).render();
+
+
+