Search in sources :

Example 1 with DocumentException

use of com.liferay.portal.kernel.xml.DocumentException in project liferay-ide by liferay.

the class MediaWikiImporter method importPages.

@Override
public void importPages(long userId, WikiNode node, InputStream[] inputStreams, Map<String, String[]> options) throws PortalException {
    if ((inputStreams.length < 1) || (inputStreams[0] == null)) {
        throw new PortalException("The pages file is mandatory");
    }
    InputStream pagesInputStream = inputStreams[0];
    InputStream usersInputStream = inputStreams[1];
    InputStream imagesInputStream = inputStreams[2];
    try {
        Document document = SAXReaderUtil.read(pagesInputStream);
        Map<String, String> usersMap = readUsersFile(usersInputStream);
        Element rootElement = document.getRootElement();
        List<String> specialNamespaces = readSpecialNamespaces(rootElement);
        processSpecialPages(userId, node, rootElement, specialNamespaces);
        processRegularPages(userId, node, rootElement, specialNamespaces, usersMap, imagesInputStream, options);
        processImages(userId, node, imagesInputStream);
        moveFrontPage(userId, node, options);
    } catch (DocumentException de) {
        throw new ImportFilesException("Invalid XML file provided");
    } catch (IOException ioe) {
        throw new ImportFilesException("Error reading the files provided");
    } catch (PortalException pe) {
        throw pe;
    } catch (Exception e) {
        throw new PortalException(e);
    }
}
Also used : InputStream(java.io.InputStream) ImportFilesException(com.liferay.portlet.wiki.ImportFilesException) Element(com.liferay.portal.kernel.xml.Element) DocumentException(com.liferay.portal.kernel.xml.DocumentException) PortalException(com.liferay.portal.kernel.exception.PortalException) IOException(java.io.IOException) Document(com.liferay.portal.kernel.xml.Document) NoSuchPageException(com.liferay.portlet.wiki.NoSuchPageException) ImportFilesException(com.liferay.portlet.wiki.ImportFilesException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) DocumentException(com.liferay.portal.kernel.xml.DocumentException) IOException(java.io.IOException) NoSuchTagException(com.liferay.portlet.asset.NoSuchTagException)

Aggregations

PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 Document (com.liferay.portal.kernel.xml.Document)1 DocumentException (com.liferay.portal.kernel.xml.DocumentException)1 Element (com.liferay.portal.kernel.xml.Element)1 NoSuchTagException (com.liferay.portlet.asset.NoSuchTagException)1 ImportFilesException (com.liferay.portlet.wiki.ImportFilesException)1 NoSuchPageException (com.liferay.portlet.wiki.NoSuchPageException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1