use of com.liferay.portal.theme.ThemeDisplay in project sw360portal by sw360.
the class UserPortlet method createOrganizations.
public void createOrganizations(PortletRequest request, Iterable<String> departments) throws PortalException, SystemException {
ImmutableSet<String> headDepartments = FluentIterable.from(departments).transform(department -> extractHeadDept(department)).toSet();
Map<String, Long> organizationIds = new HashMap<>();
ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long companyId = themeDisplay.getCompanyId();
for (String headDepartment : headDepartments) {
long organizationId;
try {
organizationId = OrganizationLocalServiceUtil.getOrganizationId(companyId, headDepartment);
} catch (SystemException e) {
organizationId = 0;
}
if (organizationId == 0) {
// The organization does not yet exist
Organization organization = createOrganization(serviceContext, headDepartment, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID);
organizationId = organization.getOrganizationId();
}
organizationIds.put(headDepartment, organizationId);
}
for (String department : departments) {
long organizationId;
try {
organizationId = OrganizationLocalServiceUtil.getOrganizationId(companyId, department);
} catch (SystemException e) {
organizationId = 0;
}
if (organizationId == 0) {
// The organization does not yet exist
createOrganization(serviceContext, department, organizationIds.get(extractHeadDept(department)).intValue());
}
}
}
use of com.liferay.portal.theme.ThemeDisplay in project sw360portal by sw360.
the class ComponentPortlet method createDetailLinkTemplate.
private LiferayPortletURL createDetailLinkTemplate(PortletRequest request) {
String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID);
ThemeDisplay tD = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long plid = tD.getPlid();
LiferayPortletURL componentUrl = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
componentUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
return componentUrl;
}
use of com.liferay.portal.theme.ThemeDisplay in project sw360portal by sw360.
the class LifeRayUserSession method getEmailFromRequest.
/**
* Get the email of the currently logged-in user
*
* @param request Java portlet render request
*/
public static String getEmailFromRequest(PortletRequest request) {
String email = null;
// Logged-in user can be fetched from Liferay's ThemeDisplay
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
if (themeDisplay.isSignedIn()) {
com.liferay.portal.model.User user = themeDisplay.getUser();
// Get email address from user
if (user != null) {
email = user.getEmailAddress();
}
}
return email;
}
Aggregations