Example usage for com.liferay.portal.kernel.xml Element addElement

List of usage examples for com.liferay.portal.kernel.xml Element addElement

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.xml Element addElement.

Prototype

public Element addElement(QName qName);

Source Link

Usage

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

License:Open Source License

protected static String exportDLFileEntries(PortletDataContext portletDataContext,
        Element dlFileEntryTypesElement, Element dlFoldersElement, Element dlFileEntriesElement,
        Element dlFileRanksElement, Element dlRepositoriesElement, Element dlRepositoryEntriesElement,
        Element entityElement, String content, boolean checkDateRange) throws Exception {

    Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getGroupId());

    if (group.isStagingGroup()) {
        group = group.getLiveGroup();//from www  . ja v  a 2s. c om
    }

    if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) {

        return content;
    }

    StringBuilder sb = new StringBuilder(content);

    int beginPos = content.length();
    int currentLocation = -1;

    while (true) {
        currentLocation = content.lastIndexOf("/c/document_library/get_file?", beginPos);

        if (currentLocation == -1) {
            currentLocation = content.lastIndexOf("/documents/", beginPos);
        }

        if (currentLocation == -1) {
            return sb.toString();
        }

        beginPos = currentLocation;

        int endPos1 = content.indexOf(CharPool.APOSTROPHE, beginPos);
        int endPos2 = content.indexOf(CharPool.CLOSE_BRACKET, beginPos);
        int endPos3 = content.indexOf(CharPool.CLOSE_CURLY_BRACE, beginPos);
        int endPos4 = content.indexOf(CharPool.CLOSE_PARENTHESIS, beginPos);
        int endPos5 = content.indexOf(CharPool.LESS_THAN, beginPos);
        int endPos6 = content.indexOf(CharPool.QUESTION, beginPos);
        int endPos7 = content.indexOf(CharPool.QUOTE, beginPos);
        int endPos8 = content.indexOf(CharPool.SPACE, beginPos);

        int endPos = endPos1;

        if ((endPos == -1) || ((endPos2 != -1) && (endPos2 < endPos))) {
            endPos = endPos2;
        }

        if ((endPos == -1) || ((endPos3 != -1) && (endPos3 < endPos))) {
            endPos = endPos3;
        }

        if ((endPos == -1) || ((endPos4 != -1) && (endPos4 < endPos))) {
            endPos = endPos4;
        }

        if ((endPos == -1) || ((endPos5 != -1) && (endPos5 < endPos))) {
            endPos = endPos5;
        }

        if ((endPos == -1) || ((endPos6 != -1) && (endPos6 < endPos))) {
            endPos = endPos6;
        }

        if ((endPos == -1) || ((endPos7 != -1) && (endPos7 < endPos))) {
            endPos = endPos7;
        }

        if ((endPos == -1) || ((endPos8 != -1) && (endPos8 < endPos))) {
            endPos = endPos8;
        }

        if ((beginPos == -1) || (endPos == -1)) {
            break;
        }

        try {
            String oldParameters = content.substring(beginPos, endPos);

            while (oldParameters.contains(StringPool.AMPERSAND_ENCODED)) {
                oldParameters = oldParameters.replace(StringPool.AMPERSAND_ENCODED, StringPool.AMPERSAND);
            }

            Map<String, String[]> map = new HashMap<String, String[]>();

            if (oldParameters.startsWith("/documents/")) {
                String[] pathArray = oldParameters.split(StringPool.SLASH);

                map.put("groupId", new String[] { pathArray[2] });

                if (pathArray.length == 4) {
                    map.put("uuid", new String[] { pathArray[3] });
                } else if (pathArray.length == 5) {
                    map.put("folderId", new String[] { pathArray[3] });

                    String name = HttpUtil.decodeURL(pathArray[4]);

                    int pos = name.indexOf(StringPool.QUESTION);

                    if (pos != -1) {
                        name = name.substring(0, pos);
                    }

                    map.put("name", new String[] { name });
                } else if (pathArray.length > 5) {
                    String uuid = pathArray[5];

                    int pos = uuid.indexOf(StringPool.QUESTION);

                    if (pos != -1) {
                        uuid = uuid.substring(0, pos);
                    }

                    map.put("uuid", new String[] { uuid });
                }
            } else {
                oldParameters = oldParameters.substring(oldParameters.indexOf(CharPool.QUESTION) + 1);

                map = HttpUtil.parameterMapFromString(oldParameters);
            }

            FileEntry fileEntry = null;

            String uuid = MapUtil.getString(map, "uuid");

            if (Validator.isNotNull(uuid)) {
                String groupIdString = MapUtil.getString(map, "groupId");

                long groupId = GetterUtil.getLong(groupIdString);

                if (groupIdString.equals("@group_id@")) {
                    groupId = portletDataContext.getScopeGroupId();
                }

                fileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);
            } else {
                String folderIdString = MapUtil.getString(map, "folderId");

                if (Validator.isNotNull(folderIdString)) {
                    long folderId = GetterUtil.getLong(folderIdString);
                    String name = MapUtil.getString(map, "name");

                    String groupIdString = MapUtil.getString(map, "groupId");

                    long groupId = GetterUtil.getLong(groupIdString);

                    if (groupIdString.equals("@group_id@")) {
                        groupId = portletDataContext.getScopeGroupId();
                    }

                    fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folderId, name);
                }
            }

            if (fileEntry == null) {
                beginPos--;

                continue;
            }

            DLPortletDataHandlerImpl.exportFileEntry(portletDataContext, dlFileEntryTypesElement,
                    dlFoldersElement, dlFileEntriesElement, dlFileRanksElement, dlRepositoriesElement,
                    dlRepositoryEntriesElement, fileEntry, checkDateRange);

            Element dlReferenceElement = entityElement.addElement("dl-reference");

            dlReferenceElement.addAttribute("default-repository",
                    String.valueOf(fileEntry.isDefaultRepository()));

            String path = null;

            if (fileEntry.isDefaultRepository()) {
                path = DLPortletDataHandlerImpl.getFileEntryPath(portletDataContext, fileEntry);

            } else {
                path = DLPortletDataHandlerImpl.getRepositoryEntryPath(portletDataContext,
                        fileEntry.getFileEntryId());
            }

            dlReferenceElement.addAttribute("path", path);

            String dlReference = "[$dl-reference=" + path + "$]";

            sb.replace(beginPos, endPos, dlReference);
        } catch (Exception e) {
            if (_log.isDebugEnabled()) {
                _log.debug(e, e);
            } else if (_log.isWarnEnabled()) {
                _log.warn(e.getMessage());
            }
        }

        beginPos--;
    }

    return sb.toString();
}

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

