use of com.liferay.portlet.wiki.ImportFilesException 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);
}
}
use of com.liferay.portlet.wiki.ImportFilesException in project liferay-ide by liferay.
the class MediaWikiImporter method readSpecialNamespaces.
protected List<String> readSpecialNamespaces(Element root) throws ImportFilesException {
List<String> namespaces = new ArrayList<String>();
Element siteinfoElement = root.element("siteinfo");
if (siteinfoElement == null) {
throw new ImportFilesException("Invalid pages XML file");
}
Element namespacesElement = siteinfoElement.element("namespaces");
List<Element> namespaceElements = namespacesElement.elements("namespace");
for (Element namespaceElement : namespaceElements) {
Attribute attribute = namespaceElement.attribute("key");
String value = attribute.getValue();
if (!value.equals("0")) {
namespaces.add(namespaceElement.getText());
}
}
return namespaces;
}
Aggregations