*/
public void validate(ContextMetadata metadata, ExceptionHolder warnings)
{
super.validate(metadata, warnings);
Lookup stateMap = new HashTab();
MetadataCompoundValidationException eh = null;
if (m_lastVersion != null && !m_metadata.getVersion().equals(m_lastVersion.getName()))
{
eh = new MetadataCompoundValidationException();
MetadataValidationException e = new MetadataValidationException("err.upgrade.lastVersion",
new Object[]{m_lastVersion.getName(), m_metadata.getVersion()});
setProperties(e);
eh.addException(e);
}
// roll back the state and validate that can undo each step and state is still valid
for (VersionUpgrade version = m_lastVersion; version != null; version = version.getPrev())
{
try
{
version.undo(getState(stateMap, version));
}
catch (UncheckedException e)
{
eh = version.addException(eh, e);
}
}
if (eh != null)
{
throw eh;
}
// validate initial state to catch alter/drop steps lacking associated create steps
for (Lookup.Iterator itr = stateMap.valueIterator(); itr.hasNext();)
{
((UpgradeState)itr.next()).start();
}
// validate that the overall state is still valid after every upgrade version is applied
for (VersionUpgrade version = m_firstVersion; version != null; version = version.getNext())
{
try
{
version.apply(getState(stateMap, version));
}
catch (UncheckedException e)
{
eh = version.addException(eh, e);
}
}
if (eh != null)
{
throw eh;
}
for (Lookup.Iterator itr = stateMap.valueIterator(); itr.hasNext();)
{
((UpgradeState)itr.next()).end();
}
}