License:Open Source License

protected static void exportFeed(PortletDataContext portletDataContext, Element feedsElement, JournalFeed feed)
        throws Exception {

    if (!portletDataContext.isWithinDateRange(feed.getModifiedDate())) {
        return;/* ww w  .  jav a 2  s.  co  m*/
    }

    String path = getFeedPath(portletDataContext, feed);

    if (!portletDataContext.isPathNotProcessed(path)) {
        return;
    }

    feed = (JournalFeed) feed.clone();

    Element feedElement = feedsElement.addElement("feed");

    Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId());

    String newGroupFriendlyURL = group.getFriendlyURL().substring(1);

    String[] friendlyUrlParts = StringUtil.split(feed.getTargetLayoutFriendlyUrl(), '/');

    String oldGroupFriendlyURL = friendlyUrlParts[2];

    if (newGroupFriendlyURL.equals(oldGroupFriendlyURL)) {
        String targetLayoutFriendlyUrl = StringUtil.replaceFirst(feed.getTargetLayoutFriendlyUrl(),
                StringPool.SLASH + newGroupFriendlyURL + StringPool.SLASH,
                "/@data_handler_group_friendly_url@/");

        feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl);
    }

    portletDataContext.addClassedModel(feedElement, path, feed, _NAMESPACE);
}

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

License:Open Source License

