Search in sources :

Example 16 with PermissionChecker

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);
    }
}
Also used : PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) File(java.io.File)

Aggregations

PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)16 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)10 IOException (java.io.IOException)3 Gadget (com.liferay.opensocial.model.Gadget)2 User (com.liferay.portal.model.User)2 ServletException (javax.servlet.ServletException)2 Calendar (com.liferay.calendar.model.Calendar)1 CalendarResource (com.liferay.calendar.model.CalendarResource)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 JSONArray (com.liferay.portal.kernel.json.JSONArray)1 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 Folder (com.liferay.portal.kernel.repository.model.Folder)1 Indexer (com.liferay.portal.kernel.search.Indexer)1 SearchPermissionChecker (com.liferay.portal.kernel.search.SearchPermissionChecker)1 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)1