List of usage examples for com.liferay.portal.kernel.xml Element addText
public Element addText(String text);
From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java
License:Open Source License
private String _getAssetEntryXml(String assetEntryType, String assetEntryUuid) { String xml = null;// w w w. j a v a 2s . co m try { Document document = SAXReaderUtil.createDocument(StringPool.UTF8); Element assetEntryElement = document.addElement("asset-entry"); Element assetEntryTypeElement = assetEntryElement.addElement("asset-entry-type"); assetEntryTypeElement.addText(assetEntryType); Element assetEntryUuidElement = assetEntryElement.addElement("asset-entry-uuid"); assetEntryUuidElement.addText(assetEntryUuid); xml = document.formattedString(StringPool.BLANK); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } return xml; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
private static String _getAssetEntryXml(String assetEntryType, String assetEntryUuid) { String xml = null;//from w w w.ja v a 2s . c o m try { Document document = SAXReaderUtil.createDocument(StringPool.UTF8); Element assetEntryElement = document.addElement("asset-entry"); Element assetEntryTypeElement = assetEntryElement.addElement("asset-entry-type"); assetEntryTypeElement.addText(assetEntryType); Element assetEntryUuidElement = assetEntryElement.addElement("asset-entry-uuid"); assetEntryUuidElement.addText(assetEntryUuid); xml = document.formattedString(StringPool.BLANK); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } return xml; }
From source file:com.liferay.dynamic.data.lists.exporter.impl.DDLXMLExporter.java
License:Open Source License
protected void addFieldElement(Element fieldsElement, String label, Serializable value) { Element fieldElement = fieldsElement.addElement("field"); Element labelElement = fieldElement.addElement("label"); labelElement.addText(label); Element valueElement = fieldElement.addElement("value"); valueElement.addText(String.valueOf(value)); }
From source file:com.liferay.exportimport.lar.PermissionExporter.java
License:Open Source License
protected void exportPermissions(PortletDataContext portletDataContext, String resourceName, String resourcePrimKey, Element permissionsElement) throws Exception { List<String> actionIds = ResourceActionsUtil.getPortletResourceActions(resourceName); Map<Long, Set<String>> roleToActionIds = ExportImportPermissionUtil .getRoleIdsToActionIds(portletDataContext.getCompanyId(), resourceName, resourcePrimKey, actionIds); for (Map.Entry<Long, Set<String>> entry : roleToActionIds.entrySet()) { long roleId = entry.getKey(); Role role = RoleLocalServiceUtil.fetchRole(roleId); String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName(role.getDescriptiveName()); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe);//from ww w .j ava 2 s . c om } } } Element roleElement = permissionsElement.addElement("role"); roleElement.addAttribute("uuid", role.getUuid()); roleElement.addAttribute("name", roleName); roleElement.addAttribute("title", role.getTitle()); roleElement.addAttribute("description", role.getDescription()); roleElement.addAttribute("type", String.valueOf(role.getType())); roleElement.addAttribute("subtype", role.getSubtype()); Set<String> availableActionIds = entry.getValue(); for (String actionId : availableActionIds) { Element actionKeyElement = roleElement.addElement("action-key"); actionKeyElement.addText(actionId); } } }
From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.LayoutStagedModelDataHandler.java
License:Open Source License
protected void exportLayoutIconImage(PortletDataContext portletDataContext, Layout layout, Element layoutElement) throws Exception { Image image = _imageLocalService.getImage(layout.getIconImageId()); if ((image != null) && (image.getTextObj() != null)) { String iconPath = ExportImportPathUtil.getModelPath(portletDataContext.getScopeGroupId(), Image.class.getName(), image.getImageId()); Element iconImagePathElement = layoutElement.addElement("icon-image-path"); iconImagePathElement.addText(iconPath); portletDataContext.addZipEntry(iconPath, image.getTextObj()); } else {//ww w . j ava 2 s .c om if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(4); sb.append("Unable to export icon image "); sb.append(layout.getIconImageId()); sb.append(" to layout "); sb.append(layout.getLayoutId()); _log.warn(sb.toString()); } layout.setIconImageId(0); } }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
@SuppressWarnings("rawtypes") public void saveHashMapToXMLExtraContent(long actId, HashMap<String, String> map) throws SystemException, PortalException { try {/*from w w w . j a v a2 s . co m*/ LearningActivity activity = learningActivityPersistence.fetchByPrimaryKey(actId); if (activity != null && !map.isEmpty()) { //Element resultadosXML=SAXReaderUtil.createElement("p2p"); Element resultadosXML = SAXReaderUtil.createElement(getNameLearningActivity(activity.getTypeId())); Document resultadosXMLDoc = SAXReaderUtil.createDocument(resultadosXML); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); Element eleXML = SAXReaderUtil.createElement(String.valueOf(e.getKey())); if (e.getKey().equals("document")) { eleXML.addAttribute("id", String.valueOf(e.getValue())); } else { eleXML.addText(String.valueOf(e.getValue())); } resultadosXML.add(eleXML); } activity.setExtracontent(resultadosXMLDoc.formattedString()); learningActivityPersistence.update(activity, true); } } catch (Exception e) { } }
From source file:com.liferay.petra.xml.DocUtil.java
License:Open Source License
public static Element add(Element element, QName qName, String text) { Element childElement = element.addElement(qName); childElement.addText(GetterUtil.getString(text)); return childElement; }
From source file:com.liferay.petra.xml.DocUtil.java
License:Open Source License
public static Element add(Element element, String name, String text) { Element childElement = element.addElement(name); childElement.addText(GetterUtil.getString(text)); return childElement; }
From source file:com.liferay.portlet.layoutsadmin.util.SitemapImpl.java
License:Open Source License
protected void addURLElement(Element element, String url, UnicodeProperties typeSettingsProperties, Date modifiedDate) {/*from w w w. ja v a 2s . c o m*/ Element urlElement = element.addElement("url"); Element locElement = urlElement.addElement("loc"); locElement.addText(encodeXML(url)); if (typeSettingsProperties == null) { if (Validator.isNotNull(PropsValues.SITES_SITEMAP_DEFAULT_CHANGE_FREQUENCY)) { Element changefreqElement = urlElement.addElement("changefreq"); changefreqElement.addText(PropsValues.SITES_SITEMAP_DEFAULT_CHANGE_FREQUENCY); } if (Validator.isNotNull(PropsValues.SITES_SITEMAP_DEFAULT_PRIORITY)) { Element priorityElement = urlElement.addElement("priority"); priorityElement.addText(PropsValues.SITES_SITEMAP_DEFAULT_PRIORITY); } } else { String changefreq = typeSettingsProperties.getProperty("sitemap-changefreq"); if (Validator.isNotNull(changefreq)) { Element changefreqElement = urlElement.addElement("changefreq"); changefreqElement.addText(changefreq); } else if (Validator.isNotNull(PropsValues.SITES_SITEMAP_DEFAULT_CHANGE_FREQUENCY)) { Element changefreqElement = urlElement.addElement("changefreq"); changefreqElement.addText(PropsValues.SITES_SITEMAP_DEFAULT_CHANGE_FREQUENCY); } String priority = typeSettingsProperties.getProperty("sitemap-priority"); if (Validator.isNotNull(priority)) { Element priorityElement = urlElement.addElement("priority"); priorityElement.addText(priority); } else if (Validator.isNotNull(PropsValues.SITES_SITEMAP_DEFAULT_PRIORITY)) { Element priorityElement = urlElement.addElement("priority"); priorityElement.addText(PropsValues.SITES_SITEMAP_DEFAULT_PRIORITY); } } if (modifiedDate != null) { Element modifiedDateElement = urlElement.addElement("lastmod"); DateFormat iso8601DateFormat = DateUtil.getISO8601Format(); modifiedDateElement.addText(iso8601DateFormat.format(modifiedDate)); } }
From source file:com.liferay.portlet.softwarecatalog.service.impl.SCProductEntryLocalServiceImpl.java
License:Open Source License
protected void populatePluginPackageElement(Element el, SCProductEntry productEntry, SCProductVersion productVersion, String baseImageURL) throws SystemException { DocUtil.add(el, "name", productEntry.getName()); String moduleId = ModuleId.toString(productEntry.getRepoGroupId(), productEntry.getRepoArtifactId(), productVersion.getVersion(), "war"); DocUtil.add(el, "module-id", moduleId); DocUtil.add(el, "modified-date", Time.getRFC822(productVersion.getModifiedDate())); Element typesEl = el.addElement("types"); DocUtil.add(typesEl, "type", productEntry.getType()); Element tagsEl = el.addElement("tags"); String[] tags = StringUtil.split(productEntry.getTags()); for (int i = 0; i < tags.length; i++) { DocUtil.add(tagsEl, "tag", tags[i]); }//from www.j av a 2 s. c o m DocUtil.add(el, "short-description", productEntry.getShortDescription()); if (Validator.isNotNull(productEntry.getLongDescription())) { DocUtil.add(el, "long-description", productEntry.getLongDescription()); } if (Validator.isNotNull(productVersion.getChangeLog())) { DocUtil.add(el, "change-log", productVersion.getChangeLog()); } if (Validator.isNotNull(productVersion.getDirectDownloadURL())) { DocUtil.add(el, "download-url", productVersion.getDirectDownloadURL()); } DocUtil.add(el, "author", productEntry.getAuthor()); Element screenshotsEl = el.addElement("screenshots"); for (SCProductScreenshot screenshot : productEntry.getScreenshots()) { long thumbnailId = screenshot.getThumbnailId(); long fullImageId = screenshot.getFullImageId(); Element screenshotEl = screenshotsEl.addElement("screenshot"); DocUtil.add(screenshotEl, "thumbnail-url", baseImageURL + "?img_id=" + thumbnailId + "&t=" + WebServerServletTokenUtil.getToken(thumbnailId)); DocUtil.add(screenshotEl, "large-image-url", baseImageURL + "?img_id=" + fullImageId + "&t=" + WebServerServletTokenUtil.getToken(fullImageId)); } Element licensesEl = el.addElement("licenses"); for (SCLicense license : productEntry.getLicenses()) { Element licenseEl = licensesEl.addElement("license"); licenseEl.addText(license.getName()); licenseEl.addAttribute("osi-approved", String.valueOf(license.isOpenSource())); } Element liferayVersionsEl = el.addElement("liferay-versions"); for (SCFrameworkVersion frameworkVersion : productVersion.getFrameworkVersions()) { DocUtil.add(liferayVersionsEl, "liferay-version", frameworkVersion.getName()); } }