@Override protected PortletPreferences doImportData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences, String data) throws Exception { portletDataContext.importPermissions( CalendarPermission.RESOURCE_NAME, portletDataContext.getSourceGroupId(), portletDataContext.getScopeGroupId()); Element rootElement = portletDataContext.getImportDataRootElement(); for (Element eventElement : rootElement.elements("event")) { String path = eventElement.attributeValue("path"); if (!portletDataContext.isPathNotProcessed(path)) { continue; } CalEvent event = (CalEvent) portletDataContext.getZipEntryAsObject(path); importEvent(portletDataContext, eventElement, event); } return null; }
protected void readExpandoTables(PortletDataContext portletDataContext) throws Exception { String xml = portletDataContext.getZipEntryAsString( ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/expando-tables.xml"); if (xml == null) { return; } Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); List<Element> expandoTableElements = rootElement.elements("expando-table"); for (Element expandoTableElement : expandoTableElements) { String className = expandoTableElement.attributeValue("class-name"); ExpandoTable expandoTable = null; try { expandoTable = ExpandoTableLocalServiceUtil.getDefaultTable( portletDataContext.getCompanyId(), className); } catch (NoSuchTableException nste) { expandoTable = ExpandoTableLocalServiceUtil.addDefaultTable( portletDataContext.getCompanyId(), className); } List<Element> expandoColumnElements = expandoTableElement.elements("expando-column"); for (Element expandoColumnElement : expandoColumnElements) { long columnId = GetterUtil.getLong(expandoColumnElement.attributeValue("column-id")); String name = expandoColumnElement.attributeValue("name"); int type = GetterUtil.getInteger(expandoColumnElement.attributeValue("type")); String defaultData = expandoColumnElement.elementText("default-data"); String typeSettings = expandoColumnElement.elementText("type-settings"); Serializable defaultDataObject = ExpandoConverterUtil.getAttributeFromString(type, defaultData); ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), name); if (expandoColumn != null) { ExpandoColumnLocalServiceUtil.updateColumn( expandoColumn.getColumnId(), name, type, defaultDataObject); } else { expandoColumn = ExpandoColumnLocalServiceUtil.addColumn( expandoTable.getTableId(), name, type, defaultDataObject); } ExpandoColumnLocalServiceUtil.updateTypeSettings(expandoColumn.getColumnId(), typeSettings); portletDataContext.importPermissions( ExpandoColumn.class, columnId, expandoColumn.getColumnId()); } } }