List of usage examples for com.liferay.portal.kernel.util MapUtil getInteger
public static int getInteger(Map<String, ?> map, String key)
From source file:com.liferay.dynamic.data.mapping.form.renderer.internal.DDMFormPagesTemplateContextFactoryTest.java
License:Open Source License
protected void assertColumnSize(int expectedSize, Map<String, Object> columnTemplateContex) { Assert.assertEquals(expectedSize, MapUtil.getInteger(columnTemplateContex, "size")); }
From source file:com.liferay.exportimport.content.processor.base.BaseTextExportImportContentProcessor.java
License:Open Source License
protected String replaceExportDLReferences(PortletDataContext portletDataContext, StagedModel stagedModel, String content, boolean exportReferencedContent) throws Exception { Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getGroupId()); if (group.isStagingGroup()) { group = group.getLiveGroup();/*from www. java 2 s . co m*/ } if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) { return content; } StringBuilder sb = new StringBuilder(content); String contextPath = PortalUtil.getPathContext(); String[] patterns = { contextPath.concat("/c/document_library/get_file?"), contextPath.concat("/documents/"), contextPath.concat("/image/image_gallery?") }; int beginPos = -1; int endPos = content.length(); while (true) { beginPos = StringUtil.lastIndexOfAny(content, patterns, endPos); if (beginPos == -1) { break; } Map<String, String[]> dlReferenceParameters = getDLReferenceParameters( portletDataContext.getScopeGroupId(), content, beginPos + contextPath.length(), endPos); FileEntry fileEntry = getFileEntry(dlReferenceParameters); if (fileEntry == null) { endPos = beginPos - 1; continue; } endPos = MapUtil.getInteger(dlReferenceParameters, "endPos"); try { if (exportReferencedContent && !fileEntry.isInTrash()) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, stagedModel, fileEntry, PortletDataContext.REFERENCE_TYPE_DEPENDENCY); } else { Element entityElement = portletDataContext.getExportDataElement(stagedModel); String referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY; if (fileEntry.isInTrash()) { referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY_DISPOSABLE; } portletDataContext.addReferenceElement(stagedModel, entityElement, fileEntry, referenceType, true); } String path = ExportImportPathUtil.getModelPath(fileEntry); StringBundler exportedReferenceSB = new StringBundler(6); exportedReferenceSB.append("[$dl-reference="); exportedReferenceSB.append(path); exportedReferenceSB.append("$]"); if (fileEntry.isInTrash()) { String originalReference = sb.substring(beginPos, endPos); exportedReferenceSB.append("[#dl-reference="); exportedReferenceSB.append(originalReference); exportedReferenceSB.append("#]"); } sb.replace(beginPos, endPos, exportedReferenceSB.toString()); int deleteTimestampParametersOffset = beginPos; if (fileEntry.isInTrash()) { deleteTimestampParametersOffset = sb.indexOf("[#dl-reference=", beginPos); } deleteTimestampParameters(sb, deleteTimestampParametersOffset); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } else if (_log.isWarnEnabled()) { StringBundler exceptionSB = new StringBundler(6); exceptionSB.append("Unable to process file entry "); exceptionSB.append(fileEntry.getFileEntryId()); exceptionSB.append(" for staged model "); exceptionSB.append(stagedModel.getModelClassName()); exceptionSB.append(" with primary key "); exceptionSB.append(stagedModel.getPrimaryKeyObj()); _log.warn(exceptionSB.toString()); } } endPos = beginPos - 1; } return sb.toString(); }
From source file:com.liferay.exportimport.internal.content.processor.DLReferencesExportImportContentProcessor.java
License:Open Source License
protected String replaceExportDLReferences(PortletDataContext portletDataContext, StagedModel stagedModel, String content, boolean exportReferencedContent) throws Exception { Group group = _groupLocalService.getGroup(portletDataContext.getGroupId()); if (group.isStagingGroup()) { group = group.getLiveGroup();/* ww w . j a v a 2 s .com*/ } if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) { return content; } StringBuilder sb = new StringBuilder(content); String contextPath = _portal.getPathContext(); String[] patterns = { contextPath.concat("/c/document_library/get_file?"), contextPath.concat("/documents/"), contextPath.concat("/image/image_gallery?") }; int beginPos = -1; int endPos = content.length(); while (true) { beginPos = StringUtil.lastIndexOfAny(content, patterns, endPos); if (beginPos == -1) { break; } Map<String, String[]> dlReferenceParameters = getDLReferenceParameters( portletDataContext.getScopeGroupId(), content, beginPos + contextPath.length(), endPos); FileEntry fileEntry = getFileEntry(dlReferenceParameters); if (fileEntry == null) { endPos = beginPos - 1; continue; } endPos = MapUtil.getInteger(dlReferenceParameters, "endPos"); try { if (exportReferencedContent && !fileEntry.isInTrash()) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, stagedModel, fileEntry, PortletDataContext.REFERENCE_TYPE_DEPENDENCY); } else { Element entityElement = portletDataContext.getExportDataElement(stagedModel); String referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY; if (fileEntry.isInTrash()) { referenceType = PortletDataContext.REFERENCE_TYPE_DEPENDENCY_DISPOSABLE; } portletDataContext.addReferenceElement(stagedModel, entityElement, fileEntry, referenceType, true); } String path = ExportImportPathUtil.getModelPath(fileEntry); StringBundler exportedReferenceSB = new StringBundler(6); exportedReferenceSB.append("[$dl-reference="); exportedReferenceSB.append(path); exportedReferenceSB.append("$]"); if (fileEntry.isInTrash()) { String originalReference = sb.substring(beginPos, endPos); exportedReferenceSB.append("[#dl-reference="); exportedReferenceSB.append(originalReference); exportedReferenceSB.append("#]"); } sb.replace(beginPos, endPos, exportedReferenceSB.toString()); int deleteTimestampParametersOffset = beginPos; if (fileEntry.isInTrash()) { deleteTimestampParametersOffset = sb.indexOf("[#dl-reference=", beginPos); } deleteTimestampParameters(sb, deleteTimestampParametersOffset); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } else if (_log.isWarnEnabled()) { StringBundler exceptionSB = new StringBundler(6); exceptionSB.append("Unable to process file entry "); exceptionSB.append(fileEntry.getFileEntryId()); exceptionSB.append(" for staged model "); exceptionSB.append(stagedModel.getModelClassName()); exceptionSB.append(" with primary key "); exceptionSB.append(stagedModel.getPrimaryKeyObj()); _log.warn(exceptionSB.toString()); } } endPos = beginPos - 1; } return sb.toString(); }
From source file:com.liferay.exportimport.messaging.LayoutsRemotePublisherMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message, MessageStatus messageStatus) throws PortalException { long exportImportConfigurationId = GetterUtil.getLong(message.getPayload()); ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .fetchExportImportConfiguration(exportImportConfigurationId); if (exportImportConfiguration == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to find export import configuration with ID " + exportImportConfigurationId); }// w w w . j av a 2 s .c o m return; } messageStatus.setPayload(exportImportConfiguration); Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); long userId = MapUtil.getLong(settingsMap, "userId"); long sourceGroupId = MapUtil.getLong(settingsMap, "sourceGroupId"); boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout"); Map<Long, Boolean> layoutIdMap = (Map<Long, Boolean>) settingsMap.get("layoutIdMap"); Map<String, String[]> parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap"); String remoteAddress = MapUtil.getString(settingsMap, "remoteAddress"); int remotePort = MapUtil.getInteger(settingsMap, "remotePort"); String remotePathContext = MapUtil.getString(settingsMap, "remotePathContext"); boolean secureConnection = MapUtil.getBoolean(settingsMap, "secureConnection"); long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId"); boolean remotePrivateLayout = MapUtil.getBoolean(settingsMap, "remotePrivateLayout"); initThreadLocals(userId, parameterMap); User user = _userLocalService.getUserById(userId); CompanyThreadLocal.setCompanyId(user.getCompanyId()); try { _staging.copyRemoteLayouts(sourceGroupId, privateLayout, layoutIdMap, exportImportConfiguration.getName(), parameterMap, remoteAddress, remotePort, remotePathContext, secureConnection, targetGroupId, remotePrivateLayout); } finally { resetThreadLocals(); } }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public String buildRemoteURL(ExportImportConfiguration exportImportConfiguration) { Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); String remoteAddress = MapUtil.getString(settingsMap, "remoteAddress"); int remotePort = MapUtil.getInteger(settingsMap, "remotePort"); String remotePathContext = MapUtil.getString(settingsMap, "remotePathContext"); boolean secureConnection = MapUtil.getBoolean(settingsMap, "secureConnection"); return buildRemoteURL(remoteAddress, remotePort, remotePathContext, secureConnection); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public long copyRemoteLayouts(ExportImportConfiguration exportImportConfiguration) throws PortalException { Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId"); String remoteAddress = MapUtil.getString(settingsMap, "remoteAddress"); int remotePort = MapUtil.getInteger(settingsMap, "remotePort"); String remotePathContext = MapUtil.getString(settingsMap, "remotePathContext"); boolean secureConnection = MapUtil.getBoolean(settingsMap, "secureConnection"); validateRemoteGroup(exportImportConfiguration.getGroupId(), targetGroupId, remoteAddress, remotePort, remotePathContext, secureConnection); boolean remotePrivateLayout = MapUtil.getBoolean(settingsMap, "remotePrivateLayout"); return doCopyRemoteLayouts(exportImportConfiguration, remoteAddress, remotePort, remotePathContext, secureConnection, remotePrivateLayout); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public long publishToRemote(PortletRequest portletRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser();//from w ww. j av a2 s . c o m long groupId = ParamUtil.getLong(portletRequest, "groupId"); Group group = _groupLocalService.getGroup(groupId); UnicodeProperties groupTypeSettingsProperties = group.getTypeSettingsProperties(); long remoteGroupId = ParamUtil.getLong(portletRequest, "remoteGroupId", GetterUtil.getLong(groupTypeSettingsProperties.getProperty("remoteGroupId"))); Map<String, Serializable> publishLayoutRemoteSettingsMap = null; String remoteAddress = null; int remotePort = 0; String remotePathContext = null; boolean secureConnection = false; boolean remotePrivateLayout = false; long exportImportConfigurationId = ParamUtil.getLong(portletRequest, "exportImportConfigurationId"); String name = ParamUtil.getString(portletRequest, "name"); if (exportImportConfigurationId > 0) { ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .fetchExportImportConfiguration(exportImportConfigurationId); if (exportImportConfiguration != null) { publishLayoutRemoteSettingsMap = exportImportConfiguration.getSettingsMap(); remoteAddress = MapUtil.getString(publishLayoutRemoteSettingsMap, "remoteAddress"); remotePort = MapUtil.getInteger(publishLayoutRemoteSettingsMap, "remotePort"); remotePathContext = MapUtil.getString(publishLayoutRemoteSettingsMap, "remotePathContext"); secureConnection = MapUtil.getBoolean(publishLayoutRemoteSettingsMap, "secureConnection"); remotePrivateLayout = MapUtil.getBoolean(publishLayoutRemoteSettingsMap, "remotePrivateLayout"); if (!Validator.isBlank(name)) { Map<String, String[]> parameterMap = (Map<String, String[]>) publishLayoutRemoteSettingsMap .get("parameterMap"); parameterMap.put("name", new String[] { name }); } } } if (publishLayoutRemoteSettingsMap == null) { boolean privateLayout = getPrivateLayout(portletRequest); Map<Long, Boolean> layoutIdMap = _exportImportHelper.getLayoutIdMap(portletRequest); Map<String, String[]> parameterMap = ExportImportConfigurationParameterMapFactory .buildParameterMap(portletRequest); remoteAddress = ParamUtil.getString(portletRequest, "remoteAddress", groupTypeSettingsProperties.getProperty("remoteAddress")); remotePort = ParamUtil.getInteger(portletRequest, "remotePort", GetterUtil.getInteger(groupTypeSettingsProperties.getProperty("remotePort"))); remotePathContext = ParamUtil.getString(portletRequest, "remotePathContext", groupTypeSettingsProperties.getProperty("remotePathContext")); secureConnection = ParamUtil.getBoolean(portletRequest, "secureConnection", GetterUtil.getBoolean(groupTypeSettingsProperties.getProperty("secureConnection"))); remotePrivateLayout = ParamUtil.getBoolean(portletRequest, "remotePrivateLayout"); publishLayoutRemoteSettingsMap = ExportImportConfigurationSettingsMapFactory .buildPublishLayoutRemoteSettingsMap(user.getUserId(), groupId, privateLayout, layoutIdMap, parameterMap, remoteAddress, remotePort, remotePathContext, secureConnection, remoteGroupId, remotePrivateLayout, user.getLocale(), user.getTimeZone()); } remoteAddress = stripProtocolFromRemoteAddress(remoteAddress); validateRemote(groupId, remoteAddress, remotePort, remotePathContext, secureConnection, remoteGroupId); ExportImportConfiguration exportImportConfiguration = null; if (Validator.isNotNull(name)) { exportImportConfiguration = _exportImportConfigurationLocalService.addDraftExportImportConfiguration( user.getUserId(), name, ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE, publishLayoutRemoteSettingsMap); } else { exportImportConfiguration = _exportImportConfigurationLocalService.addDraftExportImportConfiguration( user.getUserId(), ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE, publishLayoutRemoteSettingsMap); } return doCopyRemoteLayouts(exportImportConfiguration, remoteAddress, remotePort, remotePathContext, secureConnection, remotePrivateLayout); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public void schedulePublishToRemote(PortletRequest portletRequest) throws PortalException { long groupId = ParamUtil.getLong(portletRequest, "groupId"); Group group = _groupLocalService.getGroup(groupId); UnicodeProperties groupTypeSettingsProperties = group.getTypeSettingsProperties(); boolean privateLayout = false; Map<Long, Boolean> layoutIdMap = null; Map<String, String[]> parameterMap = null; String remoteAddress = null;//from ww w.ja v a 2 s. c o m int remotePort = 0; String remotePathContext = null; boolean secureConnection = false; boolean remotePrivateLayout = false; long exportImportConfigurationId = ParamUtil.getLong(portletRequest, "exportImportConfigurationId"); if (exportImportConfigurationId > 0) { ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService .fetchExportImportConfiguration(exportImportConfigurationId); if (exportImportConfiguration != null) { Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout"); layoutIdMap = (Map<Long, Boolean>) settingsMap.get("layoutIdMap"); parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap"); remoteAddress = MapUtil.getString(settingsMap, "remoteAddress"); remotePort = MapUtil.getInteger(settingsMap, "remotePort"); remotePathContext = MapUtil.getString(settingsMap, "remotePathContext"); secureConnection = MapUtil.getBoolean(settingsMap, "secureConnection"); remotePrivateLayout = MapUtil.getBoolean(settingsMap, "remotePrivateLayout"); } } if (parameterMap == null) { privateLayout = getPrivateLayout(portletRequest); layoutIdMap = _exportImportHelper.getLayoutIdMap(portletRequest); parameterMap = ExportImportConfigurationParameterMapFactory.buildParameterMap(portletRequest); remoteAddress = ParamUtil.getString(portletRequest, "remoteAddress", groupTypeSettingsProperties.getProperty("remoteAddress")); remotePort = ParamUtil.getInteger(portletRequest, "remotePort", GetterUtil.getInteger(groupTypeSettingsProperties.getProperty("remotePort"))); remotePathContext = ParamUtil.getString(portletRequest, "remotePathContext", groupTypeSettingsProperties.getProperty("remotePathContext")); secureConnection = ParamUtil.getBoolean(portletRequest, "secureConnection", GetterUtil.getBoolean(groupTypeSettingsProperties.getProperty("secureConnection"))); remotePrivateLayout = ParamUtil.getBoolean(portletRequest, "remotePrivateLayout"); } remoteAddress = stripProtocolFromRemoteAddress(remoteAddress); long remoteGroupId = ParamUtil.getLong(portletRequest, "remoteGroupId", GetterUtil.getLong(groupTypeSettingsProperties.getProperty("remoteGroupId"))); validateRemote(groupId, remoteAddress, remotePort, remotePathContext, secureConnection, remoteGroupId); ScheduleInformation scheduleInformation = getScheduleInformation(portletRequest, groupId, true); String name = ParamUtil.getString(portletRequest, "name"); _layoutService.schedulePublishToRemote(groupId, privateLayout, layoutIdMap, parameterMap, remoteAddress, remotePort, remotePathContext, secureConnection, remoteGroupId, remotePrivateLayout, null, null, scheduleInformation.getGroupName(), scheduleInformation.getCronText(), scheduleInformation.getStartDate(), scheduleInformation.getSchedulerEndDate(), name); }