001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.document.library.kernel.exception.NoSuchFolderException;
020    import com.liferay.document.library.kernel.model.DLFolder;
021    import com.liferay.document.library.kernel.service.persistence.DLFileEntryTypePersistence;
022    import com.liferay.document.library.kernel.service.persistence.DLFolderPersistence;
023    
024    import com.liferay.portal.kernel.bean.BeanReference;
025    import com.liferay.portal.kernel.dao.orm.EntityCache;
026    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderCache;
028    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
029    import com.liferay.portal.kernel.dao.orm.FinderPath;
030    import com.liferay.portal.kernel.dao.orm.Query;
031    import com.liferay.portal.kernel.dao.orm.QueryPos;
032    import com.liferay.portal.kernel.dao.orm.QueryUtil;
033    import com.liferay.portal.kernel.dao.orm.SQLQuery;
034    import com.liferay.portal.kernel.dao.orm.Session;
035    import com.liferay.portal.kernel.log.Log;
036    import com.liferay.portal.kernel.log.LogFactoryUtil;
037    import com.liferay.portal.kernel.model.CacheModel;
038    import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.kernel.service.ServiceContext;
040    import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
041    import com.liferay.portal.kernel.service.persistence.CompanyProvider;
042    import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
043    import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
044    import com.liferay.portal.kernel.service.persistence.impl.TableMapper;
045    import com.liferay.portal.kernel.service.persistence.impl.TableMapperFactory;
046    import com.liferay.portal.kernel.util.CharPool;
047    import com.liferay.portal.kernel.util.OrderByComparator;
048    import com.liferay.portal.kernel.util.SetUtil;
049    import com.liferay.portal.kernel.util.StringBundler;
050    import com.liferay.portal.kernel.util.StringPool;
051    import com.liferay.portal.kernel.util.StringUtil;
052    import com.liferay.portal.kernel.util.Validator;
053    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
054    
055    import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
056    import com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl;
057    
058    import java.io.Serializable;
059    
060    import java.util.Collections;
061    import java.util.Date;
062    import java.util.HashMap;
063    import java.util.HashSet;
064    import java.util.Iterator;
065    import java.util.List;
066    import java.util.Map;
067    import java.util.Objects;
068    import java.util.Set;
069    
070    /**
071     * The persistence implementation for the document library folder service.
072     *
073     * <p>
074     * Caching information and settings can be found in <code>portal.properties</code>
075     * </p>
076     *
077     * @author Brian Wing Shun Chan
078     * @see DLFolderPersistence
079     * @see com.liferay.document.library.kernel.service.persistence.DLFolderUtil
080     * @generated
081     */
082    @ProviderType
083    public class DLFolderPersistenceImpl extends BasePersistenceImpl<DLFolder>
084            implements DLFolderPersistence {
085            /*
086             * NOTE FOR DEVELOPERS:
087             *
088             * Never modify or reference this class directly. Always use {@link DLFolderUtil} to access the document library folder persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
089             */
090            public static final String FINDER_CLASS_NAME_ENTITY = DLFolderImpl.class.getName();
091            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List1";
093            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094                    ".List2";
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
096                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
099                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
101            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
102                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
104            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
105                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
107                            new String[] {
108                                    String.class.getName(),
109                                    
110                            Integer.class.getName(), Integer.class.getName(),
111                                    OrderByComparator.class.getName()
112                            });
113            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
114                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
116                            new String[] { String.class.getName() },
117                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
118                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
119                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
121                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
123                            new String[] { String.class.getName() });
124    
125            /**
126             * Returns all the document library folders where uuid = &#63;.
127             *
128             * @param uuid the uuid
129             * @return the matching document library folders
130             */
131            @Override
132            public List<DLFolder> findByUuid(String uuid) {
133                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
134            }
135    
136            /**
137             * Returns a range of all the document library folders where uuid = &#63;.
138             *
139             * <p>
140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
141             * </p>
142             *
143             * @param uuid the uuid
144             * @param start the lower bound of the range of document library folders
145             * @param end the upper bound of the range of document library folders (not inclusive)
146             * @return the range of matching document library folders
147             */
148            @Override
149            public List<DLFolder> findByUuid(String uuid, int start, int end) {
150                    return findByUuid(uuid, start, end, null);
151            }
152    
153            /**
154             * Returns an ordered range of all the document library folders where uuid = &#63;.
155             *
156             * <p>
157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
158             * </p>
159             *
160             * @param uuid the uuid
161             * @param start the lower bound of the range of document library folders
162             * @param end the upper bound of the range of document library folders (not inclusive)
163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
164             * @return the ordered range of matching document library folders
165             */
166            @Override
167            public List<DLFolder> findByUuid(String uuid, int start, int end,
168                    OrderByComparator<DLFolder> orderByComparator) {
169                    return findByUuid(uuid, start, end, orderByComparator, true);
170            }
171    
172            /**
173             * Returns an ordered range of all the document library folders where uuid = &#63;.
174             *
175             * <p>
176             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
177             * </p>
178             *
179             * @param uuid the uuid
180             * @param start the lower bound of the range of document library folders
181             * @param end the upper bound of the range of document library folders (not inclusive)
182             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
183             * @param retrieveFromCache whether to retrieve from the finder cache
184             * @return the ordered range of matching document library folders
185             */
186            @Override
187            public List<DLFolder> findByUuid(String uuid, int start, int end,
188                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
189                    boolean pagination = true;
190                    FinderPath finderPath = null;
191                    Object[] finderArgs = null;
192    
193                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
194                                    (orderByComparator == null)) {
195                            pagination = false;
196                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
197                            finderArgs = new Object[] { uuid };
198                    }
199                    else {
200                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
201                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
202                    }
203    
204                    List<DLFolder> list = null;
205    
206                    if (retrieveFromCache) {
207                            list = (List<DLFolder>)finderCache.getResult(finderPath,
208                                            finderArgs, this);
209    
210                            if ((list != null) && !list.isEmpty()) {
211                                    for (DLFolder dlFolder : list) {
212                                            if (!Objects.equals(uuid, dlFolder.getUuid())) {
213                                                    list = null;
214    
215                                                    break;
216                                            }
217                                    }
218                            }
219                    }
220    
221                    if (list == null) {
222                            StringBundler query = null;
223    
224                            if (orderByComparator != null) {
225                                    query = new StringBundler(3 +
226                                                    (orderByComparator.getOrderByFields().length * 2));
227                            }
228                            else {
229                                    query = new StringBundler(3);
230                            }
231    
232                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
233    
234                            boolean bindUuid = false;
235    
236                            if (uuid == null) {
237                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
238                            }
239                            else if (uuid.equals(StringPool.BLANK)) {
240                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
241                            }
242                            else {
243                                    bindUuid = true;
244    
245                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
246                            }
247    
248                            if (orderByComparator != null) {
249                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
250                                            orderByComparator);
251                            }
252                            else
253                             if (pagination) {
254                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
255                            }
256    
257                            String sql = query.toString();
258    
259                            Session session = null;
260    
261                            try {
262                                    session = openSession();
263    
264                                    Query q = session.createQuery(sql);
265    
266                                    QueryPos qPos = QueryPos.getInstance(q);
267    
268                                    if (bindUuid) {
269                                            qPos.add(uuid);
270                                    }
271    
272                                    if (!pagination) {
273                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
274                                                            start, end, false);
275    
276                                            Collections.sort(list);
277    
278                                            list = Collections.unmodifiableList(list);
279                                    }
280                                    else {
281                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
282                                                            start, end);
283                                    }
284    
285                                    cacheResult(list);
286    
287                                    finderCache.putResult(finderPath, finderArgs, list);
288                            }
289                            catch (Exception e) {
290                                    finderCache.removeResult(finderPath, finderArgs);
291    
292                                    throw processException(e);
293                            }
294                            finally {
295                                    closeSession(session);
296                            }
297                    }
298    
299                    return list;
300            }
301    
302            /**
303             * Returns the first document library folder in the ordered set where uuid = &#63;.
304             *
305             * @param uuid the uuid
306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
307             * @return the first matching document library folder
308             * @throws NoSuchFolderException if a matching document library folder could not be found
309             */
310            @Override
311            public DLFolder findByUuid_First(String uuid,
312                    OrderByComparator<DLFolder> orderByComparator)
313                    throws NoSuchFolderException {
314                    DLFolder dlFolder = fetchByUuid_First(uuid, orderByComparator);
315    
316                    if (dlFolder != null) {
317                            return dlFolder;
318                    }
319    
320                    StringBundler msg = new StringBundler(4);
321    
322                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
323    
324                    msg.append("uuid=");
325                    msg.append(uuid);
326    
327                    msg.append(StringPool.CLOSE_CURLY_BRACE);
328    
329                    throw new NoSuchFolderException(msg.toString());
330            }
331    
332            /**
333             * Returns the first document library folder in the ordered set where uuid = &#63;.
334             *
335             * @param uuid the uuid
336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
337             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
338             */
339            @Override
340            public DLFolder fetchByUuid_First(String uuid,
341                    OrderByComparator<DLFolder> orderByComparator) {
342                    List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
343    
344                    if (!list.isEmpty()) {
345                            return list.get(0);
346                    }
347    
348                    return null;
349            }
350    
351            /**
352             * Returns the last document library folder in the ordered set where uuid = &#63;.
353             *
354             * @param uuid the uuid
355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
356             * @return the last matching document library folder
357             * @throws NoSuchFolderException if a matching document library folder could not be found
358             */
359            @Override
360            public DLFolder findByUuid_Last(String uuid,
361                    OrderByComparator<DLFolder> orderByComparator)
362                    throws NoSuchFolderException {
363                    DLFolder dlFolder = fetchByUuid_Last(uuid, orderByComparator);
364    
365                    if (dlFolder != null) {
366                            return dlFolder;
367                    }
368    
369                    StringBundler msg = new StringBundler(4);
370    
371                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
372    
373                    msg.append("uuid=");
374                    msg.append(uuid);
375    
376                    msg.append(StringPool.CLOSE_CURLY_BRACE);
377    
378                    throw new NoSuchFolderException(msg.toString());
379            }
380    
381            /**
382             * Returns the last document library folder in the ordered set where uuid = &#63;.
383             *
384             * @param uuid the uuid
385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
386             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
387             */
388            @Override
389            public DLFolder fetchByUuid_Last(String uuid,
390                    OrderByComparator<DLFolder> orderByComparator) {
391                    int count = countByUuid(uuid);
392    
393                    if (count == 0) {
394                            return null;
395                    }
396    
397                    List<DLFolder> list = findByUuid(uuid, count - 1, count,
398                                    orderByComparator);
399    
400                    if (!list.isEmpty()) {
401                            return list.get(0);
402                    }
403    
404                    return null;
405            }
406    
407            /**
408             * Returns the document library folders before and after the current document library folder in the ordered set where uuid = &#63;.
409             *
410             * @param folderId the primary key of the current document library folder
411             * @param uuid the uuid
412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
413             * @return the previous, current, and next document library folder
414             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
415             */
416            @Override
417            public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
418                    OrderByComparator<DLFolder> orderByComparator)
419                    throws NoSuchFolderException {
420                    DLFolder dlFolder = findByPrimaryKey(folderId);
421    
422                    Session session = null;
423    
424                    try {
425                            session = openSession();
426    
427                            DLFolder[] array = new DLFolderImpl[3];
428    
429                            array[0] = getByUuid_PrevAndNext(session, dlFolder, uuid,
430                                            orderByComparator, true);
431    
432                            array[1] = dlFolder;
433    
434                            array[2] = getByUuid_PrevAndNext(session, dlFolder, uuid,
435                                            orderByComparator, false);
436    
437                            return array;
438                    }
439                    catch (Exception e) {
440                            throw processException(e);
441                    }
442                    finally {
443                            closeSession(session);
444                    }
445            }
446    
447            protected DLFolder getByUuid_PrevAndNext(Session session,
448                    DLFolder dlFolder, String uuid,
449                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
450                    StringBundler query = null;
451    
452                    if (orderByComparator != null) {
453                            query = new StringBundler(4 +
454                                            (orderByComparator.getOrderByConditionFields().length * 3) +
455                                            (orderByComparator.getOrderByFields().length * 3));
456                    }
457                    else {
458                            query = new StringBundler(3);
459                    }
460    
461                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
462    
463                    boolean bindUuid = false;
464    
465                    if (uuid == null) {
466                            query.append(_FINDER_COLUMN_UUID_UUID_1);
467                    }
468                    else if (uuid.equals(StringPool.BLANK)) {
469                            query.append(_FINDER_COLUMN_UUID_UUID_3);
470                    }
471                    else {
472                            bindUuid = true;
473    
474                            query.append(_FINDER_COLUMN_UUID_UUID_2);
475                    }
476    
477                    if (orderByComparator != null) {
478                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
479    
480                            if (orderByConditionFields.length > 0) {
481                                    query.append(WHERE_AND);
482                            }
483    
484                            for (int i = 0; i < orderByConditionFields.length; i++) {
485                                    query.append(_ORDER_BY_ENTITY_ALIAS);
486                                    query.append(orderByConditionFields[i]);
487    
488                                    if ((i + 1) < orderByConditionFields.length) {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
491                                            }
492                                            else {
493                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
494                                            }
495                                    }
496                                    else {
497                                            if (orderByComparator.isAscending() ^ previous) {
498                                                    query.append(WHERE_GREATER_THAN);
499                                            }
500                                            else {
501                                                    query.append(WHERE_LESSER_THAN);
502                                            }
503                                    }
504                            }
505    
506                            query.append(ORDER_BY_CLAUSE);
507    
508                            String[] orderByFields = orderByComparator.getOrderByFields();
509    
510                            for (int i = 0; i < orderByFields.length; i++) {
511                                    query.append(_ORDER_BY_ENTITY_ALIAS);
512                                    query.append(orderByFields[i]);
513    
514                                    if ((i + 1) < orderByFields.length) {
515                                            if (orderByComparator.isAscending() ^ previous) {
516                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
517                                            }
518                                            else {
519                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
520                                            }
521                                    }
522                                    else {
523                                            if (orderByComparator.isAscending() ^ previous) {
524                                                    query.append(ORDER_BY_ASC);
525                                            }
526                                            else {
527                                                    query.append(ORDER_BY_DESC);
528                                            }
529                                    }
530                            }
531                    }
532                    else {
533                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
534                    }
535    
536                    String sql = query.toString();
537    
538                    Query q = session.createQuery(sql);
539    
540                    q.setFirstResult(0);
541                    q.setMaxResults(2);
542    
543                    QueryPos qPos = QueryPos.getInstance(q);
544    
545                    if (bindUuid) {
546                            qPos.add(uuid);
547                    }
548    
549                    if (orderByComparator != null) {
550                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
551    
552                            for (Object value : values) {
553                                    qPos.add(value);
554                            }
555                    }
556    
557                    List<DLFolder> list = q.list();
558    
559                    if (list.size() == 2) {
560                            return list.get(1);
561                    }
562                    else {
563                            return null;
564                    }
565            }
566    
567            /**
568             * Removes all the document library folders where uuid = &#63; from the database.
569             *
570             * @param uuid the uuid
571             */
572            @Override
573            public void removeByUuid(String uuid) {
574                    for (DLFolder dlFolder : findByUuid(uuid, QueryUtil.ALL_POS,
575                                    QueryUtil.ALL_POS, null)) {
576                            remove(dlFolder);
577                    }
578            }
579    
580            /**
581             * Returns the number of document library folders where uuid = &#63;.
582             *
583             * @param uuid the uuid
584             * @return the number of matching document library folders
585             */
586            @Override
587            public int countByUuid(String uuid) {
588                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
589    
590                    Object[] finderArgs = new Object[] { uuid };
591    
592                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
593    
594                    if (count == null) {
595                            StringBundler query = new StringBundler(2);
596    
597                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
598    
599                            boolean bindUuid = false;
600    
601                            if (uuid == null) {
602                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
603                            }
604                            else if (uuid.equals(StringPool.BLANK)) {
605                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
606                            }
607                            else {
608                                    bindUuid = true;
609    
610                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
611                            }
612    
613                            String sql = query.toString();
614    
615                            Session session = null;
616    
617                            try {
618                                    session = openSession();
619    
620                                    Query q = session.createQuery(sql);
621    
622                                    QueryPos qPos = QueryPos.getInstance(q);
623    
624                                    if (bindUuid) {
625                                            qPos.add(uuid);
626                                    }
627    
628                                    count = (Long)q.uniqueResult();
629    
630                                    finderCache.putResult(finderPath, finderArgs, count);
631                            }
632                            catch (Exception e) {
633                                    finderCache.removeResult(finderPath, finderArgs);
634    
635                                    throw processException(e);
636                            }
637                            finally {
638                                    closeSession(session);
639                            }
640                    }
641    
642                    return count.intValue();
643            }
644    
645            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
646            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
647            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '')";
648            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
649                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
650                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
651                            new String[] { String.class.getName(), Long.class.getName() },
652                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
653                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
654            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
655                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
656                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
657                            new String[] { String.class.getName(), Long.class.getName() });
658    
659            /**
660             * Returns the document library folder where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFolderException} if it could not be found.
661             *
662             * @param uuid the uuid
663             * @param groupId the group ID
664             * @return the matching document library folder
665             * @throws NoSuchFolderException if a matching document library folder could not be found
666             */
667            @Override
668            public DLFolder findByUUID_G(String uuid, long groupId)
669                    throws NoSuchFolderException {
670                    DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
671    
672                    if (dlFolder == null) {
673                            StringBundler msg = new StringBundler(6);
674    
675                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
676    
677                            msg.append("uuid=");
678                            msg.append(uuid);
679    
680                            msg.append(", groupId=");
681                            msg.append(groupId);
682    
683                            msg.append(StringPool.CLOSE_CURLY_BRACE);
684    
685                            if (_log.isDebugEnabled()) {
686                                    _log.debug(msg.toString());
687                            }
688    
689                            throw new NoSuchFolderException(msg.toString());
690                    }
691    
692                    return dlFolder;
693            }
694    
695            /**
696             * Returns the document library folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
697             *
698             * @param uuid the uuid
699             * @param groupId the group ID
700             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
701             */
702            @Override
703            public DLFolder fetchByUUID_G(String uuid, long groupId) {
704                    return fetchByUUID_G(uuid, groupId, true);
705            }
706    
707            /**
708             * Returns the document library folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
709             *
710             * @param uuid the uuid
711             * @param groupId the group ID
712             * @param retrieveFromCache whether to retrieve from the finder cache
713             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
714             */
715            @Override
716            public DLFolder fetchByUUID_G(String uuid, long groupId,
717                    boolean retrieveFromCache) {
718                    Object[] finderArgs = new Object[] { uuid, groupId };
719    
720                    Object result = null;
721    
722                    if (retrieveFromCache) {
723                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
724                                            finderArgs, this);
725                    }
726    
727                    if (result instanceof DLFolder) {
728                            DLFolder dlFolder = (DLFolder)result;
729    
730                            if (!Objects.equals(uuid, dlFolder.getUuid()) ||
731                                            (groupId != dlFolder.getGroupId())) {
732                                    result = null;
733                            }
734                    }
735    
736                    if (result == null) {
737                            StringBundler query = new StringBundler(4);
738    
739                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
740    
741                            boolean bindUuid = false;
742    
743                            if (uuid == null) {
744                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
745                            }
746                            else if (uuid.equals(StringPool.BLANK)) {
747                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
748                            }
749                            else {
750                                    bindUuid = true;
751    
752                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
753                            }
754    
755                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
756    
757                            String sql = query.toString();
758    
759                            Session session = null;
760    
761                            try {
762                                    session = openSession();
763    
764                                    Query q = session.createQuery(sql);
765    
766                                    QueryPos qPos = QueryPos.getInstance(q);
767    
768                                    if (bindUuid) {
769                                            qPos.add(uuid);
770                                    }
771    
772                                    qPos.add(groupId);
773    
774                                    List<DLFolder> list = q.list();
775    
776                                    if (list.isEmpty()) {
777                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
778                                                    finderArgs, list);
779                                    }
780                                    else {
781                                            DLFolder dlFolder = list.get(0);
782    
783                                            result = dlFolder;
784    
785                                            cacheResult(dlFolder);
786    
787                                            if ((dlFolder.getUuid() == null) ||
788                                                            !dlFolder.getUuid().equals(uuid) ||
789                                                            (dlFolder.getGroupId() != groupId)) {
790                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
791                                                            finderArgs, dlFolder);
792                                            }
793                                    }
794                            }
795                            catch (Exception e) {
796                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
797    
798                                    throw processException(e);
799                            }
800                            finally {
801                                    closeSession(session);
802                            }
803                    }
804    
805                    if (result instanceof List<?>) {
806                            return null;
807                    }
808                    else {
809                            return (DLFolder)result;
810                    }
811            }
812    
813            /**
814             * Removes the document library folder where uuid = &#63; and groupId = &#63; from the database.
815             *
816             * @param uuid the uuid
817             * @param groupId the group ID
818             * @return the document library folder that was removed
819             */
820            @Override
821            public DLFolder removeByUUID_G(String uuid, long groupId)
822                    throws NoSuchFolderException {
823                    DLFolder dlFolder = findByUUID_G(uuid, groupId);
824    
825                    return remove(dlFolder);
826            }
827    
828            /**
829             * Returns the number of document library folders where uuid = &#63; and groupId = &#63;.
830             *
831             * @param uuid the uuid
832             * @param groupId the group ID
833             * @return the number of matching document library folders
834             */
835            @Override
836            public int countByUUID_G(String uuid, long groupId) {
837                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
838    
839                    Object[] finderArgs = new Object[] { uuid, groupId };
840    
841                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
842    
843                    if (count == null) {
844                            StringBundler query = new StringBundler(3);
845    
846                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
847    
848                            boolean bindUuid = false;
849    
850                            if (uuid == null) {
851                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
852                            }
853                            else if (uuid.equals(StringPool.BLANK)) {
854                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
855                            }
856                            else {
857                                    bindUuid = true;
858    
859                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
860                            }
861    
862                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
863    
864                            String sql = query.toString();
865    
866                            Session session = null;
867    
868                            try {
869                                    session = openSession();
870    
871                                    Query q = session.createQuery(sql);
872    
873                                    QueryPos qPos = QueryPos.getInstance(q);
874    
875                                    if (bindUuid) {
876                                            qPos.add(uuid);
877                                    }
878    
879                                    qPos.add(groupId);
880    
881                                    count = (Long)q.uniqueResult();
882    
883                                    finderCache.putResult(finderPath, finderArgs, count);
884                            }
885                            catch (Exception e) {
886                                    finderCache.removeResult(finderPath, finderArgs);
887    
888                                    throw processException(e);
889                            }
890                            finally {
891                                    closeSession(session);
892                            }
893                    }
894    
895                    return count.intValue();
896            }
897    
898            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
899            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
900            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '') AND ";
901            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
902            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
903                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
904                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
905                            new String[] {
906                                    String.class.getName(), Long.class.getName(),
907                                    
908                            Integer.class.getName(), Integer.class.getName(),
909                                    OrderByComparator.class.getName()
910                            });
911            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
912                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
913                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
914                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
915                            new String[] { String.class.getName(), Long.class.getName() },
916                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
917                            DLFolderModelImpl.COMPANYID_COLUMN_BITMASK |
918                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
919                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
920            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
921                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
922                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
923                            new String[] { String.class.getName(), Long.class.getName() });
924    
925            /**
926             * Returns all the document library folders where uuid = &#63; and companyId = &#63;.
927             *
928             * @param uuid the uuid
929             * @param companyId the company ID
930             * @return the matching document library folders
931             */
932            @Override
933            public List<DLFolder> findByUuid_C(String uuid, long companyId) {
934                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
935                            QueryUtil.ALL_POS, null);
936            }
937    
938            /**
939             * Returns a range of all the document library folders where uuid = &#63; and companyId = &#63;.
940             *
941             * <p>
942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
943             * </p>
944             *
945             * @param uuid the uuid
946             * @param companyId the company ID
947             * @param start the lower bound of the range of document library folders
948             * @param end the upper bound of the range of document library folders (not inclusive)
949             * @return the range of matching document library folders
950             */
951            @Override
952            public List<DLFolder> findByUuid_C(String uuid, long companyId, int start,
953                    int end) {
954                    return findByUuid_C(uuid, companyId, start, end, null);
955            }
956    
957            /**
958             * Returns an ordered range of all the document library folders where uuid = &#63; and companyId = &#63;.
959             *
960             * <p>
961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
962             * </p>
963             *
964             * @param uuid the uuid
965             * @param companyId the company ID
966             * @param start the lower bound of the range of document library folders
967             * @param end the upper bound of the range of document library folders (not inclusive)
968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
969             * @return the ordered range of matching document library folders
970             */
971            @Override
972            public List<DLFolder> findByUuid_C(String uuid, long companyId, int start,
973                    int end, OrderByComparator<DLFolder> orderByComparator) {
974                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
975            }
976    
977            /**
978             * Returns an ordered range of all the document library folders where uuid = &#63; and companyId = &#63;.
979             *
980             * <p>
981             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
982             * </p>
983             *
984             * @param uuid the uuid
985             * @param companyId the company ID
986             * @param start the lower bound of the range of document library folders
987             * @param end the upper bound of the range of document library folders (not inclusive)
988             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
989             * @param retrieveFromCache whether to retrieve from the finder cache
990             * @return the ordered range of matching document library folders
991             */
992            @Override
993            public List<DLFolder> findByUuid_C(String uuid, long companyId, int start,
994                    int end, OrderByComparator<DLFolder> orderByComparator,
995                    boolean retrieveFromCache) {
996                    boolean pagination = true;
997                    FinderPath finderPath = null;
998                    Object[] finderArgs = null;
999    
1000                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1001                                    (orderByComparator == null)) {
1002                            pagination = false;
1003                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1004                            finderArgs = new Object[] { uuid, companyId };
1005                    }
1006                    else {
1007                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1008                            finderArgs = new Object[] {
1009                                            uuid, companyId,
1010                                            
1011                                            start, end, orderByComparator
1012                                    };
1013                    }
1014    
1015                    List<DLFolder> list = null;
1016    
1017                    if (retrieveFromCache) {
1018                            list = (List<DLFolder>)finderCache.getResult(finderPath,
1019                                            finderArgs, this);
1020    
1021                            if ((list != null) && !list.isEmpty()) {
1022                                    for (DLFolder dlFolder : list) {
1023                                            if (!Objects.equals(uuid, dlFolder.getUuid()) ||
1024                                                            (companyId != dlFolder.getCompanyId())) {
1025                                                    list = null;
1026    
1027                                                    break;
1028                                            }
1029                                    }
1030                            }
1031                    }
1032    
1033                    if (list == null) {
1034                            StringBundler query = null;
1035    
1036                            if (orderByComparator != null) {
1037                                    query = new StringBundler(4 +
1038                                                    (orderByComparator.getOrderByFields().length * 2));
1039                            }
1040                            else {
1041                                    query = new StringBundler(4);
1042                            }
1043    
1044                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
1045    
1046                            boolean bindUuid = false;
1047    
1048                            if (uuid == null) {
1049                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1050                            }
1051                            else if (uuid.equals(StringPool.BLANK)) {
1052                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1053                            }
1054                            else {
1055                                    bindUuid = true;
1056    
1057                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1058                            }
1059    
1060                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1061    
1062                            if (orderByComparator != null) {
1063                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1064                                            orderByComparator);
1065                            }
1066                            else
1067                             if (pagination) {
1068                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1069                            }
1070    
1071                            String sql = query.toString();
1072    
1073                            Session session = null;
1074    
1075                            try {
1076                                    session = openSession();
1077    
1078                                    Query q = session.createQuery(sql);
1079    
1080                                    QueryPos qPos = QueryPos.getInstance(q);
1081    
1082                                    if (bindUuid) {
1083                                            qPos.add(uuid);
1084                                    }
1085    
1086                                    qPos.add(companyId);
1087    
1088                                    if (!pagination) {
1089                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1090                                                            start, end, false);
1091    
1092                                            Collections.sort(list);
1093    
1094                                            list = Collections.unmodifiableList(list);
1095                                    }
1096                                    else {
1097                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1098                                                            start, end);
1099                                    }
1100    
1101                                    cacheResult(list);
1102    
1103                                    finderCache.putResult(finderPath, finderArgs, list);
1104                            }
1105                            catch (Exception e) {
1106                                    finderCache.removeResult(finderPath, finderArgs);
1107    
1108                                    throw processException(e);
1109                            }
1110                            finally {
1111                                    closeSession(session);
1112                            }
1113                    }
1114    
1115                    return list;
1116            }
1117    
1118            /**
1119             * Returns the first document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1120             *
1121             * @param uuid the uuid
1122             * @param companyId the company ID
1123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1124             * @return the first matching document library folder
1125             * @throws NoSuchFolderException if a matching document library folder could not be found
1126             */
1127            @Override
1128            public DLFolder findByUuid_C_First(String uuid, long companyId,
1129                    OrderByComparator<DLFolder> orderByComparator)
1130                    throws NoSuchFolderException {
1131                    DLFolder dlFolder = fetchByUuid_C_First(uuid, companyId,
1132                                    orderByComparator);
1133    
1134                    if (dlFolder != null) {
1135                            return dlFolder;
1136                    }
1137    
1138                    StringBundler msg = new StringBundler(6);
1139    
1140                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141    
1142                    msg.append("uuid=");
1143                    msg.append(uuid);
1144    
1145                    msg.append(", companyId=");
1146                    msg.append(companyId);
1147    
1148                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1149    
1150                    throw new NoSuchFolderException(msg.toString());
1151            }
1152    
1153            /**
1154             * Returns the first document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1155             *
1156             * @param uuid the uuid
1157             * @param companyId the company ID
1158             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1159             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1160             */
1161            @Override
1162            public DLFolder fetchByUuid_C_First(String uuid, long companyId,
1163                    OrderByComparator<DLFolder> orderByComparator) {
1164                    List<DLFolder> list = findByUuid_C(uuid, companyId, 0, 1,
1165                                    orderByComparator);
1166    
1167                    if (!list.isEmpty()) {
1168                            return list.get(0);
1169                    }
1170    
1171                    return null;
1172            }
1173    
1174            /**
1175             * Returns the last document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1176             *
1177             * @param uuid the uuid
1178             * @param companyId the company ID
1179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1180             * @return the last matching document library folder
1181             * @throws NoSuchFolderException if a matching document library folder could not be found
1182             */
1183            @Override
1184            public DLFolder findByUuid_C_Last(String uuid, long companyId,
1185                    OrderByComparator<DLFolder> orderByComparator)
1186                    throws NoSuchFolderException {
1187                    DLFolder dlFolder = fetchByUuid_C_Last(uuid, companyId,
1188                                    orderByComparator);
1189    
1190                    if (dlFolder != null) {
1191                            return dlFolder;
1192                    }
1193    
1194                    StringBundler msg = new StringBundler(6);
1195    
1196                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1197    
1198                    msg.append("uuid=");
1199                    msg.append(uuid);
1200    
1201                    msg.append(", companyId=");
1202                    msg.append(companyId);
1203    
1204                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1205    
1206                    throw new NoSuchFolderException(msg.toString());
1207            }
1208    
1209            /**
1210             * Returns the last document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1211             *
1212             * @param uuid the uuid
1213             * @param companyId the company ID
1214             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1215             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1216             */
1217            @Override
1218            public DLFolder fetchByUuid_C_Last(String uuid, long companyId,
1219                    OrderByComparator<DLFolder> orderByComparator) {
1220                    int count = countByUuid_C(uuid, companyId);
1221    
1222                    if (count == 0) {
1223                            return null;
1224                    }
1225    
1226                    List<DLFolder> list = findByUuid_C(uuid, companyId, count - 1, count,
1227                                    orderByComparator);
1228    
1229                    if (!list.isEmpty()) {
1230                            return list.get(0);
1231                    }
1232    
1233                    return null;
1234            }
1235    
1236            /**
1237             * Returns the document library folders before and after the current document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1238             *
1239             * @param folderId the primary key of the current document library folder
1240             * @param uuid the uuid
1241             * @param companyId the company ID
1242             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1243             * @return the previous, current, and next document library folder
1244             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
1245             */
1246            @Override
1247            public DLFolder[] findByUuid_C_PrevAndNext(long folderId, String uuid,
1248                    long companyId, OrderByComparator<DLFolder> orderByComparator)
1249                    throws NoSuchFolderException {
1250                    DLFolder dlFolder = findByPrimaryKey(folderId);
1251    
1252                    Session session = null;
1253    
1254                    try {
1255                            session = openSession();
1256    
1257                            DLFolder[] array = new DLFolderImpl[3];
1258    
1259                            array[0] = getByUuid_C_PrevAndNext(session, dlFolder, uuid,
1260                                            companyId, orderByComparator, true);
1261    
1262                            array[1] = dlFolder;
1263    
1264                            array[2] = getByUuid_C_PrevAndNext(session, dlFolder, uuid,
1265                                            companyId, orderByComparator, false);
1266    
1267                            return array;
1268                    }
1269                    catch (Exception e) {
1270                            throw processException(e);
1271                    }
1272                    finally {
1273                            closeSession(session);
1274                    }
1275            }
1276    
1277            protected DLFolder getByUuid_C_PrevAndNext(Session session,
1278                    DLFolder dlFolder, String uuid, long companyId,
1279                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
1280                    StringBundler query = null;
1281    
1282                    if (orderByComparator != null) {
1283                            query = new StringBundler(5 +
1284                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1285                                            (orderByComparator.getOrderByFields().length * 3));
1286                    }
1287                    else {
1288                            query = new StringBundler(4);
1289                    }
1290    
1291                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1292    
1293                    boolean bindUuid = false;
1294    
1295                    if (uuid == null) {
1296                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1297                    }
1298                    else if (uuid.equals(StringPool.BLANK)) {
1299                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1300                    }
1301                    else {
1302                            bindUuid = true;
1303    
1304                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1305                    }
1306    
1307                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1308    
1309                    if (orderByComparator != null) {
1310                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1311    
1312                            if (orderByConditionFields.length > 0) {
1313                                    query.append(WHERE_AND);
1314                            }
1315    
1316                            for (int i = 0; i < orderByConditionFields.length; i++) {
1317                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1318                                    query.append(orderByConditionFields[i]);
1319    
1320                                    if ((i + 1) < orderByConditionFields.length) {
1321                                            if (orderByComparator.isAscending() ^ previous) {
1322                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1323                                            }
1324                                            else {
1325                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1326                                            }
1327                                    }
1328                                    else {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(WHERE_GREATER_THAN);
1331                                            }
1332                                            else {
1333                                                    query.append(WHERE_LESSER_THAN);
1334                                            }
1335                                    }
1336                            }
1337    
1338                            query.append(ORDER_BY_CLAUSE);
1339    
1340                            String[] orderByFields = orderByComparator.getOrderByFields();
1341    
1342                            for (int i = 0; i < orderByFields.length; i++) {
1343                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1344                                    query.append(orderByFields[i]);
1345    
1346                                    if ((i + 1) < orderByFields.length) {
1347                                            if (orderByComparator.isAscending() ^ previous) {
1348                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1349                                            }
1350                                            else {
1351                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1352                                            }
1353                                    }
1354                                    else {
1355                                            if (orderByComparator.isAscending() ^ previous) {
1356                                                    query.append(ORDER_BY_ASC);
1357                                            }
1358                                            else {
1359                                                    query.append(ORDER_BY_DESC);
1360                                            }
1361                                    }
1362                            }
1363                    }
1364                    else {
1365                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1366                    }
1367    
1368                    String sql = query.toString();
1369    
1370                    Query q = session.createQuery(sql);
1371    
1372                    q.setFirstResult(0);
1373                    q.setMaxResults(2);
1374    
1375                    QueryPos qPos = QueryPos.getInstance(q);
1376    
1377                    if (bindUuid) {
1378                            qPos.add(uuid);
1379                    }
1380    
1381                    qPos.add(companyId);
1382    
1383                    if (orderByComparator != null) {
1384                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1385    
1386                            for (Object value : values) {
1387                                    qPos.add(value);
1388                            }
1389                    }
1390    
1391                    List<DLFolder> list = q.list();
1392    
1393                    if (list.size() == 2) {
1394                            return list.get(1);
1395                    }
1396                    else {
1397                            return null;
1398                    }
1399            }
1400    
1401            /**
1402             * Removes all the document library folders where uuid = &#63; and companyId = &#63; from the database.
1403             *
1404             * @param uuid the uuid
1405             * @param companyId the company ID
1406             */
1407            @Override
1408            public void removeByUuid_C(String uuid, long companyId) {
1409                    for (DLFolder dlFolder : findByUuid_C(uuid, companyId,
1410                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1411                            remove(dlFolder);
1412                    }
1413            }
1414    
1415            /**
1416             * Returns the number of document library folders where uuid = &#63; and companyId = &#63;.
1417             *
1418             * @param uuid the uuid
1419             * @param companyId the company ID
1420             * @return the number of matching document library folders
1421             */
1422            @Override
1423            public int countByUuid_C(String uuid, long companyId) {
1424                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1425    
1426                    Object[] finderArgs = new Object[] { uuid, companyId };
1427    
1428                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1429    
1430                    if (count == null) {
1431                            StringBundler query = new StringBundler(3);
1432    
1433                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
1434    
1435                            boolean bindUuid = false;
1436    
1437                            if (uuid == null) {
1438                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1439                            }
1440                            else if (uuid.equals(StringPool.BLANK)) {
1441                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1442                            }
1443                            else {
1444                                    bindUuid = true;
1445    
1446                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1447                            }
1448    
1449                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1450    
1451                            String sql = query.toString();
1452    
1453                            Session session = null;
1454    
1455                            try {
1456                                    session = openSession();
1457    
1458                                    Query q = session.createQuery(sql);
1459    
1460                                    QueryPos qPos = QueryPos.getInstance(q);
1461    
1462                                    if (bindUuid) {
1463                                            qPos.add(uuid);
1464                                    }
1465    
1466                                    qPos.add(companyId);
1467    
1468                                    count = (Long)q.uniqueResult();
1469    
1470                                    finderCache.putResult(finderPath, finderArgs, count);
1471                            }
1472                            catch (Exception e) {
1473                                    finderCache.removeResult(finderPath, finderArgs);
1474    
1475                                    throw processException(e);
1476                            }
1477                            finally {
1478                                    closeSession(session);
1479                            }
1480                    }
1481    
1482                    return count.intValue();
1483            }
1484    
1485            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFolder.uuid IS NULL AND ";
1486            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFolder.uuid = ? AND ";
1487            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '') AND ";
1488            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFolder.companyId = ?";
1489            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1490                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
1491                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1492                            new String[] {
1493                                    Long.class.getName(),
1494                                    
1495                            Integer.class.getName(), Integer.class.getName(),
1496                                    OrderByComparator.class.getName()
1497                            });
1498            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1499                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1500                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
1501                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1502                            new String[] { Long.class.getName() },
1503                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
1504                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
1505                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
1506            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1507                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
1508                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1509                            new String[] { Long.class.getName() });
1510    
1511            /**
1512             * Returns all the document library folders where groupId = &#63;.
1513             *
1514             * @param groupId the group ID
1515             * @return the matching document library folders
1516             */
1517            @Override
1518            public List<DLFolder> findByGroupId(long groupId) {
1519                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1520            }
1521    
1522            /**
1523             * Returns a range of all the document library folders where groupId = &#63;.
1524             *
1525             * <p>
1526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1527             * </p>
1528             *
1529             * @param groupId the group ID
1530             * @param start the lower bound of the range of document library folders
1531             * @param end the upper bound of the range of document library folders (not inclusive)
1532             * @return the range of matching document library folders
1533             */
1534            @Override
1535            public List<DLFolder> findByGroupId(long groupId, int start, int end) {
1536                    return findByGroupId(groupId, start, end, null);
1537            }
1538    
1539            /**
1540             * Returns an ordered range of all the document library folders where groupId = &#63;.
1541             *
1542             * <p>
1543             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1544             * </p>
1545             *
1546             * @param groupId the group ID
1547             * @param start the lower bound of the range of document library folders
1548             * @param end the upper bound of the range of document library folders (not inclusive)
1549             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1550             * @return the ordered range of matching document library folders
1551             */
1552            @Override
1553            public List<DLFolder> findByGroupId(long groupId, int start, int end,
1554                    OrderByComparator<DLFolder> orderByComparator) {
1555                    return findByGroupId(groupId, start, end, orderByComparator, true);
1556            }
1557    
1558            /**
1559             * Returns an ordered range of all the document library folders where groupId = &#63;.
1560             *
1561             * <p>
1562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1563             * </p>
1564             *
1565             * @param groupId the group ID
1566             * @param start the lower bound of the range of document library folders
1567             * @param end the upper bound of the range of document library folders (not inclusive)
1568             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1569             * @param retrieveFromCache whether to retrieve from the finder cache
1570             * @return the ordered range of matching document library folders
1571             */
1572            @Override
1573            public List<DLFolder> findByGroupId(long groupId, int start, int end,
1574                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
1575                    boolean pagination = true;
1576                    FinderPath finderPath = null;
1577                    Object[] finderArgs = null;
1578    
1579                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1580                                    (orderByComparator == null)) {
1581                            pagination = false;
1582                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1583                            finderArgs = new Object[] { groupId };
1584                    }
1585                    else {
1586                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1587                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1588                    }
1589    
1590                    List<DLFolder> list = null;
1591    
1592                    if (retrieveFromCache) {
1593                            list = (List<DLFolder>)finderCache.getResult(finderPath,
1594                                            finderArgs, this);
1595    
1596                            if ((list != null) && !list.isEmpty()) {
1597                                    for (DLFolder dlFolder : list) {
1598                                            if ((groupId != dlFolder.getGroupId())) {
1599                                                    list = null;
1600    
1601                                                    break;
1602                                            }
1603                                    }
1604                            }
1605                    }
1606    
1607                    if (list == null) {
1608                            StringBundler query = null;
1609    
1610                            if (orderByComparator != null) {
1611                                    query = new StringBundler(3 +
1612                                                    (orderByComparator.getOrderByFields().length * 2));
1613                            }
1614                            else {
1615                                    query = new StringBundler(3);
1616                            }
1617    
1618                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
1619    
1620                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1621    
1622                            if (orderByComparator != null) {
1623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1624                                            orderByComparator);
1625                            }
1626                            else
1627                             if (pagination) {
1628                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1629                            }
1630    
1631                            String sql = query.toString();
1632    
1633                            Session session = null;
1634    
1635                            try {
1636                                    session = openSession();
1637    
1638                                    Query q = session.createQuery(sql);
1639    
1640                                    QueryPos qPos = QueryPos.getInstance(q);
1641    
1642                                    qPos.add(groupId);
1643    
1644                                    if (!pagination) {
1645                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1646                                                            start, end, false);
1647    
1648                                            Collections.sort(list);
1649    
1650                                            list = Collections.unmodifiableList(list);
1651                                    }
1652                                    else {
1653                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1654                                                            start, end);
1655                                    }
1656    
1657                                    cacheResult(list);
1658    
1659                                    finderCache.putResult(finderPath, finderArgs, list);
1660                            }
1661                            catch (Exception e) {
1662                                    finderCache.removeResult(finderPath, finderArgs);
1663    
1664                                    throw processException(e);
1665                            }
1666                            finally {
1667                                    closeSession(session);
1668                            }
1669                    }
1670    
1671                    return list;
1672            }
1673    
1674            /**
1675             * Returns the first document library folder in the ordered set where groupId = &#63;.
1676             *
1677             * @param groupId the group ID
1678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1679             * @return the first matching document library folder
1680             * @throws NoSuchFolderException if a matching document library folder could not be found
1681             */
1682            @Override
1683            public DLFolder findByGroupId_First(long groupId,
1684                    OrderByComparator<DLFolder> orderByComparator)
1685                    throws NoSuchFolderException {
1686                    DLFolder dlFolder = fetchByGroupId_First(groupId, orderByComparator);
1687    
1688                    if (dlFolder != null) {
1689                            return dlFolder;
1690                    }
1691    
1692                    StringBundler msg = new StringBundler(4);
1693    
1694                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1695    
1696                    msg.append("groupId=");
1697                    msg.append(groupId);
1698    
1699                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1700    
1701                    throw new NoSuchFolderException(msg.toString());
1702            }
1703    
1704            /**
1705             * Returns the first document library folder in the ordered set where groupId = &#63;.
1706             *
1707             * @param groupId the group ID
1708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1709             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1710             */
1711            @Override
1712            public DLFolder fetchByGroupId_First(long groupId,
1713                    OrderByComparator<DLFolder> orderByComparator) {
1714                    List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1715    
1716                    if (!list.isEmpty()) {
1717                            return list.get(0);
1718                    }
1719    
1720                    return null;
1721            }
1722    
1723            /**
1724             * Returns the last document library folder in the ordered set where groupId = &#63;.
1725             *
1726             * @param groupId the group ID
1727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1728             * @return the last matching document library folder
1729             * @throws NoSuchFolderException if a matching document library folder could not be found
1730             */
1731            @Override
1732            public DLFolder findByGroupId_Last(long groupId,
1733                    OrderByComparator<DLFolder> orderByComparator)
1734                    throws NoSuchFolderException {
1735                    DLFolder dlFolder = fetchByGroupId_Last(groupId, orderByComparator);
1736    
1737                    if (dlFolder != null) {
1738                            return dlFolder;
1739                    }
1740    
1741                    StringBundler msg = new StringBundler(4);
1742    
1743                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1744    
1745                    msg.append("groupId=");
1746                    msg.append(groupId);
1747    
1748                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1749    
1750                    throw new NoSuchFolderException(msg.toString());
1751            }
1752    
1753            /**
1754             * Returns the last document library folder in the ordered set where groupId = &#63;.
1755             *
1756             * @param groupId the group ID
1757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1758             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1759             */
1760            @Override
1761            public DLFolder fetchByGroupId_Last(long groupId,
1762                    OrderByComparator<DLFolder> orderByComparator) {
1763                    int count = countByGroupId(groupId);
1764    
1765                    if (count == 0) {
1766                            return null;
1767                    }
1768    
1769                    List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1770                                    orderByComparator);
1771    
1772                    if (!list.isEmpty()) {
1773                            return list.get(0);
1774                    }
1775    
1776                    return null;
1777            }
1778    
1779            /**
1780             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63;.
1781             *
1782             * @param folderId the primary key of the current document library folder
1783             * @param groupId the group ID
1784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1785             * @return the previous, current, and next document library folder
1786             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
1787             */
1788            @Override
1789            public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1790                    OrderByComparator<DLFolder> orderByComparator)
1791                    throws NoSuchFolderException {
1792                    DLFolder dlFolder = findByPrimaryKey(folderId);
1793    
1794                    Session session = null;
1795    
1796                    try {
1797                            session = openSession();
1798    
1799                            DLFolder[] array = new DLFolderImpl[3];
1800    
1801                            array[0] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1802                                            orderByComparator, true);
1803    
1804                            array[1] = dlFolder;
1805    
1806                            array[2] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1807                                            orderByComparator, false);
1808    
1809                            return array;
1810                    }
1811                    catch (Exception e) {
1812                            throw processException(e);
1813                    }
1814                    finally {
1815                            closeSession(session);
1816                    }
1817            }
1818    
1819            protected DLFolder getByGroupId_PrevAndNext(Session session,
1820                    DLFolder dlFolder, long groupId,
1821                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
1822                    StringBundler query = null;
1823    
1824                    if (orderByComparator != null) {
1825                            query = new StringBundler(4 +
1826                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1827                                            (orderByComparator.getOrderByFields().length * 3));
1828                    }
1829                    else {
1830                            query = new StringBundler(3);
1831                    }
1832    
1833                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1834    
1835                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1836    
1837                    if (orderByComparator != null) {
1838                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1839    
1840                            if (orderByConditionFields.length > 0) {
1841                                    query.append(WHERE_AND);
1842                            }
1843    
1844                            for (int i = 0; i < orderByConditionFields.length; i++) {
1845                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1846                                    query.append(orderByConditionFields[i]);
1847    
1848                                    if ((i + 1) < orderByConditionFields.length) {
1849                                            if (orderByComparator.isAscending() ^ previous) {
1850                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1851                                            }
1852                                            else {
1853                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1854                                            }
1855                                    }
1856                                    else {
1857                                            if (orderByComparator.isAscending() ^ previous) {
1858                                                    query.append(WHERE_GREATER_THAN);
1859                                            }
1860                                            else {
1861                                                    query.append(WHERE_LESSER_THAN);
1862                                            }
1863                                    }
1864                            }
1865    
1866                            query.append(ORDER_BY_CLAUSE);
1867    
1868                            String[] orderByFields = orderByComparator.getOrderByFields();
1869    
1870                            for (int i = 0; i < orderByFields.length; i++) {
1871                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1872                                    query.append(orderByFields[i]);
1873    
1874                                    if ((i + 1) < orderByFields.length) {
1875                                            if (orderByComparator.isAscending() ^ previous) {
1876                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1877                                            }
1878                                            else {
1879                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1880                                            }
1881                                    }
1882                                    else {
1883                                            if (orderByComparator.isAscending() ^ previous) {
1884                                                    query.append(ORDER_BY_ASC);
1885                                            }
1886                                            else {
1887                                                    query.append(ORDER_BY_DESC);
1888                                            }
1889                                    }
1890                            }
1891                    }
1892                    else {
1893                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1894                    }
1895    
1896                    String sql = query.toString();
1897    
1898                    Query q = session.createQuery(sql);
1899    
1900                    q.setFirstResult(0);
1901                    q.setMaxResults(2);
1902    
1903                    QueryPos qPos = QueryPos.getInstance(q);
1904    
1905                    qPos.add(groupId);
1906    
1907                    if (orderByComparator != null) {
1908                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1909    
1910                            for (Object value : values) {
1911                                    qPos.add(value);
1912                            }
1913                    }
1914    
1915                    List<DLFolder> list = q.list();
1916    
1917                    if (list.size() == 2) {
1918                            return list.get(1);
1919                    }
1920                    else {
1921                            return null;
1922                    }
1923            }
1924    
1925            /**
1926             * Returns all the document library folders that the user has permission to view where groupId = &#63;.
1927             *
1928             * @param groupId the group ID
1929             * @return the matching document library folders that the user has permission to view
1930             */
1931            @Override
1932            public List<DLFolder> filterFindByGroupId(long groupId) {
1933                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1934                            QueryUtil.ALL_POS, null);
1935            }
1936    
1937            /**
1938             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63;.
1939             *
1940             * <p>
1941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1942             * </p>
1943             *
1944             * @param groupId the group ID
1945             * @param start the lower bound of the range of document library folders
1946             * @param end the upper bound of the range of document library folders (not inclusive)
1947             * @return the range of matching document library folders that the user has permission to view
1948             */
1949            @Override
1950            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end) {
1951                    return filterFindByGroupId(groupId, start, end, null);
1952            }
1953    
1954            /**
1955             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63;.
1956             *
1957             * <p>
1958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1959             * </p>
1960             *
1961             * @param groupId the group ID
1962             * @param start the lower bound of the range of document library folders
1963             * @param end the upper bound of the range of document library folders (not inclusive)
1964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1965             * @return the ordered range of matching document library folders that the user has permission to view
1966             */
1967            @Override
1968            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end,
1969                    OrderByComparator<DLFolder> orderByComparator) {
1970                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1971                            return findByGroupId(groupId, start, end, orderByComparator);
1972                    }
1973    
1974                    StringBundler query = null;
1975    
1976                    if (orderByComparator != null) {
1977                            query = new StringBundler(3 +
1978                                            (orderByComparator.getOrderByFields().length * 2));
1979                    }
1980                    else {
1981                            query = new StringBundler(4);
1982                    }
1983    
1984                    if (getDB().isSupportsInlineDistinct()) {
1985                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1986                    }
1987                    else {
1988                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1989                    }
1990    
1991                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1992    
1993                    if (!getDB().isSupportsInlineDistinct()) {
1994                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1995                    }
1996    
1997                    if (orderByComparator != null) {
1998                            if (getDB().isSupportsInlineDistinct()) {
1999                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2000                                            orderByComparator, true);
2001                            }
2002                            else {
2003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2004                                            orderByComparator, true);
2005                            }
2006                    }
2007                    else {
2008                            if (getDB().isSupportsInlineDistinct()) {
2009                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2010                            }
2011                            else {
2012                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
2013                            }
2014                    }
2015    
2016                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2017                                    DLFolder.class.getName(),
2018                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2019    
2020                    Session session = null;
2021    
2022                    try {
2023                            session = openSession();
2024    
2025                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2026    
2027                            if (getDB().isSupportsInlineDistinct()) {
2028                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2029                            }
2030                            else {
2031                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2032                            }
2033    
2034                            QueryPos qPos = QueryPos.getInstance(q);
2035    
2036                            qPos.add(groupId);
2037    
2038                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
2039                    }
2040                    catch (Exception e) {
2041                            throw processException(e);
2042                    }
2043                    finally {
2044                            closeSession(session);
2045                    }
2046            }
2047    
2048            /**
2049             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63;.
2050             *
2051             * @param folderId the primary key of the current document library folder
2052             * @param groupId the group ID
2053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2054             * @return the previous, current, and next document library folder
2055             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
2056             */
2057            @Override
2058            public DLFolder[] filterFindByGroupId_PrevAndNext(long folderId,
2059                    long groupId, OrderByComparator<DLFolder> orderByComparator)
2060                    throws NoSuchFolderException {
2061                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2062                            return findByGroupId_PrevAndNext(folderId, groupId,
2063                                    orderByComparator);
2064                    }
2065    
2066                    DLFolder dlFolder = findByPrimaryKey(folderId);
2067    
2068                    Session session = null;
2069    
2070                    try {
2071                            session = openSession();
2072    
2073                            DLFolder[] array = new DLFolderImpl[3];
2074    
2075                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFolder,
2076                                            groupId, orderByComparator, true);
2077    
2078                            array[1] = dlFolder;
2079    
2080                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFolder,
2081                                            groupId, orderByComparator, false);
2082    
2083                            return array;
2084                    }
2085                    catch (Exception e) {
2086                            throw processException(e);
2087                    }
2088                    finally {
2089                            closeSession(session);
2090                    }
2091            }
2092    
2093            protected DLFolder filterGetByGroupId_PrevAndNext(Session session,
2094                    DLFolder dlFolder, long groupId,
2095                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
2096                    StringBundler query = null;
2097    
2098                    if (orderByComparator != null) {
2099                            query = new StringBundler(5 +
2100                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2101                                            (orderByComparator.getOrderByFields().length * 3));
2102                    }
2103                    else {
2104                            query = new StringBundler(4);
2105                    }
2106    
2107                    if (getDB().isSupportsInlineDistinct()) {
2108                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
2109                    }
2110                    else {
2111                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2112                    }
2113    
2114                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2115    
2116                    if (!getDB().isSupportsInlineDistinct()) {
2117                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2118                    }
2119    
2120                    if (orderByComparator != null) {
2121                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2122    
2123                            if (orderByConditionFields.length > 0) {
2124                                    query.append(WHERE_AND);
2125                            }
2126    
2127                            for (int i = 0; i < orderByConditionFields.length; i++) {
2128                                    if (getDB().isSupportsInlineDistinct()) {
2129                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2130                                    }
2131                                    else {
2132                                            query.append(_ORDER_BY_ENTITY_TABLE);
2133                                    }
2134    
2135                                    query.append(orderByConditionFields[i]);
2136    
2137                                    if ((i + 1) < orderByConditionFields.length) {
2138                                            if (orderByComparator.isAscending() ^ previous) {
2139                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2140                                            }
2141                                            else {
2142                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2143                                            }
2144                                    }
2145                                    else {
2146                                            if (orderByComparator.isAscending() ^ previous) {
2147                                                    query.append(WHERE_GREATER_THAN);
2148                                            }
2149                                            else {
2150                                                    query.append(WHERE_LESSER_THAN);
2151                                            }
2152                                    }
2153                            }
2154    
2155                            query.append(ORDER_BY_CLAUSE);
2156    
2157                            String[] orderByFields = orderByComparator.getOrderByFields();
2158    
2159                            for (int i = 0; i < orderByFields.length; i++) {
2160                                    if (getDB().isSupportsInlineDistinct()) {
2161                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2162                                    }
2163                                    else {
2164                                            query.append(_ORDER_BY_ENTITY_TABLE);
2165                                    }
2166    
2167                                    query.append(orderByFields[i]);
2168    
2169                                    if ((i + 1) < orderByFields.length) {
2170                                            if (orderByComparator.isAscending() ^ previous) {
2171                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2172                                            }
2173                                            else {
2174                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2175                                            }
2176                                    }
2177                                    else {
2178                                            if (orderByComparator.isAscending() ^ previous) {
2179                                                    query.append(ORDER_BY_ASC);
2180                                            }
2181                                            else {
2182                                                    query.append(ORDER_BY_DESC);
2183                                            }
2184                                    }
2185                            }
2186                    }
2187                    else {
2188                            if (getDB().isSupportsInlineDistinct()) {
2189                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2190                            }
2191                            else {
2192                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
2193                            }
2194                    }
2195    
2196                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2197                                    DLFolder.class.getName(),
2198                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2199    
2200                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2201    
2202                    q.setFirstResult(0);
2203                    q.setMaxResults(2);
2204    
2205                    if (getDB().isSupportsInlineDistinct()) {
2206                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2207                    }
2208                    else {
2209                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2210                    }
2211    
2212                    QueryPos qPos = QueryPos.getInstance(q);
2213    
2214                    qPos.add(groupId);
2215    
2216                    if (orderByComparator != null) {
2217                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2218    
2219                            for (Object value : values) {
2220                                    qPos.add(value);
2221                            }
2222                    }
2223    
2224                    List<DLFolder> list = q.list();
2225    
2226                    if (list.size() == 2) {
2227                            return list.get(1);
2228                    }
2229                    else {
2230                            return null;
2231                    }
2232            }
2233    
2234            /**
2235             * Removes all the document library folders where groupId = &#63; from the database.
2236             *
2237             * @param groupId the group ID
2238             */
2239            @Override
2240            public void removeByGroupId(long groupId) {
2241                    for (DLFolder dlFolder : findByGroupId(groupId, QueryUtil.ALL_POS,
2242                                    QueryUtil.ALL_POS, null)) {
2243                            remove(dlFolder);
2244                    }
2245            }
2246    
2247            /**
2248             * Returns the number of document library folders where groupId = &#63;.
2249             *
2250             * @param groupId the group ID
2251             * @return the number of matching document library folders
2252             */
2253            @Override
2254            public int countByGroupId(long groupId) {
2255                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2256    
2257                    Object[] finderArgs = new Object[] { groupId };
2258    
2259                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2260    
2261                    if (count == null) {
2262                            StringBundler query = new StringBundler(2);
2263    
2264                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
2265    
2266                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2267    
2268                            String sql = query.toString();
2269    
2270                            Session session = null;
2271    
2272                            try {
2273                                    session = openSession();
2274    
2275                                    Query q = session.createQuery(sql);
2276    
2277                                    QueryPos qPos = QueryPos.getInstance(q);
2278    
2279                                    qPos.add(groupId);
2280    
2281                                    count = (Long)q.uniqueResult();
2282    
2283                                    finderCache.putResult(finderPath, finderArgs, count);
2284                            }
2285                            catch (Exception e) {
2286                                    finderCache.removeResult(finderPath, finderArgs);
2287    
2288                                    throw processException(e);
2289                            }
2290                            finally {
2291                                    closeSession(session);
2292                            }
2293                    }
2294    
2295                    return count.intValue();
2296            }
2297    
2298            /**
2299             * Returns the number of document library folders that the user has permission to view where groupId = &#63;.
2300             *
2301             * @param groupId the group ID
2302             * @return the number of matching document library folders that the user has permission to view
2303             */
2304            @Override
2305            public int filterCountByGroupId(long groupId) {
2306                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2307                            return countByGroupId(groupId);
2308                    }
2309    
2310                    StringBundler query = new StringBundler(2);
2311    
2312                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
2313    
2314                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2315    
2316                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2317                                    DLFolder.class.getName(),
2318                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2319    
2320                    Session session = null;
2321    
2322                    try {
2323                            session = openSession();
2324    
2325                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2326    
2327                            q.addScalar(COUNT_COLUMN_NAME,
2328                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2329    
2330                            QueryPos qPos = QueryPos.getInstance(q);
2331    
2332                            qPos.add(groupId);
2333    
2334                            Long count = (Long)q.uniqueResult();
2335    
2336                            return count.intValue();
2337                    }
2338                    catch (Exception e) {
2339                            throw processException(e);
2340                    }
2341                    finally {
2342                            closeSession(session);
2343                    }
2344            }
2345    
2346            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
2347            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2348                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2349                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2350                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2351                            new String[] {
2352                                    Long.class.getName(),
2353                                    
2354                            Integer.class.getName(), Integer.class.getName(),
2355                                    OrderByComparator.class.getName()
2356                            });
2357            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2358                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2359                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2360                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2361                            new String[] { Long.class.getName() },
2362                            DLFolderModelImpl.COMPANYID_COLUMN_BITMASK |
2363                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2364                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
2365            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2366                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2367                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2368                            new String[] { Long.class.getName() });
2369    
2370            /**
2371             * Returns all the document library folders where companyId = &#63;.
2372             *
2373             * @param companyId the company ID
2374             * @return the matching document library folders
2375             */
2376            @Override
2377            public List<DLFolder> findByCompanyId(long companyId) {
2378                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2379                            null);
2380            }
2381    
2382            /**
2383             * Returns a range of all the document library folders where companyId = &#63;.
2384             *
2385             * <p>
2386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2387             * </p>
2388             *
2389             * @param companyId the company ID
2390             * @param start the lower bound of the range of document library folders
2391             * @param end the upper bound of the range of document library folders (not inclusive)
2392             * @return the range of matching document library folders
2393             */
2394            @Override
2395            public List<DLFolder> findByCompanyId(long companyId, int start, int end) {
2396                    return findByCompanyId(companyId, start, end, null);
2397            }
2398    
2399            /**
2400             * Returns an ordered range of all the document library folders where companyId = &#63;.
2401             *
2402             * <p>
2403             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2404             * </p>
2405             *
2406             * @param companyId the company ID
2407             * @param start the lower bound of the range of document library folders
2408             * @param end the upper bound of the range of document library folders (not inclusive)
2409             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2410             * @return the ordered range of matching document library folders
2411             */
2412            @Override
2413            public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2414                    OrderByComparator<DLFolder> orderByComparator) {
2415                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2416            }
2417    
2418            /**
2419             * Returns an ordered range of all the document library folders where companyId = &#63;.
2420             *
2421             * <p>
2422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2423             * </p>
2424             *
2425             * @param companyId the company ID
2426             * @param start the lower bound of the range of document library folders
2427             * @param end the upper bound of the range of document library folders (not inclusive)
2428             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2429             * @param retrieveFromCache whether to retrieve from the finder cache
2430             * @return the ordered range of matching document library folders
2431             */
2432            @Override
2433            public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2434                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
2435                    boolean pagination = true;
2436                    FinderPath finderPath = null;
2437                    Object[] finderArgs = null;
2438    
2439                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2440                                    (orderByComparator == null)) {
2441                            pagination = false;
2442                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2443                            finderArgs = new Object[] { companyId };
2444                    }
2445                    else {
2446                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2447                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2448                    }
2449    
2450                    List<DLFolder> list = null;
2451    
2452                    if (retrieveFromCache) {
2453                            list = (List<DLFolder>)finderCache.getResult(finderPath,
2454                                            finderArgs, this);
2455    
2456                            if ((list != null) && !list.isEmpty()) {
2457                                    for (DLFolder dlFolder : list) {
2458                                            if ((companyId != dlFolder.getCompanyId())) {
2459                                                    list = null;
2460    
2461                                                    break;
2462                                            }
2463                                    }
2464                            }
2465                    }
2466    
2467                    if (list == null) {
2468                            StringBundler query = null;
2469    
2470                            if (orderByComparator != null) {
2471                                    query = new StringBundler(3 +
2472                                                    (orderByComparator.getOrderByFields().length * 2));
2473                            }
2474                            else {
2475                                    query = new StringBundler(3);
2476                            }
2477    
2478                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2479    
2480                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2481    
2482                            if (orderByComparator != null) {
2483                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2484                                            orderByComparator);
2485                            }
2486                            else
2487                             if (pagination) {
2488                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2489                            }
2490    
2491                            String sql = query.toString();
2492    
2493                            Session session = null;
2494    
2495                            try {
2496                                    session = openSession();
2497    
2498                                    Query q = session.createQuery(sql);
2499    
2500                                    QueryPos qPos = QueryPos.getInstance(q);
2501    
2502                                    qPos.add(companyId);
2503    
2504                                    if (!pagination) {
2505                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2506                                                            start, end, false);
2507    
2508                                            Collections.sort(list);
2509    
2510                                            list = Collections.unmodifiableList(list);
2511                                    }
2512                                    else {
2513                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2514                                                            start, end);
2515                                    }
2516    
2517                                    cacheResult(list);
2518    
2519                                    finderCache.putResult(finderPath, finderArgs, list);
2520                            }
2521                            catch (Exception e) {
2522                                    finderCache.removeResult(finderPath, finderArgs);
2523    
2524                                    throw processException(e);
2525                            }
2526                            finally {
2527                                    closeSession(session);
2528                            }
2529                    }
2530    
2531                    return list;
2532            }
2533    
2534            /**
2535             * Returns the first document library folder in the ordered set where companyId = &#63;.
2536             *
2537             * @param companyId the company ID
2538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2539             * @return the first matching document library folder
2540             * @throws NoSuchFolderException if a matching document library folder could not be found
2541             */
2542            @Override
2543            public DLFolder findByCompanyId_First(long companyId,
2544                    OrderByComparator<DLFolder> orderByComparator)
2545                    throws NoSuchFolderException {
2546                    DLFolder dlFolder = fetchByCompanyId_First(companyId, orderByComparator);
2547    
2548                    if (dlFolder != null) {
2549                            return dlFolder;
2550                    }
2551    
2552                    StringBundler msg = new StringBundler(4);
2553    
2554                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2555    
2556                    msg.append("companyId=");
2557                    msg.append(companyId);
2558    
2559                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2560    
2561                    throw new NoSuchFolderException(msg.toString());
2562            }
2563    
2564            /**
2565             * Returns the first document library folder in the ordered set where companyId = &#63;.
2566             *
2567             * @param companyId the company ID
2568             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2569             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
2570             */
2571            @Override
2572            public DLFolder fetchByCompanyId_First(long companyId,
2573                    OrderByComparator<DLFolder> orderByComparator) {
2574                    List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2575    
2576                    if (!list.isEmpty()) {
2577                            return list.get(0);
2578                    }
2579    
2580                    return null;
2581            }
2582    
2583            /**
2584             * Returns the last document library folder in the ordered set where companyId = &#63;.
2585             *
2586             * @param companyId the company ID
2587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2588             * @return the last matching document library folder
2589             * @throws NoSuchFolderException if a matching document library folder could not be found
2590             */
2591            @Override
2592            public DLFolder findByCompanyId_Last(long companyId,
2593                    OrderByComparator<DLFolder> orderByComparator)
2594                    throws NoSuchFolderException {
2595                    DLFolder dlFolder = fetchByCompanyId_Last(companyId, orderByComparator);
2596    
2597                    if (dlFolder != null) {
2598                            return dlFolder;
2599                    }
2600    
2601                    StringBundler msg = new StringBundler(4);
2602    
2603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2604    
2605                    msg.append("companyId=");
2606                    msg.append(companyId);
2607    
2608                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2609    
2610                    throw new NoSuchFolderException(msg.toString());
2611            }
2612    
2613            /**
2614             * Returns the last document library folder in the ordered set where companyId = &#63;.
2615             *
2616             * @param companyId the company ID
2617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2618             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
2619             */
2620            @Override
2621            public DLFolder fetchByCompanyId_Last(long companyId,
2622                    OrderByComparator<DLFolder> orderByComparator) {
2623                    int count = countByCompanyId(companyId);
2624    
2625                    if (count == 0) {
2626                            return null;
2627                    }
2628    
2629                    List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
2630                                    orderByComparator);
2631    
2632                    if (!list.isEmpty()) {
2633                            return list.get(0);
2634                    }
2635    
2636                    return null;
2637            }
2638    
2639            /**
2640             * Returns the document library folders before and after the current document library folder in the ordered set where companyId = &#63;.
2641             *
2642             * @param folderId the primary key of the current document library folder
2643             * @param companyId the company ID
2644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2645             * @return the previous, current, and next document library folder
2646             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
2647             */
2648            @Override
2649            public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
2650                    long companyId, OrderByComparator<DLFolder> orderByComparator)
2651                    throws NoSuchFolderException {
2652                    DLFolder dlFolder = findByPrimaryKey(folderId);
2653    
2654                    Session session = null;
2655    
2656                    try {
2657                            session = openSession();
2658    
2659                            DLFolder[] array = new DLFolderImpl[3];
2660    
2661                            array[0] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2662                                            orderByComparator, true);
2663    
2664                            array[1] = dlFolder;
2665    
2666                            array[2] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2667                                            orderByComparator, false);
2668    
2669                            return array;
2670                    }
2671                    catch (Exception e) {
2672                            throw processException(e);
2673                    }
2674                    finally {
2675                            closeSession(session);
2676                    }
2677            }
2678    
2679            protected DLFolder getByCompanyId_PrevAndNext(Session session,
2680                    DLFolder dlFolder, long companyId,
2681                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
2682                    StringBundler query = null;
2683    
2684                    if (orderByComparator != null) {
2685                            query = new StringBundler(4 +
2686                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2687                                            (orderByComparator.getOrderByFields().length * 3));
2688                    }
2689                    else {
2690                            query = new StringBundler(3);
2691                    }
2692    
2693                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
2694    
2695                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2696    
2697                    if (orderByComparator != null) {
2698                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2699    
2700                            if (orderByConditionFields.length > 0) {
2701                                    query.append(WHERE_AND);
2702                            }
2703    
2704                            for (int i = 0; i < orderByConditionFields.length; i++) {
2705                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2706                                    query.append(orderByConditionFields[i]);
2707    
2708                                    if ((i + 1) < orderByConditionFields.length) {
2709                                            if (orderByComparator.isAscending() ^ previous) {
2710                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2711                                            }
2712                                            else {
2713                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2714                                            }
2715                                    }
2716                                    else {
2717                                            if (orderByComparator.isAscending() ^ previous) {
2718                                                    query.append(WHERE_GREATER_THAN);
2719                                            }
2720                                            else {
2721                                                    query.append(WHERE_LESSER_THAN);
2722                                            }
2723                                    }
2724                            }
2725    
2726                            query.append(ORDER_BY_CLAUSE);
2727    
2728                            String[] orderByFields = orderByComparator.getOrderByFields();
2729    
2730                            for (int i = 0; i < orderByFields.length; i++) {
2731                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2732                                    query.append(orderByFields[i]);
2733    
2734                                    if ((i + 1) < orderByFields.length) {
2735                                            if (orderByComparator.isAscending() ^ previous) {
2736                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2737                                            }
2738                                            else {
2739                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2740                                            }
2741                                    }
2742                                    else {
2743                                            if (orderByComparator.isAscending() ^ previous) {
2744                                                    query.append(ORDER_BY_ASC);
2745                                            }
2746                                            else {
2747                                                    query.append(ORDER_BY_DESC);
2748                                            }
2749                                    }
2750                            }
2751                    }
2752                    else {
2753                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2754                    }
2755    
2756                    String sql = query.toString();
2757    
2758                    Query q = session.createQuery(sql);
2759    
2760                    q.setFirstResult(0);
2761                    q.setMaxResults(2);
2762    
2763                    QueryPos qPos = QueryPos.getInstance(q);
2764    
2765                    qPos.add(companyId);
2766    
2767                    if (orderByComparator != null) {
2768                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2769    
2770                            for (Object value : values) {
2771                                    qPos.add(value);
2772                            }
2773                    }
2774    
2775                    List<DLFolder> list = q.list();
2776    
2777                    if (list.size() == 2) {
2778                            return list.get(1);
2779                    }
2780                    else {
2781                            return null;
2782                    }
2783            }
2784    
2785            /**
2786             * Removes all the document library folders where companyId = &#63; from the database.
2787             *
2788             * @param companyId the company ID
2789             */
2790            @Override
2791            public void removeByCompanyId(long companyId) {
2792                    for (DLFolder dlFolder : findByCompanyId(companyId, QueryUtil.ALL_POS,
2793                                    QueryUtil.ALL_POS, null)) {
2794                            remove(dlFolder);
2795                    }
2796            }
2797    
2798            /**
2799             * Returns the number of document library folders where companyId = &#63;.
2800             *
2801             * @param companyId the company ID
2802             * @return the number of matching document library folders
2803             */
2804            @Override
2805            public int countByCompanyId(long companyId) {
2806                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2807    
2808                    Object[] finderArgs = new Object[] { companyId };
2809    
2810                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2811    
2812                    if (count == null) {
2813                            StringBundler query = new StringBundler(2);
2814    
2815                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
2816    
2817                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2818    
2819                            String sql = query.toString();
2820    
2821                            Session session = null;
2822    
2823                            try {
2824                                    session = openSession();
2825    
2826                                    Query q = session.createQuery(sql);
2827    
2828                                    QueryPos qPos = QueryPos.getInstance(q);
2829    
2830                                    qPos.add(companyId);
2831    
2832                                    count = (Long)q.uniqueResult();
2833    
2834                                    finderCache.putResult(finderPath, finderArgs, count);
2835                            }
2836                            catch (Exception e) {
2837                                    finderCache.removeResult(finderPath, finderArgs);
2838    
2839                                    throw processException(e);
2840                            }
2841                            finally {
2842                                    closeSession(session);
2843                            }
2844                    }
2845    
2846                    return count.intValue();
2847            }
2848    
2849            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
2850            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
2851                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2852                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2853                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRepositoryId",
2854                            new String[] {
2855                                    Long.class.getName(),
2856                                    
2857                            Integer.class.getName(), Integer.class.getName(),
2858                                    OrderByComparator.class.getName()
2859                            });
2860            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
2861                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2862                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2863                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
2864                            new String[] { Long.class.getName() },
2865                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
2866                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2867                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
2868            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2869                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2870                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
2871                            new String[] { Long.class.getName() });
2872    
2873            /**
2874             * Returns all the document library folders where repositoryId = &#63;.
2875             *
2876             * @param repositoryId the repository ID
2877             * @return the matching document library folders
2878             */
2879            @Override
2880            public List<DLFolder> findByRepositoryId(long repositoryId) {
2881                    return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
2882                            QueryUtil.ALL_POS, null);
2883            }
2884    
2885            /**
2886             * Returns a range of all the document library folders where repositoryId = &#63;.
2887             *
2888             * <p>
2889             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2890             * </p>
2891             *
2892             * @param repositoryId the repository ID
2893             * @param start the lower bound of the range of document library folders
2894             * @param end the upper bound of the range of document library folders (not inclusive)
2895             * @return the range of matching document library folders
2896             */
2897            @Override
2898            public List<DLFolder> findByRepositoryId(long repositoryId, int start,
2899                    int end) {
2900                    return findByRepositoryId(repositoryId, start, end, null);
2901            }
2902    
2903            /**
2904             * Returns an ordered range of all the document library folders where repositoryId = &#63;.
2905             *
2906             * <p>
2907             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2908             * </p>
2909             *
2910             * @param repositoryId the repository ID
2911             * @param start the lower bound of the range of document library folders
2912             * @param end the upper bound of the range of document library folders (not inclusive)
2913             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2914             * @return the ordered range of matching document library folders
2915             */
2916            @Override
2917            public List<DLFolder> findByRepositoryId(long repositoryId, int start,
2918                    int end, OrderByComparator<DLFolder> orderByComparator) {
2919                    return findByRepositoryId(repositoryId, start, end, orderByComparator,
2920                            true);
2921            }
2922    
2923            /**
2924             * Returns an ordered range of all the document library folders where repositoryId = &#63;.
2925             *
2926             * <p>
2927             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2928             * </p>
2929             *
2930             * @param repositoryId the repository ID
2931             * @param start the lower bound of the range of document library folders
2932             * @param end the upper bound of the range of document library folders (not inclusive)
2933             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2934             * @param retrieveFromCache whether to retrieve from the finder cache
2935             * @return the ordered range of matching document library folders
2936             */
2937            @Override
2938            public List<DLFolder> findByRepositoryId(long repositoryId, int start,
2939                    int end, OrderByComparator<DLFolder> orderByComparator,
2940                    boolean retrieveFromCache) {
2941                    boolean pagination = true;
2942                    FinderPath finderPath = null;
2943                    Object[] finderArgs = null;
2944    
2945                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2946                                    (orderByComparator == null)) {
2947                            pagination = false;
2948                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
2949                            finderArgs = new Object[] { repositoryId };
2950                    }
2951                    else {
2952                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
2953                            finderArgs = new Object[] {
2954                                            repositoryId,
2955                                            
2956                                            start, end, orderByComparator
2957                                    };
2958                    }
2959    
2960                    List<DLFolder> list = null;
2961    
2962                    if (retrieveFromCache) {
2963                            list = (List<DLFolder>)finderCache.getResult(finderPath,
2964                                            finderArgs, this);
2965    
2966                            if ((list != null) && !list.isEmpty()) {
2967                                    for (DLFolder dlFolder : list) {
2968                                            if ((repositoryId != dlFolder.getRepositoryId())) {
2969                                                    list = null;
2970    
2971                                                    break;
2972                                            }
2973                                    }
2974                            }
2975                    }
2976    
2977                    if (list == null) {
2978                            StringBundler query = null;
2979    
2980                            if (orderByComparator != null) {
2981                                    query = new StringBundler(3 +
2982                                                    (orderByComparator.getOrderByFields().length * 2));
2983                            }
2984                            else {
2985                                    query = new StringBundler(3);
2986                            }
2987    
2988                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2989    
2990                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2991    
2992                            if (orderByComparator != null) {
2993                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2994                                            orderByComparator);
2995                            }
2996                            else
2997                             if (pagination) {
2998                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2999                            }
3000    
3001                            String sql = query.toString();
3002    
3003                            Session session = null;
3004    
3005                            try {
3006                                    session = openSession();
3007    
3008                                    Query q = session.createQuery(sql);
3009    
3010                                    QueryPos qPos = QueryPos.getInstance(q);
3011    
3012                                    qPos.add(repositoryId);
3013    
3014                                    if (!pagination) {
3015                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3016                                                            start, end, false);
3017    
3018                                            Collections.sort(list);
3019    
3020                                            list = Collections.unmodifiableList(list);
3021                                    }
3022                                    else {
3023                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3024                                                            start, end);
3025                                    }
3026    
3027                                    cacheResult(list);
3028    
3029                                    finderCache.putResult(finderPath, finderArgs, list);
3030                            }
3031                            catch (Exception e) {
3032                                    finderCache.removeResult(finderPath, finderArgs);
3033    
3034                                    throw processException(e);
3035                            }
3036                            finally {
3037                                    closeSession(session);
3038                            }
3039                    }
3040    
3041                    return list;
3042            }
3043    
3044            /**
3045             * Returns the first document library folder in the ordered set where repositoryId = &#63;.
3046             *
3047             * @param repositoryId the repository ID
3048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3049             * @return the first matching document library folder
3050             * @throws NoSuchFolderException if a matching document library folder could not be found
3051             */
3052            @Override
3053            public DLFolder findByRepositoryId_First(long repositoryId,
3054                    OrderByComparator<DLFolder> orderByComparator)
3055                    throws NoSuchFolderException {
3056                    DLFolder dlFolder = fetchByRepositoryId_First(repositoryId,
3057                                    orderByComparator);
3058    
3059                    if (dlFolder != null) {
3060                            return dlFolder;
3061                    }
3062    
3063                    StringBundler msg = new StringBundler(4);
3064    
3065                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3066    
3067                    msg.append("repositoryId=");
3068                    msg.append(repositoryId);
3069    
3070                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3071    
3072                    throw new NoSuchFolderException(msg.toString());
3073            }
3074    
3075            /**
3076             * Returns the first document library folder in the ordered set where repositoryId = &#63;.
3077             *
3078             * @param repositoryId the repository ID
3079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3080             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
3081             */
3082            @Override
3083            public DLFolder fetchByRepositoryId_First(long repositoryId,
3084                    OrderByComparator<DLFolder> orderByComparator) {
3085                    List<DLFolder> list = findByRepositoryId(repositoryId, 0, 1,
3086                                    orderByComparator);
3087    
3088                    if (!list.isEmpty()) {
3089                            return list.get(0);
3090                    }
3091    
3092                    return null;
3093            }
3094    
3095            /**
3096             * Returns the last document library folder in the ordered set where repositoryId = &#63;.
3097             *
3098             * @param repositoryId the repository ID
3099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3100             * @return the last matching document library folder
3101             * @throws NoSuchFolderException if a matching document library folder could not be found
3102             */
3103            @Override
3104            public DLFolder findByRepositoryId_Last(long repositoryId,
3105                    OrderByComparator<DLFolder> orderByComparator)
3106                    throws NoSuchFolderException {
3107                    DLFolder dlFolder = fetchByRepositoryId_Last(repositoryId,
3108                                    orderByComparator);
3109    
3110                    if (dlFolder != null) {
3111                            return dlFolder;
3112                    }
3113    
3114                    StringBundler msg = new StringBundler(4);
3115    
3116                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3117    
3118                    msg.append("repositoryId=");
3119                    msg.append(repositoryId);
3120    
3121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3122    
3123                    throw new NoSuchFolderException(msg.toString());
3124            }
3125    
3126            /**
3127             * Returns the last document library folder in the ordered set where repositoryId = &#63;.
3128             *
3129             * @param repositoryId the repository ID
3130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3131             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
3132             */
3133            @Override
3134            public DLFolder fetchByRepositoryId_Last(long repositoryId,
3135                    OrderByComparator<DLFolder> orderByComparator) {
3136                    int count = countByRepositoryId(repositoryId);
3137    
3138                    if (count == 0) {
3139                            return null;
3140                    }
3141    
3142                    List<DLFolder> list = findByRepositoryId(repositoryId, count - 1,
3143                                    count, orderByComparator);
3144    
3145                    if (!list.isEmpty()) {
3146                            return list.get(0);
3147                    }
3148    
3149                    return null;
3150            }
3151    
3152            /**
3153             * Returns the document library folders before and after the current document library folder in the ordered set where repositoryId = &#63;.
3154             *
3155             * @param folderId the primary key of the current document library folder
3156             * @param repositoryId the repository ID
3157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3158             * @return the previous, current, and next document library folder
3159             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3160             */
3161            @Override
3162            public DLFolder[] findByRepositoryId_PrevAndNext(long folderId,
3163                    long repositoryId, OrderByComparator<DLFolder> orderByComparator)
3164                    throws NoSuchFolderException {
3165                    DLFolder dlFolder = findByPrimaryKey(folderId);
3166    
3167                    Session session = null;
3168    
3169                    try {
3170                            session = openSession();
3171    
3172                            DLFolder[] array = new DLFolderImpl[3];
3173    
3174                            array[0] = getByRepositoryId_PrevAndNext(session, dlFolder,
3175                                            repositoryId, orderByComparator, true);
3176    
3177                            array[1] = dlFolder;
3178    
3179                            array[2] = getByRepositoryId_PrevAndNext(session, dlFolder,
3180                                            repositoryId, orderByComparator, false);
3181    
3182                            return array;
3183                    }
3184                    catch (Exception e) {
3185                            throw processException(e);
3186                    }
3187                    finally {
3188                            closeSession(session);
3189                    }
3190            }
3191    
3192            protected DLFolder getByRepositoryId_PrevAndNext(Session session,
3193                    DLFolder dlFolder, long repositoryId,
3194                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
3195                    StringBundler query = null;
3196    
3197                    if (orderByComparator != null) {
3198                            query = new StringBundler(4 +
3199                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3200                                            (orderByComparator.getOrderByFields().length * 3));
3201                    }
3202                    else {
3203                            query = new StringBundler(3);
3204                    }
3205    
3206                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
3207    
3208                    query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3209    
3210                    if (orderByComparator != null) {
3211                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3212    
3213                            if (orderByConditionFields.length > 0) {
3214                                    query.append(WHERE_AND);
3215                            }
3216    
3217                            for (int i = 0; i < orderByConditionFields.length; i++) {
3218                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3219                                    query.append(orderByConditionFields[i]);
3220    
3221                                    if ((i + 1) < orderByConditionFields.length) {
3222                                            if (orderByComparator.isAscending() ^ previous) {
3223                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3224                                            }
3225                                            else {
3226                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3227                                            }
3228                                    }
3229                                    else {
3230                                            if (orderByComparator.isAscending() ^ previous) {
3231                                                    query.append(WHERE_GREATER_THAN);
3232                                            }
3233                                            else {
3234                                                    query.append(WHERE_LESSER_THAN);
3235                                            }
3236                                    }
3237                            }
3238    
3239                            query.append(ORDER_BY_CLAUSE);
3240    
3241                            String[] orderByFields = orderByComparator.getOrderByFields();
3242    
3243                            for (int i = 0; i < orderByFields.length; i++) {
3244                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3245                                    query.append(orderByFields[i]);
3246    
3247                                    if ((i + 1) < orderByFields.length) {
3248                                            if (orderByComparator.isAscending() ^ previous) {
3249                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3250                                            }
3251                                            else {
3252                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3253                                            }
3254                                    }
3255                                    else {
3256                                            if (orderByComparator.isAscending() ^ previous) {
3257                                                    query.append(ORDER_BY_ASC);
3258                                            }
3259                                            else {
3260                                                    query.append(ORDER_BY_DESC);
3261                                            }
3262                                    }
3263                            }
3264                    }
3265                    else {
3266                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3267                    }
3268    
3269                    String sql = query.toString();
3270    
3271                    Query q = session.createQuery(sql);
3272    
3273                    q.setFirstResult(0);
3274                    q.setMaxResults(2);
3275    
3276                    QueryPos qPos = QueryPos.getInstance(q);
3277    
3278                    qPos.add(repositoryId);
3279    
3280                    if (orderByComparator != null) {
3281                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3282    
3283                            for (Object value : values) {
3284                                    qPos.add(value);
3285                            }
3286                    }
3287    
3288                    List<DLFolder> list = q.list();
3289    
3290                    if (list.size() == 2) {
3291                            return list.get(1);
3292                    }
3293                    else {
3294                            return null;
3295                    }
3296            }
3297    
3298            /**
3299             * Removes all the document library folders where repositoryId = &#63; from the database.
3300             *
3301             * @param repositoryId the repository ID
3302             */
3303            @Override
3304            public void removeByRepositoryId(long repositoryId) {
3305                    for (DLFolder dlFolder : findByRepositoryId(repositoryId,
3306                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3307                            remove(dlFolder);
3308                    }
3309            }
3310    
3311            /**
3312             * Returns the number of document library folders where repositoryId = &#63;.
3313             *
3314             * @param repositoryId the repository ID
3315             * @return the number of matching document library folders
3316             */
3317            @Override
3318            public int countByRepositoryId(long repositoryId) {
3319                    FinderPath finderPath = FINDER_PATH_COUNT_BY_REPOSITORYID;
3320    
3321                    Object[] finderArgs = new Object[] { repositoryId };
3322    
3323                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3324    
3325                    if (count == null) {
3326                            StringBundler query = new StringBundler(2);
3327    
3328                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
3329    
3330                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3331    
3332                            String sql = query.toString();
3333    
3334                            Session session = null;
3335    
3336                            try {
3337                                    session = openSession();
3338    
3339                                    Query q = session.createQuery(sql);
3340    
3341                                    QueryPos qPos = QueryPos.getInstance(q);
3342    
3343                                    qPos.add(repositoryId);
3344    
3345                                    count = (Long)q.uniqueResult();
3346    
3347                                    finderCache.putResult(finderPath, finderArgs, count);
3348                            }
3349                            catch (Exception e) {
3350                                    finderCache.removeResult(finderPath, finderArgs);
3351    
3352                                    throw processException(e);
3353                            }
3354                            finally {
3355                                    closeSession(session);
3356                            }
3357                    }
3358    
3359                    return count.intValue();
3360            }
3361    
3362            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFolder.repositoryId = ?";
3363            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3364                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
3365                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
3366                            new String[] {
3367                                    Long.class.getName(), Long.class.getName(),
3368                                    
3369                            Integer.class.getName(), Integer.class.getName(),
3370                                    OrderByComparator.class.getName()
3371                            });
3372            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3373                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
3374                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
3375                            new String[] { Long.class.getName(), Long.class.getName() },
3376                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
3377                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
3378                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
3379            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3380                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
3381                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
3382                            new String[] { Long.class.getName(), Long.class.getName() });
3383    
3384            /**
3385             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3386             *
3387             * @param groupId the group ID
3388             * @param parentFolderId the parent folder ID
3389             * @return the matching document library folders
3390             */
3391            @Override
3392            public List<DLFolder> findByG_P(long groupId, long parentFolderId) {
3393                    return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3394                            QueryUtil.ALL_POS, null);
3395            }
3396    
3397            /**
3398             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3399             *
3400             * <p>
3401             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3402             * </p>
3403             *
3404             * @param groupId the group ID
3405             * @param parentFolderId the parent folder ID
3406             * @param start the lower bound of the range of document library folders
3407             * @param end the upper bound of the range of document library folders (not inclusive)
3408             * @return the range of matching document library folders
3409             */
3410            @Override
3411            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
3412                    int start, int end) {
3413                    return findByG_P(groupId, parentFolderId, start, end, null);
3414            }
3415    
3416            /**
3417             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3418             *
3419             * <p>
3420             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3421             * </p>
3422             *
3423             * @param groupId the group ID
3424             * @param parentFolderId the parent folder ID
3425             * @param start the lower bound of the range of document library folders
3426             * @param end the upper bound of the range of document library folders (not inclusive)
3427             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3428             * @return the ordered range of matching document library folders
3429             */
3430            @Override
3431            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
3432                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
3433                    return findByG_P(groupId, parentFolderId, start, end,
3434                            orderByComparator, true);
3435            }
3436    
3437            /**
3438             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3439             *
3440             * <p>
3441             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3442             * </p>
3443             *
3444             * @param groupId the group ID
3445             * @param parentFolderId the parent folder ID
3446             * @param start the lower bound of the range of document library folders
3447             * @param end the upper bound of the range of document library folders (not inclusive)
3448             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3449             * @param retrieveFromCache whether to retrieve from the finder cache
3450             * @return the ordered range of matching document library folders
3451             */
3452            @Override
3453            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
3454                    int start, int end, OrderByComparator<DLFolder> orderByComparator,
3455                    boolean retrieveFromCache) {
3456                    boolean pagination = true;
3457                    FinderPath finderPath = null;
3458                    Object[] finderArgs = null;
3459    
3460                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3461                                    (orderByComparator == null)) {
3462                            pagination = false;
3463                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
3464                            finderArgs = new Object[] { groupId, parentFolderId };
3465                    }
3466                    else {
3467                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
3468                            finderArgs = new Object[] {
3469                                            groupId, parentFolderId,
3470                                            
3471                                            start, end, orderByComparator
3472                                    };
3473                    }
3474    
3475                    List<DLFolder> list = null;
3476    
3477                    if (retrieveFromCache) {
3478                            list = (List<DLFolder>)finderCache.getResult(finderPath,
3479                                            finderArgs, this);
3480    
3481                            if ((list != null) && !list.isEmpty()) {
3482                                    for (DLFolder dlFolder : list) {
3483                                            if ((groupId != dlFolder.getGroupId()) ||
3484                                                            (parentFolderId != dlFolder.getParentFolderId())) {
3485                                                    list = null;
3486    
3487                                                    break;
3488                                            }
3489                                    }
3490                            }
3491                    }
3492    
3493                    if (list == null) {
3494                            StringBundler query = null;
3495    
3496                            if (orderByComparator != null) {
3497                                    query = new StringBundler(4 +
3498                                                    (orderByComparator.getOrderByFields().length * 2));
3499                            }
3500                            else {
3501                                    query = new StringBundler(4);
3502                            }
3503    
3504                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
3505    
3506                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3507    
3508                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3509    
3510                            if (orderByComparator != null) {
3511                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3512                                            orderByComparator);
3513                            }
3514                            else
3515                             if (pagination) {
3516                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3517                            }
3518    
3519                            String sql = query.toString();
3520    
3521                            Session session = null;
3522    
3523                            try {
3524                                    session = openSession();
3525    
3526                                    Query q = session.createQuery(sql);
3527    
3528                                    QueryPos qPos = QueryPos.getInstance(q);
3529    
3530                                    qPos.add(groupId);
3531    
3532                                    qPos.add(parentFolderId);
3533    
3534                                    if (!pagination) {
3535                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3536                                                            start, end, false);
3537    
3538                                            Collections.sort(list);
3539    
3540                                            list = Collections.unmodifiableList(list);
3541                                    }
3542                                    else {
3543                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3544                                                            start, end);
3545                                    }
3546    
3547                                    cacheResult(list);
3548    
3549                                    finderCache.putResult(finderPath, finderArgs, list);
3550                            }
3551                            catch (Exception e) {
3552                                    finderCache.removeResult(finderPath, finderArgs);
3553    
3554                                    throw processException(e);
3555                            }
3556                            finally {
3557                                    closeSession(session);
3558                            }
3559                    }
3560    
3561                    return list;
3562            }
3563    
3564            /**
3565             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3566             *
3567             * @param groupId the group ID
3568             * @param parentFolderId the parent folder ID
3569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3570             * @return the first matching document library folder
3571             * @throws NoSuchFolderException if a matching document library folder could not be found
3572             */
3573            @Override
3574            public DLFolder findByG_P_First(long groupId, long parentFolderId,
3575                    OrderByComparator<DLFolder> orderByComparator)
3576                    throws NoSuchFolderException {
3577                    DLFolder dlFolder = fetchByG_P_First(groupId, parentFolderId,
3578                                    orderByComparator);
3579    
3580                    if (dlFolder != null) {
3581                            return dlFolder;
3582                    }
3583    
3584                    StringBundler msg = new StringBundler(6);
3585    
3586                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3587    
3588                    msg.append("groupId=");
3589                    msg.append(groupId);
3590    
3591                    msg.append(", parentFolderId=");
3592                    msg.append(parentFolderId);
3593    
3594                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3595    
3596                    throw new NoSuchFolderException(msg.toString());
3597            }
3598    
3599            /**
3600             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3601             *
3602             * @param groupId the group ID
3603             * @param parentFolderId the parent folder ID
3604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3605             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
3606             */
3607            @Override
3608            public DLFolder fetchByG_P_First(long groupId, long parentFolderId,
3609                    OrderByComparator<DLFolder> orderByComparator) {
3610                    List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
3611                                    orderByComparator);
3612    
3613                    if (!list.isEmpty()) {
3614                            return list.get(0);
3615                    }
3616    
3617                    return null;
3618            }
3619    
3620            /**
3621             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3622             *
3623             * @param groupId the group ID
3624             * @param parentFolderId the parent folder ID
3625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3626             * @return the last matching document library folder
3627             * @throws NoSuchFolderException if a matching document library folder could not be found
3628             */
3629            @Override
3630            public DLFolder findByG_P_Last(long groupId, long parentFolderId,
3631                    OrderByComparator<DLFolder> orderByComparator)
3632                    throws NoSuchFolderException {
3633                    DLFolder dlFolder = fetchByG_P_Last(groupId, parentFolderId,
3634                                    orderByComparator);
3635    
3636                    if (dlFolder != null) {
3637                            return dlFolder;
3638                    }
3639    
3640                    StringBundler msg = new StringBundler(6);
3641    
3642                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3643    
3644                    msg.append("groupId=");
3645                    msg.append(groupId);
3646    
3647                    msg.append(", parentFolderId=");
3648                    msg.append(parentFolderId);
3649    
3650                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3651    
3652                    throw new NoSuchFolderException(msg.toString());
3653            }
3654    
3655            /**
3656             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3657             *
3658             * @param groupId the group ID
3659             * @param parentFolderId the parent folder ID
3660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3661             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
3662             */
3663            @Override
3664            public DLFolder fetchByG_P_Last(long groupId, long parentFolderId,
3665                    OrderByComparator<DLFolder> orderByComparator) {
3666                    int count = countByG_P(groupId, parentFolderId);
3667    
3668                    if (count == 0) {
3669                            return null;
3670                    }
3671    
3672                    List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
3673                                    count, orderByComparator);
3674    
3675                    if (!list.isEmpty()) {
3676                            return list.get(0);
3677                    }
3678    
3679                    return null;
3680            }
3681    
3682            /**
3683             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3684             *
3685             * @param folderId the primary key of the current document library folder
3686             * @param groupId the group ID
3687             * @param parentFolderId the parent folder ID
3688             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3689             * @return the previous, current, and next document library folder
3690             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3691             */
3692            @Override
3693            public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
3694                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
3695                    throws NoSuchFolderException {
3696                    DLFolder dlFolder = findByPrimaryKey(folderId);
3697    
3698                    Session session = null;
3699    
3700                    try {
3701                            session = openSession();
3702    
3703                            DLFolder[] array = new DLFolderImpl[3];
3704    
3705                            array[0] = getByG_P_PrevAndNext(session, dlFolder, groupId,
3706                                            parentFolderId, orderByComparator, true);
3707    
3708                            array[1] = dlFolder;
3709    
3710                            array[2] = getByG_P_PrevAndNext(session, dlFolder, groupId,
3711                                            parentFolderId, orderByComparator, false);
3712    
3713                            return array;
3714                    }
3715                    catch (Exception e) {
3716                            throw processException(e);
3717                    }
3718                    finally {
3719                            closeSession(session);
3720                    }
3721            }
3722    
3723            protected DLFolder getByG_P_PrevAndNext(Session session, DLFolder dlFolder,
3724                    long groupId, long parentFolderId,
3725                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
3726                    StringBundler query = null;
3727    
3728                    if (orderByComparator != null) {
3729                            query = new StringBundler(5 +
3730                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3731                                            (orderByComparator.getOrderByFields().length * 3));
3732                    }
3733                    else {
3734                            query = new StringBundler(4);
3735                    }
3736    
3737                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
3738    
3739                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3740    
3741                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3742    
3743                    if (orderByComparator != null) {
3744                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3745    
3746                            if (orderByConditionFields.length > 0) {
3747                                    query.append(WHERE_AND);
3748                            }
3749    
3750                            for (int i = 0; i < orderByConditionFields.length; i++) {
3751                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3752                                    query.append(orderByConditionFields[i]);
3753    
3754                                    if ((i + 1) < orderByConditionFields.length) {
3755                                            if (orderByComparator.isAscending() ^ previous) {
3756                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3757                                            }
3758                                            else {
3759                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3760                                            }
3761                                    }
3762                                    else {
3763                                            if (orderByComparator.isAscending() ^ previous) {
3764                                                    query.append(WHERE_GREATER_THAN);
3765                                            }
3766                                            else {
3767                                                    query.append(WHERE_LESSER_THAN);
3768                                            }
3769                                    }
3770                            }
3771    
3772                            query.append(ORDER_BY_CLAUSE);
3773    
3774                            String[] orderByFields = orderByComparator.getOrderByFields();
3775    
3776                            for (int i = 0; i < orderByFields.length; i++) {
3777                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3778                                    query.append(orderByFields[i]);
3779    
3780                                    if ((i + 1) < orderByFields.length) {
3781                                            if (orderByComparator.isAscending() ^ previous) {
3782                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3783                                            }
3784                                            else {
3785                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3786                                            }
3787                                    }
3788                                    else {
3789                                            if (orderByComparator.isAscending() ^ previous) {
3790                                                    query.append(ORDER_BY_ASC);
3791                                            }
3792                                            else {
3793                                                    query.append(ORDER_BY_DESC);
3794                                            }
3795                                    }
3796                            }
3797                    }
3798                    else {
3799                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3800                    }
3801    
3802                    String sql = query.toString();
3803    
3804                    Query q = session.createQuery(sql);
3805    
3806                    q.setFirstResult(0);
3807                    q.setMaxResults(2);
3808    
3809                    QueryPos qPos = QueryPos.getInstance(q);
3810    
3811                    qPos.add(groupId);
3812    
3813                    qPos.add(parentFolderId);
3814    
3815                    if (orderByComparator != null) {
3816                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3817    
3818                            for (Object value : values) {
3819                                    qPos.add(value);
3820                            }
3821                    }
3822    
3823                    List<DLFolder> list = q.list();
3824    
3825                    if (list.size() == 2) {
3826                            return list.get(1);
3827                    }
3828                    else {
3829                            return null;
3830                    }
3831            }
3832    
3833            /**
3834             * Returns all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3835             *
3836             * @param groupId the group ID
3837             * @param parentFolderId the parent folder ID
3838             * @return the matching document library folders that the user has permission to view
3839             */
3840            @Override
3841            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId) {
3842                    return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3843                            QueryUtil.ALL_POS, null);
3844            }
3845    
3846            /**
3847             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3848             *
3849             * <p>
3850             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3851             * </p>
3852             *
3853             * @param groupId the group ID
3854             * @param parentFolderId the parent folder ID
3855             * @param start the lower bound of the range of document library folders
3856             * @param end the upper bound of the range of document library folders (not inclusive)
3857             * @return the range of matching document library folders that the user has permission to view
3858             */
3859            @Override
3860            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3861                    int start, int end) {
3862                    return filterFindByG_P(groupId, parentFolderId, start, end, null);
3863            }
3864    
3865            /**
3866             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63;.
3867             *
3868             * <p>
3869             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3870             * </p>
3871             *
3872             * @param groupId the group ID
3873             * @param parentFolderId the parent folder ID
3874             * @param start the lower bound of the range of document library folders
3875             * @param end the upper bound of the range of document library folders (not inclusive)
3876             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3877             * @return the ordered range of matching document library folders that the user has permission to view
3878             */
3879            @Override
3880            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3881                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
3882                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3883                            return findByG_P(groupId, parentFolderId, start, end,
3884                                    orderByComparator);
3885                    }
3886    
3887                    StringBundler query = null;
3888    
3889                    if (orderByComparator != null) {
3890                            query = new StringBundler(4 +
3891                                            (orderByComparator.getOrderByFields().length * 2));
3892                    }
3893                    else {
3894                            query = new StringBundler(5);
3895                    }
3896    
3897                    if (getDB().isSupportsInlineDistinct()) {
3898                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3899                    }
3900                    else {
3901                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3902                    }
3903    
3904                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3905    
3906                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3907    
3908                    if (!getDB().isSupportsInlineDistinct()) {
3909                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3910                    }
3911    
3912                    if (orderByComparator != null) {
3913                            if (getDB().isSupportsInlineDistinct()) {
3914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3915                                            orderByComparator, true);
3916                            }
3917                            else {
3918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3919                                            orderByComparator, true);
3920                            }
3921                    }
3922                    else {
3923                            if (getDB().isSupportsInlineDistinct()) {
3924                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3925                            }
3926                            else {
3927                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
3928                            }
3929                    }
3930    
3931                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3932                                    DLFolder.class.getName(),
3933                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3934    
3935                    Session session = null;
3936    
3937                    try {
3938                            session = openSession();
3939    
3940                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3941    
3942                            if (getDB().isSupportsInlineDistinct()) {
3943                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3944                            }
3945                            else {
3946                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3947                            }
3948    
3949                            QueryPos qPos = QueryPos.getInstance(q);
3950    
3951                            qPos.add(groupId);
3952    
3953                            qPos.add(parentFolderId);
3954    
3955                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
3956                    }
3957                    catch (Exception e) {
3958                            throw processException(e);
3959                    }
3960                    finally {
3961                            closeSession(session);
3962                    }
3963            }
3964    
3965            /**
3966             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3967             *
3968             * @param folderId the primary key of the current document library folder
3969             * @param groupId the group ID
3970             * @param parentFolderId the parent folder ID
3971             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3972             * @return the previous, current, and next document library folder
3973             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3974             */
3975            @Override
3976            public DLFolder[] filterFindByG_P_PrevAndNext(long folderId, long groupId,
3977                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
3978                    throws NoSuchFolderException {
3979                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3980                            return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3981                                    orderByComparator);
3982                    }
3983    
3984                    DLFolder dlFolder = findByPrimaryKey(folderId);
3985    
3986                    Session session = null;
3987    
3988                    try {
3989                            session = openSession();
3990    
3991                            DLFolder[] array = new DLFolderImpl[3];
3992    
3993                            array[0] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3994                                            parentFolderId, orderByComparator, true);
3995    
3996                            array[1] = dlFolder;
3997    
3998                            array[2] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3999                                            parentFolderId, orderByComparator, false);
4000    
4001                            return array;
4002                    }
4003                    catch (Exception e) {
4004                            throw processException(e);
4005                    }
4006                    finally {
4007                            closeSession(session);
4008                    }
4009            }
4010    
4011            protected DLFolder filterGetByG_P_PrevAndNext(Session session,
4012                    DLFolder dlFolder, long groupId, long parentFolderId,
4013                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
4014                    StringBundler query = null;
4015    
4016                    if (orderByComparator != null) {
4017                            query = new StringBundler(6 +
4018                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4019                                            (orderByComparator.getOrderByFields().length * 3));
4020                    }
4021                    else {
4022                            query = new StringBundler(5);
4023                    }
4024    
4025                    if (getDB().isSupportsInlineDistinct()) {
4026                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4027                    }
4028                    else {
4029                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4030                    }
4031    
4032                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4033    
4034                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4035    
4036                    if (!getDB().isSupportsInlineDistinct()) {
4037                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4038                    }
4039    
4040                    if (orderByComparator != null) {
4041                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4042    
4043                            if (orderByConditionFields.length > 0) {
4044                                    query.append(WHERE_AND);
4045                            }
4046    
4047                            for (int i = 0; i < orderByConditionFields.length; i++) {
4048                                    if (getDB().isSupportsInlineDistinct()) {
4049                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4050                                    }
4051                                    else {
4052                                            query.append(_ORDER_BY_ENTITY_TABLE);
4053                                    }
4054    
4055                                    query.append(orderByConditionFields[i]);
4056    
4057                                    if ((i + 1) < orderByConditionFields.length) {
4058                                            if (orderByComparator.isAscending() ^ previous) {
4059                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4060                                            }
4061                                            else {
4062                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4063                                            }
4064                                    }
4065                                    else {
4066                                            if (orderByComparator.isAscending() ^ previous) {
4067                                                    query.append(WHERE_GREATER_THAN);
4068                                            }
4069                                            else {
4070                                                    query.append(WHERE_LESSER_THAN);
4071                                            }
4072                                    }
4073                            }
4074    
4075                            query.append(ORDER_BY_CLAUSE);
4076    
4077                            String[] orderByFields = orderByComparator.getOrderByFields();
4078    
4079                            for (int i = 0; i < orderByFields.length; i++) {
4080                                    if (getDB().isSupportsInlineDistinct()) {
4081                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4082                                    }
4083                                    else {
4084                                            query.append(_ORDER_BY_ENTITY_TABLE);
4085                                    }
4086    
4087                                    query.append(orderByFields[i]);
4088    
4089                                    if ((i + 1) < orderByFields.length) {
4090                                            if (orderByComparator.isAscending() ^ previous) {
4091                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4092                                            }
4093                                            else {
4094                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4095                                            }
4096                                    }
4097                                    else {
4098                                            if (orderByComparator.isAscending() ^ previous) {
4099                                                    query.append(ORDER_BY_ASC);
4100                                            }
4101                                            else {
4102                                                    query.append(ORDER_BY_DESC);
4103                                            }
4104                                    }
4105                            }
4106                    }
4107                    else {
4108                            if (getDB().isSupportsInlineDistinct()) {
4109                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4110                            }
4111                            else {
4112                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
4113                            }
4114                    }
4115    
4116                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4117                                    DLFolder.class.getName(),
4118                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4119    
4120                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4121    
4122                    q.setFirstResult(0);
4123                    q.setMaxResults(2);
4124    
4125                    if (getDB().isSupportsInlineDistinct()) {
4126                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4127                    }
4128                    else {
4129                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4130                    }
4131    
4132                    QueryPos qPos = QueryPos.getInstance(q);
4133    
4134                    qPos.add(groupId);
4135    
4136                    qPos.add(parentFolderId);
4137    
4138                    if (orderByComparator != null) {
4139                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4140    
4141                            for (Object value : values) {
4142                                    qPos.add(value);
4143                            }
4144                    }
4145    
4146                    List<DLFolder> list = q.list();
4147    
4148                    if (list.size() == 2) {
4149                            return list.get(1);
4150                    }
4151                    else {
4152                            return null;
4153                    }
4154            }
4155    
4156            /**
4157             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; from the database.
4158             *
4159             * @param groupId the group ID
4160             * @param parentFolderId the parent folder ID
4161             */
4162            @Override
4163            public void removeByG_P(long groupId, long parentFolderId) {
4164                    for (DLFolder dlFolder : findByG_P(groupId, parentFolderId,
4165                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4166                            remove(dlFolder);
4167                    }
4168            }
4169    
4170            /**
4171             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63;.
4172             *
4173             * @param groupId the group ID
4174             * @param parentFolderId the parent folder ID
4175             * @return the number of matching document library folders
4176             */
4177            @Override
4178            public int countByG_P(long groupId, long parentFolderId) {
4179                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
4180    
4181                    Object[] finderArgs = new Object[] { groupId, parentFolderId };
4182    
4183                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4184    
4185                    if (count == null) {
4186                            StringBundler query = new StringBundler(3);
4187    
4188                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4189    
4190                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4191    
4192                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4193    
4194                            String sql = query.toString();
4195    
4196                            Session session = null;
4197    
4198                            try {
4199                                    session = openSession();
4200    
4201                                    Query q = session.createQuery(sql);
4202    
4203                                    QueryPos qPos = QueryPos.getInstance(q);
4204    
4205                                    qPos.add(groupId);
4206    
4207                                    qPos.add(parentFolderId);
4208    
4209                                    count = (Long)q.uniqueResult();
4210    
4211                                    finderCache.putResult(finderPath, finderArgs, count);
4212                            }
4213                            catch (Exception e) {
4214                                    finderCache.removeResult(finderPath, finderArgs);
4215    
4216                                    throw processException(e);
4217                            }
4218                            finally {
4219                                    closeSession(session);
4220                            }
4221                    }
4222    
4223                    return count.intValue();
4224            }
4225    
4226            /**
4227             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
4228             *
4229             * @param groupId the group ID
4230             * @param parentFolderId the parent folder ID
4231             * @return the number of matching document library folders that the user has permission to view
4232             */
4233            @Override
4234            public int filterCountByG_P(long groupId, long parentFolderId) {
4235                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4236                            return countByG_P(groupId, parentFolderId);
4237                    }
4238    
4239                    StringBundler query = new StringBundler(3);
4240    
4241                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
4242    
4243                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4244    
4245                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4246    
4247                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4248                                    DLFolder.class.getName(),
4249                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4250    
4251                    Session session = null;
4252    
4253                    try {
4254                            session = openSession();
4255    
4256                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4257    
4258                            q.addScalar(COUNT_COLUMN_NAME,
4259                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4260    
4261                            QueryPos qPos = QueryPos.getInstance(q);
4262    
4263                            qPos.add(groupId);
4264    
4265                            qPos.add(parentFolderId);
4266    
4267                            Long count = (Long)q.uniqueResult();
4268    
4269                            return count.intValue();
4270                    }
4271                    catch (Exception e) {
4272                            throw processException(e);
4273                    }
4274                    finally {
4275                            closeSession(session);
4276                    }
4277            }
4278    
4279            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
4280            private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
4281            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4282                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4283                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
4284                            new String[] {
4285                                    Long.class.getName(), Integer.class.getName(),
4286                                    
4287                            Integer.class.getName(), Integer.class.getName(),
4288                                    OrderByComparator.class.getName()
4289                            });
4290            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4291                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4292                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
4293                            new String[] { Long.class.getName(), Integer.class.getName() });
4294    
4295            /**
4296             * Returns all the document library folders where companyId = &#63; and status &ne; &#63;.
4297             *
4298             * @param companyId the company ID
4299             * @param status the status
4300             * @return the matching document library folders
4301             */
4302            @Override
4303            public List<DLFolder> findByC_NotS(long companyId, int status) {
4304                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
4305                            QueryUtil.ALL_POS, null);
4306            }
4307    
4308            /**
4309             * Returns a range of all the document library folders where companyId = &#63; and status &ne; &#63;.
4310             *
4311             * <p>
4312             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4313             * </p>
4314             *
4315             * @param companyId the company ID
4316             * @param status the status
4317             * @param start the lower bound of the range of document library folders
4318             * @param end the upper bound of the range of document library folders (not inclusive)
4319             * @return the range of matching document library folders
4320             */
4321            @Override
4322            public List<DLFolder> findByC_NotS(long companyId, int status, int start,
4323                    int end) {
4324                    return findByC_NotS(companyId, status, start, end, null);
4325            }
4326    
4327            /**
4328             * Returns an ordered range of all the document library folders where companyId = &#63; and status &ne; &#63;.
4329             *
4330             * <p>
4331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4332             * </p>
4333             *
4334             * @param companyId the company ID
4335             * @param status the status
4336             * @param start the lower bound of the range of document library folders
4337             * @param end the upper bound of the range of document library folders (not inclusive)
4338             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4339             * @return the ordered range of matching document library folders
4340             */
4341            @Override
4342            public List<DLFolder> findByC_NotS(long companyId, int status, int start,
4343                    int end, OrderByComparator<DLFolder> orderByComparator) {
4344                    return findByC_NotS(companyId, status, start, end, orderByComparator,
4345                            true);
4346            }
4347    
4348            /**
4349             * Returns an ordered range of all the document library folders where companyId = &#63; and status &ne; &#63;.
4350             *
4351             * <p>
4352             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4353             * </p>
4354             *
4355             * @param companyId the company ID
4356             * @param status the status
4357             * @param start the lower bound of the range of document library folders
4358             * @param end the upper bound of the range of document library folders (not inclusive)
4359             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4360             * @param retrieveFromCache whether to retrieve from the finder cache
4361             * @return the ordered range of matching document library folders
4362             */
4363            @Override
4364            public List<DLFolder> findByC_NotS(long companyId, int status, int start,
4365                    int end, OrderByComparator<DLFolder> orderByComparator,
4366                    boolean retrieveFromCache) {
4367                    boolean pagination = true;
4368                    FinderPath finderPath = null;
4369                    Object[] finderArgs = null;
4370    
4371                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
4372                    finderArgs = new Object[] {
4373                                    companyId, status,
4374                                    
4375                                    start, end, orderByComparator
4376                            };
4377    
4378                    List<DLFolder> list = null;
4379    
4380                    if (retrieveFromCache) {
4381                            list = (List<DLFolder>)finderCache.getResult(finderPath,
4382                                            finderArgs, this);
4383    
4384                            if ((list != null) && !list.isEmpty()) {
4385                                    for (DLFolder dlFolder : list) {
4386                                            if ((companyId != dlFolder.getCompanyId()) ||
4387                                                            (status == dlFolder.getStatus())) {
4388                                                    list = null;
4389    
4390                                                    break;
4391                                            }
4392                                    }
4393                            }
4394                    }
4395    
4396                    if (list == null) {
4397                            StringBundler query = null;
4398    
4399                            if (orderByComparator != null) {
4400                                    query = new StringBundler(4 +
4401                                                    (orderByComparator.getOrderByFields().length * 2));
4402                            }
4403                            else {
4404                                    query = new StringBundler(4);
4405                            }
4406    
4407                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4408    
4409                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4410    
4411                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4412    
4413                            if (orderByComparator != null) {
4414                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4415                                            orderByComparator);
4416                            }
4417                            else
4418                             if (pagination) {
4419                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4420                            }
4421    
4422                            String sql = query.toString();
4423    
4424                            Session session = null;
4425    
4426                            try {
4427                                    session = openSession();
4428    
4429                                    Query q = session.createQuery(sql);
4430    
4431                                    QueryPos qPos = QueryPos.getInstance(q);
4432    
4433                                    qPos.add(companyId);
4434    
4435                                    qPos.add(status);
4436    
4437                                    if (!pagination) {
4438                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4439                                                            start, end, false);
4440    
4441                                            Collections.sort(list);
4442    
4443                                            list = Collections.unmodifiableList(list);
4444                                    }
4445                                    else {
4446                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4447                                                            start, end);
4448                                    }
4449    
4450                                    cacheResult(list);
4451    
4452                                    finderCache.putResult(finderPath, finderArgs, list);
4453                            }
4454                            catch (Exception e) {
4455                                    finderCache.removeResult(finderPath, finderArgs);
4456    
4457                                    throw processException(e);
4458                            }
4459                            finally {
4460                                    closeSession(session);
4461                            }
4462                    }
4463    
4464                    return list;
4465            }
4466    
4467            /**
4468             * Returns the first document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4469             *
4470             * @param companyId the company ID
4471             * @param status the status
4472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4473             * @return the first matching document library folder
4474             * @throws NoSuchFolderException if a matching document library folder could not be found
4475             */
4476            @Override
4477            public DLFolder findByC_NotS_First(long companyId, int status,
4478                    OrderByComparator<DLFolder> orderByComparator)
4479                    throws NoSuchFolderException {
4480                    DLFolder dlFolder = fetchByC_NotS_First(companyId, status,
4481                                    orderByComparator);
4482    
4483                    if (dlFolder != null) {
4484                            return dlFolder;
4485                    }
4486    
4487                    StringBundler msg = new StringBundler(6);
4488    
4489                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4490    
4491                    msg.append("companyId=");
4492                    msg.append(companyId);
4493    
4494                    msg.append(", status=");
4495                    msg.append(status);
4496    
4497                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4498    
4499                    throw new NoSuchFolderException(msg.toString());
4500            }
4501    
4502            /**
4503             * Returns the first document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4504             *
4505             * @param companyId the company ID
4506             * @param status the status
4507             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4508             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
4509             */
4510            @Override
4511            public DLFolder fetchByC_NotS_First(long companyId, int status,
4512                    OrderByComparator<DLFolder> orderByComparator) {
4513                    List<DLFolder> list = findByC_NotS(companyId, status, 0, 1,
4514                                    orderByComparator);
4515    
4516                    if (!list.isEmpty()) {
4517                            return list.get(0);
4518                    }
4519    
4520                    return null;
4521            }
4522    
4523            /**
4524             * Returns the last document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4525             *
4526             * @param companyId the company ID
4527             * @param status the status
4528             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4529             * @return the last matching document library folder
4530             * @throws NoSuchFolderException if a matching document library folder could not be found
4531             */
4532            @Override
4533            public DLFolder findByC_NotS_Last(long companyId, int status,
4534                    OrderByComparator<DLFolder> orderByComparator)
4535                    throws NoSuchFolderException {
4536                    DLFolder dlFolder = fetchByC_NotS_Last(companyId, status,
4537                                    orderByComparator);
4538    
4539                    if (dlFolder != null) {
4540                            return dlFolder;
4541                    }
4542    
4543                    StringBundler msg = new StringBundler(6);
4544    
4545                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4546    
4547                    msg.append("companyId=");
4548                    msg.append(companyId);
4549    
4550                    msg.append(", status=");
4551                    msg.append(status);
4552    
4553                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4554    
4555                    throw new NoSuchFolderException(msg.toString());
4556            }
4557    
4558            /**
4559             * Returns the last document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4560             *
4561             * @param companyId the company ID
4562             * @param status the status
4563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4564             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
4565             */
4566            @Override
4567            public DLFolder fetchByC_NotS_Last(long companyId, int status,
4568                    OrderByComparator<DLFolder> orderByComparator) {
4569                    int count = countByC_NotS(companyId, status);
4570    
4571                    if (count == 0) {
4572                            return null;
4573                    }
4574    
4575                    List<DLFolder> list = findByC_NotS(companyId, status, count - 1, count,
4576                                    orderByComparator);
4577    
4578                    if (!list.isEmpty()) {
4579                            return list.get(0);
4580                    }
4581    
4582                    return null;
4583            }
4584    
4585            /**
4586             * Returns the document library folders before and after the current document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4587             *
4588             * @param folderId the primary key of the current document library folder
4589             * @param companyId the company ID
4590             * @param status the status
4591             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4592             * @return the previous, current, and next document library folder
4593             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
4594             */
4595            @Override
4596            public DLFolder[] findByC_NotS_PrevAndNext(long folderId, long companyId,
4597                    int status, OrderByComparator<DLFolder> orderByComparator)
4598                    throws NoSuchFolderException {
4599                    DLFolder dlFolder = findByPrimaryKey(folderId);
4600    
4601                    Session session = null;
4602    
4603                    try {
4604                            session = openSession();
4605    
4606                            DLFolder[] array = new DLFolderImpl[3];
4607    
4608                            array[0] = getByC_NotS_PrevAndNext(session, dlFolder, companyId,
4609                                            status, orderByComparator, true);
4610    
4611                            array[1] = dlFolder;
4612    
4613                            array[2] = getByC_NotS_PrevAndNext(session, dlFolder, companyId,
4614                                            status, orderByComparator, false);
4615    
4616                            return array;
4617                    }
4618                    catch (Exception e) {
4619                            throw processException(e);
4620                    }
4621                    finally {
4622                            closeSession(session);
4623                    }
4624            }
4625    
4626            protected DLFolder getByC_NotS_PrevAndNext(Session session,
4627                    DLFolder dlFolder, long companyId, int status,
4628                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
4629                    StringBundler query = null;
4630    
4631                    if (orderByComparator != null) {
4632                            query = new StringBundler(5 +
4633                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4634                                            (orderByComparator.getOrderByFields().length * 3));
4635                    }
4636                    else {
4637                            query = new StringBundler(4);
4638                    }
4639    
4640                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
4641    
4642                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4643    
4644                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4645    
4646                    if (orderByComparator != null) {
4647                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4648    
4649                            if (orderByConditionFields.length > 0) {
4650                                    query.append(WHERE_AND);
4651                            }
4652    
4653                            for (int i = 0; i < orderByConditionFields.length; i++) {
4654                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4655                                    query.append(orderByConditionFields[i]);
4656    
4657                                    if ((i + 1) < orderByConditionFields.length) {
4658                                            if (orderByComparator.isAscending() ^ previous) {
4659                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4660                                            }
4661                                            else {
4662                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4663                                            }
4664                                    }
4665                                    else {
4666                                            if (orderByComparator.isAscending() ^ previous) {
4667                                                    query.append(WHERE_GREATER_THAN);
4668                                            }
4669                                            else {
4670                                                    query.append(WHERE_LESSER_THAN);
4671                                            }
4672                                    }
4673                            }
4674    
4675                            query.append(ORDER_BY_CLAUSE);
4676    
4677                            String[] orderByFields = orderByComparator.getOrderByFields();
4678    
4679                            for (int i = 0; i < orderByFields.length; i++) {
4680                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4681                                    query.append(orderByFields[i]);
4682    
4683                                    if ((i + 1) < orderByFields.length) {
4684                                            if (orderByComparator.isAscending() ^ previous) {
4685                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4686                                            }
4687                                            else {
4688                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4689                                            }
4690                                    }
4691                                    else {
4692                                            if (orderByComparator.isAscending() ^ previous) {
4693                                                    query.append(ORDER_BY_ASC);
4694                                            }
4695                                            else {
4696                                                    query.append(ORDER_BY_DESC);
4697                                            }
4698                                    }
4699                            }
4700                    }
4701                    else {
4702                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4703                    }
4704    
4705                    String sql = query.toString();
4706    
4707                    Query q = session.createQuery(sql);
4708    
4709                    q.setFirstResult(0);
4710                    q.setMaxResults(2);
4711    
4712                    QueryPos qPos = QueryPos.getInstance(q);
4713    
4714                    qPos.add(companyId);
4715    
4716                    qPos.add(status);
4717    
4718                    if (orderByComparator != null) {
4719                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4720    
4721                            for (Object value : values) {
4722                                    qPos.add(value);
4723                            }
4724                    }
4725    
4726                    List<DLFolder> list = q.list();
4727    
4728                    if (list.size() == 2) {
4729                            return list.get(1);
4730                    }
4731                    else {
4732                            return null;
4733                    }
4734            }
4735    
4736            /**
4737             * Removes all the document library folders where companyId = &#63; and status &ne; &#63; from the database.
4738             *
4739             * @param companyId the company ID
4740             * @param status the status
4741             */
4742            @Override
4743            public void removeByC_NotS(long companyId, int status) {
4744                    for (DLFolder dlFolder : findByC_NotS(companyId, status,
4745                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4746                            remove(dlFolder);
4747                    }
4748            }
4749    
4750            /**
4751             * Returns the number of document library folders where companyId = &#63; and status &ne; &#63;.
4752             *
4753             * @param companyId the company ID
4754             * @param status the status
4755             * @return the number of matching document library folders
4756             */
4757            @Override
4758            public int countByC_NotS(long companyId, int status) {
4759                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
4760    
4761                    Object[] finderArgs = new Object[] { companyId, status };
4762    
4763                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4764    
4765                    if (count == null) {
4766                            StringBundler query = new StringBundler(3);
4767    
4768                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4769    
4770                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4771    
4772                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4773    
4774                            String sql = query.toString();
4775    
4776                            Session session = null;
4777    
4778                            try {
4779                                    session = openSession();
4780    
4781                                    Query q = session.createQuery(sql);
4782    
4783                                    QueryPos qPos = QueryPos.getInstance(q);
4784    
4785                                    qPos.add(companyId);
4786    
4787                                    qPos.add(status);
4788    
4789                                    count = (Long)q.uniqueResult();
4790    
4791                                    finderCache.putResult(finderPath, finderArgs, count);
4792                            }
4793                            catch (Exception e) {
4794                                    finderCache.removeResult(finderPath, finderArgs);
4795    
4796                                    throw processException(e);
4797                            }
4798                            finally {
4799                                    closeSession(session);
4800                            }
4801                    }
4802    
4803                    return count.intValue();
4804            }
4805    
4806            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "dlFolder.companyId = ? AND ";
4807            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "dlFolder.status != ?";
4808            public static final FinderPath FINDER_PATH_FETCH_BY_R_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4809                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4810                            FINDER_CLASS_NAME_ENTITY, "fetchByR_M",
4811                            new String[] { Long.class.getName(), Boolean.class.getName() },
4812                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
4813                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK);
4814            public static final FinderPath FINDER_PATH_COUNT_BY_R_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4815                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4816                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_M",
4817                            new String[] { Long.class.getName(), Boolean.class.getName() });
4818    
4819            /**
4820             * Returns the document library folder where repositoryId = &#63; and mountPoint = &#63; or throws a {@link NoSuchFolderException} if it could not be found.
4821             *
4822             * @param repositoryId the repository ID
4823             * @param mountPoint the mount point
4824             * @return the matching document library folder
4825             * @throws NoSuchFolderException if a matching document library folder could not be found
4826             */
4827            @Override
4828            public DLFolder findByR_M(long repositoryId, boolean mountPoint)
4829                    throws NoSuchFolderException {
4830                    DLFolder dlFolder = fetchByR_M(repositoryId, mountPoint);
4831    
4832                    if (dlFolder == null) {
4833                            StringBundler msg = new StringBundler(6);
4834    
4835                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4836    
4837                            msg.append("repositoryId=");
4838                            msg.append(repositoryId);
4839    
4840                            msg.append(", mountPoint=");
4841                            msg.append(mountPoint);
4842    
4843                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4844    
4845                            if (_log.isDebugEnabled()) {
4846                                    _log.debug(msg.toString());
4847                            }
4848    
4849                            throw new NoSuchFolderException(msg.toString());
4850                    }
4851    
4852                    return dlFolder;
4853            }
4854    
4855            /**
4856             * Returns the document library folder where repositoryId = &#63; and mountPoint = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4857             *
4858             * @param repositoryId the repository ID
4859             * @param mountPoint the mount point
4860             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4861             */
4862            @Override
4863            public DLFolder fetchByR_M(long repositoryId, boolean mountPoint) {
4864                    return fetchByR_M(repositoryId, mountPoint, true);
4865            }
4866    
4867            /**
4868             * Returns the document library folder where repositoryId = &#63; and mountPoint = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4869             *
4870             * @param repositoryId the repository ID
4871             * @param mountPoint the mount point
4872             * @param retrieveFromCache whether to retrieve from the finder cache
4873             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4874             */
4875            @Override
4876            public DLFolder fetchByR_M(long repositoryId, boolean mountPoint,
4877                    boolean retrieveFromCache) {
4878                    Object[] finderArgs = new Object[] { repositoryId, mountPoint };
4879    
4880                    Object result = null;
4881    
4882                    if (retrieveFromCache) {
4883                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_R_M,
4884                                            finderArgs, this);
4885                    }
4886    
4887                    if (result instanceof DLFolder) {
4888                            DLFolder dlFolder = (DLFolder)result;
4889    
4890                            if ((repositoryId != dlFolder.getRepositoryId()) ||
4891                                            (mountPoint != dlFolder.getMountPoint())) {
4892                                    result = null;
4893                            }
4894                    }
4895    
4896                    if (result == null) {
4897                            StringBundler query = new StringBundler(4);
4898    
4899                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4900    
4901                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
4902    
4903                            query.append(_FINDER_COLUMN_R_M_MOUNTPOINT_2);
4904    
4905                            String sql = query.toString();
4906    
4907                            Session session = null;
4908    
4909                            try {
4910                                    session = openSession();
4911    
4912                                    Query q = session.createQuery(sql);
4913    
4914                                    QueryPos qPos = QueryPos.getInstance(q);
4915    
4916                                    qPos.add(repositoryId);
4917    
4918                                    qPos.add(mountPoint);
4919    
4920                                    List<DLFolder> list = q.list();
4921    
4922                                    if (list.isEmpty()) {
4923                                            finderCache.putResult(FINDER_PATH_FETCH_BY_R_M, finderArgs,
4924                                                    list);
4925                                    }
4926                                    else {
4927                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
4928                                                    _log.warn(
4929                                                            "DLFolderPersistenceImpl.fetchByR_M(long, boolean, boolean) with parameters (" +
4930                                                            StringUtil.merge(finderArgs) +
4931                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
4932                                            }
4933    
4934                                            DLFolder dlFolder = list.get(0);
4935    
4936                                            result = dlFolder;
4937    
4938                                            cacheResult(dlFolder);
4939    
4940                                            if ((dlFolder.getRepositoryId() != repositoryId) ||
4941                                                            (dlFolder.getMountPoint() != mountPoint)) {
4942                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_R_M,
4943                                                            finderArgs, dlFolder);
4944                                            }
4945                                    }
4946                            }
4947                            catch (Exception e) {
4948                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_R_M, finderArgs);
4949    
4950                                    throw processException(e);
4951                            }
4952                            finally {
4953                                    closeSession(session);
4954                            }
4955                    }
4956    
4957                    if (result instanceof List<?>) {
4958                            return null;
4959                    }
4960                    else {
4961                            return (DLFolder)result;
4962                    }
4963            }
4964    
4965            /**
4966             * Removes the document library folder where repositoryId = &#63; and mountPoint = &#63; from the database.
4967             *
4968             * @param repositoryId the repository ID
4969             * @param mountPoint the mount point
4970             * @return the document library folder that was removed
4971             */
4972            @Override
4973            public DLFolder removeByR_M(long repositoryId, boolean mountPoint)
4974                    throws NoSuchFolderException {
4975                    DLFolder dlFolder = findByR_M(repositoryId, mountPoint);
4976    
4977                    return remove(dlFolder);
4978            }
4979    
4980            /**
4981             * Returns the number of document library folders where repositoryId = &#63; and mountPoint = &#63;.
4982             *
4983             * @param repositoryId the repository ID
4984             * @param mountPoint the mount point
4985             * @return the number of matching document library folders
4986             */
4987            @Override
4988            public int countByR_M(long repositoryId, boolean mountPoint) {
4989                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_M;
4990    
4991                    Object[] finderArgs = new Object[] { repositoryId, mountPoint };
4992    
4993                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4994    
4995                    if (count == null) {
4996                            StringBundler query = new StringBundler(3);
4997    
4998                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4999    
5000                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
5001    
5002                            query.append(_FINDER_COLUMN_R_M_MOUNTPOINT_2);
5003    
5004                            String sql = query.toString();
5005    
5006                            Session session = null;
5007    
5008                            try {
5009                                    session = openSession();
5010    
5011                                    Query q = session.createQuery(sql);
5012    
5013                                    QueryPos qPos = QueryPos.getInstance(q);
5014    
5015                                    qPos.add(repositoryId);
5016    
5017                                    qPos.add(mountPoint);
5018    
5019                                    count = (Long)q.uniqueResult();
5020    
5021                                    finderCache.putResult(finderPath, finderArgs, count);
5022                            }
5023                            catch (Exception e) {
5024                                    finderCache.removeResult(finderPath, finderArgs);
5025    
5026                                    throw processException(e);
5027                            }
5028                            finally {
5029                                    closeSession(session);
5030                            }
5031                    }
5032    
5033                    return count.intValue();
5034            }
5035    
5036            private static final String _FINDER_COLUMN_R_M_REPOSITORYID_2 = "dlFolder.repositoryId = ? AND ";
5037            private static final String _FINDER_COLUMN_R_M_MOUNTPOINT_2 = "dlFolder.mountPoint = ?";
5038            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5039                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5040                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_P",
5041                            new String[] {
5042                                    Long.class.getName(), Long.class.getName(),
5043                                    
5044                            Integer.class.getName(), Integer.class.getName(),
5045                                    OrderByComparator.class.getName()
5046                            });
5047            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5048                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5049                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_P",
5050                            new String[] { Long.class.getName(), Long.class.getName() },
5051                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
5052                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
5053                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
5054            public static final FinderPath FINDER_PATH_COUNT_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5055                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
5056                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_P",
5057                            new String[] { Long.class.getName(), Long.class.getName() });
5058    
5059            /**
5060             * Returns all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5061             *
5062             * @param repositoryId the repository ID
5063             * @param parentFolderId the parent folder ID
5064             * @return the matching document library folders
5065             */
5066            @Override
5067            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId) {
5068                    return findByR_P(repositoryId, parentFolderId, QueryUtil.ALL_POS,
5069                            QueryUtil.ALL_POS, null);
5070            }
5071    
5072            /**
5073             * Returns a range of all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5074             *
5075             * <p>
5076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5077             * </p>
5078             *
5079             * @param repositoryId the repository ID
5080             * @param parentFolderId the parent folder ID
5081             * @param start the lower bound of the range of document library folders
5082             * @param end the upper bound of the range of document library folders (not inclusive)
5083             * @return the range of matching document library folders
5084             */
5085            @Override
5086            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId,
5087                    int start, int end) {
5088                    return findByR_P(repositoryId, parentFolderId, start, end, null);
5089            }
5090    
5091            /**
5092             * Returns an ordered range of all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5093             *
5094             * <p>
5095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5096             * </p>
5097             *
5098             * @param repositoryId the repository ID
5099             * @param parentFolderId the parent folder ID
5100             * @param start the lower bound of the range of document library folders
5101             * @param end the upper bound of the range of document library folders (not inclusive)
5102             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5103             * @return the ordered range of matching document library folders
5104             */
5105            @Override
5106            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId,
5107                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
5108                    return findByR_P(repositoryId, parentFolderId, start, end,
5109                            orderByComparator, true);
5110            }
5111    
5112            /**
5113             * Returns an ordered range of all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5114             *
5115             * <p>
5116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5117             * </p>
5118             *
5119             * @param repositoryId the repository ID
5120             * @param parentFolderId the parent folder ID
5121             * @param start the lower bound of the range of document library folders
5122             * @param end the upper bound of the range of document library folders (not inclusive)
5123             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5124             * @param retrieveFromCache whether to retrieve from the finder cache
5125             * @return the ordered range of matching document library folders
5126             */
5127            @Override
5128            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId,
5129                    int start, int end, OrderByComparator<DLFolder> orderByComparator,
5130                    boolean retrieveFromCache) {
5131                    boolean pagination = true;
5132                    FinderPath finderPath = null;
5133                    Object[] finderArgs = null;
5134    
5135                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5136                                    (orderByComparator == null)) {
5137                            pagination = false;
5138                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P;
5139                            finderArgs = new Object[] { repositoryId, parentFolderId };
5140                    }
5141                    else {
5142                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_P;
5143                            finderArgs = new Object[] {
5144                                            repositoryId, parentFolderId,
5145                                            
5146                                            start, end, orderByComparator
5147                                    };
5148                    }
5149    
5150                    List<DLFolder> list = null;
5151    
5152                    if (retrieveFromCache) {
5153                            list = (List<DLFolder>)finderCache.getResult(finderPath,
5154                                            finderArgs, this);
5155    
5156                            if ((list != null) && !list.isEmpty()) {
5157                                    for (DLFolder dlFolder : list) {
5158                                            if ((repositoryId != dlFolder.getRepositoryId()) ||
5159                                                            (parentFolderId != dlFolder.getParentFolderId())) {
5160                                                    list = null;
5161    
5162                                                    break;
5163                                            }
5164                                    }
5165                            }
5166                    }
5167    
5168                    if (list == null) {
5169                            StringBundler query = null;
5170    
5171                            if (orderByComparator != null) {
5172                                    query = new StringBundler(4 +
5173                                                    (orderByComparator.getOrderByFields().length * 2));
5174                            }
5175                            else {
5176                                    query = new StringBundler(4);
5177                            }
5178    
5179                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
5180    
5181                            query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
5182    
5183                            query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
5184    
5185                            if (orderByComparator != null) {
5186                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5187                                            orderByComparator);
5188                            }
5189                            else
5190                             if (pagination) {
5191                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5192                            }
5193    
5194                            String sql = query.toString();
5195    
5196                            Session session = null;
5197    
5198                            try {
5199                                    session = openSession();
5200    
5201                                    Query q = session.createQuery(sql);
5202    
5203                                    QueryPos qPos = QueryPos.getInstance(q);
5204    
5205                                    qPos.add(repositoryId);
5206    
5207                                    qPos.add(parentFolderId);
5208    
5209                                    if (!pagination) {
5210                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5211                                                            start, end, false);
5212    
5213                                            Collections.sort(list);
5214    
5215                                            list = Collections.unmodifiableList(list);
5216                                    }
5217                                    else {
5218                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5219                                                            start, end);
5220                                    }
5221    
5222                                    cacheResult(list);
5223    
5224                                    finderCache.putResult(finderPath, finderArgs, list);
5225                            }
5226                            catch (Exception e) {
5227                                    finderCache.removeResult(finderPath, finderArgs);
5228    
5229                                    throw processException(e);
5230                            }
5231                            finally {
5232                                    closeSession(session);
5233                            }
5234                    }
5235    
5236                    return list;
5237            }
5238    
5239            /**
5240             * Returns the first document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5241             *
5242             * @param repositoryId the repository ID
5243             * @param parentFolderId the parent folder ID
5244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5245             * @return the first matching document library folder
5246             * @throws NoSuchFolderException if a matching document library folder could not be found
5247             */
5248            @Override
5249            public DLFolder findByR_P_First(long repositoryId, long parentFolderId,
5250                    OrderByComparator<DLFolder> orderByComparator)
5251                    throws NoSuchFolderException {
5252                    DLFolder dlFolder = fetchByR_P_First(repositoryId, parentFolderId,
5253                                    orderByComparator);
5254    
5255                    if (dlFolder != null) {
5256                            return dlFolder;
5257                    }
5258    
5259                    StringBundler msg = new StringBundler(6);
5260    
5261                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5262    
5263                    msg.append("repositoryId=");
5264                    msg.append(repositoryId);
5265    
5266                    msg.append(", parentFolderId=");
5267                    msg.append(parentFolderId);
5268    
5269                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5270    
5271                    throw new NoSuchFolderException(msg.toString());
5272            }
5273    
5274            /**
5275             * Returns the first document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5276             *
5277             * @param repositoryId the repository ID
5278             * @param parentFolderId the parent folder ID
5279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5280             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
5281             */
5282            @Override
5283            public DLFolder fetchByR_P_First(long repositoryId, long parentFolderId,
5284                    OrderByComparator<DLFolder> orderByComparator) {
5285                    List<DLFolder> list = findByR_P(repositoryId, parentFolderId, 0, 1,
5286                                    orderByComparator);
5287    
5288                    if (!list.isEmpty()) {
5289                            return list.get(0);
5290                    }
5291    
5292                    return null;
5293            }
5294    
5295            /**
5296             * Returns the last document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5297             *
5298             * @param repositoryId the repository ID
5299             * @param parentFolderId the parent folder ID
5300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5301             * @return the last matching document library folder
5302             * @throws NoSuchFolderException if a matching document library folder could not be found
5303             */
5304            @Override
5305            public DLFolder findByR_P_Last(long repositoryId, long parentFolderId,
5306                    OrderByComparator<DLFolder> orderByComparator)
5307                    throws NoSuchFolderException {
5308                    DLFolder dlFolder = fetchByR_P_Last(repositoryId, parentFolderId,
5309                                    orderByComparator);
5310    
5311                    if (dlFolder != null) {
5312                            return dlFolder;
5313                    }
5314    
5315                    StringBundler msg = new StringBundler(6);
5316    
5317                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5318    
5319                    msg.append("repositoryId=");
5320                    msg.append(repositoryId);
5321    
5322                    msg.append(", parentFolderId=");
5323                    msg.append(parentFolderId);
5324    
5325                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5326    
5327                    throw new NoSuchFolderException(msg.toString());
5328            }
5329    
5330            /**
5331             * Returns the last document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5332             *
5333             * @param repositoryId the repository ID
5334             * @param parentFolderId the parent folder ID
5335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5336             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
5337             */
5338            @Override
5339            public DLFolder fetchByR_P_Last(long repositoryId, long parentFolderId,
5340                    OrderByComparator<DLFolder> orderByComparator) {
5341                    int count = countByR_P(repositoryId, parentFolderId);
5342    
5343                    if (count == 0) {
5344                            return null;
5345                    }
5346    
5347                    List<DLFolder> list = findByR_P(repositoryId, parentFolderId,
5348                                    count - 1, count, orderByComparator);
5349    
5350                    if (!list.isEmpty()) {
5351                            return list.get(0);
5352                    }
5353    
5354                    return null;
5355            }
5356    
5357            /**
5358             * Returns the document library folders before and after the current document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5359             *
5360             * @param folderId the primary key of the current document library folder
5361             * @param repositoryId the repository ID
5362             * @param parentFolderId the parent folder ID
5363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5364             * @return the previous, current, and next document library folder
5365             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
5366             */
5367            @Override
5368            public DLFolder[] findByR_P_PrevAndNext(long folderId, long repositoryId,
5369                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
5370                    throws NoSuchFolderException {
5371                    DLFolder dlFolder = findByPrimaryKey(folderId);
5372    
5373                    Session session = null;
5374    
5375                    try {
5376                            session = openSession();
5377    
5378                            DLFolder[] array = new DLFolderImpl[3];
5379    
5380                            array[0] = getByR_P_PrevAndNext(session, dlFolder, repositoryId,
5381                                            parentFolderId, orderByComparator, true);
5382    
5383                            array[1] = dlFolder;
5384    
5385                            array[2] = getByR_P_PrevAndNext(session, dlFolder, repositoryId,
5386                                            parentFolderId, orderByComparator, false);
5387    
5388                            return array;
5389                    }
5390                    catch (Exception e) {
5391                            throw processException(e);
5392                    }
5393                    finally {
5394                            closeSession(session);
5395                    }
5396            }
5397    
5398            protected DLFolder getByR_P_PrevAndNext(Session session, DLFolder dlFolder,
5399                    long repositoryId, long parentFolderId,
5400                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
5401                    StringBundler query = null;
5402    
5403                    if (orderByComparator != null) {
5404                            query = new StringBundler(5 +
5405                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5406                                            (orderByComparator.getOrderByFields().length * 3));
5407                    }
5408                    else {
5409                            query = new StringBundler(4);
5410                    }
5411    
5412                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
5413    
5414                    query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
5415    
5416                    query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
5417    
5418                    if (orderByComparator != null) {
5419                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5420    
5421                            if (orderByConditionFields.length > 0) {
5422                                    query.append(WHERE_AND);
5423                            }
5424    
5425                            for (int i = 0; i < orderByConditionFields.length; i++) {
5426                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5427                                    query.append(orderByConditionFields[i]);
5428    
5429                                    if ((i + 1) < orderByConditionFields.length) {
5430                                            if (orderByComparator.isAscending() ^ previous) {
5431                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5432                                            }
5433                                            else {
5434                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5435                                            }
5436                                    }
5437                                    else {
5438                                            if (orderByComparator.isAscending() ^ previous) {
5439                                                    query.append(WHERE_GREATER_THAN);
5440                                            }
5441                                            else {
5442                                                    query.append(WHERE_LESSER_THAN);
5443                                            }
5444                                    }
5445                            }
5446    
5447                            query.append(ORDER_BY_CLAUSE);
5448    
5449                            String[] orderByFields = orderByComparator.getOrderByFields();
5450    
5451                            for (int i = 0; i < orderByFields.length; i++) {
5452                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5453                                    query.append(orderByFields[i]);
5454    
5455                                    if ((i + 1) < orderByFields.length) {
5456                                            if (orderByComparator.isAscending() ^ previous) {
5457                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5458                                            }
5459                                            else {
5460                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5461                                            }
5462                                    }
5463                                    else {
5464                                            if (orderByComparator.isAscending() ^ previous) {
5465                                                    query.append(ORDER_BY_ASC);
5466                                            }
5467                                            else {
5468                                                    query.append(ORDER_BY_DESC);
5469                                            }
5470                                    }
5471                            }
5472                    }
5473                    else {
5474                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5475                    }
5476    
5477                    String sql = query.toString();
5478    
5479                    Query q = session.createQuery(sql);
5480    
5481                    q.setFirstResult(0);
5482                    q.setMaxResults(2);
5483    
5484                    QueryPos qPos = QueryPos.getInstance(q);
5485    
5486                    qPos.add(repositoryId);
5487    
5488                    qPos.add(parentFolderId);
5489    
5490                    if (orderByComparator != null) {
5491                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
5492    
5493                            for (Object value : values) {
5494                                    qPos.add(value);
5495                            }
5496                    }
5497    
5498                    List<DLFolder> list = q.list();
5499    
5500                    if (list.size() == 2) {
5501                            return list.get(1);
5502                    }
5503                    else {
5504                            return null;
5505                    }
5506            }
5507    
5508            /**
5509             * Removes all the document library folders where repositoryId = &#63; and parentFolderId = &#63; from the database.
5510             *
5511             * @param repositoryId the repository ID
5512             * @param parentFolderId the parent folder ID
5513             */
5514            @Override
5515            public void removeByR_P(long repositoryId, long parentFolderId) {
5516                    for (DLFolder dlFolder : findByR_P(repositoryId, parentFolderId,
5517                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5518                            remove(dlFolder);
5519                    }
5520            }
5521    
5522            /**
5523             * Returns the number of document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5524             *
5525             * @param repositoryId the repository ID
5526             * @param parentFolderId the parent folder ID
5527             * @return the number of matching document library folders
5528             */
5529            @Override
5530            public int countByR_P(long repositoryId, long parentFolderId) {
5531                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_P;
5532    
5533                    Object[] finderArgs = new Object[] { repositoryId, parentFolderId };
5534    
5535                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5536    
5537                    if (count == null) {
5538                            StringBundler query = new StringBundler(3);
5539    
5540                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5541    
5542                            query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
5543    
5544                            query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
5545    
5546                            String sql = query.toString();
5547    
5548                            Session session = null;
5549    
5550                            try {
5551                                    session = openSession();
5552    
5553                                    Query q = session.createQuery(sql);
5554    
5555                                    QueryPos qPos = QueryPos.getInstance(q);
5556    
5557                                    qPos.add(repositoryId);
5558    
5559                                    qPos.add(parentFolderId);
5560    
5561                                    count = (Long)q.uniqueResult();
5562    
5563                                    finderCache.putResult(finderPath, finderArgs, count);
5564                            }
5565                            catch (Exception e) {
5566                                    finderCache.removeResult(finderPath, finderArgs);
5567    
5568                                    throw processException(e);
5569                            }
5570                            finally {
5571                                    closeSession(session);
5572                            }
5573                    }
5574    
5575                    return count.intValue();
5576            }
5577    
5578            private static final String _FINDER_COLUMN_R_P_REPOSITORYID_2 = "dlFolder.repositoryId = ? AND ";
5579            private static final String _FINDER_COLUMN_R_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
5580            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5581                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5582                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_N",
5583                            new String[] {
5584                                    Long.class.getName(), String.class.getName(),
5585                                    
5586                            Integer.class.getName(), Integer.class.getName(),
5587                                    OrderByComparator.class.getName()
5588                            });
5589            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5590                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5591                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_N",
5592                            new String[] { Long.class.getName(), String.class.getName() },
5593                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
5594                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
5595            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5596                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
5597                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
5598                            new String[] { Long.class.getName(), String.class.getName() });
5599    
5600            /**
5601             * Returns all the document library folders where parentFolderId = &#63; and name = &#63;.
5602             *
5603             * @param parentFolderId the parent folder ID
5604             * @param name the name
5605             * @return the matching document library folders
5606             */
5607            @Override
5608            public List<DLFolder> findByP_N(long parentFolderId, String name) {
5609                    return findByP_N(parentFolderId, name, QueryUtil.ALL_POS,
5610                            QueryUtil.ALL_POS, null);
5611            }
5612    
5613            /**
5614             * Returns a range of all the document library folders where parentFolderId = &#63; and name = &#63;.
5615             *
5616             * <p>
5617             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5618             * </p>
5619             *
5620             * @param parentFolderId the parent folder ID
5621             * @param name the name
5622             * @param start the lower bound of the range of document library folders
5623             * @param end the upper bound of the range of document library folders (not inclusive)
5624             * @return the range of matching document library folders
5625             */
5626            @Override
5627            public List<DLFolder> findByP_N(long parentFolderId, String name,
5628                    int start, int end) {
5629                    return findByP_N(parentFolderId, name, start, end, null);
5630            }
5631    
5632            /**
5633             * Returns an ordered range of all the document library folders where parentFolderId = &#63; and name = &#63;.
5634             *
5635             * <p>
5636             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5637             * </p>
5638             *
5639             * @param parentFolderId the parent folder ID
5640             * @param name the name
5641             * @param start the lower bound of the range of document library folders
5642             * @param end the upper bound of the range of document library folders (not inclusive)
5643             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5644             * @return the ordered range of matching document library folders
5645             */
5646            @Override
5647            public List<DLFolder> findByP_N(long parentFolderId, String name,
5648                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
5649                    return findByP_N(parentFolderId, name, start, end, orderByComparator,
5650                            true);
5651            }
5652    
5653            /**
5654             * Returns an ordered range of all the document library folders where parentFolderId = &#63; and name = &#63;.
5655             *
5656             * <p>
5657             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5658             * </p>
5659             *
5660             * @param parentFolderId the parent folder ID
5661             * @param name the name
5662             * @param start the lower bound of the range of document library folders
5663             * @param end the upper bound of the range of document library folders (not inclusive)
5664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5665             * @param retrieveFromCache whether to retrieve from the finder cache
5666             * @return the ordered range of matching document library folders
5667             */
5668            @Override
5669            public List<DLFolder> findByP_N(long parentFolderId, String name,
5670                    int start, int end, OrderByComparator<DLFolder> orderByComparator,
5671                    boolean retrieveFromCache) {
5672                    boolean pagination = true;
5673                    FinderPath finderPath = null;
5674                    Object[] finderArgs = null;
5675    
5676                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5677                                    (orderByComparator == null)) {
5678                            pagination = false;
5679                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
5680                            finderArgs = new Object[] { parentFolderId, name };
5681                    }
5682                    else {
5683                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
5684                            finderArgs = new Object[] {
5685                                            parentFolderId, name,
5686                                            
5687                                            start, end, orderByComparator
5688                                    };
5689                    }
5690    
5691                    List<DLFolder> list = null;
5692    
5693                    if (retrieveFromCache) {
5694                            list = (List<DLFolder>)finderCache.getResult(finderPath,
5695                                            finderArgs, this);
5696    
5697                            if ((list != null) && !list.isEmpty()) {
5698                                    for (DLFolder dlFolder : list) {
5699                                            if ((parentFolderId != dlFolder.getParentFolderId()) ||
5700                                                            !Objects.equals(name, dlFolder.getName())) {
5701                                                    list = null;
5702    
5703                                                    break;
5704                                            }
5705                                    }
5706                            }
5707                    }
5708    
5709                    if (list == null) {
5710                            StringBundler query = null;
5711    
5712                            if (orderByComparator != null) {
5713                                    query = new StringBundler(4 +
5714                                                    (orderByComparator.getOrderByFields().length * 2));
5715                            }
5716                            else {
5717                                    query = new StringBundler(4);
5718                            }
5719    
5720                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
5721    
5722                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5723    
5724                            boolean bindName = false;
5725    
5726                            if (name == null) {
5727                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5728                            }
5729                            else if (name.equals(StringPool.BLANK)) {
5730                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
5731                            }
5732                            else {
5733                                    bindName = true;
5734    
5735                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
5736                            }
5737    
5738                            if (orderByComparator != null) {
5739                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5740                                            orderByComparator);
5741                            }
5742                            else
5743                             if (pagination) {
5744                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5745                            }
5746    
5747                            String sql = query.toString();
5748    
5749                            Session session = null;
5750    
5751                            try {
5752                                    session = openSession();
5753    
5754                                    Query q = session.createQuery(sql);
5755    
5756                                    QueryPos qPos = QueryPos.getInstance(q);
5757    
5758                                    qPos.add(parentFolderId);
5759    
5760                                    if (bindName) {
5761                                            qPos.add(name);
5762                                    }
5763    
5764                                    if (!pagination) {
5765                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5766                                                            start, end, false);
5767    
5768                                            Collections.sort(list);
5769    
5770                                            list = Collections.unmodifiableList(list);
5771                                    }
5772                                    else {
5773                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5774                                                            start, end);
5775                                    }
5776    
5777                                    cacheResult(list);
5778    
5779                                    finderCache.putResult(finderPath, finderArgs, list);
5780                            }
5781                            catch (Exception e) {
5782                                    finderCache.removeResult(finderPath, finderArgs);
5783    
5784                                    throw processException(e);
5785                            }
5786                            finally {
5787                                    closeSession(session);
5788                            }
5789                    }
5790    
5791                    return list;
5792            }
5793    
5794            /**
5795             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5796             *
5797             * @param parentFolderId the parent folder ID
5798             * @param name the name
5799             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5800             * @return the first matching document library folder
5801             * @throws NoSuchFolderException if a matching document library folder could not be found
5802             */
5803            @Override
5804            public DLFolder findByP_N_First(long parentFolderId, String name,
5805                    OrderByComparator<DLFolder> orderByComparator)
5806                    throws NoSuchFolderException {
5807                    DLFolder dlFolder = fetchByP_N_First(parentFolderId, name,
5808                                    orderByComparator);
5809    
5810                    if (dlFolder != null) {
5811                            return dlFolder;
5812                    }
5813    
5814                    StringBundler msg = new StringBundler(6);
5815    
5816                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5817    
5818                    msg.append("parentFolderId=");
5819                    msg.append(parentFolderId);
5820    
5821                    msg.append(", name=");
5822                    msg.append(name);
5823    
5824                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5825    
5826                    throw new NoSuchFolderException(msg.toString());
5827            }
5828    
5829            /**
5830             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5831             *
5832             * @param parentFolderId the parent folder ID
5833             * @param name the name
5834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5835             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
5836             */
5837            @Override
5838            public DLFolder fetchByP_N_First(long parentFolderId, String name,
5839                    OrderByComparator<DLFolder> orderByComparator) {
5840                    List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
5841                                    orderByComparator);
5842    
5843                    if (!list.isEmpty()) {
5844                            return list.get(0);
5845                    }
5846    
5847                    return null;
5848            }
5849    
5850            /**
5851             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5852             *
5853             * @param parentFolderId the parent folder ID
5854             * @param name the name
5855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5856             * @return the last matching document library folder
5857             * @throws NoSuchFolderException if a matching document library folder could not be found
5858             */
5859            @Override
5860            public DLFolder findByP_N_Last(long parentFolderId, String name,
5861                    OrderByComparator<DLFolder> orderByComparator)
5862                    throws NoSuchFolderException {
5863                    DLFolder dlFolder = fetchByP_N_Last(parentFolderId, name,
5864                                    orderByComparator);
5865    
5866                    if (dlFolder != null) {
5867                            return dlFolder;
5868                    }
5869    
5870                    StringBundler msg = new StringBundler(6);
5871    
5872                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5873    
5874                    msg.append("parentFolderId=");
5875                    msg.append(parentFolderId);
5876    
5877                    msg.append(", name=");
5878                    msg.append(name);
5879    
5880                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5881    
5882                    throw new NoSuchFolderException(msg.toString());
5883            }
5884    
5885            /**
5886             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5887             *
5888             * @param parentFolderId the parent folder ID
5889             * @param name the name
5890             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5891             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
5892             */
5893            @Override
5894            public DLFolder fetchByP_N_Last(long parentFolderId, String name,
5895                    OrderByComparator<DLFolder> orderByComparator) {
5896                    int count = countByP_N(parentFolderId, name);
5897    
5898                    if (count == 0) {
5899                            return null;
5900                    }
5901    
5902                    List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
5903                                    orderByComparator);
5904    
5905                    if (!list.isEmpty()) {
5906                            return list.get(0);
5907                    }
5908    
5909                    return null;
5910            }
5911    
5912            /**
5913             * Returns the document library folders before and after the current document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5914             *
5915             * @param folderId the primary key of the current document library folder
5916             * @param parentFolderId the parent folder ID
5917             * @param name the name
5918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5919             * @return the previous, current, and next document library folder
5920             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
5921             */
5922            @Override
5923            public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
5924                    String name, OrderByComparator<DLFolder> orderByComparator)
5925                    throws NoSuchFolderException {
5926                    DLFolder dlFolder = findByPrimaryKey(folderId);
5927    
5928                    Session session = null;
5929    
5930                    try {
5931                            session = openSession();
5932    
5933                            DLFolder[] array = new DLFolderImpl[3];
5934    
5935                            array[0] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
5936                                            name, orderByComparator, true);
5937    
5938                            array[1] = dlFolder;
5939    
5940                            array[2] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
5941                                            name, orderByComparator, false);
5942    
5943                            return array;
5944                    }
5945                    catch (Exception e) {
5946                            throw processException(e);
5947                    }
5948                    finally {
5949                            closeSession(session);
5950                    }
5951            }
5952    
5953            protected DLFolder getByP_N_PrevAndNext(Session session, DLFolder dlFolder,
5954                    long parentFolderId, String name,
5955                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
5956                    StringBundler query = null;
5957    
5958                    if (orderByComparator != null) {
5959                            query = new StringBundler(5 +
5960                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5961                                            (orderByComparator.getOrderByFields().length * 3));
5962                    }
5963                    else {
5964                            query = new StringBundler(4);
5965                    }
5966    
5967                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
5968    
5969                    query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5970    
5971                    boolean bindName = false;
5972    
5973                    if (name == null) {
5974                            query.append(_FINDER_COLUMN_P_N_NAME_1);
5975                    }
5976                    else if (name.equals(StringPool.BLANK)) {
5977                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5978                    }
5979                    else {
5980                            bindName = true;
5981    
5982                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5983                    }
5984    
5985                    if (orderByComparator != null) {
5986                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5987    
5988                            if (orderByConditionFields.length > 0) {
5989                                    query.append(WHERE_AND);
5990                            }
5991    
5992                            for (int i = 0; i < orderByConditionFields.length; i++) {
5993                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5994                                    query.append(orderByConditionFields[i]);
5995    
5996                                    if ((i + 1) < orderByConditionFields.length) {
5997                                            if (orderByComparator.isAscending() ^ previous) {
5998                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5999                                            }
6000                                            else {
6001                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6002                                            }
6003                                    }
6004                                    else {
6005                                            if (orderByComparator.isAscending() ^ previous) {
6006                                                    query.append(WHERE_GREATER_THAN);
6007                                            }
6008                                            else {
6009                                                    query.append(WHERE_LESSER_THAN);
6010                                            }
6011                                    }
6012                            }
6013    
6014                            query.append(ORDER_BY_CLAUSE);
6015    
6016                            String[] orderByFields = orderByComparator.getOrderByFields();
6017    
6018                            for (int i = 0; i < orderByFields.length; i++) {
6019                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6020                                    query.append(orderByFields[i]);
6021    
6022                                    if ((i + 1) < orderByFields.length) {
6023                                            if (orderByComparator.isAscending() ^ previous) {
6024                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6025                                            }
6026                                            else {
6027                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6028                                            }
6029                                    }
6030                                    else {
6031                                            if (orderByComparator.isAscending() ^ previous) {
6032                                                    query.append(ORDER_BY_ASC);
6033                                            }
6034                                            else {
6035                                                    query.append(ORDER_BY_DESC);
6036                                            }
6037                                    }
6038                            }
6039                    }
6040                    else {
6041                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6042                    }
6043    
6044                    String sql = query.toString();
6045    
6046                    Query q = session.createQuery(sql);
6047    
6048                    q.setFirstResult(0);
6049                    q.setMaxResults(2);
6050    
6051                    QueryPos qPos = QueryPos.getInstance(q);
6052    
6053                    qPos.add(parentFolderId);
6054    
6055                    if (bindName) {
6056                            qPos.add(name);
6057                    }
6058    
6059                    if (orderByComparator != null) {
6060                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
6061    
6062                            for (Object value : values) {
6063                                    qPos.add(value);
6064                            }
6065                    }
6066    
6067                    List<DLFolder> list = q.list();
6068    
6069                    if (list.size() == 2) {
6070                            return list.get(1);
6071                    }
6072                    else {
6073                            return null;
6074                    }
6075            }
6076    
6077            /**
6078             * Removes all the document library folders where parentFolderId = &#63; and name = &#63; from the database.
6079             *
6080             * @param parentFolderId the parent folder ID
6081             * @param name the name
6082             */
6083            @Override
6084            public void removeByP_N(long parentFolderId, String name) {
6085                    for (DLFolder dlFolder : findByP_N(parentFolderId, name,
6086                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6087                            remove(dlFolder);
6088                    }
6089            }
6090    
6091            /**
6092             * Returns the number of document library folders where parentFolderId = &#63; and name = &#63;.
6093             *
6094             * @param parentFolderId the parent folder ID
6095             * @param name the name
6096             * @return the number of matching document library folders
6097             */
6098            @Override
6099            public int countByP_N(long parentFolderId, String name) {
6100                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
6101    
6102                    Object[] finderArgs = new Object[] { parentFolderId, name };
6103    
6104                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6105    
6106                    if (count == null) {
6107                            StringBundler query = new StringBundler(3);
6108    
6109                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
6110    
6111                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
6112    
6113                            boolean bindName = false;
6114    
6115                            if (name == null) {
6116                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
6117                            }
6118                            else if (name.equals(StringPool.BLANK)) {
6119                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
6120                            }
6121                            else {
6122                                    bindName = true;
6123    
6124                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
6125                            }
6126    
6127                            String sql = query.toString();
6128    
6129                            Session session = null;
6130    
6131                            try {
6132                                    session = openSession();
6133    
6134                                    Query q = session.createQuery(sql);
6135    
6136                                    QueryPos qPos = QueryPos.getInstance(q);
6137    
6138                                    qPos.add(parentFolderId);
6139    
6140                                    if (bindName) {
6141                                            qPos.add(name);
6142                                    }
6143    
6144                                    count = (Long)q.uniqueResult();
6145    
6146                                    finderCache.putResult(finderPath, finderArgs, count);
6147                            }
6148                            catch (Exception e) {
6149                                    finderCache.removeResult(finderPath, finderArgs);
6150    
6151                                    throw processException(e);
6152                            }
6153                            finally {
6154                                    closeSession(session);
6155                            }
6156                    }
6157    
6158                    return count.intValue();
6159            }
6160    
6161            private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6162            private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
6163            private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
6164            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = '')";
6165            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
6166                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
6167                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P",
6168                            new String[] {
6169                                    Long.class.getName(), Boolean.class.getName(),
6170                                    Long.class.getName(),
6171                                    
6172                            Integer.class.getName(), Integer.class.getName(),
6173                                    OrderByComparator.class.getName()
6174                            });
6175            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
6176                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
6177                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P",
6178                            new String[] {
6179                                    Long.class.getName(), Boolean.class.getName(),
6180                                    Long.class.getName()
6181                            },
6182                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
6183                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
6184                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
6185                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
6186            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
6187                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
6188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P",
6189                            new String[] {
6190                                    Long.class.getName(), Boolean.class.getName(),
6191                                    Long.class.getName()
6192                            });
6193    
6194            /**
6195             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6196             *
6197             * @param groupId the group ID
6198             * @param mountPoint the mount point
6199             * @param parentFolderId the parent folder ID
6200             * @return the matching document library folders
6201             */
6202            @Override
6203            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
6204                    long parentFolderId) {
6205                    return findByG_M_P(groupId, mountPoint, parentFolderId,
6206                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6207            }
6208    
6209            /**
6210             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6211             *
6212             * <p>
6213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6214             * </p>
6215             *
6216             * @param groupId the group ID
6217             * @param mountPoint the mount point
6218             * @param parentFolderId the parent folder ID
6219             * @param start the lower bound of the range of document library folders
6220             * @param end the upper bound of the range of document library folders (not inclusive)
6221             * @return the range of matching document library folders
6222             */
6223            @Override
6224            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
6225                    long parentFolderId, int start, int end) {
6226                    return findByG_M_P(groupId, mountPoint, parentFolderId, start, end, null);
6227            }
6228    
6229            /**
6230             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6231             *
6232             * <p>
6233             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6234             * </p>
6235             *
6236             * @param groupId the group ID
6237             * @param mountPoint the mount point
6238             * @param parentFolderId the parent folder ID
6239             * @param start the lower bound of the range of document library folders
6240             * @param end the upper bound of the range of document library folders (not inclusive)
6241             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6242             * @return the ordered range of matching document library folders
6243             */
6244            @Override
6245            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
6246                    long parentFolderId, int start, int end,
6247                    OrderByComparator<DLFolder> orderByComparator) {
6248                    return findByG_M_P(groupId, mountPoint, parentFolderId, start, end,
6249                            orderByComparator, true);
6250            }
6251    
6252            /**
6253             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6254             *
6255             * <p>
6256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6257             * </p>
6258             *
6259             * @param groupId the group ID
6260             * @param mountPoint the mount point
6261             * @param parentFolderId the parent folder ID
6262             * @param start the lower bound of the range of document library folders
6263             * @param end the upper bound of the range of document library folders (not inclusive)
6264             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6265             * @param retrieveFromCache whether to retrieve from the finder cache
6266             * @return the ordered range of matching document library folders
6267             */
6268            @Override
6269            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
6270                    long parentFolderId, int start, int end,
6271                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
6272                    boolean pagination = true;
6273                    FinderPath finderPath = null;
6274                    Object[] finderArgs = null;
6275    
6276                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6277                                    (orderByComparator == null)) {
6278                            pagination = false;
6279                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P;
6280                            finderArgs = new Object[] { groupId, mountPoint, parentFolderId };
6281                    }
6282                    else {
6283                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P;
6284                            finderArgs = new Object[] {
6285                                            groupId, mountPoint, parentFolderId,
6286                                            
6287                                            start, end, orderByComparator
6288                                    };
6289                    }
6290    
6291                    List<DLFolder> list = null;
6292    
6293                    if (retrieveFromCache) {
6294                            list = (List<DLFolder>)finderCache.getResult(finderPath,
6295                                            finderArgs, this);
6296    
6297                            if ((list != null) && !list.isEmpty()) {
6298                                    for (DLFolder dlFolder : list) {
6299                                            if ((groupId != dlFolder.getGroupId()) ||
6300                                                            (mountPoint != dlFolder.getMountPoint()) ||
6301                                                            (parentFolderId != dlFolder.getParentFolderId())) {
6302                                                    list = null;
6303    
6304                                                    break;
6305                                            }
6306                                    }
6307                            }
6308                    }
6309    
6310                    if (list == null) {
6311                            StringBundler query = null;
6312    
6313                            if (orderByComparator != null) {
6314                                    query = new StringBundler(5 +
6315                                                    (orderByComparator.getOrderByFields().length * 2));
6316                            }
6317                            else {
6318                                    query = new StringBundler(5);
6319                            }
6320    
6321                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
6322    
6323                            query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6324    
6325                            query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6326    
6327                            query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6328    
6329                            if (orderByComparator != null) {
6330                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6331                                            orderByComparator);
6332                            }
6333                            else
6334                             if (pagination) {
6335                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6336                            }
6337    
6338                            String sql = query.toString();
6339    
6340                            Session session = null;
6341    
6342                            try {
6343                                    session = openSession();
6344    
6345                                    Query q = session.createQuery(sql);
6346    
6347                                    QueryPos qPos = QueryPos.getInstance(q);
6348    
6349                                    qPos.add(groupId);
6350    
6351                                    qPos.add(mountPoint);
6352    
6353                                    qPos.add(parentFolderId);
6354    
6355                                    if (!pagination) {
6356                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
6357                                                            start, end, false);
6358    
6359                                            Collections.sort(list);
6360    
6361                                            list = Collections.unmodifiableList(list);
6362                                    }
6363                                    else {
6364                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
6365                                                            start, end);
6366                                    }
6367    
6368                                    cacheResult(list);
6369    
6370                                    finderCache.putResult(finderPath, finderArgs, list);
6371                            }
6372                            catch (Exception e) {
6373                                    finderCache.removeResult(finderPath, finderArgs);
6374    
6375                                    throw processException(e);
6376                            }
6377                            finally {
6378                                    closeSession(session);
6379                            }
6380                    }
6381    
6382                    return list;
6383            }
6384    
6385            /**
6386             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6387             *
6388             * @param groupId the group ID
6389             * @param mountPoint the mount point
6390             * @param parentFolderId the parent folder ID
6391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6392             * @return the first matching document library folder
6393             * @throws NoSuchFolderException if a matching document library folder could not be found
6394             */
6395            @Override
6396            public DLFolder findByG_M_P_First(long groupId, boolean mountPoint,
6397                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
6398                    throws NoSuchFolderException {
6399                    DLFolder dlFolder = fetchByG_M_P_First(groupId, mountPoint,
6400                                    parentFolderId, orderByComparator);
6401    
6402                    if (dlFolder != null) {
6403                            return dlFolder;
6404                    }
6405    
6406                    StringBundler msg = new StringBundler(8);
6407    
6408                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6409    
6410                    msg.append("groupId=");
6411                    msg.append(groupId);
6412    
6413                    msg.append(", mountPoint=");
6414                    msg.append(mountPoint);
6415    
6416                    msg.append(", parentFolderId=");
6417                    msg.append(parentFolderId);
6418    
6419                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6420    
6421                    throw new NoSuchFolderException(msg.toString());
6422            }
6423    
6424            /**
6425             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6426             *
6427             * @param groupId the group ID
6428             * @param mountPoint the mount point
6429             * @param parentFolderId the parent folder ID
6430             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6431             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
6432             */
6433            @Override
6434            public DLFolder fetchByG_M_P_First(long groupId, boolean mountPoint,
6435                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator) {
6436                    List<DLFolder> list = findByG_M_P(groupId, mountPoint, parentFolderId,
6437                                    0, 1, orderByComparator);
6438    
6439                    if (!list.isEmpty()) {
6440                            return list.get(0);
6441                    }
6442    
6443                    return null;
6444            }
6445    
6446            /**
6447             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6448             *
6449             * @param groupId the group ID
6450             * @param mountPoint the mount point
6451             * @param parentFolderId the parent folder ID
6452             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6453             * @return the last matching document library folder
6454             * @throws NoSuchFolderException if a matching document library folder could not be found
6455             */
6456            @Override
6457            public DLFolder findByG_M_P_Last(long groupId, boolean mountPoint,
6458                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
6459                    throws NoSuchFolderException {
6460                    DLFolder dlFolder = fetchByG_M_P_Last(groupId, mountPoint,
6461                                    parentFolderId, orderByComparator);
6462    
6463                    if (dlFolder != null) {
6464                            return dlFolder;
6465                    }
6466    
6467                    StringBundler msg = new StringBundler(8);
6468    
6469                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6470    
6471                    msg.append("groupId=");
6472                    msg.append(groupId);
6473    
6474                    msg.append(", mountPoint=");
6475                    msg.append(mountPoint);
6476    
6477                    msg.append(", parentFolderId=");
6478                    msg.append(parentFolderId);
6479    
6480                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6481    
6482                    throw new NoSuchFolderException(msg.toString());
6483            }
6484    
6485            /**
6486             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6487             *
6488             * @param groupId the group ID
6489             * @param mountPoint the mount point
6490             * @param parentFolderId the parent folder ID
6491             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6492             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
6493             */
6494            @Override
6495            public DLFolder fetchByG_M_P_Last(long groupId, boolean mountPoint,
6496                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator) {
6497                    int count = countByG_M_P(groupId, mountPoint, parentFolderId);
6498    
6499                    if (count == 0) {
6500                            return null;
6501                    }
6502    
6503                    List<DLFolder> list = findByG_M_P(groupId, mountPoint, parentFolderId,
6504                                    count - 1, count, orderByComparator);
6505    
6506                    if (!list.isEmpty()) {
6507                            return list.get(0);
6508                    }
6509    
6510                    return null;
6511            }
6512    
6513            /**
6514             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6515             *
6516             * @param folderId the primary key of the current document library folder
6517             * @param groupId the group ID
6518             * @param mountPoint the mount point
6519             * @param parentFolderId the parent folder ID
6520             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6521             * @return the previous, current, and next document library folder
6522             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
6523             */
6524            @Override
6525            public DLFolder[] findByG_M_P_PrevAndNext(long folderId, long groupId,
6526                    boolean mountPoint, long parentFolderId,
6527                    OrderByComparator<DLFolder> orderByComparator)
6528                    throws NoSuchFolderException {
6529                    DLFolder dlFolder = findByPrimaryKey(folderId);
6530    
6531                    Session session = null;
6532    
6533                    try {
6534                            session = openSession();
6535    
6536                            DLFolder[] array = new DLFolderImpl[3];
6537    
6538                            array[0] = getByG_M_P_PrevAndNext(session, dlFolder, groupId,
6539                                            mountPoint, parentFolderId, orderByComparator, true);
6540    
6541                            array[1] = dlFolder;
6542    
6543                            array[2] = getByG_M_P_PrevAndNext(session, dlFolder, groupId,
6544                                            mountPoint, parentFolderId, orderByComparator, false);
6545    
6546                            return array;
6547                    }
6548                    catch (Exception e) {
6549                            throw processException(e);
6550                    }
6551                    finally {
6552                            closeSession(session);
6553                    }
6554            }
6555    
6556            protected DLFolder getByG_M_P_PrevAndNext(Session session,
6557                    DLFolder dlFolder, long groupId, boolean mountPoint,
6558                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator,
6559                    boolean previous) {
6560                    StringBundler query = null;
6561    
6562                    if (orderByComparator != null) {
6563                            query = new StringBundler(6 +
6564                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6565                                            (orderByComparator.getOrderByFields().length * 3));
6566                    }
6567                    else {
6568                            query = new StringBundler(5);
6569                    }
6570    
6571                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
6572    
6573                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6574    
6575                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6576    
6577                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6578    
6579                    if (orderByComparator != null) {
6580                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6581    
6582                            if (orderByConditionFields.length > 0) {
6583                                    query.append(WHERE_AND);
6584                            }
6585    
6586                            for (int i = 0; i < orderByConditionFields.length; i++) {
6587                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6588                                    query.append(orderByConditionFields[i]);
6589    
6590                                    if ((i + 1) < orderByConditionFields.length) {
6591                                            if (orderByComparator.isAscending() ^ previous) {
6592                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6593                                            }
6594                                            else {
6595                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6596                                            }
6597                                    }
6598                                    else {
6599                                            if (orderByComparator.isAscending() ^ previous) {
6600                                                    query.append(WHERE_GREATER_THAN);
6601                                            }
6602                                            else {
6603                                                    query.append(WHERE_LESSER_THAN);
6604                                            }
6605                                    }
6606                            }
6607    
6608                            query.append(ORDER_BY_CLAUSE);
6609    
6610                            String[] orderByFields = orderByComparator.getOrderByFields();
6611    
6612                            for (int i = 0; i < orderByFields.length; i++) {
6613                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6614                                    query.append(orderByFields[i]);
6615    
6616                                    if ((i + 1) < orderByFields.length) {
6617                                            if (orderByComparator.isAscending() ^ previous) {
6618                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6619                                            }
6620                                            else {
6621                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6622                                            }
6623                                    }
6624                                    else {
6625                                            if (orderByComparator.isAscending() ^ previous) {
6626                                                    query.append(ORDER_BY_ASC);
6627                                            }
6628                                            else {
6629                                                    query.append(ORDER_BY_DESC);
6630                                            }
6631                                    }
6632                            }
6633                    }
6634                    else {
6635                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6636                    }
6637    
6638                    String sql = query.toString();
6639    
6640                    Query q = session.createQuery(sql);
6641    
6642                    q.setFirstResult(0);
6643                    q.setMaxResults(2);
6644    
6645                    QueryPos qPos = QueryPos.getInstance(q);
6646    
6647                    qPos.add(groupId);
6648    
6649                    qPos.add(mountPoint);
6650    
6651                    qPos.add(parentFolderId);
6652    
6653                    if (orderByComparator != null) {
6654                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
6655    
6656                            for (Object value : values) {
6657                                    qPos.add(value);
6658                            }
6659                    }
6660    
6661                    List<DLFolder> list = q.list();
6662    
6663                    if (list.size() == 2) {
6664                            return list.get(1);
6665                    }
6666                    else {
6667                            return null;
6668                    }
6669            }
6670    
6671            /**
6672             * Returns all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6673             *
6674             * @param groupId the group ID
6675             * @param mountPoint the mount point
6676             * @param parentFolderId the parent folder ID
6677             * @return the matching document library folders that the user has permission to view
6678             */
6679            @Override
6680            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6681                    long parentFolderId) {
6682                    return filterFindByG_M_P(groupId, mountPoint, parentFolderId,
6683                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6684            }
6685    
6686            /**
6687             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6688             *
6689             * <p>
6690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6691             * </p>
6692             *
6693             * @param groupId the group ID
6694             * @param mountPoint the mount point
6695             * @param parentFolderId the parent folder ID
6696             * @param start the lower bound of the range of document library folders
6697             * @param end the upper bound of the range of document library folders (not inclusive)
6698             * @return the range of matching document library folders that the user has permission to view
6699             */
6700            @Override
6701            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6702                    long parentFolderId, int start, int end) {
6703                    return filterFindByG_M_P(groupId, mountPoint, parentFolderId, start,
6704                            end, null);
6705            }
6706    
6707            /**
6708             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6709             *
6710             * <p>
6711             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6712             * </p>
6713             *
6714             * @param groupId the group ID
6715             * @param mountPoint the mount point
6716             * @param parentFolderId the parent folder ID
6717             * @param start the lower bound of the range of document library folders
6718             * @param end the upper bound of the range of document library folders (not inclusive)
6719             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6720             * @return the ordered range of matching document library folders that the user has permission to view
6721             */
6722            @Override
6723            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6724                    long parentFolderId, int start, int end,
6725                    OrderByComparator<DLFolder> orderByComparator) {
6726                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6727                            return findByG_M_P(groupId, mountPoint, parentFolderId, start, end,
6728                                    orderByComparator);
6729                    }
6730    
6731                    StringBundler query = null;
6732    
6733                    if (orderByComparator != null) {
6734                            query = new StringBundler(5 +
6735                                            (orderByComparator.getOrderByFields().length * 2));
6736                    }
6737                    else {
6738                            query = new StringBundler(6);
6739                    }
6740    
6741                    if (getDB().isSupportsInlineDistinct()) {
6742                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
6743                    }
6744                    else {
6745                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
6746                    }
6747    
6748                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6749    
6750                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6751    
6752                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6753    
6754                    if (!getDB().isSupportsInlineDistinct()) {
6755                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
6756                    }
6757    
6758                    if (orderByComparator != null) {
6759                            if (getDB().isSupportsInlineDistinct()) {
6760                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6761                                            orderByComparator, true);
6762                            }
6763                            else {
6764                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6765                                            orderByComparator, true);
6766                            }
6767                    }
6768                    else {
6769                            if (getDB().isSupportsInlineDistinct()) {
6770                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6771                            }
6772                            else {
6773                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
6774                            }
6775                    }
6776    
6777                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6778                                    DLFolder.class.getName(),
6779                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6780    
6781                    Session session = null;
6782    
6783                    try {
6784                            session = openSession();
6785    
6786                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6787    
6788                            if (getDB().isSupportsInlineDistinct()) {
6789                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
6790                            }
6791                            else {
6792                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
6793                            }
6794    
6795                            QueryPos qPos = QueryPos.getInstance(q);
6796    
6797                            qPos.add(groupId);
6798    
6799                            qPos.add(mountPoint);
6800    
6801                            qPos.add(parentFolderId);
6802    
6803                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
6804                    }
6805                    catch (Exception e) {
6806                            throw processException(e);
6807                    }
6808                    finally {
6809                            closeSession(session);
6810                    }
6811            }
6812    
6813            /**
6814             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6815             *
6816             * @param folderId the primary key of the current document library folder
6817             * @param groupId the group ID
6818             * @param mountPoint the mount point
6819             * @param parentFolderId the parent folder ID
6820             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6821             * @return the previous, current, and next document library folder
6822             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
6823             */
6824            @Override
6825            public DLFolder[] filterFindByG_M_P_PrevAndNext(long folderId,
6826                    long groupId, boolean mountPoint, long parentFolderId,
6827                    OrderByComparator<DLFolder> orderByComparator)
6828                    throws NoSuchFolderException {
6829                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6830                            return findByG_M_P_PrevAndNext(folderId, groupId, mountPoint,
6831                                    parentFolderId, orderByComparator);
6832                    }
6833    
6834                    DLFolder dlFolder = findByPrimaryKey(folderId);
6835    
6836                    Session session = null;
6837    
6838                    try {
6839                            session = openSession();
6840    
6841                            DLFolder[] array = new DLFolderImpl[3];
6842    
6843                            array[0] = filterGetByG_M_P_PrevAndNext(session, dlFolder, groupId,
6844                                            mountPoint, parentFolderId, orderByComparator, true);
6845    
6846                            array[1] = dlFolder;
6847    
6848                            array[2] = filterGetByG_M_P_PrevAndNext(session, dlFolder, groupId,
6849                                            mountPoint, parentFolderId, orderByComparator, false);
6850    
6851                            return array;
6852                    }
6853                    catch (Exception e) {
6854                            throw processException(e);
6855                    }
6856                    finally {
6857                            closeSession(session);
6858                    }
6859            }
6860    
6861            protected DLFolder filterGetByG_M_P_PrevAndNext(Session session,
6862                    DLFolder dlFolder, long groupId, boolean mountPoint,
6863                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator,
6864                    boolean previous) {
6865                    StringBundler query = null;
6866    
6867                    if (orderByComparator != null) {
6868                            query = new StringBundler(7 +
6869                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6870                                            (orderByComparator.getOrderByFields().length * 3));
6871                    }
6872                    else {
6873                            query = new StringBundler(6);
6874                    }
6875    
6876                    if (getDB().isSupportsInlineDistinct()) {
6877                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
6878                    }
6879                    else {
6880                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
6881                    }
6882    
6883                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6884    
6885                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6886    
6887                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6888    
6889                    if (!getDB().isSupportsInlineDistinct()) {
6890                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
6891                    }
6892    
6893                    if (orderByComparator != null) {
6894                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6895    
6896                            if (orderByConditionFields.length > 0) {
6897                                    query.append(WHERE_AND);
6898                            }
6899    
6900                            for (int i = 0; i < orderByConditionFields.length; i++) {
6901                                    if (getDB().isSupportsInlineDistinct()) {
6902                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6903                                    }
6904                                    else {
6905                                            query.append(_ORDER_BY_ENTITY_TABLE);
6906                                    }
6907    
6908                                    query.append(orderByConditionFields[i]);
6909    
6910                                    if ((i + 1) < orderByConditionFields.length) {
6911                                            if (orderByComparator.isAscending() ^ previous) {
6912                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6913                                            }
6914                                            else {
6915                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6916                                            }
6917                                    }
6918                                    else {
6919                                            if (orderByComparator.isAscending() ^ previous) {
6920                                                    query.append(WHERE_GREATER_THAN);
6921                                            }
6922                                            else {
6923                                                    query.append(WHERE_LESSER_THAN);
6924                                            }
6925                                    }
6926                            }
6927    
6928                            query.append(ORDER_BY_CLAUSE);
6929    
6930                            String[] orderByFields = orderByComparator.getOrderByFields();
6931    
6932                            for (int i = 0; i < orderByFields.length; i++) {
6933                                    if (getDB().isSupportsInlineDistinct()) {
6934                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6935                                    }
6936                                    else {
6937                                            query.append(_ORDER_BY_ENTITY_TABLE);
6938                                    }
6939    
6940                                    query.append(orderByFields[i]);
6941    
6942                                    if ((i + 1) < orderByFields.length) {
6943                                            if (orderByComparator.isAscending() ^ previous) {
6944                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6945                                            }
6946                                            else {
6947                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6948                                            }
6949                                    }
6950                                    else {
6951                                            if (orderByComparator.isAscending() ^ previous) {
6952                                                    query.append(ORDER_BY_ASC);
6953                                            }
6954                                            else {
6955                                                    query.append(ORDER_BY_DESC);
6956                                            }
6957                                    }
6958                            }
6959                    }
6960                    else {
6961                            if (getDB().isSupportsInlineDistinct()) {
6962                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6963                            }
6964                            else {
6965                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
6966                            }
6967                    }
6968    
6969                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6970                                    DLFolder.class.getName(),
6971                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6972    
6973                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
6974    
6975                    q.setFirstResult(0);
6976                    q.setMaxResults(2);
6977    
6978                    if (getDB().isSupportsInlineDistinct()) {
6979                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
6980                    }
6981                    else {
6982                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
6983                    }
6984    
6985                    QueryPos qPos = QueryPos.getInstance(q);
6986    
6987                    qPos.add(groupId);
6988    
6989                    qPos.add(mountPoint);
6990    
6991                    qPos.add(parentFolderId);
6992    
6993                    if (orderByComparator != null) {
6994                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
6995    
6996                            for (Object value : values) {
6997                                    qPos.add(value);
6998                            }
6999                    }
7000    
7001                    List<DLFolder> list = q.list();
7002    
7003                    if (list.size() == 2) {
7004                            return list.get(1);
7005                    }
7006                    else {
7007                            return null;
7008                    }
7009            }
7010    
7011            /**
7012             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; from the database.
7013             *
7014             * @param groupId the group ID
7015             * @param mountPoint the mount point
7016             * @param parentFolderId the parent folder ID
7017             */
7018            @Override
7019            public void removeByG_M_P(long groupId, boolean mountPoint,
7020                    long parentFolderId) {
7021                    for (DLFolder dlFolder : findByG_M_P(groupId, mountPoint,
7022                                    parentFolderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7023                            remove(dlFolder);
7024                    }
7025            }
7026    
7027            /**
7028             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
7029             *
7030             * @param groupId the group ID
7031             * @param mountPoint the mount point
7032             * @param parentFolderId the parent folder ID
7033             * @return the number of matching document library folders
7034             */
7035            @Override
7036            public int countByG_M_P(long groupId, boolean mountPoint,
7037                    long parentFolderId) {
7038                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P;
7039    
7040                    Object[] finderArgs = new Object[] { groupId, mountPoint, parentFolderId };
7041    
7042                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7043    
7044                    if (count == null) {
7045                            StringBundler query = new StringBundler(4);
7046    
7047                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
7048    
7049                            query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
7050    
7051                            query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
7052    
7053                            query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
7054    
7055                            String sql = query.toString();
7056    
7057                            Session session = null;
7058    
7059                            try {
7060                                    session = openSession();
7061    
7062                                    Query q = session.createQuery(sql);
7063    
7064                                    QueryPos qPos = QueryPos.getInstance(q);
7065    
7066                                    qPos.add(groupId);
7067    
7068                                    qPos.add(mountPoint);
7069    
7070                                    qPos.add(parentFolderId);
7071    
7072                                    count = (Long)q.uniqueResult();
7073    
7074                                    finderCache.putResult(finderPath, finderArgs, count);
7075                            }
7076                            catch (Exception e) {
7077                                    finderCache.removeResult(finderPath, finderArgs);
7078    
7079                                    throw processException(e);
7080                            }
7081                            finally {
7082                                    closeSession(session);
7083                            }
7084                    }
7085    
7086                    return count.intValue();
7087            }
7088    
7089            /**
7090             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
7091             *
7092             * @param groupId the group ID
7093             * @param mountPoint the mount point
7094             * @param parentFolderId the parent folder ID
7095             * @return the number of matching document library folders that the user has permission to view
7096             */
7097            @Override
7098            public int filterCountByG_M_P(long groupId, boolean mountPoint,
7099                    long parentFolderId) {
7100                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7101                            return countByG_M_P(groupId, mountPoint, parentFolderId);
7102                    }
7103    
7104                    StringBundler query = new StringBundler(4);
7105    
7106                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
7107    
7108                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
7109    
7110                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
7111    
7112                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
7113    
7114                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7115                                    DLFolder.class.getName(),
7116                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7117    
7118                    Session session = null;
7119    
7120                    try {
7121                            session = openSession();
7122    
7123                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
7124    
7125                            q.addScalar(COUNT_COLUMN_NAME,
7126                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7127    
7128                            QueryPos qPos = QueryPos.getInstance(q);
7129    
7130                            qPos.add(groupId);
7131    
7132                            qPos.add(mountPoint);
7133    
7134                            qPos.add(parentFolderId);
7135    
7136                            Long count = (Long)q.uniqueResult();
7137    
7138                            return count.intValue();
7139                    }
7140                    catch (Exception e) {
7141                            throw processException(e);
7142                    }
7143                    finally {
7144                            closeSession(session);
7145                    }
7146            }
7147    
7148            private static final String _FINDER_COLUMN_G_M_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
7149            private static final String _FINDER_COLUMN_G_M_P_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
7150            private static final String _FINDER_COLUMN_G_M_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
7151            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7152                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7153                            FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
7154                            new String[] {
7155                                    Long.class.getName(), Long.class.getName(),
7156                                    String.class.getName()
7157                            },
7158                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
7159                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
7160                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
7161            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7162                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
7163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
7164                            new String[] {
7165                                    Long.class.getName(), Long.class.getName(),
7166                                    String.class.getName()
7167                            });
7168    
7169            /**
7170             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or throws a {@link NoSuchFolderException} if it could not be found.
7171             *
7172             * @param groupId the group ID
7173             * @param parentFolderId the parent folder ID
7174             * @param name the name
7175             * @return the matching document library folder
7176             * @throws NoSuchFolderException if a matching document library folder could not be found
7177             */
7178            @Override
7179            public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
7180                    throws NoSuchFolderException {
7181                    DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
7182    
7183                    if (dlFolder == null) {
7184                            StringBundler msg = new StringBundler(8);
7185    
7186                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7187    
7188                            msg.append("groupId=");
7189                            msg.append(groupId);
7190    
7191                            msg.append(", parentFolderId=");
7192                            msg.append(parentFolderId);
7193    
7194                            msg.append(", name=");
7195                            msg.append(name);
7196    
7197                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7198    
7199                            if (_log.isDebugEnabled()) {
7200                                    _log.debug(msg.toString());
7201                            }
7202    
7203                            throw new NoSuchFolderException(msg.toString());
7204                    }
7205    
7206                    return dlFolder;
7207            }
7208    
7209            /**
7210             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
7211             *
7212             * @param groupId the group ID
7213             * @param parentFolderId the parent folder ID
7214             * @param name the name
7215             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
7216             */
7217            @Override
7218            public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name) {
7219                    return fetchByG_P_N(groupId, parentFolderId, name, true);
7220            }
7221    
7222            /**
7223             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
7224             *
7225             * @param groupId the group ID
7226             * @param parentFolderId the parent folder ID
7227             * @param name the name
7228             * @param retrieveFromCache whether to retrieve from the finder cache
7229             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
7230             */
7231            @Override
7232            public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
7233                    String name, boolean retrieveFromCache) {
7234                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
7235    
7236                    Object result = null;
7237    
7238                    if (retrieveFromCache) {
7239                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_P_N,
7240                                            finderArgs, this);
7241                    }
7242    
7243                    if (result instanceof DLFolder) {
7244                            DLFolder dlFolder = (DLFolder)result;
7245    
7246                            if ((groupId != dlFolder.getGroupId()) ||
7247                                            (parentFolderId != dlFolder.getParentFolderId()) ||
7248                                            !Objects.equals(name, dlFolder.getName())) {
7249                                    result = null;
7250                            }
7251                    }
7252    
7253                    if (result == null) {
7254                            StringBundler query = new StringBundler(5);
7255    
7256                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
7257    
7258                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7259    
7260                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
7261    
7262                            boolean bindName = false;
7263    
7264                            if (name == null) {
7265                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7266                            }
7267                            else if (name.equals(StringPool.BLANK)) {
7268                                    query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7269                            }
7270                            else {
7271                                    bindName = true;
7272    
7273                                    query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7274                            }
7275    
7276                            String sql = query.toString();
7277    
7278                            Session session = null;
7279    
7280                            try {
7281                                    session = openSession();
7282    
7283                                    Query q = session.createQuery(sql);
7284    
7285                                    QueryPos qPos = QueryPos.getInstance(q);
7286    
7287                                    qPos.add(groupId);
7288    
7289                                    qPos.add(parentFolderId);
7290    
7291                                    if (bindName) {
7292                                            qPos.add(name);
7293                                    }
7294    
7295                                    List<DLFolder> list = q.list();
7296    
7297                                    if (list.isEmpty()) {
7298                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_P_N,
7299                                                    finderArgs, list);
7300                                    }
7301                                    else {
7302                                            DLFolder dlFolder = list.get(0);
7303    
7304                                            result = dlFolder;
7305    
7306                                            cacheResult(dlFolder);
7307    
7308                                            if ((dlFolder.getGroupId() != groupId) ||
7309                                                            (dlFolder.getParentFolderId() != parentFolderId) ||
7310                                                            (dlFolder.getName() == null) ||
7311                                                            !dlFolder.getName().equals(name)) {
7312                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_P_N,
7313                                                            finderArgs, dlFolder);
7314                                            }
7315                                    }
7316                            }
7317                            catch (Exception e) {
7318                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_P_N, finderArgs);
7319    
7320                                    throw processException(e);
7321                            }
7322                            finally {
7323                                    closeSession(session);
7324                            }
7325                    }
7326    
7327                    if (result instanceof List<?>) {
7328                            return null;
7329                    }
7330                    else {
7331                            return (DLFolder)result;
7332                    }
7333            }
7334    
7335            /**
7336             * Removes the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; from the database.
7337             *
7338             * @param groupId the group ID
7339             * @param parentFolderId the parent folder ID
7340             * @param name the name
7341             * @return the document library folder that was removed
7342             */
7343            @Override
7344            public DLFolder removeByG_P_N(long groupId, long parentFolderId, String name)
7345                    throws NoSuchFolderException {
7346                    DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
7347    
7348                    return remove(dlFolder);
7349            }
7350    
7351            /**
7352             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and name = &#63;.
7353             *
7354             * @param groupId the group ID
7355             * @param parentFolderId the parent folder ID
7356             * @param name the name
7357             * @return the number of matching document library folders
7358             */
7359            @Override
7360            public int countByG_P_N(long groupId, long parentFolderId, String name) {
7361                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N;
7362    
7363                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
7364    
7365                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7366    
7367                    if (count == null) {
7368                            StringBundler query = new StringBundler(4);
7369    
7370                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
7371    
7372                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7373    
7374                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
7375    
7376                            boolean bindName = false;
7377    
7378                            if (name == null) {
7379                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7380                            }
7381                            else if (name.equals(StringPool.BLANK)) {
7382                                    query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7383                            }
7384                            else {
7385                                    bindName = true;
7386    
7387                                    query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7388                            }
7389    
7390                            String sql = query.toString();
7391    
7392                            Session session = null;
7393    
7394                            try {
7395                                    session = openSession();
7396    
7397                                    Query q = session.createQuery(sql);
7398    
7399                                    QueryPos qPos = QueryPos.getInstance(q);
7400    
7401                                    qPos.add(groupId);
7402    
7403                                    qPos.add(parentFolderId);
7404    
7405                                    if (bindName) {
7406                                            qPos.add(name);
7407                                    }
7408    
7409                                    count = (Long)q.uniqueResult();
7410    
7411                                    finderCache.putResult(finderPath, finderArgs, count);
7412                            }
7413                            catch (Exception e) {
7414                                    finderCache.removeResult(finderPath, finderArgs);
7415    
7416                                    throw processException(e);
7417                            }
7418                            finally {
7419                                    closeSession(session);
7420                            }
7421                    }
7422    
7423                    return count.intValue();
7424            }
7425    
7426            private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
7427            private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
7428            private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
7429            private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
7430            private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = '')";
7431            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_C_P_NOTS =
7432                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7433                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7434                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByF_C_P_NotS",
7435                            new String[] {
7436                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7437                                    Integer.class.getName(),
7438                                    
7439                            Integer.class.getName(), Integer.class.getName(),
7440                                    OrderByComparator.class.getName()
7441                            });
7442            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_F_C_P_NOTS =
7443                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7444                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
7445                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByF_C_P_NotS",
7446                            new String[] {
7447                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7448                                    Integer.class.getName()
7449                            });
7450    
7451            /**
7452             * Returns all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7453             *
7454             * @param folderId the folder ID
7455             * @param companyId the company ID
7456             * @param parentFolderId the parent folder ID
7457             * @param status the status
7458             * @return the matching document library folders
7459             */
7460            @Override
7461            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7462                    long parentFolderId, int status) {
7463                    return findByF_C_P_NotS(folderId, companyId, parentFolderId, status,
7464                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7465            }
7466    
7467            /**
7468             * Returns a range of all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7469             *
7470             * <p>
7471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7472             * </p>
7473             *
7474             * @param folderId the folder ID
7475             * @param companyId the company ID
7476             * @param parentFolderId the parent folder ID
7477             * @param status the status
7478             * @param start the lower bound of the range of document library folders
7479             * @param end the upper bound of the range of document library folders (not inclusive)
7480             * @return the range of matching document library folders
7481             */
7482            @Override
7483            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7484                    long parentFolderId, int status, int start, int end) {
7485                    return findByF_C_P_NotS(folderId, companyId, parentFolderId, status,
7486                            start, end, null);
7487            }
7488    
7489            /**
7490             * Returns an ordered range of all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7491             *
7492             * <p>
7493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7494             * </p>
7495             *
7496             * @param folderId the folder ID
7497             * @param companyId the company ID
7498             * @param parentFolderId the parent folder ID
7499             * @param status the status
7500             * @param start the lower bound of the range of document library folders
7501             * @param end the upper bound of the range of document library folders (not inclusive)
7502             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7503             * @return the ordered range of matching document library folders
7504             */
7505            @Override
7506            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7507                    long parentFolderId, int status, int start, int end,
7508                    OrderByComparator<DLFolder> orderByComparator) {
7509                    return findByF_C_P_NotS(folderId, companyId, parentFolderId, status,
7510                            start, end, orderByComparator, true);
7511            }
7512    
7513            /**
7514             * Returns an ordered range of all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7515             *
7516             * <p>
7517             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7518             * </p>
7519             *
7520             * @param folderId the folder ID
7521             * @param companyId the company ID
7522             * @param parentFolderId the parent folder ID
7523             * @param status the status
7524             * @param start the lower bound of the range of document library folders
7525             * @param end the upper bound of the range of document library folders (not inclusive)
7526             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7527             * @param retrieveFromCache whether to retrieve from the finder cache
7528             * @return the ordered range of matching document library folders
7529             */
7530            @Override
7531            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7532                    long parentFolderId, int status, int start, int end,
7533                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
7534                    boolean pagination = true;
7535                    FinderPath finderPath = null;
7536                    Object[] finderArgs = null;
7537    
7538                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_C_P_NOTS;
7539                    finderArgs = new Object[] {
7540                                    folderId, companyId, parentFolderId, status,
7541                                    
7542                                    start, end, orderByComparator
7543                            };
7544    
7545                    List<DLFolder> list = null;
7546    
7547                    if (retrieveFromCache) {
7548                            list = (List<DLFolder>)finderCache.getResult(finderPath,
7549                                            finderArgs, this);
7550    
7551                            if ((list != null) && !list.isEmpty()) {
7552                                    for (DLFolder dlFolder : list) {
7553                                            if ((folderId >= dlFolder.getFolderId()) ||
7554                                                            (companyId != dlFolder.getCompanyId()) ||
7555                                                            (parentFolderId != dlFolder.getParentFolderId()) ||
7556                                                            (status == dlFolder.getStatus())) {
7557                                                    list = null;
7558    
7559                                                    break;
7560                                            }
7561                                    }
7562                            }
7563                    }
7564    
7565                    if (list == null) {
7566                            StringBundler query = null;
7567    
7568                            if (orderByComparator != null) {
7569                                    query = new StringBundler(6 +
7570                                                    (orderByComparator.getOrderByFields().length * 2));
7571                            }
7572                            else {
7573                                    query = new StringBundler(6);
7574                            }
7575    
7576                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
7577    
7578                            query.append(_FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2);
7579    
7580                            query.append(_FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2);
7581    
7582                            query.append(_FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2);
7583    
7584                            query.append(_FINDER_COLUMN_F_C_P_NOTS_STATUS_2);
7585    
7586                            if (orderByComparator != null) {
7587                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7588                                            orderByComparator);
7589                            }
7590                            else
7591                             if (pagination) {
7592                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
7593                            }
7594    
7595                            String sql = query.toString();
7596    
7597                            Session session = null;
7598    
7599                            try {
7600                                    session = openSession();
7601    
7602                                    Query q = session.createQuery(sql);
7603    
7604                                    QueryPos qPos = QueryPos.getInstance(q);
7605    
7606                                    qPos.add(folderId);
7607    
7608                                    qPos.add(companyId);
7609    
7610                                    qPos.add(parentFolderId);
7611    
7612                                    qPos.add(status);
7613    
7614                                    if (!pagination) {
7615                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7616                                                            start, end, false);
7617    
7618                                            Collections.sort(list);
7619    
7620                                            list = Collections.unmodifiableList(list);
7621                                    }
7622                                    else {
7623                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7624                                                            start, end);
7625                                    }
7626    
7627                                    cacheResult(list);
7628    
7629                                    finderCache.putResult(finderPath, finderArgs, list);
7630                            }
7631                            catch (Exception e) {
7632                                    finderCache.removeResult(finderPath, finderArgs);
7633    
7634                                    throw processException(e);
7635                            }
7636                            finally {
7637                                    closeSession(session);
7638                            }
7639                    }
7640    
7641                    return list;
7642            }
7643    
7644            /**
7645             * Returns the first document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7646             *
7647             * @param folderId the folder ID
7648             * @param companyId the company ID
7649             * @param parentFolderId the parent folder ID
7650             * @param status the status
7651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7652             * @return the first matching document library folder
7653             * @throws NoSuchFolderException if a matching document library folder could not be found
7654             */
7655            @Override
7656            public DLFolder findByF_C_P_NotS_First(long folderId, long companyId,
7657                    long parentFolderId, int status,
7658                    OrderByComparator<DLFolder> orderByComparator)
7659                    throws NoSuchFolderException {
7660                    DLFolder dlFolder = fetchByF_C_P_NotS_First(folderId, companyId,
7661                                    parentFolderId, status, orderByComparator);
7662    
7663                    if (dlFolder != null) {
7664                            return dlFolder;
7665                    }
7666    
7667                    StringBundler msg = new StringBundler(10);
7668    
7669                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7670    
7671                    msg.append("folderId=");
7672                    msg.append(folderId);
7673    
7674                    msg.append(", companyId=");
7675                    msg.append(companyId);
7676    
7677                    msg.append(", parentFolderId=");
7678                    msg.append(parentFolderId);
7679    
7680                    msg.append(", status=");
7681                    msg.append(status);
7682    
7683                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7684    
7685                    throw new NoSuchFolderException(msg.toString());
7686            }
7687    
7688            /**
7689             * Returns the first document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7690             *
7691             * @param folderId the folder ID
7692             * @param companyId the company ID
7693             * @param parentFolderId the parent folder ID
7694             * @param status the status
7695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7696             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
7697             */
7698            @Override
7699            public DLFolder fetchByF_C_P_NotS_First(long folderId, long companyId,
7700                    long parentFolderId, int status,
7701                    OrderByComparator<DLFolder> orderByComparator) {
7702                    List<DLFolder> list = findByF_C_P_NotS(folderId, companyId,
7703                                    parentFolderId, status, 0, 1, orderByComparator);
7704    
7705                    if (!list.isEmpty()) {
7706                            return list.get(0);
7707                    }
7708    
7709                    return null;
7710            }
7711    
7712            /**
7713             * Returns the last document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7714             *
7715             * @param folderId the folder ID
7716             * @param companyId the company ID
7717             * @param parentFolderId the parent folder ID
7718             * @param status the status
7719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7720             * @return the last matching document library folder
7721             * @throws NoSuchFolderException if a matching document library folder could not be found
7722             */
7723            @Override
7724            public DLFolder findByF_C_P_NotS_Last(long folderId, long companyId,
7725                    long parentFolderId, int status,
7726                    OrderByComparator<DLFolder> orderByComparator)
7727                    throws NoSuchFolderException {
7728                    DLFolder dlFolder = fetchByF_C_P_NotS_Last(folderId, companyId,
7729                                    parentFolderId, status, orderByComparator);
7730    
7731                    if (dlFolder != null) {
7732                            return dlFolder;
7733                    }
7734    
7735                    StringBundler msg = new StringBundler(10);
7736    
7737                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7738    
7739                    msg.append("folderId=");
7740                    msg.append(folderId);
7741    
7742                    msg.append(", companyId=");
7743                    msg.append(companyId);
7744    
7745                    msg.append(", parentFolderId=");
7746                    msg.append(parentFolderId);
7747    
7748                    msg.append(", status=");
7749                    msg.append(status);
7750    
7751                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7752    
7753                    throw new NoSuchFolderException(msg.toString());
7754            }
7755    
7756            /**
7757             * Returns the last document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7758             *
7759             * @param folderId the folder ID
7760             * @param companyId the company ID
7761             * @param parentFolderId the parent folder ID
7762             * @param status the status
7763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7764             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
7765             */
7766            @Override
7767            public DLFolder fetchByF_C_P_NotS_Last(long folderId, long companyId,
7768                    long parentFolderId, int status,
7769                    OrderByComparator<DLFolder> orderByComparator) {
7770                    int count = countByF_C_P_NotS(folderId, companyId, parentFolderId,
7771                                    status);
7772    
7773                    if (count == 0) {
7774                            return null;
7775                    }
7776    
7777                    List<DLFolder> list = findByF_C_P_NotS(folderId, companyId,
7778                                    parentFolderId, status, count - 1, count, orderByComparator);
7779    
7780                    if (!list.isEmpty()) {
7781                            return list.get(0);
7782                    }
7783    
7784                    return null;
7785            }
7786    
7787            /**
7788             * Removes all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63; from the database.
7789             *
7790             * @param folderId the folder ID
7791             * @param companyId the company ID
7792             * @param parentFolderId the parent folder ID
7793             * @param status the status
7794             */
7795            @Override
7796            public void removeByF_C_P_NotS(long folderId, long companyId,
7797                    long parentFolderId, int status) {
7798                    for (DLFolder dlFolder : findByF_C_P_NotS(folderId, companyId,
7799                                    parentFolderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7800                                    null)) {
7801                            remove(dlFolder);
7802                    }
7803            }
7804    
7805            /**
7806             * Returns the number of document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7807             *
7808             * @param folderId the folder ID
7809             * @param companyId the company ID
7810             * @param parentFolderId the parent folder ID
7811             * @param status the status
7812             * @return the number of matching document library folders
7813             */
7814            @Override
7815            public int countByF_C_P_NotS(long folderId, long companyId,
7816                    long parentFolderId, int status) {
7817                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_F_C_P_NOTS;
7818    
7819                    Object[] finderArgs = new Object[] {
7820                                    folderId, companyId, parentFolderId, status
7821                            };
7822    
7823                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7824    
7825                    if (count == null) {
7826                            StringBundler query = new StringBundler(5);
7827    
7828                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
7829    
7830                            query.append(_FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2);
7831    
7832                            query.append(_FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2);
7833    
7834                            query.append(_FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2);
7835    
7836                            query.append(_FINDER_COLUMN_F_C_P_NOTS_STATUS_2);
7837    
7838                            String sql = query.toString();
7839    
7840                            Session session = null;
7841    
7842                            try {
7843                                    session = openSession();
7844    
7845                                    Query q = session.createQuery(sql);
7846    
7847                                    QueryPos qPos = QueryPos.getInstance(q);
7848    
7849                                    qPos.add(folderId);
7850    
7851                                    qPos.add(companyId);
7852    
7853                                    qPos.add(parentFolderId);
7854    
7855                                    qPos.add(status);
7856    
7857                                    count = (Long)q.uniqueResult();
7858    
7859                                    finderCache.putResult(finderPath, finderArgs, count);
7860                            }
7861                            catch (Exception e) {
7862                                    finderCache.removeResult(finderPath, finderArgs);
7863    
7864                                    throw processException(e);
7865                            }
7866                            finally {
7867                                    closeSession(session);
7868                            }
7869                    }
7870    
7871                    return count.intValue();
7872            }
7873    
7874            private static final String _FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2 = "dlFolder.folderId > ? AND ";
7875            private static final String _FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2 = "dlFolder.companyId = ? AND ";
7876            private static final String _FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
7877            private static final String _FINDER_COLUMN_F_C_P_NOTS_STATUS_2 = "dlFolder.status != ?";
7878            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7879                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7880                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P_H",
7881                            new String[] {
7882                                    Long.class.getName(), Boolean.class.getName(),
7883                                    Long.class.getName(), Boolean.class.getName(),
7884                                    
7885                            Integer.class.getName(), Integer.class.getName(),
7886                                    OrderByComparator.class.getName()
7887                            });
7888            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H =
7889                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7890                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7891                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P_H",
7892                            new String[] {
7893                                    Long.class.getName(), Boolean.class.getName(),
7894                                    Long.class.getName(), Boolean.class.getName()
7895                            },
7896                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
7897                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
7898                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
7899                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
7900                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
7901            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7902                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
7903                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P_H",
7904                            new String[] {
7905                                    Long.class.getName(), Boolean.class.getName(),
7906                                    Long.class.getName(), Boolean.class.getName()
7907                            });
7908    
7909            /**
7910             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7911             *
7912             * @param groupId the group ID
7913             * @param mountPoint the mount point
7914             * @param parentFolderId the parent folder ID
7915             * @param hidden the hidden
7916             * @return the matching document library folders
7917             */
7918            @Override
7919            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7920                    long parentFolderId, boolean hidden) {
7921                    return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
7922                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7923            }
7924    
7925            /**
7926             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7927             *
7928             * <p>
7929             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7930             * </p>
7931             *
7932             * @param groupId the group ID
7933             * @param mountPoint the mount point
7934             * @param parentFolderId the parent folder ID
7935             * @param hidden the hidden
7936             * @param start the lower bound of the range of document library folders
7937             * @param end the upper bound of the range of document library folders (not inclusive)
7938             * @return the range of matching document library folders
7939             */
7940            @Override
7941            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7942                    long parentFolderId, boolean hidden, int start, int end) {
7943                    return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
7944                            start, end, null);
7945            }
7946    
7947            /**
7948             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7949             *
7950             * <p>
7951             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7952             * </p>
7953             *
7954             * @param groupId the group ID
7955             * @param mountPoint the mount point
7956             * @param parentFolderId the parent folder ID
7957             * @param hidden the hidden
7958             * @param start the lower bound of the range of document library folders
7959             * @param end the upper bound of the range of document library folders (not inclusive)
7960             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7961             * @return the ordered range of matching document library folders
7962             */
7963            @Override
7964            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7965                    long parentFolderId, boolean hidden, int start, int end,
7966                    OrderByComparator<DLFolder> orderByComparator) {
7967                    return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
7968                            start, end, orderByComparator, true);
7969            }
7970    
7971            /**
7972             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7973             *
7974             * <p>
7975             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7976             * </p>
7977             *
7978             * @param groupId the group ID
7979             * @param mountPoint the mount point
7980             * @param parentFolderId the parent folder ID
7981             * @param hidden the hidden
7982             * @param start the lower bound of the range of document library folders
7983             * @param end the upper bound of the range of document library folders (not inclusive)
7984             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7985             * @param retrieveFromCache whether to retrieve from the finder cache
7986             * @return the ordered range of matching document library folders
7987             */
7988            @Override
7989            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7990                    long parentFolderId, boolean hidden, int start, int end,
7991                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
7992                    boolean pagination = true;
7993                    FinderPath finderPath = null;
7994                    Object[] finderArgs = null;
7995    
7996                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7997                                    (orderByComparator == null)) {
7998                            pagination = false;
7999                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H;
8000                            finderArgs = new Object[] {
8001                                            groupId, mountPoint, parentFolderId, hidden
8002                                    };
8003                    }
8004                    else {
8005                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H;
8006                            finderArgs = new Object[] {
8007                                            groupId, mountPoint, parentFolderId, hidden,
8008                                            
8009                                            start, end, orderByComparator
8010                                    };
8011                    }
8012    
8013                    List<DLFolder> list = null;
8014    
8015                    if (retrieveFromCache) {
8016                            list = (List<DLFolder>)finderCache.getResult(finderPath,
8017                                            finderArgs, this);
8018    
8019                            if ((list != null) && !list.isEmpty()) {
8020                                    for (DLFolder dlFolder : list) {
8021                                            if ((groupId != dlFolder.getGroupId()) ||
8022                                                            (mountPoint != dlFolder.getMountPoint()) ||
8023                                                            (parentFolderId != dlFolder.getParentFolderId()) ||
8024                                                            (hidden != dlFolder.getHidden())) {
8025                                                    list = null;
8026    
8027                                                    break;
8028                                            }
8029                                    }
8030                            }
8031                    }
8032    
8033                    if (list == null) {
8034                            StringBundler query = null;
8035    
8036                            if (orderByComparator != null) {
8037                                    query = new StringBundler(6 +
8038                                                    (orderByComparator.getOrderByFields().length * 2));
8039                            }
8040                            else {
8041                                    query = new StringBundler(6);
8042                            }
8043    
8044                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
8045    
8046                            query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8047    
8048                            query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8049    
8050                            query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8051    
8052                            query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
8053    
8054                            if (orderByComparator != null) {
8055                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8056                                            orderByComparator);
8057                            }
8058                            else
8059                             if (pagination) {
8060                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8061                            }
8062    
8063                            String sql = query.toString();
8064    
8065                            Session session = null;
8066    
8067                            try {
8068                                    session = openSession();
8069    
8070                                    Query q = session.createQuery(sql);
8071    
8072                                    QueryPos qPos = QueryPos.getInstance(q);
8073    
8074                                    qPos.add(groupId);
8075    
8076                                    qPos.add(mountPoint);
8077    
8078                                    qPos.add(parentFolderId);
8079    
8080                                    qPos.add(hidden);
8081    
8082                                    if (!pagination) {
8083                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
8084                                                            start, end, false);
8085    
8086                                            Collections.sort(list);
8087    
8088                                            list = Collections.unmodifiableList(list);
8089                                    }
8090                                    else {
8091                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
8092                                                            start, end);
8093                                    }
8094    
8095                                    cacheResult(list);
8096    
8097                                    finderCache.putResult(finderPath, finderArgs, list);
8098                            }
8099                            catch (Exception e) {
8100                                    finderCache.removeResult(finderPath, finderArgs);
8101    
8102                                    throw processException(e);
8103                            }
8104                            finally {
8105                                    closeSession(session);
8106                            }
8107                    }
8108    
8109                    return list;
8110            }
8111    
8112            /**
8113             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8114             *
8115             * @param groupId the group ID
8116             * @param mountPoint the mount point
8117             * @param parentFolderId the parent folder ID
8118             * @param hidden the hidden
8119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8120             * @return the first matching document library folder
8121             * @throws NoSuchFolderException if a matching document library folder could not be found
8122             */
8123            @Override
8124            public DLFolder findByG_M_P_H_First(long groupId, boolean mountPoint,
8125                    long parentFolderId, boolean hidden,
8126                    OrderByComparator<DLFolder> orderByComparator)
8127                    throws NoSuchFolderException {
8128                    DLFolder dlFolder = fetchByG_M_P_H_First(groupId, mountPoint,
8129                                    parentFolderId, hidden, orderByComparator);
8130    
8131                    if (dlFolder != null) {
8132                            return dlFolder;
8133                    }
8134    
8135                    StringBundler msg = new StringBundler(10);
8136    
8137                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8138    
8139                    msg.append("groupId=");
8140                    msg.append(groupId);
8141    
8142                    msg.append(", mountPoint=");
8143                    msg.append(mountPoint);
8144    
8145                    msg.append(", parentFolderId=");
8146                    msg.append(parentFolderId);
8147    
8148                    msg.append(", hidden=");
8149                    msg.append(hidden);
8150    
8151                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8152    
8153                    throw new NoSuchFolderException(msg.toString());
8154            }
8155    
8156            /**
8157             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8158             *
8159             * @param groupId the group ID
8160             * @param mountPoint the mount point
8161             * @param parentFolderId the parent folder ID
8162             * @param hidden the hidden
8163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8164             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
8165             */
8166            @Override
8167            public DLFolder fetchByG_M_P_H_First(long groupId, boolean mountPoint,
8168                    long parentFolderId, boolean hidden,
8169                    OrderByComparator<DLFolder> orderByComparator) {
8170                    List<DLFolder> list = findByG_M_P_H(groupId, mountPoint,
8171                                    parentFolderId, hidden, 0, 1, orderByComparator);
8172    
8173                    if (!list.isEmpty()) {
8174                            return list.get(0);
8175                    }
8176    
8177                    return null;
8178            }
8179    
8180            /**
8181             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8182             *
8183             * @param groupId the group ID
8184             * @param mountPoint the mount point
8185             * @param parentFolderId the parent folder ID
8186             * @param hidden the hidden
8187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8188             * @return the last matching document library folder
8189             * @throws NoSuchFolderException if a matching document library folder could not be found
8190             */
8191            @Override
8192            public DLFolder findByG_M_P_H_Last(long groupId, boolean mountPoint,
8193                    long parentFolderId, boolean hidden,
8194                    OrderByComparator<DLFolder> orderByComparator)
8195                    throws NoSuchFolderException {
8196                    DLFolder dlFolder = fetchByG_M_P_H_Last(groupId, mountPoint,
8197                                    parentFolderId, hidden, orderByComparator);
8198    
8199                    if (dlFolder != null) {
8200                            return dlFolder;
8201                    }
8202    
8203                    StringBundler msg = new StringBundler(10);
8204    
8205                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8206    
8207                    msg.append("groupId=");
8208                    msg.append(groupId);
8209    
8210                    msg.append(", mountPoint=");
8211                    msg.append(mountPoint);
8212    
8213                    msg.append(", parentFolderId=");
8214                    msg.append(parentFolderId);
8215    
8216                    msg.append(", hidden=");
8217                    msg.append(hidden);
8218    
8219                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8220    
8221                    throw new NoSuchFolderException(msg.toString());
8222            }
8223    
8224            /**
8225             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8226             *
8227             * @param groupId the group ID
8228             * @param mountPoint the mount point
8229             * @param parentFolderId the parent folder ID
8230             * @param hidden the hidden
8231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8232             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
8233             */
8234            @Override
8235            public DLFolder fetchByG_M_P_H_Last(long groupId, boolean mountPoint,
8236                    long parentFolderId, boolean hidden,
8237                    OrderByComparator<DLFolder> orderByComparator) {
8238                    int count = countByG_M_P_H(groupId, mountPoint, parentFolderId, hidden);
8239    
8240                    if (count == 0) {
8241                            return null;
8242                    }
8243    
8244                    List<DLFolder> list = findByG_M_P_H(groupId, mountPoint,
8245                                    parentFolderId, hidden, count - 1, count, orderByComparator);
8246    
8247                    if (!list.isEmpty()) {
8248                            return list.get(0);
8249                    }
8250    
8251                    return null;
8252            }
8253    
8254            /**
8255             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8256             *
8257             * @param folderId the primary key of the current document library folder
8258             * @param groupId the group ID
8259             * @param mountPoint the mount point
8260             * @param parentFolderId the parent folder ID
8261             * @param hidden the hidden
8262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8263             * @return the previous, current, and next document library folder
8264             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
8265             */
8266            @Override
8267            public DLFolder[] findByG_M_P_H_PrevAndNext(long folderId, long groupId,
8268                    boolean mountPoint, long parentFolderId, boolean hidden,
8269                    OrderByComparator<DLFolder> orderByComparator)
8270                    throws NoSuchFolderException {
8271                    DLFolder dlFolder = findByPrimaryKey(folderId);
8272    
8273                    Session session = null;
8274    
8275                    try {
8276                            session = openSession();
8277    
8278                            DLFolder[] array = new DLFolderImpl[3];
8279    
8280                            array[0] = getByG_M_P_H_PrevAndNext(session, dlFolder, groupId,
8281                                            mountPoint, parentFolderId, hidden, orderByComparator, true);
8282    
8283                            array[1] = dlFolder;
8284    
8285                            array[2] = getByG_M_P_H_PrevAndNext(session, dlFolder, groupId,
8286                                            mountPoint, parentFolderId, hidden, orderByComparator, false);
8287    
8288                            return array;
8289                    }
8290                    catch (Exception e) {
8291                            throw processException(e);
8292                    }
8293                    finally {
8294                            closeSession(session);
8295                    }
8296            }
8297    
8298            protected DLFolder getByG_M_P_H_PrevAndNext(Session session,
8299                    DLFolder dlFolder, long groupId, boolean mountPoint,
8300                    long parentFolderId, boolean hidden,
8301                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
8302                    StringBundler query = null;
8303    
8304                    if (orderByComparator != null) {
8305                            query = new StringBundler(7 +
8306                                            (orderByComparator.getOrderByConditionFields().length * 3) +
8307                                            (orderByComparator.getOrderByFields().length * 3));
8308                    }
8309                    else {
8310                            query = new StringBundler(6);
8311                    }
8312    
8313                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
8314    
8315                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8316    
8317                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8318    
8319                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8320    
8321                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
8322    
8323                    if (orderByComparator != null) {
8324                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8325    
8326                            if (orderByConditionFields.length > 0) {
8327                                    query.append(WHERE_AND);
8328                            }
8329    
8330                            for (int i = 0; i < orderByConditionFields.length; i++) {
8331                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8332                                    query.append(orderByConditionFields[i]);
8333    
8334                                    if ((i + 1) < orderByConditionFields.length) {
8335                                            if (orderByComparator.isAscending() ^ previous) {
8336                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8337                                            }
8338                                            else {
8339                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8340                                            }
8341                                    }
8342                                    else {
8343                                            if (orderByComparator.isAscending() ^ previous) {
8344                                                    query.append(WHERE_GREATER_THAN);
8345                                            }
8346                                            else {
8347                                                    query.append(WHERE_LESSER_THAN);
8348                                            }
8349                                    }
8350                            }
8351    
8352                            query.append(ORDER_BY_CLAUSE);
8353    
8354                            String[] orderByFields = orderByComparator.getOrderByFields();
8355    
8356                            for (int i = 0; i < orderByFields.length; i++) {
8357                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8358                                    query.append(orderByFields[i]);
8359    
8360                                    if ((i + 1) < orderByFields.length) {
8361                                            if (orderByComparator.isAscending() ^ previous) {
8362                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8363                                            }
8364                                            else {
8365                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8366                                            }
8367                                    }
8368                                    else {
8369                                            if (orderByComparator.isAscending() ^ previous) {
8370                                                    query.append(ORDER_BY_ASC);
8371                                            }
8372                                            else {
8373                                                    query.append(ORDER_BY_DESC);
8374                                            }
8375                                    }
8376                            }
8377                    }
8378                    else {
8379                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8380                    }
8381    
8382                    String sql = query.toString();
8383    
8384                    Query q = session.createQuery(sql);
8385    
8386                    q.setFirstResult(0);
8387                    q.setMaxResults(2);
8388    
8389                    QueryPos qPos = QueryPos.getInstance(q);
8390    
8391                    qPos.add(groupId);
8392    
8393                    qPos.add(mountPoint);
8394    
8395                    qPos.add(parentFolderId);
8396    
8397                    qPos.add(hidden);
8398    
8399                    if (orderByComparator != null) {
8400                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
8401    
8402                            for (Object value : values) {
8403                                    qPos.add(value);
8404                            }
8405                    }
8406    
8407                    List<DLFolder> list = q.list();
8408    
8409                    if (list.size() == 2) {
8410                            return list.get(1);
8411                    }
8412                    else {
8413                            return null;
8414                    }
8415            }
8416    
8417            /**
8418             * Returns all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8419             *
8420             * @param groupId the group ID
8421             * @param mountPoint the mount point
8422             * @param parentFolderId the parent folder ID
8423             * @param hidden the hidden
8424             * @return the matching document library folders that the user has permission to view
8425             */
8426            @Override
8427            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8428                    long parentFolderId, boolean hidden) {
8429                    return filterFindByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8430                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8431            }
8432    
8433            /**
8434             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8435             *
8436             * <p>
8437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8438             * </p>
8439             *
8440             * @param groupId the group ID
8441             * @param mountPoint the mount point
8442             * @param parentFolderId the parent folder ID
8443             * @param hidden the hidden
8444             * @param start the lower bound of the range of document library folders
8445             * @param end the upper bound of the range of document library folders (not inclusive)
8446             * @return the range of matching document library folders that the user has permission to view
8447             */
8448            @Override
8449            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8450                    long parentFolderId, boolean hidden, int start, int end) {
8451                    return filterFindByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8452                            start, end, null);
8453            }
8454    
8455            /**
8456             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8457             *
8458             * <p>
8459             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8460             * </p>
8461             *
8462             * @param groupId the group ID
8463             * @param mountPoint the mount point
8464             * @param parentFolderId the parent folder ID
8465             * @param hidden the hidden
8466             * @param start the lower bound of the range of document library folders
8467             * @param end the upper bound of the range of document library folders (not inclusive)
8468             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8469             * @return the ordered range of matching document library folders that the user has permission to view
8470             */
8471            @Override
8472            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8473                    long parentFolderId, boolean hidden, int start, int end,
8474                    OrderByComparator<DLFolder> orderByComparator) {
8475                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8476                            return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8477                                    start, end, orderByComparator);
8478                    }
8479    
8480                    StringBundler query = null;
8481    
8482                    if (orderByComparator != null) {
8483                            query = new StringBundler(6 +
8484                                            (orderByComparator.getOrderByFields().length * 2));
8485                    }
8486                    else {
8487                            query = new StringBundler(7);
8488                    }
8489    
8490                    if (getDB().isSupportsInlineDistinct()) {
8491                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
8492                    }
8493                    else {
8494                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
8495                    }
8496    
8497                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8498    
8499                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8500    
8501                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8502    
8503                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8504    
8505                    if (!getDB().isSupportsInlineDistinct()) {
8506                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
8507                    }
8508    
8509                    if (orderByComparator != null) {
8510                            if (getDB().isSupportsInlineDistinct()) {
8511                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8512                                            orderByComparator, true);
8513                            }
8514                            else {
8515                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8516                                            orderByComparator, true);
8517                            }
8518                    }
8519                    else {
8520                            if (getDB().isSupportsInlineDistinct()) {
8521                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8522                            }
8523                            else {
8524                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
8525                            }
8526                    }
8527    
8528                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8529                                    DLFolder.class.getName(),
8530                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8531    
8532                    Session session = null;
8533    
8534                    try {
8535                            session = openSession();
8536    
8537                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8538    
8539                            if (getDB().isSupportsInlineDistinct()) {
8540                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
8541                            }
8542                            else {
8543                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
8544                            }
8545    
8546                            QueryPos qPos = QueryPos.getInstance(q);
8547    
8548                            qPos.add(groupId);
8549    
8550                            qPos.add(mountPoint);
8551    
8552                            qPos.add(parentFolderId);
8553    
8554                            qPos.add(hidden);
8555    
8556                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
8557                    }
8558                    catch (Exception e) {
8559                            throw processException(e);
8560                    }
8561                    finally {
8562                            closeSession(session);
8563                    }
8564            }
8565    
8566            /**
8567             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8568             *
8569             * @param folderId the primary key of the current document library folder
8570             * @param groupId the group ID
8571             * @param mountPoint the mount point
8572             * @param parentFolderId the parent folder ID
8573             * @param hidden the hidden
8574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8575             * @return the previous, current, and next document library folder
8576             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
8577             */
8578            @Override
8579            public DLFolder[] filterFindByG_M_P_H_PrevAndNext(long folderId,
8580                    long groupId, boolean mountPoint, long parentFolderId, boolean hidden,
8581                    OrderByComparator<DLFolder> orderByComparator)
8582                    throws NoSuchFolderException {
8583                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8584                            return findByG_M_P_H_PrevAndNext(folderId, groupId, mountPoint,
8585                                    parentFolderId, hidden, orderByComparator);
8586                    }
8587    
8588                    DLFolder dlFolder = findByPrimaryKey(folderId);
8589    
8590                    Session session = null;
8591    
8592                    try {
8593                            session = openSession();
8594    
8595                            DLFolder[] array = new DLFolderImpl[3];
8596    
8597                            array[0] = filterGetByG_M_P_H_PrevAndNext(session, dlFolder,
8598                                            groupId, mountPoint, parentFolderId, hidden,
8599                                            orderByComparator, true);
8600    
8601                            array[1] = dlFolder;
8602    
8603                            array[2] = filterGetByG_M_P_H_PrevAndNext(session, dlFolder,
8604                                            groupId, mountPoint, parentFolderId, hidden,
8605                                            orderByComparator, false);
8606    
8607                            return array;
8608                    }
8609                    catch (Exception e) {
8610                            throw processException(e);
8611                    }
8612                    finally {
8613                            closeSession(session);
8614                    }
8615            }
8616    
8617            protected DLFolder filterGetByG_M_P_H_PrevAndNext(Session session,
8618                    DLFolder dlFolder, long groupId, boolean mountPoint,
8619                    long parentFolderId, boolean hidden,
8620                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
8621                    StringBundler query = null;
8622    
8623                    if (orderByComparator != null) {
8624                            query = new StringBundler(8 +
8625                                            (orderByComparator.getOrderByConditionFields().length * 3) +
8626                                            (orderByComparator.getOrderByFields().length * 3));
8627                    }
8628                    else {
8629                            query = new StringBundler(7);
8630                    }
8631    
8632                    if (getDB().isSupportsInlineDistinct()) {
8633                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
8634                    }
8635                    else {
8636                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
8637                    }
8638    
8639                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8640    
8641                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8642    
8643                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8644    
8645                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8646    
8647                    if (!getDB().isSupportsInlineDistinct()) {
8648                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
8649                    }
8650    
8651                    if (orderByComparator != null) {
8652                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8653    
8654                            if (orderByConditionFields.length > 0) {
8655                                    query.append(WHERE_AND);
8656                            }
8657    
8658                            for (int i = 0; i < orderByConditionFields.length; i++) {
8659                                    if (getDB().isSupportsInlineDistinct()) {
8660                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8661                                    }
8662                                    else {
8663                                            query.append(_ORDER_BY_ENTITY_TABLE);
8664                                    }
8665    
8666                                    query.append(orderByConditionFields[i]);
8667    
8668                                    if ((i + 1) < orderByConditionFields.length) {
8669                                            if (orderByComparator.isAscending() ^ previous) {
8670                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8671                                            }
8672                                            else {
8673                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8674                                            }
8675                                    }
8676                                    else {
8677                                            if (orderByComparator.isAscending() ^ previous) {
8678                                                    query.append(WHERE_GREATER_THAN);
8679                                            }
8680                                            else {
8681                                                    query.append(WHERE_LESSER_THAN);
8682                                            }
8683                                    }
8684                            }
8685    
8686                            query.append(ORDER_BY_CLAUSE);
8687    
8688                            String[] orderByFields = orderByComparator.getOrderByFields();
8689    
8690                            for (int i = 0; i < orderByFields.length; i++) {
8691                                    if (getDB().isSupportsInlineDistinct()) {
8692                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8693                                    }
8694                                    else {
8695                                            query.append(_ORDER_BY_ENTITY_TABLE);
8696                                    }
8697    
8698                                    query.append(orderByFields[i]);
8699    
8700                                    if ((i + 1) < orderByFields.length) {
8701                                            if (orderByComparator.isAscending() ^ previous) {
8702                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8703                                            }
8704                                            else {
8705                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8706                                            }
8707                                    }
8708                                    else {
8709                                            if (orderByComparator.isAscending() ^ previous) {
8710                                                    query.append(ORDER_BY_ASC);
8711                                            }
8712                                            else {
8713                                                    query.append(ORDER_BY_DESC);
8714                                            }
8715                                    }
8716                            }
8717                    }
8718                    else {
8719                            if (getDB().isSupportsInlineDistinct()) {
8720                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8721                            }
8722                            else {
8723                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
8724                            }
8725                    }
8726    
8727                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8728                                    DLFolder.class.getName(),
8729                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8730    
8731                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8732    
8733                    q.setFirstResult(0);
8734                    q.setMaxResults(2);
8735    
8736                    if (getDB().isSupportsInlineDistinct()) {
8737                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
8738                    }
8739                    else {
8740                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
8741                    }
8742    
8743                    QueryPos qPos = QueryPos.getInstance(q);
8744    
8745                    qPos.add(groupId);
8746    
8747                    qPos.add(mountPoint);
8748    
8749                    qPos.add(parentFolderId);
8750    
8751                    qPos.add(hidden);
8752    
8753                    if (orderByComparator != null) {
8754                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
8755    
8756                            for (Object value : values) {
8757                                    qPos.add(value);
8758                            }
8759                    }
8760    
8761                    List<DLFolder> list = q.list();
8762    
8763                    if (list.size() == 2) {
8764                            return list.get(1);
8765                    }
8766                    else {
8767                            return null;
8768                    }
8769            }
8770    
8771            /**
8772             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; from the database.
8773             *
8774             * @param groupId the group ID
8775             * @param mountPoint the mount point
8776             * @param parentFolderId the parent folder ID
8777             * @param hidden the hidden
8778             */
8779            @Override
8780            public void removeByG_M_P_H(long groupId, boolean mountPoint,
8781                    long parentFolderId, boolean hidden) {
8782                    for (DLFolder dlFolder : findByG_M_P_H(groupId, mountPoint,
8783                                    parentFolderId, hidden, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
8784                                    null)) {
8785                            remove(dlFolder);
8786                    }
8787            }
8788    
8789            /**
8790             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8791             *
8792             * @param groupId the group ID
8793             * @param mountPoint the mount point
8794             * @param parentFolderId the parent folder ID
8795             * @param hidden the hidden
8796             * @return the number of matching document library folders
8797             */
8798            @Override
8799            public int countByG_M_P_H(long groupId, boolean mountPoint,
8800                    long parentFolderId, boolean hidden) {
8801                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P_H;
8802    
8803                    Object[] finderArgs = new Object[] {
8804                                    groupId, mountPoint, parentFolderId, hidden
8805                            };
8806    
8807                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8808    
8809                    if (count == null) {
8810                            StringBundler query = new StringBundler(5);
8811    
8812                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
8813    
8814                            query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8815    
8816                            query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8817    
8818                            query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8819    
8820                            query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
8821    
8822                            String sql = query.toString();
8823    
8824                            Session session = null;
8825    
8826                            try {
8827                                    session = openSession();
8828    
8829                                    Query q = session.createQuery(sql);
8830    
8831                                    QueryPos qPos = QueryPos.getInstance(q);
8832    
8833                                    qPos.add(groupId);
8834    
8835                                    qPos.add(mountPoint);
8836    
8837                                    qPos.add(parentFolderId);
8838    
8839                                    qPos.add(hidden);
8840    
8841                                    count = (Long)q.uniqueResult();
8842    
8843                                    finderCache.putResult(finderPath, finderArgs, count);
8844                            }
8845                            catch (Exception e) {
8846                                    finderCache.removeResult(finderPath, finderArgs);
8847    
8848                                    throw processException(e);
8849                            }
8850                            finally {
8851                                    closeSession(session);
8852                            }
8853                    }
8854    
8855                    return count.intValue();
8856            }
8857    
8858            /**
8859             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8860             *
8861             * @param groupId the group ID
8862             * @param mountPoint the mount point
8863             * @param parentFolderId the parent folder ID
8864             * @param hidden the hidden
8865             * @return the number of matching document library folders that the user has permission to view
8866             */
8867            @Override
8868            public int filterCountByG_M_P_H(long groupId, boolean mountPoint,
8869                    long parentFolderId, boolean hidden) {
8870                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8871                            return countByG_M_P_H(groupId, mountPoint, parentFolderId, hidden);
8872                    }
8873    
8874                    StringBundler query = new StringBundler(5);
8875    
8876                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
8877    
8878                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8879    
8880                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8881    
8882                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8883    
8884                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8885    
8886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8887                                    DLFolder.class.getName(),
8888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8889    
8890                    Session session = null;
8891    
8892                    try {
8893                            session = openSession();
8894    
8895                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8896    
8897                            q.addScalar(COUNT_COLUMN_NAME,
8898                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8899    
8900                            QueryPos qPos = QueryPos.getInstance(q);
8901    
8902                            qPos.add(groupId);
8903    
8904                            qPos.add(mountPoint);
8905    
8906                            qPos.add(parentFolderId);
8907    
8908                            qPos.add(hidden);
8909    
8910                            Long count = (Long)q.uniqueResult();
8911    
8912                            return count.intValue();
8913                    }
8914                    catch (Exception e) {
8915                            throw processException(e);
8916                    }
8917                    finally {
8918                            closeSession(session);
8919                    }
8920            }
8921    
8922            private static final String _FINDER_COLUMN_G_M_P_H_GROUPID_2 = "dlFolder.groupId = ? AND ";
8923            private static final String _FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
8924            private static final String _FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
8925            private static final String _FINDER_COLUMN_G_M_P_H_HIDDEN_2 = "dlFolder.hidden = ?";
8926            private static final String _FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL = "dlFolder.hidden_ = ?";
8927            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_T_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
8928                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
8929                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_T_H",
8930                            new String[] {
8931                                    Long.class.getName(), Boolean.class.getName(),
8932                                    String.class.getName(), Boolean.class.getName(),
8933                                    
8934                            Integer.class.getName(), Integer.class.getName(),
8935                                    OrderByComparator.class.getName()
8936                            });
8937            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_M_T_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
8938                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
8939                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_M_T_H",
8940                            new String[] {
8941                                    Long.class.getName(), Boolean.class.getName(),
8942                                    String.class.getName(), Boolean.class.getName()
8943                            });
8944    
8945            /**
8946             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
8947             *
8948             * @param groupId the group ID
8949             * @param mountPoint the mount point
8950             * @param treePath the tree path
8951             * @param hidden the hidden
8952             * @return the matching document library folders
8953             */
8954            @Override
8955            public List<DLFolder> findByG_M_T_H(long groupId, boolean mountPoint,
8956                    String treePath, boolean hidden) {
8957                    return findByG_M_T_H(groupId, mountPoint, treePath, hidden,
8958                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8959            }
8960    
8961            /**
8962             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
8963             *
8964             * <p>
8965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8966             * </p>
8967             *
8968             * @param groupId the group ID
8969             * @param mountPoint the mount point
8970             * @param treePath the tree path
8971             * @param hidden the hidden
8972             * @param start the lower bound of the range of document library folders
8973             * @param end the upper bound of the range of document library folders (not inclusive)
8974             * @return the range of matching document library folders
8975             */
8976            @Override
8977            public List<DLFolder> findByG_M_T_H(long groupId, boolean mountPoint,
8978                    String treePath, boolean hidden, int start, int end) {
8979                    return findByG_M_T_H(groupId, mountPoint, treePath, hidden, start, end,
8980                            null);
8981            }
8982    
8983            /**
8984             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
8985             *
8986             * <p>
8987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8988             * </p>
8989             *
8990             * @param groupId the group ID
8991             * @param mountPoint the mount point
8992             * @param treePath the tree path
8993             * @param hidden the hidden
8994             * @param start the lower bound of the range of document library folders
8995             * @param end the upper bound of the range of document library folders (not inclusive)
8996             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8997             * @return the ordered range of matching document library folders
8998             */
8999            @Override
9000            public List<DLFolder> findByG_M_T_H(long groupId, boolean mountPoint,
9001                    String treePath, boolean hidden, int start, int end,
9002                    OrderByComparator<DLFolder> orderByComparator) {
9003                    return findByG_M_T_H(groupId, mountPoint, treePath, hidden, start, end,
9004                            orderByComparator, true);
9005            }
9006    
9007            /**
9008             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9009             *
9010             * <p>
9011             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9012             * </p>
9013             *
9014             * @param groupId the group ID
9015             * @param mountPoint the mount point
9016             * @param treePath the tree path
9017             * @param hidden the hidden
9018             * @param start the lower bound of the range of document library folders
9019             * @param end the upper bound of the range of document library folders (not inclusive)
9020             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9021             * @param retrieveFromCache whether to retrieve from the finder cache
9022             * @return the ordered range of matching document library folders
9023             */
9024            @Override
9025            public List<DLFolder> findByG_M_T_H(long groupId, boolean mountPoint,
9026                    String treePath, boolean hidden, int start, int end,
9027                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
9028                    boolean pagination = true;
9029                    FinderPath finderPath = null;
9030                    Object[] finderArgs = null;
9031    
9032                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_T_H;
9033                    finderArgs = new Object[] {
9034                                    groupId, mountPoint, treePath, hidden,
9035                                    
9036                                    start, end, orderByComparator
9037                            };
9038    
9039                    List<DLFolder> list = null;
9040    
9041                    if (retrieveFromCache) {
9042                            list = (List<DLFolder>)finderCache.getResult(finderPath,
9043                                            finderArgs, this);
9044    
9045                            if ((list != null) && !list.isEmpty()) {
9046                                    for (DLFolder dlFolder : list) {
9047                                            if ((groupId != dlFolder.getGroupId()) ||
9048                                                            (mountPoint != dlFolder.getMountPoint()) ||
9049                                                            !StringUtil.wildcardMatches(
9050                                                                    dlFolder.getTreePath(), treePath,
9051                                                                    CharPool.UNDERLINE, CharPool.PERCENT,
9052                                                                    CharPool.BACK_SLASH, true) ||
9053                                                            (hidden != dlFolder.getHidden())) {
9054                                                    list = null;
9055    
9056                                                    break;
9057                                            }
9058                                    }
9059                            }
9060                    }
9061    
9062                    if (list == null) {
9063                            StringBundler query = null;
9064    
9065                            if (orderByComparator != null) {
9066                                    query = new StringBundler(6 +
9067                                                    (orderByComparator.getOrderByFields().length * 2));
9068                            }
9069                            else {
9070                                    query = new StringBundler(6);
9071                            }
9072    
9073                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
9074    
9075                            query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9076    
9077                            query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9078    
9079                            boolean bindTreePath = false;
9080    
9081                            if (treePath == null) {
9082                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9083                            }
9084                            else if (treePath.equals(StringPool.BLANK)) {
9085                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9086                            }
9087                            else {
9088                                    bindTreePath = true;
9089    
9090                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9091                            }
9092    
9093                            query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2);
9094    
9095                            if (orderByComparator != null) {
9096                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9097                                            orderByComparator);
9098                            }
9099                            else
9100                             if (pagination) {
9101                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9102                            }
9103    
9104                            String sql = query.toString();
9105    
9106                            Session session = null;
9107    
9108                            try {
9109                                    session = openSession();
9110    
9111                                    Query q = session.createQuery(sql);
9112    
9113                                    QueryPos qPos = QueryPos.getInstance(q);
9114    
9115                                    qPos.add(groupId);
9116    
9117                                    qPos.add(mountPoint);
9118    
9119                                    if (bindTreePath) {
9120                                            qPos.add(treePath);
9121                                    }
9122    
9123                                    qPos.add(hidden);
9124    
9125                                    if (!pagination) {
9126                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
9127                                                            start, end, false);
9128    
9129                                            Collections.sort(list);
9130    
9131                                            list = Collections.unmodifiableList(list);
9132                                    }
9133                                    else {
9134                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
9135                                                            start, end);
9136                                    }
9137    
9138                                    cacheResult(list);
9139    
9140                                    finderCache.putResult(finderPath, finderArgs, list);
9141                            }
9142                            catch (Exception e) {
9143                                    finderCache.removeResult(finderPath, finderArgs);
9144    
9145                                    throw processException(e);
9146                            }
9147                            finally {
9148                                    closeSession(session);
9149                            }
9150                    }
9151    
9152                    return list;
9153            }
9154    
9155            /**
9156             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9157             *
9158             * @param groupId the group ID
9159             * @param mountPoint the mount point
9160             * @param treePath the tree path
9161             * @param hidden the hidden
9162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9163             * @return the first matching document library folder
9164             * @throws NoSuchFolderException if a matching document library folder could not be found
9165             */
9166            @Override
9167            public DLFolder findByG_M_T_H_First(long groupId, boolean mountPoint,
9168                    String treePath, boolean hidden,
9169                    OrderByComparator<DLFolder> orderByComparator)
9170                    throws NoSuchFolderException {
9171                    DLFolder dlFolder = fetchByG_M_T_H_First(groupId, mountPoint, treePath,
9172                                    hidden, orderByComparator);
9173    
9174                    if (dlFolder != null) {
9175                            return dlFolder;
9176                    }
9177    
9178                    StringBundler msg = new StringBundler(10);
9179    
9180                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9181    
9182                    msg.append("groupId=");
9183                    msg.append(groupId);
9184    
9185                    msg.append(", mountPoint=");
9186                    msg.append(mountPoint);
9187    
9188                    msg.append(", treePath=");
9189                    msg.append(treePath);
9190    
9191                    msg.append(", hidden=");
9192                    msg.append(hidden);
9193    
9194                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9195    
9196                    throw new NoSuchFolderException(msg.toString());
9197            }
9198    
9199            /**
9200             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9201             *
9202             * @param groupId the group ID
9203             * @param mountPoint the mount point
9204             * @param treePath the tree path
9205             * @param hidden the hidden
9206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9207             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
9208             */
9209            @Override
9210            public DLFolder fetchByG_M_T_H_First(long groupId, boolean mountPoint,
9211                    String treePath, boolean hidden,
9212                    OrderByComparator<DLFolder> orderByComparator) {
9213                    List<DLFolder> list = findByG_M_T_H(groupId, mountPoint, treePath,
9214                                    hidden, 0, 1, orderByComparator);
9215    
9216                    if (!list.isEmpty()) {
9217                            return list.get(0);
9218                    }
9219    
9220                    return null;
9221            }
9222    
9223            /**
9224             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9225             *
9226             * @param groupId the group ID
9227             * @param mountPoint the mount point
9228             * @param treePath the tree path
9229             * @param hidden the hidden
9230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9231             * @return the last matching document library folder
9232             * @throws NoSuchFolderException if a matching document library folder could not be found
9233             */
9234            @Override
9235            public DLFolder findByG_M_T_H_Last(long groupId, boolean mountPoint,
9236                    String treePath, boolean hidden,
9237                    OrderByComparator<DLFolder> orderByComparator)
9238                    throws NoSuchFolderException {
9239                    DLFolder dlFolder = fetchByG_M_T_H_Last(groupId, mountPoint, treePath,
9240                                    hidden, orderByComparator);
9241    
9242                    if (dlFolder != null) {
9243                            return dlFolder;
9244                    }
9245    
9246                    StringBundler msg = new StringBundler(10);
9247    
9248                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9249    
9250                    msg.append("groupId=");
9251                    msg.append(groupId);
9252    
9253                    msg.append(", mountPoint=");
9254                    msg.append(mountPoint);
9255    
9256                    msg.append(", treePath=");
9257                    msg.append(treePath);
9258    
9259                    msg.append(", hidden=");
9260                    msg.append(hidden);
9261    
9262                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9263    
9264                    throw new NoSuchFolderException(msg.toString());
9265            }
9266    
9267            /**
9268             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9269             *
9270             * @param groupId the group ID
9271             * @param mountPoint the mount point
9272             * @param treePath the tree path
9273             * @param hidden the hidden
9274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9275             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
9276             */
9277            @Override
9278            public DLFolder fetchByG_M_T_H_Last(long groupId, boolean mountPoint,
9279                    String treePath, boolean hidden,
9280                    OrderByComparator<DLFolder> orderByComparator) {
9281                    int count = countByG_M_T_H(groupId, mountPoint, treePath, hidden);
9282    
9283                    if (count == 0) {
9284                            return null;
9285                    }
9286    
9287                    List<DLFolder> list = findByG_M_T_H(groupId, mountPoint, treePath,
9288                                    hidden, count - 1, count, orderByComparator);
9289    
9290                    if (!list.isEmpty()) {
9291                            return list.get(0);
9292                    }
9293    
9294                    return null;
9295            }
9296    
9297            /**
9298             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9299             *
9300             * @param folderId the primary key of the current document library folder
9301             * @param groupId the group ID
9302             * @param mountPoint the mount point
9303             * @param treePath the tree path
9304             * @param hidden the hidden
9305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9306             * @return the previous, current, and next document library folder
9307             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
9308             */
9309            @Override
9310            public DLFolder[] findByG_M_T_H_PrevAndNext(long folderId, long groupId,
9311                    boolean mountPoint, String treePath, boolean hidden,
9312                    OrderByComparator<DLFolder> orderByComparator)
9313                    throws NoSuchFolderException {
9314                    DLFolder dlFolder = findByPrimaryKey(folderId);
9315    
9316                    Session session = null;
9317    
9318                    try {
9319                            session = openSession();
9320    
9321                            DLFolder[] array = new DLFolderImpl[3];
9322    
9323                            array[0] = getByG_M_T_H_PrevAndNext(session, dlFolder, groupId,
9324                                            mountPoint, treePath, hidden, orderByComparator, true);
9325    
9326                            array[1] = dlFolder;
9327    
9328                            array[2] = getByG_M_T_H_PrevAndNext(session, dlFolder, groupId,
9329                                            mountPoint, treePath, hidden, orderByComparator, false);
9330    
9331                            return array;
9332                    }
9333                    catch (Exception e) {
9334                            throw processException(e);
9335                    }
9336                    finally {
9337                            closeSession(session);
9338                    }
9339            }
9340    
9341            protected DLFolder getByG_M_T_H_PrevAndNext(Session session,
9342                    DLFolder dlFolder, long groupId, boolean mountPoint, String treePath,
9343                    boolean hidden, OrderByComparator<DLFolder> orderByComparator,
9344                    boolean previous) {
9345                    StringBundler query = null;
9346    
9347                    if (orderByComparator != null) {
9348                            query = new StringBundler(7 +
9349                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9350                                            (orderByComparator.getOrderByFields().length * 3));
9351                    }
9352                    else {
9353                            query = new StringBundler(6);
9354                    }
9355    
9356                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
9357    
9358                    query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9359    
9360                    query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9361    
9362                    boolean bindTreePath = false;
9363    
9364                    if (treePath == null) {
9365                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9366                    }
9367                    else if (treePath.equals(StringPool.BLANK)) {
9368                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9369                    }
9370                    else {
9371                            bindTreePath = true;
9372    
9373                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9374                    }
9375    
9376                    query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2);
9377    
9378                    if (orderByComparator != null) {
9379                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9380    
9381                            if (orderByConditionFields.length > 0) {
9382                                    query.append(WHERE_AND);
9383                            }
9384    
9385                            for (int i = 0; i < orderByConditionFields.length; i++) {
9386                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9387                                    query.append(orderByConditionFields[i]);
9388    
9389                                    if ((i + 1) < orderByConditionFields.length) {
9390                                            if (orderByComparator.isAscending() ^ previous) {
9391                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9392                                            }
9393                                            else {
9394                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9395                                            }
9396                                    }
9397                                    else {
9398                                            if (orderByComparator.isAscending() ^ previous) {
9399                                                    query.append(WHERE_GREATER_THAN);
9400                                            }
9401                                            else {
9402                                                    query.append(WHERE_LESSER_THAN);
9403                                            }
9404                                    }
9405                            }
9406    
9407                            query.append(ORDER_BY_CLAUSE);
9408    
9409                            String[] orderByFields = orderByComparator.getOrderByFields();
9410    
9411                            for (int i = 0; i < orderByFields.length; i++) {
9412                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9413                                    query.append(orderByFields[i]);
9414    
9415                                    if ((i + 1) < orderByFields.length) {
9416                                            if (orderByComparator.isAscending() ^ previous) {
9417                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9418                                            }
9419                                            else {
9420                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9421                                            }
9422                                    }
9423                                    else {
9424                                            if (orderByComparator.isAscending() ^ previous) {
9425                                                    query.append(ORDER_BY_ASC);
9426                                            }
9427                                            else {
9428                                                    query.append(ORDER_BY_DESC);
9429                                            }
9430                                    }
9431                            }
9432                    }
9433                    else {
9434                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9435                    }
9436    
9437                    String sql = query.toString();
9438    
9439                    Query q = session.createQuery(sql);
9440    
9441                    q.setFirstResult(0);
9442                    q.setMaxResults(2);
9443    
9444                    QueryPos qPos = QueryPos.getInstance(q);
9445    
9446                    qPos.add(groupId);
9447    
9448                    qPos.add(mountPoint);
9449    
9450                    if (bindTreePath) {
9451                            qPos.add(treePath);
9452                    }
9453    
9454                    qPos.add(hidden);
9455    
9456                    if (orderByComparator != null) {
9457                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
9458    
9459                            for (Object value : values) {
9460                                    qPos.add(value);
9461                            }
9462                    }
9463    
9464                    List<DLFolder> list = q.list();
9465    
9466                    if (list.size() == 2) {
9467                            return list.get(1);
9468                    }
9469                    else {
9470                            return null;
9471                    }
9472            }
9473    
9474            /**
9475             * Returns all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9476             *
9477             * @param groupId the group ID
9478             * @param mountPoint the mount point
9479             * @param treePath the tree path
9480             * @param hidden the hidden
9481             * @return the matching document library folders that the user has permission to view
9482             */
9483            @Override
9484            public List<DLFolder> filterFindByG_M_T_H(long groupId, boolean mountPoint,
9485                    String treePath, boolean hidden) {
9486                    return filterFindByG_M_T_H(groupId, mountPoint, treePath, hidden,
9487                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9488            }
9489    
9490            /**
9491             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9492             *
9493             * <p>
9494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9495             * </p>
9496             *
9497             * @param groupId the group ID
9498             * @param mountPoint the mount point
9499             * @param treePath the tree path
9500             * @param hidden the hidden
9501             * @param start the lower bound of the range of document library folders
9502             * @param end the upper bound of the range of document library folders (not inclusive)
9503             * @return the range of matching document library folders that the user has permission to view
9504             */
9505            @Override
9506            public List<DLFolder> filterFindByG_M_T_H(long groupId, boolean mountPoint,
9507                    String treePath, boolean hidden, int start, int end) {
9508                    return filterFindByG_M_T_H(groupId, mountPoint, treePath, hidden,
9509                            start, end, null);
9510            }
9511    
9512            /**
9513             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9514             *
9515             * <p>
9516             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9517             * </p>
9518             *
9519             * @param groupId the group ID
9520             * @param mountPoint the mount point
9521             * @param treePath the tree path
9522             * @param hidden the hidden
9523             * @param start the lower bound of the range of document library folders
9524             * @param end the upper bound of the range of document library folders (not inclusive)
9525             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9526             * @return the ordered range of matching document library folders that the user has permission to view
9527             */
9528            @Override
9529            public List<DLFolder> filterFindByG_M_T_H(long groupId, boolean mountPoint,
9530                    String treePath, boolean hidden, int start, int end,
9531                    OrderByComparator<DLFolder> orderByComparator) {
9532                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9533                            return findByG_M_T_H(groupId, mountPoint, treePath, hidden, start,
9534                                    end, orderByComparator);
9535                    }
9536    
9537                    StringBundler query = null;
9538    
9539                    if (orderByComparator != null) {
9540                            query = new StringBundler(6 +
9541                                            (orderByComparator.getOrderByFields().length * 2));
9542                    }
9543                    else {
9544                            query = new StringBundler(7);
9545                    }
9546    
9547                    if (getDB().isSupportsInlineDistinct()) {
9548                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
9549                    }
9550                    else {
9551                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
9552                    }
9553    
9554                    query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9555    
9556                    query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9557    
9558                    boolean bindTreePath = false;
9559    
9560                    if (treePath == null) {
9561                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9562                    }
9563                    else if (treePath.equals(StringPool.BLANK)) {
9564                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9565                    }
9566                    else {
9567                            bindTreePath = true;
9568    
9569                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9570                    }
9571    
9572                    query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2_SQL);
9573    
9574                    if (!getDB().isSupportsInlineDistinct()) {
9575                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
9576                    }
9577    
9578                    if (orderByComparator != null) {
9579                            if (getDB().isSupportsInlineDistinct()) {
9580                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9581                                            orderByComparator, true);
9582                            }
9583                            else {
9584                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9585                                            orderByComparator, true);
9586                            }
9587                    }
9588                    else {
9589                            if (getDB().isSupportsInlineDistinct()) {
9590                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9591                            }
9592                            else {
9593                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
9594                            }
9595                    }
9596    
9597                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9598                                    DLFolder.class.getName(),
9599                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9600    
9601                    Session session = null;
9602    
9603                    try {
9604                            session = openSession();
9605    
9606                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9607    
9608                            if (getDB().isSupportsInlineDistinct()) {
9609                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
9610                            }
9611                            else {
9612                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
9613                            }
9614    
9615                            QueryPos qPos = QueryPos.getInstance(q);
9616    
9617                            qPos.add(groupId);
9618    
9619                            qPos.add(mountPoint);
9620    
9621                            if (bindTreePath) {
9622                                    qPos.add(treePath);
9623                            }
9624    
9625                            qPos.add(hidden);
9626    
9627                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
9628                    }
9629                    catch (Exception e) {
9630                            throw processException(e);
9631                    }
9632                    finally {
9633                            closeSession(session);
9634                    }
9635            }
9636    
9637            /**
9638             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9639             *
9640             * @param folderId the primary key of the current document library folder
9641             * @param groupId the group ID
9642             * @param mountPoint the mount point
9643             * @param treePath the tree path
9644             * @param hidden the hidden
9645             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9646             * @return the previous, current, and next document library folder
9647             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
9648             */
9649            @Override
9650            public DLFolder[] filterFindByG_M_T_H_PrevAndNext(long folderId,
9651                    long groupId, boolean mountPoint, String treePath, boolean hidden,
9652                    OrderByComparator<DLFolder> orderByComparator)
9653                    throws NoSuchFolderException {
9654                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9655                            return findByG_M_T_H_PrevAndNext(folderId, groupId, mountPoint,
9656                                    treePath, hidden, orderByComparator);
9657                    }
9658    
9659                    DLFolder dlFolder = findByPrimaryKey(folderId);
9660    
9661                    Session session = null;
9662    
9663                    try {
9664                            session = openSession();
9665    
9666                            DLFolder[] array = new DLFolderImpl[3];
9667    
9668                            array[0] = filterGetByG_M_T_H_PrevAndNext(session, dlFolder,
9669                                            groupId, mountPoint, treePath, hidden, orderByComparator,
9670                                            true);
9671    
9672                            array[1] = dlFolder;
9673    
9674                            array[2] = filterGetByG_M_T_H_PrevAndNext(session, dlFolder,
9675                                            groupId, mountPoint, treePath, hidden, orderByComparator,
9676                                            false);
9677    
9678                            return array;
9679                    }
9680                    catch (Exception e) {
9681                            throw processException(e);
9682                    }
9683                    finally {
9684                            closeSession(session);
9685                    }
9686            }
9687    
9688            protected DLFolder filterGetByG_M_T_H_PrevAndNext(Session session,
9689                    DLFolder dlFolder, long groupId, boolean mountPoint, String treePath,
9690                    boolean hidden, OrderByComparator<DLFolder> orderByComparator,
9691                    boolean previous) {
9692                    StringBundler query = null;
9693    
9694                    if (orderByComparator != null) {
9695                            query = new StringBundler(8 +
9696                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9697                                            (orderByComparator.getOrderByFields().length * 3));
9698                    }
9699                    else {
9700                            query = new StringBundler(7);
9701                    }
9702    
9703                    if (getDB().isSupportsInlineDistinct()) {
9704                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
9705                    }
9706                    else {
9707                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
9708                    }
9709    
9710                    query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9711    
9712                    query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9713    
9714                    boolean bindTreePath = false;
9715    
9716                    if (treePath == null) {
9717                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9718                    }
9719                    else if (treePath.equals(StringPool.BLANK)) {
9720                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9721                    }
9722                    else {
9723                            bindTreePath = true;
9724    
9725                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9726                    }
9727    
9728                    query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2_SQL);
9729    
9730                    if (!getDB().isSupportsInlineDistinct()) {
9731                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
9732                    }
9733    
9734                    if (orderByComparator != null) {
9735                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9736    
9737                            if (orderByConditionFields.length > 0) {
9738                                    query.append(WHERE_AND);
9739                            }
9740    
9741                            for (int i = 0; i < orderByConditionFields.length; i++) {
9742                                    if (getDB().isSupportsInlineDistinct()) {
9743                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9744                                    }
9745                                    else {
9746                                            query.append(_ORDER_BY_ENTITY_TABLE);
9747                                    }
9748    
9749                                    query.append(orderByConditionFields[i]);
9750    
9751                                    if ((i + 1) < orderByConditionFields.length) {
9752                                            if (orderByComparator.isAscending() ^ previous) {
9753                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9754                                            }
9755                                            else {
9756                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9757                                            }
9758                                    }
9759                                    else {
9760                                            if (orderByComparator.isAscending() ^ previous) {
9761                                                    query.append(WHERE_GREATER_THAN);
9762                                            }
9763                                            else {
9764                                                    query.append(WHERE_LESSER_THAN);
9765                                            }
9766                                    }
9767                            }
9768    
9769                            query.append(ORDER_BY_CLAUSE);
9770    
9771                            String[] orderByFields = orderByComparator.getOrderByFields();
9772    
9773                            for (int i = 0; i < orderByFields.length; i++) {
9774                                    if (getDB().isSupportsInlineDistinct()) {
9775                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9776                                    }
9777                                    else {
9778                                            query.append(_ORDER_BY_ENTITY_TABLE);
9779                                    }
9780    
9781                                    query.append(orderByFields[i]);
9782    
9783                                    if ((i + 1) < orderByFields.length) {
9784                                            if (orderByComparator.isAscending() ^ previous) {
9785                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9786                                            }
9787                                            else {
9788                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9789                                            }
9790                                    }
9791                                    else {
9792                                            if (orderByComparator.isAscending() ^ previous) {
9793                                                    query.append(ORDER_BY_ASC);
9794                                            }
9795                                            else {
9796                                                    query.append(ORDER_BY_DESC);
9797                                            }
9798                                    }
9799                            }
9800                    }
9801                    else {
9802                            if (getDB().isSupportsInlineDistinct()) {
9803                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9804                            }
9805                            else {
9806                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
9807                            }
9808                    }
9809    
9810                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9811                                    DLFolder.class.getName(),
9812                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9813    
9814                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9815    
9816                    q.setFirstResult(0);
9817                    q.setMaxResults(2);
9818    
9819                    if (getDB().isSupportsInlineDistinct()) {
9820                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
9821                    }
9822                    else {
9823                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
9824                    }
9825    
9826                    QueryPos qPos = QueryPos.getInstance(q);
9827    
9828                    qPos.add(groupId);
9829    
9830                    qPos.add(mountPoint);
9831    
9832                    if (bindTreePath) {
9833                            qPos.add(treePath);
9834                    }
9835    
9836                    qPos.add(hidden);
9837    
9838                    if (orderByComparator != null) {
9839                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
9840    
9841                            for (Object value : values) {
9842                                    qPos.add(value);
9843                            }
9844                    }
9845    
9846                    List<DLFolder> list = q.list();
9847    
9848                    if (list.size() == 2) {
9849                            return list.get(1);
9850                    }
9851                    else {
9852                            return null;
9853                    }
9854            }
9855    
9856            /**
9857             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63; from the database.
9858             *
9859             * @param groupId the group ID
9860             * @param mountPoint the mount point
9861             * @param treePath the tree path
9862             * @param hidden the hidden
9863             */
9864            @Override
9865            public void removeByG_M_T_H(long groupId, boolean mountPoint,
9866                    String treePath, boolean hidden) {
9867                    for (DLFolder dlFolder : findByG_M_T_H(groupId, mountPoint, treePath,
9868                                    hidden, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9869                            remove(dlFolder);
9870                    }
9871            }
9872    
9873            /**
9874             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9875             *
9876             * @param groupId the group ID
9877             * @param mountPoint the mount point
9878             * @param treePath the tree path
9879             * @param hidden the hidden
9880             * @return the number of matching document library folders
9881             */
9882            @Override
9883            public int countByG_M_T_H(long groupId, boolean mountPoint,
9884                    String treePath, boolean hidden) {
9885                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_M_T_H;
9886    
9887                    Object[] finderArgs = new Object[] { groupId, mountPoint, treePath, hidden };
9888    
9889                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9890    
9891                    if (count == null) {
9892                            StringBundler query = new StringBundler(5);
9893    
9894                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
9895    
9896                            query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9897    
9898                            query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9899    
9900                            boolean bindTreePath = false;
9901    
9902                            if (treePath == null) {
9903                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9904                            }
9905                            else if (treePath.equals(StringPool.BLANK)) {
9906                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9907                            }
9908                            else {
9909                                    bindTreePath = true;
9910    
9911                                    query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9912                            }
9913    
9914                            query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2);
9915    
9916                            String sql = query.toString();
9917    
9918                            Session session = null;
9919    
9920                            try {
9921                                    session = openSession();
9922    
9923                                    Query q = session.createQuery(sql);
9924    
9925                                    QueryPos qPos = QueryPos.getInstance(q);
9926    
9927                                    qPos.add(groupId);
9928    
9929                                    qPos.add(mountPoint);
9930    
9931                                    if (bindTreePath) {
9932                                            qPos.add(treePath);
9933                                    }
9934    
9935                                    qPos.add(hidden);
9936    
9937                                    count = (Long)q.uniqueResult();
9938    
9939                                    finderCache.putResult(finderPath, finderArgs, count);
9940                            }
9941                            catch (Exception e) {
9942                                    finderCache.removeResult(finderPath, finderArgs);
9943    
9944                                    throw processException(e);
9945                            }
9946                            finally {
9947                                    closeSession(session);
9948                            }
9949                    }
9950    
9951                    return count.intValue();
9952            }
9953    
9954            /**
9955             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and treePath LIKE &#63; and hidden = &#63;.
9956             *
9957             * @param groupId the group ID
9958             * @param mountPoint the mount point
9959             * @param treePath the tree path
9960             * @param hidden the hidden
9961             * @return the number of matching document library folders that the user has permission to view
9962             */
9963            @Override
9964            public int filterCountByG_M_T_H(long groupId, boolean mountPoint,
9965                    String treePath, boolean hidden) {
9966                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9967                            return countByG_M_T_H(groupId, mountPoint, treePath, hidden);
9968                    }
9969    
9970                    StringBundler query = new StringBundler(5);
9971    
9972                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
9973    
9974                    query.append(_FINDER_COLUMN_G_M_T_H_GROUPID_2);
9975    
9976                    query.append(_FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2);
9977    
9978                    boolean bindTreePath = false;
9979    
9980                    if (treePath == null) {
9981                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_1);
9982                    }
9983                    else if (treePath.equals(StringPool.BLANK)) {
9984                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_3);
9985                    }
9986                    else {
9987                            bindTreePath = true;
9988    
9989                            query.append(_FINDER_COLUMN_G_M_T_H_TREEPATH_2);
9990                    }
9991    
9992                    query.append(_FINDER_COLUMN_G_M_T_H_HIDDEN_2_SQL);
9993    
9994                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9995                                    DLFolder.class.getName(),
9996                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9997    
9998                    Session session = null;
9999    
10000                    try {
10001                            session = openSession();
10002    
10003                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10004    
10005                            q.addScalar(COUNT_COLUMN_NAME,
10006                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10007    
10008                            QueryPos qPos = QueryPos.getInstance(q);
10009    
10010                            qPos.add(groupId);
10011    
10012                            qPos.add(mountPoint);
10013    
10014                            if (bindTreePath) {
10015                                    qPos.add(treePath);
10016                            }
10017    
10018                            qPos.add(hidden);
10019    
10020                            Long count = (Long)q.uniqueResult();
10021    
10022                            return count.intValue();
10023                    }
10024                    catch (Exception e) {
10025                            throw processException(e);
10026                    }
10027                    finally {
10028                            closeSession(session);
10029                    }
10030            }
10031    
10032            private static final String _FINDER_COLUMN_G_M_T_H_GROUPID_2 = "dlFolder.groupId = ? AND ";
10033            private static final String _FINDER_COLUMN_G_M_T_H_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
10034            private static final String _FINDER_COLUMN_G_M_T_H_TREEPATH_1 = "dlFolder.treePath IS NULL AND ";
10035            private static final String _FINDER_COLUMN_G_M_T_H_TREEPATH_2 = "dlFolder.treePath LIKE ? AND ";
10036            private static final String _FINDER_COLUMN_G_M_T_H_TREEPATH_3 = "(dlFolder.treePath IS NULL OR dlFolder.treePath LIKE '') AND ";
10037            private static final String _FINDER_COLUMN_G_M_T_H_HIDDEN_2 = "dlFolder.hidden = ?";
10038            private static final String _FINDER_COLUMN_G_M_T_H_HIDDEN_2_SQL = "dlFolder.hidden_ = ?";
10039            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10040                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
10041                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_H_S",
10042                            new String[] {
10043                                    Long.class.getName(), Long.class.getName(),
10044                                    Boolean.class.getName(), Integer.class.getName(),
10045                                    
10046                            Integer.class.getName(), Integer.class.getName(),
10047                                    OrderByComparator.class.getName()
10048                            });
10049            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S =
10050                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10051                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
10052                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_H_S",
10053                            new String[] {
10054                                    Long.class.getName(), Long.class.getName(),
10055                                    Boolean.class.getName(), Integer.class.getName()
10056                            },
10057                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
10058                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
10059                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
10060                            DLFolderModelImpl.STATUS_COLUMN_BITMASK |
10061                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
10062            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10063                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
10064                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_H_S",
10065                            new String[] {
10066                                    Long.class.getName(), Long.class.getName(),
10067                                    Boolean.class.getName(), Integer.class.getName()
10068                            });
10069    
10070            /**
10071             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10072             *
10073             * @param groupId the group ID
10074             * @param parentFolderId the parent folder ID
10075             * @param hidden the hidden
10076             * @param status the status
10077             * @return the matching document library folders
10078             */
10079            @Override
10080            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
10081                    boolean hidden, int status) {
10082                    return findByG_P_H_S(groupId, parentFolderId, hidden, status,
10083                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10084            }
10085    
10086            /**
10087             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10088             *
10089             * <p>
10090             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10091             * </p>
10092             *
10093             * @param groupId the group ID
10094             * @param parentFolderId the parent folder ID
10095             * @param hidden the hidden
10096             * @param status the status
10097             * @param start the lower bound of the range of document library folders
10098             * @param end the upper bound of the range of document library folders (not inclusive)
10099             * @return the range of matching document library folders
10100             */
10101            @Override
10102            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
10103                    boolean hidden, int status, int start, int end) {
10104                    return findByG_P_H_S(groupId, parentFolderId, hidden, status, start,
10105                            end, null);
10106            }
10107    
10108            /**
10109             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10110             *
10111             * <p>
10112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10113             * </p>
10114             *
10115             * @param groupId the group ID
10116             * @param parentFolderId the parent folder ID
10117             * @param hidden the hidden
10118             * @param status the status
10119             * @param start the lower bound of the range of document library folders
10120             * @param end the upper bound of the range of document library folders (not inclusive)
10121             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10122             * @return the ordered range of matching document library folders
10123             */
10124            @Override
10125            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
10126                    boolean hidden, int status, int start, int end,
10127                    OrderByComparator<DLFolder> orderByComparator) {
10128                    return findByG_P_H_S(groupId, parentFolderId, hidden, status, start,
10129                            end, orderByComparator, true);
10130            }
10131    
10132            /**
10133             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10134             *
10135             * <p>
10136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10137             * </p>
10138             *
10139             * @param groupId the group ID
10140             * @param parentFolderId the parent folder ID
10141             * @param hidden the hidden
10142             * @param status the status
10143             * @param start the lower bound of the range of document library folders
10144             * @param end the upper bound of the range of document library folders (not inclusive)
10145             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10146             * @param retrieveFromCache whether to retrieve from the finder cache
10147             * @return the ordered range of matching document library folders
10148             */
10149            @Override
10150            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
10151                    boolean hidden, int status, int start, int end,
10152                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
10153                    boolean pagination = true;
10154                    FinderPath finderPath = null;
10155                    Object[] finderArgs = null;
10156    
10157                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10158                                    (orderByComparator == null)) {
10159                            pagination = false;
10160                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S;
10161                            finderArgs = new Object[] { groupId, parentFolderId, hidden, status };
10162                    }
10163                    else {
10164                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_H_S;
10165                            finderArgs = new Object[] {
10166                                            groupId, parentFolderId, hidden, status,
10167                                            
10168                                            start, end, orderByComparator
10169                                    };
10170                    }
10171    
10172                    List<DLFolder> list = null;
10173    
10174                    if (retrieveFromCache) {
10175                            list = (List<DLFolder>)finderCache.getResult(finderPath,
10176                                            finderArgs, this);
10177    
10178                            if ((list != null) && !list.isEmpty()) {
10179                                    for (DLFolder dlFolder : list) {
10180                                            if ((groupId != dlFolder.getGroupId()) ||
10181                                                            (parentFolderId != dlFolder.getParentFolderId()) ||
10182                                                            (hidden != dlFolder.getHidden()) ||
10183                                                            (status != dlFolder.getStatus())) {
10184                                                    list = null;
10185    
10186                                                    break;
10187                                            }
10188                                    }
10189                            }
10190                    }
10191    
10192                    if (list == null) {
10193                            StringBundler query = null;
10194    
10195                            if (orderByComparator != null) {
10196                                    query = new StringBundler(6 +
10197                                                    (orderByComparator.getOrderByFields().length * 2));
10198                            }
10199                            else {
10200                                    query = new StringBundler(6);
10201                            }
10202    
10203                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
10204    
10205                            query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
10206    
10207                            query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
10208    
10209                            query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
10210    
10211                            query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
10212    
10213                            if (orderByComparator != null) {
10214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10215                                            orderByComparator);
10216                            }
10217                            else
10218                             if (pagination) {
10219                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10220                            }
10221    
10222                            String sql = query.toString();
10223    
10224                            Session session = null;
10225    
10226                            try {
10227                                    session = openSession();
10228    
10229                                    Query q = session.createQuery(sql);
10230    
10231                                    QueryPos qPos = QueryPos.getInstance(q);
10232    
10233                                    qPos.add(groupId);
10234    
10235                                    qPos.add(parentFolderId);
10236    
10237                                    qPos.add(hidden);
10238    
10239                                    qPos.add(status);
10240    
10241                                    if (!pagination) {
10242                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
10243                                                            start, end, false);
10244    
10245                                            Collections.sort(list);
10246    
10247                                            list = Collections.unmodifiableList(list);
10248                                    }
10249                                    else {
10250                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
10251                                                            start, end);
10252                                    }
10253    
10254                                    cacheResult(list);
10255    
10256                                    finderCache.putResult(finderPath, finderArgs, list);
10257                            }
10258                            catch (Exception e) {
10259                                    finderCache.removeResult(finderPath, finderArgs);
10260    
10261                                    throw processException(e);
10262                            }
10263                            finally {
10264                                    closeSession(session);
10265                            }
10266                    }
10267    
10268                    return list;
10269            }
10270    
10271            /**
10272             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10273             *
10274             * @param groupId the group ID
10275             * @param parentFolderId the parent folder ID
10276             * @param hidden the hidden
10277             * @param status the status
10278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10279             * @return the first matching document library folder
10280             * @throws NoSuchFolderException if a matching document library folder could not be found
10281             */
10282            @Override
10283            public DLFolder findByG_P_H_S_First(long groupId, long parentFolderId,
10284                    boolean hidden, int status,
10285                    OrderByComparator<DLFolder> orderByComparator)
10286                    throws NoSuchFolderException {
10287                    DLFolder dlFolder = fetchByG_P_H_S_First(groupId, parentFolderId,
10288                                    hidden, status, orderByComparator);
10289    
10290                    if (dlFolder != null) {
10291                            return dlFolder;
10292                    }
10293    
10294                    StringBundler msg = new StringBundler(10);
10295    
10296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10297    
10298                    msg.append("groupId=");
10299                    msg.append(groupId);
10300    
10301                    msg.append(", parentFolderId=");
10302                    msg.append(parentFolderId);
10303    
10304                    msg.append(", hidden=");
10305                    msg.append(hidden);
10306    
10307                    msg.append(", status=");
10308                    msg.append(status);
10309    
10310                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10311    
10312                    throw new NoSuchFolderException(msg.toString());
10313            }
10314    
10315            /**
10316             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10317             *
10318             * @param groupId the group ID
10319             * @param parentFolderId the parent folder ID
10320             * @param hidden the hidden
10321             * @param status the status
10322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10323             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
10324             */
10325            @Override
10326            public DLFolder fetchByG_P_H_S_First(long groupId, long parentFolderId,
10327                    boolean hidden, int status,
10328                    OrderByComparator<DLFolder> orderByComparator) {
10329                    List<DLFolder> list = findByG_P_H_S(groupId, parentFolderId, hidden,
10330                                    status, 0, 1, orderByComparator);
10331    
10332                    if (!list.isEmpty()) {
10333                            return list.get(0);
10334                    }
10335    
10336                    return null;
10337            }
10338    
10339            /**
10340             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10341             *
10342             * @param groupId the group ID
10343             * @param parentFolderId the parent folder ID
10344             * @param hidden the hidden
10345             * @param status the status
10346             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10347             * @return the last matching document library folder
10348             * @throws NoSuchFolderException if a matching document library folder could not be found
10349             */
10350            @Override
10351            public DLFolder findByG_P_H_S_Last(long groupId, long parentFolderId,
10352                    boolean hidden, int status,
10353                    OrderByComparator<DLFolder> orderByComparator)
10354                    throws NoSuchFolderException {
10355                    DLFolder dlFolder = fetchByG_P_H_S_Last(groupId, parentFolderId,
10356                                    hidden, status, orderByComparator);
10357    
10358                    if (dlFolder != null) {
10359                            return dlFolder;
10360                    }
10361    
10362                    StringBundler msg = new StringBundler(10);
10363    
10364                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10365    
10366                    msg.append("groupId=");
10367                    msg.append(groupId);
10368    
10369                    msg.append(", parentFolderId=");
10370                    msg.append(parentFolderId);
10371    
10372                    msg.append(", hidden=");
10373                    msg.append(hidden);
10374    
10375                    msg.append(", status=");
10376                    msg.append(status);
10377    
10378                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10379    
10380                    throw new NoSuchFolderException(msg.toString());
10381            }
10382    
10383            /**
10384             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10385             *
10386             * @param groupId the group ID
10387             * @param parentFolderId the parent folder ID
10388             * @param hidden the hidden
10389             * @param status the status
10390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10391             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
10392             */
10393            @Override
10394            public DLFolder fetchByG_P_H_S_Last(long groupId, long parentFolderId,
10395                    boolean hidden, int status,
10396                    OrderByComparator<DLFolder> orderByComparator) {
10397                    int count = countByG_P_H_S(groupId, parentFolderId, hidden, status);
10398    
10399                    if (count == 0) {
10400                            return null;
10401                    }
10402    
10403                    List<DLFolder> list = findByG_P_H_S(groupId, parentFolderId, hidden,
10404                                    status, count - 1, count, orderByComparator);
10405    
10406                    if (!list.isEmpty()) {
10407                            return list.get(0);
10408                    }
10409    
10410                    return null;
10411            }
10412    
10413            /**
10414             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10415             *
10416             * @param folderId the primary key of the current document library folder
10417             * @param groupId the group ID
10418             * @param parentFolderId the parent folder ID
10419             * @param hidden the hidden
10420             * @param status the status
10421             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10422             * @return the previous, current, and next document library folder
10423             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10424             */
10425            @Override
10426            public DLFolder[] findByG_P_H_S_PrevAndNext(long folderId, long groupId,
10427                    long parentFolderId, boolean hidden, int status,
10428                    OrderByComparator<DLFolder> orderByComparator)
10429                    throws NoSuchFolderException {
10430                    DLFolder dlFolder = findByPrimaryKey(folderId);
10431    
10432                    Session session = null;
10433    
10434                    try {
10435                            session = openSession();
10436    
10437                            DLFolder[] array = new DLFolderImpl[3];
10438    
10439                            array[0] = getByG_P_H_S_PrevAndNext(session, dlFolder, groupId,
10440                                            parentFolderId, hidden, status, orderByComparator, true);
10441    
10442                            array[1] = dlFolder;
10443    
10444                            array[2] = getByG_P_H_S_PrevAndNext(session, dlFolder, groupId,
10445                                            parentFolderId, hidden, status, orderByComparator, false);
10446    
10447                            return array;
10448                    }
10449                    catch (Exception e) {
10450                            throw processException(e);
10451                    }
10452                    finally {
10453                            closeSession(session);
10454                    }
10455            }
10456    
10457            protected DLFolder getByG_P_H_S_PrevAndNext(Session session,
10458                    DLFolder dlFolder, long groupId, long parentFolderId, boolean hidden,
10459                    int status, OrderByComparator<DLFolder> orderByComparator,
10460                    boolean previous) {
10461                    StringBundler query = null;
10462    
10463                    if (orderByComparator != null) {
10464                            query = new StringBundler(7 +
10465                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10466                                            (orderByComparator.getOrderByFields().length * 3));
10467                    }
10468                    else {
10469                            query = new StringBundler(6);
10470                    }
10471    
10472                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
10473    
10474                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
10475    
10476                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
10477    
10478                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
10479    
10480                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
10481    
10482                    if (orderByComparator != null) {
10483                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10484    
10485                            if (orderByConditionFields.length > 0) {
10486                                    query.append(WHERE_AND);
10487                            }
10488    
10489                            for (int i = 0; i < orderByConditionFields.length; i++) {
10490                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10491                                    query.append(orderByConditionFields[i]);
10492    
10493                                    if ((i + 1) < orderByConditionFields.length) {
10494                                            if (orderByComparator.isAscending() ^ previous) {
10495                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10496                                            }
10497                                            else {
10498                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10499                                            }
10500                                    }
10501                                    else {
10502                                            if (orderByComparator.isAscending() ^ previous) {
10503                                                    query.append(WHERE_GREATER_THAN);
10504                                            }
10505                                            else {
10506                                                    query.append(WHERE_LESSER_THAN);
10507                                            }
10508                                    }
10509                            }
10510    
10511                            query.append(ORDER_BY_CLAUSE);
10512    
10513                            String[] orderByFields = orderByComparator.getOrderByFields();
10514    
10515                            for (int i = 0; i < orderByFields.length; i++) {
10516                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10517                                    query.append(orderByFields[i]);
10518    
10519                                    if ((i + 1) < orderByFields.length) {
10520                                            if (orderByComparator.isAscending() ^ previous) {
10521                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10522                                            }
10523                                            else {
10524                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10525                                            }
10526                                    }
10527                                    else {
10528                                            if (orderByComparator.isAscending() ^ previous) {
10529                                                    query.append(ORDER_BY_ASC);
10530                                            }
10531                                            else {
10532                                                    query.append(ORDER_BY_DESC);
10533                                            }
10534                                    }
10535                            }
10536                    }
10537                    else {
10538                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10539                    }
10540    
10541                    String sql = query.toString();
10542    
10543                    Query q = session.createQuery(sql);
10544    
10545                    q.setFirstResult(0);
10546                    q.setMaxResults(2);
10547    
10548                    QueryPos qPos = QueryPos.getInstance(q);
10549    
10550                    qPos.add(groupId);
10551    
10552                    qPos.add(parentFolderId);
10553    
10554                    qPos.add(hidden);
10555    
10556                    qPos.add(status);
10557    
10558                    if (orderByComparator != null) {
10559                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
10560    
10561                            for (Object value : values) {
10562                                    qPos.add(value);
10563                            }
10564                    }
10565    
10566                    List<DLFolder> list = q.list();
10567    
10568                    if (list.size() == 2) {
10569                            return list.get(1);
10570                    }
10571                    else {
10572                            return null;
10573                    }
10574            }
10575    
10576            /**
10577             * Returns all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10578             *
10579             * @param groupId the group ID
10580             * @param parentFolderId the parent folder ID
10581             * @param hidden the hidden
10582             * @param status the status
10583             * @return the matching document library folders that the user has permission to view
10584             */
10585            @Override
10586            public List<DLFolder> filterFindByG_P_H_S(long groupId,
10587                    long parentFolderId, boolean hidden, int status) {
10588                    return filterFindByG_P_H_S(groupId, parentFolderId, hidden, status,
10589                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10590            }
10591    
10592            /**
10593             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10594             *
10595             * <p>
10596             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10597             * </p>
10598             *
10599             * @param groupId the group ID
10600             * @param parentFolderId the parent folder ID
10601             * @param hidden the hidden
10602             * @param status the status
10603             * @param start the lower bound of the range of document library folders
10604             * @param end the upper bound of the range of document library folders (not inclusive)
10605             * @return the range of matching document library folders that the user has permission to view
10606             */
10607            @Override
10608            public List<DLFolder> filterFindByG_P_H_S(long groupId,
10609                    long parentFolderId, boolean hidden, int status, int start, int end) {
10610                    return filterFindByG_P_H_S(groupId, parentFolderId, hidden, status,
10611                            start, end, null);
10612            }
10613    
10614            /**
10615             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10616             *
10617             * <p>
10618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10619             * </p>
10620             *
10621             * @param groupId the group ID
10622             * @param parentFolderId the parent folder ID
10623             * @param hidden the hidden
10624             * @param status the status
10625             * @param start the lower bound of the range of document library folders
10626             * @param end the upper bound of the range of document library folders (not inclusive)
10627             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10628             * @return the ordered range of matching document library folders that the user has permission to view
10629             */
10630            @Override
10631            public List<DLFolder> filterFindByG_P_H_S(long groupId,
10632                    long parentFolderId, boolean hidden, int status, int start, int end,
10633                    OrderByComparator<DLFolder> orderByComparator) {
10634                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10635                            return findByG_P_H_S(groupId, parentFolderId, hidden, status,
10636                                    start, end, orderByComparator);
10637                    }
10638    
10639                    StringBundler query = null;
10640    
10641                    if (orderByComparator != null) {
10642                            query = new StringBundler(6 +
10643                                            (orderByComparator.getOrderByFields().length * 2));
10644                    }
10645                    else {
10646                            query = new StringBundler(7);
10647                    }
10648    
10649                    if (getDB().isSupportsInlineDistinct()) {
10650                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
10651                    }
10652                    else {
10653                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
10654                    }
10655    
10656                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
10657    
10658                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
10659    
10660                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
10661    
10662                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
10663    
10664                    if (!getDB().isSupportsInlineDistinct()) {
10665                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
10666                    }
10667    
10668                    if (orderByComparator != null) {
10669                            if (getDB().isSupportsInlineDistinct()) {
10670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10671                                            orderByComparator, true);
10672                            }
10673                            else {
10674                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10675                                            orderByComparator, true);
10676                            }
10677                    }
10678                    else {
10679                            if (getDB().isSupportsInlineDistinct()) {
10680                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10681                            }
10682                            else {
10683                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
10684                            }
10685                    }
10686    
10687                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10688                                    DLFolder.class.getName(),
10689                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10690    
10691                    Session session = null;
10692    
10693                    try {
10694                            session = openSession();
10695    
10696                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10697    
10698                            if (getDB().isSupportsInlineDistinct()) {
10699                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
10700                            }
10701                            else {
10702                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
10703                            }
10704    
10705                            QueryPos qPos = QueryPos.getInstance(q);
10706    
10707                            qPos.add(groupId);
10708    
10709                            qPos.add(parentFolderId);
10710    
10711                            qPos.add(hidden);
10712    
10713                            qPos.add(status);
10714    
10715                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
10716                    }
10717                    catch (Exception e) {
10718                            throw processException(e);
10719                    }
10720                    finally {
10721                            closeSession(session);
10722                    }
10723            }
10724    
10725            /**
10726             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10727             *
10728             * @param folderId the primary key of the current document library folder
10729             * @param groupId the group ID
10730             * @param parentFolderId the parent folder ID
10731             * @param hidden the hidden
10732             * @param status the status
10733             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10734             * @return the previous, current, and next document library folder
10735             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10736             */
10737            @Override
10738            public DLFolder[] filterFindByG_P_H_S_PrevAndNext(long folderId,
10739                    long groupId, long parentFolderId, boolean hidden, int status,
10740                    OrderByComparator<DLFolder> orderByComparator)
10741                    throws NoSuchFolderException {
10742                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10743                            return findByG_P_H_S_PrevAndNext(folderId, groupId, parentFolderId,
10744                                    hidden, status, orderByComparator);
10745                    }
10746    
10747                    DLFolder dlFolder = findByPrimaryKey(folderId);
10748    
10749                    Session session = null;
10750    
10751                    try {
10752                            session = openSession();
10753    
10754                            DLFolder[] array = new DLFolderImpl[3];
10755    
10756                            array[0] = filterGetByG_P_H_S_PrevAndNext(session, dlFolder,
10757                                            groupId, parentFolderId, hidden, status, orderByComparator,
10758                                            true);
10759    
10760                            array[1] = dlFolder;
10761    
10762                            array[2] = filterGetByG_P_H_S_PrevAndNext(session, dlFolder,
10763                                            groupId, parentFolderId, hidden, status, orderByComparator,
10764                                            false);
10765    
10766                            return array;
10767                    }
10768                    catch (Exception e) {
10769                            throw processException(e);
10770                    }
10771                    finally {
10772                            closeSession(session);
10773                    }
10774            }
10775    
10776            protected DLFolder filterGetByG_P_H_S_PrevAndNext(Session session,
10777                    DLFolder dlFolder, long groupId, long parentFolderId, boolean hidden,
10778                    int status, OrderByComparator<DLFolder> orderByComparator,
10779                    boolean previous) {
10780                    StringBundler query = null;
10781    
10782                    if (orderByComparator != null) {
10783                            query = new StringBundler(8 +
10784                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10785                                            (orderByComparator.getOrderByFields().length * 3));
10786                    }
10787                    else {
10788                            query = new StringBundler(7);
10789                    }
10790    
10791                    if (getDB().isSupportsInlineDistinct()) {
10792                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
10793                    }
10794                    else {
10795                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
10796                    }
10797    
10798                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
10799    
10800                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
10801    
10802                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
10803    
10804                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
10805    
10806                    if (!getDB().isSupportsInlineDistinct()) {
10807                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
10808                    }
10809    
10810                    if (orderByComparator != null) {
10811                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10812    
10813                            if (orderByConditionFields.length > 0) {
10814                                    query.append(WHERE_AND);
10815                            }
10816    
10817                            for (int i = 0; i < orderByConditionFields.length; i++) {
10818                                    if (getDB().isSupportsInlineDistinct()) {
10819                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10820                                    }
10821                                    else {
10822                                            query.append(_ORDER_BY_ENTITY_TABLE);
10823                                    }
10824    
10825                                    query.append(orderByConditionFields[i]);
10826    
10827                                    if ((i + 1) < orderByConditionFields.length) {
10828                                            if (orderByComparator.isAscending() ^ previous) {
10829                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10830                                            }
10831                                            else {
10832                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10833                                            }
10834                                    }
10835                                    else {
10836                                            if (orderByComparator.isAscending() ^ previous) {
10837                                                    query.append(WHERE_GREATER_THAN);
10838                                            }
10839                                            else {
10840                                                    query.append(WHERE_LESSER_THAN);
10841                                            }
10842                                    }
10843                            }
10844    
10845                            query.append(ORDER_BY_CLAUSE);
10846    
10847                            String[] orderByFields = orderByComparator.getOrderByFields();
10848    
10849                            for (int i = 0; i < orderByFields.length; i++) {
10850                                    if (getDB().isSupportsInlineDistinct()) {
10851                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10852                                    }
10853                                    else {
10854                                            query.append(_ORDER_BY_ENTITY_TABLE);
10855                                    }
10856    
10857                                    query.append(orderByFields[i]);
10858    
10859                                    if ((i + 1) < orderByFields.length) {
10860                                            if (orderByComparator.isAscending() ^ previous) {
10861                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10862                                            }
10863                                            else {
10864                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10865                                            }
10866                                    }
10867                                    else {
10868                                            if (orderByComparator.isAscending() ^ previous) {
10869                                                    query.append(ORDER_BY_ASC);
10870                                            }
10871                                            else {
10872                                                    query.append(ORDER_BY_DESC);
10873                                            }
10874                                    }
10875                            }
10876                    }
10877                    else {
10878                            if (getDB().isSupportsInlineDistinct()) {
10879                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10880                            }
10881                            else {
10882                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
10883                            }
10884                    }
10885    
10886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10887                                    DLFolder.class.getName(),
10888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10889    
10890                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10891    
10892                    q.setFirstResult(0);
10893                    q.setMaxResults(2);
10894    
10895                    if (getDB().isSupportsInlineDistinct()) {
10896                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
10897                    }
10898                    else {
10899                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
10900                    }
10901    
10902                    QueryPos qPos = QueryPos.getInstance(q);
10903    
10904                    qPos.add(groupId);
10905    
10906                    qPos.add(parentFolderId);
10907    
10908                    qPos.add(hidden);
10909    
10910                    qPos.add(status);
10911    
10912                    if (orderByComparator != null) {
10913                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
10914    
10915                            for (Object value : values) {
10916                                    qPos.add(value);
10917                            }
10918                    }
10919    
10920                    List<DLFolder> list = q.list();
10921    
10922                    if (list.size() == 2) {
10923                            return list.get(1);
10924                    }
10925                    else {
10926                            return null;
10927                    }
10928            }
10929    
10930            /**
10931             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63; from the database.
10932             *
10933             * @param groupId the group ID
10934             * @param parentFolderId the parent folder ID
10935             * @param hidden the hidden
10936             * @param status the status
10937             */
10938            @Override
10939            public void removeByG_P_H_S(long groupId, long parentFolderId,
10940                    boolean hidden, int status) {
10941                    for (DLFolder dlFolder : findByG_P_H_S(groupId, parentFolderId, hidden,
10942                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10943                            remove(dlFolder);
10944                    }
10945            }
10946    
10947            /**
10948             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10949             *
10950             * @param groupId the group ID
10951             * @param parentFolderId the parent folder ID
10952             * @param hidden the hidden
10953             * @param status the status
10954             * @return the number of matching document library folders
10955             */
10956            @Override
10957            public int countByG_P_H_S(long groupId, long parentFolderId,
10958                    boolean hidden, int status) {
10959                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_H_S;
10960    
10961                    Object[] finderArgs = new Object[] {
10962                                    groupId, parentFolderId, hidden, status
10963                            };
10964    
10965                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10966    
10967                    if (count == null) {
10968                            StringBundler query = new StringBundler(5);
10969    
10970                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
10971    
10972                            query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
10973    
10974                            query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
10975    
10976                            query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
10977    
10978                            query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
10979    
10980                            String sql = query.toString();
10981    
10982                            Session session = null;
10983    
10984                            try {
10985                                    session = openSession();
10986    
10987                                    Query q = session.createQuery(sql);
10988    
10989                                    QueryPos qPos = QueryPos.getInstance(q);
10990    
10991                                    qPos.add(groupId);
10992    
10993                                    qPos.add(parentFolderId);
10994    
10995                                    qPos.add(hidden);
10996    
10997                                    qPos.add(status);
10998    
10999                                    count = (Long)q.uniqueResult();
11000    
11001                                    finderCache.putResult(finderPath, finderArgs, count);
11002                            }
11003                            catch (Exception e) {
11004                                    finderCache.removeResult(finderPath, finderArgs);
11005    
11006                                    throw processException(e);
11007                            }
11008                            finally {
11009                                    closeSession(session);
11010                            }
11011                    }
11012    
11013                    return count.intValue();
11014            }
11015    
11016            /**
11017             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11018             *
11019             * @param groupId the group ID
11020             * @param parentFolderId the parent folder ID
11021             * @param hidden the hidden
11022             * @param status the status
11023             * @return the number of matching document library folders that the user has permission to view
11024             */
11025            @Override
11026            public int filterCountByG_P_H_S(long groupId, long parentFolderId,
11027                    boolean hidden, int status) {
11028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11029                            return countByG_P_H_S(groupId, parentFolderId, hidden, status);
11030                    }
11031    
11032                    StringBundler query = new StringBundler(5);
11033    
11034                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
11035    
11036                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
11037    
11038                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
11039    
11040                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
11041    
11042                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
11043    
11044                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11045                                    DLFolder.class.getName(),
11046                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11047    
11048                    Session session = null;
11049    
11050                    try {
11051                            session = openSession();
11052    
11053                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11054    
11055                            q.addScalar(COUNT_COLUMN_NAME,
11056                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11057    
11058                            QueryPos qPos = QueryPos.getInstance(q);
11059    
11060                            qPos.add(groupId);
11061    
11062                            qPos.add(parentFolderId);
11063    
11064                            qPos.add(hidden);
11065    
11066                            qPos.add(status);
11067    
11068                            Long count = (Long)q.uniqueResult();
11069    
11070                            return count.intValue();
11071                    }
11072                    catch (Exception e) {
11073                            throw processException(e);
11074                    }
11075                    finally {
11076                            closeSession(session);
11077                    }
11078            }
11079    
11080            private static final String _FINDER_COLUMN_G_P_H_S_GROUPID_2 = "dlFolder.groupId = ? AND ";
11081            private static final String _FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
11082            private static final String _FINDER_COLUMN_G_P_H_S_HIDDEN_2 = "dlFolder.hidden = ? AND ";
11083            private static final String _FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL = "dlFolder.hidden_ = ? AND ";
11084            private static final String _FINDER_COLUMN_G_P_H_S_STATUS_2 = "dlFolder.status = ?";
11085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H_S =
11086                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11087                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
11088                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P_H_S",
11089                            new String[] {
11090                                    Long.class.getName(), Boolean.class.getName(),
11091                                    Long.class.getName(), Boolean.class.getName(),
11092                                    Integer.class.getName(),
11093                                    
11094                            Integer.class.getName(), Integer.class.getName(),
11095                                    OrderByComparator.class.getName()
11096                            });
11097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S =
11098                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11099                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
11100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P_H_S",
11101                            new String[] {
11102                                    Long.class.getName(), Boolean.class.getName(),
11103                                    Long.class.getName(), Boolean.class.getName(),
11104                                    Integer.class.getName()
11105                            },
11106                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
11107                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
11108                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
11109                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
11110                            DLFolderModelImpl.STATUS_COLUMN_BITMASK |
11111                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
11112            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11113                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
11114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P_H_S",
11115                            new String[] {
11116                                    Long.class.getName(), Boolean.class.getName(),
11117                                    Long.class.getName(), Boolean.class.getName(),
11118                                    Integer.class.getName()
11119                            });
11120    
11121            /**
11122             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11123             *
11124             * @param groupId the group ID
11125             * @param mountPoint the mount point
11126             * @param parentFolderId the parent folder ID
11127             * @param hidden the hidden
11128             * @param status the status
11129             * @return the matching document library folders
11130             */
11131            @Override
11132            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
11133                    long parentFolderId, boolean hidden, int status) {
11134                    return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
11135                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11136            }
11137    
11138            /**
11139             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11140             *
11141             * <p>
11142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11143             * </p>
11144             *
11145             * @param groupId the group ID
11146             * @param mountPoint the mount point
11147             * @param parentFolderId the parent folder ID
11148             * @param hidden the hidden
11149             * @param status the status
11150             * @param start the lower bound of the range of document library folders
11151             * @param end the upper bound of the range of document library folders (not inclusive)
11152             * @return the range of matching document library folders
11153             */
11154            @Override
11155            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
11156                    long parentFolderId, boolean hidden, int status, int start, int end) {
11157                    return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
11158                            status, start, end, null);
11159            }
11160    
11161            /**
11162             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11163             *
11164             * <p>
11165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11166             * </p>
11167             *
11168             * @param groupId the group ID
11169             * @param mountPoint the mount point
11170             * @param parentFolderId the parent folder ID
11171             * @param hidden the hidden
11172             * @param status the status
11173             * @param start the lower bound of the range of document library folders
11174             * @param end the upper bound of the range of document library folders (not inclusive)
11175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11176             * @return the ordered range of matching document library folders
11177             */
11178            @Override
11179            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
11180                    long parentFolderId, boolean hidden, int status, int start, int end,
11181                    OrderByComparator<DLFolder> orderByComparator) {
11182                    return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
11183                            status, start, end, orderByComparator, true);
11184            }
11185    
11186            /**
11187             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11188             *
11189             * <p>
11190             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11191             * </p>
11192             *
11193             * @param groupId the group ID
11194             * @param mountPoint the mount point
11195             * @param parentFolderId the parent folder ID
11196             * @param hidden the hidden
11197             * @param status the status
11198             * @param start the lower bound of the range of document library folders
11199             * @param end the upper bound of the range of document library folders (not inclusive)
11200             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11201             * @param retrieveFromCache whether to retrieve from the finder cache
11202             * @return the ordered range of matching document library folders
11203             */
11204            @Override
11205            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
11206                    long parentFolderId, boolean hidden, int status, int start, int end,
11207                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
11208                    boolean pagination = true;
11209                    FinderPath finderPath = null;
11210                    Object[] finderArgs = null;
11211    
11212                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11213                                    (orderByComparator == null)) {
11214                            pagination = false;
11215                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S;
11216                            finderArgs = new Object[] {
11217                                            groupId, mountPoint, parentFolderId, hidden, status
11218                                    };
11219                    }
11220                    else {
11221                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H_S;
11222                            finderArgs = new Object[] {
11223                                            groupId, mountPoint, parentFolderId, hidden, status,
11224                                            
11225                                            start, end, orderByComparator
11226                                    };
11227                    }
11228    
11229                    List<DLFolder> list = null;
11230    
11231                    if (retrieveFromCache) {
11232                            list = (List<DLFolder>)finderCache.getResult(finderPath,
11233                                            finderArgs, this);
11234    
11235                            if ((list != null) && !list.isEmpty()) {
11236                                    for (DLFolder dlFolder : list) {
11237                                            if ((groupId != dlFolder.getGroupId()) ||
11238                                                            (mountPoint != dlFolder.getMountPoint()) ||
11239                                                            (parentFolderId != dlFolder.getParentFolderId()) ||
11240                                                            (hidden != dlFolder.getHidden()) ||
11241                                                            (status != dlFolder.getStatus())) {
11242                                                    list = null;
11243    
11244                                                    break;
11245                                            }
11246                                    }
11247                            }
11248                    }
11249    
11250                    if (list == null) {
11251                            StringBundler query = null;
11252    
11253                            if (orderByComparator != null) {
11254                                    query = new StringBundler(7 +
11255                                                    (orderByComparator.getOrderByFields().length * 2));
11256                            }
11257                            else {
11258                                    query = new StringBundler(7);
11259                            }
11260    
11261                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
11262    
11263                            query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
11264    
11265                            query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
11266    
11267                            query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
11268    
11269                            query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
11270    
11271                            query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
11272    
11273                            if (orderByComparator != null) {
11274                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11275                                            orderByComparator);
11276                            }
11277                            else
11278                             if (pagination) {
11279                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
11280                            }
11281    
11282                            String sql = query.toString();
11283    
11284                            Session session = null;
11285    
11286                            try {
11287                                    session = openSession();
11288    
11289                                    Query q = session.createQuery(sql);
11290    
11291                                    QueryPos qPos = QueryPos.getInstance(q);
11292    
11293                                    qPos.add(groupId);
11294    
11295                                    qPos.add(mountPoint);
11296    
11297                                    qPos.add(parentFolderId);
11298    
11299                                    qPos.add(hidden);
11300    
11301                                    qPos.add(status);
11302    
11303                                    if (!pagination) {
11304                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
11305                                                            start, end, false);
11306    
11307                                            Collections.sort(list);
11308    
11309                                            list = Collections.unmodifiableList(list);
11310                                    }
11311                                    else {
11312                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
11313                                                            start, end);
11314                                    }
11315    
11316                                    cacheResult(list);
11317    
11318                                    finderCache.putResult(finderPath, finderArgs, list);
11319                            }
11320                            catch (Exception e) {
11321                                    finderCache.removeResult(finderPath, finderArgs);
11322    
11323                                    throw processException(e);
11324                            }
11325                            finally {
11326                                    closeSession(session);
11327                            }
11328                    }
11329    
11330                    return list;
11331            }
11332    
11333            /**
11334             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11335             *
11336             * @param groupId the group ID
11337             * @param mountPoint the mount point
11338             * @param parentFolderId the parent folder ID
11339             * @param hidden the hidden
11340             * @param status the status
11341             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11342             * @return the first matching document library folder
11343             * @throws NoSuchFolderException if a matching document library folder could not be found
11344             */
11345            @Override
11346            public DLFolder findByG_M_P_H_S_First(long groupId, boolean mountPoint,
11347                    long parentFolderId, boolean hidden, int status,
11348                    OrderByComparator<DLFolder> orderByComparator)
11349                    throws NoSuchFolderException {
11350                    DLFolder dlFolder = fetchByG_M_P_H_S_First(groupId, mountPoint,
11351                                    parentFolderId, hidden, status, orderByComparator);
11352    
11353                    if (dlFolder != null) {
11354                            return dlFolder;
11355                    }
11356    
11357                    StringBundler msg = new StringBundler(12);
11358    
11359                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11360    
11361                    msg.append("groupId=");
11362                    msg.append(groupId);
11363    
11364                    msg.append(", mountPoint=");
11365                    msg.append(mountPoint);
11366    
11367                    msg.append(", parentFolderId=");
11368                    msg.append(parentFolderId);
11369    
11370                    msg.append(", hidden=");
11371                    msg.append(hidden);
11372    
11373                    msg.append(", status=");
11374                    msg.append(status);
11375    
11376                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11377    
11378                    throw new NoSuchFolderException(msg.toString());
11379            }
11380    
11381            /**
11382             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11383             *
11384             * @param groupId the group ID
11385             * @param mountPoint the mount point
11386             * @param parentFolderId the parent folder ID
11387             * @param hidden the hidden
11388             * @param status the status
11389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11390             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
11391             */
11392            @Override
11393            public DLFolder fetchByG_M_P_H_S_First(long groupId, boolean mountPoint,
11394                    long parentFolderId, boolean hidden, int status,
11395                    OrderByComparator<DLFolder> orderByComparator) {
11396                    List<DLFolder> list = findByG_M_P_H_S(groupId, mountPoint,
11397                                    parentFolderId, hidden, status, 0, 1, orderByComparator);
11398    
11399                    if (!list.isEmpty()) {
11400                            return list.get(0);
11401                    }
11402    
11403                    return null;
11404            }
11405    
11406            /**
11407             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11408             *
11409             * @param groupId the group ID
11410             * @param mountPoint the mount point
11411             * @param parentFolderId the parent folder ID
11412             * @param hidden the hidden
11413             * @param status the status
11414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11415             * @return the last matching document library folder
11416             * @throws NoSuchFolderException if a matching document library folder could not be found
11417             */
11418            @Override
11419            public DLFolder findByG_M_P_H_S_Last(long groupId, boolean mountPoint,
11420                    long parentFolderId, boolean hidden, int status,
11421                    OrderByComparator<DLFolder> orderByComparator)
11422                    throws NoSuchFolderException {
11423                    DLFolder dlFolder = fetchByG_M_P_H_S_Last(groupId, mountPoint,
11424                                    parentFolderId, hidden, status, orderByComparator);
11425    
11426                    if (dlFolder != null) {
11427                            return dlFolder;
11428                    }
11429    
11430                    StringBundler msg = new StringBundler(12);
11431    
11432                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11433    
11434                    msg.append("groupId=");
11435                    msg.append(groupId);
11436    
11437                    msg.append(", mountPoint=");
11438                    msg.append(mountPoint);
11439    
11440                    msg.append(", parentFolderId=");
11441                    msg.append(parentFolderId);
11442    
11443                    msg.append(", hidden=");
11444                    msg.append(hidden);
11445    
11446                    msg.append(", status=");
11447                    msg.append(status);
11448    
11449                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11450    
11451                    throw new NoSuchFolderException(msg.toString());
11452            }
11453    
11454            /**
11455             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11456             *
11457             * @param groupId the group ID
11458             * @param mountPoint the mount point
11459             * @param parentFolderId the parent folder ID
11460             * @param hidden the hidden
11461             * @param status the status
11462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11463             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
11464             */
11465            @Override
11466            public DLFolder fetchByG_M_P_H_S_Last(long groupId, boolean mountPoint,
11467                    long parentFolderId, boolean hidden, int status,
11468                    OrderByComparator<DLFolder> orderByComparator) {
11469                    int count = countByG_M_P_H_S(groupId, mountPoint, parentFolderId,
11470                                    hidden, status);
11471    
11472                    if (count == 0) {
11473                            return null;
11474                    }
11475    
11476                    List<DLFolder> list = findByG_M_P_H_S(groupId, mountPoint,
11477                                    parentFolderId, hidden, status, count - 1, count,
11478                                    orderByComparator);
11479    
11480                    if (!list.isEmpty()) {
11481                            return list.get(0);
11482                    }
11483    
11484                    return null;
11485            }
11486    
11487            /**
11488             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11489             *
11490             * @param folderId the primary key of the current document library folder
11491             * @param groupId the group ID
11492             * @param mountPoint the mount point
11493             * @param parentFolderId the parent folder ID
11494             * @param hidden the hidden
11495             * @param status the status
11496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11497             * @return the previous, current, and next document library folder
11498             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
11499             */
11500            @Override
11501            public DLFolder[] findByG_M_P_H_S_PrevAndNext(long folderId, long groupId,
11502                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
11503                    OrderByComparator<DLFolder> orderByComparator)
11504                    throws NoSuchFolderException {
11505                    DLFolder dlFolder = findByPrimaryKey(folderId);
11506    
11507                    Session session = null;
11508    
11509                    try {
11510                            session = openSession();
11511    
11512                            DLFolder[] array = new DLFolderImpl[3];
11513    
11514                            array[0] = getByG_M_P_H_S_PrevAndNext(session, dlFolder, groupId,
11515                                            mountPoint, parentFolderId, hidden, status,
11516                                            orderByComparator, true);
11517    
11518                            array[1] = dlFolder;
11519    
11520                            array[2] = getByG_M_P_H_S_PrevAndNext(session, dlFolder, groupId,
11521                                            mountPoint, parentFolderId, hidden, status,
11522                                            orderByComparator, false);
11523    
11524                            return array;
11525                    }
11526                    catch (Exception e) {
11527                            throw processException(e);
11528                    }
11529                    finally {
11530                            closeSession(session);
11531                    }
11532            }
11533    
11534            protected DLFolder getByG_M_P_H_S_PrevAndNext(Session session,
11535                    DLFolder dlFolder, long groupId, boolean mountPoint,
11536                    long parentFolderId, boolean hidden, int status,
11537                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
11538                    StringBundler query = null;
11539    
11540                    if (orderByComparator != null) {
11541                            query = new StringBundler(8 +
11542                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11543                                            (orderByComparator.getOrderByFields().length * 3));
11544                    }
11545                    else {
11546                            query = new StringBundler(7);
11547                    }
11548    
11549                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
11550    
11551                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
11552    
11553                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
11554    
11555                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
11556    
11557                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
11558    
11559                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
11560    
11561                    if (orderByComparator != null) {
11562                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11563    
11564                            if (orderByConditionFields.length > 0) {
11565                                    query.append(WHERE_AND);
11566                            }
11567    
11568                            for (int i = 0; i < orderByConditionFields.length; i++) {
11569                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11570                                    query.append(orderByConditionFields[i]);
11571    
11572                                    if ((i + 1) < orderByConditionFields.length) {
11573                                            if (orderByComparator.isAscending() ^ previous) {
11574                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11575                                            }
11576                                            else {
11577                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11578                                            }
11579                                    }
11580                                    else {
11581                                            if (orderByComparator.isAscending() ^ previous) {
11582                                                    query.append(WHERE_GREATER_THAN);
11583                                            }
11584                                            else {
11585                                                    query.append(WHERE_LESSER_THAN);
11586                                            }
11587                                    }
11588                            }
11589    
11590                            query.append(ORDER_BY_CLAUSE);
11591    
11592                            String[] orderByFields = orderByComparator.getOrderByFields();
11593    
11594                            for (int i = 0; i < orderByFields.length; i++) {
11595                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11596                                    query.append(orderByFields[i]);
11597    
11598                                    if ((i + 1) < orderByFields.length) {
11599                                            if (orderByComparator.isAscending() ^ previous) {
11600                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11601                                            }
11602                                            else {
11603                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11604                                            }
11605                                    }
11606                                    else {
11607                                            if (orderByComparator.isAscending() ^ previous) {
11608                                                    query.append(ORDER_BY_ASC);
11609                                            }
11610                                            else {
11611                                                    query.append(ORDER_BY_DESC);
11612                                            }
11613                                    }
11614                            }
11615                    }
11616                    else {
11617                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
11618                    }
11619    
11620                    String sql = query.toString();
11621    
11622                    Query q = session.createQuery(sql);
11623    
11624                    q.setFirstResult(0);
11625                    q.setMaxResults(2);
11626    
11627                    QueryPos qPos = QueryPos.getInstance(q);
11628    
11629                    qPos.add(groupId);
11630    
11631                    qPos.add(mountPoint);
11632    
11633                    qPos.add(parentFolderId);
11634    
11635                    qPos.add(hidden);
11636    
11637                    qPos.add(status);
11638    
11639                    if (orderByComparator != null) {
11640                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
11641    
11642                            for (Object value : values) {
11643                                    qPos.add(value);
11644                            }
11645                    }
11646    
11647                    List<DLFolder> list = q.list();
11648    
11649                    if (list.size() == 2) {
11650                            return list.get(1);
11651                    }
11652                    else {
11653                            return null;
11654                    }
11655            }
11656    
11657            /**
11658             * Returns all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11659             *
11660             * @param groupId the group ID
11661             * @param mountPoint the mount point
11662             * @param parentFolderId the parent folder ID
11663             * @param hidden the hidden
11664             * @param status the status
11665             * @return the matching document library folders that the user has permission to view
11666             */
11667            @Override
11668            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
11669                    boolean mountPoint, long parentFolderId, boolean hidden, int status) {
11670                    return filterFindByG_M_P_H_S(groupId, mountPoint, parentFolderId,
11671                            hidden, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11672            }
11673    
11674            /**
11675             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11676             *
11677             * <p>
11678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11679             * </p>
11680             *
11681             * @param groupId the group ID
11682             * @param mountPoint the mount point
11683             * @param parentFolderId the parent folder ID
11684             * @param hidden the hidden
11685             * @param status the status
11686             * @param start the lower bound of the range of document library folders
11687             * @param end the upper bound of the range of document library folders (not inclusive)
11688             * @return the range of matching document library folders that the user has permission to view
11689             */
11690            @Override
11691            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
11692                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
11693                    int start, int end) {
11694                    return filterFindByG_M_P_H_S(groupId, mountPoint, parentFolderId,
11695                            hidden, status, start, end, null);
11696            }
11697    
11698            /**
11699             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11700             *
11701             * <p>
11702             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11703             * </p>
11704             *
11705             * @param groupId the group ID
11706             * @param mountPoint the mount point
11707             * @param parentFolderId the parent folder ID
11708             * @param hidden the hidden
11709             * @param status the status
11710             * @param start the lower bound of the range of document library folders
11711             * @param end the upper bound of the range of document library folders (not inclusive)
11712             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11713             * @return the ordered range of matching document library folders that the user has permission to view
11714             */
11715            @Override
11716            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
11717                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
11718                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
11719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11720                            return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
11721                                    status, start, end, orderByComparator);
11722                    }
11723    
11724                    StringBundler query = null;
11725    
11726                    if (orderByComparator != null) {
11727                            query = new StringBundler(7 +
11728                                            (orderByComparator.getOrderByFields().length * 2));
11729                    }
11730                    else {
11731                            query = new StringBundler(8);
11732                    }
11733    
11734                    if (getDB().isSupportsInlineDistinct()) {
11735                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
11736                    }
11737                    else {
11738                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
11739                    }
11740    
11741                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
11742    
11743                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
11744    
11745                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
11746    
11747                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
11748    
11749                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
11750    
11751                    if (!getDB().isSupportsInlineDistinct()) {
11752                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
11753                    }
11754    
11755                    if (orderByComparator != null) {
11756                            if (getDB().isSupportsInlineDistinct()) {
11757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11758                                            orderByComparator, true);
11759                            }
11760                            else {
11761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11762                                            orderByComparator, true);
11763                            }
11764                    }
11765                    else {
11766                            if (getDB().isSupportsInlineDistinct()) {
11767                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
11768                            }
11769                            else {
11770                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
11771                            }
11772                    }
11773    
11774                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11775                                    DLFolder.class.getName(),
11776                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11777    
11778                    Session session = null;
11779    
11780                    try {
11781                            session = openSession();
11782    
11783                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11784    
11785                            if (getDB().isSupportsInlineDistinct()) {
11786                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
11787                            }
11788                            else {
11789                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
11790                            }
11791    
11792                            QueryPos qPos = QueryPos.getInstance(q);
11793    
11794                            qPos.add(groupId);
11795    
11796                            qPos.add(mountPoint);
11797    
11798                            qPos.add(parentFolderId);
11799    
11800                            qPos.add(hidden);
11801    
11802                            qPos.add(status);
11803    
11804                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
11805                    }
11806                    catch (Exception e) {
11807                            throw processException(e);
11808                    }
11809                    finally {
11810                            closeSession(session);
11811                    }
11812            }
11813    
11814            /**
11815             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
11816             *
11817             * @param folderId the primary key of the current document library folder
11818             * @param groupId the group ID
11819             * @param mountPoint the mount point
11820             * @param parentFolderId the parent folder ID
11821             * @param hidden the hidden
11822             * @param status the status
11823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11824             * @return the previous, current, and next document library folder
11825             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
11826             */
11827            @Override
11828            public DLFolder[] filterFindByG_M_P_H_S_PrevAndNext(long folderId,
11829                    long groupId, boolean mountPoint, long parentFolderId, boolean hidden,
11830                    int status, OrderByComparator<DLFolder> orderByComparator)
11831                    throws NoSuchFolderException {
11832                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11833                            return findByG_M_P_H_S_PrevAndNext(folderId, groupId, mountPoint,
11834                                    parentFolderId, hidden, status, orderByComparator);
11835                    }
11836    
11837                    DLFolder dlFolder = findByPrimaryKey(folderId);
11838    
11839                    Session session = null;
11840    
11841                    try {
11842                            session = openSession();
11843    
11844                            DLFolder[] array = new DLFolderImpl[3];
11845    
11846                            array[0] = filterGetByG_M_P_H_S_PrevAndNext(session, dlFolder,
11847                                            groupId, mountPoint, parentFolderId, hidden, status,
11848                                            orderByComparator, true);
11849    
11850                            array[1] = dlFolder;
11851    
11852                            array[2] = filterGetByG_M_P_H_S_PrevAndNext(session, dlFolder,
11853                                            groupId, mountPoint, parentFolderId, hidden, status,
11854                                            orderByComparator, false);
11855    
11856                            return array;
11857                    }
11858                    catch (Exception e) {
11859                            throw processException(e);
11860                    }
11861                    finally {
11862                            closeSession(session);
11863                    }
11864            }
11865    
11866            protected DLFolder filterGetByG_M_P_H_S_PrevAndNext(Session session,
11867                    DLFolder dlFolder, long groupId, boolean mountPoint,
11868                    long parentFolderId, boolean hidden, int status,
11869                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
11870                    StringBundler query = null;
11871    
11872                    if (orderByComparator != null) {
11873                            query = new StringBundler(9 +
11874                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11875                                            (orderByComparator.getOrderByFields().length * 3));
11876                    }
11877                    else {
11878                            query = new StringBundler(8);
11879                    }
11880    
11881                    if (getDB().isSupportsInlineDistinct()) {
11882                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
11883                    }
11884                    else {
11885                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
11886                    }
11887    
11888                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
11889    
11890                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
11891    
11892                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
11893    
11894                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
11895    
11896                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
11897    
11898                    if (!getDB().isSupportsInlineDistinct()) {
11899                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
11900                    }
11901    
11902                    if (orderByComparator != null) {
11903                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11904    
11905                            if (orderByConditionFields.length > 0) {
11906                                    query.append(WHERE_AND);
11907                            }
11908    
11909                            for (int i = 0; i < orderByConditionFields.length; i++) {
11910                                    if (getDB().isSupportsInlineDistinct()) {
11911                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11912                                    }
11913                                    else {
11914                                            query.append(_ORDER_BY_ENTITY_TABLE);
11915                                    }
11916    
11917                                    query.append(orderByConditionFields[i]);
11918    
11919                                    if ((i + 1) < orderByConditionFields.length) {
11920                                            if (orderByComparator.isAscending() ^ previous) {
11921                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11922                                            }
11923                                            else {
11924                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11925                                            }
11926                                    }
11927                                    else {
11928                                            if (orderByComparator.isAscending() ^ previous) {
11929                                                    query.append(WHERE_GREATER_THAN);
11930                                            }
11931                                            else {
11932                                                    query.append(WHERE_LESSER_THAN);
11933                                            }
11934                                    }
11935                            }
11936    
11937                            query.append(ORDER_BY_CLAUSE);
11938    
11939                            String[] orderByFields = orderByComparator.getOrderByFields();
11940    
11941                            for (int i = 0; i < orderByFields.length; i++) {
11942                                    if (getDB().isSupportsInlineDistinct()) {
11943                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11944                                    }
11945                                    else {
11946                                            query.append(_ORDER_BY_ENTITY_TABLE);
11947                                    }
11948    
11949                                    query.append(orderByFields[i]);
11950    
11951                                    if ((i + 1) < orderByFields.length) {
11952                                            if (orderByComparator.isAscending() ^ previous) {
11953                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11954                                            }
11955                                            else {
11956                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11957                                            }
11958                                    }
11959                                    else {
11960                                            if (orderByComparator.isAscending() ^ previous) {
11961                                                    query.append(ORDER_BY_ASC);
11962                                            }
11963                                            else {
11964                                                    query.append(ORDER_BY_DESC);
11965                                            }
11966                                    }
11967                            }
11968                    }
11969                    else {
11970                            if (getDB().isSupportsInlineDistinct()) {
11971                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
11972                            }
11973                            else {
11974                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
11975                            }
11976                    }
11977    
11978                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11979                                    DLFolder.class.getName(),
11980                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11981    
11982                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11983    
11984                    q.setFirstResult(0);
11985                    q.setMaxResults(2);
11986    
11987                    if (getDB().isSupportsInlineDistinct()) {
11988                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
11989                    }
11990                    else {
11991                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
11992                    }
11993    
11994                    QueryPos qPos = QueryPos.getInstance(q);
11995    
11996                    qPos.add(groupId);
11997    
11998                    qPos.add(mountPoint);
11999    
12000                    qPos.add(parentFolderId);
12001    
12002                    qPos.add(hidden);
12003    
12004                    qPos.add(status);
12005    
12006                    if (orderByComparator != null) {
12007                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
12008    
12009                            for (Object value : values) {
12010                                    qPos.add(value);
12011                            }
12012                    }
12013    
12014                    List<DLFolder> list = q.list();
12015    
12016                    if (list.size() == 2) {
12017                            return list.get(1);
12018                    }
12019                    else {
12020                            return null;
12021                    }
12022            }
12023    
12024            /**
12025             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63; from the database.
12026             *
12027             * @param groupId the group ID
12028             * @param mountPoint the mount point
12029             * @param parentFolderId the parent folder ID
12030             * @param hidden the hidden
12031             * @param status the status
12032             */
12033            @Override
12034            public void removeByG_M_P_H_S(long groupId, boolean mountPoint,
12035                    long parentFolderId, boolean hidden, int status) {
12036                    for (DLFolder dlFolder : findByG_M_P_H_S(groupId, mountPoint,
12037                                    parentFolderId, hidden, status, QueryUtil.ALL_POS,
12038                                    QueryUtil.ALL_POS, null)) {
12039                            remove(dlFolder);
12040                    }
12041            }
12042    
12043            /**
12044             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
12045             *
12046             * @param groupId the group ID
12047             * @param mountPoint the mount point
12048             * @param parentFolderId the parent folder ID
12049             * @param hidden the hidden
12050             * @param status the status
12051             * @return the number of matching document library folders
12052             */
12053            @Override
12054            public int countByG_M_P_H_S(long groupId, boolean mountPoint,
12055                    long parentFolderId, boolean hidden, int status) {
12056                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P_H_S;
12057    
12058                    Object[] finderArgs = new Object[] {
12059                                    groupId, mountPoint, parentFolderId, hidden, status
12060                            };
12061    
12062                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12063    
12064                    if (count == null) {
12065                            StringBundler query = new StringBundler(6);
12066    
12067                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
12068    
12069                            query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
12070    
12071                            query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
12072    
12073                            query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
12074    
12075                            query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
12076    
12077                            query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
12078    
12079                            String sql = query.toString();
12080    
12081                            Session session = null;
12082    
12083                            try {
12084                                    session = openSession();
12085    
12086                                    Query q = session.createQuery(sql);
12087    
12088                                    QueryPos qPos = QueryPos.getInstance(q);
12089    
12090                                    qPos.add(groupId);
12091    
12092                                    qPos.add(mountPoint);
12093    
12094                                    qPos.add(parentFolderId);
12095    
12096                                    qPos.add(hidden);
12097    
12098                                    qPos.add(status);
12099    
12100                                    count = (Long)q.uniqueResult();
12101    
12102                                    finderCache.putResult(finderPath, finderArgs, count);
12103                            }
12104                            catch (Exception e) {
12105                                    finderCache.removeResult(finderPath, finderArgs);
12106    
12107                                    throw processException(e);
12108                            }
12109                            finally {
12110                                    closeSession(session);
12111                            }
12112                    }
12113    
12114                    return count.intValue();
12115            }
12116    
12117            /**
12118             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
12119             *
12120             * @param groupId the group ID
12121             * @param mountPoint the mount point
12122             * @param parentFolderId the parent folder ID
12123             * @param hidden the hidden
12124             * @param status the status
12125             * @return the number of matching document library folders that the user has permission to view
12126             */
12127            @Override
12128            public int filterCountByG_M_P_H_S(long groupId, boolean mountPoint,
12129                    long parentFolderId, boolean hidden, int status) {
12130                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12131                            return countByG_M_P_H_S(groupId, mountPoint, parentFolderId,
12132                                    hidden, status);
12133                    }
12134    
12135                    StringBundler query = new StringBundler(6);
12136    
12137                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
12138    
12139                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
12140    
12141                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
12142    
12143                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
12144    
12145                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
12146    
12147                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
12148    
12149                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12150                                    DLFolder.class.getName(),
12151                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12152    
12153                    Session session = null;
12154    
12155                    try {
12156                            session = openSession();
12157    
12158                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12159    
12160                            q.addScalar(COUNT_COLUMN_NAME,
12161                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12162    
12163                            QueryPos qPos = QueryPos.getInstance(q);
12164    
12165                            qPos.add(groupId);
12166    
12167                            qPos.add(mountPoint);
12168    
12169                            qPos.add(parentFolderId);
12170    
12171                            qPos.add(hidden);
12172    
12173                            qPos.add(status);
12174    
12175                            Long count = (Long)q.uniqueResult();
12176    
12177                            return count.intValue();
12178                    }
12179                    catch (Exception e) {
12180                            throw processException(e);
12181                    }
12182                    finally {
12183                            closeSession(session);
12184                    }
12185            }
12186    
12187            private static final String _FINDER_COLUMN_G_M_P_H_S_GROUPID_2 = "dlFolder.groupId = ? AND ";
12188            private static final String _FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
12189            private static final String _FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
12190            private static final String _FINDER_COLUMN_G_M_P_H_S_HIDDEN_2 = "dlFolder.hidden = ? AND ";
12191            private static final String _FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL = "dlFolder.hidden_ = ? AND ";
12192            private static final String _FINDER_COLUMN_G_M_P_H_S_STATUS_2 = "dlFolder.status = ?";
12193    
12194            public DLFolderPersistenceImpl() {
12195                    setModelClass(DLFolder.class);
12196            }
12197    
12198            /**
12199             * Caches the document library folder in the entity cache if it is enabled.
12200             *
12201             * @param dlFolder the document library folder
12202             */
12203            @Override
12204            public void cacheResult(DLFolder dlFolder) {
12205                    entityCache.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12206                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
12207    
12208                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
12209                            new Object[] { dlFolder.getUuid(), dlFolder.getGroupId() }, dlFolder);
12210    
12211                    finderCache.putResult(FINDER_PATH_FETCH_BY_R_M,
12212                            new Object[] { dlFolder.getRepositoryId(), dlFolder.getMountPoint() },
12213                            dlFolder);
12214    
12215                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_P_N,
12216                            new Object[] {
12217                                    dlFolder.getGroupId(), dlFolder.getParentFolderId(),
12218                                    dlFolder.getName()
12219                            }, dlFolder);
12220    
12221                    dlFolder.resetOriginalValues();
12222            }
12223    
12224            /**
12225             * Caches the document library folders in the entity cache if it is enabled.
12226             *
12227             * @param dlFolders the document library folders
12228             */
12229            @Override
12230            public void cacheResult(List<DLFolder> dlFolders) {
12231                    for (DLFolder dlFolder : dlFolders) {
12232                            if (entityCache.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12233                                                    DLFolderImpl.class, dlFolder.getPrimaryKey()) == null) {
12234                                    cacheResult(dlFolder);
12235                            }
12236                            else {
12237                                    dlFolder.resetOriginalValues();
12238                            }
12239                    }
12240            }
12241    
12242            /**
12243             * Clears the cache for all document library folders.
12244             *
12245             * <p>
12246             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
12247             * </p>
12248             */
12249            @Override
12250            public void clearCache() {
12251                    entityCache.clearCache(DLFolderImpl.class);
12252    
12253                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
12254                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12255                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12256            }
12257    
12258            /**
12259             * Clears the cache for the document library folder.
12260             *
12261             * <p>
12262             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
12263             * </p>
12264             */
12265            @Override
12266            public void clearCache(DLFolder dlFolder) {
12267                    entityCache.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12268                            DLFolderImpl.class, dlFolder.getPrimaryKey());
12269    
12270                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12271                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12272    
12273                    clearUniqueFindersCache((DLFolderModelImpl)dlFolder);
12274            }
12275    
12276            @Override
12277            public void clearCache(List<DLFolder> dlFolders) {
12278                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12279                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12280    
12281                    for (DLFolder dlFolder : dlFolders) {
12282                            entityCache.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12283                                    DLFolderImpl.class, dlFolder.getPrimaryKey());
12284    
12285                            clearUniqueFindersCache((DLFolderModelImpl)dlFolder);
12286                    }
12287            }
12288    
12289            protected void cacheUniqueFindersCache(
12290                    DLFolderModelImpl dlFolderModelImpl, boolean isNew) {
12291                    if (isNew) {
12292                            Object[] args = new Object[] {
12293                                            dlFolderModelImpl.getUuid(), dlFolderModelImpl.getGroupId()
12294                                    };
12295    
12296                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
12297                                    Long.valueOf(1));
12298                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
12299                                    dlFolderModelImpl);
12300    
12301                            args = new Object[] {
12302                                            dlFolderModelImpl.getRepositoryId(),
12303                                            dlFolderModelImpl.getMountPoint()
12304                                    };
12305    
12306                            finderCache.putResult(FINDER_PATH_COUNT_BY_R_M, args,
12307                                    Long.valueOf(1));
12308                            finderCache.putResult(FINDER_PATH_FETCH_BY_R_M, args,
12309                                    dlFolderModelImpl);
12310    
12311                            args = new Object[] {
12312                                            dlFolderModelImpl.getGroupId(),
12313                                            dlFolderModelImpl.getParentFolderId(),
12314                                            dlFolderModelImpl.getName()
12315                                    };
12316    
12317                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
12318                                    Long.valueOf(1));
12319                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
12320                                    dlFolderModelImpl);
12321                    }
12322                    else {
12323                            if ((dlFolderModelImpl.getColumnBitmask() &
12324                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
12325                                    Object[] args = new Object[] {
12326                                                    dlFolderModelImpl.getUuid(),
12327                                                    dlFolderModelImpl.getGroupId()
12328                                            };
12329    
12330                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
12331                                            Long.valueOf(1));
12332                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
12333                                            dlFolderModelImpl);
12334                            }
12335    
12336                            if ((dlFolderModelImpl.getColumnBitmask() &
12337                                            FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
12338                                    Object[] args = new Object[] {
12339                                                    dlFolderModelImpl.getRepositoryId(),
12340                                                    dlFolderModelImpl.getMountPoint()
12341                                            };
12342    
12343                                    finderCache.putResult(FINDER_PATH_COUNT_BY_R_M, args,
12344                                            Long.valueOf(1));
12345                                    finderCache.putResult(FINDER_PATH_FETCH_BY_R_M, args,
12346                                            dlFolderModelImpl);
12347                            }
12348    
12349                            if ((dlFolderModelImpl.getColumnBitmask() &
12350                                            FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
12351                                    Object[] args = new Object[] {
12352                                                    dlFolderModelImpl.getGroupId(),
12353                                                    dlFolderModelImpl.getParentFolderId(),
12354                                                    dlFolderModelImpl.getName()
12355                                            };
12356    
12357                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
12358                                            Long.valueOf(1));
12359                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
12360                                            dlFolderModelImpl);
12361                            }
12362                    }
12363            }
12364    
12365            protected void clearUniqueFindersCache(DLFolderModelImpl dlFolderModelImpl) {
12366                    Object[] args = new Object[] {
12367                                    dlFolderModelImpl.getUuid(), dlFolderModelImpl.getGroupId()
12368                            };
12369    
12370                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
12371                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
12372    
12373                    if ((dlFolderModelImpl.getColumnBitmask() &
12374                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
12375                            args = new Object[] {
12376                                            dlFolderModelImpl.getOriginalUuid(),
12377                                            dlFolderModelImpl.getOriginalGroupId()
12378                                    };
12379    
12380                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
12381                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
12382                    }
12383    
12384                    args = new Object[] {
12385                                    dlFolderModelImpl.getRepositoryId(),
12386                                    dlFolderModelImpl.getMountPoint()
12387                            };
12388    
12389                    finderCache.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
12390                    finderCache.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
12391    
12392                    if ((dlFolderModelImpl.getColumnBitmask() &
12393                                    FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
12394                            args = new Object[] {
12395                                            dlFolderModelImpl.getOriginalRepositoryId(),
12396                                            dlFolderModelImpl.getOriginalMountPoint()
12397                                    };
12398    
12399                            finderCache.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
12400                            finderCache.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
12401                    }
12402    
12403                    args = new Object[] {
12404                                    dlFolderModelImpl.getGroupId(),
12405                                    dlFolderModelImpl.getParentFolderId(),
12406                                    dlFolderModelImpl.getName()
12407                            };
12408    
12409                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
12410                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
12411    
12412                    if ((dlFolderModelImpl.getColumnBitmask() &
12413                                    FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
12414                            args = new Object[] {
12415                                            dlFolderModelImpl.getOriginalGroupId(),
12416                                            dlFolderModelImpl.getOriginalParentFolderId(),
12417                                            dlFolderModelImpl.getOriginalName()
12418                                    };
12419    
12420                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
12421                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
12422                    }
12423            }
12424    
12425            /**
12426             * Creates a new document library folder with the primary key. Does not add the document library folder to the database.
12427             *
12428             * @param folderId the primary key for the new document library folder
12429             * @return the new document library folder
12430             */
12431            @Override
12432            public DLFolder create(long folderId) {
12433                    DLFolder dlFolder = new DLFolderImpl();
12434    
12435                    dlFolder.setNew(true);
12436                    dlFolder.setPrimaryKey(folderId);
12437    
12438                    String uuid = PortalUUIDUtil.generate();
12439    
12440                    dlFolder.setUuid(uuid);
12441    
12442                    dlFolder.setCompanyId(companyProvider.getCompanyId());
12443    
12444                    return dlFolder;
12445            }
12446    
12447            /**
12448             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
12449             *
12450             * @param folderId the primary key of the document library folder
12451             * @return the document library folder that was removed
12452             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
12453             */
12454            @Override
12455            public DLFolder remove(long folderId) throws NoSuchFolderException {
12456                    return remove((Serializable)folderId);
12457            }
12458    
12459            /**
12460             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
12461             *
12462             * @param primaryKey the primary key of the document library folder
12463             * @return the document library folder that was removed
12464             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
12465             */
12466            @Override
12467            public DLFolder remove(Serializable primaryKey)
12468                    throws NoSuchFolderException {
12469                    Session session = null;
12470    
12471                    try {
12472                            session = openSession();
12473    
12474                            DLFolder dlFolder = (DLFolder)session.get(DLFolderImpl.class,
12475                                            primaryKey);
12476    
12477                            if (dlFolder == null) {
12478                                    if (_log.isDebugEnabled()) {
12479                                            _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12480                                    }
12481    
12482                                    throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12483                                            primaryKey);
12484                            }
12485    
12486                            return remove(dlFolder);
12487                    }
12488                    catch (NoSuchFolderException nsee) {
12489                            throw nsee;
12490                    }
12491                    catch (Exception e) {
12492                            throw processException(e);
12493                    }
12494                    finally {
12495                            closeSession(session);
12496                    }
12497            }
12498    
12499            @Override
12500            protected DLFolder removeImpl(DLFolder dlFolder) {
12501                    dlFolder = toUnwrappedModel(dlFolder);
12502    
12503                    dlFolderToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(dlFolder.getPrimaryKey());
12504    
12505                    Session session = null;
12506    
12507                    try {
12508                            session = openSession();
12509    
12510                            if (!session.contains(dlFolder)) {
12511                                    dlFolder = (DLFolder)session.get(DLFolderImpl.class,
12512                                                    dlFolder.getPrimaryKeyObj());
12513                            }
12514    
12515                            if (dlFolder != null) {
12516                                    session.delete(dlFolder);
12517                            }
12518                    }
12519                    catch (Exception e) {
12520                            throw processException(e);
12521                    }
12522                    finally {
12523                            closeSession(session);
12524                    }
12525    
12526                    if (dlFolder != null) {
12527                            clearCache(dlFolder);
12528                    }
12529    
12530                    return dlFolder;
12531            }
12532    
12533            @Override
12534            public DLFolder updateImpl(DLFolder dlFolder) {
12535                    dlFolder = toUnwrappedModel(dlFolder);
12536    
12537                    boolean isNew = dlFolder.isNew();
12538    
12539                    DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
12540    
12541                    if (Validator.isNull(dlFolder.getUuid())) {
12542                            String uuid = PortalUUIDUtil.generate();
12543    
12544                            dlFolder.setUuid(uuid);
12545                    }
12546    
12547                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
12548    
12549                    Date now = new Date();
12550    
12551                    if (isNew && (dlFolder.getCreateDate() == null)) {
12552                            if (serviceContext == null) {
12553                                    dlFolder.setCreateDate(now);
12554                            }
12555                            else {
12556                                    dlFolder.setCreateDate(serviceContext.getCreateDate(now));
12557                            }
12558                    }
12559    
12560                    if (!dlFolderModelImpl.hasSetModifiedDate()) {
12561                            if (serviceContext == null) {
12562                                    dlFolder.setModifiedDate(now);
12563                            }
12564                            else {
12565                                    dlFolder.setModifiedDate(serviceContext.getModifiedDate(now));
12566                            }
12567                    }
12568    
12569                    Session session = null;
12570    
12571                    try {
12572                            session = openSession();
12573    
12574                            if (dlFolder.isNew()) {
12575                                    session.save(dlFolder);
12576    
12577                                    dlFolder.setNew(false);
12578                            }
12579                            else {
12580                                    dlFolder = (DLFolder)session.merge(dlFolder);
12581                            }
12582                    }
12583                    catch (Exception e) {
12584                            throw processException(e);
12585                    }
12586                    finally {
12587                            closeSession(session);
12588                    }
12589    
12590                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12591    
12592                    if (isNew || !DLFolderModelImpl.COLUMN_BITMASK_ENABLED) {
12593                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12594                    }
12595    
12596                    else {
12597                            if ((dlFolderModelImpl.getColumnBitmask() &
12598                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
12599                                    Object[] args = new Object[] { dlFolderModelImpl.getOriginalUuid() };
12600    
12601                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12602                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12603                                            args);
12604    
12605                                    args = new Object[] { dlFolderModelImpl.getUuid() };
12606    
12607                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12608                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12609                                            args);
12610                            }
12611    
12612                            if ((dlFolderModelImpl.getColumnBitmask() &
12613                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
12614                                    Object[] args = new Object[] {
12615                                                    dlFolderModelImpl.getOriginalUuid(),
12616                                                    dlFolderModelImpl.getOriginalCompanyId()
12617                                            };
12618    
12619                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12620                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12621                                            args);
12622    
12623                                    args = new Object[] {
12624                                                    dlFolderModelImpl.getUuid(),
12625                                                    dlFolderModelImpl.getCompanyId()
12626                                            };
12627    
12628                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12629                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12630                                            args);
12631                            }
12632    
12633                            if ((dlFolderModelImpl.getColumnBitmask() &
12634                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
12635                                    Object[] args = new Object[] {
12636                                                    dlFolderModelImpl.getOriginalGroupId()
12637                                            };
12638    
12639                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
12640                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
12641                                            args);
12642    
12643                                    args = new Object[] { dlFolderModelImpl.getGroupId() };
12644    
12645                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
12646                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
12647                                            args);
12648                            }
12649    
12650                            if ((dlFolderModelImpl.getColumnBitmask() &
12651                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
12652                                    Object[] args = new Object[] {
12653                                                    dlFolderModelImpl.getOriginalCompanyId()
12654                                            };
12655    
12656                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
12657                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12658                                            args);
12659    
12660                                    args = new Object[] { dlFolderModelImpl.getCompanyId() };
12661    
12662                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
12663                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12664                                            args);
12665                            }
12666    
12667                            if ((dlFolderModelImpl.getColumnBitmask() &
12668                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
12669                                    Object[] args = new Object[] {
12670                                                    dlFolderModelImpl.getOriginalRepositoryId()
12671                                            };
12672    
12673                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
12674                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
12675                                            args);
12676    
12677                                    args = new Object[] { dlFolderModelImpl.getRepositoryId() };
12678    
12679                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
12680                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
12681                                            args);
12682                            }
12683    
12684                            if ((dlFolderModelImpl.getColumnBitmask() &
12685                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
12686                                    Object[] args = new Object[] {
12687                                                    dlFolderModelImpl.getOriginalGroupId(),
12688                                                    dlFolderModelImpl.getOriginalParentFolderId()
12689                                            };
12690    
12691                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
12692                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
12693                                            args);
12694    
12695                                    args = new Object[] {
12696                                                    dlFolderModelImpl.getGroupId(),
12697                                                    dlFolderModelImpl.getParentFolderId()
12698                                            };
12699    
12700                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
12701                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
12702                                            args);
12703                            }
12704    
12705                            if ((dlFolderModelImpl.getColumnBitmask() &
12706                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P.getColumnBitmask()) != 0) {
12707                                    Object[] args = new Object[] {
12708                                                    dlFolderModelImpl.getOriginalRepositoryId(),
12709                                                    dlFolderModelImpl.getOriginalParentFolderId()
12710                                            };
12711    
12712                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_R_P, args);
12713                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P,
12714                                            args);
12715    
12716                                    args = new Object[] {
12717                                                    dlFolderModelImpl.getRepositoryId(),
12718                                                    dlFolderModelImpl.getParentFolderId()
12719                                            };
12720    
12721                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_R_P, args);
12722                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P,
12723                                            args);
12724                            }
12725    
12726                            if ((dlFolderModelImpl.getColumnBitmask() &
12727                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
12728                                    Object[] args = new Object[] {
12729                                                    dlFolderModelImpl.getOriginalParentFolderId(),
12730                                                    dlFolderModelImpl.getOriginalName()
12731                                            };
12732    
12733                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
12734                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
12735                                            args);
12736    
12737                                    args = new Object[] {
12738                                                    dlFolderModelImpl.getParentFolderId(),
12739                                                    dlFolderModelImpl.getName()
12740                                            };
12741    
12742                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
12743                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
12744                                            args);
12745                            }
12746    
12747                            if ((dlFolderModelImpl.getColumnBitmask() &
12748                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P.getColumnBitmask()) != 0) {
12749                                    Object[] args = new Object[] {
12750                                                    dlFolderModelImpl.getOriginalGroupId(),
12751                                                    dlFolderModelImpl.getOriginalMountPoint(),
12752                                                    dlFolderModelImpl.getOriginalParentFolderId()
12753                                            };
12754    
12755                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P, args);
12756                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P,
12757                                            args);
12758    
12759                                    args = new Object[] {
12760                                                    dlFolderModelImpl.getGroupId(),
12761                                                    dlFolderModelImpl.getMountPoint(),
12762                                                    dlFolderModelImpl.getParentFolderId()
12763                                            };
12764    
12765                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P, args);
12766                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P,
12767                                            args);
12768                            }
12769    
12770                            if ((dlFolderModelImpl.getColumnBitmask() &
12771                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H.getColumnBitmask()) != 0) {
12772                                    Object[] args = new Object[] {
12773                                                    dlFolderModelImpl.getOriginalGroupId(),
12774                                                    dlFolderModelImpl.getOriginalMountPoint(),
12775                                                    dlFolderModelImpl.getOriginalParentFolderId(),
12776                                                    dlFolderModelImpl.getOriginalHidden()
12777                                            };
12778    
12779                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H, args);
12780                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H,
12781                                            args);
12782    
12783                                    args = new Object[] {
12784                                                    dlFolderModelImpl.getGroupId(),
12785                                                    dlFolderModelImpl.getMountPoint(),
12786                                                    dlFolderModelImpl.getParentFolderId(),
12787                                                    dlFolderModelImpl.getHidden()
12788                                            };
12789    
12790                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H, args);
12791                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H,
12792                                            args);
12793                            }
12794    
12795                            if ((dlFolderModelImpl.getColumnBitmask() &
12796                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S.getColumnBitmask()) != 0) {
12797                                    Object[] args = new Object[] {
12798                                                    dlFolderModelImpl.getOriginalGroupId(),
12799                                                    dlFolderModelImpl.getOriginalParentFolderId(),
12800                                                    dlFolderModelImpl.getOriginalHidden(),
12801                                                    dlFolderModelImpl.getOriginalStatus()
12802                                            };
12803    
12804                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_H_S, args);
12805                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S,
12806                                            args);
12807    
12808                                    args = new Object[] {
12809                                                    dlFolderModelImpl.getGroupId(),
12810                                                    dlFolderModelImpl.getParentFolderId(),
12811                                                    dlFolderModelImpl.getHidden(),
12812                                                    dlFolderModelImpl.getStatus()
12813                                            };
12814    
12815                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_H_S, args);
12816                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S,
12817                                            args);
12818                            }
12819    
12820                            if ((dlFolderModelImpl.getColumnBitmask() &
12821                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S.getColumnBitmask()) != 0) {
12822                                    Object[] args = new Object[] {
12823                                                    dlFolderModelImpl.getOriginalGroupId(),
12824                                                    dlFolderModelImpl.getOriginalMountPoint(),
12825                                                    dlFolderModelImpl.getOriginalParentFolderId(),
12826                                                    dlFolderModelImpl.getOriginalHidden(),
12827                                                    dlFolderModelImpl.getOriginalStatus()
12828                                            };
12829    
12830                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H_S, args);
12831                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S,
12832                                            args);
12833    
12834                                    args = new Object[] {
12835                                                    dlFolderModelImpl.getGroupId(),
12836                                                    dlFolderModelImpl.getMountPoint(),
12837                                                    dlFolderModelImpl.getParentFolderId(),
12838                                                    dlFolderModelImpl.getHidden(),
12839                                                    dlFolderModelImpl.getStatus()
12840                                            };
12841    
12842                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H_S, args);
12843                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S,
12844                                            args);
12845                            }
12846                    }
12847    
12848                    entityCache.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12849                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder, false);
12850    
12851                    clearUniqueFindersCache(dlFolderModelImpl);
12852                    cacheUniqueFindersCache(dlFolderModelImpl, isNew);
12853    
12854                    dlFolder.resetOriginalValues();
12855    
12856                    return dlFolder;
12857            }
12858    
12859            protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
12860                    if (dlFolder instanceof DLFolderImpl) {
12861                            return dlFolder;
12862                    }
12863    
12864                    DLFolderImpl dlFolderImpl = new DLFolderImpl();
12865    
12866                    dlFolderImpl.setNew(dlFolder.isNew());
12867                    dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
12868    
12869                    dlFolderImpl.setUuid(dlFolder.getUuid());
12870                    dlFolderImpl.setFolderId(dlFolder.getFolderId());
12871                    dlFolderImpl.setGroupId(dlFolder.getGroupId());
12872                    dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
12873                    dlFolderImpl.setUserId(dlFolder.getUserId());
12874                    dlFolderImpl.setUserName(dlFolder.getUserName());
12875                    dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
12876                    dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
12877                    dlFolderImpl.setRepositoryId(dlFolder.getRepositoryId());
12878                    dlFolderImpl.setMountPoint(dlFolder.isMountPoint());
12879                    dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
12880                    dlFolderImpl.setTreePath(dlFolder.getTreePath());
12881                    dlFolderImpl.setName(dlFolder.getName());
12882                    dlFolderImpl.setDescription(dlFolder.getDescription());
12883                    dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
12884                    dlFolderImpl.setDefaultFileEntryTypeId(dlFolder.getDefaultFileEntryTypeId());
12885                    dlFolderImpl.setHidden(dlFolder.isHidden());
12886                    dlFolderImpl.setRestrictionType(dlFolder.getRestrictionType());
12887                    dlFolderImpl.setLastPublishDate(dlFolder.getLastPublishDate());
12888                    dlFolderImpl.setStatus(dlFolder.getStatus());
12889                    dlFolderImpl.setStatusByUserId(dlFolder.getStatusByUserId());
12890                    dlFolderImpl.setStatusByUserName(dlFolder.getStatusByUserName());
12891                    dlFolderImpl.setStatusDate(dlFolder.getStatusDate());
12892    
12893                    return dlFolderImpl;
12894            }
12895    
12896            /**
12897             * Returns the document library folder with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found.
12898             *
12899             * @param primaryKey the primary key of the document library folder
12900             * @return the document library folder
12901             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
12902             */
12903            @Override
12904            public DLFolder findByPrimaryKey(Serializable primaryKey)
12905                    throws NoSuchFolderException {
12906                    DLFolder dlFolder = fetchByPrimaryKey(primaryKey);
12907    
12908                    if (dlFolder == null) {
12909                            if (_log.isDebugEnabled()) {
12910                                    _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12911                            }
12912    
12913                            throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12914                                    primaryKey);
12915                    }
12916    
12917                    return dlFolder;
12918            }
12919    
12920            /**
12921             * Returns the document library folder with the primary key or throws a {@link NoSuchFolderException} if it could not be found.
12922             *
12923             * @param folderId the primary key of the document library folder
12924             * @return the document library folder
12925             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
12926             */
12927            @Override
12928            public DLFolder findByPrimaryKey(long folderId)
12929                    throws NoSuchFolderException {
12930                    return findByPrimaryKey((Serializable)folderId);
12931            }
12932    
12933            /**
12934             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
12935             *
12936             * @param primaryKey the primary key of the document library folder
12937             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
12938             */
12939            @Override
12940            public DLFolder fetchByPrimaryKey(Serializable primaryKey) {
12941                    DLFolder dlFolder = (DLFolder)entityCache.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12942                                    DLFolderImpl.class, primaryKey);
12943    
12944                    if (dlFolder == _nullDLFolder) {
12945                            return null;
12946                    }
12947    
12948                    if (dlFolder == null) {
12949                            Session session = null;
12950    
12951                            try {
12952                                    session = openSession();
12953    
12954                                    dlFolder = (DLFolder)session.get(DLFolderImpl.class, primaryKey);
12955    
12956                                    if (dlFolder != null) {
12957                                            cacheResult(dlFolder);
12958                                    }
12959                                    else {
12960                                            entityCache.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12961                                                    DLFolderImpl.class, primaryKey, _nullDLFolder);
12962                                    }
12963                            }
12964                            catch (Exception e) {
12965                                    entityCache.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
12966                                            DLFolderImpl.class, primaryKey);
12967    
12968                                    throw processException(e);
12969                            }
12970                            finally {
12971                                    closeSession(session);
12972                            }
12973                    }
12974    
12975                    return dlFolder;
12976            }
12977    
12978            /**
12979             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
12980             *
12981             * @param folderId the primary key of the document library folder
12982             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
12983             */
12984            @Override
12985            public DLFolder fetchByPrimaryKey(long folderId) {
12986                    return fetchByPrimaryKey((Serializable)folderId);
12987            }
12988    
12989            @Override
12990            public Map<Serializable, DLFolder> fetchByPrimaryKeys(
12991                    Set<Serializable> primaryKeys) {
12992                    if (primaryKeys.isEmpty()) {
12993                            return Collections.emptyMap();
12994                    }
12995    
12996                    Map<Serializable, DLFolder> map = new HashMap<Serializable, DLFolder>();
12997    
12998                    if (primaryKeys.size() == 1) {
12999                            Iterator<Serializable> iterator = primaryKeys.iterator();
13000    
13001                            Serializable primaryKey = iterator.next();
13002    
13003                            DLFolder dlFolder = fetchByPrimaryKey(primaryKey);
13004    
13005                            if (dlFolder != null) {
13006                                    map.put(primaryKey, dlFolder);
13007                            }
13008    
13009                            return map;
13010                    }
13011    
13012                    Set<Serializable> uncachedPrimaryKeys = null;
13013    
13014                    for (Serializable primaryKey : primaryKeys) {
13015                            DLFolder dlFolder = (DLFolder)entityCache.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
13016                                            DLFolderImpl.class, primaryKey);
13017    
13018                            if (dlFolder == null) {
13019                                    if (uncachedPrimaryKeys == null) {
13020                                            uncachedPrimaryKeys = new HashSet<Serializable>();
13021                                    }
13022    
13023                                    uncachedPrimaryKeys.add(primaryKey);
13024                            }
13025                            else {
13026                                    map.put(primaryKey, dlFolder);
13027                            }
13028                    }
13029    
13030                    if (uncachedPrimaryKeys == null) {
13031                            return map;
13032                    }
13033    
13034                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
13035                                    1);
13036    
13037                    query.append(_SQL_SELECT_DLFOLDER_WHERE_PKS_IN);
13038    
13039                    for (Serializable primaryKey : uncachedPrimaryKeys) {
13040                            query.append(String.valueOf(primaryKey));
13041    
13042                            query.append(StringPool.COMMA);
13043                    }
13044    
13045                    query.setIndex(query.index() - 1);
13046    
13047                    query.append(StringPool.CLOSE_PARENTHESIS);
13048    
13049                    String sql = query.toString();
13050    
13051                    Session session = null;
13052    
13053                    try {
13054                            session = openSession();
13055    
13056                            Query q = session.createQuery(sql);
13057    
13058                            for (DLFolder dlFolder : (List<DLFolder>)q.list()) {
13059                                    map.put(dlFolder.getPrimaryKeyObj(), dlFolder);
13060    
13061                                    cacheResult(dlFolder);
13062    
13063                                    uncachedPrimaryKeys.remove(dlFolder.getPrimaryKeyObj());
13064                            }
13065    
13066                            for (Serializable primaryKey : uncachedPrimaryKeys) {
13067                                    entityCache.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
13068                                            DLFolderImpl.class, primaryKey, _nullDLFolder);
13069                            }
13070                    }
13071                    catch (Exception e) {
13072                            throw processException(e);
13073                    }
13074                    finally {
13075                            closeSession(session);
13076                    }
13077    
13078                    return map;
13079            }
13080    
13081            /**
13082             * Returns all the document library folders.
13083             *
13084             * @return the document library folders
13085             */
13086            @Override
13087            public List<DLFolder> findAll() {
13088                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13089            }
13090    
13091            /**
13092             * Returns a range of all the document library folders.
13093             *
13094             * <p>
13095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13096             * </p>
13097             *
13098             * @param start the lower bound of the range of document library folders
13099             * @param end the upper bound of the range of document library folders (not inclusive)
13100             * @return the range of document library folders
13101             */
13102            @Override
13103            public List<DLFolder> findAll(int start, int end) {
13104                    return findAll(start, end, null);
13105            }
13106    
13107            /**
13108             * Returns an ordered range of all the document library folders.
13109             *
13110             * <p>
13111             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13112             * </p>
13113             *
13114             * @param start the lower bound of the range of document library folders
13115             * @param end the upper bound of the range of document library folders (not inclusive)
13116             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13117             * @return the ordered range of document library folders
13118             */
13119            @Override
13120            public List<DLFolder> findAll(int start, int end,
13121                    OrderByComparator<DLFolder> orderByComparator) {
13122                    return findAll(start, end, orderByComparator, true);
13123            }
13124    
13125            /**
13126             * Returns an ordered range of all the document library folders.
13127             *
13128             * <p>
13129             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13130             * </p>
13131             *
13132             * @param start the lower bound of the range of document library folders
13133             * @param end the upper bound of the range of document library folders (not inclusive)
13134             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13135             * @param retrieveFromCache whether to retrieve from the finder cache
13136             * @return the ordered range of document library folders
13137             */
13138            @Override
13139            public List<DLFolder> findAll(int start, int end,
13140                    OrderByComparator<DLFolder> orderByComparator, boolean retrieveFromCache) {
13141                    boolean pagination = true;
13142                    FinderPath finderPath = null;
13143                    Object[] finderArgs = null;
13144    
13145                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13146                                    (orderByComparator == null)) {
13147                            pagination = false;
13148                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
13149                            finderArgs = FINDER_ARGS_EMPTY;
13150                    }
13151                    else {
13152                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
13153                            finderArgs = new Object[] { start, end, orderByComparator };
13154                    }
13155    
13156                    List<DLFolder> list = null;
13157    
13158                    if (retrieveFromCache) {
13159                            list = (List<DLFolder>)finderCache.getResult(finderPath,
13160                                            finderArgs, this);
13161                    }
13162    
13163                    if (list == null) {
13164                            StringBundler query = null;
13165                            String sql = null;
13166    
13167                            if (orderByComparator != null) {
13168                                    query = new StringBundler(2 +
13169                                                    (orderByComparator.getOrderByFields().length * 2));
13170    
13171                                    query.append(_SQL_SELECT_DLFOLDER);
13172    
13173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13174                                            orderByComparator);
13175    
13176                                    sql = query.toString();
13177                            }
13178                            else {
13179                                    sql = _SQL_SELECT_DLFOLDER;
13180    
13181                                    if (pagination) {
13182                                            sql = sql.concat(DLFolderModelImpl.ORDER_BY_JPQL);
13183                                    }
13184                            }
13185    
13186                            Session session = null;
13187    
13188                            try {
13189                                    session = openSession();
13190    
13191                                    Query q = session.createQuery(sql);
13192    
13193                                    if (!pagination) {
13194                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
13195                                                            start, end, false);
13196    
13197                                            Collections.sort(list);
13198    
13199                                            list = Collections.unmodifiableList(list);
13200                                    }
13201                                    else {
13202                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
13203                                                            start, end);
13204                                    }
13205    
13206                                    cacheResult(list);
13207    
13208                                    finderCache.putResult(finderPath, finderArgs, list);
13209                            }
13210                            catch (Exception e) {
13211                                    finderCache.removeResult(finderPath, finderArgs);
13212    
13213                                    throw processException(e);
13214                            }
13215                            finally {
13216                                    closeSession(session);
13217                            }
13218                    }
13219    
13220                    return list;
13221            }
13222    
13223            /**
13224             * Removes all the document library folders from the database.
13225             *
13226             */
13227            @Override
13228            public void removeAll() {
13229                    for (DLFolder dlFolder : findAll()) {
13230                            remove(dlFolder);
13231                    }
13232            }
13233    
13234            /**
13235             * Returns the number of document library folders.
13236             *
13237             * @return the number of document library folders
13238             */
13239            @Override
13240            public int countAll() {
13241                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
13242                                    FINDER_ARGS_EMPTY, this);
13243    
13244                    if (count == null) {
13245                            Session session = null;
13246    
13247                            try {
13248                                    session = openSession();
13249    
13250                                    Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
13251    
13252                                    count = (Long)q.uniqueResult();
13253    
13254                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
13255                                            count);
13256                            }
13257                            catch (Exception e) {
13258                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
13259                                            FINDER_ARGS_EMPTY);
13260    
13261                                    throw processException(e);
13262                            }
13263                            finally {
13264                                    closeSession(session);
13265                            }
13266                    }
13267    
13268                    return count.intValue();
13269            }
13270    
13271            /**
13272             * Returns the primaryKeys of document library file entry types associated with the document library folder.
13273             *
13274             * @param pk the primary key of the document library folder
13275             * @return long[] of the primaryKeys of document library file entry types associated with the document library folder
13276             */
13277            @Override
13278            public long[] getDLFileEntryTypePrimaryKeys(long pk) {
13279                    long[] pks = dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(pk);
13280    
13281                    return pks.clone();
13282            }
13283    
13284            /**
13285             * Returns all the document library file entry types associated with the document library folder.
13286             *
13287             * @param pk the primary key of the document library folder
13288             * @return the document library file entry types associated with the document library folder
13289             */
13290            @Override
13291            public List<com.liferay.document.library.kernel.model.DLFileEntryType> getDLFileEntryTypes(
13292                    long pk) {
13293                    return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
13294            }
13295    
13296            /**
13297             * Returns a range of all the document library file entry types associated with the document library folder.
13298             *
13299             * <p>
13300             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13301             * </p>
13302             *
13303             * @param pk the primary key of the document library folder
13304             * @param start the lower bound of the range of document library folders
13305             * @param end the upper bound of the range of document library folders (not inclusive)
13306             * @return the range of document library file entry types associated with the document library folder
13307             */
13308            @Override
13309            public List<com.liferay.document.library.kernel.model.DLFileEntryType> getDLFileEntryTypes(
13310                    long pk, int start, int end) {
13311                    return getDLFileEntryTypes(pk, start, end, null);
13312            }
13313    
13314            /**
13315             * Returns an ordered range of all the document library file entry types associated with the document library folder.
13316             *
13317             * <p>
13318             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFolderModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13319             * </p>
13320             *
13321             * @param pk the primary key of the document library folder
13322             * @param start the lower bound of the range of document library folders
13323             * @param end the upper bound of the range of document library folders (not inclusive)
13324             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13325             * @return the ordered range of document library file entry types associated with the document library folder
13326             */
13327            @Override
13328            public List<com.liferay.document.library.kernel.model.DLFileEntryType> getDLFileEntryTypes(
13329                    long pk, int start, int end,
13330                    OrderByComparator<com.liferay.document.library.kernel.model.DLFileEntryType> orderByComparator) {
13331                    return dlFolderToDLFileEntryTypeTableMapper.getRightBaseModels(pk,
13332                            start, end, orderByComparator);
13333            }
13334    
13335            /**
13336             * Returns the number of document library file entry types associated with the document library folder.
13337             *
13338             * @param pk the primary key of the document library folder
13339             * @return the number of document library file entry types associated with the document library folder
13340             */
13341            @Override
13342            public int getDLFileEntryTypesSize(long pk) {
13343                    long[] pks = dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(pk);
13344    
13345                    return pks.length;
13346            }
13347    
13348            /**
13349             * Returns <code>true</code> if the document library file entry type is associated with the document library folder.
13350             *
13351             * @param pk the primary key of the document library folder
13352             * @param dlFileEntryTypePK the primary key of the document library file entry type
13353             * @return <code>true</code> if the document library file entry type is associated with the document library folder; <code>false</code> otherwise
13354             */
13355            @Override
13356            public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK) {
13357                    return dlFolderToDLFileEntryTypeTableMapper.containsTableMapping(pk,
13358                            dlFileEntryTypePK);
13359            }
13360    
13361            /**
13362             * Returns <code>true</code> if the document library folder has any document library file entry types associated with it.
13363             *
13364             * @param pk the primary key of the document library folder to check for associations with document library file entry types
13365             * @return <code>true</code> if the document library folder has any document library file entry types associated with it; <code>false</code> otherwise
13366             */
13367            @Override
13368            public boolean containsDLFileEntryTypes(long pk) {
13369                    if (getDLFileEntryTypesSize(pk) > 0) {
13370                            return true;
13371                    }
13372                    else {
13373                            return false;
13374                    }
13375            }
13376    
13377            /**
13378             * Adds an association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13379             *
13380             * @param pk the primary key of the document library folder
13381             * @param dlFileEntryTypePK the primary key of the document library file entry type
13382             */
13383            @Override
13384            public void addDLFileEntryType(long pk, long dlFileEntryTypePK) {
13385                    DLFolder dlFolder = fetchByPrimaryKey(pk);
13386    
13387                    if (dlFolder == null) {
13388                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(companyProvider.getCompanyId(),
13389                                    pk, dlFileEntryTypePK);
13390                    }
13391                    else {
13392                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(dlFolder.getCompanyId(),
13393                                    pk, dlFileEntryTypePK);
13394                    }
13395            }
13396    
13397            /**
13398             * Adds an association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13399             *
13400             * @param pk the primary key of the document library folder
13401             * @param dlFileEntryType the document library file entry type
13402             */
13403            @Override
13404            public void addDLFileEntryType(long pk,
13405                    com.liferay.document.library.kernel.model.DLFileEntryType dlFileEntryType) {
13406                    DLFolder dlFolder = fetchByPrimaryKey(pk);
13407    
13408                    if (dlFolder == null) {
13409                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(companyProvider.getCompanyId(),
13410                                    pk, dlFileEntryType.getPrimaryKey());
13411                    }
13412                    else {
13413                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(dlFolder.getCompanyId(),
13414                                    pk, dlFileEntryType.getPrimaryKey());
13415                    }
13416            }
13417    
13418            /**
13419             * Adds an association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13420             *
13421             * @param pk the primary key of the document library folder
13422             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
13423             */
13424            @Override
13425            public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
13426                    long companyId = 0;
13427    
13428                    DLFolder dlFolder = fetchByPrimaryKey(pk);
13429    
13430                    if (dlFolder == null) {
13431                            companyId = companyProvider.getCompanyId();
13432                    }
13433                    else {
13434                            companyId = dlFolder.getCompanyId();
13435                    }
13436    
13437                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
13438                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(companyId, pk,
13439                                    dlFileEntryTypePK);
13440                    }
13441            }
13442    
13443            /**
13444             * Adds an association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13445             *
13446             * @param pk the primary key of the document library folder
13447             * @param dlFileEntryTypes the document library file entry types
13448             */
13449            @Override
13450            public void addDLFileEntryTypes(long pk,
13451                    List<com.liferay.document.library.kernel.model.DLFileEntryType> dlFileEntryTypes) {
13452                    long companyId = 0;
13453    
13454                    DLFolder dlFolder = fetchByPrimaryKey(pk);
13455    
13456                    if (dlFolder == null) {
13457                            companyId = companyProvider.getCompanyId();
13458                    }
13459                    else {
13460                            companyId = dlFolder.getCompanyId();
13461                    }
13462    
13463                    for (com.liferay.document.library.kernel.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
13464                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(companyId, pk,
13465                                    dlFileEntryType.getPrimaryKey());
13466                    }
13467            }
13468    
13469            /**
13470             * Clears all associations between the document library folder and its document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13471             *
13472             * @param pk the primary key of the document library folder to clear the associated document library file entry types from
13473             */
13474            @Override
13475            public void clearDLFileEntryTypes(long pk) {
13476                    dlFolderToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
13477            }
13478    
13479            /**
13480             * Removes the association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13481             *
13482             * @param pk the primary key of the document library folder
13483             * @param dlFileEntryTypePK the primary key of the document library file entry type
13484             */
13485            @Override
13486            public void removeDLFileEntryType(long pk, long dlFileEntryTypePK) {
13487                    dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
13488                            dlFileEntryTypePK);
13489            }
13490    
13491            /**
13492             * Removes the association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13493             *
13494             * @param pk the primary key of the document library folder
13495             * @param dlFileEntryType the document library file entry type
13496             */
13497            @Override
13498            public void removeDLFileEntryType(long pk,
13499                    com.liferay.document.library.kernel.model.DLFileEntryType dlFileEntryType) {
13500                    dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
13501                            dlFileEntryType.getPrimaryKey());
13502            }
13503    
13504            /**
13505             * Removes the association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13506             *
13507             * @param pk the primary key of the document library folder
13508             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
13509             */
13510            @Override
13511            public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
13512                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
13513                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
13514                                    dlFileEntryTypePK);
13515                    }
13516            }
13517    
13518            /**
13519             * Removes the association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13520             *
13521             * @param pk the primary key of the document library folder
13522             * @param dlFileEntryTypes the document library file entry types
13523             */
13524            @Override
13525            public void removeDLFileEntryTypes(long pk,
13526                    List<com.liferay.document.library.kernel.model.DLFileEntryType> dlFileEntryTypes) {
13527                    for (com.liferay.document.library.kernel.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
13528                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
13529                                    dlFileEntryType.getPrimaryKey());
13530                    }
13531            }
13532    
13533            /**
13534             * Sets the document library file entry types associated with the document library folder, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13535             *
13536             * @param pk the primary key of the document library folder
13537             * @param dlFileEntryTypePKs the primary keys of the document library file entry types to be associated with the document library folder
13538             */
13539            @Override
13540            public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
13541                    Set<Long> newDLFileEntryTypePKsSet = SetUtil.fromArray(dlFileEntryTypePKs);
13542                    Set<Long> oldDLFileEntryTypePKsSet = SetUtil.fromArray(dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(
13543                                            pk));
13544    
13545                    Set<Long> removeDLFileEntryTypePKsSet = new HashSet<Long>(oldDLFileEntryTypePKsSet);
13546    
13547                    removeDLFileEntryTypePKsSet.removeAll(newDLFileEntryTypePKsSet);
13548    
13549                    for (long removeDLFileEntryTypePK : removeDLFileEntryTypePKsSet) {
13550                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
13551                                    removeDLFileEntryTypePK);
13552                    }
13553    
13554                    newDLFileEntryTypePKsSet.removeAll(oldDLFileEntryTypePKsSet);
13555    
13556                    long companyId = 0;
13557    
13558                    DLFolder dlFolder = fetchByPrimaryKey(pk);
13559    
13560                    if (dlFolder == null) {
13561                            companyId = companyProvider.getCompanyId();
13562                    }
13563                    else {
13564                            companyId = dlFolder.getCompanyId();
13565                    }
13566    
13567                    for (long newDLFileEntryTypePK : newDLFileEntryTypePKsSet) {
13568                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(companyId, pk,
13569                                    newDLFileEntryTypePK);
13570                    }
13571            }
13572    
13573            /**
13574             * Sets the document library file entry types associated with the document library folder, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
13575             *
13576             * @param pk the primary key of the document library folder
13577             * @param dlFileEntryTypes the document library file entry types to be associated with the document library folder
13578             */
13579            @Override
13580            public void setDLFileEntryTypes(long pk,
13581                    List<com.liferay.document.library.kernel.model.DLFileEntryType> dlFileEntryTypes) {
13582                    try {
13583                            long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
13584    
13585                            for (int i = 0; i < dlFileEntryTypes.size(); i++) {
13586                                    com.liferay.document.library.kernel.model.DLFileEntryType dlFileEntryType =
13587                                            dlFileEntryTypes.get(i);
13588    
13589                                    dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
13590                            }
13591    
13592                            setDLFileEntryTypes(pk, dlFileEntryTypePKs);
13593                    }
13594                    catch (Exception e) {
13595                            throw processException(e);
13596                    }
13597            }
13598    
13599            @Override
13600            public Set<String> getBadColumnNames() {
13601                    return _badColumnNames;
13602            }
13603    
13604            @Override
13605            protected Map<String, Integer> getTableColumnsMap() {
13606                    return DLFolderModelImpl.TABLE_COLUMNS_MAP;
13607            }
13608    
13609            /**
13610             * Initializes the document library folder persistence.
13611             */
13612            public void afterPropertiesSet() {
13613                    dlFolderToDLFileEntryTypeTableMapper = TableMapperFactory.getTableMapper("DLFileEntryTypes_DLFolders",
13614                                    "companyId", "folderId", "fileEntryTypeId", this,
13615                                    dlFileEntryTypePersistence);
13616            }
13617    
13618            public void destroy() {
13619                    entityCache.removeCache(DLFolderImpl.class.getName());
13620                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
13621                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13622                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13623    
13624                    TableMapperFactory.removeTableMapper("DLFileEntryTypes_DLFolders");
13625            }
13626    
13627            @BeanReference(type = CompanyProviderWrapper.class)
13628            protected CompanyProvider companyProvider;
13629            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
13630            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
13631            @BeanReference(type = DLFileEntryTypePersistence.class)
13632            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
13633            protected TableMapper<DLFolder, com.liferay.document.library.kernel.model.DLFileEntryType> dlFolderToDLFileEntryTypeTableMapper;
13634            private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
13635            private static final String _SQL_SELECT_DLFOLDER_WHERE_PKS_IN = "SELECT dlFolder FROM DLFolder dlFolder WHERE folderId IN (";
13636            private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
13637            private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
13638            private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
13639            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFolder.folderId";
13640            private static final String _FILTER_SQL_SELECT_DLFOLDER_WHERE = "SELECT DISTINCT {dlFolder.*} FROM DLFolder dlFolder WHERE ";
13641            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
13642                    "SELECT {DLFolder.*} FROM (SELECT DISTINCT dlFolder.folderId FROM DLFolder dlFolder WHERE ";
13643            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
13644                    ") TEMP_TABLE INNER JOIN DLFolder ON TEMP_TABLE.folderId = DLFolder.folderId";
13645            private static final String _FILTER_SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(DISTINCT dlFolder.folderId) AS COUNT_VALUE FROM DLFolder dlFolder WHERE ";
13646            private static final String _FILTER_ENTITY_ALIAS = "dlFolder";
13647            private static final String _FILTER_ENTITY_TABLE = "DLFolder";
13648            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
13649            private static final String _ORDER_BY_ENTITY_TABLE = "DLFolder.";
13650            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
13651            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
13652            private static final Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
13653            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
13654                                    "uuid", "hidden"
13655                            });
13656            private static final DLFolder _nullDLFolder = new DLFolderImpl() {
13657                            @Override
13658                            public Object clone() {
13659                                    return this;
13660                            }
13661    
13662                            @Override
13663                            public CacheModel<DLFolder> toCacheModel() {
13664                                    return _nullDLFolderCacheModel;
13665                            }
13666                    };
13667    
13668            private static final CacheModel<DLFolder> _nullDLFolderCacheModel = new CacheModel<DLFolder>() {
13669                            @Override
13670                            public DLFolder toEntityModel() {
13671                                    return _nullDLFolder;
13672                            }
13673                    };
13674    }