roller-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mitesh Meswani <Mitesh.Mesw...@Sun.COM>
Subject Re: Question about code in HibernateUserManagerImpl
Date Thu, 05 Oct 2006 16:39:50 GMT
Hit the send button too soon...

Mitesh Meswani wrote:
>
>
> Anil Gangolli wrote:
>> Inline.  Maybe Allen can comment too?
>>
>> ----- Original Message ----- From: "Mitesh Meswani" 
>> <Mitesh.Meswani@Sun.COM>
>> To: <roller-dev@incubator.apache.org>
>> Sent: Wednesday, October 04, 2006 2:48 PM
>> Subject: Question about code in HibernateUserManagerImpl
>>
>>
>>> Hi,
>>>
>>> I am working (along with Craig) on developing a persistence layer
>>> abstraction for roller. While converting the code, I had following
>>> questions about code in 
>>> HibernateUserManagerImpl#removeWebsiteContents()
>>>
>>> 1. The list queueEntries is retrieved but not used.
>>>    I think the intention would have been to remove the queueEntries
>>>    from database is that correct?
>>
>> Yes; it seems incomplete.
>>
>> Removing the website's custom ping target will remove the associated 
>> queue
>> entries, but you can have queue entries from common ping targets as 
>> well, so
>> this is probably good to do.
> If it is ok to not delete queue entries here we should either the 
> unnecessary database access to fetch queueEntries. I will remove the 
> entries in DatamapperUserManagerImpl.
Meant to say....
If it is ok to not delete queue entries while removing a website, we 
should avoid the unnecessary database access to fetch queueEntries in 
HibernateUserManagerImpl.

I will delete the queue entries in DatamapperUserManagerImpl.

Thanks,
Mitesh
>>
>>> 2. All the removals below (For example removing of auto ping
>>>     configurations) can be replaced by bulk deletes.
>>>    That is deleting directly from database instead of getting them into
>>>    memory and than deleting.I saw
>>>            HibernateRefererManagerImpl#clearReferrers using the "bulk
>>>    delete" pattern. Is there any reason
>>>   (apart from historic code) why "bulk delete" is not used here ?
>>>
>>
>> I think you just have to be careful that the object's manager doesn't 
>> itself
>> have some cascading delete logic that expects to be called whenever an
>> object it manages is removed.
>>
>> It seems to me that the current pattern for handling cascading 
>> deletion in
>> the managers seems to expect this; that is, the bulk deletion 
>> shortcut can
>> only be used (safely) if it is in the manager that manages that 
>> object type directly.
> Good point. I think than it makes sense to use current pattern.
>
> Thanks,
> Mitesh
>>
>> --a.
>>
>>
>>> Thanks,
>>> Mitesh
>>>
>>>
>>> <code_Of_the_method_for_quick_referece>
>>>
>>>    private void removeWebsiteContents(WebsiteData website)
>>>    throws HibernateException, RollerException {
>>>
>>>        Session session = this.strategy.getSession();
>>>
>>>        BookmarkManager bmgr =
>>> RollerFactory.getRoller().getBookmarkManager();
>>>        WeblogManager wmgr = 
>>> RollerFactory.getRoller().getWeblogManager();
>>>
>>>        // Remove the website's ping queue entries
>>>        Criteria criteria =
>>> session.createCriteria(PingQueueEntryData.class);
>>>        criteria.add(Expression.eq("website", website));
>>>        List queueEntries = criteria.list();  *<--------1*
>>>
>>>        // Remove the website's auto ping configurations   *<------ 2.*
>>>        AutoPingManager autoPingMgr =
>>> RollerFactory.getRoller().getAutopingManager();
>>>        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
>>>        Iterator it = autopings.iterator();
>>>        while(it.hasNext()) {
>>>            this.strategy.remove((AutoPingData) it.next());
>>>        }
>>>
>>>        // Remove the website's custom ping targets
>>>        PingTargetManager pingTargetMgr =
>>> RollerFactory.getRoller().getPingTargetManager();
>>>        List pingtargets = pingTargetMgr.getCustomPingTargets(website);
>>>        it = pingtargets.iterator();
>>>        while(it.hasNext()) {
>>>            this.strategy.remove((PingTargetData) it.next());
>>>        }
>>>
>>>        // remove entries
>>>        Criteria entryQuery =
>>> session.createCriteria(WeblogEntryData.class);
>>>        entryQuery.add(Expression.eq("website", website));
>>>        List entries = entryQuery.list();
>>>        for (Iterator iter = entries.iterator(); iter.hasNext();) {
>>>            WeblogEntryData entry = (WeblogEntryData) iter.next();
>>>
>>>            this.strategy.remove(entry);
>>>        }
>>>
>>>        // remove associated referers
>>>        Criteria refererQuery = 
>>> session.createCriteria(RefererData.class);
>>>        refererQuery.add(Expression.eq("website", website));
>>>        List referers = refererQuery.list();
>>>        for (Iterator iter = referers.iterator(); iter.hasNext();) {
>>>            RefererData referer = (RefererData) iter.next();
>>>            this.strategy.remove(referer);
>>>        }
>>>
>>>
>>>        // remove associated pages
>>>        Criteria pageQuery = 
>>> session.createCriteria(WeblogTemplate.class);
>>>        pageQuery.add(Expression.eq("website", website));
>>>        List pages = pageQuery.list();
>>>        for (Iterator iter = pages.iterator(); iter.hasNext();) {
>>>            WeblogTemplate page = (WeblogTemplate) iter.next();
>>>            this.strategy.remove(page);
>>>        }
>>>
>>>        // remove folders (including bookmarks)
>>>        FolderData rootFolder = bmgr.getRootFolder(website);
>>>        if (null != rootFolder) {
>>>            this.strategy.remove(rootFolder);
>>>
>>>            // Still cannot get all Bookmarks cleared!
>>>            Iterator allFolders = 
>>> bmgr.getAllFolders(website).iterator();
>>>            while (allFolders.hasNext()) {
>>>                FolderData aFolder = (FolderData)allFolders.next();
>>>                bmgr.removeFolderContents(aFolder);
>>>                this.strategy.remove(aFolder);
>>>            }
>>>        }
>>>
>>>        // remove categories
>>>        WeblogCategoryData rootCat = 
>>> wmgr.getRootWeblogCategory(website);
>>>        if (null != rootCat) {
>>>            this.strategy.remove(rootCat);
>>>        }
>>>
>>>    }
>>>
>>>
>>> </code_Of_the_method_for_quick_referece>
>>>
>>

Mime
View raw message