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

New REST api with CRUD operations



    • Attachments:
    • Comments:
    • Documentation Status:
      In Description


      New REST api with CRUD operations over community, collections, items, bitstreams.

      • Developed from version of 31.10.2013, commit 9a626efd9c6f1b375bd90e705694c2061b6c1e5f
      • We used Oracle database, version 11g
      • All code is formatted with convention of DSpace, except line break, which was setted to 130
      • Every method is commented by JavaDoc
      • Many changes where done by DRY principle and by book [REST API design rulebook. (2012). Sebastopol, CA: O'Reilly. ISBN: ISBN 978-1-449-31050-9] recommendation


      • Slash has been removed from list of entities. Reason: This is not right logic of Rest API, by the book.
      • Every method is logged. Logged is start and end.
      • Changes about context:
      • Removed global context in all resources. It was replaced by method for creating context, which is in superclass Resource.
      • Autocommit was removed. - We do not want to has operation half-completed. And in case of exception, we want to do rollback of changes. So, every method is fully transactional.
      • User can be logged into context. - It is needed for create, update and delete entities.
      • Added context exception for exception caused by creation of context. We wanted to have separated SQLExceptions from creation of context and exceptions caused by operation over entities.
      • Added logging:
      • Logging is provided by token.
      • Added class TokenHolder, which holds every information about logged users, created tokens and create tokens.
      • Added class User, which has used only for login method.
      • Tokens are generated by UUID generator from Java library.
      • Writing statistics
      • Method pulled up to superclass.
      • Moved condition for writing to pulled up class.
      • Method is generalized. Parameters are: TypeOfObject, DSpaceObject, Action and other variables for usageEvent.
      • Processing Exceptions
      • Added method for processing exceptions in superclass.
      • Added language support in class MetadataEntry.
      • Added getter and setter for subcommunities in Community class. - Bad name (subCommunity2) is because there was problem with parsing XML. (It was throwing exception with message: There is variable with name subCommunity)
      • Added superclass Resource.
      • It is class for all *Resource classes.
      • Provide creating context, exception processing, metadata key splitting, type of action in string and getting logged user from TokenHolder.
      • MySplit is there because split from Java library was useable enough.
      • All CREATE methods returns created object
      • Changes in /Resource/
      • Added method for finding entity.
        Added check if user has permission to do action with entity or if entity exists. Note: Every resource has method for reading, creating and deleting entities, which are in objects. (Bitstreams in item, collection in community and so on) - Reason: Sometimes is easier to change only type of request from POST to GET. Second reason is better URI structure. Third reason is described in book[rest2012]. Fourth reason, deletion has check if entity is in that entity.
      • Changes in /CommunityResource/
      • Removed method for returning community in HTML. - It is unusable in Rest API.
      • Based on previous changes, changed method for getting community and communities.
      • Added method:
      • get top community
      • get collections of community
      • get subcommunity of community
      • create top community
      • create collection in community
      • create subcommunity in community
      • update community
      • delete community
      • delete collection in community
      • delete subcommunity in community
      • Changes in /CollectionResouce/
      • Removed method for returning community in HTML. - It is unusable in Rest API.
      • Based on previous changes, changed method for getting collections and collection.
      • Added methods:
      • get items in collection
      • create item in collection
      • update collection
      • delete collection
      • delete item in collection
      • Added method for searching collection by name
      • Changes in /ItemResource/
      • Based on previous changes, changed method for getting item.
      • Added methods:
      • get items
      • There is bug. It sometimes throw SQLException with message: Closed list iteration.
      • get item metadata
      • get item bitstreams
      • add metadata to item
      • create bitstream
      • It create only bitstream without metadata. Reason: It can be send only InputStream. It can be solved by sending URI in bitstream class and server download file.
      • Added parameters in methods for creating of bitstream (direct setting of name of file and its description)
        class for policy.
      • update metadata of item
      • delete item
      • delete metadata of item - Maybe unusable.
      • delete bitstream in item
      • find item by metadata entry
      • There was problem with using DSpace API method, so we must write own finding.
      • Changes in BitstreamResource
      • Based on previous changes, changed method for getting bitstream.
      • Change request method at bitstream retrieving to POST. - Reason: In book was wrote, every method which not returning entity must be post. Post is used for creating and for calling methods which are not for returning entity.
      • Added methods:
      • get bitstreams
      • update bitstream
      • update bitstream data
      • There was must be programmed by editing database, because DSpace API has no method for updating bitstream data.
      • delete bitstream
      • CRUD operation of policy of bitstreams (per bitstream in item). Added
      • Changes in RestIndex
      • Updated method which return information about Rest API.
      • Added method for testing if Rest API is running.
      • Added method for logging and logout.


          Issue Links



              peterdietz Peter Dietz
              ctu-developers CTU Developers
              0 Vote for this issue
              3 Start watching this issue