Problem for index deleted file vfs in search

View: New views
2 Messages — Rating Filter:   Alert me  

Problem for index deleted file vfs in search

by Deiverson Silveira-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alex and List,

I'm trying index deleted files, I can list files, and show me in moment with rebuild but, when I try to not look files.

I'm custom function rebuildIndex in class CmsVfsIndexerDeletedFiles:

public void rebuildIndex(IndexWriter writer, CmsIndexingThreadManager threadManager, CmsSearchIndexSource source)
    throws CmsIndexException {
    System.out.println("Entrou no RebuildIndex");
        List resourceNames = source.getResourcesNames();
        Iterator i = resourceNames.iterator();
        while (i.hasNext()) {
            // read the resources from all configured source folders
            String resourceName = (String)i.next();
            List resources = null;
            List resourceDeleted = null;
            try {
                // read all resources (only files) below the given path
                resources = m_cms.readResources(resourceName, CmsResourceFilter.DEFAULT.addRequireFile());
                // read resource deleted and add in List
                resourceDeleted = m_cms.readDeletedResources(resourceName,true);
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

            } catch (CmsException e) {
            System.out.println("Entrou CmsException");
                if (m_report != null) {
                    System.out.println("Entrou CmsException 1");
                    m_report.println(Messages.get().container(
                        Messages.RPT_UNABLE_TO_READ_SOURCE_2,
                        resourceName,
                        e.getLocalizedMessage()), I_CmsReport.FORMAT_WARNING);
                }
                if (LOG.isWarnEnabled()) {
                    System.out.println("Entrou CmsException 2");
                    LOG.warn(Messages.get().getBundle().key(
                        Messages.LOG_UNABLE_TO_READ_SOURCE_2,
                        resourceName,
                        m_index.getName()), e);
                }
            }
            if (resources != null) {
                // iterate all resources found in the folder
                Iterator j = resources.iterator();
                while (j.hasNext()) {
                    // now update all the resources individually
                    CmsResource resource = (CmsResource)j.next();
                    updateResource(writer, threadManager, resource);
                }
            }
            if (resourceDeleted != null) {
                // iterate all resources found in the folder
                Iterator j = resourceDeleted.iterator();
                while (j.hasNext()) {
                    // now update resource deleted
                    CmsResource resource = (CmsResource)j.next();
                    updateResource(writer, threadManager, resource); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                }
            }
        }
    }

But result dont work, i tested wirh Luke, dont sucess,
you can tell me what is missing I can do to perform search with deleted files?

Thanks for any help and Kind Regards,

Deiverson Silveira


_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev

Re: Problem for index deleted file vfs in search

by Michael Moossen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Deiverson!

first, what do you mean by deleted? marked as deleted or actually deleted?

then,
 >                 resources = m_cms.readResources(resourceName,
 > CmsResourceFilter.DEFAULT.addRequireFile());
this method wont include files MARKED as deleted. if you want to read
files MARKED as deleted use CmsResourceFilter.ALL instead of
CmsResourceFilter.DEFAULT.

 >                 resourceDeleted =
 > m_cms.readDeletedResources(resourceName,true);
this method will return resources that no longer exists in VFS but in
the history, ie. CmsHistoryFile objects instead of CmsResource objects.
ie. if you do not have the history feature activated there wont be any.

HTH

-------------------
Michael Moossen

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

Deiverson Silveira schrieb:

> Hi Alex and List,
>
> I'm trying index deleted files, I can list files, and show me in moment
> with rebuild but, when I try to not look files.
>
> I'm custom function rebuildIndex in class CmsVfsIndexerDeletedFiles:
>
> public void rebuildIndex(IndexWriter writer, CmsIndexingThreadManager
> threadManager, CmsSearchIndexSource source)
>     throws CmsIndexException {
>     System.out.println("Entrou no RebuildIndex");
>         List resourceNames = source.getResourcesNames();
>         Iterator i = resourceNames.iterator();
>         while (i.hasNext()) {
>             // read the resources from all configured source folders
>             String resourceName = (String)i.next();
>             List resources = null;
>             List resourceDeleted = null;
>             try {
>                 // read all resources (only files) below the given path
>                 resources = m_cms.readResources(resourceName,
> CmsResourceFilter.DEFAULT.addRequireFile());
>                 // read resource deleted and add in List
>                 resourceDeleted =
> m_cms.readDeletedResources(resourceName,true);//
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>             } catch (CmsException e) {
>             System.out.println("Entrou CmsException");
>                 if (m_report != null) {
>                     System.out.println("Entrou CmsException 1");
>                     m_report.println(Messages.get().container(
>                         Messages.RPT_UNABLE_TO_READ_SOURCE_2,
>                         resourceName,
>                         e.getLocalizedMessage()),
> I_CmsReport.FORMAT_WARNING);
>                 }
>                 if (LOG.isWarnEnabled()) {
>                     System.out.println("Entrou CmsException 2");
>                     LOG.warn(Messages.get().getBundle().key(
>                         Messages.LOG_UNABLE_TO_READ_SOURCE_2,
>                         resourceName,
>                         m_index.getName()), e);
>                 }
>             }
>             if (resources != null) {
>                 // iterate all resources found in the folder
>                 Iterator j = resources.iterator();
>                 while (j.hasNext()) {
>                     // now update all the resources individually
>                     CmsResource resource = (CmsResource)j.next();
>                     updateResource(writer, threadManager, resource);
>                 }
>             }
>             if (resourceDeleted != null) {
>                 // iterate all resources found in the folder
>                 Iterator j = resourceDeleted.iterator();
>                 while (j.hasNext()) {
>                     // now update resource deleted
>                     CmsResource resource = (CmsResource)j.next();
>                     updateResource(writer, threadManager, resource); //
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>                 }
>             }
>         }
>     }
>
> But result dont work, i tested wirh Luke, dont sucess, you can tell me
> what is missing I can do to perform search with deleted files?
>
> Thanks for any help and Kind Regards,
>
> Deiverson Silveira
>
>
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev