@Indexable(type = IndexableType.REINDEX) @Override public AssetCategory addCategory( long userId, long groupId, long parentCategoryId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, long vocabularyId, String[] categoryProperties, ServiceContext serviceContext) throws PortalException { // Category User user = userPersistence.findByPrimaryKey(userId); String name = titleMap.get(LocaleUtil.getSiteDefault()); name = ModelHintsUtil.trimString(AssetCategory.class.getName(), "name", name); if (categoryProperties == null) { categoryProperties = new String[0]; } validate(0, parentCategoryId, name, vocabularyId); if (parentCategoryId > 0) { assetCategoryPersistence.findByPrimaryKey(parentCategoryId); } assetVocabularyPersistence.findByPrimaryKey(vocabularyId); long categoryId = counterLocalService.increment(); AssetCategory category = assetCategoryPersistence.create(categoryId); category.setUuid(serviceContext.getUuid()); category.setGroupId(groupId); category.setCompanyId(user.getCompanyId()); category.setUserId(user.getUserId()); category.setUserName(user.getFullName()); category.setParentCategoryId(parentCategoryId); category.setName(name); category.setTitleMap(titleMap); category.setDescriptionMap(descriptionMap); category.setVocabularyId(vocabularyId); assetCategoryPersistence.update(category); // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addCategoryResources( category, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addCategoryResources(category, serviceContext.getModelPermissions()); } // Properties for (int i = 0; i < categoryProperties.length; i++) { String[] categoryProperty = StringUtil.split( categoryProperties[i], AssetCategoryConstants.PROPERTY_KEY_VALUE_SEPARATOR); if (categoryProperty.length <= 1) { categoryProperty = StringUtil.split(categoryProperties[i], CharPool.COLON); } String key = StringPool.BLANK; String value = StringPool.BLANK; if (categoryProperty.length > 1) { key = GetterUtil.getString(categoryProperty[0]); value = GetterUtil.getString(categoryProperty[1]); } if (Validator.isNotNull(key)) { assetCategoryPropertyLocalService.addCategoryProperty(userId, categoryId, key, value); } } return category; }