Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-260

Template item some times has owningCollection filled and some times not

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.0, 1.5.1, 1.5.2
    • Fix Version/s: 1.6.0
    • Component/s: DSpace API, JSPUI, XMLUI
    • Labels:
      None
    • Attachments:
      1
    • Comments:
      3
    • Documentation Status:
      Not Required

      Description

      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;
      }
      }

        Attachments

          Activity

            People

            • Assignee:
              bollini Andrea Bollini (4Science)
              Reporter:
              bollini Andrea Bollini (4Science)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: