Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to remove the filter path from Content package using Java?

Avatar

Level 2

Hi,

I am trying to find how to completely remove the filter path from the  content package in AEM using Java. My scenario is like, when author deactivate the page, then that particular page path in the filter of the content package has to be removed. And it has to be implemented using Java. If some have solution, Please let me know. I am using com.day.jcr.vault.fs.api.PathFilterSet, com.day.jcr.vault.fs.config.DefaultWorkspaceFilter and  com.day.jcr.vault.packaging.JcrPackageManager. 

 

Regards,

Sai

1 Accepted Solution

Avatar

Correct answer by
Level 10

Looking through the Javadocs - there is no remove filter method. Perhaps look at deleting the package and creating a new one with the updated filter information. 

View solution in original post

7 Replies

Avatar

Level 10

These are the APIs you use to programmatically work with AEM packages. Here is a basic code example:

http://massapi.com/class/com/day/jcr/vault/packaging/JcrPackageManager.html

Avatar

Level 2

Thank you for your response. Above one is to remove the package. Actually I am looking for the thing to remove the particular filterpath from the content package.

Regards,
Sai

Avatar

Correct answer by
Level 10

Looking through the Javadocs - there is no remove filter method. Perhaps look at deleting the package and creating a new one with the updated filter information. 

Avatar

Level 2

Yeah. Do you any method or do you know the way to read all filter paths in  a package?. Because to implement the thing as  you mentioned above, we  should first read the filterpaths of a package. When, I searched the javadocs and I couldn't find it and if you know something about this, please let me know. 

 

Regards,

Sai

Avatar

Level 2

Yeah. Do you any method or do you know the way to read all filter paths in  a package?. Because to implement the thing as  you mentioned above, we  should first read the filterpaths of a package. When, I searched the javadocs and I couldn't find it and if you know something about this, please let me know. 

 

Regards,

Sai

Avatar

Level 10

Look at this:

http://wem.help.adobe.com/enterprise/en_US/10-0/wem/javadoc/com/day/jcr/vault/fs/config/DefaultWorks...()

I agree that we need a good DEV article that shows using these APIS in detail. I am going to add this topic to a list of AEM DEV community articles. 

Avatar

Level 2

To get the filter paths details of the content package, we need to get metaInfo  ad from there we need to get the filterpaths information in a content package.

 

Here is the small snippet of code:

import org.apache.jackrabbit.vault.packaging.JcrPackage;
import org.apache.jackrabbit.vault.packaging.JcrPackageDefinition;
import org.apache.jackrabbit.vault.packaging.JcrPackageManager;

WorkspaceFilter launchPackageFilter = (DefaultWorkspaceFilter) jcrPackage.getDefinition().getMetaInf().getFilter();
                List<PathFilterSet> launchPackageFilterSets = launchPackageFilter.getFilterSets();
                LOG.info("Size of the launchPackageFilterSets ::::::::::::::::::" + launchPackageFilterSets.size());
                DefaultWorkspaceFilter newFilter = new DefaultWorkspaceFilter();
                DefaultWorkspaceFilter ignoreFilter = new DefaultWorkspaceFilter();