@Override protected void doImportStagedModel( PortletDataContext portletDataContext, CalendarNotificationTemplate calendarNotificationTemplate) throws Exception { long userId = portletDataContext.getUserId(calendarNotificationTemplate.getUserUuid()); Map<Long, Long> calendarIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Calendar.class); long calendarId = MapUtil.getLong( calendarIds, calendarNotificationTemplate.getCalendarId(), calendarNotificationTemplate.getCalendarId()); NotificationType notificationType = NotificationType.parse(calendarNotificationTemplate.getNotificationType()); NotificationTemplateType notificationTemplateType = NotificationTemplateType.parse(calendarNotificationTemplate.getNotificationTemplateType()); ServiceContext serviceContext = portletDataContext.createServiceContext(calendarNotificationTemplate); CalendarNotificationTemplate importedCalendarNotificationTemplate = null; String body = ExportImportHelperUtil.replaceImportContentReferences( portletDataContext, calendarNotificationTemplate, calendarNotificationTemplate.getBody()); if (portletDataContext.isDataStrategyMirror()) { CalendarNotificationTemplate existingCalendarNotificationTemplate = fetchStagedModelByUuidAndGroupId( calendarNotificationTemplate.getUuid(), portletDataContext.getScopeGroupId()); if (existingCalendarNotificationTemplate == null) { serviceContext.setUuid(calendarNotificationTemplate.getUuid()); importedCalendarNotificationTemplate = CalendarNotificationTemplateLocalServiceUtil.addCalendarNotificationTemplate( userId, calendarId, notificationType, calendarNotificationTemplate.getNotificationTypeSettings(), notificationTemplateType, calendarNotificationTemplate.getSubject(), body, serviceContext); } else { importedCalendarNotificationTemplate = CalendarNotificationTemplateLocalServiceUtil.updateCalendarNotificationTemplate( existingCalendarNotificationTemplate.getCalendarNotificationTemplateId(), calendarNotificationTemplate.getNotificationTypeSettings(), calendarNotificationTemplate.getSubject(), body, serviceContext); } } else { importedCalendarNotificationTemplate = CalendarNotificationTemplateLocalServiceUtil.addCalendarNotificationTemplate( userId, calendarId, notificationType, calendarNotificationTemplate.getNotificationTypeSettings(), notificationTemplateType, calendarNotificationTemplate.getSubject(), body, serviceContext); } portletDataContext.importClassedModel( calendarNotificationTemplate, importedCalendarNotificationTemplate); }