protected static void exportStructure(PortletDataContext portletDataContext, Element structuresElement,
        JournalStructure structure) throws Exception {

    String path = getStructurePath(portletDataContext, structure);

    if (!portletDataContext.isPathNotProcessed(path)) {
        return;// w  ww. ja  v  a  2 s.  c  o  m
    }

    Element structureElement = structuresElement.addElement("structure");

    String parentStructureId = structure.getParentStructureId();

    if (Validator.isNotNull(parentStructureId)) {
        try {
            JournalStructure parentStructure = JournalStructureLocalServiceUtil
                    .getStructure(structure.getGroupId(), parentStructureId, true);

            structureElement.addAttribute("parent-structure-uuid", parentStructure.getUuid());

            exportStructure(portletDataContext, structuresElement, parentStructure);
        } catch (NoSuchStructureException nsse) {
        }
    }

    portletDataContext.addClassedModel(structureElement, path, structure, _NAMESPACE);
}

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

License:Open Source License

protected static void exportTemplate(PortletDataContext portletDataContext, Element templatesElement,
        Element dlFileEntryTypesElement, Element dlFoldersElement, Element dlFileEntriesElement,
        Element dlFileRanksElement, Element dlRepositoriesElement, Element dlRepositoryEntriesElement,
        JournalTemplate template) throws Exception {

    String path = getTemplatePath(portletDataContext, template);

    if (!portletDataContext.isPathNotProcessed(path)) {
        return;//from w ww  . j  a v a2 s. co m
    }

    // Clone this template to make sure changes to its content are never
    // persisted

    template = (JournalTemplate) template.clone();

    Element templateElement = templatesElement.addElement("template");

    if (template.isSmallImage()) {
        String smallImagePath = getTemplateSmallImagePath(portletDataContext, template);

        templateElement.addAttribute("small-image-path", smallImagePath);

        Image smallImage = ImageUtil.fetchByPrimaryKey(template.getSmallImageId());

        template.setSmallImageType(smallImage.getType());

        portletDataContext.addZipEntry(smallImagePath, smallImage.getTextObj());
    }

    if (portletDataContext.getBooleanParameter(_NAMESPACE, "embedded-assets")) {

        String content = exportReferencedContent(portletDataContext, dlFileEntryTypesElement, dlFoldersElement,
                dlFileEntriesElement, dlFileRanksElement, dlRepositoriesElement, dlRepositoryEntriesElement,
                templateElement, template.getXsl());

        template.setXsl(content);
    }

    portletDataContext.addClassedModel(templateElement, path, template, _NAMESPACE);
}

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

License:Open Source License

