use of com.liferay.portal.security.permission.PermissionChecker 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);
}
}
Aggregations