3 Replies Latest reply on Nov 14, 2007 11:28 PM by ajohnson1200

    adding extended properties to a doc in VersionRestoreAction


      I'm overriding execute method on DocVersionRestoreAction since we have custom doc properties for our documents and need those restored when a version is restored.  So these are stored in the jivedocumentprop table with the key as <customfield-versionid>.  So after calling super.execute in my extended action, I use oldvalue = getDocument().getProperties().get(customfield-old_versionid) and then run getDocument.getProperties.put(customfield-new_versionid,oldvalue).  I've put logging statements throughout this action and it's retrieving the values fine but somehow it's not getting saved to the db.



      I even just went ahead and copied over the entire DocVersionRestoreAction class directly and added a bunch of getProperties().put("randomfield","blahval") throughout the execute action but it's still not getting stored for some reason since calling document.getProperties().get("randomfield") gives undefined error.  Log.debug shows no exceptions or anything when getProperties.put is executed in the action.  Is there something I need to do within the action to get the updated doc properties to persist properly?



        • Re: adding extended properties to a doc in VersionRestoreAction

          hi James,


          Can you try doing this:

          Document d = getDocument();
          d.getProperties().put("test", "test");

          I'm thinking that you're just missing a call to save().





            • Re: adding extended properties to a doc in VersionRestoreAction


              Cool yeah that worked -  I had originally called save earlier but it didn't work since I was using the getDocument() document object instead of the one returned from DocumentManager and must've forgotten to try it again - but seems to work now.  But now I'm seeing a similar type of issue in overriding docversiondeleteaction execute method since if a version gets deleted, we want the extended properties associated with that version cleared from db as well.  Doing the same thing as in restore action - call super.execute() then




              JiveContext systemContext = JiveApplication.getContext(AuthFactory.getSystemAuthToken());

              DocumentManager dm = systemContext.getDocumentManager();

              Document doc = dm.getDocument(getDocument().getDocumentID());





              I added logging before doc.save() with doc.getProperties().get(key-version) output which is correctly returning null but then when I actually delete a version and then call getDocument().getProperties().get(key-deletedversion) in an ftl it still returns the old value fine and doesn't give the undefined expression error it should.  Any thoughts as to what might cause this?  Thanks