In the previous blog, we set up the project and configured all the required config and based on that we published a DCP and saw custom logs are available which means everything is working fine.
Today we are going to read the content of DCP and will see how Storage Extension work when we publish, re-publish and un-publish an item.
The Content is available in the form of Bytes and we need to convert that, below is the code snippet that will allow you to access the DCP content in your custom code.
Today we are going to read the content of DCP and will see how Storage Extension work when we publish, re-publish and un-publish an item.
The Content is available in the form of Bytes and we need to convert that, below is the code snippet that will allow you to access the DCP content in your custom code.
public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType)
throws StorageException
{
super.create(itemToCreate,componentPresentationType);
log.debug("Custom Code Create Method COMID :- " + itemToCreate.getComponentId());
log.debug("Custom Storage create Method:- "+ itemToCreate.getContent());
log.debug(String.valueOf(itemToCreate.getComponentId()));
byte[] dcpComponent= itemToCreate.getContent();
try
{
componentPresentation = new String(dcpComponent,"UTF-8");
log.debug("Custom Storage create DCP :- " + componentPresentation);
}
catch (UnsupportedEncodingException ex)
{
log.error("Custom Storage create Unsupported " + ex);
}
}
DCP content |
Publish a new component and in the deployer log file, you will see the DCP content but what will happen when we re-publish the same component or un-publish this. How we are going to manage that in the custom code, will see in the next blog, until then.
Happy Coding and Keep Sharing !!!