Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9836

Add file id of the gridfs file created in the header of the exchange

    Details

    • Type: Wish
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.17.0
    • Fix Version/s: 2.17.1, 2.18.0
    • Component/s: camel-mongodb
    • Labels:
      None
    • Environment:

      Any

    • Estimated Complexity:
      Novice

      Description

      Currently the camel-mongodb-gridfs component (which is not available in this Jira) when a file is cretated does not return back the Id (_id) of the file created, it only returns the filename

      String metaData = exchange.getIn().getHeader(GridFsEndpoint.GRIDFS_METADATA, String.class);
                  DBObject dbObject = (DBObject) JSON.parse(metaData);
                  gfsFile.setMetaData(dbObject);
                  gfsFile.save();
                  exchange.getIn().setHeader(Exchange.FILE_NAME_PRODUCED, gfsFile.getFilename());
      

      mongodb api has the method getid: http://api.mongodb.org/java/current/com/mongodb/gridfs/GridFSFile.html#getId--

      So i'd like to ask to:
      a) create a header field (maybe GridFsEndpoint.GRIDFS_FILE_ID_PRODUCED)
      b) Add the header after the creation

      String metaData = exchange.getIn().getHeader(GridFsEndpoint.GRIDFS_METADATA, String.class);
                  DBObject dbObject = (DBObject) JSON.parse(metaData);
                  gfsFile.setMetaData(dbObject);
                  gfsFile.save();
                  exchange.getIn().setHeader(Exchange.FILE_NAME_PRODUCED, gfsFile.getFilename());
                  exchange.getIn().setHeader(GridFsEndpoint.GRIDFS_FILE_ID_PRODUCED, gfsFile.getId());
      

      Of course I can create a PR myself, but I think the administrative work would be more? Up to you guys.

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              jlpedrosa Jose Luis Pedrosa
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: