use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class KnowledgeBaseUtil method addPortletBreadcrumbEntries.
protected static void addPortletBreadcrumbEntries(Map<String, Object> parameters, HttpServletRequest request, RenderResponse renderResponse) throws PortalException, SystemException {
PortletURL portletURL = renderResponse.createRenderURL();
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
portletURL.setParameter(entry.getKey(), value.toString());
}
long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
long parentResourceClassNameId = (Long) parameters.get("parentResourceClassNameId");
long parentResourcePrimKey = (Long) parameters.get("parentResourcePrimKey");
String mvcPath = (String) parameters.get("mvcPath");
if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString());
} else if (parentResourceClassNameId == kbFolderClassNameId) {
KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(parentResourcePrimKey);
addPortletBreadcrumbEntries(kbFolder.getClassNameId(), kbFolder.getParentKBFolderId(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbFolder.getName(), portletURL.toString());
} else {
KBArticle kbArticle = KBArticleServiceUtil.getLatestKBArticle(parentResourcePrimKey, WorkflowConstants.STATUS_ANY);
addPortletBreadcrumbEntries(kbArticle.getParentResourceClassNameId(), kbArticle.getParentResourcePrimKey(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbArticle.getTitle(), portletURL.toString());
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class CalendarPortlet method addCalendar.
protected void addCalendar(PortletRequest portletRequest, Set<Calendar> calendarsSet, long classNameId, long classPK) throws PortalException, SystemException {
CalendarResource calendarResource = CalendarResourceUtil.getCalendarResource(portletRequest, classNameId, classPK);
if (calendarResource == null) {
return;
}
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(calendarResource.getGroupId(), calendarResource.getCalendarResourceId());
for (Calendar calendar : calendars) {
if (!CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {
continue;
}
calendarsSet.add(calendar);
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class JournalArticleAssetRendererFactory method getURLAdd.
@Override
public PortletURL getURLAdd(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!JournalPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_ARTICLE)) {
return null;
}
long classTypeId = GetterUtil.getLong(liferayPortletRequest.getAttribute(WebKeys.ASSET_RENDERER_FACTORY_CLASS_TYPE_ID));
if ((classTypeId > 0) && !DDMStructurePermission.contains(themeDisplay.getPermissionChecker(), classTypeId, ActionKeys.VIEW)) {
return null;
}
PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.JOURNAL);
portletURL.setParameter("struts_action", "/journal/edit_article");
return portletURL;
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class MeetupsPortlet method updateMeetupsEntry.
public void updateMeetupsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (!permissionChecker.isCompanyAdmin()) {
return;
}
long meetupsEntryId = ParamUtil.getLong(uploadPortletRequest, "meetupsEntryId");
String title = ParamUtil.getString(uploadPortletRequest, "title");
String description = ParamUtil.getString(uploadPortletRequest, "description");
int startDateMonth = ParamUtil.getInteger(uploadPortletRequest, "startDateMonth");
int startDateDay = ParamUtil.getInteger(uploadPortletRequest, "startDateDay");
int startDateYear = ParamUtil.getInteger(uploadPortletRequest, "startDateYear");
int startDateHour = ParamUtil.getInteger(uploadPortletRequest, "startDateHour");
int startDateMinute = ParamUtil.getInteger(uploadPortletRequest, "startDateMinute");
int startDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "startDateAmPm");
if (startDateAmPm == Calendar.PM) {
startDateHour += 12;
}
int endDateMonth = ParamUtil.getInteger(uploadPortletRequest, "endDateMonth");
int endDateDay = ParamUtil.getInteger(uploadPortletRequest, "endDateDay");
int endDateYear = ParamUtil.getInteger(uploadPortletRequest, "endDateYear");
int endDateHour = ParamUtil.getInteger(uploadPortletRequest, "endDateHour");
int endDateMinute = ParamUtil.getInteger(uploadPortletRequest, "endDateMinute");
int endDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "endDateAmPm");
if (endDateAmPm == Calendar.PM) {
endDateHour += 12;
}
int totalAttendees = ParamUtil.getInteger(uploadPortletRequest, "totalAttendees");
int maxAttendees = ParamUtil.getInteger(uploadPortletRequest, "maxAttendees");
double price = ParamUtil.getDouble(uploadPortletRequest, "price");
File file = uploadPortletRequest.getFile("fileName");
byte[] bytes = FileUtil.getBytes(file);
if (meetupsEntryId <= 0) {
MeetupsEntryLocalServiceUtil.addMeetupsEntry(themeDisplay.getUserId(), title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, totalAttendees, maxAttendees, price, bytes);
} else {
MeetupsEntryLocalServiceUtil.updateMeetupsEntry(themeDisplay.getUserId(), meetupsEntryId, title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, totalAttendees, maxAttendees, price, bytes);
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class MicroblogsPortlet method updateMicroblogsEntry.
public void updateMicroblogsEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long microblogsEntryId = ParamUtil.getLong(actionRequest, "microblogsEntryId");
String content = ParamUtil.getString(actionRequest, "content");
int type = ParamUtil.getInteger(actionRequest, "type");
long receiverUserId = ParamUtil.getLong(actionRequest, "receiverUserId");
long receiverMicroblogsEntryId = ParamUtil.getLong(actionRequest, "receiverMicroblogsEntryId");
int socialRelationType = ParamUtil.getInteger(actionRequest, "socialRelationType");
ServiceContext serviceContext = ServiceContextFactory.getInstance(MicroblogsEntry.class.getName(), actionRequest);
String[] assetTagNames = getAssetTagNames(content);
serviceContext.setAssetTagNames(assetTagNames);
if (microblogsEntryId > 0) {
MicroblogsEntryServiceUtil.updateMicroblogsEntry(microblogsEntryId, content, socialRelationType, serviceContext);
} else {
MicroblogsEntryServiceUtil.addMicroblogsEntry(themeDisplay.getUserId(), content, type, receiverUserId, receiverMicroblogsEntryId, socialRelationType, serviceContext);
}
}
Aggregations