I'm trying to get page structure name. I made hook and writing checking every page structure name.
I used JournalStructureLocalServiceUtil.getStructure()
but it didn't work and gave me errors and when i used JournalStructureLocalServiceUtil.getStructures()
it gave me the result
[{uuid=6e12b579-c03e-4bd1-a4b3-45c6259807c7, id=10802,groupId=88,
companyId=1, userId=2, userName=Haider Ghaleb, createDate=Wed Sep 05 12:23:43 GMT
2012, modifiedDate=Mon Sep 10 16:23:46 GMT 2012, structureId=10801,
parentStructureId=, name=Restriction, description=Testing testing, xsd= }]
Here i can find the structure name "Restriction". Anyone can help me in this, Also i used
BeanParamUtil.getString(article, request, "structureId")
BeanParamUtil.getLong(article, request, "groupId", scopeGroupId)
To get the structure ID and group ID.
You were nearly there with getting the name of the Structure! Try the following code:
String structureName = JournalStructureLocalServiceUtil.getStructure(groupId, structureId).getName(Locale.US, true);
Where "groupId" and "structureId" are the ones you've grabbed via BeanParamUtil or as Prakash has suggested (and it's also a better way):
String structureId = article.getStructureId();
long groupId = article.getGroupId();
The part that says getName(Locale.US, true);
will get the name of the structure with the Locale for US, or if there isn't one for the Locale US it will return the default Locale version.
This should do the trick for you.