cancel
Showing results for 
Search instead for 
Did you mean: 

Content Filter

Former Member
0 Kudos

Hi,

We are creating content using XML forms.Say, we have country/language as fields in the form, Based on the value, i need to filter out content. i.e display only content with language=en.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi,

you could implement a Namespace Filter, see http://help.sap.com/saphelp_nw04/helpdata/en/c1/902ae120a886459b0e028f2e89ffe1/frameset.htm and

Hope it helps

Detlev

PS: Please consider rewarding points for helpsul answers on SDN! Thanks in advance.

Former Member
0 Kudos

Detlev,

The filter needs to be based on the content of the documents. and not based on the file types.

Is there anyway to filter based on the content of the doc?

detlev_beutner
Active Contributor
0 Kudos

Hi,

> The filter needs to be based on the content

> of the documents. and not based on the file types

Who says that a namespace filter is only able to filter based on "file types"?! Within the configuration, you declare if you want to restrict the filtering on certain type(s) (and that is what you want here, you want to restrict it on XML forms files).

What you will filter depends on your own implementation; you will have the collection at hand, from this each document, and you can have a look inside the document, to check whether you want to sort it out or not.

A second possibility - faster at runtime - would be to map the field to a property (maybe a custom property) and to implement a property filter.

Hope it helps

Detlev

Former Member
0 Kudos

Thanks Detlev.This was very useful.

Can anyone point me to a sample namespace filter project?

or if you have written one, could you share it with me.

email: rtbits@gmail.com

Former Member
0 Kudos

Hi Srinivasa,

i am not sure, but think you could do this with the ResourceListFilter. the basic idea is the following you get the collection and then render through IResources, as you can see it here:


import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.repository.*;
import com.sapportals.wcm.repository.service.layout.customizing.*;
import com.sapportals.wcm.service.resourcelistfilter.IResourceListFilter;
import java.util.Date;

public class ResourceListFilterExample implements IResourceListFilter {

	public void filterResourceList(IResourceList list, IParameters parameters)
		throws WcmException
	{
		boolean remove = false;
		IResource currResource = null;		
		IPropertyName ipn = new PropertyName("http://sapportals.com/xmlns/cm", "created");
		IProperty ip = null;
		Date thresholdDate = new Date(System.currentTimeMillis()-86400000L);
			for(IResourceListIterator it = list.listIterator(); it.hasNext();)
				{
					remove = false;
					currResource = it.next();	
					ip = currResource.getProperty(ipn);
					// remove files which are older than our threshold date
					if (ip!=null) if (ip.getDateValue().before(thresholdDate)) remove = true;
					// remove hidden files
					if(currResource.getName().startsWith(".")) remove = true; 
					if(remove) it.remove();
				}
	}
	
	public IResourceListFilter getNewInstance() {
		return new ResourceListFilterExample();
	}

	public ResourceListFilterExample() {
	}
}

Here i make use of the properties map, but i suppose you can also getContent() and then parse XML at this point. I will mail you the project (in KM service wrapper add usual

CrtClassLoaderRegistry.addClassLoader(this.getClass().getClassLoader());

line in init() method).

regards,

ds

Former Member
0 Kudos

One more question related to this,

is it possible to access parameters from request in the filter class. i.e i need to pass the language as en/fr from request and filter contents based on the value passed.

detlev_beutner
Active Contributor
0 Kudos

Hi,

when having some resource (collection / real resource) at hand (which you do when using these filter implementations), you can retrieve the ResourceContext, and from this again the Locale (or the User): resource.getContext().getLocale().

Hope it helps

Detlev

PS: The ResourceListFilter is some filter you can add specifically to a collection renderer, so it does not work in any case. Maybe that's what you can use, too. The NamespaceFilter implementation is more or less equivalent, in addition you have to implement a manager class.