How to get the global (company) group id in Liferay without accessing ThemeDisplay
?
P.S.: with ThemeDisplay
it is simple: themeDisplay.ge
If you need this info for Document Library, you can use
public static long getDefaultCompanyId(){
long companyId = 0;
try{ companyId = getDefaultCompany().getCompanyId(); }
catch(Exception e){ System.out.println(e.getClass() + " " +e.getMessage()); }
return companyId;
}
public static long getDefaultGroupId (){
long companyId = getDefaultCompanyId();
long globalGroupId = 0L;
Group group = null;
try {
group = GroupLocalServiceUtil.getGroup(companyId, "Guest");
} catch (PortalException | SystemException e) {
e.printStackTrace();
return globalGroupId;
}
globalGroupId = group.getGroupId();
return globalGroupId;
}