public static SiteNodeVersion createInitialSiteNodeVersion(Database db, SiteNode siteNode, InfoGluePrincipal infoGluePrincipal) throws SystemException, Bug
{
ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
SiteNodeVersion siteNodeVersion = null;
try
{
int maxSortOrder;
if (siteNode.getParentSiteNode() != null)
{
maxSortOrder = siteNode.getParentSiteNode().getChildSiteNodes().size()-1;
}
else
{
maxSortOrder = 0;
}
//SiteNode siteNode = SiteNodeController.getSiteNodeWithId(siteNodeId, db);
siteNodeVersion = new SiteNodeVersionImpl();
siteNodeVersion.setIsCheckedOut(new Boolean(false));
siteNodeVersion.setModifiedDateTime(DateHelper.getSecondPreciseDate());
siteNodeVersion.setOwningSiteNode((SiteNodeImpl)siteNode);
siteNodeVersion.setStateId(new Integer(0));
siteNodeVersion.setVersionComment("Initial version");
siteNodeVersion.setVersionModifier(infoGluePrincipal.getName());
siteNodeVersion.setVersionNumber(new Integer(1));
siteNodeVersion.setSortOrder(maxSortOrder);
db.create((SiteNodeVersion)siteNodeVersion);
List siteNodeVersions = new ArrayList();
siteNodeVersions.add(siteNodeVersion);