use of com.liferay.portal.kernel.xml.Element in project liferay-ide by liferay.
the class AdminPortletDataHandler method doExportData.
@Override
protected String doExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception {
portletDataContext.addPortletPermissions(RESOURCE_NAME);
Element rootElement = addExportDataRootElement(portletDataContext);
rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId()));
ActionableDynamicQuery kbArticleActionableDynamicQuery = getKBArticleActionableDynamicQuery(portletDataContext);
kbArticleActionableDynamicQuery.performActions();
ActionableDynamicQuery kbTemplateActionableDynamicQuery = new KBTemplateExportActionableDynamicQuery(portletDataContext);
kbTemplateActionableDynamicQuery.performActions();
ActionableDynamicQuery kbCommentActionableDynamicQuery = getKBCommentActionableDynamicQuery(portletDataContext);
kbCommentActionableDynamicQuery.performActions();
return getExportDataRootElementString(rootElement);
}
use of com.liferay.portal.kernel.xml.Element in project liferay-ide by liferay.
the class KBArticleStagedModelDataHandler method doExportStagedModel.
@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, KBArticle kbArticle) throws Exception {
if (kbArticle.getParentResourcePrimKey() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());
if (kbArticle.getParentResourceClassNameId() == kbArticleClassNameId) {
KBArticle parentKBArticle = KBArticleLocalServiceUtil.getLatestKBArticle(kbArticle.getParentResourcePrimKey(), WorkflowConstants.STATUS_APPROVED);
StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, kbArticle, parentKBArticle, PortletDataContext.REFERENCE_TYPE_PARENT);
} else {
KBFolder parentKBFolder = KBFolderLocalServiceUtil.getKBFolder(kbArticle.getParentResourcePrimKey());
StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, kbArticle, parentKBFolder, PortletDataContext.REFERENCE_TYPE_PARENT);
}
}
Element kbArticleElement = portletDataContext.getExportDataElement(kbArticle);
exportKBArticleAttachments(portletDataContext, kbArticleElement, kbArticle);
portletDataContext.addClassedModel(kbArticleElement, ExportImportPathUtil.getModelPath(kbArticle), kbArticle);
}
use of com.liferay.portal.kernel.xml.Element in project liferay-ide by liferay.
the class KBArticleStagedModelDataHandler method importKBArticleAttachments.
protected void importKBArticleAttachments(PortletDataContext portletDataContext, KBArticle kbArticle, KBArticle importedKBArticle) throws Exception {
List<Element> dlFileEntryElements = portletDataContext.getReferenceDataElements(kbArticle, DLFileEntry.class);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(portletDataContext.getCompanyId());
serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId());
InputStream inputStream = null;
for (Element dlFileEntryElement : dlFileEntryElements) {
try {
byte[] bytes = portletDataContext.getZipEntryAsByteArray(dlFileEntryElement.attributeValue("path"));
inputStream = new UnsyncByteArrayInputStream(bytes);
String fileName = dlFileEntryElement.attributeValue("file-name");
String mimeType = KnowledgeBaseUtil.getMimeType(bytes, fileName);
PortletFileRepositoryUtil.addPortletFileEntry(portletDataContext.getScopeGroupId(), portletDataContext.getUserId(importedKBArticle.getUserUuid()), KBArticle.class.getName(), importedKBArticle.getClassPK(), PortletKeys.KNOWLEDGE_BASE_ADMIN, importedKBArticle.getAttachmentsFolderId(), inputStream, fileName, mimeType, true);
} catch (DuplicateFileException dfe) {
continue;
} finally {
StreamUtil.cleanUp(inputStream);
}
}
}
use of com.liferay.portal.kernel.xml.Element in project liferay-ide by liferay.
the class KBCommentStagedModelDataHandler method doExportStagedModel.
@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, KBComment kbComment) throws Exception {
Element kbCommentElement = portletDataContext.getExportDataElement(kbComment);
portletDataContext.addClassedModel(kbCommentElement, ExportImportPathUtil.getModelPath(kbComment), kbComment);
}
use of com.liferay.portal.kernel.xml.Element in project liferay-ide by liferay.
the class AdminPortletDataHandler method doExportData.
@Override
protected String doExportData(final PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception {
Element rootElement = addExportDataRootElement(portletDataContext);
portletDataContext.addPortletPermissions(GadgetPermission.RESOURCE_NAME);
rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId()));
ActionableDynamicQuery actionableDynamicQuery = new GadgetExportActionableDynamicQuery(portletDataContext);
actionableDynamicQuery.performActions();
return getExportDataRootElementString(rootElement);
}
Aggregations