@Override
protected String doExportData(PortletDataContext portletDataContext, String portletId,
        PortletPreferences portletPreferences) throws Exception {

    portletDataContext.addPermissions("com.liferay.portlet.journal", portletDataContext.getScopeGroupId());

    Document document = SAXReaderUtil.createDocument();

    Element rootElement = document.addElement("journal-data");

    rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId()));

    Element structuresElement = rootElement.addElement("structures");

    List<JournalStructure> structures = JournalStructureUtil.findByGroupId(portletDataContext.getScopeGroupId(),
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new StructurePKComparator(true));

    //Modification start
    long processedItems = 0, itemsToprocess = 0;

    itemsToprocess += structures.size();

    Element templatesElement = rootElement.addElement("templates");
    Element dlFileEntryTypesElement = rootElement.addElement("dl-file-entry-types");
    Element dlFoldersElement = rootElement.addElement("dl-folders");
    Element dlFilesElement = rootElement.addElement("dl-file-entries");
    Element dlFileRanksElement = rootElement.addElement("dl-file-ranks");
    Element dlRepositoriesElement = rootElement.addElement("dl-repositories");
    Element dlRepositoryEntriesElement = rootElement.addElement("dl-repository-entries");

    List<JournalTemplate> templates = JournalTemplateUtil.findByGroupId(portletDataContext.getScopeGroupId());
    itemsToprocess += templates.size();/*from   www  . jav  a2 s  .c o m*/

    Element feedsElement = rootElement.addElement("feeds");
    List<JournalFeed> feeds = JournalFeedUtil.findByGroupId(portletDataContext.getScopeGroupId());
    itemsToprocess += feeds.size();

    List<JournalArticle> articles = new ArrayList<JournalArticle>();
    if (portletDataContext.getBooleanParameter(_NAMESPACE, "web-content")) {
        articles = JournalArticleUtil.findByGroupId(portletDataContext.getScopeGroupId(), QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, new ArticleIDComparator(true));
    }
    itemsToprocess += articles.size();

    StagingProgressUpdaterThreadLocal.getMonitor().getComponent(PublishProcessProgressMonitor.COMPONENT_JOURNAL)
            .setItemsCount(itemsToprocess);

    for (JournalStructure structure : structures) {
        StagingProgressUpdaterThreadLocal.getMonitor()
                .getComponent(PublishProcessProgressMonitor.COMPONENT_JOURNAL)
                .setItemsProcessed(processedItems++);

        if (portletDataContext.isWithinDateRange(structure.getModifiedDate())) {

            exportStructure(portletDataContext, structuresElement, structure);
        }
    }

    for (JournalTemplate template : templates) {
        StagingProgressUpdaterThreadLocal.getMonitor()
                .getComponent(PublishProcessProgressMonitor.COMPONENT_JOURNAL)
                .setItemsProcessed(processedItems++);

        if (portletDataContext.isWithinDateRange(template.getModifiedDate())) {

            exportTemplate(portletDataContext, templatesElement, dlFileEntryTypesElement, dlFoldersElement,
                    dlFilesElement, dlFileRanksElement, dlRepositoriesElement, dlRepositoryEntriesElement,
                    template);
        }
    }

    for (JournalFeed feed : feeds) {
        StagingProgressUpdaterThreadLocal.getMonitor()
                .getComponent(PublishProcessProgressMonitor.COMPONENT_JOURNAL)
                .setItemsProcessed(processedItems++);

        if (portletDataContext.isWithinDateRange(feed.getModifiedDate())) {
            exportFeed(portletDataContext, feedsElement, feed);
        }
    }

    Element articlesElement = rootElement.addElement("articles");

    for (JournalArticle article : articles) {
        StagingProgressUpdaterThreadLocal.getMonitor()
                .getComponent(PublishProcessProgressMonitor.COMPONENT_JOURNAL)
                .setItemsProcessed(processedItems++);

        exportArticle(portletDataContext, articlesElement, structuresElement, templatesElement,
                dlFileEntryTypesElement, dlFoldersElement, dlFilesElement, dlFileRanksElement,
                dlRepositoriesElement, dlRepositoryEntriesElement, article, null, true);
    }
    //Modification end

    return document.formattedString();
}

From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java

License:Open Source License

@Override
public String getContent(DDMStructure ddmStructure, Fields ddmFields) throws Exception {

    Document document = SAXReaderUtil.createDocument();

    Element rootElement = document.addElement("root");

    String availableLocales = getAvailableLocales(ddmFields);

    rootElement.addAttribute("available-locales", availableLocales);

    Locale defaultLocale = ddmFields.getDefaultLocale();

    rootElement.addAttribute("default-locale", LocaleUtil.toLanguageId(defaultLocale));

    DDMFieldsCounter ddmFieldsCounter = new DDMFieldsCounter();

    for (String fieldName : ddmStructure.getRootFieldNames()) {
        int repetitions = countFieldRepetition(ddmFields, fieldName, null, -1);
        for (int i = 0; i < repetitions; i++) {
            Element dynamicElementElement = rootElement.addElement("dynamic-element");

            dynamicElementElement.addAttribute("name", fieldName);
            dynamicElementElement.addAttribute("index", String.valueOf(i));
            updateContentDynamicElement(dynamicElementElement, ddmStructure, ddmFields, ddmFieldsCounter);
        }//from   www  . ja  v a2 s  . co m
    }
    return DDMXMLUtil.formatXML(document.asXML());
}

From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java

License:Open Source License

