OK

I think this will work for DOCUMENTS OR FOLDERS....
And will resolve issue having document named description_files.

Perhaps not perfect but works...

    public static ContentFilter DOCUMENT_OR_FOLDER_CONTENT_FILTER = new 
ContentFilter() {
        public boolean accept(Content content) {
            try {
                // special case
                if (content.getHandle().equals("/")) {
                    return true;
                } else {
                    // if content type is mgnl:contentNode AND its parent is 
type mgnl:content
                    return 
(content.isNodeType(ItemType.CONTENTNODE.getSystemName()) && 
                            
content.getParent().getNodeType().getName().equals(ItemType.CONTENT.getSystemName())
 );
                }
            } catch (RepositoryException e) {
                log.error("Cannot determine if node=[" + content.getHandle() + 
"] is a document or a folder" , e);
            }
            return false;
        }
    };



Thanks
 
Amir
 

> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 07, 2007 5:14 PM
> To: [email protected]
> Subject: [magnolia-dev] ContentFilter....
> 
> Hi everyone
> 
> 
> I am experimenting with ContentUtil.visit() and am writing a 
> tag to display folders and documents in DMS as a HTML unordered list.
> However I am having a difficulty "hitting" the right ContentFilter....
> 
> I have following:
> 
>     public static ContentFilter DOCUMENT_CONTENT_FILTER = new 
> ContentFilter() {
>         public boolean accept(Content content) {
>             return 
> content.isNodeType(ItemType.CONTENTNODE.getSystemName());
>         }
>     };
> 
> But this visits documents, folders and documents' description files...
> Here is a log output of visit()
> 
> - visiting level=[3], node=[/library/image/logo]
> - visiting level=[4], node=[/library/image/logo/nemours]
> - visiting level=[5], 
> node=[/library/image/logo/nemours/description_files]
> - visiting level=[4], node=[/library/image/logo/ncc]
> - visiting level=[5], node=[/library/image/logo/ncc/description_files]
> - visiting level=[4], node=[/library/image/logo/nmg]
> - visiting level=[5], node=[/library/image/logo/nmg/description_files]
> - visiting level=[4], node=[/library/image/logo/aidhc]
> - visiting level=[5], 
> node=[/library/image/logo/aidhc/description_files]
> - visiting level=[4], node=[/library/image/logo/npch]
> - visiting level=[5], 
> node=[/library/image/logo/npch/description_files]
> - visiting level=[4], node=[/library/image/logo/nhc]
> - visiting level=[5], node=[/library/image/logo/nhc/description_files]
> 
> 
> 
> Doing a query (via dev tools) I can see that 
> 
> - documents are mgnl:contentNode
> - description_files are mgnl:contentNode
> - folders are mgnl:content
> 
> 
> So my questions are
> 
> 1. Why is the ContentFilter above visiting folders when I 
> haven't specified it?
> 2. How do you define ContentFilter that visits only 
> docs...only folders....only docs and folders....
>       I saw classes that use (node.getName().startsWith() in 
> accept method but what happens when a user uploads a document 
> named "description_files"....
> 
> Sorry for the long email - I am sure this is all too simple 
> for you developers....
> 
> Thanks 
> 
> Amir
>   
> 
> ----------------------------------------------------------------
> for list details see
> http://documentation.magnolia.info/docs/en/editor/stayupdated.html
> ----------------------------------------------------------------
> 

----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------

Reply via email to