Author: bpapez
Date: Fri Nov  9 14:28:46 2007
New Revision: 19106

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19106&repname=
=3Djahia
Log:
new getPageIDsWithAclIDs method and add limitation size attribute for getUn=
checkedPageSubTreeIDs

Modified:
    trunk/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java
    trunk/core/src/java/org/jahia/services/pages/JahiaPageService.java

Modified: trunk/core/src/java/org/jahia/services/pages/JahiaPageBaseService=
.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/pages/JahiaPageBaseService.java&rev=3D19106&repname=3Djah=
ia
=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
--- trunk/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java =
(original)
+++ trunk/core/src/java/org/jahia/services/pages/JahiaPageBaseService.java =
Fri Nov  9 14:28:46 2007
@@ -37,7 +37,6 @@
 import org.jahia.services.acl.JahiaBaseACL;
 import org.jahia.services.cache.Cache;
 import org.jahia.services.cache.CacheService;
-import org.jahia.services.cache.GroupCacheKey;
 import org.jahia.services.events.JahiaEventGeneratorBaseService;
 import org.jahia.services.fields.ContentField;
 import org.jahia.services.sites.JahiaSite;
@@ -45,7 +44,7 @@
 import org.jahia.services.version.EntryLoadRequest;
 import org.jahia.services.workflow.WorkflowEvent;
 import org.jahia.utils.JahiaTools;
-import org.springframework.util.StopWatch;
+import org.jahia.utils.LanguageCodeConverters;
 =

 import java.io.IOException;
 import java.io.InputStream;
@@ -200,13 +199,6 @@
         // Get the next available counter.
         int pageID =3D 0;
 =

-        // No page hits until now ;)
-        int counter =3D 0;
-
-        // Get the current date.
-        String dateOfCreation =3D new Long( (new java.util.Date()).getTime=
()).
-                                toString();
-
         ContentPage linkedPage =3D null;
         JahiaBaseACL acl =3D null;
 =

@@ -296,7 +288,6 @@
         //jParam.getLocale().toString());
         Vector pageInfoVector =3D new Vector();
         pageInfoVector.add(pageInfo);
