@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String columns = ParamUtil.getString(actionRequest, "columns"); String[] exportFileNames = actionRequest.getParameterValues("exportFileName"); String[] exportNames = actionRequest.getParameterValues("exportName"); String[] exportScripts = actionRequest.getParameterValues("exportScript"); setPreference(actionRequest, "columns", columns.split(",")); setPreference(actionRequest, "exportFileName", exportFileNames); setPreference(actionRequest, "exportName", exportNames); setPreference(actionRequest, "exportScript", exportScripts); super.processAction(portletConfig, actionRequest, actionResponse); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, TaskRecord taskRecord, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editTaskRecord"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(taskRecord.getGroupId()), false); portletURL.setParameter( "taskRecordId", String.valueOf(taskRecord.getTaskRecordId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { _log.info("doProcessAction()"); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); _log.info("cmd = " + cmd); if (cmd.equals(Constants.DELETE)) { deleteBackgroundTasks(actionRequest, actionResponse); } else if (cmd.equals(Constants.EXPORT)) { exportTaskRecords(actionRequest, actionResponse); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); } }
/** * Saves the global aspect of the configuration * * @param request The request * @param response The response * @throws IOException If something goes wrong * @throws PortletException If something goes wrong */ @ProcessAction(name = ACTION_NAME_SAVE_GLOBAL) public void actionSaveGlobal(ActionRequest request, ActionResponse response) throws IOException, PortletException { String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); String adtUuid = ParamUtil.get(request, FORM_FIELD_ADT_UUID, StringPool.BLANK); boolean doSearchOnStartup = ParamUtil.getBoolean(request, FORM_FIELD_DO_SEARCH_ON_STARTUP, false); if (!PATTERN_UUID.matcher(adtUuid).matches()) { adtUuid = StringPool.BLANK; } String doSearchOnStartupKeywords = ParamUtil.getString(request, FORM_FIELD_DO_SEARCH_ON_STARTUP_KEYWORDS, FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS); this.searchService.saveGlobalSettings(adtUuid, doSearchOnStartup, doSearchOnStartupKeywords, request.getPreferences()); SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); if (!redirectUrl.isEmpty()) { response.sendRedirect(redirectUrl); } }
/** * This action saves the Liferay facet configuration for a given tab * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @ProcessAction(name = ACTION_NAME_SAVE_FACET_CONFIG) public void actionSaveFacetConfig(ActionRequest request, ActionResponse response) throws PortletException, IOException { String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK); String facetClassName = ParamUtil.get(request, FORM_FIELD_FACET_CLASS_NAME, StringPool.BLANK); String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); PortletPreferences preferences = request.getPreferences(); FlashlightSearchConfiguration configuration = this.searchService.readConfiguration(preferences); SearchFacet targetFacet = this.getSearchFacetFromRequest(tabId, facetClassName, configuration); if(targetFacet != null) { JSONObject facetConfiguration = targetFacet.getJSONData(request); targetFacet.getFacetConfiguration().setDataJSONObject(facetConfiguration); this.searchService.saveSearchFacetConfig(configuration.getTabs().get(tabId), targetFacet, preferences); SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); response.sendRedirect(redirectUrl); } }
/** * Deletes a tab from the configuration * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @ProcessAction(name = ACTION_NAME_DELETE_TAB) public void actionDeleteTab(ActionRequest request, ActionResponse response) throws PortletException, IOException { String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK); String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); if (tabId != null && PATTERN_UUID.matcher(tabId).matches()) { PortletPreferences preferences = request.getPreferences(); Map<String, FlashlightSearchConfigurationTab> tabs = this.searchService.readConfiguration(preferences).getTabs(); if (tabs.containsKey(tabId)) { this.searchService.deleteConfigurationTab(tabId, preferences); } } SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); if (!redirectUrl.isEmpty()) { response.sendRedirect(redirectUrl); } }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Contact contact, Layout layout, String redirect) throws Exception { _log.info("getSaveAndContinueRedirect()"); PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editContact"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(contact.getGroupId()), false); portletURL.setParameter( "contactId", String.valueOf(contact.getContactId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals(Constants.DELETE)) { deleteBackgroundTasks(actionRequest, actionResponse); } else if (cmd.equals(Constants.EXPORT)) { exportContacts(actionRequest, actionResponse); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); } }
@Override public DummyGenerator<JournalContext> create(ActionRequest request) { long createContentsType = 0; DummyGenerator<JournalContext> generator = _JournalSimpleDummyGenerator; createContentsType = ParamUtil.getLong(request, "createContentsType", LDFPortletKeys.MB_CATEGORY_CREATE); if (createContentsType == LDFPortletKeys.WCM_DUMMY_CONTENTS_CREATE) { generator = _JournalRandomDummyGenerator; } else if (createContentsType == LDFPortletKeys.WCM_STRUCTURE_TEMPLATE_SELECT_CREATE) { generator = _JournalStructureTemplateDummyGenerator; } return generator; }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) { try { DummyGenerator<OrgContext> dummyGenerator = _orgDummyFactory.create(request); dummyGenerator.create(request); } catch (Exception e) { hideDefaultSuccessMessage(request); _log.error(e, e); } response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); SessionMessages.add(request, "success"); }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) throws Exception { try { response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); DummyGenerator<MBContext> dummyGenerator = _MBDummyFactory.create(request); dummyGenerator.create(request); SessionMessages.add(request, "success"); } catch (Exception e) { hideDefaultSuccessMessage(request); SessionErrors.add(request,Exception.class); _log.error(e, e); } }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) { try { DummyGenerator<CategoryContext> dummyGenerator = _categoryDummyFactory.create(request); dummyGenerator.create(request); } catch (Exception e) { hideDefaultSuccessMessage(request); _log.error(e, e); return; } response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); SessionMessages.add(request, "success"); }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) { try { DummyGenerator<DLContext> dummyGenerator = _dlDummyFactory.create(request); dummyGenerator.create(request); } catch (Exception e) { hideDefaultSuccessMessage(request); _log.error(e, e); } response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); SessionMessages.add(request, "success"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String linkList = ParamUtil.getString(actionRequest, DummyFactoryConfiguration.CONF_LINKLIST); String urlList = ParamUtil.getString(actionRequest, DummyFactoryConfiguration.CONF_URLLIST); if (_log.isDebugEnabled()) { _log.debug("Link List :" + linkList); _log.debug("URL List :" + urlList); } List<String> errors = Lists.newArrayList(); if (validate(linkList, errors)) { setPreference(actionRequest, DummyFactoryConfiguration.CONF_LINKLIST, linkList); setPreference(actionRequest, DummyFactoryConfiguration.CONF_URLLIST, urlList); SessionMessages.add(actionRequest, "prefs-success"); } super.processAction(portletConfig, actionRequest, actionResponse); }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) { try { DummyGenerator<JournalContext> dummyGenerator = _journalDummyFactory.create(request); dummyGenerator.create(request); } catch (Exception e) { hideDefaultSuccessMessage(request); _log.error(e, e); } response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); SessionMessages.add(request, "success"); }
public MBContext(ActionRequest actionRequest) { ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute( WebKeys.THEME_DISPLAY); //Fetch data numberOfMB = ParamUtil.getLong(actionRequest, "numberOfMB",0); categoryId = ParamUtil.getLong(actionRequest, "categoryId",MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID); subject = ParamUtil.getString(actionRequest, "subject","dummy subject"); body = ParamUtil.getString(actionRequest, "body","dummy body"); anonymous = ParamUtil.getBoolean(actionRequest, "anonymous",false); allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks",false); priority = ParamUtil.getDouble(actionRequest, "priority",0.0); parentCategoryId = ParamUtil.getLong(actionRequest, "parentCategoryId",MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID); categoryName = ParamUtil.getString(actionRequest, "categoryName","dummy Category Name"); description = ParamUtil.getString(actionRequest, "description","dummy description"); threadId = ParamUtil.getLong(actionRequest, "threadId",0); siteGroupId = ParamUtil.getLong(actionRequest, "siteGroupId",themeDisplay.getScopeGroupId()); // Sites String[] groupsStrIds = ParamUtil.getStringValues(actionRequest, "groupIds", new String[] { String.valueOf(themeDisplay.getScopeGroupId()) }); groupIds = CommonUtil.convertStringToLongArray(groupsStrIds); }
/** * Create Dummy data * * @param request * @throws Exception */ public void create(ActionRequest request) throws Exception { T paramContext = getContext(request); if(!validate(paramContext)) { throw new Exception("Validation Error"); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), request); paramContext.setThemeDisplay(themeDisplay); paramContext.setServiceContext(serviceContext); exec(request, paramContext); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Measurement measurement, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editMeasurement"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(measurement.getGroupId()), false); portletURL.setParameter( "measurementId", String.valueOf(measurement.getMeasurementId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
protected void validateFile(ActionRequest actionRequest, ActionResponse actionResponse, String folderName) throws Exception { _log.info("validateFile()"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); FileEntry fileEntry = ExportImportHelperUtil.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName); InputStream inputStream = null; try { inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(), false); // TODO: validate uploaded file JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); // // if ((weakMissingReferences != null) && // !weakMissingReferences.isEmpty()) { // // jsonObject.put("warningMessages", // StagingUtil.getWarningMessagesJSONArray(themeDisplay.getLocale(), // weakMissingReferences)); // } JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } finally { StreamUtil.cleanUp(inputStream); } }
protected ExportImportConfiguration getExportImportConfiguration(ActionRequest actionRequest) throws Exception { Map<String, Serializable> exportTaskRecordsSettingsMap = null; long exportImportConfigurationId = ParamUtil.getLong(actionRequest, "exportImportConfigurationId"); if (exportImportConfigurationId > 0) { ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .fetchExportImportConfiguration(exportImportConfigurationId); if (exportImportConfiguration != null) { exportTaskRecordsSettingsMap = exportImportConfiguration.getSettingsMap(); } } ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (exportTaskRecordsSettingsMap == null) { exportTaskRecordsSettingsMap = ExportImportTaskRecordsConfigurationSettingsMapFactory .buildExportTaskRecordsSettingsMap(themeDisplay.getCompanyId(), themeDisplay.getUserId(), themeDisplay.getPlid(), themeDisplay.getScopeGroupId(), PortletKeys.TIMETRACKER, actionRequest.getParameterMap(), themeDisplay.getLocale(), TimeZone.getDefault(), null); } String taskName = ParamUtil.getString(actionRequest, "name"); if (Validator.isNull(taskName)) { taskName = "task-records"; } // TODO: remove dependendency from ExportImportConfigurationConstants return _exportImportConfigurationLocalService.addDraftExportImportConfiguration(themeDisplay.getUserId(), taskName, ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT, exportTaskRecordsSettingsMap); }
private static final int _getPortletRequestLength(final Object request) { if (!(request instanceof ActionRequest)) return -1; return ((ActionRequest) request).getContentLength(); }
public UploadActionRequestWrapper( ExternalContext ec, Map<String, String[]> params) { super((ActionRequest)ec.getRequest()); _response = (ActionResponse)ec.getResponse(); _manager = new UploadRequestManager(ec, params); }
public ContactGroupTerm(ActionRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); contactGroupId = ParamUtil.getLong(request, CONTACT_GROUP_ID); groupId = themeDisplay.getScopeGroupId(); companyId = themeDisplay.getCompanyId(); userId = themeDisplay.getUserId(); createDate = ParamUtil.getDate(request, CREATE_DATE, DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT)); modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE, DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT)); groupName = ParamUtil.getString(request, GROUP_NAME); contactList = ParamUtil.getString(request, CONTACT_LIST); shared = ParamUtil.getInteger(request, SHARED); }
public SiteContext(ActionRequest actionRequest) { //Fetch data numberOfSites = ParamUtil.getLong(actionRequest, "numberOfSites",0); baseSiteName = ParamUtil.getString(actionRequest, "baseSiteName","dummy"); siteType = ParamUtil.getInteger(actionRequest, "siteType", GroupConstants.TYPE_SITE_OPEN); parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupId", GroupConstants.DEFAULT_PARENT_GROUP_ID); liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId", GroupConstants.DEFAULT_LIVE_GROUP_ID); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership", true); site = ParamUtil.getBoolean(actionRequest, "site", true); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", false); active = ParamUtil.getBoolean(actionRequest, "active", true); }
/** * Constructor * * @param actionRequest * @throws PortalException */ public JournalContext(ActionRequest actionRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); // Fetch data numberOfArticles = ParamUtil.getLong(actionRequest, "numberOfArticles", 1); baseTitle = ParamUtil.getString(actionRequest, "baseTitle", ""); baseArticle = ParamUtil.getString(actionRequest, "baseArticle", ""); folderId = ParamUtil.getLong(actionRequest, "folderId", 0); totalParagraphs = ParamUtil.getInteger(actionRequest, "totalParagraphs", 0); titleWords = ParamUtil.getInteger(actionRequest, "titleWords", 0); randomAmount = ParamUtil.getInteger(actionRequest, "randomAmount", 0); createContentsType = ParamUtil.getLong(actionRequest, "createContentsType", 0); linkLists = ParamUtil.getString(actionRequest, "linkLists", ""); ddmStructureId = ParamUtil.getLong(actionRequest, "ddmStructureId", 0); ddmTemplateId = ParamUtil.getLong(actionRequest, "ddmTemplateId", 0); // Locales String[] defLang = { LocaleUtil.getDefault().toString() }; locales = ParamUtil.getStringValues(actionRequest, "locales", defLang); // Sites String[] groupsStrIds = ParamUtil.getStringValues(actionRequest, "groupIds", new String[] { String.valueOf(themeDisplay.getScopeGroupId()) }); groupIds = CommonUtil.convertStringToLongArray(groupsStrIds); // Fetch default locale defaultLocale = LocaleUtil.fromLanguageId(themeDisplay.getUser().getLanguageId()); descriptionMap = new ConcurrentHashMap<Locale, String>(); descriptionMap.put(defaultLocale, StringPool.BLANK); }
/** * Start Progress * * @param request ActionRequest * @param loaderInit */ public void start(ActionRequest request) { _request = request; //Tracking progress start _progressTracker = new ProgressTracker(""); ProgressTrackerThreadLocal.setProgressTracker(_progressTracker); _progressTracker.start(request); }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) { try { // Create users createUsers(actionRequest, actionResponse); } catch (Exception e) { hideDefaultSuccessMessage(actionRequest); _log.error(e, e); } actionResponse.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); }
@Override protected void doProcessAction(ActionRequest request, ActionResponse response) { try { DummyGenerator<SiteContext> dummyGenerator = _siteDummyFactory.create(request); dummyGenerator.create(request); } catch (Exception e) { hideDefaultSuccessMessage(request); _log.error(e, e); } response.setRenderParameter("mvcRenderCommandName", LDFPortletKeys.COMMON); SessionMessages.add(request, "success"); }
@Override public DummyGenerator<MBContext> create(ActionRequest request) { long createContentsType = 0; DummyGenerator<MBContext> generator = _MBThreadDummyGenerator; createContentsType = ParamUtil.getLong(request, "createContentsType", LDFPortletKeys.MB_CATEGORY_CREATE); if (createContentsType == LDFPortletKeys.MB_CATEGORY_CREATE) { generator = _MBCategoryDummyGenerator; } else if(createContentsType == LDFPortletKeys.MB_REPLY_CREATE) { generator = _MBReplyDummyGenerator; } return generator; }
@Override public DummyGenerator<CategoryContext> create(ActionRequest request) { long createContentsType = 0; DummyGenerator<CategoryContext> generator = _categoryDefaultDummyGenerator; createContentsType = ParamUtil.getLong(request, "createContentsType", LDFPortletKeys.C_CATEGORY_CREATE); if (createContentsType == LDFPortletKeys.C_VOCABULARY_CREATE) { generator = _vocabularyDefaultDummyGenerator; } return generator; }
public CategoryContext(ActionRequest actionRequest) { //Fetch data numberOfCategories = ParamUtil.getLong(actionRequest, "numberOfCategories",0); baseCategoryName = ParamUtil.getString(actionRequest, "baseCategoryName",""); groupId = ParamUtil.getLong(actionRequest, "group",0); vocabularyId = ParamUtil.getLong(actionRequest, "vocabularyId",0); numberOfVocabulary = ParamUtil.getLong(actionRequest, "numberOfVocabulary",0); baseVocabularyName = ParamUtil.getString(actionRequest, "baseVocabularyName",""); parentCategoryId = ParamUtil.getLong(actionRequest, "parentCategoryId",0); }
public PageContext(ActionRequest actionRequest) { //Fetch data numberOfpages = ParamUtil.getLong(actionRequest, "numberOfpages",0); basePageName = ParamUtil.getString(actionRequest, "basePageName",""); groupId = ParamUtil.getLong(actionRequest, "group",0); parentLayoutId = ParamUtil.getLong(actionRequest, "parentLayoutId",LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); layoutType = ParamUtil.getString(actionRequest, "layoutType",LayoutConstants.TYPE_PORTLET); privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout", false); hidden = ParamUtil.getBoolean(actionRequest, "hidden", false); }
public DLContext(ActionRequest actionRequest) { ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute( WebKeys.THEME_DISPLAY); // Fetch data numberOfDocuments = ParamUtil.getLong(actionRequest, "numberOfDocuments", 1); baseDocumentTitle = ParamUtil.getString(actionRequest, "baseDocumentTitle", ""); baseDocumentDescription = ParamUtil.getString(actionRequest, "baseDocumentDescription", ""); folderId = ParamUtil.getLong(actionRequest, "folderId", 0); // Sites groupId = ParamUtil.getLong(actionRequest, "groupId", themeDisplay.getScopeGroupId()); }
public OrgContext(ActionRequest actionRequest) { //Fetch data startIndex = ParamUtil.getLong(actionRequest, "startIndex",1); numberOfOrganizations = ParamUtil.getLong(actionRequest, "numberOfOrganizations",0); baseOrganizationName = ParamUtil.getString(actionRequest, "baseOrganizationName",""); parentOrganizationId = ParamUtil.getInteger(actionRequest, "parentOrganizationId", OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID); organizationSiteCreate = ParamUtil.getBoolean(actionRequest, "organizationSiteCreate", false); }
protected void addTempFileEntry(ActionRequest actionRequest, String folderName) throws Exception { _log.info("addTempFileEntry()"); UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); checkExceededSizeLimit(uploadPortletRequest); long groupId = ParamUtil.getLong(actionRequest, "groupId"); deleteTempFileEntry(groupId, folderName); InputStream inputStream = null; try { String sourceFileName = uploadPortletRequest.getFileName("file"); inputStream = uploadPortletRequest.getFileAsStream("file"); String contentType = uploadPortletRequest.getContentType("file"); _layoutService.addTempFileEntry(groupId, folderName, sourceFileName, inputStream, contentType); } catch (Exception e) { UploadException uploadException = (UploadException) actionRequest.getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (cause instanceof FileUploadBase.IOFileUploadException) { if (_log.isInfoEnabled()) { _log.info("Temporary upload was cancelled"); } } if (uploadException.isExceededFileSizeLimit()) { throw new FileSizeException(cause); } if (uploadException.isExceededUploadRequestSizeLimit()) { throw new UploadRequestSizeException(cause); } } else { throw e; } } finally { StreamUtil.cleanUp(inputStream); } }
protected void deleteTempFileEntry(ActionRequest actionRequest, ActionResponse actionResponse, String folderName) throws Exception { _log.info("deleteTempFileEntry()"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { String fileName = ParamUtil.getString(actionRequest, "fileName"); _layoutService.deleteTempFileEntry(themeDisplay.getScopeGroupId(), folderName, fileName); jsonObject.put("deleted", Boolean.TRUE); } catch (Exception e) { String errorMessage = themeDisplay.translate("an-unexpected-error-occurred-while-deleting-the-file"); jsonObject.put("deleted", Boolean.FALSE); jsonObject.put("errorMessage", errorMessage); } JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); }
protected void handleUploadException(ActionRequest actionRequest, ActionResponse actionResponse, String folderName, Exception e) throws Exception { _log.info("handleUploadException()"); HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); response.setContentType(ContentTypes.TEXT_HTML); response.setStatus(HttpServletResponse.SC_OK); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); deleteTempFileEntry(themeDisplay.getScopeGroupId(), folderName); JSONObject jsonObject = StagingUtil.getExceptionMessagesJSONObject(themeDisplay.getLocale(), e, (ExportImportConfiguration) null); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); }
protected void importData(ActionRequest actionRequest, String folderName) throws Exception { _log.info("importData()"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); FileEntry fileEntry = ExportImportHelperUtil.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName); InputStream inputStream = null; try { inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(), false); importData(actionRequest, fileEntry.getTitle(), inputStream); deleteTempFileEntry(groupId, folderName); } finally { StreamUtil.cleanUp(inputStream); } }