Skip to content

Instantly share code, notes, and snippets.

@epgarcia
Created December 13, 2017 18:08
Show Gist options
  • Save epgarcia/a98b5c34e8545620d35c34d10c0a7c56 to your computer and use it in GitHub Desktop.
Save epgarcia/a98b5c34e8545620d35c34d10c0a7c56 to your computer and use it in GitHub Desktop.
diff --git a/content-targeting-api/src/main/java/com/liferay/content/targeting/util/UserSegmentUtil.java b/content-targeting-api/src/main/java/com/liferay/content/targeting/util/UserSegmentUtil.java
index 0bb2408a4..95c2d28a2 100644
--- a/content-targeting-api/src/main/java/com/liferay/content/targeting/util/UserSegmentUtil.java
+++ b/content-targeting-api/src/main/java/com/liferay/content/targeting/util/UserSegmentUtil.java
@@ -28,6 +28,7 @@
import com.liferay.portal.kernel.search.Indexer;
import com.liferay.portal.kernel.search.IndexerRegistryUtil;
import com.liferay.portal.kernel.service.ServiceContext;
+import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
@@ -127,6 +128,18 @@ public long getAssetVocabularyId(long userId, ServiceContext serviceContext)
}
}
+ if (vocabularyIds.size() == 0) {
+ ServiceContext serviceContext =
+ ServiceContextThreadLocal.getServiceContext();
+
+ if (serviceContext != null) {
+ AssetVocabulary assetVocabulary = addAssetVocabulary(
+ serviceContext.getUserId(), serviceContext);
+
+ vocabularyIds.add(assetVocabulary.getVocabularyId());
+ }
+ }
+
return ArrayUtil.toLongArray(vocabularyIds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment