Example usage for org.dom4j Element elementText

List of usage examples for org.dom4j Element elementText

Introduction

In this page you can find the example usage for org.dom4j Element elementText.

Prototype

String elementText(QName qname);

Source Link

Usage

From source file:org.vosao.business.impl.imex.MessagesExporterImpl.java

License:Open Source License

public void readMessages(Element messagesElement) throws DaoTaskException {
    for (Iterator<Element> i = messagesElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("message")) {
            String language = element.elementText("language");
            String code = element.elementText("code");
            String value = element.elementText("value");
            MessageEntity message = getDao().getMessageDao().getByCode(code, language);
            if (message == null) {
                message = new MessageEntity(code, language, value);
            }//from  w  w  w .j  a  v a2s.  c  o m
            message.setValue(value);
            getDaoTaskAdapter().messageSave(message);
        }
    }
}

From source file:org.vosao.business.impl.imex.PageDependencyExporterImpl.java

License:Open Source License

public void read(Element rootElement) throws DaoTaskException {
    for (Iterator<Element> i = rootElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("item")) {
            String page = element.elementText("page");
            String dependency = element.elementText("dependency");
            PageDependencyEntity entity = getDao().getPageDependencyDao().getByPageAndDependency(page,
                    dependency);//from  w  ww .  ja va  2s .  c o  m

            if (entity == null) {
                entity = new PageDependencyEntity(dependency, page);
            }
            getDaoTaskAdapter().pageDependencySave(entity);
        }
    }
}

From source file:org.vosao.business.impl.imex.PageExporterImpl.java

License:Open Source License

private void readTags(Element tagsElement, String pageURL) throws DaoTaskException {
    for (Iterator<Element> i = tagsElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("tag")) {
            String path = element.elementText("name");
            TagEntity tag = getBusiness().getTagBusiness().getByPath(path);
            if (tag != null) {
                PageTagEntity pageTag = getDao().getPageTagDao().getByURL(pageURL);
                if (pageTag == null) {
                    pageTag = new PageTagEntity(pageURL);
                }/*from  www.  java 2 s .  co m*/
                if (!pageTag.getTags().contains(tag.getId())) {
                    pageTag.getTags().add(tag.getId());
                }
                getDaoTaskAdapter().pageTagSave(pageTag);
                if (!tag.getPages().contains(pageURL)) {
                    tag.getPages().add(pageURL);
                    getDaoTaskAdapter().tagSave(tag);
                }
            } else {
                logger.error("Tag not found " + path);
            }
        }
    }
}

From source file:org.vosao.business.impl.imex.PagePermissionExporterImpl.java

License:Open Source License

public void readPagePermissions(Element permissionsElement, final String url) {
    for (Iterator<Element> i = permissionsElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("permission")) {
            String groupName = element.elementText("group");
            GroupEntity group = getDao().getGroupDao().getByName(groupName);
            if (group == null) {
                logger.error("Group " + groupName + " was not found.");
                continue;
            }/*from   w w w .jav a  2s.  c o m*/
            ContentPermissionType permType = ContentPermissionType
                    .valueOf(element.elementText("permissionType"));
            boolean allLanguages = Boolean.valueOf(element.elementText("allLanguages"));
            String languages = element.elementText("languages");
            getBusiness().getContentPermissionBusiness().setPermission(url, group, permType, languages);
        }
    }
}

From source file:org.vosao.business.impl.imex.PluginExporterImpl.java

License:Open Source License

public void readPlugins(Element PluginsElement) throws DaoTaskException {
    for (Iterator<Element> i = PluginsElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("plugin")) {
            String name = element.elementText("name");
            PluginEntity plugin = getDao().getPluginDao().getByName(name);
            if (plugin == null) {
                continue;
            }/* ww w. jav a  2s .co m*/
            plugin.setName(name);
            plugin.setConfigData(element.elementText("configData"));
            getDaoTaskAdapter().pluginSave(plugin);
        }
    }
}

From source file:org.vosao.business.impl.imex.ResourceExporterImpl.java

License:Open Source License

/**
 * Read and import data from _folder.xml file.
 * @param folderPath - folder path.//from w w w  . j  a  va  2s  .c  o m
 * @param xml - _folder.xml file.
 * @throws DocumentException 
 * @throws DaoTaskException 
 */
public void readFolderFile(String folderPath, String xml) throws DocumentException, DaoTaskException {
    FolderEntity folder = getBusiness().getFolderBusiness().createFolder(folderPath);
    Element root = DocumentHelper.parseText(xml).getRootElement();
    String title = root.elementText("title");
    if (!StringUtils.isEmpty(title)) {
        folder.setTitle(title);
        getDaoTaskAdapter().folderSave(folder);
    }
    readFolderPermissions(root.element("permissions"), folder);
}

From source file:org.vosao.business.impl.imex.ResourceExporterImpl.java

License:Open Source License

private void readFolderPermissions(Element element, FolderEntity folder) {
    for (Element permElement : (List<Element>) element.elements("permission")) {
        GroupEntity group = getDao().getGroupDao().getByName(permElement.elementText("group"));
        FolderPermissionType permission = FolderPermissionType
                .valueOf(permElement.elementText("permissionType"));
        getBusiness().getFolderPermissionBusiness().setPermission(folder, group, permission);
    }/*from w ww .  j  av  a 2 s .  c om*/
}

From source file:org.vosao.business.impl.imex.SeoUrlsExporterImpl.java

License:Open Source License

public void read(Element urlsElement) throws DaoTaskException {
    for (Iterator<Element> i = urlsElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("seo-url")) {
            String from = element.elementText("from");
            String to = element.elementText("to");
            SeoUrlEntity seourl = getDao().getSeoUrlDao().getByFrom(from);
            if (seourl == null) {
                seourl = new SeoUrlEntity(from, to);
            }//w  w w  . ja v  a 2 s  .c  o  m
            getDaoTaskAdapter().seoUrlSave(seourl);
        }
    }
}

From source file:org.vosao.business.impl.imex.StructureExporterImpl.java

License:Open Source License

@Override
public void readStructures(Element structuresElement) throws DaoTaskException {
    for (Iterator<Element> i = structuresElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("structure")) {
            String title = element.elementText("title");
            String content = element.elementText("content");
            StructureEntity structure = getDao().getStructureDao().getByTitle(title);
            if (structure == null) {
                structure = new StructureEntity(title, content);
            }//from   ww  w. ja va2s  . co m
            structure.setContent(content);
            getDaoTaskAdapter().structureSave(structure);
            readTemplates(element.element("templates"), structure);
        }
    }
}

From source file:org.vosao.business.impl.imex.StructureExporterImpl.java

License:Open Source License

private void readTemplates(Element templatesElement, StructureEntity structure) {
    for (Iterator<Element> i = templatesElement.elementIterator(); i.hasNext();) {
        Element element = i.next();
        if (element.getName().equals("template")) {
            String title = element.elementText("title");
            String name = element.elementText("name");
            name = name == null ? title : name;
            String content = element.elementText("content");
            StructureTemplateType type = StructureTemplateType.valueOf(element.elementText("type"));
            StructureTemplateEntity template = getDao().getStructureTemplateDao().getByName(name);
            if (template == null) {
                template = new StructureTemplateEntity(name, title, structure.getId(), type, content);
            }//www.  ja  v  a  2s  .  co m
            template.setHeadContent(element.elementText("headContent"));
            getDao().getStructureTemplateDao().save(template);
        }
    }
}