protected void updateContentDynamicElement(Element dynamicElementElement, DDMStructure ddmStructure,
        Field ddmField, DDMFieldsCounter ddmFieldsCounter) throws Exception {

    String fieldName = ddmField.getName();
    String fieldType = ddmStructure.getFieldType(fieldName);
    String indexType = ddmStructure.getFieldProperty(fieldName, "indexType");
    String type = _ddmTypesToJournalTypes.get(fieldType);

    if (type == null) {
        type = fieldType;/*from w  w  w . j av  a2s. c  om*/
    }

    dynamicElementElement.addAttribute("type", type);

    dynamicElementElement.addAttribute("index-type", indexType);

    for (Locale locale : ddmField.getAvailableLocales()) {
        Element dynamicContentElement = dynamicElementElement.addElement("dynamic-content");

        dynamicContentElement.addAttribute("language-id", LocaleUtil.toLanguageId(locale));

        int count = ddmFieldsCounter.get(fieldName);
        Serializable fieldValue = ddmField.getValue(locale, count);
        if ((null == fieldValue || fieldValue.equals("")) && fieldType.equalsIgnoreCase("ddm-date")) {
            fieldValue = System.currentTimeMillis();
        } else if (fieldValue instanceof Date) {
            Date valueDate = (Date) fieldValue;
            fieldValue = valueDate.getTime();
        }
        String valueString = String.valueOf(fieldValue);

        updateDynamicContentValue(dynamicContentElement, fieldType, valueString.trim());
    }

    ddmFieldsCounter.incrementKey(fieldName);
}

From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java

License:Open Source License

protected void updateContentDynamicElement(Element dynamicElementElement, DDMStructure ddmStructure,
        Fields ddmFields, DDMFieldsCounter ddmFieldsCounter) throws Exception {

    String fieldName = dynamicElementElement.attributeValue("name");
    for (String childFieldName : ddmStructure.getChildrenFieldNames(fieldName)) {

        int count = ddmFieldsCounter.get(fieldName);

        int repetitions = countFieldRepetition(ddmFields, childFieldName, fieldName, count);

        for (int i = 0; i < repetitions; i++) {
            Element childDynamicElementElement = dynamicElementElement.addElement("dynamic-element");

            childDynamicElementElement.addAttribute("name", childFieldName);
            childDynamicElementElement.addAttribute("index", String.valueOf(i));

            updateContentDynamicElement(childDynamicElementElement, ddmStructure, ddmFields, ddmFieldsCounter);
        }//from www.  j av a2 s .  c  o m
    }

    updateContentDynamicElement(dynamicElementElement, ddmStructure, ddmFields.get(fieldName),
            ddmFieldsCounter);
}

From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java

License:Open Source License

protected void updateDynamicContentValue(Element dynamicContentElement, String fieldType, String fieldValue)
        throws Exception {

    if (DDMImpl.TYPE_CHECKBOX.equals(fieldType)) {
        if (fieldValue.equals(Boolean.FALSE.toString())) {
            fieldValue = StringPool.BLANK;
        }//w  w w.ja  v a 2s.  c  o  m

        dynamicContentElement.addCDATA(fieldValue);
    } else if (DDMImpl.TYPE_DDM_DOCUMENTLIBRARY.equals(fieldType) && Validator.isNotNull(fieldValue)) {
        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(fieldValue);
        FileEntry fileEntry = null;
        String uuid = jsonObject.getString("uuid");
        long groupId = jsonObject.getLong("groupId");
        _log.info("In updateDynamicContentValue uuid is " + uuid + " and the groupId is " + groupId);
        fileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);
        fieldValue = DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, StringPool.BLANK, false,
                true);
        _log.info(" fieldValue is " + fieldValue);
        dynamicContentElement.addCDATA(fieldValue);
    } else if (DDMImpl.TYPE_DDM_LINK_TO_PAGE.equals(fieldType) && Validator.isNotNull(fieldValue)) {

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(fieldValue);

        long groupId = jsonObject.getLong("groupId");

        String layoutId = jsonObject.getString("layoutId");

        boolean privateLayout = jsonObject.getBoolean("privateLayout");

        StringBundler sb = new StringBundler((groupId > 0) ? 5 : 3);

        sb.append(layoutId);
        sb.append(StringPool.AT);

        if (privateLayout) {
            sb.append("private");
        } else {
            sb.append("public");
        }

        if (groupId > 0) {
            sb.append(StringPool.AT);
            sb.append(groupId);
        }

        dynamicContentElement.addCDATA(sb.toString());
    } else if (DDMImpl.TYPE_SELECT.equals(fieldType) && Validator.isNotNull(fieldValue)) {

        JSONArray jsonArray = JSONFactoryUtil.createJSONArray(fieldValue);

        if (jsonArray.length() > 1) {
            for (int i = 0; i < jsonArray.length(); i++) {
                Element optionElement = dynamicContentElement.addElement("option");

                optionElement.addCDATA(jsonArray.getString(i));
            }
        } else {
            dynamicContentElement.addCDATA(jsonArray.getString(0));
        }
    } else {
        dynamicContentElement.addCDATA(fieldValue);
    }
}

