Thanks for your time. Sorry, my question was very generic in the initial post. let me post where I am .
I have implemented a filter method the code as below. Our portal server has limitation on ports some reason we are unable to switch on debug port. I have no option to troubleshoot my code in debug mode.
coming to the point, I deployed my project , I can see my filter name in portal, I applied filter on repository but still i did not see the desired output. I added the system.out.print message to see message on the Java console but not writing any logs are any thing...I am not sure what is the location to check these log files....
is there any thing wrong with the below code? It looks good to me....I cannot even see any error. When I deploy, the .ear file deployed fine. I also used logger class , do you know where these log files are get stored?
package com.test.km;
import java.util.logging.Logger;
import com.sap.security.api.IUser;
import com.sap.tc.webdynpro.services.sal.um.api.IWDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;
import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.repository.ICollection;
import com.sapportals.wcm.repository.IResource;
import com.sapportals.wcm.repository.IResourceList;
import com.sapportals.wcm.repository.IResourceListIterator;
import com.sapportals.wcm.repository.PropertyName;
import com.sapportals.wcm.repository.filter.INamespaceFilter;
public class KMDocumentFilter implements INamespaceFilter {
private final INamespaceFilter predecessorFilter;
KMDocumentFilter(INamespaceFilter predecessorFilter) {
this.predecessorFilter = predecessorFilter;
}
public IResourceList filter() throws WcmException {
// TODO Implement filtering (remove resources from the list)
String filename;
IWDClientUser wdUser = null;
IUser portalUser = null;
// get the currently logged in user
try{
wdUser = WDClientUser.getCurrentUser();
portalUser = wdUser.getSAPUser();
} catch (WDUMException e)
{
System.out.println("Error occurred while getting EP User : " + e.toString());
}
Logger.getLogger("Test log").info("user message" + portalUser );
Logger.getLogger("Entered filter() method and predecessorFilter is " ).info("message" + this.predecessorFilter );
IResourceList workingResourceList = this.predecessorFilter.filter();
System.out.println("workingResourceList is " + workingResourceList);
IResourceListIterator workingResourcelistIter = workingResourceList.listIterator();
System.out.println("workingResourceListIter is " + workingResourcelistIter + " and workingResourceList size is " + workingResourceList.size());
while (workingResourcelistIter.hasNext())
{
IResource currentResource = workingResourcelistIter.next();
System.out.print("currentResource is " + currentResource);
if (currentResource != null)
{
System.out.println(" currentResource.isCollection() is " + currentResource.isCollection());
if (!currentResource.isCollection())
{
filename = currentResource.getName().toUpperCase();
if(portalUser != null && filename != null) {
if(portalUser.toString().equalsIgnoreCase(filename.substring(0, filename.indexOf("_")))) {
System.out.println(" File not removed even though name matches");
}else {
workingResourcelistIter.remove();
System.out.println(" File removed");
}
}
}
}
}
return workingResourceList;
//return this.predecessorFilter.filter();
}
public ICollection getCollection() throws WcmException {
return this.predecessorFilter.getCollection();
}
}
Thanks
Krishna