return siteNode.getValueObject();
}
public SiteNode create(Database db, Integer parentSiteNodeId, Integer siteNodeTypeDefinitionId, InfoGluePrincipal infoGluePrincipal, Integer repositoryId, SiteNodeVO siteNodeVO) throws SystemException, Exception
{
SiteNode siteNode = null;
logger.info("******************************************");
logger.info("parentSiteNode:" + parentSiteNodeId);
logger.info("siteNodeTypeDefinition:" + siteNodeTypeDefinitionId);
logger.info("repository:" + repositoryId);
logger.info("******************************************");
//Fetch related entities here if they should be referenced
SiteNode parentSiteNode = null;
SiteNodeTypeDefinition siteNodeTypeDefinition = null;
if(parentSiteNodeId != null)
{
parentSiteNode = getSiteNodeWithId(parentSiteNodeId, db);
if(repositoryId == null)
repositoryId = parentSiteNode.getRepository().getRepositoryId();
}
if(siteNodeTypeDefinitionId != null)
siteNodeTypeDefinition = SiteNodeTypeDefinitionController.getController().getSiteNodeTypeDefinitionWithId(siteNodeTypeDefinitionId, db);
Repository repository = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
siteNode = new SiteNodeImpl();
siteNode.setValueObject(siteNodeVO);
siteNode.setParentSiteNode((SiteNodeImpl)parentSiteNode);
siteNode.setRepository((RepositoryImpl)repository);
siteNode.setSiteNodeTypeDefinition((SiteNodeTypeDefinitionImpl)siteNodeTypeDefinition);
siteNode.setCreator(infoGluePrincipal.getName());
db.create(siteNode);
if(parentSiteNode != null)
parentSiteNode.getChildSiteNodes().add(siteNode);
//No siteNode is an island (humhum) so we also have to create an siteNodeVersion for it.
SiteNodeVersionController.createInitialSiteNodeVersion(db, siteNode, infoGluePrincipal);
return siteNode;