@Override public T visitElement(Element element) { List<Attribute> attributes = element.attributes(); List<T> attributeResults = new ArrayList<>(attributes.size()); for (int i = 0, size = element.attributeCount(); i < size; i++) { Attribute attribute = element.attribute(i); T atrributeResult = attribute.accept(this); attributeResults.add(atrributeResult); } List<T> nodeResults = new ArrayList<>(element.nodeCount()); for (int i = 0, size = element.nodeCount(); i < size; i++) { Node node = element.node(i); T nodeResult = node.accept(this); if (nodeResult != null) { nodeResults.add(nodeResult); } } return handleElement(element, attributeResults, nodeResults); }
for (Attribute attribute : dynamicContentElement.attributes()) { attributes.put(attribute.getName(), attribute.getValue());
@Override public void importServicePortletPreferences( PortletDataContext portletDataContext, Element serviceElement) throws PortalException { long ownerId = GetterUtil.getLong( serviceElement.attributeValue("owner-id")); int ownerType = GetterUtil.getInteger( serviceElement.attributeValue("owner-type")); String serviceName = serviceElement.attributeValue("service-name"); if (ownerType == PortletKeys.PREFS_OWNER_TYPE_GROUP) { ownerId = portletDataContext.getGroupId(); } else if (ownerType == PortletKeys.PREFS_OWNER_TYPE_COMPANY) { ownerId = portletDataContext.getCompanyId(); } PortletPreferences portletPreferences = getPortletPreferences( portletDataContext.getCompanyId(), ownerId, ownerType, LayoutConstants.DEFAULT_PLID, serviceName); for (Attribute attribute : serviceElement.attributes()) { serviceElement.remove(attribute); } String xml = serviceElement.asXML(); portletPreferences.setPreferences(xml); _portletPreferencesLocalService.updatePortletPreferences( portletPreferences); }