protected void exportPortletData( PortletDataContext portletDataContext, Portlet portlet, Layout layout, javax.portlet.PortletPreferences jxPreferences, Element parentElement) throws Exception { PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); if (portletDataHandler == null) { return; } String portletId = portlet.getPortletId(); Group liveGroup = layout.getGroup(); if (liveGroup.isStagingGroup()) { liveGroup = liveGroup.getLiveGroup(); } boolean staged = liveGroup.isStagedPortlet(portlet.getRootPortletId()); if (!staged && ImportExportThreadLocal.isLayoutExportInProcess()) { if (_log.isDebugEnabled()) { _log.debug( "Not exporting data for " + portletId + " because it is configured not to be staged"); } return; } if (_log.isDebugEnabled()) { _log.debug("Exporting data for " + portletId); } StringBundler sb = new StringBundler(4); sb.append(portletDataContext.getPortletPath(portletId)); sb.append(StringPool.SLASH); if (portlet.isPreferencesUniquePerLayout()) { sb.append(layout.getPlid()); } else { sb.append(portletDataContext.getScopeGroupId()); } sb.append("/portlet-data.xml"); String path = sb.toString(); if (!portletDataContext.isPathNotProcessed(path)) { return; } long lastPublishDate = GetterUtil.getLong(jxPreferences.getValue("last-publish-date", StringPool.BLANK)); Date startDate = portletDataContext.getStartDate(); if ((lastPublishDate > 0) && (startDate != null) && (lastPublishDate < startDate.getTime())) { portletDataContext.setStartDate(new Date(lastPublishDate)); } String data = null; long groupId = portletDataContext.getGroupId(); portletDataContext.setGroupId(portletDataContext.getScopeGroupId()); try { data = portletDataHandler.exportData(portletDataContext, portletId, jxPreferences); } catch (Exception e) { throw new SystemException(e); } finally { portletDataContext.setGroupId(groupId); portletDataContext.setStartDate(startDate); } if (Validator.isNull(data)) { if (_log.isDebugEnabled()) { _log.debug("Not exporting data for " + portletId + " because null data was returned"); } return; } Element portletDataElement = parentElement.addElement("portlet-data"); portletDataElement.addAttribute("path", path); portletDataContext.addZipEntry(path, data); Date endDate = portletDataContext.getEndDate(); if (endDate != null) { try { jxPreferences.setValue("last-publish-date", String.valueOf(endDate.getTime())); jxPreferences.store(); } catch (Exception e) { _log.error(e, e); } } }