I'm new here

Revisions and Archived

Hello dear Community,

I never used the revisions per API, but now I try to "rebuild" the history function in the WebEdit. I now how I can get the revisions for different objects, but when I like to restore a deleted element I get sometimes the information that my revision is archived.

Everything is fine with this information, but I can't find a method to check if my object or revision is archived...

I know the following pice of code is very bad, but currently I just try to understand the API.

          element = context.getStoreElement();

          StoreAgent storeAgent = context.requestSpecialist(StoreAgent.TYPE);
          BrokerAgent brokerAgent = context.requireSpecialist(BrokerAgent.TYPE);
          PageStoreRoot pageStore = (PageStoreRoot) storeAgent.getStore(Type.PAGESTORE);
          context.logInfo("MyElement: " + element);
          context.logInfo("Revision : " + element.getRevision().getId());
          List deletedElements = pageStore.getDeletedChildren(element.getRevision().getId(), 0);
                  for (DeletedElementsInfo deletedElementsInfo : deletedElements) {
                         context.logInfo("deletedElementsInfo: " + deletedElementsInfo);
                         for(ElementInfo info : deletedElementsInfo.getDeletedElements()) {
                              if(info.getNodeTag().equals("SECTION") == false) {
                                     context.logInfo("info:  " + info);
                                  context.logInfo("uid: " + info.getUid());
                                  context.logInfo("storetype: " + info.getStoreType());
                                   rev = context.getProject().getRevision(info.getRevisionId() - 1);

                                   context.logInfo("try to get broker at rev.: "  + (info.getRevisionId() - 1));
                                      SpecialistsBroker broker = brokerAgent.getBroker(info.getRevisionId() - 1);
                                      StoreElementAgent revisionElementAgent = broker.requestSpecialist(StoreElementAgent.TYPE);
                                      IDProvider elem = revisionElementAgent.loadStoreElement(info.getUid(), Page.UID_TYPE, false);      // Exception
                                      context.logInfo("" + elem);

I get the following exception at the marked line.

ElementNotFoundException: Element with id 65 not found for revision 20204 (initial=20204) (current) pagestore), revision 20204 is archived!

Kind regards


0 Kudos
4 Replies
Crownpeak employee

Hi Benjamin,

the runtime exception you get when trying to load the element is exactly the information you need in general. In your example you make a call to the revisionElementAgent to load an element of a specific revision which is correct so far. If the project was archived before, e.g. using a "cleanup" schedule, the element maybe is truely non-existent within this revision. This depends on the settings of your archive-task, of course (what is when to be archived, etc.).

Therefore you'll get a runtime exception saying that there is no such element at all while trying to load it. As this is quite a dynamic information only available at runtime there's no special method to claim this infomation from a persistent state. You simply have to handle the exception. Another (old) way of loading an element of a specific revision would be using the UserService you can receive from the Project. Anyway the behaviour is exactly the same in this case throwing a runtime exception you'll have to handle...

Anyway I also tested to reload deleted elements within a custom client connection from an IDE. In that case all I got was a "null" element without any exception. Handling the exception and see if the resulting element is not null would be a safe bet though.



0 Kudos
I'm new here

If you simply want to restore an element you might also be interested in:


Yours sincerely


0 Kudos


thank you very much for your replies. I will check it tomorrow and reply as soon as possible.

Kind regards


0 Kudos

Hello Benjamin,

did the replies solve your questions or do you need further help?

Best regards


0 Kudos