throw new RegistryException(e);
}
register = false;
}
MutablePortletApplication pa = (MutablePortletApplication) registry.getPortletApplication(contextName);
if (pa != null)
{
if ( pa.getApplicationType() != getApplicationType(local) )
{
if ( local )
{
throw new RegistryException("Cannot start local portlet application "+contextName+": it is not a local application");
}
else
{
throw new RegistryException("Cannot start portlet application "+contextName+": it is a local application");
}
}
DescriptorChangeMonitor changeMonitor = this.monitor;
if (!monitored && changeMonitor != null)
{
changeMonitor.remove(contextName);
}
portletFactory.unregisterPortletApplication(pa);
}
// if (register && (pa == null || checksum != pa.getChecksum()))
if (register)
{
if (pa == null)
{
// new
try
{
pa = registerPortletApplication(paWar, pa, local, paClassLoader);
}
catch (Exception e)
{
// don't register the pa
register = false;
}
}
else
{
int status = nodeManager.checkNode(new Long(pa.getId().toString()), pa.getName());
boolean reregister = false;
boolean deploy = false;
switch (status)
{
case NodeManager.NODE_NEW:
{
//only reason is that the file got somehow corrupted
// so we really do not know what is going on here...
// the best chance at this point is to reregister (which might be the absolute wrong choice)
log.warn("The portlet application " + pa.getName() + " is registered in the database but not locally .... we will reregister");
reregister = true;
if (checksum != pa.getChecksum())
{
log.warn("The provided portlet application " + pa.getName() + " is a different version than in the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will redeploy (also to the database)");
deploy = true;
}
break;
}
case NodeManager.NODE_SAVED:
{
if (checksum != pa.getChecksum())
{
log.warn("The provided portlet application " + pa.getName() + " is a different version than in the local node info and the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will reregister AND redeploy (also to the database)");
//database and local node info are in synch, so we assume that this is a brand new
// war .... let's deploy
reregister = true;
deploy = true;
}
break;
}
case NodeManager.NODE_OUTDATED:
{
//database version is older (determined by id) than the database
//let's deploy and reregister
if (checksum != pa.getChecksum())
log.error("The portlet application " + pa.getName() + " provided for the upgrade IS WRONG. The database checksum= " + pa.getChecksum() + ", but the local=" + checksum + "....THIS NEEDS TO BE CORRECTED");
reregister = true;
break;
}
}
if (deploy)
pa = registerPortletApplication(paWar, pa, local, paClassLoader);
else
if (reregister)
{
// add to search engine result
this.updateSearchEngine(true, pa);
this.updateSearchEngine(false, pa);
// and add to the current node info
try
{
nodeManager.addNode(new Long(pa.getId().toString()), pa.getName());
} catch (Exception e)
{
log.error("Adding node for portlet application " + pa.getName() + " caused exception" , e);
}
}
}