-        dateOfCreation =3D null;
 =

         // insert the page info into the database.
         try {
@@ -356,8 +347,8 @@
                 .getJahiaContainersService()
                           .getContainerListIDsInPage(contentPage,
             jParams.getEntryLoadRequest());
-        for (int i =3D 0; i < cListIDs.size(); i++) {
-            int cListID =3D ((Integer) cListIDs.elementAt(i)).intValue();
+        for (Iterator it =3D cListIDs.iterator(); it.hasNext();) {
+            int cListID =3D ((Integer) it.next()).intValue();
             logger.debug("Deleting container list ID " + cListID);
             ServicesRegistry.getInstance().getJahiaContainersService().
                     deleteContainerList(cListID, jParams);
@@ -371,8 +362,8 @@
             throws JahiaException {
         List fieldIDs =3D ServicesRegistry.getInstance().getJahiaFieldServ=
ice().
                 getNonContainerFieldIDsInPage(thePage.getID());
-        for (int i =3D 0; i < fieldIDs.size(); i++) {
-            int fieldID =3D ((Integer) fieldIDs.get(i)).intValue();
+        for (Iterator it =3D fieldIDs.iterator(); it.hasNext();) {        =
    =

+            int fieldID =3D ((Integer) it.next()).intValue();
             ServicesRegistry.getInstance().getJahiaFieldService().deleteFi=
eld(
                 fieldID,
                     jParam);
@@ -385,8 +376,8 @@
     private void deleteLinksOnPage(JahiaPage thePage, ProcessingContext jP=
aram)
             throws JahiaException {
         Vector links =3D getPagesPointingOnPage(thePage.getID(), jParam);
-        for (int i =3D 0; i < links.size(); i++) {
-            JahiaPage theLink =3D (JahiaPage) links.elementAt(i);
+        for (Iterator it =3D links.iterator(); it.hasNext();) {        =

+            JahiaPage theLink =3D (JahiaPage) it.next();
             int fieldID =3D pageManager.getPageFieldID(theLink.getID());
             if (fieldID !=3D -1) {
                 ServicesRegistry.getInstance().getJahiaFieldService().
@@ -532,9 +523,9 @@
 =

             // for each page ID, lookup the page, and check if the page
             // matches the load flags and if the user is authorized to see=
 it.
-            for (int i =3D 0; i < allPages.size(); i++) {
+            for (Iterator it =3D allPages.iterator(); it.hasNext();) {    =
        =

                 try {
-                    Integer id =3D (Integer) allPages.get(i);
+                    Integer id =3D (Integer) it.next();
                     if (id.intValue() > 0) {
                         JahiaPage page =3D lookupPage(id.intValue(),
                                 jParam.getEntryLoadRequest(),
@@ -626,8 +617,20 @@
 =

         return pageManager.getPageIDsWithTemplate(templateID);
     }
+    =

+    /**
+     * Retrieves all the page IDs that have the specified ACL-IDs
+     *
+     * @param aclIDs a Set of ACL-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occurre=
d.
+     * @returns Returns a List of page IDs stored as Integers. =

+     */
+    public List getPageIDsWithAclIDs(Set aclIDs) throws JahiaException {
+        return pageManager.getPageIDsWithAclIDs(aclIDs);
+    }            =

 =

-    //--------------------------------------------------------------------=
-----
+    // -------------------------------------------------------------------=
------
     /**
      * Returns the page field id  that is parent of the given pageId.
      * The order is by workflows state from most staged to active.
@@ -753,10 +756,9 @@
                                  (ContentPage.STAGING_PAGE_INFOS | Content=
Page.ACTIVE_PAGE_INFOS),
                                  ContentObject.SHARED_LANGUAGE,directPageO=
nly);
 =

-        int size =3D contentPageChilds.size();
         // For each child page ID, get the page reference.
-        for (int i =3D 0; i < size; i++) {
-            ContentPage contentPage =3D (ContentPage) contentPageChilds.ge=
t(i);
+        for (Iterator it =3D contentPageChilds.iterator(); it.hasNext();) {
+            ContentPage contentPage =3D (ContentPage) it.next();
 =

             // try to get the page reference.
             try {
@@ -777,8 +779,6 @@
             }
         }
 =

-        contentPageChilds =3D null;
-
         // sort pages by IDs
         sortPages(childs);
         return childs;
@@ -846,8 +846,8 @@
         JahiaPageService jahiaPageService =3D ServicesRegistry.getInstance=
().
                         getJahiaPageService();
         // For each child page ID, get the page reference.
-        for (int i =3D 0; i < childIDs.size(); i++) {
-            Integer id =3D (Integer) childIDs.get(i);
+        for (Iterator it =3D childIDs.iterator(); it.hasNext();) {        =

+            Integer id =3D (Integer) it.next();
             // try to get the page reference.
             try {
                 ContentPage pageContent =3D jahiaPageService.lookupContent=
Page(id.intValue(),
@@ -941,10 +941,9 @@
             childIDs =3D pageManager.getStagingPageChildIDs(pageID);
             List activeChildIDs =3D pageManager.getActivePageChildIDs(page=
ID);
             // add the deleted childs too
-            int size =3D activeChildIDs.size();
             Integer I =3D null;
-            for ( int i=3D0; i<size; i++ ){
-                I =3D (Integer)activeChildIDs.get(i);
+            for (Iterator it =3D activeChildIDs.iterator(); it.hasNext();){
+                I =3D (Integer)it.next();
                 if ( !childIDs.contains(I) ){
                     int size2 =3D childIDs.size();
                     Integer J =3D null;
@@ -973,10 +972,9 @@
             childIDs =3D pageManager.getVersioningPageChildIDs(pageID, ver=
sionId);
             List stagingChildIDs =3D pageManager.getStagingPageChildIDs(pa=
geID);
             // add the deleted childs too
-            int size =3D stagingChildIDs.size();
             Integer I =3D null;
-            for ( int i=3D0; i<size; i++ ){
-                I =3D (Integer)stagingChildIDs.get(i);
+            for (Iterator it =3D stagingChildIDs.iterator(); it.hasNext();=
){            =

+                I =3D (Integer)it.next();
                 if ( !childIDs.contains(I) ){
                     int size2 =3D childIDs.size();
                     Integer J =3D null;
@@ -1048,8 +1046,8 @@
 */
 =

         // For each child page ID, get the page reference.
-        for (int i =3D 0; i < childIDs.size(); i++) {
-            Integer id =3D (Integer) childIDs.get(i);
+        for (Iterator it =3D childIDs.iterator(); it.hasNext();){        =

+            Integer id =3D (Integer) it.next();
             // try to get the page reference.
             try {
 =

@@ -1078,7 +1076,7 @@
                 // resulting Vector.
             }
         }
-        childIDs =3D null;
+
         return childs;
     }
 =

@@ -1104,22 +1102,19 @@
             throws JahiaException {
         logger.debug("getting page childs for page=3D" + pageID + ", loadF=
lags=3D" + pageInfosFlag + ", languageCode=3D" + languageCode + ", directPa=
geOnly=3D" +  directPageOnly);
         Vector childs =3D new Vector();
-        List childIDs =3D null;
-        if (childIDs =3D=3D null) {
-            // get all the child page IDs
-            childIDs =3D pageManager.getPageChildIDs(pageID);
-            // FIXME : NO SUPPORT FOR VERSIONING
-            // mPageChildIDsCache.put(intPageID, childIDs);
-        }
+        // get all the child page IDs        =

+        List childIDs =3D pageManager.getPageChildIDs(pageID);
+        // FIXME : NO SUPPORT FOR VERSIONING
+        // mPageChildIDsCache.put(intPageID, childIDs);
 =

         EntryLoadRequest loadRequest =3D null;
         ArrayList langs =3D new ArrayList();
         langs.add(
-                org.jahia.utils.LanguageCodeConverters.languageCodeToLocal=
e(
+                LanguageCodeConverters.languageCodeToLocale(
                         ContentField.SHARED_LANGUAGE));
         if (languageCode !=3D null) {
             langs.add(
-                org.jahia.utils.LanguageCodeConverters.languageCodeToLocal=
e(
+                LanguageCodeConverters.languageCodeToLocale(
                 languageCode));
         }
         if ((pageInfosFlag & ContentPage.STAGING_PAGE_INFOS) !=3D 0) {
@@ -1141,8 +1136,8 @@
         }
 =

         // For each child page ID, get the page reference.
-        for (int i =3D 0; i < childIDs.size(); i++) {
-            Integer id =3D (Integer) childIDs.get(i);
+        for (Iterator it =3D childIDs.iterator(); it.hasNext();) {
+            Integer id =3D (Integer) it.next();
             // try to get the page reference.
             try {
 =

@@ -1202,7 +1197,7 @@
                 // resulting Vector.
             }
         }
-        childIDs =3D null;
+
         return childs;
     }
 =

@@ -1403,10 +1398,10 @@
 =

         Vector pages =3D new Vector();
         List pageIDs =3D pageManager.getPageIDsPointingOnPage(pageID, load=
Request);
-
-        for (int i =3D 0; i < pageIDs.size(); i++) {
+        =

+        for (Iterator it =3D pageIDs.iterator(); it.hasNext();) {
             // get the page ID
-            int pID =3D ((Integer) pageIDs.get(i)).intValue();
+            int pID =3D ((Integer) it.next()).intValue();
 =

             // get the page reference
             try {
@@ -1442,9 +1437,9 @@
 =

         Vector subTree =3D getPageChilds(pageID, loadFlag, jParam);
         Vector results =3D new Vector(subTree);
-        for (int i =3D 0; i < subTree.size(); i++) {
-            JahiaPage aPage =3D (JahiaPage) subTree.elementAt(i);
-            results.addAll(results.size(),getPageSubTree(aPage.getID(), lo=
adFlag, jParam,pageID));
+        for (Iterator it =3D subTree.iterator(); it.hasNext(); ) {
+            JahiaPage aPage =3D (JahiaPage) it.next();
+            results.addAll(getPageSubTree(aPage.getID(), loadFlag, jParam,=
pageID));
 //            aPage =3D null;
         }
 =

@@ -1456,38 +1451,72 @@
 =

         Vector subTree =3D getPageChilds(pageID, loadFlag, jParam);
         Vector results =3D new Vector(subTree);
-        for (int i =3D 0; i < subTree.size(); i++) {
-            JahiaPage aPage =3D (JahiaPage) subTree.elementAt(i);
+        for (Iterator it =3D subTree.iterator(); it.hasNext(); ) {
+            JahiaPage aPage =3D (JahiaPage) it.next();
             if ( aPage.getID() =3D=3D startPage ){
                 continue;
             }
-            results.addAll(results.size(),getPageSubTree(aPage.getID(), lo=
adFlag, jParam, startPage));
+            results.addAll(getPageSubTree(aPage.getID(), loadFlag, jParam,=
 startPage));
 //            aPage =3D null;
         }
 =

         return results;
     }
 =

-    public Set getUncheckedPageSubTreeIDs(int pageID)
-            throws JahiaException {
-        StopWatch stopWatch =3D new StopWatch("getUncheckedPageSubTreeIDs"=
);
-        stopWatch.start("start for page "+ pageID);
-        Set subTree =3D getPageChildsIds(pageID);
-        Set results =3D new HashSet(subTree);
-        Iterator it =3D subTree.iterator();
-        while (it.hasNext()) {
-            Integer pageId =3D (Integer) it.next();
-            results.addAll(getUncheckedPageSubTreeIDs(pageId.intValue()));
-        }
-        stopWatch.stop();
-//        logger.debug(stopWatch.prettyPrint());
+    /**
+     * Gets page-IDs of complete subtree under page not checked for any ri=
ghts or workflow status
+     *
+     * @param pageID   Page unique identification number.
+     *
+     * @return Return a Set of page-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occured.
+     */
+    public Set getUncheckedPageSubTreeIDs(int pageID) throws JahiaExceptio=
n {
+        return getUncheckedPageSubTreeIDs(pageID, false, 0);
+    }
+  =

+    =

+    /**
+     * Gets page-IDs of complete subtree under page not checked for any ri=
ghts or workflow status.
+     *
+     * @param pageID            Page unique identification number.
+     * @param withoutDeleted    If true, deleted or "marked-for-delete" pa=
ges are not returned  =

+     * @param limitedReturnSize If the given size is reached (or exceeded)=
 the method stops iterating =

+     *                          through the child pages (0=3Dunlimited)
+     * =

+     * @return Return a Set of page-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occured.
+     */    =

+    public Set getUncheckedPageSubTreeIDs(int pageID, =

+            boolean withoutDeleted, int limitedReturnSize) throws JahiaExc=
eption {
+
+        Set results =3D new HashSet(limitedReturnSize > 0 ? limitedReturnS=
ize : 50);
+        results =3D getUncheckedPageSubTreeIDs(pageID, withoutDeleted, =

+                limitedReturnSize, results);
+        =

         return results;
     }
 =

-    private Set getPageChildsIds(int pageID) {
-        return new HashSet(pageManager.getPageChildIDs(pageID));
-    }
+    protected Set getUncheckedPageSubTreeIDs(int pageID, =

+            boolean withoutDeleted, int limitedReturnSize, Set results) th=
rows JahiaException {
 =

+        List childIDs =3D withoutDeleted ? pageManager
+                .getNonDeletedPageChildIDs(pageID) : pageManager
+                .getPageChildIDs(pageID);
+        results.addAll(childIDs);
+        =

+        for (Iterator it =3D childIDs.iterator(); it.hasNext() && (limited=
ReturnSize =3D=3D 0 || results.size() < limitedReturnSize);) {
+            int aPageID =3D ((Integer) it.next()).intValue();
+
+            results =3D getUncheckedPageSubTreeIDs(aPageID, withoutDeleted=
, =

+                    limitedReturnSize, results);
+        }        =

+        =

+        return results;
+    }    =

+    =

     public synchronized void start()
         throws JahiaInitializationException {
         logger.debug("** Initializing the Page Service ...");
@@ -2065,8 +2094,8 @@
                                         jParam.getEntryLoadRequest());
 =

         int cListID;
-        for (int i =3D 0; i < cListIDs.size(); i++) {
-            cListID =3D ((Integer) cListIDs.elementAt(i)).intValue();
+        for (Iterator it =3D cListIDs.iterator(); it.hasNext();) {        =

+            cListID =3D ((Integer) it.next()).intValue();
 =

             sReg.getJahiaContainersService().cloneContainerList(cListID, p=
ageID,
                 pageAclID,
@@ -2082,10 +2111,9 @@
 =

         int fieldID;
         JahiaField field;
-
-        for (int i =3D 0; i < fieldIDs.size(); i++) {
+        for (Iterator it =3D fieldIDs.iterator(); it.hasNext();) {
             // @toto : clone field inn multi-language
-            fieldID =3D ((Integer) fieldIDs.get(i)).intValue();
+            fieldID =3D ((Integer) it.next()).intValue();
             field =3D
                 sReg.getJahiaFieldService().loadField(fieldID,
                 LoadFlags.NOTHING, jParam);

Modified: trunk/core/src/java/org/jahia/services/pages/JahiaPageService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/pages/JahiaPageService.java&rev=3D19106&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
--- trunk/core/src/java/org/jahia/services/pages/JahiaPageService.java (ori=
ginal)
+++ trunk/core/src/java/org/jahia/services/pages/JahiaPageService.java Fri =
Nov  9 14:28:46 2007
@@ -218,12 +218,23 @@
      * @param templateID the identifier of the template we want the page I=
Ds
      *                   for
      *
-     * @throws JahiaException Return this exception if any failure occured.
-     * @returns Returns a Vector of page IDs stored as Integers. The Vector
+     * @throws JahiaException Return this exception if any failure occurre=
d.
+     * @returns Returns a List of page IDs stored as Integers. The List
      * might be empty if no page was found.
      */
     public abstract List getPageIDsWithTemplate (int templateID)
             throws JahiaException;
+    =

+    /**
+     * Retrieves all the page IDs that have the specified ACL-IDs
+     *
+     * @param aclIDs a Set of ACL-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occurre=
d.
+     * @returns Returns a List of page IDs stored as Integers. =

+     */
+    public abstract List getPageIDsWithAclIDs (Set aclIDs)
+            throws JahiaException;    =

 =

     //--------------------------------------------------------------------=
-----
     /**
@@ -539,8 +550,35 @@
             int loadFlag,
             ProcessingContext jParam)
             throws JahiaException;
-    public abstract Set getUncheckedPageSubTreeIDs(int pageID) throws Jahi=
aException;
-    //--------------------------------------------------------------------=
-----
+    =

+    /**
+     * Gets page-IDs of complete subtree under page not checked for any ri=
ghts or workflow status
+     *
+     * @param pageID   Page unique identification number.
+     *
+     * @return Return a Set of page-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occured.
+     */
+    public abstract Set getUncheckedPageSubTreeIDs(int pageID)
+            throws JahiaException;
+
+    /**
+     * Gets page-IDs of complete subtree under page not checked for any ri=
ghts or workflow status.
+     *
+     * @param pageID            Page unique identification number.
+     * @param withoutDeleted    If true, deleted or "marked-for-delete" pa=
ges are not returned  =

+     * @param limitedReturnSize If the given size is reached (or exceeded)=
 the method stops iterating =

+     *                          through the child pages (0=3Dunlimited)
+     * =

+     * @return Return a Set of page-IDs
+     *
+     * @throws JahiaException Return this exception if any failure occured.
+     */    =

+    public abstract Set getUncheckedPageSubTreeIDs(int pageID, =

+            boolean withoutDeleted, int limitedReturnSize) throws JahiaExc=
eption;
+    =

+    // -------------------------------------------------------------------=
------
     /**
      * Try to find the specified page. Create a new JahiaPage object, in
      * which will be included a reference to the raw page info, a reference

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

Reply via email to