{
try
{
SessionState state = this.getSessionState(portlet, rundata);
String fromcatalogName = this.getParameterUsingFallback(portlet, rundata, FROM_URI, FROM_URI_DEFAULT_VALUE);
String tocatalogName = rundata.getParameters().getString(TO_URI);
if (tocatalogName == null)
{
// this case occur when the normal context is calling for the first time
if (state.getAttribute(CATALOG_PARAM) == null)
{
tocatalogName = fromcatalogName;
}
// this case occur when the end-used moves from the configure context to the normal context
else
{
context.put(CATALOG_PATH_PARAM, state.getAttribute(CATALOG_PATH_PARAM));
context.put(CATALOG_PARAM, state.getAttribute(CATALOG_PARAM));
return;
}
}
// get all catalogs objects used for the "catalog path"
Vector catalogPath = this.getCmsManager().getCatalogs(fromcatalogName, tocatalogName);
// get the catalog selected in the velocity template
Catalog catalog = (Catalog) catalogPath.lastElement();
// Retrieve catalog items
this.getCmsManager().populateCatalog(catalog,true,true,1);
// Store the cataloPath collection and the catalog into the portlet session for performance reason
// (can be used by the customizer without a second retrieve in the cms repository
state.setAttribute(CATALOG_PATH_PARAM, catalogPath);
state.setAttribute(CATALOG_PARAM, catalog);
// Store cataloPath and catalog into the context
context.put(CATALOG_PATH_PARAM, catalogPath);
context.put(CATALOG_PARAM, catalog);