Skip to content

Commit a515bd9

Browse files
LPD-49933 1.) Label usually maps to a language key. 2.) And it's only used in one TaxonomyVocabularyResourceImpl.
1 parent b1c774d commit a515bd9

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

modules/apps/headless/headless-admin-taxonomy/headless-admin-taxonomy-impl/src/main/java/com/liferay/headless/admin/taxonomy/internal/resource/v1_0/TaxonomyVocabularyResourceImpl.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.liferay.asset.kernel.model.AssetCategoryConstants;
1111
import com.liferay.asset.kernel.model.AssetRendererFactory;
1212
import com.liferay.asset.kernel.model.AssetVocabulary;
13-
import com.liferay.asset.kernel.model.AssetVocabularyConstants;
1413
import com.liferay.asset.kernel.model.AssetVocabularyGroupRel;
1514
import com.liferay.asset.kernel.model.ClassType;
1615
import com.liferay.asset.kernel.model.ClassTypeReader;
@@ -514,6 +513,10 @@ private AssetVocabulary _addAssetVocabulary(
514513
true, LocaleUtil.getSiteDefault(), "Taxonomy vocabulary", titleMap,
515514
new HashSet<>(descriptionMap.keySet()));
516515

516+
boolean internalVisibilityType =
517+
TaxonomyVocabulary.VisibilityType.INTERNAL.equals(
518+
taxonomyVocabulary.getVisibilityType());
519+
517520
return _assetVocabularyService.addVocabulary(
518521
externalReferenceCode, siteId,
519522
titleMap.get(LocaleUtil.getSiteDefault()), null, titleMap,
@@ -522,8 +525,7 @@ private AssetVocabulary _addAssetVocabulary(
522525
taxonomyVocabulary.getAssetTypes(), siteId,
523526
GetterUtil.getBoolean(
524527
taxonomyVocabulary.getMultiValued(), true)),
525-
AssetVocabularyConstants.getLabelVisibilityType(
526-
taxonomyVocabulary.getVisibilityTypeAsString()),
528+
internalVisibilityType ? 1 : 0,
527529
ServiceContextBuilder.create(
528530
siteId, contextHttpServletRequest,
529531
taxonomyVocabulary.getViewableByAsString()
@@ -912,9 +914,9 @@ private TaxonomyVocabulary _toTaxonomyVocabulary(
912914
return GroupUtil.getSiteId(group);
913915
});
914916
setVisibilityType(
915-
() -> TaxonomyVocabulary.VisibilityType.create(
916-
AssetVocabularyConstants.getVisibilityTypeLabel(
917-
assetVocabulary.getVisibilityType())));
917+
() -> (assetVocabulary.getVisibilityType() == 1) ?
918+
TaxonomyVocabulary.VisibilityType.INTERNAL :
919+
TaxonomyVocabulary.VisibilityType.PUBLIC);
918920
}
919921
};
920922
}

modules/apps/headless/headless-admin-taxonomy/headless-admin-taxonomy-test/src/testIntegration/java/com/liferay/headless/admin/taxonomy/resource/v1_0/test/TaxonomyVocabularyResourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ public void testPostTaxonomyVocabulary() throws Exception {
457457
randomTaxonomyVocabulary);
458458

459459
assertEquals(randomTaxonomyVocabulary, postTaxonomyVocabulary);
460+
460461
Assert.assertTrue(
461462
Objects.deepEquals(
462463
assetLibraries, postTaxonomyVocabulary.getAssetLibraries()));
@@ -596,7 +597,6 @@ private TaxonomyVocabulary _randomTaxonomyVocabularyWithAssetLibraries(
596597
TaxonomyVocabulary taxonomyVocabulary = randomTaxonomyVocabulary();
597598

598599
taxonomyVocabulary.setAssetLibraries(assetLibraries);
599-
600600
taxonomyVocabulary.setSiteId(GroupConstants.DEFAULT_LIVE_GROUP_ID);
601601

602602
return taxonomyVocabulary;

portal-kernel/src/com/liferay/asset/kernel/model/AssetVocabularyConstants.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,17 @@
55

66
package com.liferay.asset.kernel.model;
77

8-
import com.liferay.portal.kernel.util.StringUtil;
9-
108
/**
119
* @author Rubén Pulido
1210
*/
1311
public class AssetVocabularyConstants {
1412

1513
public static final int VISIBILITY_TYPE_INTERNAL = 1;
1614

17-
public static final String VISIBILITY_TYPE_INTERNAL_LABEL = "INTERNAL";
18-
1915
public static final int VISIBILITY_TYPE_PUBLIC = 0;
2016

21-
public static final String VISIBILITY_TYPE_PUBLIC_LABEL = "PUBLIC";
22-
2317
public static final int[] VISIBILITY_TYPES = {
2418
VISIBILITY_TYPE_INTERNAL, VISIBILITY_TYPE_PUBLIC
2519
};
2620

27-
public static int getLabelVisibilityType(String label) {
28-
if (StringUtil.equalsIgnoreCase(
29-
VISIBILITY_TYPE_INTERNAL_LABEL, label)) {
30-
31-
return VISIBILITY_TYPE_INTERNAL;
32-
}
33-
34-
return VISIBILITY_TYPE_PUBLIC;
35-
}
36-
37-
public static String getVisibilityTypeLabel(int visibilityType) {
38-
if (visibilityType == VISIBILITY_TYPE_INTERNAL) {
39-
return VISIBILITY_TYPE_INTERNAL_LABEL;
40-
}
41-
42-
return VISIBILITY_TYPE_PUBLIC_LABEL;
43-
}
44-
4521
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version 11.7.0
1+
version 11.6.0

0 commit comments

Comments
 (0)