38
38
import com .liferay .portal .kernel .service .ClassNameLocalServiceUtil ;
39
39
import com .liferay .portal .kernel .service .ServiceContext ;
40
40
import com .liferay .portal .kernel .util .ArrayUtil ;
41
+ import com .liferay .portal .kernel .util .LocalizationUtil ;
41
42
import com .liferay .portal .kernel .util .PortalUtil ;
42
43
import com .liferay .portlet .asset .util .AssetVocabularySettingsHelper ;
43
44
import com .mimacom .liferay .portal .setup .LiferaySetup ;
44
45
import com .mimacom .liferay .portal .setup .core .util .ResolverUtil ;
46
+ import com .mimacom .liferay .portal .setup .core .util .TitleMapUtil ;
45
47
import com .mimacom .liferay .portal .setup .domain .AssociatedAssetType ;
46
48
import com .mimacom .liferay .portal .setup .domain .Category ;
47
49
import com .mimacom .liferay .portal .setup .domain .Site ;
@@ -83,25 +85,24 @@ public static void setupVocabularies(final Site site, final long groupId)
83
85
84
86
private static void setupVocabulary (final Vocabulary vocabulary , final Site site , final long groupId , final Locale defaultLocale ) {
85
87
86
- LOG .info ("Setting up vocabulary with title : " + vocabulary .getTitle ());
88
+ LOG .info ("Setting up vocabulary with name : " + vocabulary .getName ());
87
89
88
- Map <Locale , String > titleMap = new HashMap <>();
89
- String title = vocabulary .getTitle ();
90
- titleMap .put (defaultLocale , title );
90
+ Map <Locale , String > titleMap = TitleMapUtil .getTitleMap (vocabulary .getTitleTranslation (), groupId , vocabulary .getName (), "" );
91
91
92
92
Map <Locale , String > descMap = new HashMap <>();
93
93
descMap .put (defaultLocale , vocabulary .getDescription ());
94
94
95
95
AssetVocabulary assetVocabulary = null ;
96
96
try {
97
- assetVocabulary = AssetVocabularyLocalServiceUtil .getGroupVocabulary (groupId , title );
97
+ assetVocabulary = AssetVocabularyLocalServiceUtil .getGroupVocabulary (groupId , vocabulary . getName () );
98
98
} catch (PortalException | SystemException e ) {
99
99
LOG .error ("Asset vocabulary was not found" );
100
100
}
101
101
102
102
if (assetVocabulary != null ) {
103
103
LOG .debug ("Vocabulary already exists. Will be updated." );
104
104
105
+ assetVocabulary .setName (vocabulary .getName ());
105
106
assetVocabulary .setTitleMap (titleMap );
106
107
assetVocabulary .setDescriptionMap (descMap );
107
108
assetVocabulary .setSettings (composeVocabularySettings (vocabulary , groupId ));
@@ -189,7 +190,7 @@ private static String composeVocabularySettings(Vocabulary vocabulary, final lon
189
190
190
191
assetVocabularySettingsHelper .setClassNameIdsAndClassTypePKs (ArrayUtil .toLongArray (classNameIds ), ArrayUtil .toLongArray (classTypePKs ), requiredsArray );
191
192
if (LOG .isDebugEnabled ()) {
192
- LOG .debug ("Vocabulary settings composed for vocabulary:" + vocabulary .getTitle () + ". Content: " + assetVocabularySettingsHelper .toString ());
193
+ LOG .debug ("Vocabulary settings composed for vocabulary:" + vocabulary .getName () + ". Content: " + assetVocabularySettingsHelper .toString ());
193
194
}
194
195
195
196
return assetVocabularySettingsHelper .toString ();
@@ -209,12 +210,10 @@ private static void setupCategories(final long vocabularyId, final long groupId,
209
210
private static void setupCategory (final Category category , final long vocabularyId ,
210
211
final long groupId , final Locale defaultLocale , final long parentCategoryId ) {
211
212
212
- LOG .info ("Setting up category with title:" + category .getTitle ());
213
-
214
- Map <Locale , String > titleMap = new HashMap <>();
215
- String title = category .getTitle ();
216
- titleMap .put (defaultLocale , title );
213
+ LOG .info ("Setting up category with name:" + category .getName ());
217
214
215
+ Map <Locale , String > titleMap = TitleMapUtil .getTitleMap (category .getTitleTranslation (), groupId , category .getName (),
216
+ "Category with name: " + category .getName ());
218
217
Map <Locale , String > descMap = new HashMap <>();
219
218
String description = category .getDescription ();
220
219
descMap .put (defaultLocale , description );
@@ -230,20 +229,20 @@ private static void setupCategory(final Category category, final long vocabulary
230
229
List <AssetCategory > existingCategories = AssetCategoryLocalServiceUtil
231
230
.getChildCategories (parentCategoryId );
232
231
for (AssetCategory ac : existingCategories ) {
233
- if (ac .getName ().equals (category .getTitle ())) {
232
+ if (ac .getName ().equals (category .getName ())) {
234
233
assetCategory = ac ;
235
234
}
236
235
}
237
236
} catch (SystemException e ) {
238
- LOG .error ("Error while trying to find category with name: " + category .getTitle (), e );
237
+ LOG .error ("Error while trying to find category with name: " + category .getName (), e );
239
238
}
240
239
241
240
if (assetCategory != null ) {
242
241
LOG .error ("Asset category already exists for parent category. Updating..." );
243
242
244
243
assetCategory .setTitleMap (titleMap );
245
244
assetCategory .setDescriptionMap (descMap );
246
- assetCategory .setName (title );
245
+ assetCategory .setName (category . getName () );
247
246
248
247
try {
249
248
AssetCategoryLocalServiceUtil .updateAssetCategory (assetCategory );
@@ -267,7 +266,7 @@ private static void setupCategory(final Category category, final long vocabulary
267
266
category .getCategory (), defaultLocale );
268
267
269
268
} catch (PortalException | SystemException e ) {
270
- LOG .error ("Error in creating category with title : " + category .getTitle (), e );
269
+ LOG .error ("Error in creating category with name : " + category .getName (), e );
271
270
}
272
271
273
272
}
0 commit comments