A tip to solve many asset category problems

Posted on 21/02/2014 by Charalampos Chrysikopoulos

In case you are experiencing a strange behaviour in the Categories portlet of the control panel, like creating a category in vocabulary x and finding it in vocabulary y, you try to rebuild the category tree for this site.

The API of the liferay gives us a method for that job: AssetCategoryLocalServiceUtil.rebuildTree

The method has 2 parameters, but you need to find out the value only for the first one. This parameter is the groupId, which is the id of the site. If you don't know it you can find it following the steps as described here.

But if you are not a programmer, how can execute this method? The solution is simple. As the Administrator, go to the "Server Administration" and then to the "script" tab. Here you can run scripts in different languages. Select "Beanshell" and in the text area give the following code:

import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
AssetCategoryLocalServiceUtil.rebuildTree(type_here_the_groupId, true);

and then type run.

This entry was posted in Liferay and tagged categories, rebuild by Charalampos Chrysikopoulos

Add new comment