public void compareAndCompleteCategoryLists(List remoteCategoryVOList, List<CategoryVO> allLocalCategories, CategoryVO localParentCategory, Map handledRemoteCategoryPaths, Map request) throws SystemException
{
Iterator remoteCategoryVOListIterator = remoteCategoryVOList.iterator();
while(remoteCategoryVOListIterator.hasNext())
{
CategoryVO remoteCategoryVO = (CategoryVO)remoteCategoryVOListIterator.next();
boolean categoryExists = false;
CategoryVO localCategoryVO = null;
Iterator allLocalCategoriesIterator = allLocalCategories.iterator();
while(allLocalCategoriesIterator.hasNext())
{
localCategoryVO = (CategoryVO)allLocalCategoriesIterator.next();
if(localCategoryVO.getName().equals(remoteCategoryVO.getName()))
{
categoryExists = true;
break;
}
}
boolean skipLocalCategory = false;
if(!categoryExists)
{
Database db = CastorDatabaseService.getDatabase();
try
{
beginTransaction(db);
String remoteParentPath = remoteCategoryVO.getCategoryPath();
String isCategorySelected = (String)request.get(remoteParentPath + "_transfer");
if(isCategorySelected != null && isCategorySelected.equals("true"))
{
skipLocalCategory = true;
handleSubCategories(localParentCategory, remoteCategoryVO, handledRemoteCategoryPaths, request, db);
}
commitTransaction(db);
}
catch (Exception e)
{
e.printStackTrace();
rollbackTransaction(db);
}
}
if(remoteCategoryVO.getChildren() != null && remoteCategoryVO.getChildren().size() > 0)
{
if(localCategoryVO != null && !skipLocalCategory)
{
compareAndCompleteCategoryLists(remoteCategoryVO.getChildren(), localCategoryVO.getChildren(), localCategoryVO, handledRemoteCategoryPaths, request);
}
else
{
compareAndCompleteCategoryLists(remoteCategoryVO.getChildren(), new ArrayList(), null, handledRemoteCategoryPaths, request);
}