Author: knguyen
Date: Mon Sep  3 10:00:34 2007
New Revision: 18351

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18351&repname=
=3Djahia
Log:
delayed indexation : apply "don't index" rules to site re-indexation.

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/Ja=
hiaSiteIndexingJob.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/va=
lves/FieldSearchIndexProcessValveImpl.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/sea=
rch/JahiaSiteIndexingJob.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/search/JahiaSiteIndexingJob.java&r=
ev=3D18351&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/Ja=
hiaSiteIndexingJob.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/Ja=
hiaSiteIndexingJob.java Mon Sep  3 10:00:34 2007
@@ -7,6 +7,7 @@
 import org.jahia.utils.JahiaChrono;
 import org.jahia.bin.Jahia;
 import org.jahia.services.containers.JahiaContainersService;
+import org.jahia.services.containers.ContentContainer;
 import org.jahia.services.pages.JahiaPageService;
 import org.jahia.services.pages.ContentPage;
 import org.jahia.services.usermanager.JahiaUser;
@@ -14,6 +15,8 @@
 import org.jahia.services.version.EntryLoadRequest;
 import org.jahia.services.scheduler.BackgroundJob;
 import org.jahia.services.scheduler.RamJob;
+import org.jahia.services.search.indexingscheduler.RuleEvaluationContext;
+import org.jahia.services.search.indexingscheduler.IndexationRuleInterface;
 import org.jahia.hibernate.manager.SpringContextSingleton;
 import org.jahia.hibernate.manager.JahiaContainerDefinitionManager;
 import org.jahia.hibernate.model.indexingjob.JahiaContainerIndexingJob;
