22
33import com .ithit .webdav .server .*;
44import com .ithit .webdav .server .exceptions .*;
5+ import com .ithit .webdav .server .paging .OrderProperty ;
6+ import com .ithit .webdav .server .paging .PageResults ;
57import com .ithit .webdav .server .quota .Quota ;
68import com .ithit .webdav .server .search .Search ;
79import com .ithit .webdav .server .search .SearchOptions ;
@@ -35,11 +37,14 @@ public class FolderImpl extends HierarchyItemImpl implements Folder, Search, Quo
3537 * Gets the array of this folder's children.
3638 *
3739 * @param propNames List of properties to retrieve with the children. They will be queried by the engine later.
38- * @return Array of {@link HierarchyItemImpl} objects. Each item is a {@link FileImpl} or {@link FolderImpl} item.
40+ * @param offset The number of items to skip before returning the remaining items.
41+ * @param nResults The number of items to return.
42+ * @param orderProps List of order properties requested by the client.
43+ * @return Instance of {@link PageResults} class that contains items on a requested page and total number of items in a folder.
3944 * @throws ServerException In case of an error.
4045 */
41- public List < HierarchyItemImpl > getChildren (List <Property > propNames ) throws ServerException {
42- return getDataAccess ().readItems (
46+ public PageResults getChildren (List <Property > propNames , Long offset , Long nResults , List < OrderProperty > orderProps ) throws ServerException {
47+ return new PageResults ( getDataAccess ().readItems (
4348 "SELECT ID," +
4449 " Parent," +
4550 " ItemType," +
@@ -54,7 +59,7 @@ public List<HierarchyItemImpl> getChildren(List<Property> propNames) throws Serv
5459 " AutoVersion," +
5560 " CheckinOnFileComplete"
5661 + " FROM Repository"
57- + " WHERE Parent = ? AND ID != 0" , getPath (), true , id );
62+ + " WHERE Parent = ? AND ID != 0" , getPath (), true , id ), null ) ;
5863 }
5964
6065 /**
@@ -217,7 +222,7 @@ public void moveTo(Folder folder, String destName)
217222 }
218223 // move children
219224 MultistatusException mr = new MultistatusException ();
220- for (HierarchyItem child : getChildren (Collections .<Property >emptyList ())) {
225+ for (HierarchyItem child : getChildren (Collections .<Property >emptyList (), null , null , null ). getPage ( )) {
221226 try {
222227 child .moveTo (newDestFolder , child .getName ());
223228 } catch (MultistatusException e ) {
@@ -274,7 +279,7 @@ public void copyTo(Folder folder, String destName, boolean deep)
274279 // copy children
275280 MultistatusException mr = new MultistatusException ();
276281 if (deep ) {
277- for (HierarchyItemImpl child : getChildren (Collections .<Property >emptyList ())) {
282+ for (HierarchyItem child : getChildren (Collections .<Property >emptyList (), null , null , null ). getPage ( )) {
278283 try {
279284 child .copyTo (newDestFolder , child .getName (), deep );
280285 } catch (MultistatusException ex ) {
@@ -310,7 +315,7 @@ public void delete() throws ServerException, LockedException, MultistatusExcepti
310315
311316 MultistatusException mx = new MultistatusException ();
312317
313- for (HierarchyItem child : getChildren (Collections .<Property >emptyList ())) {
318+ for (HierarchyItem child : getChildren (Collections .<Property >emptyList (), null , null , null ). getPage ( )) {
314319 try {
315320 child .delete ();
316321 } catch (MultistatusException ex ) {
@@ -336,12 +341,12 @@ public void delete() throws ServerException, LockedException, MultistatusExcepti
336341 * @throws ServerException in case of DB errors.
337342 */
338343 void removeTree () throws ServerException {
339- for (HierarchyItemImpl child : getChildren (Collections .<Property >emptyList ())) {
344+ for (HierarchyItem child : getChildren (Collections .<Property >emptyList (), null , null , null ). getPage ( )) {
340345 FolderImpl childFolder = child instanceof FolderImpl ? (FolderImpl ) child : null ;
341346 if (childFolder != null )
342347 childFolder .removeTree ();
343348 else
344- child .deleteThisItem ();
349+ (( HierarchyItemImpl ) child ) .deleteThisItem ();
345350 }
346351 deleteThisItem ();
347352 }
@@ -355,13 +360,13 @@ private boolean clientHasTokenForTree() throws ServerException {
355360
356361 if (!clientHasToken ())
357362 return false ;
358- for (HierarchyItemImpl child : getChildren (Collections .<Property >emptyList ())) {
363+ for (HierarchyItem child : getChildren (Collections .<Property >emptyList (), null , null , null ). getPage ( )) {
359364 FolderImpl childFolder = child instanceof FolderImpl ? (FolderImpl ) child : null ;
360365 if (childFolder != null ) {
361366 if (!childFolder .clientHasTokenForTree ())
362367 return false ;
363368 } else {
364- if (!child .clientHasToken ())
369+ if (!(( HierarchyItemImpl ) child ) .clientHasToken ())
365370 return false ;
366371 }
367372 }
@@ -390,14 +395,16 @@ protected HierarchyItemImpl createItemCopy(int id, int parentId, String name, St
390395 * @param searchString A phrase to search.
391396 * @param options Search parameters.
392397 * @param propNames List of properties to retrieve with the children. They will be queried by the engine later.
393- * @return ist of {@link HierarchyItem} satisfying the search parameters or empty list.
398+ * @param offset The number of items to skip before returning the remaining items.
399+ * @param nResults The number of items to return.
400+ * @return Instance of {@link PageResults} class that contains items on a requested page and total number of items in search results.
394401 */
395402 @ Override
396- public List < HierarchyItem > search (String searchString , SearchOptions options , List <Property > propNames ) {
403+ public PageResults search (String searchString , SearchOptions options , List <Property > propNames , Long offset , Long nResults ) {
397404 List <HierarchyItem > results = new LinkedList <>();
398405 SearchFacade .Searcher searcher = getEngine ().getSearchFacade ().getSearcher ();
399406 if (searcher == null ) {
400- return results ;
407+ return new PageResults ( results , null ) ;
401408 }
402409 boolean snippet = false ;
403410 for (Property pr : propNames ) {
@@ -440,7 +447,7 @@ public List<HierarchyItem> search(String searchString, SearchOptions options, Li
440447 getEngine ().getLogger ().logError ("Error during search." , ex );
441448 }
442449 }
443- return results ;
450+ return new PageResults ( results , null ) ;
444451 }
445452
446453 /**
0 commit comments