Foren
Getting associated WebContent(s) of an asset publisher programmatically
Mike Harris, geändert vor 12 Jahren.
Getting associated WebContent(s) of an asset publisher programmatically
Junior Member Beiträge: 91 Beitrittsdatum: 28.03.11 Neueste Beiträge
My goal is to find all web content(s) associated to asset publishers inside a page.
I'm able to get a Portlet object and check if it's an asset publisher or not:
After that, I'm lost. How can I take that Portlet object and find the ids (or other informations) about Web Contests that are associated to it in its configuration?
I'm able to get a Portlet object and check if it's an asset publisher or not:
LayoutTypePortlet lt = (LayoutTypePortlet)layout.getLayoutType();
List<portlet> portlets = lt.getPortlets();
for (Portlet portlet : portlets) {
System.out.println(portlet.getDisplayName());
}</portlet>
After that, I'm lost. How can I take that Portlet object and find the ids (or other informations) about Web Contests that are associated to it in its configuration?
Mike Harris, geändert vor 12 Jahren.
RE: Getting associated WebContent(s) of an asset publisher programmatically
Junior Member Beiträge: 91 Beitrittsdatum: 28.03.11 Neueste Beiträge
Finally, I found the uuid of the asset entry(ies) like this :
XMLUtil is just a class that I wrote that runs an XPath query on the Document object.
Wow, that was something. ;)
Note that it will probably crash if you have other portlets than asset publisher, I didn't tested for this. So it's not production ready.
LayoutTypePortlet lt = (LayoutTypePortlet)layout.getLayoutType();
List<portlet> portlets = lt.getPortlets();
for (Portlet portlet : portlets) {
PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), "<portlet-preferences />");
String[] assetEntryXmls = preferences.getValues(
"assetEntryXml", new String[0]);
for (int i = 0; i < assetEntryXmls.length; i++) {
Document doc;
doc = SAXReaderUtil.read(assetEntryXmls[i]);
String assetEntryType = XmlUtil.getContentFromXpath("/asset-entry/asset-entry-type/text()", doc);
String assetEntryUuid = XmlUtil.getContentFromXpath("/asset-entry/asset-entry-uuid/text()", doc);
System.out.println(i + " : " + assetEntryType + " : " + assetEntryUuid);
}
}</portlet>
XMLUtil is just a class that I wrote that runs an XPath query on the Document object.
Wow, that was something. ;)
Note that it will probably crash if you have other portlets than asset publisher, I didn't tested for this. So it's not production ready.