@Override protected void doImportStagedModel( PortletDataContext portletDataContext, Element ruleGroupInstanceElement, String path, MDRRuleGroupInstance ruleGroupInstance) throws Exception { long userId = portletDataContext.getUserId(ruleGroupInstance.getUserUuid()); String ruleGroupPath = StagedModelPathUtil.getPath( portletDataContext, MDRRuleGroup.class.getName(), ruleGroupInstance.getRuleGroupId()); MDRRuleGroup ruleGroup = (MDRRuleGroup) portletDataContext.getZipEntryAsObject(ruleGroupPath); StagedModelDataHandlerUtil.importStagedModel( portletDataContext, ruleGroupInstanceElement, ruleGroupPath, ruleGroup); Map<Long, Long> ruleGroupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(MDRRuleGroup.class); Long ruleGroupId = MapUtil.getLong( ruleGroupIds, ruleGroupInstance.getRuleGroupId(), ruleGroupInstance.getRuleGroupId()); long classPK = 0; String layoutUuid = ruleGroupInstanceElement.attributeValue("layout-uuid"); try { if (Validator.isNotNull(layoutUuid)) { Layout layout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId( layoutUuid, portletDataContext.getScopeGroupId(), portletDataContext.isPrivateLayout()); classPK = layout.getPrimaryKey(); } else { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet( portletDataContext.getScopeGroupId(), portletDataContext.isPrivateLayout()); classPK = layoutSet.getLayoutSetId(); } } catch (Exception e) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(5); sb.append("Layout "); sb.append(layoutUuid); sb.append(" is missing for rule group instance "); sb.append(ruleGroupInstance.getRuleGroupInstanceId()); sb.append(", skipping this rule group instance."); _log.warn(sb.toString()); } return; } ServiceContext serviceContext = portletDataContext.createServiceContext( ruleGroupInstanceElement, ruleGroupInstance, MDRPortletDataHandler.NAMESPACE); serviceContext.setUserId(userId); MDRRuleGroupInstance importedRuleGroupInstance = null; if (portletDataContext.isDataStrategyMirror()) { MDRRuleGroupInstance existingMDRRuleGroupInstance = MDRRuleGroupInstanceUtil.fetchByUUID_G( ruleGroupInstance.getUuid(), portletDataContext.getScopeGroupId()); if (existingMDRRuleGroupInstance == null) { serviceContext.setUuid(ruleGroupInstance.getUuid()); importedRuleGroupInstance = MDRRuleGroupInstanceLocalServiceUtil.addRuleGroupInstance( portletDataContext.getScopeGroupId(), ruleGroupInstance.getClassName(), classPK, ruleGroupId, ruleGroupInstance.getPriority(), serviceContext); } else { importedRuleGroupInstance = MDRRuleGroupInstanceLocalServiceUtil.updateRuleGroupInstance( existingMDRRuleGroupInstance.getRuleGroupInstanceId(), ruleGroupInstance.getPriority()); } } else { importedRuleGroupInstance = MDRRuleGroupInstanceLocalServiceUtil.addRuleGroupInstance( portletDataContext.getScopeGroupId(), ruleGroupInstance.getClassName(), classPK, ruleGroupId, ruleGroupInstance.getPriority(), serviceContext); } portletDataContext.importClassedModel( ruleGroupInstance, importedRuleGroupInstance, MDRPortletDataHandler.NAMESPACE); }