@RequestMapping("EDIT") public void savePreferences( ActionRequest request, ActionResponse response, @RequestParam("topicsToUpdate") Integer topicsToUpdate) throws PortletException { List<TopicSubscription> newSubscription = new ArrayList<TopicSubscription>(); for (int i = 0; i < topicsToUpdate; i++) { Long topicId = Long.valueOf(request.getParameter("topicId_" + i)); // Will be numeric for existing, persisted TopicSubscription // instances; blank (due to null id field) otherwise String topicSubId = request.getParameter("topicSubId_" + i).trim(); Boolean subscribed = Boolean.valueOf(request.getParameter("subscribed_" + i)); Topic topic = announcementService.getTopic(topicId); // Make sure that any pushed_forced topics weren't sneakingly removed (by tweaking the URL, // for example) if (topic.getSubscriptionMethod() == Topic.PUSHED_FORCED) { subscribed = new Boolean(true); } TopicSubscription ts = new TopicSubscription(request.getRemoteUser(), topic, subscribed); if (topicSubId.length() > 0) { // This TopicSubscription represents an existing, persisted entity try { ts.setId(Long.valueOf(topicSubId)); } catch (NumberFormatException nfe) { logger.debug(nfe.getMessage(), nfe); } } newSubscription.add(ts); } if (newSubscription.size() > 0) { try { announcementService.addOrSaveTopicSubscription(newSubscription); } catch (Exception e) { logger.error( "ERROR saving TopicSubscriptions for user " + request.getRemoteUser() + ". Message: " + e.getMessage()); } } response.setPortletMode(PortletMode.VIEW); response.setRenderParameter("action", "displayAnnouncements"); }
/** * Handles deletion of announcements * * @param topicId * @param annId * @param response * @throws PortletException */ @RequestMapping(params = "action=deleteAnnouncement") public void actionDeleteAnnouncement( @RequestParam("topicId") Long topicId, @RequestParam("annId") Long annId, ActionRequest request, ActionResponse response) throws PortletException { Topic topic = announcementService.getTopic(topicId); Announcement ann = announcementService.getAnnouncement(annId); UserPermissionChecker upChecker = userPermissionCheckerFactory.createUserPermissionChecker(request, topic); if (upChecker.isAdmin() || upChecker.isModerator() || (upChecker.isAuthor() && ann.getAuthor() != null && ann.getAuthor().equals(request.getRemoteUser()))) { // the person deleting the announcement must be the author, a moderator or an admin announcementService.deleteAnnouncement(ann); } else { throw new UnauthorizedException("You do not have permission to delete this announcement"); } response.setRenderParameter("topicId", topicId.toString()); response.setRenderParameter("action", "showTopic"); }
@ActionMapping(params = "myaction=updateTextArea") public void updateProduct( ActionRequest request, ActionResponse response, @ModelAttribute(displayTextCommantString) DisplayTextCommantVO textAreaVO, BindingResult result, Model model) { java.util.Date date1 = new java.util.Date(); Date dt = new Date(date1.getTime()); textAreaVO.setCommentstatus( TGPProcurementPropertiesUtil.getProperty( TGPProcurementConstants.TGP_MARKETINFO_COMMENT_STATUS_ENABLE)); textAreaVO.setCreatedbyuserid(Long.valueOf(request.getRemoteUser())); textAreaVO.setModifiedbyuserid(Long.valueOf(request.getRemoteUser())); textAreaVO.setCommoditytype( TGPProcurementPropertiesUtil.getProperty(TGPProcurementConstants.TGP_MARKETINFO_POWER)); try { if (!("".equalsIgnoreCase(textAreaVO.getTextcomment()))) { tgpMarketInfoDelegate.saveTextAreaComment(textAreaVO); listOfDisplayTextCommantVO = tgpMarketInfoDelegate.displayTextCommentforSupplier( dt, TGPProcurementPropertiesUtil.getProperty( TGPProcurementConstants.TGP_MARKETINFO_POWER)); response.setRenderParameter( TGPProcurementConstants.SUCCESS_MESSAGE, TGPProcurementConstants.TGP_TEXT_AREA_ADDED_SUCESSFULLY); } else { response.setRenderParameter( TGPProcurementConstants.ERROR_MESSAGE, TGPProcurementConstants.TGP_TEXT_AREA_ERROR_MSG); } } catch (TGPProcurementException e) { response.setRenderParameter(TGPProcurementConstants.ERROR_MESSAGE, e.getErrorCode()); } listOfDisplayTextCommantVO.add(textAreaVO); model.addAttribute(displayTextCommantVOString, listOfDisplayTextCommantVO); displayTextComment(model); }
@Override public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!_openId.isEnabled(themeDisplay.getCompanyId())) { throw new PrincipalException.MustBeEnabled( themeDisplay.getCompanyId(), OpenId.class.getName()); } if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.READ)) { String redirect = readOpenIdResponse(themeDisplay, actionRequest); if (Validator.isNull(redirect)) { redirect = themeDisplay.getURLSignIn(); } redirect = PortalUtil.escapeRedirect(redirect); actionResponse.sendRedirect(redirect); } else { sendOpenIdRequest(themeDisplay, actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof OpenIDException) { if (_log.isInfoEnabled()) { _log.info("Error communicating with OpenID provider: " + e.getMessage()); } SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { SessionErrors.add(actionRequest, e.getClass()); } else { _log.error("Error processing the OpenID login", e); PortalUtil.sendError(e, actionRequest, actionResponse); } } }
protected boolean redirectToLogin(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { if (actionRequest.getRemoteUser() == null) { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); SessionErrors.add(request, PrincipalException.class.getName()); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); actionResponse.sendRedirect(themeDisplay.getURLSignIn()); return true; } else { return false; } }
@ActionMapping(params = "myaction=upLoadCSVDataforGasFile") public void upLoadCSVDataforGas( ActionRequest request, ActionResponse response, @ModelAttribute(tgpUploadCSVDataforMarketInfoString) UploadCSVDataforMarketInfo tgpUploadCSVDataforMarketInfo, BindingResult result, Model model) { try { if (!("" .equalsIgnoreCase(tgpUploadCSVDataforMarketInfo.getFileData().getFileItem().getName()))) { tgpUploadCSVDataforMarketInfo.setCreatedbyUserid(Long.valueOf(request.getRemoteUser())); tgpUploadCSVDataforMarketInfo.setCommoditytype( TGPProcurementPropertiesUtil.getProperty(TGPProcurementConstants.TGP_MARKETINFO_POWER)); List<UploadCSVDataforMarketInfo> uploadCSVDataforMarketInfoSet = tgpMarketInfoDelegate.getUploaedDataforMarketInfo(tgpUploadCSVDataforMarketInfo); if (uploadCSVDataforMarketInfoSet.size() > 0) { response.setRenderParameter( TGPProcurementConstants.SUCCESS_MESSAGE, TGPProcurementConstants.TGP_UPLOAD_MARKET_INFO_SUCCESS_MESSAGE); } else { response.setRenderParameter( TGPProcurementConstants.ERROR_MESSAGE, TGPProcurementConstants.TGP_UPLOAD_MARKET_INFO_FILE_UPLOAD_ERROR_MESSAGE); } } else { response.setRenderParameter( TGPProcurementConstants.ERROR_MESSAGE, TGPProcurementConstants.TGP_MARKET_INFO_UPLOAD_ENERGY_REPORT_NO_FILE_ERROR_MSG); } } catch (TGPProcurementException tgpEx) { response.setRenderParameter(TGPProcurementConstants.ERROR_MESSAGE, tgpEx.getErrorCode()); if (TGPObjectUtil.isDefined(tgpEx.getArguments())) { response.setRenderParameter( TGPProcurementConstants.MESSAGE_ARGUMENTS, tgpEx.getArguments()); } } catch (Exception ex) { response.setRenderParameter( TGPProcurementConstants.ERROR_MESSAGE, TGPProcurementConstants.TGP_UPLOAD_MARKET_INFO_FILE_UPLOAD_ERROR_MESSAGE); } }
@Override public void doFilter(ActionRequest request, ActionResponse response, FilterChain chain) throws IOException, PortletException { String username = request.getRemoteUser(); OAuthProvider oauthProvider = getOAuthProvider(); AccessToken accessToken; if (username != null && oauthProvider != null) { accessToken = oauthProvider.loadAccessToken(username); } else { accessToken = null; } if (oauthProvider != null) { requestContext.saveOAuthInfo(oauthProvider, accessToken); } chain.doFilter(request, response); }
/** * Saves the announcement * * @param req * @param res * @throws PortletException */ @RequestMapping(params = "action=addAnnouncement") public void actionAddAnnouncementForm( @ModelAttribute("announcement") Announcement announcement, BindingResult result, SessionStatus status, ActionRequest req, ActionResponse res) throws PortletException { // First verify the user has AUTHOR permission for this topic UserPermissionChecker upChecker = userPermissionCheckerFactory.createUserPermissionChecker(req, announcement.getParent()); if (!(upChecker.isAdmin() || upChecker.isModerator() || upChecker.isAuthor())) { throw new UnauthorizedException( "You do not have permission to create an announcement in this topic"); } // Next validate the announcement new AnnouncementValidator(getAllowOpenEndDate(req), getAllowEmptyMessage(req)) .validate(announcement, result); if (result.hasErrors()) { res.setRenderParameter("action", "addAnnouncement"); return; } if (!result.hasErrors()) { if (!announcement.hasId()) { // add the automatic data announcement.setAuthor(req.getRemoteUser()); announcement.setCreated(new Date()); announcementService.addOrSaveAnnouncement(announcement); } else { announcementService.mergeAnnouncement(announcement); } status.setComplete(); res.setRenderParameter("topicId", announcement.getParent().getId().toString()); res.setRenderParameter("action", "showTopic"); } }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled( company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } PortletConfig portletConfig = (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { throw new PrincipalException("Unable to create anonymous account"); } if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create( actionRequest, LoginPortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { jsonObject = updateIncompleteUser(actionRequest, actionResponse); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { User user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); PortalUtil.sendError(e, actionRequest, actionResponse); } } }
/** * Do upload. * * @param request the request * @param response the response * @param model the model * @throws NullPointerException the null pointer exception */ private void doUpload( ActionRequest request, ActionResponse response, ProducerVideoDataInputEditModel model) throws NullPointerException { File destination = null; String fileDestPhad = ""; // upload this file to the user home desitation try { Producer producer = model.getProducer(); Video video = model.getVideo(); Host host = model.getHost(); // pick the multipart file content data MultipartFile file = model.getContactFile(); // get the producers home directory String producerHomeDir = producer.getHomeDir(); // Current Path for the current User String tmpath = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/"; // get the original file name String originalFileName = file.getOriginalFilename(); originalFileName = replaceBadCharacters(originalFileName); // upload ############ if mp4 upload or tar // the upload-file has to end on 'mp4' or 'mp3' or 'm4v' or 'm4a' or // pdf String[] p = originalFileName.split("\\."); int l = p.length; l--; String fileFormat = p[l].toLowerCase(); /** rename start* */ String[] parameter = originalFileName.split("\\_"); // the parameter array length has to be 4, // if not -> this is not l2go upload // so, have to rename SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); String newDate = format.format(getUploadDate()).toString(); if (parameter.length != 4) originalFileName = model.getLectureseries().getNumber() + "_" + model.getMetadata().getCreator() + "_" + newDate + "." + fileFormat; originalFileName = replaceBadCharacters(originalFileName); // now reset the parameter array from above parameter = originalFileName.split("\\_"); /** rename end* */ if ((fileFormat.equalsIgnoreCase("mp4") || fileFormat.equalsIgnoreCase("tar") || fileFormat.equalsIgnoreCase("mp3")) && (video.getFilename() == null)) { // build the filename without file format String[] ofn = originalFileName.split("\\_"); String filename = ofn[0] + "_" + ofn[1] + "_" + ofn[2] + "_" + ofn[3].split("\\.")[0]; // extract time and date from the originalFileName // the upload-file has to end on 'mp4' or 'mp3' or 'm4v' or flv String parameter4 = parameter[3]; // check parameter 3 - this is the date String l2gDate = parameter[2]; // and parameter 4 - this is the time String l2gTime = parameter4.split("\\.")[0]; String generationDate = l2gDate + "_" + l2gTime; // does filename exists in the DB? if (((VideoDao) getDaoBeanFactory().getBean("videoDao")).filenameExists(filename) && !fileFormat.equalsIgnoreCase("tar")) // check // only for mp4 and mp3 filename = ofn[0] + "_" + ofn[1] + "-" + video.getId() + "_" + ofn[2] + "_" + ofn[3].split("\\.")[0]; // update video-database, only if mp4 or tar or mp3 - this is the first upload if (fileFormat.equalsIgnoreCase("mp4") || fileFormat.equalsIgnoreCase("tar") || fileFormat.equalsIgnoreCase("mp3")) { // update the data row for this file-> set the new original // filename in the ´url´ field from the database table if (fileFormat.equalsIgnoreCase("mp3")) video.setFilename(filename + ".mp3"); else video.setFilename(filename + ".mp4"); // and save the extracted date and time in the database video.setGenerationDate(generationDate); String secfilename = Security.createSecureFileName(); if (fileFormat.equalsIgnoreCase("mp4")) secfilename = secfilename + ".mp4"; if (fileFormat.equalsIgnoreCase("mp3")) secfilename = secfilename + ".mp3"; if (fileFormat.equalsIgnoreCase("tar")) secfilename = secfilename + ".mp4"; ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .updateById( video.getTitle(), video.getTags(), video.getLectureseriesId(), video.getEigentuemerId(), video.getProducerId(), video.getContainerFormat(), video.getFilename(), video.getResolution(), video.getDuration(), producer.getHostId(), 0, // textId video.getFileSize(), // filesize video.getGenerationDate(), false, // openAccess false, // downloadLink video.getMetadataId(), // metadataId secfilename, video.getHits(), video.isPermittedToSegment(), video.getFacilityId(), video.getCitation2go(), video.getId()); ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .setUploadDate(getUploadDate(), video.getId()); Video v = ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .getById(video.getId()) .iterator() .next(); // is mp4 or tar and not openaccess if (!v.isOpenaccess()) { destination = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getSecureFilename()); fileDestPhad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getSPreffix(); model.setOpenAccess(false); model.setSecureUrl(v.getSecureUrl()); } else { destination = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getFilename()); fileDestPhad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getSPreffix(); model.setOpenAccess(true); model.setSecureUrl(null); } } } else { // update model // if mp4, mp3, m4v, pdf file upload // get the video name -> 11.123_sturm_2009-09-11_10-00 Integer vidId = new Integer(request.getParameter("videoId")); Video v = ((VideoDao) getDaoBeanFactory().getBean("videoDao")).getById(vidId).iterator().next(); if (v.isOpenaccess()) fileDestPhad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getPreffix(); else fileDestPhad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producerHomeDir + "/" + v.getSPreffix(); // if mp4 if (fileFormat.equalsIgnoreCase("mp4")) { ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .setUploadDate(getUploadDate(), video.getId()); destination = new File(fileDestPhad + ".mp4"); } // if mp3 if (fileFormat.equalsIgnoreCase("mp3")) { destination = new File(fileDestPhad + ".mp3"); model.setMp3File(fileDestPhad + ".mp3"); } // if m4v if (fileFormat.equalsIgnoreCase("m4v")) { destination = new File(fileDestPhad + ".m4v"); model.setM4vFile(fileDestPhad + ".m4v"); } // if pdf if (fileFormat.equalsIgnoreCase("pdf")) { destination = new File(fileDestPhad + ".pdf"); model.setPdfFile(fileDestPhad + ".pdf"); } // if m4a if (fileFormat.equalsIgnoreCase("m4a")) { destination = new File(fileDestPhad + ".m4a"); model.setM4aFile(fileDestPhad + ".m4a"); } // if xml if (fileFormat.equalsIgnoreCase("xml")) destination = new File(fileDestPhad + ".xml"); } // before mp4-upload is completed, delete all thumbnails from file if (fileFormat.equalsIgnoreCase("mp4")) ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")) .deleteThumbnails(video); // UPLOAD this file to the user home destination file.transferTo(destination); // change upload status after update prozess Upload upload = ((UploadDao) getDaoBeanFactory().getBean("uploadDao")) .getByUserIdDesc(producer.getId()) .iterator() .next(); ((UploadDao) getDaoBeanFactory().getBean("uploadDao")) .updateById( upload.getId(), upload.getUserId(), upload.getContentLength(), upload.getTimestamp(), 1, video.getId()); // get updated video from DB Video uploadetVideo = ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .getById(video.getId()) .iterator() .next(); // update RSS try { ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")) .RSS(uploadetVideo, "mp4", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")) .RSS(uploadetVideo, "mp3", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")) .RSS(uploadetVideo, "m4v", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")) .RSS(uploadetVideo, "m4a", model); } catch (Exception e) { } // TAR -- unpack the tar file in the home directory and rename all files if (fileFormat.equalsIgnoreCase("tar")) { // unpack all files and rename try { String videopre = uploadetVideo.getPreffix(); String videoSpre = uploadetVideo.getSPreffix(); String tarFileName = tmpath + uploadetVideo.getSecureFilename(); File dest = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir()); // extract all files from archive TarExtraktor.untarFiles(tarFileName, dest); // get extracted files File mp4 = new File(tmpath + videopre + ".mp4"); File mp3 = new File(tmpath + videopre + ".mp3"); File m4v = new File(tmpath + videopre + ".m4v"); File m4a = new File(tmpath + videopre + ".m4a"); // rename them File smp4 = new File(tmpath + videoSpre + ".mp4"); File smp3 = new File(tmpath + videoSpre + ".mp3"); File sm4v = new File(tmpath + videoSpre + ".m4v"); File sm4a = new File(tmpath + videoSpre + ".m4a"); // do mp4.renameTo(smp4); mp3.renameTo(smp3); m4v.renameTo(sm4v); m4a.renameTo(sm4a); // delete the tar file File tar = new File(tmpath + videoSpre + ".tar"); tar.delete(); // update model model.setM4aFile(tmpath + videoSpre + ".m4a"); model.setMp3File(tmpath + videoSpre + ".mp3"); model.setM4vFile(tmpath + videoSpre + ".m4v"); } catch (IOException e) { } } // write the htaccess String url = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producer.getHomeDir() + "/"; String remoteUserId = request.getRemoteUser(); int remoteUId = new Integer(remoteUserId); ((Htaccess) getUtilityBeanFactory().getBean("htaccess")) .makeHtaccess( url, ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .getLockedByProducerId(remoteUId)); // and update metadata if not xml if (!fileFormat.equalsIgnoreCase("xml")) updateFfmpegMetadata(uploadetVideo, model); // and check for xml-file try { String[] arg = new String[1]; // destination if (video.isOpenaccess()) arg[0] = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + video.getFilenamePreffix() + ".xml"; else arg[0] = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + video.getSecureFilename().split("\\.")[0] + ".xml"; // if XML file exists, import it to database File xml = new File(arg[0]); if (xml.isFile()) { if (this.importXmlToDatabase(arg, video)) { xml.delete(); } } } catch (NullPointerException npe) { } model.setContactFile(null); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // set current site for browsing! int currentSeite = 1; try { currentSeite = new Integer(request.getParameter("videoSeite")); } catch (Exception e) { } model.setCurrentSeite(currentSeite); }
@Override public void processAction( ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletName = portletConfig.getPortletName(); if (!portletName.equals(PortletKeys.FAST_LOGIN)) { throw new PrincipalException(); } if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create( actionRequest, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { jsonObject = updateIncompleteUser(actionRequest, actionResponse); writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof DuplicateUserEmailAddressException) { User user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactFirstNameException || e instanceof ContactFullNameException || e instanceof ContactLastNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof ReservedUserEmailAddressException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); PortalUtil.sendError(e, actionRequest, actionResponse); } } }