@Override
/**
* Get a "fake" page that contains ALL portlets (portlet instances)
*/
public PageConfig getDefaultPage() {
PageConfig pageConfig = pageConfigThreadLocal.get();
if ((pageConfig == null) || (pageConfig.getPortletIds().isEmpty())) {
try {
pageConfig = JCRTemplate.getInstance().doExecuteWithSystemSessionInSameWorkspaceAndLocale(new JCRCallback<PageConfig>() {
public PageConfig doInJCR(JCRSessionWrapper session) throws RepositoryException {
PageConfig pageConfig = new PageConfig();
pageConfig.setUri(PortalDriverServlet.DEFAULT_PAGE_URI);
pageConfig.setName(DEFAULT_PAGE_NAME);
Query q = createAllPortletsQuery(session);
if (q != null) {
QueryResult qr = q.execute();
NodeIterator ni = qr.getNodes();
List<String> portletIds = new ArrayList<String>();
while (ni.hasNext()) {
JCRPortletNode nodeWrapper = new JCRPortletNode((JCRNodeWrapper) ni.nextNode());
portletIds.add(PortletWindowConfig.fromId(nodeWrapper));
}
pageConfig.setPortletIds(portletIds);
}
return pageConfig;
}
});
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
if (pageConfig.getPortletIds().isEmpty()) {
pageConfigThreadLocal.set(null);
} else {
pageConfigThreadLocal.set(pageConfig);
}
return pageConfig;