Template item some times has owningCollection filled and some times not
-----------------------------------------------------------------------

                 Key: DS-260
                 URL: http://jira.dspace.org/jira/browse/DS-260
             Project: DSpace 1.x
          Issue Type: Bug
          Components: DSpace API, JSPUI, XMLUI
    Affects Versions: 1.5.2, 1.5.1, 1.5.0
            Reporter: Andrea Bollini
            Priority: Critical


A template item is created by the Collection API 
(Collection.createTemplateItem()) without keep the collection id in his owning 
collection field/db column...

If you create the template item from the xmlui you will get the same behaviour 
(only the api is used)
if you create the template item from the jspui you will get two differents 
behavior:
- during the collection creation (the wizard) only the collection api is used 
so no collection id is stored in the owning collection field/db column
- from an already created collection (the EditCommunityCollection servlet) the 
collection is explicity setted as owining collection of the template item

 else if (button.equals("submit_create_template"))
        {
            // Create a template item
            collection.createTemplateItem();

            // Forward to edit page for new template item
            Item i = collection.getTemplateItem();
            i.setOwningCollection(collection);

            // have to update to avoid ref. integrity error
            i.update();
            collection.update();
            context.complete();
            response.sendRedirect(response.encodeRedirectURL(request
                    .getContextPath()
                    + "/tools/edit-item?item_id=" + i.getID()));

            return;
        }

So we could have a db that is not full consistently, we need to choose one of 
the two behaviour and uniform him through all the app (a sql script to 
update/fix will be required).

Option 1) keep the actual collection api and clean the jspui 
EditCommunityCollection servlet
Option 2) add to the current collection api the responsability to set the 
owning collection

The option 2 will give us a little performance gain on the "community admin" 
check because we will be not longer need to use a different query for discover 
template item
see AuthorizeManager.isAdmin(Contex, DSpaceObject)
case Constants.ITEM:
                        {
                                Item item = (Item) o;
                                Collection ownCollection = 
item.getOwningCollection();
                                if (ownCollection != null)
                                {
                                        return isAdmin(c,ownCollection);
                                }
                                else
                                {
                                        // is a template item?
                                        TableRow qResult = 
DatabaseManager.querySingle(c,
                                                       "SELECT collection_id 
FROM collection " +
                                                       "WHERE template_item_id 
= ?",o.getID());
                                        if (qResult != null) 
                                        {
                                                Collection collection = 
Collection.find(c,qResult.getIntColumn("collection_id"));
                                                return isAdmin(c,collection);
                                        }                                       
                                        return false;
                                }
                        }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Dspace-devel mailing list
Dspace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to