4

We have a Storage Extension deployed at SDL Docs Delivery (DXD) end. The extension has a "MyCustomComponentPresentationDAO " class extending "JPAComponentPresentationDAO" class.

The class has overridden methods Create and Remove. When I publish a publication the "Create" method is called as expected but during un-publishing, "Remove" method doesn't trigger.

Any idea about this strange behavior?

Below is is the code I am using:

public class MyCustomComponentPresentationDAO extends JPAComponentPresentationDAO implements ComponentPresentationDAO
{


    public MyCustomComponentPresentationDAO(String storageId, EntityManagerFactory entityManagerFactory,
             String storageType) {
        super(storageId, entityManagerFactory, storageType);
        log.debug("Constructor V 1 called");

    }

    public MyCustomComponentPresentationDAO(String storageId, EntityManagerFactory entityManagerFactory,
            EntityManager entityManager, String storageType) {
        super(storageId, entityManagerFactory, entityManager, storageType);
        log.debug("Constructor V 2 called");
    }   

    @Override
    public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType)
    {
     log.debug("Create Method Called for the Component");
    }
    @Override
     public void remove(int publicationId, int componentId, int componentTemplateId, ComponentPresentationTypeEnum componentPresentationType)
    {
     log.debug("Remove Method Called for the Component");

    }

    @Override
     public void remove(ComponentPresentation itemToRemove, ComponentPresentationTypeEnum componentPresentationType) throws StorageException {
        log.debug("1.Remove Method Called for the Component");

    }

}
2

2 Answers 2

6

The behavior is because of the way the storage layer function for Tridion Docs.

As we know in Tridion Docs only Publications can be published/unpublished. While publishing, the storage layer stores the Publication along with its items (Page => Topic + Template, Component Presentations => Topic + Template) individually so the create methods execute for items individually. During unpublishing though, storage layer triggers call to remove the publication only. The dependent items get removed from the storage(Broker DB) along with the publication.

Based on the above, only the "Remove" method of a publication gets triggered (and of a component presentation) on unpublishing a publication.

So I had to override the Remove function for Publication in my storage extension and place logic there. It has the signature as below:

remove(int namespaceId, int publicationId)

Please note, one should use the 11.0.0 artifacts or late, the above-mentioned method is not present in the earlier versions.

2

Instead of doing @Override, can you just call super.remove(), as per the example here?:

https://pankajgaur83.wordpress.com/2014/07/18/tridion-2013-storage-extension-for-dynamic-component-presentations/

1
  • 1
    The @override annotation doesn't make any difference when it comes to the execution of the program. It is just a good Java practice and used by the compiler to an extent. I will try without it still. Also, in my actual code, I call super.remove() after the logging statement. Commented Sep 27, 2019 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.