Search in sources :

Example 1 with Element

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);
}
Also used : Element(com.liferay.portal.kernel.xml.Element) KBTemplateExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBTemplateExportActionableDynamicQuery) KBTemplateExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBTemplateExportActionableDynamicQuery) KBArticleExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleExportActionableDynamicQuery) KBCommentExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBCommentExportActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Example 2 with Element

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);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle) Element(com.liferay.portal.kernel.xml.Element)

Example 3 with Element

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);
        }
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) DuplicateFileException(com.liferay.portlet.documentlibrary.DuplicateFileException) ServiceContext(com.liferay.portal.service.ServiceContext) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream) InputStream(java.io.InputStream) Element(com.liferay.portal.kernel.xml.Element) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream)

Example 4 with Element

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);
}
Also used : Element(com.liferay.portal.kernel.xml.Element)

Example 5 with Element

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);
}
Also used : Element(com.liferay.portal.kernel.xml.Element) GadgetExportActionableDynamicQuery(com.liferay.opensocial.service.persistence.GadgetExportActionableDynamicQuery) GadgetExportActionableDynamicQuery(com.liferay.opensocial.service.persistence.GadgetExportActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Aggregations

Element (com.liferay.portal.kernel.xml.Element)22 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)5 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)5 ServiceContext (com.liferay.portal.service.ServiceContext)4 InputStream (java.io.InputStream)4 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)3 SystemException (com.liferay.portal.kernel.exception.SystemException)3 UnsyncByteArrayInputStream (com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream)3 NoSuchTagException (com.liferay.portlet.asset.NoSuchTagException)3 ImportFilesException (com.liferay.portlet.wiki.ImportFilesException)3 Artist (org.liferay.jukebox.model.Artist)3 KBArticle (com.liferay.knowledgebase.model.KBArticle)2 KBFolder (com.liferay.knowledgebase.model.KBFolder)2 PortalException (com.liferay.portal.kernel.exception.PortalException)2 ProgressTracker (com.liferay.portal.kernel.util.ProgressTracker)2 Document (com.liferay.portal.kernel.xml.Document)2 DocumentException (com.liferay.portal.kernel.xml.DocumentException)2 NoSuchFileException (com.liferay.portlet.documentlibrary.NoSuchFileException)2 NoSuchPageException (com.liferay.portlet.wiki.NoSuchPageException)2 IOException (java.io.IOException)2