From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java

License:Open Source License

protected void updateJournalXSDDynamicElement(Element element) {
    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String name = element.attributeValue("name");
    String type = element.attributeValue("type");

    Element metadataElement = element.element("meta-data");

    if (metadataElement == null) {
        metadataElement = element.addElement("meta-data");
    }/*  ww  w . ja  v a  2 s. com*/

    if (type.equals("multi-list")) {
        element.addAttribute("multiple", "true");
    } else if (type.equals("selection_break")) {
        Element parentElement = element.getParent();

        parentElement.remove(element);

        return;
    } else {
        Element parentElement = element.getParent();

        String parentType = parentElement.attributeValue("type");

        if ((parentType != null) && parentType.equals("select")) {
            metadataElement.addAttribute("locale", defaultLocale.toString());

            addMetadataEntry(metadataElement, "label", name);

            element.addAttribute("name", "option" + StringUtil.randomId());
            element.addAttribute("type", "option");
            element.addAttribute("value", name);

            return;
        }
    }

    String indexType = StringPool.BLANK;

    Attribute indexTypeAttribute = element.attribute("index-type");

    if (indexTypeAttribute != null) {
        indexType = indexTypeAttribute.getValue();

        element.remove(indexTypeAttribute);
    }

    element.remove(element.attribute("type"));

    String dataType = _ddmDataTypes.get(type);

    if (dataType == null) {
        dataType = "string";
    }

    element.addAttribute("dataType", dataType);
    element.addAttribute("indexType", indexType);

    String required = "false";

    Element requiredElement = fetchMetadataEntry(metadataElement, "name", "required");

    if (requiredElement != null) {
        required = requiredElement.getText();
    }

    element.addAttribute("required", required);

    element.addAttribute("showLabel", "true");

    String newType = _journalTypesToDDMTypes.get(type);

    if (newType == null) {
        newType = type;
    }

    element.addAttribute("type", newType);

    if (newType.startsWith("ddm")) {
        element.addAttribute("fieldNamespace", "ddm");
    }

    metadataElement.addAttribute("locale", defaultLocale.toString());

    List<Element> entryElements = metadataElement.elements();

    if (entryElements.isEmpty()) {
        addMetadataEntry(metadataElement, "label", name);
    } else {
        for (Element entryElement : entryElements) {
            String oldEntryName = entryElement.attributeValue("name");

            String newEntryName = _ddmMetadataAttributes.get(oldEntryName);

            if (newEntryName == null) {
                metadataElement.remove(entryElement);
            } else {
                entryElement.addAttribute("name", newEntryName);
            }
        }
    }

    if (newType.equals("ddm-date") || newType.equals("ddm-decimal") || newType.equals("ddm-integer")
            || newType.equals("ddm-link-to-page") || newType.equals("ddm-number")
            || newType.equals("ddm-text-html") || newType.equals("text") || newType.equals("textarea")) {

        element.addAttribute("width", "25");
    } else if (newType.equals("wcm-image")) {
        element.addAttribute("fieldNamespace", "wcm");
        element.addAttribute("readOnly", "false");
    }

    List<Element> dynamicElementElements = element.elements("dynamic-element");

    for (Element dynamicElementElement : dynamicElementElements) {
        updateJournalXSDDynamicElement(dynamicElementElement);
    }
}