List of usage examples for com.liferay.portal.kernel.servlet SessionErrors isEmpty
public static boolean isEmpty(PortletRequest portletRequest)
From source file:com.rivetlogic.event.portlet.EventsManagementPortlet.java
License:Open Source License
public void addEditEvent(ActionRequest request, ActionResponse response) throws PortalException, SystemException, PortletException, IOException { Event event;// w ww .ja v a 2s. co m if (Validator.isNull(ParamUtil.getLong(request, EventPortletConstants.PARAMETER_RESOURCE_PRIMARY_KEY))) { event = createEvent(request, response); } else { event = editEvent(request, response); } if (!SessionErrors.isEmpty(request)) { request.setAttribute(WebKeys.EVENT_ENTRY, event); response.setRenderParameter(WebKeys.REDIRECT, PortalUtil.getCurrentURL(request)); response.setRenderParameter(WebKeys.MVC_PATH, WebKeys.EDIT_EVENT_PAGE); } }
From source file:com.rivetlogic.event.portlet.EventsManagementPortlet.java
License:Open Source License
public Event createEvent(ActionRequest request, ActionResponse response) throws PortletException, IOException, PortalException, SystemException { UploadPortletRequest upreq = PortalUtil.getUploadPortletRequest(request); ThemeDisplay themeDisplay = (ThemeDisplay) upreq.getAttribute(WebKeys.THEME_DISPLAY); Calendar newEventDate = getDateFromRequest(request, upreq, themeDisplay, true); Calendar newEventEndDate = getDateFromRequest(request, upreq, themeDisplay, false); validateStartEndDate(request, newEventDate, newEventEndDate); EventImpl event = new EventImpl(); event.setCompanyId(themeDisplay.getCompanyId()); event.setGroupId(themeDisplay.getCompanyGroupId()); event.setUserId(themeDisplay.getUserId()); event.setName(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_NAME)); event.setLocation(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_LOCATION)); event.setDescription(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_DESCRIPTION)); event.setEventDate(newEventDate.getTime()); event.setEventEndDate(newEventEndDate.getTime()); event.setPrivateEvent(ParamUtil.getBoolean(upreq, EventPortletConstants.PARAMETER_EVENT)); event.setCalendarId(ParamUtil.getLong(upreq, EventPortletConstants.PARAMETER_CALENDAR_ID)); List<String> errors = new ArrayList<String>(); EventValidator.validateEvent(event, errors); EventActionUtil.setErrors(errors, request); List<Participant> participants = createParticipants(request, upreq, themeDisplay, event); if (SessionErrors.isEmpty(request)) { saveNewEvent(request, themeDisplay, event, participants); }/*from w w w.j a v a2 s . co m*/ return event; }
From source file:com.rivetlogic.event.portlet.EventsManagementPortlet.java
License:Open Source License
public List<Participant> createParticipants(ActionRequest request, UploadPortletRequest upreq, ThemeDisplay themeDisplay, Event event) throws PortalException, SystemException, PortletException, IOException { List<Participant> participants = new ArrayList<Participant>(); List<String> repeatedEmails = new ArrayList<String>(); List<String> invalidEmails = new ArrayList<String>(); getParticipantsByCSV(request, upreq, participants, repeatedEmails, invalidEmails, event.getEventId()); getParticipansByForm(upreq, request, participants, repeatedEmails, invalidEmails, event.getEventId()); if (!SessionErrors.isEmpty(request)) { request.setAttribute(WebKeys.REPEATED_EMAILS, repeatedEmails); request.setAttribute(WebKeys.INVALID_EMAILS, invalidEmails); }/*from w w w.j ava2 s. c om*/ return participants; }
From source file:com.rivetlogic.event.portlet.EventsManagementPortlet.java
License:Open Source License
private Event editEvent(ActionRequest request, ActionResponse response) throws PortletException, IOException, PortalException, SystemException { UploadPortletRequest upreq = PortalUtil.getUploadPortletRequest(request); ThemeDisplay themeDisplay = (ThemeDisplay) upreq.getAttribute(WebKeys.THEME_DISPLAY); Calendar newEventDate = getDateFromRequest(request, upreq, themeDisplay, true); Calendar newEventEndDate = getDateFromRequest(request, upreq, themeDisplay, false); validateStartEndDate(request, newEventDate, newEventEndDate); Event dbEvent = EventLocalServiceUtil .getEvent(ParamUtil.getLong(upreq, EventPortletConstants.PARAMETER_RESOURCE_PRIMARY_KEY)); Event event = (Event) dbEvent.clone(); event.setName(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_NAME)); event.setLocation(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_LOCATION)); event.setDescription(ParamUtil.getString(upreq, EventPortletConstants.PARAMETER_DESCRIPTION)); event.setEventDate(newEventDate.getTime()); event.setEventEndDate(newEventEndDate.getTime()); event.setPrivateEvent(ParamUtil.getBoolean(upreq, EventPortletConstants.PARAMETER_EVENT)); event.setCalendarId(ParamUtil.getLong(upreq, EventPortletConstants.PARAMETER_CALENDAR_ID)); List<String> errors = new ArrayList<String>(); EventValidator.validateEvent(event, errors); EventActionUtil.setErrors(errors, request); List<Participant> participants = new ArrayList<Participant>(); boolean eventChanged = !dbEvent.equals(event); boolean useCSV = updateParticipants(request, upreq, event, participants); if (SessionErrors.isEmpty(request)) { saveEditEventChanges(event, participants, useCSV, eventChanged, themeDisplay, request); }// w w w. j a va 2s . c om return event; }
From source file:com.rivetlogic.event.portlet.EventsManagementPortlet.java
License:Open Source License
private boolean updateParticipants(ActionRequest request, UploadPortletRequest upreq, Event event, List<Participant> participants) throws SystemException, IOException, PortalException, PortletException { boolean useCSV = false; List<String> repeatedEmails = new ArrayList<String>(); List<String> invalidEmails = new ArrayList<String>(); getParticipantsByCSV(request, upreq, participants, repeatedEmails, invalidEmails, event.getEventId()); if (!participants.isEmpty()) { useCSV = true;//w ww . java2 s . co m } getParticipansByForm(upreq, request, participants, repeatedEmails, invalidEmails, event.getEventId()); if (!SessionErrors.isEmpty(request)) { request.setAttribute(WebKeys.REPEATED_EMAILS, repeatedEmails); request.setAttribute(WebKeys.INVALID_EMAILS, invalidEmails); } return useCSV; }
From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java
License:Open Source License
@Override public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { PortletSession portletSession = request.getPortletSession(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isSignedIn()) { if (((String) portletSession.getAttribute(ACCESS_TOKEN)) != null) { request.setAttribute(ACCESS_TOKEN, (String) portletSession.getAttribute(ACCESS_TOKEN)); request.setAttribute(NEED_AUTHORIZE, Boolean.FALSE); } else {//from w w w .ja v a2 s . c om request.setAttribute(NEED_AUTHORIZE, Boolean.TRUE); try { EvernoteUtil.authenticateEvernote(request, portletSession, themeDisplay); } catch (OAuthException e) { if (LOG.isDebugEnabled()) { LOG.error(EVERNOTE_AUTHENTICATION_ERROR, e); } if (SessionErrors.isEmpty(request)) { SessionMessages.add(request, request.getAttribute(WebKeys.PORTLET_ID) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); } SessionErrors.add(request, OAuthException.class); } } } super.doView(request, response); }
From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java
License:Open Source License
public void createNote(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { PortletSession portletSession = actionRequest.getPortletSession(); String accessToken = (String) portletSession.getAttribute(ACCESS_TOKEN); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, accessToken); NoteStoreClient noteStoreClient;// w w w . ja va 2s . c o m try { noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient(); // To create a new note, simply create a new Note object and fill in // attributes such as the note's title. Note note = new Note(); String title = ParamUtil.getString(actionRequest, NEW_NOTE_TITLE); if (Validator.isNull(title)) { title = LanguageUtil.get(themeDisplay.getLocale(), UNTITLED_NOTE_KEY); } // The content of an Evernote note is represented using Evernote // Markup Language // (ENML). The full ENML specification can be found in the Evernote // API // Overview at // http://dev.evernote.com/documentation/cloud/chapters/ENML.php StringBundler sb = new StringBundler(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") .append("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">") .append("<en-note>").append(ParamUtil.getString(actionRequest, "newNoteContent")) .append("</en-note>"); String notebookGuid = ParamUtil.getString(actionRequest, NEW_NOTE_NOTEBOOK); note.setTitle(title); note.setContent(sb.toString()); if (!notebookGuid.isEmpty()) note.setNotebookGuid(notebookGuid); // Finally, send the new note to Evernote using the createNote // method // The new Note object that is returned will contain // server-generated // attributes such as the new note's unique GUID. Note createdNote = noteStoreClient.createNote(note); String newNoteGuid = createdNote.getGuid(); if (LOG.isDebugEnabled()) { LOG.debug(GUID_SUCCESSFULL_CREATED_MESSAGE + newNoteGuid); } } catch (EDAMUserException e) { LOG.error(e); SessionErrors.add(actionRequest, EDAMUserException.class); } catch (EDAMSystemException e) { LOG.error(e); SessionErrors.add(actionRequest, EDAMSystemException.class); } catch (TException e) { LOG.error(e); SessionErrors.add(actionRequest, TException.class); } catch (EDAMNotFoundException e) { LOG.error(e); SessionErrors.add(actionRequest, EDAMNotFoundException.class); } if (!SessionErrors.isEmpty(actionRequest)) { actionResponse.setRenderParameter(MVC_PATH, getInitParameter(CREATE_NOTE_JSP)); } }
From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java
License:Open Source License
public void createNotebook(ActionRequest request, ActionResponse response) throws IOException, PortletException { PortletSession portletSession = request.getPortletSession(); String accessToken = (String) portletSession.getAttribute(ACCESS_TOKEN); EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, accessToken); NoteStoreClient noteStoreClient;//w w w .ja v a 2 s .c om String name = ParamUtil.getString(request, NEW_NOTEBOOK_NAME); if (Validator.isNotNull(name)) { try { noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient(); // To create a new note, simply create a new Note object and fill in // attributes such as the note's title. Notebook notebook = new Notebook(); notebook.setName(name); Notebook createdNotebook = noteStoreClient.createNotebook(notebook); String newNotebookGuid = createdNotebook.getGuid(); if (LOG.isDebugEnabled()) { LOG.debug(GUID_SUCCESSFULL_CREATED_MESSAGE + newNotebookGuid); } } catch (EDAMUserException e) { LOG.error(e); SessionErrors.add(request, EDAMUserException.class); } catch (EDAMSystemException e) { LOG.error(e); SessionErrors.add(request, EDAMSystemException.class); } catch (TException e) { LOG.error(e); SessionErrors.add(request, TException.class); } } else { SessionErrors.add(request, NOTEBOOK_EMPTY_ERROR); } if (!SessionErrors.isEmpty(request)) { response.setRenderParameter(MVC_PATH, getInitParameter(CREATE_NOTE_JSP)); } }
From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java
License:Open Source License
public void deleteNote(ActionRequest request, ActionResponse response) { PortletSession portletSession = request.getPortletSession(); String accessToken = (String) portletSession.getAttribute(ACCESS_TOKEN); EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, accessToken); NoteStoreClient noteStoreClient;//from w ww .j a v a 2 s. c o m try { noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient(); String noteGuid = ParamUtil.getString(request, NOTE_GUID_DELETE); if (!Validator.isNull(noteGuid)) { noteStoreClient.deleteNote(noteGuid); if (LOG.isDebugEnabled()) { LOG.debug(GUID_SUCCESSFULL_DELETED_MESSAGE + noteGuid); } } else { throw new NoNoteException(); } } catch (EDAMUserException e) { LOG.error(e); SessionErrors.add(request, EDAMUserException.class); } catch (EDAMSystemException e) { LOG.error(e); SessionErrors.add(request, EDAMSystemException.class); } catch (TException e) { LOG.error(e); SessionErrors.add(request, TException.class); } catch (EDAMNotFoundException e) { LOG.error(e); SessionErrors.add(request, EDAMNotFoundException.class); } catch (NoNoteException e) { LOG.error(e); SessionErrors.add(request, NoNoteException.class); } if (!SessionErrors.isEmpty(request)) { response.setRenderParameter(MVC_PATH, viewTemplate); } }
From source file:com.slemarchand.peoplepublisher.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = actionRequest.getPreferences(); if (cmd.equals(Constants.TRANSLATE)) { super.processAction(portletConfig, actionRequest, actionResponse); } else if (cmd.equals(Constants.UPDATE)) { try {// www . j ava 2 s .c o m String selectionStyle = getParameter(actionRequest, "selectionStyle"); if (selectionStyle.equals("dynamic")) { updateQueryLogic(actionRequest, preferences); } super.processAction(portletConfig, actionRequest, actionResponse); } catch (DuplicateQueryRuleException e) { SessionErrors.add(actionRequest, e.getClass(), e); } } else { if (cmd.equals("add-scope")) { addScope(actionRequest, preferences); } else if (cmd.equals("add-selection")) { peoplePublisher.addSelection(actionRequest, preferences, portletResource); } else if (cmd.equals("move-selection-down")) { moveSelectionDown(actionRequest, preferences); } else if (cmd.equals("move-selection-up")) { moveSelectionUp(actionRequest, preferences); } else if (cmd.equals("remove-selection")) { removeSelection(actionRequest, preferences); } else if (cmd.equals("remove-scope")) { removeScope(actionRequest, preferences); } else if (cmd.equals("select-scope")) { setScopes(actionRequest, preferences); } else if (cmd.equals("selection-style")) { setSelectionStyle(actionRequest, preferences); } if (SessionErrors.isEmpty(actionRequest)) { preferences.store(); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); } String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } }