List of usage examples for com.liferay.portal.kernel.xml Element addAttribute
public Element addAttribute(String name, String value);
From source file:com.custom.portal.verify.CustomVerifyDynamicDataMapping.java
License:Open Source License
protected boolean createDefaultMetadataElement(Element dynamicElementElement, String defaultLanguageId) { boolean hasDefaultMetadataElement = hasDefaultMetadataElement(dynamicElementElement, defaultLanguageId); if (hasDefaultMetadataElement) { return false; }// w w w . j a va 2 s .c om Element metadataElement = dynamicElementElement.addElement("meta-data"); metadataElement.addAttribute("locale", defaultLanguageId); Element entryElement = metadataElement.addElement("entry"); entryElement.addAttribute("name", "label"); entryElement.addCDATA(StringPool.BLANK); return true; }
From source file:com.custom.portal.verify.CustomVerifyDynamicDataMapping.java
License:Open Source License
protected void updateXSDDynamicElement(Element element) { String dataType = element.attributeValue("dataType"); if (Validator.equals(dataType, "file-upload")) { element.addAttribute("dataType", "document-library"); element.addAttribute("type", "ddm-documentlibrary"); }/* w w w . j a v a 2 s . c o m*/ List<Element> dynamicElementElements = element.elements("dynamic-element"); for (Element dynamicElementElement : dynamicElementElements) { updateXSDDynamicElement(dynamicElementElement); } }
From source file:com.hrportal.service.impl.WebArticleHelperLocalServiceImpl.java
License:Open Source License
private Element generateAssetVocabularyElement(AssetVocabulary vocab) { Element vocabElem = SAXReaderUtil.createElement(vocab.getName()); vocabElem.addAttribute("id", String.valueOf(vocab.getVocabularyId())); vocabElem.addAttribute("companyId", String.valueOf(vocab.getCompanyId())); vocabElem.addAttribute("groupId", String.valueOf(vocab.getGroupId())); return vocabElem; }
From source file:com.hrportal.service.impl.WebArticleHelperLocalServiceImpl.java
License:Open Source License
private Element generateAssetCategoryElement(AssetCategory cat) { Element e = SAXReaderUtil.createElement(cat.getName()); e.addAttribute("id", String.valueOf(cat.getCategoryId())); e.addAttribute("companyId", String.valueOf(cat.getCompanyId())); e.addAttribute("groupId", String.valueOf(cat.getGroupId())); e.addAttribute("vocabularyId", String.valueOf(cat.getVocabularyId())); e.addAttribute("parentCategoryId", String.valueOf(cat.getParentCategoryId())); return e;/*w w w . j a v a 2 s . com*/ }
From source file:com.liferay.adaptive.media.journal.internal.exportimport.data.handler.test.AMJournalArticleStagedModelDataHandlerTest.java
License:Open Source License
private String _getContent(String html) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); Element dynamicElementElement = rootElement.addElement("dynamic-element"); dynamicElementElement.addAttribute("name", "content"); dynamicElementElement.addAttribute("type", "text_area"); Element element = dynamicElementElement.addElement("dynamic-content"); element.addCDATA(html);//from w ww. ja v a 2s.co m return document.asXML(); }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetCategoryPortletDataHandler.java
License:Open Source License
@Override protected String doExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { Element rootElement = addExportDataRootElement(portletDataContext); rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId())); if (portletDataContext.getBooleanParameter(NAMESPACE, "categories")) { ActionableDynamicQuery categoryActionableDynamicQuery = _assetCategoryLocalService .getExportActionableDynamicQuery(portletDataContext); categoryActionableDynamicQuery.performActions(); }/* w w w. j a v a2 s . c o m*/ if (portletDataContext.getBooleanParameter(NAMESPACE, "vocabularies")) { ActionableDynamicQuery vocabularyActionableDynamicQuery = _assetVocabularyLocalService .getExportActionableDynamicQuery(portletDataContext); vocabularyActionableDynamicQuery.performActions(); } return getExportDataRootElementString(rootElement); }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetCategoryStagedModelDataHandler.java
License:Open Source License
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, AssetCategory category) throws Exception { if (category.getParentCategoryId() != AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { AssetCategory parentCategory = _assetCategoryLocalService .fetchAssetCategory(category.getParentCategoryId()); StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, category, parentCategory, PortletDataContext.REFERENCE_TYPE_PARENT); } else {/*from w ww . j a v a2 s .com*/ AssetVocabulary vocabulary = _assetVocabularyLocalService .fetchAssetVocabulary(category.getVocabularyId()); StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, category, vocabulary, PortletDataContext.REFERENCE_TYPE_PARENT); } Element categoryElement = portletDataContext.getExportDataElement(category); category.setUserUuid(category.getUserUuid()); List<AssetCategoryProperty> categoryProperties = _assetCategoryPropertyLocalService .getCategoryProperties(category.getCategoryId()); for (AssetCategoryProperty categoryProperty : categoryProperties) { Element propertyElement = categoryElement.addElement("property"); propertyElement.addAttribute("userUuid", categoryProperty.getUserUuid()); propertyElement.addAttribute("key", categoryProperty.getKey()); propertyElement.addAttribute("value", categoryProperty.getValue()); } String categoryPath = ExportImportPathUtil.getModelPath(category); categoryElement.addAttribute("path", categoryPath); portletDataContext.addReferenceElement(category, categoryElement, category, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, false); portletDataContext.addPermissions(AssetCategory.class, category.getCategoryId()); portletDataContext.addZipEntry(categoryPath, category); }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetVocabularyStagedModelDataHandler.java
License:Open Source License
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, AssetVocabulary vocabulary) throws Exception { Locale locale = _portal.getSiteDefaultLocale(portletDataContext.getScopeGroupId()); Element vocabularyElement = portletDataContext.getExportDataElement(vocabulary); String vocabularyPath = ExportImportPathUtil.getModelPath(vocabulary); vocabularyElement.addAttribute("path", vocabularyPath); vocabulary.setUserUuid(vocabulary.getUserUuid()); exportSettingsMetadata(portletDataContext, vocabulary, vocabularyElement, locale); portletDataContext.addReferenceElement(vocabulary, vocabularyElement, vocabulary, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, false); portletDataContext.addPermissions(AssetVocabulary.class, vocabulary.getVocabularyId()); portletDataContext.addZipEntry(vocabularyPath, vocabulary); }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetVocabularyStagedModelDataHandler.java
License:Open Source License
protected void exportSettingsMetadata(PortletDataContext portletDataContext, AssetVocabulary vocabulary, Element vocabularyElement, Locale locale) throws PortalException { String settingsMetadataPath = ExportImportPathUtil.getModelPath(vocabulary, _SETTINGS_METADATA + ".json"); vocabularyElement.addAttribute(_SETTINGS_METADATA, settingsMetadataPath); AssetVocabularySettingsExportHelper assetVocabularySettingsExportHelper = new AssetVocabularySettingsExportHelper( vocabulary.getSettings(), _jsonFactory, locale); portletDataContext.addZipEntry(settingsMetadataPath, assetVocabularySettingsExportHelper.getSettingsMetadata()); }
From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java
License:Open Source License
protected void updateExportScopeIds(PortletDataContext portletDataContext, PortletPreferences portletPreferences, String key, long plid) throws Exception { String[] oldValues = portletPreferences.getValues(key, null); if (oldValues == null) { return;/*from w ww . jav a 2 s . c o m*/ } Layout layout = _layoutLocalService.getLayout(plid); String companyGroupScopeId = AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + portletDataContext.getCompanyGroupId(); String[] newValues = new String[oldValues.length]; Element rootElement = portletDataContext.getExportDataRootElement(); Element groupIdMappingsElement = rootElement.addElement("group-id-mappings"); for (int i = 0; i < oldValues.length; i++) { String oldValue = oldValues[i]; if (oldValue.startsWith(AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX)) { newValues[i] = StringUtil.replace(oldValue, companyGroupScopeId, "[$COMPANY_GROUP_SCOPE_ID$]"); if (newValues[i].contains("[$COMPANY_GROUP_SCOPE_ID$]")) { continue; } } else if (oldValue.startsWith(AssetPublisherUtil.SCOPE_ID_LAYOUT_PREFIX)) { // Legacy preferences String scopeIdSuffix = oldValue.substring(AssetPublisherUtil.SCOPE_ID_LAYOUT_PREFIX.length()); long scopeIdLayoutId = GetterUtil.getLong(scopeIdSuffix); Layout scopeIdLayout = _layoutLocalService.getLayout(layout.getGroupId(), layout.isPrivateLayout(), scopeIdLayoutId); if (plid != scopeIdLayout.getPlid()) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletDataContext.getPortletId(), scopeIdLayout); } newValues[i] = AssetPublisherUtil.SCOPE_ID_LAYOUT_UUID_PREFIX + scopeIdLayout.getUuid(); } else if (oldValue.startsWith(AssetPublisherUtil.SCOPE_ID_LAYOUT_UUID_PREFIX)) { String scopeLayoutUuid = oldValue .substring(AssetPublisherUtil.SCOPE_ID_LAYOUT_UUID_PREFIX.length()); Layout scopeUuidLayout = _layoutLocalService.getLayoutByUuidAndGroupId(scopeLayoutUuid, portletDataContext.getGroupId(), portletDataContext.isPrivateLayout()); if (plid != scopeUuidLayout.getPlid()) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletDataContext.getPortletId(), scopeUuidLayout); } newValues[i] = oldValue; } else { newValues[i] = oldValue; } long groupId = AssetPublisherUtil.getGroupIdFromScopeId(newValues[i], portletDataContext.getGroupId(), portletDataContext.isPrivateLayout()); Group group = _groupLocalService.fetchGroup(groupId); long liveGroupId = 0; if (group != null) { liveGroupId = group.getLiveGroupId(); if (group.isStagedRemotely()) { liveGroupId = group.getRemoteLiveGroupId(); } } if ((groupId == 0) || (liveGroupId == 0)) { continue; } newValues[i] = String.valueOf(groupId); Element groupIdMappingElement = groupIdMappingsElement.addElement("group-id-mapping"); groupIdMappingElement.addAttribute("group-id", String.valueOf(groupId)); groupIdMappingElement.addAttribute("live-group-id", String.valueOf(liveGroupId)); } portletPreferences.setValues(key, newValues); }