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

    if (portletDataContext.getBooleanParameter(NAMESPACE, "categories")) {
      Element categoriesElement = portletDataContext.getImportDataGroupElement(AssetCategory.class);

      List<Element> categoryElements = categoriesElement.elements();

      for (Element categoryElement : categoryElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, categoryElement);
      }
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "vocabularies")) {
      Element vocabulariesElement =
          portletDataContext.getImportDataGroupElement(AssetVocabulary.class);

      List<Element> vocabularyElements = vocabulariesElement.elements();

      for (Element vocabularyElement : vocabularyElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, vocabularyElement);
      }
    }

    return null;
  }
  protected void readExpandoTables(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/expando-tables.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> expandoTableElements = rootElement.elements("expando-table");

    for (Element expandoTableElement : expandoTableElements) {
      String className = expandoTableElement.attributeValue("class-name");

      ExpandoTable expandoTable = null;

      try {
        expandoTable =
            _expandoTableLocalService.getDefaultTable(portletDataContext.getCompanyId(), className);
      } catch (NoSuchTableException nste) {
        expandoTable =
            _expandoTableLocalService.addDefaultTable(portletDataContext.getCompanyId(), className);
      }

      List<Element> expandoColumnElements = expandoTableElement.elements("expando-column");

      for (Element expandoColumnElement : expandoColumnElements) {
        long columnId = GetterUtil.getLong(expandoColumnElement.attributeValue("column-id"));
        String name = expandoColumnElement.attributeValue("name");
        int type = GetterUtil.getInteger(expandoColumnElement.attributeValue("type"));
        String defaultData = expandoColumnElement.elementText("default-data");
        String typeSettings = expandoColumnElement.elementText("type-settings");

        Serializable defaultDataObject =
            ExpandoConverterUtil.getAttributeFromString(type, defaultData);

        ExpandoColumn expandoColumn =
            _expandoColumnLocalService.getColumn(expandoTable.getTableId(), name);

        if (expandoColumn != null) {
          _expandoColumnLocalService.updateColumn(
              expandoColumn.getColumnId(), name, type, defaultDataObject);
        } else {
          expandoColumn =
              _expandoColumnLocalService.addColumn(
                  expandoTable.getTableId(), name, type, defaultDataObject);
        }

        _expandoColumnLocalService.updateTypeSettings(expandoColumn.getColumnId(), typeSettings);

        portletDataContext.importPermissions(
            ExpandoColumn.class, columnId, expandoColumn.getColumnId());
      }
    }
  }
Exemple #3
0
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPermissions(
        "com.liferay.portlet.dynamicdatamapping",
        portletDataContext.getSourceGroupId(),
        portletDataContext.getScopeGroupId());

    Element structuresElement = portletDataContext.getImportDataGroupElement(DDMStructure.class);

    List<Element> structureElements = structuresElement.elements();

    for (Element structureElement : structureElements) {
      StagedModelDataHandlerUtil.importStagedModel(portletDataContext, structureElement);
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "templates")) {
      Element templatesElement = portletDataContext.getImportDataGroupElement(DDMTemplate.class);

      List<Element> templateElements = templatesElement.elements();

      for (Element templateElement : templateElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, templateElement);
      }
    }

    return portletPreferences;
  }
  protected void processStructure(
      com.liferay.portal.kernel.xml.Document structureDocument,
      Document document,
      Element rootElement)
      throws Exception {

    LinkedList<Element> queue = new LinkedList<Element>(rootElement.elements());

    Element element = null;

    while ((element = queue.poll()) != null) {
      String elName = element.attributeValue("name", StringPool.BLANK);
      String elType = element.attributeValue("type", StringPool.BLANK);
      String elIndexType = element.attributeValue("index-type", StringPool.BLANK);

      if (structureDocument != null) {
        String path = element.getPath().concat("[@name='").concat(elName).concat("']");

        Node structureNode = structureDocument.selectSingleNode(path);

        if (structureNode != null) {
          Element structureElement = (Element) structureNode;

          elType = structureElement.attributeValue("type", StringPool.BLANK);
          elIndexType = structureElement.attributeValue("index-type", StringPool.BLANK);
        }
      }

      if (Validator.isNotNull(elType)) {
        indexField(document, element, elType, elIndexType);
      }

      queue.addAll(element.elements());
    }
  }
  protected void indexField(Document document, Element element, String elType, String elIndexType) {

    if (Validator.isNull(elIndexType)) {
      return;
    }

    com.liferay.portal.kernel.xml.Document structureDocument = element.getDocument();

    Element rootElement = structureDocument.getRootElement();

    String defaultLocale = GetterUtil.getString(rootElement.attributeValue("default-locale"));

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

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

    for (Element dynamicContentElement : dynamicContentElements) {
      String contentLocale =
          GetterUtil.getString(dynamicContentElement.attributeValue("language-id"));

      String[] value = new String[] {dynamicContentElement.getText()};

      if (elType.equals("multi-list")) {
        List<Element> optionElements = dynamicContentElement.elements("option");

        value = new String[optionElements.size()];

        for (int i = 0; i < optionElements.size(); i++) {
          value[i] = optionElements.get(i).getText();
        }
      }

      if (elIndexType.equals("keyword")) {
        if (Validator.isNull(contentLocale)) {
          document.addKeyword(name, value);
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addKeyword(name, value);
          }

          document.addKeyword(name.concat(StringPool.UNDERLINE).concat(contentLocale), value);
        }
      } else if (elIndexType.equals("text")) {
        if (Validator.isNull(contentLocale)) {
          document.addText(name, StringUtil.merge(value, StringPool.SPACE));
        } else {
          if (defaultLocale.equals(contentLocale)) {
            document.addText(name, StringUtil.merge(value, StringPool.SPACE));
          }

          document.addText(
              name.concat(StringPool.UNDERLINE).concat(contentLocale),
              StringUtil.merge(value, StringPool.SPACE));
        }
      }
    }
  }
  protected Definition doParse(InputStream inputStream) throws Exception {
    Document document = SAXReaderUtil.read(inputStream, _validate);

    Element rootElement = document.getRootElement();

    String name = rootElement.elementText("name");
    String description = rootElement.elementText("description");
    int version = GetterUtil.getInteger(rootElement.elementText("version"));

    Definition definition = new Definition(name, description, document.formattedString(), version);

    List<Element> conditionElements = rootElement.elements("condition");

    for (Element conditionElement : conditionElements) {
      Condition condition = parseCondition(conditionElement);

      definition.addNode(condition);
    }

    List<Element> forkElements = rootElement.elements("fork");

    for (Element forkElement : forkElements) {
      Fork fork = parseFork(forkElement);

      definition.addNode(fork);
    }

    List<Element> joinElements = rootElement.elements("join");

    for (Element joinElement : joinElements) {
      Join join = parseJoin(joinElement);

      definition.addNode(join);
    }

    List<Element> stateElements = rootElement.elements("state");

    for (Element stateElement : stateElements) {
      State state = parseState(stateElement);

      definition.addNode(state);
    }

    List<Element> taskElements = rootElement.elements("task");

    for (Element taskElement : taskElements) {
      Task task = parseTask(taskElement);

      definition.addNode(task);
    }

    parseTransitions(
        definition, conditionElements, forkElements, joinElements, stateElements, taskElements);

    return definition;
  }
  protected List<TemplateNode> getTemplateNodes(ThemeDisplay themeDisplay, Element element)
      throws Exception {

    List<TemplateNode> templateNodes = new ArrayList<TemplateNode>();

    Map<String, TemplateNode> prototypeTemplateNodes = new HashMap<String, TemplateNode>();

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

    for (Element dynamicElementElement : dynamicElementElements) {
      Element dynamicContentElement = dynamicElementElement.element("dynamic-content");

      String data = StringPool.BLANK;

      if (dynamicContentElement != null) {
        data = dynamicContentElement.getText();
      }

      String name = dynamicElementElement.attributeValue("name", StringPool.BLANK);

      if (name.length() == 0) {
        throw new TransformException("Element missing \"name\" attribute");
      }

      String type = dynamicElementElement.attributeValue("type", StringPool.BLANK);

      TemplateNode templateNode = new TemplateNode(themeDisplay, name, stripCDATA(data), type);

      if (dynamicElementElement.element("dynamic-element") != null) {
        templateNode.appendChildren(getTemplateNodes(themeDisplay, dynamicElementElement));
      } else if ((dynamicContentElement != null)
          && (dynamicContentElement.element("option") != null)) {

        List<Element> optionElements = dynamicContentElement.elements("option");

        for (Element optionElement : optionElements) {
          templateNode.appendOption(stripCDATA(optionElement.getText()));
        }
      }

      TemplateNode prototypeTemplateNode = prototypeTemplateNodes.get(name);

      if (prototypeTemplateNode == null) {
        prototypeTemplateNode = templateNode;

        prototypeTemplateNodes.put(name, prototypeTemplateNode);

        templateNodes.add(templateNode);
      }

      prototypeTemplateNode.appendSibling(templateNode);
    }

    return templateNodes;
  }
  protected void parseRecipients(Element recipientsElement, Notification notification) {

    if (recipientsElement == null) {
      return;
    }

    List<Element> addressRecipientElements = recipientsElement.elements("address");

    for (Element addressRecipientElement : addressRecipientElements) {
      AddressRecipient addressRecipient = new AddressRecipient(addressRecipientElement.getText());

      notification.addRecipients(addressRecipient);
    }

    Element rolesElement = recipientsElement.element("roles");

    if (rolesElement != null) {
      List<Element> roleReceipientElements = rolesElement.elements("role");

      for (Element roleReceipientElement : roleReceipientElements) {
        long roleId = GetterUtil.getLong(roleReceipientElement.elementText("role-id"));
        String roleType = roleReceipientElement.elementText("role-type");
        String name = roleReceipientElement.elementText("name");

        RoleRecipient roleRecipient = null;

        if (roleId > 0) {
          roleRecipient = new RoleRecipient(roleId, roleType);
        } else {
          roleRecipient = new RoleRecipient(name, roleType);

          boolean autoCreate =
              GetterUtil.getBoolean(roleReceipientElement.elementText("auto-create"), true);

          roleRecipient.setAutoCreate(autoCreate);
        }

        notification.addRecipients(roleRecipient);
      }
    }

    List<Element> userRecipientElements = recipientsElement.elements("user");

    for (Element userRecipientElement : userRecipientElements) {
      long userId = GetterUtil.getLong(userRecipientElement.elementText("user-id"));
      String screenName = userRecipientElement.elementText("screen-name");
      String emailAddress = userRecipientElement.elementText("email-address");

      UserRecipient userRecipient = new UserRecipient(userId, screenName, emailAddress);

      notification.addRecipients(userRecipient);
    }
  }
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPortletPermissions(DDLPermission.RESOURCE_NAME);

    if (portletDataContext.getBooleanParameter(NAMESPACE, "data-definitions")) {

      Element ddmStructuresElement =
          portletDataContext.getImportDataGroupElement(DDMStructure.class);

      List<Element> ddmStructureElements = ddmStructuresElement.elements();

      for (Element ddmStructureElement : ddmStructureElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, ddmStructureElement);
      }

      Element ddmTemplatesElement = portletDataContext.getImportDataGroupElement(DDMTemplate.class);

      List<Element> ddmTemplateElements = ddmTemplatesElement.elements();

      for (Element ddmTemplateElement : ddmTemplateElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, ddmTemplateElement);
      }
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "record-sets")) {
      Element recordSetsElement = portletDataContext.getImportDataGroupElement(DDLRecordSet.class);

      List<Element> recordSetElements = recordSetsElement.elements();

      for (Element recordSetElement : recordSetElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, recordSetElement);
      }
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "records")) {
      Element recordsElement = portletDataContext.getImportDataGroupElement(DDLRecord.class);

      List<Element> recordElements = recordsElement.elements();

      for (Element recordElement : recordElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, recordElement);
      }
    }

    return portletPreferences;
  }
  protected void parseActionsElement(Element actionsElement, Node node) {
    if (actionsElement == null) {
      return;
    }

    List<Element> actionElements = actionsElement.elements("action");

    parseActionElements(actionElements, node);

    List<Element> notificationElements = actionsElement.elements("notification");

    parseNotificationElements(notificationElements, node);
  }
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPortletPermissions(MBPermission.RESOURCE_NAME);

    if (portletDataContext.getBooleanParameter(NAMESPACE, "messages")) {
      Element categoriesElement = portletDataContext.getImportDataGroupElement(MBCategory.class);

      List<Element> categoryElements = categoriesElement.elements();

      for (Element categoryElement : categoryElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, categoryElement);
      }

      Element messagesElement = portletDataContext.getImportDataGroupElement(MBMessage.class);

      List<Element> messageElements = messagesElement.elements();

      for (Element messageElement : messageElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, messageElement);
      }
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "thread-flags")) {
      Element threadFlagsElement = portletDataContext.getImportDataGroupElement(MBThreadFlag.class);

      List<Element> threadFlagElements = threadFlagsElement.elements();

      for (Element threadFlagElement : threadFlagElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, threadFlagElement);
      }
    }

    if (portletDataContext.getBooleanParameter(NAMESPACE, "user-bans")) {
      Element userBansElement = portletDataContext.getImportDataGroupElement(MBBan.class);

      List<Element> userBanElements = userBansElement.elements();

      for (Element userBanElement : userBanElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, userBanElement);
      }
    }

    return null;
  }
  protected void validateActionDocument(String fileName, Element rootElement) {

    if (!Validator.equals(rootElement.getName(), "definition")) {
      throwValidationException(1000, fileName, rootElement);
    }

    List<Element> elements = rootElement.elements();

    if (elements.isEmpty()) {
      throwValidationException(1001, fileName, rootElement, new String[] {"command"});
    }

    for (Element element : elements) {
      String elementName = element.getName();

      if (elementName.equals("command")) {
        String attributeValue = element.attributeValue("name");

        if (attributeValue == null) {
          throwValidationException(1003, fileName, element, "name");
        } else if (Validator.isNull(attributeValue)) {
          throwValidationException(1006, fileName, element, "name");
        }

        validateActionCommandElement(
            fileName, element, new String[] {"execute"}, new String[] {"function"}, new String[0]);
      } else {
        throwValidationException(1002, fileName, element, elementName);
      }
    }
  }
  protected void validateTestSuiteDocument(String fileName, Element rootElement) {

    if (!Validator.equals(rootElement.getName(), "definition")) {
      throwValidationException(1000, fileName, rootElement);
    }

    List<Element> elements = rootElement.elements();

    if (elements.isEmpty()) {
      throwValidationException(1001, fileName, rootElement, new String[] {"execute"});
    }

    for (Element element : elements) {
      String elementName = element.getName();

      if (elementName.equals("execute")) {
        validateExecuteElement(
            fileName,
            element,
            new String[] {"test-case", "test-class", "test-suite"},
            ".+",
            new String[0]);
      } else {
        throwValidationException(1002, fileName, element, elementName);
      }
    }
  }
  protected void validate(String name, String description, String xsd) throws PortalException {

    if (Validator.isNull(name)) {
      throw new StructureNameException();
    } else if (Validator.isNull(description)) {
      throw new StructureDescriptionException();
    }

    if (Validator.isNull(xsd)) {
      throw new StructureXsdException();
    } else {
      try {
        Document doc = SAXReaderUtil.read(xsd);

        Element root = doc.getRootElement();

        List<Element> children = root.elements();

        if (children.size() == 0) {
          throw new StructureXsdException();
        }

        Set<String> elNames = new HashSet<String>();

        validate(children, elNames);
      } catch (Exception e) {
        throw new StructureXsdException();
      }
    }
  }
Exemple #15
0
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPermissions(
        "com.liferay.portlet.calendar",
        portletDataContext.getSourceGroupId(),
        portletDataContext.getScopeGroupId());

    Element rootElement = portletDataContext.getImportDataRootElement();

    for (Element eventElement : rootElement.elements("event")) {
      String path = eventElement.attributeValue("path");

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

      CalEvent event = (CalEvent) portletDataContext.getZipEntryAsObject(path);

      importEvent(portletDataContext, eventElement, event);
    }

    return null;
  }
  protected void fixElementsDefaultLocale(
      Element element, Locale contentDefaultLocale, Locale contentNewDefaultLocale) {

    for (Element dynamicElementElement : element.elements(_DYNAMIC_ELEMENT)) {

      Element importMetaDataElement =
          (Element)
              dynamicElementElement.selectSingleNode(
                  "meta-data[@locale='" + contentNewDefaultLocale.toString() + "']");

      if (importMetaDataElement == null) {
        Element metaDataElement =
            (Element)
                dynamicElementElement.selectSingleNode(
                    "meta-data[@locale='" + contentDefaultLocale.toString() + "']");

        Element copiedMetadataElement = metaDataElement.createCopy();

        Attribute localeAttribute = copiedMetadataElement.attribute(_LOCALE);

        String contentNewDefaultLanguageId = LocaleUtil.toLanguageId(contentNewDefaultLocale);

        localeAttribute.setValue(contentNewDefaultLanguageId);

        dynamicElementElement.add(copiedMetadataElement);
      }

      fixElementsDefaultLocale(
          dynamicElementElement, contentDefaultLocale, contentNewDefaultLocale);
    }
  }
  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;
  }
  private List<ThemeGroupId> _getGroupLimitExcludes(Element element) {
    List<ThemeGroupId> includes = new ArrayList<ThemeGroupId>();

    if (element == null) {
      return includes;
    }

    List<Element> groupIdsElements = element.elements("group-id");

    for (int i = 0; i < groupIdsElements.size(); i++) {
      Element groupIdElement = groupIdsElements.get(i);

      String name = groupIdElement.attributeValue("name");
      String pattern = groupIdElement.attributeValue("pattern");

      ThemeGroupId themeGroupId = null;

      if (Validator.isNotNull(name)) {
        themeGroupId = new ThemeGroupId(name, false);
      } else if (Validator.isNotNull(pattern)) {
        themeGroupId = new ThemeGroupId(pattern, true);
      }

      if (themeGroupId != null) {
        includes.add(themeGroupId);
      }
    }

    return includes;
  }
  private List<ThemeCompanyId> _getCompanyLimitExcludes(Element el) {
    List<ThemeCompanyId> includes = new ArrayList<ThemeCompanyId>();

    if (el != null) {
      List<Element> companyIds = el.elements("company-id");

      for (int i = 0; i < companyIds.size(); i++) {
        Element companyIdEl = companyIds.get(i);

        String name = companyIdEl.attributeValue("name");
        String pattern = companyIdEl.attributeValue("pattern");

        ThemeCompanyId themeCompanyId = null;

        if (Validator.isNotNull(name)) {
          themeCompanyId = new ThemeCompanyId(name, false);
        } else if (Validator.isNotNull(pattern)) {
          themeCompanyId = new ThemeCompanyId(pattern, true);
        }

        if (themeCompanyId != null) {
          includes.add(themeCompanyId);
        }
      }
    }

    return includes;
  }
  protected void read(String servletContextName, Document document) throws Exception {

    Element rootElement = document.getRootElement();

    if (PropsValues.RESOURCE_ACTIONS_READ_PORTLET_RESOURCES) {
      for (Element portletResourceElement : rootElement.elements("portlet-resource")) {

        readPortletResource(servletContextName, portletResourceElement);
      }
    }

    for (Element modelResourceElement : rootElement.elements("model-resource")) {

      readModelResource(servletContextName, modelResourceElement);
    }
  }
  protected void importAssetLinks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/links.xml");

    if (xml == null) {
      return;
    }

    Element importDataRootElement = portletDataContext.getImportDataRootElement();

    try {
      Document document = SAXReaderUtil.read(xml);

      Element rootElement = document.getRootElement();

      portletDataContext.setImportDataRootElement(rootElement);

      Element linksElement = portletDataContext.getImportDataGroupElement(StagedAssetLink.class);

      List<Element> linkElements = linksElement.elements();

      for (Element linkElement : linkElements) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, linkElement);
      }
    } finally {
      portletDataContext.setImportDataRootElement(importDataRootElement);
    }
  }
  public Set<String> getChildElementAttributeValues(Element element, String attributeName) {

    Set<String> childElementAttributeValues = new TreeSet<String>();

    List<Element> childElements = element.elements();

    if (childElements.isEmpty()) {
      return childElementAttributeValues;
    }

    for (Element childElement : childElements) {
      String childElementName = childElement.attributeValue(attributeName);

      if (childElementName != null) {
        int x = childElementName.lastIndexOf(StringPool.POUND);

        if (x != -1) {
          childElementAttributeValues.add(childElementName.substring(0, x));
        }
      }

      childElementAttributeValues.addAll(
          getChildElementAttributeValues(childElement, attributeName));
    }

    return childElementAttributeValues;
  }
  protected String extractDynamicContent(Element rootElement) {
    StringBundler sb = new StringBundler();

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

    for (Element dynamicElementElement : dynamicElementElements) {
      String type = dynamicElementElement.attributeValue("type", StringPool.BLANK);

      if (!type.equals("boolean")
          && !type.equals("document_library")
          && !type.equals("image")
          && !type.equals("list")
          && !type.equals("link_to_layout")
          && !type.equals("multi-list")
          && !type.equals("selection_break")) {

        Element dynamicContentElement = dynamicElementElement.element("dynamic-content");

        if (dynamicContentElement != null) {
          String dynamicContent = dynamicContentElement.getText();

          sb.append(dynamicContent);
          sb.append(StringPool.SPACE);
        }
      }

      sb.append(extractDynamicContent(dynamicElementElement));
    }

    return sb.toString();
  }
  @Override
  protected PortletPreferences doImportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences,
      String data)
      throws Exception {

    portletDataContext.importPermissions(
        "com.liferay.portlet.blogs",
        portletDataContext.getSourceGroupId(),
        portletDataContext.getScopeGroupId());

    Element entriesElement = portletDataContext.getImportDataGroupElement(BlogsEntry.class);

    JournalPortletDataHandler.importReferenceData(portletDataContext, entriesElement);

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

    for (Element entryElement : entryElements) {
      StagedModelDataHandlerUtil.importStagedModel(portletDataContext, entryElement);
    }

    return null;
  }
  protected void importWSRPConsumers(
      PortletDataContext portletDataContext, Element wsrpConsumersElement) throws Exception {

    if (wsrpConsumersElement == null) {
      return;
    }

    for (Element wsrpConsumerElement : wsrpConsumersElement.elements("wsrp-consumer")) {

      String path = wsrpConsumerElement.attributeValue("path");

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

      WSRPConsumer wsrpConsumer = (WSRPConsumer) portletDataContext.getZipEntryAsObject(path);

      WSRPConsumer importedWSRPConsumer =
          importWSRPConsumer(portletDataContext, wsrpConsumerElement, wsrpConsumer);

      if (portletDataContext.getBooleanParameter(_NAMESPACE, "wsrp-consumer-portlets")) {

        Element wsrpConsumerPortletsElement = wsrpConsumerElement.element("wsrp-consumer-portlets");

        importWSRPConsumerPortlets(
            portletDataContext, importedWSRPConsumer, wsrpConsumerPortletsElement);
      }
    }
  }
  protected void importWSRPConsumerPortlets(
      PortletDataContext portletDataContext,
      WSRPConsumer wsrpConsumer,
      Element wsrpConsumerPortletsElement)
      throws Exception {

    if (wsrpConsumerPortletsElement == null) {
      return;
    }

    for (Element wsrpConsumerPortletElement :
        wsrpConsumerPortletsElement.elements("wsrp-consumer-portlet")) {

      String path = wsrpConsumerPortletElement.attributeValue("path");

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

      WSRPConsumerPortlet wsrpConsumerPortlet =
          (WSRPConsumerPortlet) portletDataContext.getZipEntryAsObject(path);

      importWSRPConsumerPortlet(
          portletDataContext, wsrpConsumer, wsrpConsumerPortletElement, wsrpConsumerPortlet);
    }
  }
  protected void readLocks(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/locks.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> assetElements = rootElement.elements("asset");

    for (Element assetElement : assetElements) {
      String path = assetElement.attributeValue("path");
      String className = assetElement.attributeValue("class-name");
      String key = assetElement.attributeValue("key");

      Lock lock = (Lock) portletDataContext.getZipEntryAsObject(path);

      if (lock != null) {
        portletDataContext.addLocks(className, key, lock);
      }
    }
  }
  protected void importSQL() throws Exception {
    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    InputStream inputStream = classLoader.getResourceAsStream("/resources/data/sql.xml");

    String xml = new String(FileUtil.getBytes(inputStream));

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> batchElements = rootElement.elements("batch");

    for (Element batchElement : batchElements) {
      String testSQL = batchElement.elementText("test-sql");

      int count = getCount(testSQL);

      if (count > 0) {
        continue;
      }

      String[] importSQLs =
          StringUtil.split(batchElement.elementText("import-sql"), StringPool.SEMICOLON);

      runSQL(importSQLs);
    }
  }
  protected void parseNotificationElements(
      List<Element> notificationElements, NotificationAware notificationAware) {

    if (notificationElements.isEmpty()) {
      return;
    }

    Set<Notification> notifications = new HashSet<Notification>(notificationElements.size());

    for (Element notificationElement : notificationElements) {
      String name = notificationElement.elementText("name");
      String description = notificationElement.elementText("description");
      String executionType = notificationElement.elementText("execution-type");
      String template = notificationElement.elementText("template");
      String templateLanguage = notificationElement.elementText("template-language");

      Notification notification =
          new Notification(name, description, executionType, template, templateLanguage);

      List<Element> notificationTypeElements = notificationElement.elements("notification-type");

      for (Element notificationTypeElement : notificationTypeElements) {
        notification.addNotificationType(notificationTypeElement.getText());
      }

      Element recipientsElement = notificationElement.element("recipients");

      parseRecipients(recipientsElement, notification);

      notifications.add(notification);
    }

    notificationAware.setNotifications(notifications);
  }
  protected void parseTransition(Definition definition, Element nodeElement) {
    String sourceName = nodeElement.elementText("name");

    Node sourceNode = definition.getNode(sourceName);

    Element transitionsElement = nodeElement.element("transitions");

    if (transitionsElement == null) {
      return;
    }

    List<Element> transitionElements = transitionsElement.elements("transition");

    for (Element transitionElement : transitionElements) {
      String transitionName = transitionElement.elementText("name");

      String targetName = transitionElement.elementText("target");

      Node targetNode = definition.getNode(targetName);

      boolean defaultValue = GetterUtil.getBoolean(transitionElement.elementText("default"), true);

      Transition transition = new Transition(transitionName, sourceNode, targetNode, defaultValue);

      Element timerElement = transitionElement.element("timer");

      if (timerElement != null) {
        Timer timer = parseTimerElement(timerElement, false);

        transition.setTimers(timer);
      }

      sourceNode.addTransition(transition);
    }
  }