/** * Returns a root path, or fragment, of the model path based on the scope * group ID from the portlet data context. * * <p> * For example, a root path would resemble the following: * </p> * * <p> * <pre> * <code> * /group/"queried groupId" * </code> * </pre></p> * * @param portletDataContext the context of the current export/import * process * @return a root path, or fragment, of the model path * @see PortletDataContext#getScopeGroupId() * @see #getSourceRootPath(PortletDataContext) */ public static String getRootPath(PortletDataContext portletDataContext) { return getRootPath( PATH_PREFIX_GROUP, portletDataContext.getScopeGroupId()); }
public static void deleteStagedModel( PortletDataContext portletDataContext, Element deletionElement) throws PortalException { String className = deletionElement.attributeValue("class-name"); StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler( className); if (stagedModelDataHandler != null) { String extraData = deletionElement.attributeValue("extra-data"); String uuid = deletionElement.attributeValue("uuid"); stagedModelDataHandler.deleteStagedModel( uuid, portletDataContext.getScopeGroupId(), className, extraData); } }
public static String getPortletDataPath( PortletDataContext portletDataContext, String portletId, long plid) { StringBundler sb = new StringBundler(4); sb.append(getPortletPath(portletDataContext, portletId)); sb.append(StringPool.SLASH); Portlet portlet = PortletLocalServiceUtil.getPortletById(portletId); if (portlet.isPreferencesUniquePerLayout()) { sb.append(plid); } else { sb.append(portletDataContext.getScopeGroupId()); } sb.append("/portlet-data.xml"); return sb.toString(); }
sb.append(companyGroupId); sb.append(" or in group "); sb.append(portletDataContext.getScopeGroupId());
@Override protected PortletPreferences doDeleteData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { if (portletDataContext.addPrimaryKey( MBPortletDataHandler.class, "deleteData")) { return portletPreferences; } _mbBanLocalService.deleteBansByGroupId( portletDataContext.getScopeGroupId()); _mbCategoryLocalService.deleteCategories( portletDataContext.getScopeGroupId()); _mbStatsUserLocalService.deleteStatsUsersByGroupId( portletDataContext.getScopeGroupId()); _mbThreadLocalService.deleteThreads( portletDataContext.getScopeGroupId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID); return portletPreferences; }
@Override protected PortletPreferences doDeleteData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { if (portletDataContext.addPrimaryKey( JournalPortletDataHandler.class, "deleteData")) { return portletPreferences; } _journalArticleLocalService.deleteArticles( portletDataContext.getScopeGroupId()); _journalFolderLocalService.deleteFolders( portletDataContext.getGroupId()); _ddmTemplateLocalService.deleteTemplates( portletDataContext.getScopeGroupId(), _portal.getClassNameId(DDMStructure.class)); _ddmStructureLocalService.deleteStructures( portletDataContext.getScopeGroupId(), _portal.getClassNameId(JournalArticle.class)); return portletPreferences; }
@Override public void deleteStagedModels(PortletDataContext portletDataContext) throws PortalException { Set<Long> formInstanceDDMStructureIds = new HashSet<>(); List<DDMFormInstance> formInstances = _ddmFormInstanceLocalService.search( portletDataContext.getCompanyId(), portletDataContext.getScopeGroupId(), null, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new DDMFormInstanceNameComparator()); for (DDMFormInstance formInstance : formInstances) { formInstanceDDMStructureIds.add(formInstance.getStructureId()); _ddmFormInstanceLocalService.deleteFormInstance(formInstance); } deleteDDMStructures(formInstanceDDMStructureIds); }
private DDMStructure _fetchDDMStructure( PortletDataContext portletDataContext, JournalArticle article) { long formerGroupId = article.getGroupId(); article.setGroupId(portletDataContext.getScopeGroupId()); DDMStructure ddmStructure = article.getDDMStructure(); article.setGroupId(formerGroupId); return ddmStructure; }
protected void exportFolderDDMStructures( PortletDataContext portletDataContext, JournalFolder folder) throws Exception { List<DDMStructure> ddmStructures = _journalFolderLocalService.getDDMStructures( new long[] { portletDataContext.getCompanyGroupId(), portletDataContext.getScopeGroupId() }, folder.getFolderId(), JournalFolderConstants. RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW); for (DDMStructure ddmStructure : ddmStructures) { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, folder, ddmStructure, PortletDataContext.REFERENCE_TYPE_STRONG); } }
portletDataContext.getScopeGroupId());
@Override public void exportService( PortletDataContext portletDataContext, Element rootElement, boolean exportServiceSetup) throws Exception { if (!exportServiceSetup) { return; } PortletDataHandler portletDataHandler = _portletDataHandlerProvider.provide( portletDataContext.getPortletId()); if (portletDataHandler == null) { return; } String serviceName = portletDataHandler.getServiceName(); if (Validator.isNotNull(serviceName)) { // Company service exportServicePortletPreferences( portletDataContext, portletDataContext.getCompanyId(), PortletKeys.PREFS_OWNER_TYPE_COMPANY, serviceName, rootElement); // Group service exportServicePortletPreferences( portletDataContext, portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP, serviceName, rootElement); } }
@Override public String replaceImportContentReferences( PortletDataContext portletDataContext, StagedModel stagedModel, String content) throws Exception { JournalFeed feed = (JournalFeed)stagedModel; Group group = _groupLocalService.getGroup( portletDataContext.getScopeGroupId()); String newGroupFriendlyURL = group.getFriendlyURL(); newGroupFriendlyURL = newGroupFriendlyURL.substring(1); String newTargetLayoutFriendlyURL = StringUtil.replace( feed.getTargetLayoutFriendlyUrl(), _DATA_HANDLER_GROUP_FRIENDLY_URL, newGroupFriendlyURL); long plid = _portal.getPlidFromFriendlyURL( portletDataContext.getCompanyId(), newTargetLayoutFriendlyURL); if (plid <= 0) { Group oldGroup = _groupLocalService.fetchGroup( portletDataContext.getSourceGroupId()); if (oldGroup == null) { return content; } String oldGroupFriendlyURL = oldGroup.getFriendlyURL(); oldGroupFriendlyURL = oldGroupFriendlyURL.substring(1); newTargetLayoutFriendlyURL = StringUtil.replace( feed.getTargetLayoutFriendlyUrl(), _DATA_HANDLER_GROUP_FRIENDLY_URL, oldGroupFriendlyURL); } feed.setTargetLayoutFriendlyUrl(newTargetLayoutFriendlyURL); return content; }
@Override protected void doRestoreStagedModel( PortletDataContext portletDataContext, JournalFolder folder) throws Exception { JournalFolder existingFolder = fetchStagedModelByUuidAndGroupId( folder.getUuid(), portletDataContext.getScopeGroupId()); if ((existingFolder == null) || !existingFolder.isInTrash()) { return; } TrashHandler trashHandler = existingFolder.getTrashHandler(); if (trashHandler.isRestorable(existingFolder.getFolderId())) { long userId = portletDataContext.getUserId(folder.getUserUuid()); trashHandler.restoreTrashEntry( userId, existingFolder.getFolderId()); } }
(DDMFormInstanceRecord)record.clone(); importedRecord.setGroupId(portletDataContext.getScopeGroupId()); importedRecord.setFormInstanceId(ddmFormInstanceId); _ddmFormInstanceRecordStagedModelRepository. fetchStagedModelByUuidAndGroupId( record.getUuid(), portletDataContext.getScopeGroupId());
private void _populateJournalArticleLastPublishDateCounts( PortletDataContext portletDataContext) throws PortalException { ManifestSummary manifestSummary = portletDataContext.getManifestSummary(); StagedModelType articleStagedModelType = new StagedModelType( JournalArticle.class); long modelAdditionCount = manifestSummary.getModelAdditionCount( articleStagedModelType); if (modelAdditionCount > -1) { return; } ChangesetCollection changesetCollection = _changesetCollectionLocalService.fetchChangesetCollection( portletDataContext.getScopeGroupId(), StagingConstants.RANGE_FROM_LAST_PUBLISH_DATE_CHANGESET_NAME); if (changesetCollection != null) { modelAdditionCount = _changesetEntryLocalService.getChangesetEntriesCount( changesetCollection.getChangesetCollectionId(), _portal.getClassNameId(JournalArticleResource.class)); manifestSummary.addModelAdditionCount( articleStagedModelType, modelAdditionCount); } long modelDeletionCount = _exportImportHelper.getModelDeletionCount( portletDataContext, articleStagedModelType); manifestSummary.addModelDeletionCount( articleStagedModelType, modelDeletionCount); }
"group-id", String.valueOf(portletDataContext.getScopeGroupId()));
if (portletDataContext.getScopeGroupId() != portletDataContext.getCompanyGroupId()) { groupIdProperty.eq(portletDataContext.getScopeGroupId()));
@Override protected void doRestoreStagedModel( PortletDataContext portletDataContext, JournalArticle article) throws Exception { long userId = portletDataContext.getUserId(article.getUserUuid()); Element articleElement = portletDataContext.getImportDataStagedModelElement(article); String articleResourceUuid = articleElement.attributeValue( "article-resource-uuid"); boolean preloaded = GetterUtil.getBoolean( articleElement.attributeValue("preloaded")); JournalArticle existingArticle = fetchExistingArticle( article.getUuid(), articleResourceUuid, portletDataContext.getScopeGroupId(), article.getArticleId(), article.getArticleId(), article.getVersion(), preloaded); if ((existingArticle == null) || !existingArticle.isInTrash()) { return; } TrashHandler trashHandler = existingArticle.getTrashHandler(); if (trashHandler.isRestorable(existingArticle.getResourcePrimKey())) { trashHandler.restoreTrashEntry( userId, existingArticle.getResourcePrimKey()); } }
portletDataContext.getScopeGroupId(), StagingConstants. RANGE_FROM_LAST_PUBLISH_DATE_CHANGESET_NAME);
groupIdProperty.eq(portletDataContext.getScopeGroupId()));