Hi,
In AEM 6.5, we have an OOTB solution in AEM sites to archive a page before deleting it and restoring it later; however, can we achieve the same for content fragment before deleting it? Is there any OOTB way? If not, what is the alternative?
Archive option when deleting a page:
Thanks
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
In AEM 6.5 there is no out-of-the-box (OOTB) solution to archive and restore content fragments like there is for pages.
If this is required - you have to create a custom service or event handler - before deleting a content fragment, move it to an "archive" location in the JCR repository. same for restore archived content fragment.
some sample code:
@service
public class ContentFragmentArchivingService {
@reference
private ResourceResolverFactory resolverFactory;
public void archiveContentFragment(String pathToFragment) throws PersistenceException {
ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null);
//ContentFragment contentFragment = resource.adaptTo(ContentFragment.class);
Session session = resolver.adaptTo(Session.class);
String archivePath = "/content/dam/archive/" + StringUtils.substringAfterLast(pathToFragment, "/");
session.move(pathToFragment, archivePath);
session.save();
}
}
In AEM 6.5 there is no out-of-the-box (OOTB) solution to archive and restore content fragments like there is for pages.
If this is required - you have to create a custom service or event handler - before deleting a content fragment, move it to an "archive" location in the JCR repository. same for restore archived content fragment.
some sample code:
@service
public class ContentFragmentArchivingService {
@reference
private ResourceResolverFactory resolverFactory;
public void archiveContentFragment(String pathToFragment) throws PersistenceException {
ResourceResolver resolver = resolverFactory.getServiceResourceResolver(null);
//ContentFragment contentFragment = resource.adaptTo(ContentFragment.class);
Session session = resolver.adaptTo(Session.class);
String archivePath = "/content/dam/archive/" + StringUtils.substringAfterLast(pathToFragment, "/");
session.move(pathToFragment, archivePath);
session.save();
}
}
Hi @nkoppul1
Use the versioning feature in AEM to create a new version of the content fragment before deleting it. This will allow you to restore the previous version of the content fragment if needed.
Create a custom workflow in AEM that archives the content fragment before deleting it. This workflow can be triggered when the content fragment is deleted.
Use a third-party tool or plugin that provides archiving functionality for content fragments in AEM.
There is no OOTB functionality to Archive the Content Fragments.
The Alternative will depend upon what you want to achieve from the Archive?
Views
Likes
Replies
Views
Likes
Replies