@@ -142,7 +145,11 @@
             ApplicationContext ctx =3D SpringContextSingleton.getInstance(=
).getContext();
             JahiaContainerDefinitionManager ctnDefManager =3D (JahiaContai=
nerDefinitionManager)
                     ctx.getBean(JahiaContainerDefinitionManager.class.getN=
ame());
+            ContentPage contentPage =3D null;
+            RuleEvaluationContext ruleCtx =3D null;
+            IndexationRuleInterface rule =3D null;
             while ( it.hasNext() ){
+                rule =3D null;
                 id =3D (Integer)it.next();
                 if ( lastProcessedPage !=3D -1 ){
                     if ( id.intValue() !=3D lastProcessedPage ) {
@@ -152,75 +159,112 @@
                     }
                 }
                 try {
-                    docs =3D ServicesRegistry.getInstance().getJahiaSearch=
Service()
-                        .getIndexableDocumentsForPage(id.intValue(), user);
+                    contentPage =3D ContentPage.getPage(id.intValue());
                 } catch ( Throwable t ){
-                    logger.debug("Exception preparing indexing document fo=
r page " + id, t);
+                    logger.debug("Error retrieving page " + id + " for ind=
exation. Page won't be re-indexed",t);
+                    continue;
                 }
-                if ( docs !=3D null ){
-                    iterator =3D docs.iterator();
-                    doc =3D null;
-                    while ( iterator.hasNext() ){
-                        doc =3D (IndexableDocument)iterator.next();
-                        if ( doc instanceof RemovableDocument ){
-                            toRemove.add(doc);
-                        } else {
-                            toAdd.add(doc);
-                        }
+                if ( contentPage !=3D null ){
+                    ruleCtx =3D new RuleEvaluationContext(contentPage.getO=
bjectKey(), contentPage, processingContext,user);
+                    try {
+                        rule =3D ServicesRegistry.getInstance()
+                            .getJahiaSearchIndexationService()
+                            .evaluateContentIndexationRules(ruleCtx);
+                    } catch ( Throwable t ){
+                        logger.debug("Exeption evaluating indexation rule =
for content page id=3D"
+                                + id, t);
                     }
-                    if ( toAdd.size() > batchSize ){
-                        synchronized (lock){
-                            try {
-                                lock.wait();
-                            } catch ( Throwable t ){
+                }
+                if ( rule =3D=3D null || rule.getIndexationMode() !=3D Ind=
exationRuleInterface.DONT_INDEX ){
+                    try {
+                        docs =3D ServicesRegistry.getInstance().getJahiaSe=
archService()
+                            .getIndexableDocumentsForPage(id.intValue(), u=
ser);
+                    } catch ( Throwable t ){
+                        logger.debug("Exception preparing indexing documen=
t for page " + id, t);
+                    }
+                    if ( docs !=3D null ){
+                        iterator =3D docs.iterator();
+                        doc =3D null;
+                        while ( iterator.hasNext() ){
+                            doc =3D (IndexableDocument)iterator.next();
+                            if ( doc instanceof RemovableDocument ){
+                                toRemove.add(doc);
+                            } else {
+                                toAdd.add(doc);
                             }
                         }
-                        this.processBachIndexation(toRemove,toAdd);
-                        if ( ! saveLastProcessedPage(id) ){
-                            return;
+                        if ( toAdd.size() > batchSize ){
+                            synchronized (lock){
+                                try {
+                                    lock.wait();
+                                } catch ( Throwable t ){
+                                }
+                            }
+                            this.processBachIndexation(toRemove,toAdd);
+                            if ( ! saveLastProcessedPage(id) ){
+                                return;
+                            }
+                            toRemove.clear();
+                            toAdd.clear();
                         }
-                        toRemove.clear();
-                        toAdd.clear();
                     }
-                }
-                ContentPage contentPage =3D null;
-                try {
-                    contentPage =3D ContentPage.getPage(id.intValue());
-                    ctnDefManager.invalidateContainerDefinitionInTemplate(=
contentPage.getPageTemplateID(loadRequest));
-                } catch ( Throwable t ){
-                    logger.debug("Error retrieving page " + id + " for ind=
exation. Page won't be re-indexed",t);
-                    continue;
-                }
+                    try {
+                        ctnDefManager.invalidateContainerDefinitionInTempl=
ate(contentPage.getPageTemplateID(loadRequest));
+                    } catch ( Throwable t ){
+                        logger.debug("Error retrieving page " + id + " for=
 indexation. Page won't be re-indexed",t);
+                        continue;
+                    }
+                }                    =

                 ctnListIds =3D containerService.getContainerListIDsInPage(=
contentPage,loadRequest);
                 ctnListEnum =3D ctnListIds.elements();
-                Map fieldDocs =3D null;
-                Map removeFieldDocs =3D null;
+                ContentContainer ctn =3D null;
+                JahiaContainerIndexingJob  indJob =3D null;
                 while ( ctnListEnum.hasMoreElements() ){
                     listId =3D (Integer)ctnListEnum.nextElement();
                     ctnIds =3D containerService.getctnidsInList(listId.int=
Value(), loadRequest);
                     ctnEnum =3D ctnIds.elements();
                     while ( ctnEnum.hasMoreElements() ){
+                        rule =3D null;
                         ctnId =3D (Integer)ctnEnum.nextElement();
-                        JahiaContainerIndexingJob  indJob =3D new JahiaCon=
tainerIndexingJob (ctnId.intValue(), 0);
+                        ctn =3D null;
                         try {
-                            indJob.prepareBatchIndexation(toRemove,toAdd,u=
ser);
-                        } catch ( Throwable t  ){
-                            logger.debug("Exception preparing indexing doc=
ument for container " + ctnId, t);
+                            ctn =3D ContentContainer.getContainer(ctnId.in=
tValue());
+                        } catch ( Throwable t ){
                             continue;
                         }
-                        if ( toAdd.size() > batchSize ){
-                            synchronized (lock){
+                        if ( ctn !=3D null ){
+                            ruleCtx =3D new RuleEvaluationContext(ctn.getO=
bjectKey(), ctn, processingContext,user);
+                            try {
+                                rule =3D ServicesRegistry.getInstance()
+                                    .getJahiaSearchIndexationService()
+                                    .evaluateContentIndexationRules(ruleCt=
x);
+                            } catch ( Throwable t ){
+                                logger.debug("Exeption evaluating indexati=
on rule for container id=3D"
+                                        + ctnId, t);
+                            }
+                            if ( rule =3D=3D null || rule.getIndexationMod=
e() !=3D IndexationRuleInterface.DONT_INDEX ){
+                                indJob =3D new JahiaContainerIndexingJob (=
ctnId.intValue(), 0);
                                 try {
-                                    lock.wait();
-                                } catch ( Throwable t ){
+                                    indJob.prepareBatchIndexation(toRemove=
,toAdd,user);
+                                } catch ( Throwable t  ){
+                                    logger.debug("Exception preparing inde=
xing document for container " + ctnId, t);
+                                    continue;
+                                }
+                                if ( toAdd.size() > batchSize ){
+                                    synchronized (lock){
+                                        try {
+                                            lock.wait();
+                                        } catch ( Throwable t ){
+                                        }
+                                    }
+                                    this.processBachIndexation(toRemove,to=
Add);
+                                    if ( ! saveLastProcessedPage(id) ){
+                                        return;
+                                    }
+                                    toRemove.clear();
+                                    toAdd.clear();
                                 }
                             }
-                            this.processBachIndexation(toRemove,toAdd);
-                            if ( ! saveLastProcessedPage(id) ){
-                                return;
-                            }
-                            toRemove.clear();
-                            toAdd.clear();
                         }
                     }
                 }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/sea=
rch/valves/FieldSearchIndexProcessValveImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/search/valves/FieldSearchIndexProc=
essValveImpl.java&rev=3D18351&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/va=
lves/FieldSearchIndexProcessValveImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/search/va=
lves/FieldSearchIndexProcessValveImpl.java Mon Sep  3 10:00:34 2007
@@ -243,8 +243,8 @@
                                         while (it.hasNext()){
                                             indexImmediately =3D false;
                                             timeRange =3D (TimeRange)it.ne=
xt();
-                                            fromTime =3D timeRange.getStar=
tHour()+timeRange.getStartMinute();
-                                            toTime =3D timeRange.getEndHou=
r()+timeRange.getEndMinute();
+                                            fromTime =3D timeRange.getStar=
tHour()*60+timeRange.getStartMinute();
+                                            toTime =3D timeRange.getEndHou=
r()*60+timeRange.getEndMinute();
                                             if ( fromTime<toTime && fromTi=
me <=3D hourInMinutes && toTime
                                                     >=3D hourInMinutes ){
                                                 indexImmediately =3D true;

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to