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.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.service.ServiceContext;
040    import com.liferay.portal.service.ServiceContextThreadLocal;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    import com.liferay.portal.service.persistence.impl.TableMapper;
043    import com.liferay.portal.service.persistence.impl.TableMapperFactory;
044    
045    import com.liferay.portlet.documentlibrary.NoSuchFolderException;
046    import com.liferay.portlet.documentlibrary.model.DLFolder;
047    import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
048    import com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl;
049    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
050    import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
051    
052    import java.io.Serializable;
053    
054    import java.util.Collections;
055    import java.util.Date;
056    import java.util.HashMap;
057    import java.util.HashSet;
058    import java.util.Iterator;
059    import java.util.List;
060    import java.util.Map;
061    import java.util.Set;
062    
063    /**
064     * The persistence implementation for the document library folder service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see DLFolderPersistence
072     * @see com.liferay.portlet.documentlibrary.service.persistence.DLFolderUtil
073     * @generated
074     */
075    @ProviderType
076    public class DLFolderPersistenceImpl extends BasePersistenceImpl<DLFolder>
077            implements DLFolderPersistence {
078            /*
079             * NOTE FOR DEVELOPERS:
080             *
081             * 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.
082             */
083            public static final String FINDER_CLASS_NAME_ENTITY = DLFolderImpl.class.getName();
084            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List1";
086            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087                    ".List2";
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
089                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
092                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
095                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
098                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
100                            new String[] {
101                                    String.class.getName(),
102                                    
103                            Integer.class.getName(), Integer.class.getName(),
104                                    OrderByComparator.class.getName()
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
107                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
109                            new String[] { String.class.getName() },
110                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
111                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
112                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
114                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
116                            new String[] { String.class.getName() });
117    
118            /**
119             * Returns all the document library folders where uuid = &#63;.
120             *
121             * @param uuid the uuid
122             * @return the matching document library folders
123             */
124            @Override
125            public List<DLFolder> findByUuid(String uuid) {
126                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
127            }
128    
129            /**
130             * Returns a range of all the document library folders where uuid = &#63;.
131             *
132             * <p>
133             * 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.
134             * </p>
135             *
136             * @param uuid the uuid
137             * @param start the lower bound of the range of document library folders
138             * @param end the upper bound of the range of document library folders (not inclusive)
139             * @return the range of matching document library folders
140             */
141            @Override
142            public List<DLFolder> findByUuid(String uuid, int start, int end) {
143                    return findByUuid(uuid, start, end, null);
144            }
145    
146            /**
147             * Returns an ordered range of all the document library folders where uuid = &#63;.
148             *
149             * <p>
150             * 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.
151             * </p>
152             *
153             * @param uuid the uuid
154             * @param start the lower bound of the range of document library folders
155             * @param end the upper bound of the range of document library folders (not inclusive)
156             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
157             * @return the ordered range of matching document library folders
158             */
159            @Override
160            public List<DLFolder> findByUuid(String uuid, int start, int end,
161                    OrderByComparator<DLFolder> orderByComparator) {
162                    boolean pagination = true;
163                    FinderPath finderPath = null;
164                    Object[] finderArgs = null;
165    
166                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
167                                    (orderByComparator == null)) {
168                            pagination = false;
169                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
170                            finderArgs = new Object[] { uuid };
171                    }
172                    else {
173                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
174                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
175                    }
176    
177                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
178                                    finderArgs, this);
179    
180                    if ((list != null) && !list.isEmpty()) {
181                            for (DLFolder dlFolder : list) {
182                                    if (!Validator.equals(uuid, dlFolder.getUuid())) {
183                                            list = null;
184    
185                                            break;
186                                    }
187                            }
188                    }
189    
190                    if (list == null) {
191                            StringBundler query = null;
192    
193                            if (orderByComparator != null) {
194                                    query = new StringBundler(3 +
195                                                    (orderByComparator.getOrderByFields().length * 3));
196                            }
197                            else {
198                                    query = new StringBundler(3);
199                            }
200    
201                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
202    
203                            boolean bindUuid = false;
204    
205                            if (uuid == null) {
206                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
207                            }
208                            else if (uuid.equals(StringPool.BLANK)) {
209                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
210                            }
211                            else {
212                                    bindUuid = true;
213    
214                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
215                            }
216    
217                            if (orderByComparator != null) {
218                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
219                                            orderByComparator);
220                            }
221                            else
222                             if (pagination) {
223                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
224                            }
225    
226                            String sql = query.toString();
227    
228                            Session session = null;
229    
230                            try {
231                                    session = openSession();
232    
233                                    Query q = session.createQuery(sql);
234    
235                                    QueryPos qPos = QueryPos.getInstance(q);
236    
237                                    if (bindUuid) {
238                                            qPos.add(uuid);
239                                    }
240    
241                                    if (!pagination) {
242                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
243                                                            start, end, false);
244    
245                                            Collections.sort(list);
246    
247                                            list = Collections.unmodifiableList(list);
248                                    }
249                                    else {
250                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
251                                                            start, end);
252                                    }
253    
254                                    cacheResult(list);
255    
256                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
257                            }
258                            catch (Exception e) {
259                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
260    
261                                    throw processException(e);
262                            }
263                            finally {
264                                    closeSession(session);
265                            }
266                    }
267    
268                    return list;
269            }
270    
271            /**
272             * Returns the first document library folder in the ordered set where uuid = &#63;.
273             *
274             * @param uuid the uuid
275             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
276             * @return the first matching document library folder
277             * @throws NoSuchFolderException if a matching document library folder could not be found
278             */
279            @Override
280            public DLFolder findByUuid_First(String uuid,
281                    OrderByComparator<DLFolder> orderByComparator)
282                    throws NoSuchFolderException {
283                    DLFolder dlFolder = fetchByUuid_First(uuid, orderByComparator);
284    
285                    if (dlFolder != null) {
286                            return dlFolder;
287                    }
288    
289                    StringBundler msg = new StringBundler(4);
290    
291                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
292    
293                    msg.append("uuid=");
294                    msg.append(uuid);
295    
296                    msg.append(StringPool.CLOSE_CURLY_BRACE);
297    
298                    throw new NoSuchFolderException(msg.toString());
299            }
300    
301            /**
302             * Returns the first document library folder in the ordered set where uuid = &#63;.
303             *
304             * @param uuid the uuid
305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
306             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
307             */
308            @Override
309            public DLFolder fetchByUuid_First(String uuid,
310                    OrderByComparator<DLFolder> orderByComparator) {
311                    List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
312    
313                    if (!list.isEmpty()) {
314                            return list.get(0);
315                    }
316    
317                    return null;
318            }
319    
320            /**
321             * Returns the last document library folder in the ordered set where uuid = &#63;.
322             *
323             * @param uuid the uuid
324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
325             * @return the last matching document library folder
326             * @throws NoSuchFolderException if a matching document library folder could not be found
327             */
328            @Override
329            public DLFolder findByUuid_Last(String uuid,
330                    OrderByComparator<DLFolder> orderByComparator)
331                    throws NoSuchFolderException {
332                    DLFolder dlFolder = fetchByUuid_Last(uuid, orderByComparator);
333    
334                    if (dlFolder != null) {
335                            return dlFolder;
336                    }
337    
338                    StringBundler msg = new StringBundler(4);
339    
340                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
341    
342                    msg.append("uuid=");
343                    msg.append(uuid);
344    
345                    msg.append(StringPool.CLOSE_CURLY_BRACE);
346    
347                    throw new NoSuchFolderException(msg.toString());
348            }
349    
350            /**
351             * Returns the last document library folder in the ordered set where uuid = &#63;.
352             *
353             * @param uuid the uuid
354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
355             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
356             */
357            @Override
358            public DLFolder fetchByUuid_Last(String uuid,
359                    OrderByComparator<DLFolder> orderByComparator) {
360                    int count = countByUuid(uuid);
361    
362                    if (count == 0) {
363                            return null;
364                    }
365    
366                    List<DLFolder> list = findByUuid(uuid, count - 1, count,
367                                    orderByComparator);
368    
369                    if (!list.isEmpty()) {
370                            return list.get(0);
371                    }
372    
373                    return null;
374            }
375    
376            /**
377             * Returns the document library folders before and after the current document library folder in the ordered set where uuid = &#63;.
378             *
379             * @param folderId the primary key of the current document library folder
380             * @param uuid the uuid
381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
382             * @return the previous, current, and next document library folder
383             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
384             */
385            @Override
386            public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
387                    OrderByComparator<DLFolder> orderByComparator)
388                    throws NoSuchFolderException {
389                    DLFolder dlFolder = findByPrimaryKey(folderId);
390    
391                    Session session = null;
392    
393                    try {
394                            session = openSession();
395    
396                            DLFolder[] array = new DLFolderImpl[3];
397    
398                            array[0] = getByUuid_PrevAndNext(session, dlFolder, uuid,
399                                            orderByComparator, true);
400    
401                            array[1] = dlFolder;
402    
403                            array[2] = getByUuid_PrevAndNext(session, dlFolder, uuid,
404                                            orderByComparator, false);
405    
406                            return array;
407                    }
408                    catch (Exception e) {
409                            throw processException(e);
410                    }
411                    finally {
412                            closeSession(session);
413                    }
414            }
415    
416            protected DLFolder getByUuid_PrevAndNext(Session session,
417                    DLFolder dlFolder, String uuid,
418                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
419                    StringBundler query = null;
420    
421                    if (orderByComparator != null) {
422                            query = new StringBundler(6 +
423                                            (orderByComparator.getOrderByFields().length * 6));
424                    }
425                    else {
426                            query = new StringBundler(3);
427                    }
428    
429                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
430    
431                    boolean bindUuid = false;
432    
433                    if (uuid == null) {
434                            query.append(_FINDER_COLUMN_UUID_UUID_1);
435                    }
436                    else if (uuid.equals(StringPool.BLANK)) {
437                            query.append(_FINDER_COLUMN_UUID_UUID_3);
438                    }
439                    else {
440                            bindUuid = true;
441    
442                            query.append(_FINDER_COLUMN_UUID_UUID_2);
443                    }
444    
445                    if (orderByComparator != null) {
446                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
447    
448                            if (orderByConditionFields.length > 0) {
449                                    query.append(WHERE_AND);
450                            }
451    
452                            for (int i = 0; i < orderByConditionFields.length; i++) {
453                                    query.append(_ORDER_BY_ENTITY_ALIAS);
454                                    query.append(orderByConditionFields[i]);
455    
456                                    if ((i + 1) < orderByConditionFields.length) {
457                                            if (orderByComparator.isAscending() ^ previous) {
458                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
459                                            }
460                                            else {
461                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
462                                            }
463                                    }
464                                    else {
465                                            if (orderByComparator.isAscending() ^ previous) {
466                                                    query.append(WHERE_GREATER_THAN);
467                                            }
468                                            else {
469                                                    query.append(WHERE_LESSER_THAN);
470                                            }
471                                    }
472                            }
473    
474                            query.append(ORDER_BY_CLAUSE);
475    
476                            String[] orderByFields = orderByComparator.getOrderByFields();
477    
478                            for (int i = 0; i < orderByFields.length; i++) {
479                                    query.append(_ORDER_BY_ENTITY_ALIAS);
480                                    query.append(orderByFields[i]);
481    
482                                    if ((i + 1) < orderByFields.length) {
483                                            if (orderByComparator.isAscending() ^ previous) {
484                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
485                                            }
486                                            else {
487                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
488                                            }
489                                    }
490                                    else {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(ORDER_BY_ASC);
493                                            }
494                                            else {
495                                                    query.append(ORDER_BY_DESC);
496                                            }
497                                    }
498                            }
499                    }
500                    else {
501                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
502                    }
503    
504                    String sql = query.toString();
505    
506                    Query q = session.createQuery(sql);
507    
508                    q.setFirstResult(0);
509                    q.setMaxResults(2);
510    
511                    QueryPos qPos = QueryPos.getInstance(q);
512    
513                    if (bindUuid) {
514                            qPos.add(uuid);
515                    }
516    
517                    if (orderByComparator != null) {
518                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
519    
520                            for (Object value : values) {
521                                    qPos.add(value);
522                            }
523                    }
524    
525                    List<DLFolder> list = q.list();
526    
527                    if (list.size() == 2) {
528                            return list.get(1);
529                    }
530                    else {
531                            return null;
532                    }
533            }
534    
535            /**
536             * Removes all the document library folders where uuid = &#63; from the database.
537             *
538             * @param uuid the uuid
539             */
540            @Override
541            public void removeByUuid(String uuid) {
542                    for (DLFolder dlFolder : findByUuid(uuid, QueryUtil.ALL_POS,
543                                    QueryUtil.ALL_POS, null)) {
544                            remove(dlFolder);
545                    }
546            }
547    
548            /**
549             * Returns the number of document library folders where uuid = &#63;.
550             *
551             * @param uuid the uuid
552             * @return the number of matching document library folders
553             */
554            @Override
555            public int countByUuid(String uuid) {
556                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
557    
558                    Object[] finderArgs = new Object[] { uuid };
559    
560                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
561                                    this);
562    
563                    if (count == null) {
564                            StringBundler query = new StringBundler(2);
565    
566                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
567    
568                            boolean bindUuid = false;
569    
570                            if (uuid == null) {
571                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
572                            }
573                            else if (uuid.equals(StringPool.BLANK)) {
574                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
575                            }
576                            else {
577                                    bindUuid = true;
578    
579                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
580                            }
581    
582                            String sql = query.toString();
583    
584                            Session session = null;
585    
586                            try {
587                                    session = openSession();
588    
589                                    Query q = session.createQuery(sql);
590    
591                                    QueryPos qPos = QueryPos.getInstance(q);
592    
593                                    if (bindUuid) {
594                                            qPos.add(uuid);
595                                    }
596    
597                                    count = (Long)q.uniqueResult();
598    
599                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
600                            }
601                            catch (Exception e) {
602                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
603    
604                                    throw processException(e);
605                            }
606                            finally {
607                                    closeSession(session);
608                            }
609                    }
610    
611                    return count.intValue();
612            }
613    
614            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
615            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
616            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '')";
617            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
618                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
619                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
620                            new String[] { String.class.getName(), Long.class.getName() },
621                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
622                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
623            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
624                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
625                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
626                            new String[] { String.class.getName(), Long.class.getName() });
627    
628            /**
629             * Returns the document library folder where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFolderException} if it could not be found.
630             *
631             * @param uuid the uuid
632             * @param groupId the group ID
633             * @return the matching document library folder
634             * @throws NoSuchFolderException if a matching document library folder could not be found
635             */
636            @Override
637            public DLFolder findByUUID_G(String uuid, long groupId)
638                    throws NoSuchFolderException {
639                    DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
640    
641                    if (dlFolder == null) {
642                            StringBundler msg = new StringBundler(6);
643    
644                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
645    
646                            msg.append("uuid=");
647                            msg.append(uuid);
648    
649                            msg.append(", groupId=");
650                            msg.append(groupId);
651    
652                            msg.append(StringPool.CLOSE_CURLY_BRACE);
653    
654                            if (_log.isWarnEnabled()) {
655                                    _log.warn(msg.toString());
656                            }
657    
658                            throw new NoSuchFolderException(msg.toString());
659                    }
660    
661                    return dlFolder;
662            }
663    
664            /**
665             * 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.
666             *
667             * @param uuid the uuid
668             * @param groupId the group ID
669             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
670             */
671            @Override
672            public DLFolder fetchByUUID_G(String uuid, long groupId) {
673                    return fetchByUUID_G(uuid, groupId, true);
674            }
675    
676            /**
677             * 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.
678             *
679             * @param uuid the uuid
680             * @param groupId the group ID
681             * @param retrieveFromCache whether to use the finder cache
682             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
683             */
684            @Override
685            public DLFolder fetchByUUID_G(String uuid, long groupId,
686                    boolean retrieveFromCache) {
687                    Object[] finderArgs = new Object[] { uuid, groupId };
688    
689                    Object result = null;
690    
691                    if (retrieveFromCache) {
692                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
693                                            finderArgs, this);
694                    }
695    
696                    if (result instanceof DLFolder) {
697                            DLFolder dlFolder = (DLFolder)result;
698    
699                            if (!Validator.equals(uuid, dlFolder.getUuid()) ||
700                                            (groupId != dlFolder.getGroupId())) {
701                                    result = null;
702                            }
703                    }
704    
705                    if (result == null) {
706                            StringBundler query = new StringBundler(4);
707    
708                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
709    
710                            boolean bindUuid = false;
711    
712                            if (uuid == null) {
713                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
714                            }
715                            else if (uuid.equals(StringPool.BLANK)) {
716                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
717                            }
718                            else {
719                                    bindUuid = true;
720    
721                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
722                            }
723    
724                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
725    
726                            String sql = query.toString();
727    
728                            Session session = null;
729    
730                            try {
731                                    session = openSession();
732    
733                                    Query q = session.createQuery(sql);
734    
735                                    QueryPos qPos = QueryPos.getInstance(q);
736    
737                                    if (bindUuid) {
738                                            qPos.add(uuid);
739                                    }
740    
741                                    qPos.add(groupId);
742    
743                                    List<DLFolder> list = q.list();
744    
745                                    if (list.isEmpty()) {
746                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
747                                                    finderArgs, list);
748                                    }
749                                    else {
750                                            DLFolder dlFolder = list.get(0);
751    
752                                            result = dlFolder;
753    
754                                            cacheResult(dlFolder);
755    
756                                            if ((dlFolder.getUuid() == null) ||
757                                                            !dlFolder.getUuid().equals(uuid) ||
758                                                            (dlFolder.getGroupId() != groupId)) {
759                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
760                                                            finderArgs, dlFolder);
761                                            }
762                                    }
763                            }
764                            catch (Exception e) {
765                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
766                                            finderArgs);
767    
768                                    throw processException(e);
769                            }
770                            finally {
771                                    closeSession(session);
772                            }
773                    }
774    
775                    if (result instanceof List<?>) {
776                            return null;
777                    }
778                    else {
779                            return (DLFolder)result;
780                    }
781            }
782    
783            /**
784             * Removes the document library folder where uuid = &#63; and groupId = &#63; from the database.
785             *
786             * @param uuid the uuid
787             * @param groupId the group ID
788             * @return the document library folder that was removed
789             */
790            @Override
791            public DLFolder removeByUUID_G(String uuid, long groupId)
792                    throws NoSuchFolderException {
793                    DLFolder dlFolder = findByUUID_G(uuid, groupId);
794    
795                    return remove(dlFolder);
796            }
797    
798            /**
799             * Returns the number of document library folders where uuid = &#63; and groupId = &#63;.
800             *
801             * @param uuid the uuid
802             * @param groupId the group ID
803             * @return the number of matching document library folders
804             */
805            @Override
806            public int countByUUID_G(String uuid, long groupId) {
807                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
808    
809                    Object[] finderArgs = new Object[] { uuid, groupId };
810    
811                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
812                                    this);
813    
814                    if (count == null) {
815                            StringBundler query = new StringBundler(3);
816    
817                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
818    
819                            boolean bindUuid = false;
820    
821                            if (uuid == null) {
822                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
823                            }
824                            else if (uuid.equals(StringPool.BLANK)) {
825                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
826                            }
827                            else {
828                                    bindUuid = true;
829    
830                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
831                            }
832    
833                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
834    
835                            String sql = query.toString();
836    
837                            Session session = null;
838    
839                            try {
840                                    session = openSession();
841    
842                                    Query q = session.createQuery(sql);
843    
844                                    QueryPos qPos = QueryPos.getInstance(q);
845    
846                                    if (bindUuid) {
847                                            qPos.add(uuid);
848                                    }
849    
850                                    qPos.add(groupId);
851    
852                                    count = (Long)q.uniqueResult();
853    
854                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
855                            }
856                            catch (Exception e) {
857                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
858    
859                                    throw processException(e);
860                            }
861                            finally {
862                                    closeSession(session);
863                            }
864                    }
865    
866                    return count.intValue();
867            }
868    
869            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
870            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
871            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '') AND ";
872            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
873            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
874                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
875                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
876                            new String[] {
877                                    String.class.getName(), Long.class.getName(),
878                                    
879                            Integer.class.getName(), Integer.class.getName(),
880                                    OrderByComparator.class.getName()
881                            });
882            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
883                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
884                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
885                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
886                            new String[] { String.class.getName(), Long.class.getName() },
887                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
888                            DLFolderModelImpl.COMPANYID_COLUMN_BITMASK |
889                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
890                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
891            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
892                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
893                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
894                            new String[] { String.class.getName(), Long.class.getName() });
895    
896            /**
897             * Returns all the document library folders where uuid = &#63; and companyId = &#63;.
898             *
899             * @param uuid the uuid
900             * @param companyId the company ID
901             * @return the matching document library folders
902             */
903            @Override
904            public List<DLFolder> findByUuid_C(String uuid, long companyId) {
905                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
906                            QueryUtil.ALL_POS, null);
907            }
908    
909            /**
910             * Returns a range of all the document library folders where uuid = &#63; and companyId = &#63;.
911             *
912             * <p>
913             * 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.
914             * </p>
915             *
916             * @param uuid the uuid
917             * @param companyId the company ID
918             * @param start the lower bound of the range of document library folders
919             * @param end the upper bound of the range of document library folders (not inclusive)
920             * @return the range of matching document library folders
921             */
922            @Override
923            public List<DLFolder> findByUuid_C(String uuid, long companyId, int start,
924                    int end) {
925                    return findByUuid_C(uuid, companyId, start, end, null);
926            }
927    
928            /**
929             * Returns an ordered range of all the document library folders where uuid = &#63; and companyId = &#63;.
930             *
931             * <p>
932             * 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.
933             * </p>
934             *
935             * @param uuid the uuid
936             * @param companyId the company ID
937             * @param start the lower bound of the range of document library folders
938             * @param end the upper bound of the range of document library folders (not inclusive)
939             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
940             * @return the ordered range of matching document library folders
941             */
942            @Override
943            public List<DLFolder> findByUuid_C(String uuid, long companyId, int start,
944                    int end, OrderByComparator<DLFolder> orderByComparator) {
945                    boolean pagination = true;
946                    FinderPath finderPath = null;
947                    Object[] finderArgs = null;
948    
949                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
950                                    (orderByComparator == null)) {
951                            pagination = false;
952                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
953                            finderArgs = new Object[] { uuid, companyId };
954                    }
955                    else {
956                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
957                            finderArgs = new Object[] {
958                                            uuid, companyId,
959                                            
960                                            start, end, orderByComparator
961                                    };
962                    }
963    
964                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
965                                    finderArgs, this);
966    
967                    if ((list != null) && !list.isEmpty()) {
968                            for (DLFolder dlFolder : list) {
969                                    if (!Validator.equals(uuid, dlFolder.getUuid()) ||
970                                                    (companyId != dlFolder.getCompanyId())) {
971                                            list = null;
972    
973                                            break;
974                                    }
975                            }
976                    }
977    
978                    if (list == null) {
979                            StringBundler query = null;
980    
981                            if (orderByComparator != null) {
982                                    query = new StringBundler(4 +
983                                                    (orderByComparator.getOrderByFields().length * 3));
984                            }
985                            else {
986                                    query = new StringBundler(4);
987                            }
988    
989                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
990    
991                            boolean bindUuid = false;
992    
993                            if (uuid == null) {
994                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
995                            }
996                            else if (uuid.equals(StringPool.BLANK)) {
997                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
998                            }
999                            else {
1000                                    bindUuid = true;
1001    
1002                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1003                            }
1004    
1005                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1006    
1007                            if (orderByComparator != null) {
1008                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1009                                            orderByComparator);
1010                            }
1011                            else
1012                             if (pagination) {
1013                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1014                            }
1015    
1016                            String sql = query.toString();
1017    
1018                            Session session = null;
1019    
1020                            try {
1021                                    session = openSession();
1022    
1023                                    Query q = session.createQuery(sql);
1024    
1025                                    QueryPos qPos = QueryPos.getInstance(q);
1026    
1027                                    if (bindUuid) {
1028                                            qPos.add(uuid);
1029                                    }
1030    
1031                                    qPos.add(companyId);
1032    
1033                                    if (!pagination) {
1034                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1035                                                            start, end, false);
1036    
1037                                            Collections.sort(list);
1038    
1039                                            list = Collections.unmodifiableList(list);
1040                                    }
1041                                    else {
1042                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1043                                                            start, end);
1044                                    }
1045    
1046                                    cacheResult(list);
1047    
1048                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1049                            }
1050                            catch (Exception e) {
1051                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1052    
1053                                    throw processException(e);
1054                            }
1055                            finally {
1056                                    closeSession(session);
1057                            }
1058                    }
1059    
1060                    return list;
1061            }
1062    
1063            /**
1064             * Returns the first document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1065             *
1066             * @param uuid the uuid
1067             * @param companyId the company ID
1068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1069             * @return the first matching document library folder
1070             * @throws NoSuchFolderException if a matching document library folder could not be found
1071             */
1072            @Override
1073            public DLFolder findByUuid_C_First(String uuid, long companyId,
1074                    OrderByComparator<DLFolder> orderByComparator)
1075                    throws NoSuchFolderException {
1076                    DLFolder dlFolder = fetchByUuid_C_First(uuid, companyId,
1077                                    orderByComparator);
1078    
1079                    if (dlFolder != null) {
1080                            return dlFolder;
1081                    }
1082    
1083                    StringBundler msg = new StringBundler(6);
1084    
1085                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1086    
1087                    msg.append("uuid=");
1088                    msg.append(uuid);
1089    
1090                    msg.append(", companyId=");
1091                    msg.append(companyId);
1092    
1093                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1094    
1095                    throw new NoSuchFolderException(msg.toString());
1096            }
1097    
1098            /**
1099             * Returns the first document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1100             *
1101             * @param uuid the uuid
1102             * @param companyId the company ID
1103             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1104             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1105             */
1106            @Override
1107            public DLFolder fetchByUuid_C_First(String uuid, long companyId,
1108                    OrderByComparator<DLFolder> orderByComparator) {
1109                    List<DLFolder> list = findByUuid_C(uuid, companyId, 0, 1,
1110                                    orderByComparator);
1111    
1112                    if (!list.isEmpty()) {
1113                            return list.get(0);
1114                    }
1115    
1116                    return null;
1117            }
1118    
1119            /**
1120             * Returns the last document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1121             *
1122             * @param uuid the uuid
1123             * @param companyId the company ID
1124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1125             * @return the last matching document library folder
1126             * @throws NoSuchFolderException if a matching document library folder could not be found
1127             */
1128            @Override
1129            public DLFolder findByUuid_C_Last(String uuid, long companyId,
1130                    OrderByComparator<DLFolder> orderByComparator)
1131                    throws NoSuchFolderException {
1132                    DLFolder dlFolder = fetchByUuid_C_Last(uuid, companyId,
1133                                    orderByComparator);
1134    
1135                    if (dlFolder != null) {
1136                            return dlFolder;
1137                    }
1138    
1139                    StringBundler msg = new StringBundler(6);
1140    
1141                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1142    
1143                    msg.append("uuid=");
1144                    msg.append(uuid);
1145    
1146                    msg.append(", companyId=");
1147                    msg.append(companyId);
1148    
1149                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1150    
1151                    throw new NoSuchFolderException(msg.toString());
1152            }
1153    
1154            /**
1155             * Returns the last document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1156             *
1157             * @param uuid the uuid
1158             * @param companyId the company ID
1159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1160             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1161             */
1162            @Override
1163            public DLFolder fetchByUuid_C_Last(String uuid, long companyId,
1164                    OrderByComparator<DLFolder> orderByComparator) {
1165                    int count = countByUuid_C(uuid, companyId);
1166    
1167                    if (count == 0) {
1168                            return null;
1169                    }
1170    
1171                    List<DLFolder> list = findByUuid_C(uuid, companyId, count - 1, count,
1172                                    orderByComparator);
1173    
1174                    if (!list.isEmpty()) {
1175                            return list.get(0);
1176                    }
1177    
1178                    return null;
1179            }
1180    
1181            /**
1182             * Returns the document library folders before and after the current document library folder in the ordered set where uuid = &#63; and companyId = &#63;.
1183             *
1184             * @param folderId the primary key of the current document library folder
1185             * @param uuid the uuid
1186             * @param companyId the company ID
1187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1188             * @return the previous, current, and next document library folder
1189             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
1190             */
1191            @Override
1192            public DLFolder[] findByUuid_C_PrevAndNext(long folderId, String uuid,
1193                    long companyId, OrderByComparator<DLFolder> orderByComparator)
1194                    throws NoSuchFolderException {
1195                    DLFolder dlFolder = findByPrimaryKey(folderId);
1196    
1197                    Session session = null;
1198    
1199                    try {
1200                            session = openSession();
1201    
1202                            DLFolder[] array = new DLFolderImpl[3];
1203    
1204                            array[0] = getByUuid_C_PrevAndNext(session, dlFolder, uuid,
1205                                            companyId, orderByComparator, true);
1206    
1207                            array[1] = dlFolder;
1208    
1209                            array[2] = getByUuid_C_PrevAndNext(session, dlFolder, uuid,
1210                                            companyId, orderByComparator, false);
1211    
1212                            return array;
1213                    }
1214                    catch (Exception e) {
1215                            throw processException(e);
1216                    }
1217                    finally {
1218                            closeSession(session);
1219                    }
1220            }
1221    
1222            protected DLFolder getByUuid_C_PrevAndNext(Session session,
1223                    DLFolder dlFolder, String uuid, long companyId,
1224                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
1225                    StringBundler query = null;
1226    
1227                    if (orderByComparator != null) {
1228                            query = new StringBundler(6 +
1229                                            (orderByComparator.getOrderByFields().length * 6));
1230                    }
1231                    else {
1232                            query = new StringBundler(3);
1233                    }
1234    
1235                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1236    
1237                    boolean bindUuid = false;
1238    
1239                    if (uuid == null) {
1240                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1241                    }
1242                    else if (uuid.equals(StringPool.BLANK)) {
1243                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1244                    }
1245                    else {
1246                            bindUuid = true;
1247    
1248                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1249                    }
1250    
1251                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1252    
1253                    if (orderByComparator != null) {
1254                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1255    
1256                            if (orderByConditionFields.length > 0) {
1257                                    query.append(WHERE_AND);
1258                            }
1259    
1260                            for (int i = 0; i < orderByConditionFields.length; i++) {
1261                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1262                                    query.append(orderByConditionFields[i]);
1263    
1264                                    if ((i + 1) < orderByConditionFields.length) {
1265                                            if (orderByComparator.isAscending() ^ previous) {
1266                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1267                                            }
1268                                            else {
1269                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1270                                            }
1271                                    }
1272                                    else {
1273                                            if (orderByComparator.isAscending() ^ previous) {
1274                                                    query.append(WHERE_GREATER_THAN);
1275                                            }
1276                                            else {
1277                                                    query.append(WHERE_LESSER_THAN);
1278                                            }
1279                                    }
1280                            }
1281    
1282                            query.append(ORDER_BY_CLAUSE);
1283    
1284                            String[] orderByFields = orderByComparator.getOrderByFields();
1285    
1286                            for (int i = 0; i < orderByFields.length; i++) {
1287                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1288                                    query.append(orderByFields[i]);
1289    
1290                                    if ((i + 1) < orderByFields.length) {
1291                                            if (orderByComparator.isAscending() ^ previous) {
1292                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1293                                            }
1294                                            else {
1295                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1296                                            }
1297                                    }
1298                                    else {
1299                                            if (orderByComparator.isAscending() ^ previous) {
1300                                                    query.append(ORDER_BY_ASC);
1301                                            }
1302                                            else {
1303                                                    query.append(ORDER_BY_DESC);
1304                                            }
1305                                    }
1306                            }
1307                    }
1308                    else {
1309                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1310                    }
1311    
1312                    String sql = query.toString();
1313    
1314                    Query q = session.createQuery(sql);
1315    
1316                    q.setFirstResult(0);
1317                    q.setMaxResults(2);
1318    
1319                    QueryPos qPos = QueryPos.getInstance(q);
1320    
1321                    if (bindUuid) {
1322                            qPos.add(uuid);
1323                    }
1324    
1325                    qPos.add(companyId);
1326    
1327                    if (orderByComparator != null) {
1328                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1329    
1330                            for (Object value : values) {
1331                                    qPos.add(value);
1332                            }
1333                    }
1334    
1335                    List<DLFolder> list = q.list();
1336    
1337                    if (list.size() == 2) {
1338                            return list.get(1);
1339                    }
1340                    else {
1341                            return null;
1342                    }
1343            }
1344    
1345            /**
1346             * Removes all the document library folders where uuid = &#63; and companyId = &#63; from the database.
1347             *
1348             * @param uuid the uuid
1349             * @param companyId the company ID
1350             */
1351            @Override
1352            public void removeByUuid_C(String uuid, long companyId) {
1353                    for (DLFolder dlFolder : findByUuid_C(uuid, companyId,
1354                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1355                            remove(dlFolder);
1356                    }
1357            }
1358    
1359            /**
1360             * Returns the number of document library folders where uuid = &#63; and companyId = &#63;.
1361             *
1362             * @param uuid the uuid
1363             * @param companyId the company ID
1364             * @return the number of matching document library folders
1365             */
1366            @Override
1367            public int countByUuid_C(String uuid, long companyId) {
1368                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1369    
1370                    Object[] finderArgs = new Object[] { uuid, companyId };
1371    
1372                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1373                                    this);
1374    
1375                    if (count == null) {
1376                            StringBundler query = new StringBundler(3);
1377    
1378                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
1379    
1380                            boolean bindUuid = false;
1381    
1382                            if (uuid == null) {
1383                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1384                            }
1385                            else if (uuid.equals(StringPool.BLANK)) {
1386                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1387                            }
1388                            else {
1389                                    bindUuid = true;
1390    
1391                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1392                            }
1393    
1394                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1395    
1396                            String sql = query.toString();
1397    
1398                            Session session = null;
1399    
1400                            try {
1401                                    session = openSession();
1402    
1403                                    Query q = session.createQuery(sql);
1404    
1405                                    QueryPos qPos = QueryPos.getInstance(q);
1406    
1407                                    if (bindUuid) {
1408                                            qPos.add(uuid);
1409                                    }
1410    
1411                                    qPos.add(companyId);
1412    
1413                                    count = (Long)q.uniqueResult();
1414    
1415                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1416                            }
1417                            catch (Exception e) {
1418                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1419    
1420                                    throw processException(e);
1421                            }
1422                            finally {
1423                                    closeSession(session);
1424                            }
1425                    }
1426    
1427                    return count.intValue();
1428            }
1429    
1430            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFolder.uuid IS NULL AND ";
1431            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFolder.uuid = ? AND ";
1432            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = '') AND ";
1433            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFolder.companyId = ?";
1434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1435                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
1436                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1437                            new String[] {
1438                                    Long.class.getName(),
1439                                    
1440                            Integer.class.getName(), Integer.class.getName(),
1441                                    OrderByComparator.class.getName()
1442                            });
1443            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1444                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1445                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
1446                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1447                            new String[] { Long.class.getName() },
1448                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
1449                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
1450                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
1451            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
1452                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
1453                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1454                            new String[] { Long.class.getName() });
1455    
1456            /**
1457             * Returns all the document library folders where groupId = &#63;.
1458             *
1459             * @param groupId the group ID
1460             * @return the matching document library folders
1461             */
1462            @Override
1463            public List<DLFolder> findByGroupId(long groupId) {
1464                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1465            }
1466    
1467            /**
1468             * Returns a range of all the document library folders where groupId = &#63;.
1469             *
1470             * <p>
1471             * 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.
1472             * </p>
1473             *
1474             * @param groupId the group ID
1475             * @param start the lower bound of the range of document library folders
1476             * @param end the upper bound of the range of document library folders (not inclusive)
1477             * @return the range of matching document library folders
1478             */
1479            @Override
1480            public List<DLFolder> findByGroupId(long groupId, int start, int end) {
1481                    return findByGroupId(groupId, start, end, null);
1482            }
1483    
1484            /**
1485             * Returns an ordered range of all the document library folders where groupId = &#63;.
1486             *
1487             * <p>
1488             * 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.
1489             * </p>
1490             *
1491             * @param groupId the group ID
1492             * @param start the lower bound of the range of document library folders
1493             * @param end the upper bound of the range of document library folders (not inclusive)
1494             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1495             * @return the ordered range of matching document library folders
1496             */
1497            @Override
1498            public List<DLFolder> findByGroupId(long groupId, int start, int end,
1499                    OrderByComparator<DLFolder> orderByComparator) {
1500                    boolean pagination = true;
1501                    FinderPath finderPath = null;
1502                    Object[] finderArgs = null;
1503    
1504                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1505                                    (orderByComparator == null)) {
1506                            pagination = false;
1507                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1508                            finderArgs = new Object[] { groupId };
1509                    }
1510                    else {
1511                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1512                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1513                    }
1514    
1515                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
1516                                    finderArgs, this);
1517    
1518                    if ((list != null) && !list.isEmpty()) {
1519                            for (DLFolder dlFolder : list) {
1520                                    if ((groupId != dlFolder.getGroupId())) {
1521                                            list = null;
1522    
1523                                            break;
1524                                    }
1525                            }
1526                    }
1527    
1528                    if (list == null) {
1529                            StringBundler query = null;
1530    
1531                            if (orderByComparator != null) {
1532                                    query = new StringBundler(3 +
1533                                                    (orderByComparator.getOrderByFields().length * 3));
1534                            }
1535                            else {
1536                                    query = new StringBundler(3);
1537                            }
1538    
1539                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
1540    
1541                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1542    
1543                            if (orderByComparator != null) {
1544                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1545                                            orderByComparator);
1546                            }
1547                            else
1548                             if (pagination) {
1549                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1550                            }
1551    
1552                            String sql = query.toString();
1553    
1554                            Session session = null;
1555    
1556                            try {
1557                                    session = openSession();
1558    
1559                                    Query q = session.createQuery(sql);
1560    
1561                                    QueryPos qPos = QueryPos.getInstance(q);
1562    
1563                                    qPos.add(groupId);
1564    
1565                                    if (!pagination) {
1566                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1567                                                            start, end, false);
1568    
1569                                            Collections.sort(list);
1570    
1571                                            list = Collections.unmodifiableList(list);
1572                                    }
1573                                    else {
1574                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
1575                                                            start, end);
1576                                    }
1577    
1578                                    cacheResult(list);
1579    
1580                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1581                            }
1582                            catch (Exception e) {
1583                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1584    
1585                                    throw processException(e);
1586                            }
1587                            finally {
1588                                    closeSession(session);
1589                            }
1590                    }
1591    
1592                    return list;
1593            }
1594    
1595            /**
1596             * Returns the first document library folder in the ordered set where groupId = &#63;.
1597             *
1598             * @param groupId the group ID
1599             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1600             * @return the first matching document library folder
1601             * @throws NoSuchFolderException if a matching document library folder could not be found
1602             */
1603            @Override
1604            public DLFolder findByGroupId_First(long groupId,
1605                    OrderByComparator<DLFolder> orderByComparator)
1606                    throws NoSuchFolderException {
1607                    DLFolder dlFolder = fetchByGroupId_First(groupId, orderByComparator);
1608    
1609                    if (dlFolder != null) {
1610                            return dlFolder;
1611                    }
1612    
1613                    StringBundler msg = new StringBundler(4);
1614    
1615                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1616    
1617                    msg.append("groupId=");
1618                    msg.append(groupId);
1619    
1620                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1621    
1622                    throw new NoSuchFolderException(msg.toString());
1623            }
1624    
1625            /**
1626             * Returns the first document library folder in the ordered set where groupId = &#63;.
1627             *
1628             * @param groupId the group ID
1629             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1630             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1631             */
1632            @Override
1633            public DLFolder fetchByGroupId_First(long groupId,
1634                    OrderByComparator<DLFolder> orderByComparator) {
1635                    List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1636    
1637                    if (!list.isEmpty()) {
1638                            return list.get(0);
1639                    }
1640    
1641                    return null;
1642            }
1643    
1644            /**
1645             * Returns the last document library folder in the ordered set where groupId = &#63;.
1646             *
1647             * @param groupId the group ID
1648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1649             * @return the last matching document library folder
1650             * @throws NoSuchFolderException if a matching document library folder could not be found
1651             */
1652            @Override
1653            public DLFolder findByGroupId_Last(long groupId,
1654                    OrderByComparator<DLFolder> orderByComparator)
1655                    throws NoSuchFolderException {
1656                    DLFolder dlFolder = fetchByGroupId_Last(groupId, orderByComparator);
1657    
1658                    if (dlFolder != null) {
1659                            return dlFolder;
1660                    }
1661    
1662                    StringBundler msg = new StringBundler(4);
1663    
1664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1665    
1666                    msg.append("groupId=");
1667                    msg.append(groupId);
1668    
1669                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1670    
1671                    throw new NoSuchFolderException(msg.toString());
1672            }
1673    
1674            /**
1675             * Returns the last 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 last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1680             */
1681            @Override
1682            public DLFolder fetchByGroupId_Last(long groupId,
1683                    OrderByComparator<DLFolder> orderByComparator) {
1684                    int count = countByGroupId(groupId);
1685    
1686                    if (count == 0) {
1687                            return null;
1688                    }
1689    
1690                    List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1691                                    orderByComparator);
1692    
1693                    if (!list.isEmpty()) {
1694                            return list.get(0);
1695                    }
1696    
1697                    return null;
1698            }
1699    
1700            /**
1701             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63;.
1702             *
1703             * @param folderId the primary key of the current document library folder
1704             * @param groupId the group ID
1705             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1706             * @return the previous, current, and next document library folder
1707             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
1708             */
1709            @Override
1710            public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1711                    OrderByComparator<DLFolder> orderByComparator)
1712                    throws NoSuchFolderException {
1713                    DLFolder dlFolder = findByPrimaryKey(folderId);
1714    
1715                    Session session = null;
1716    
1717                    try {
1718                            session = openSession();
1719    
1720                            DLFolder[] array = new DLFolderImpl[3];
1721    
1722                            array[0] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1723                                            orderByComparator, true);
1724    
1725                            array[1] = dlFolder;
1726    
1727                            array[2] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1728                                            orderByComparator, false);
1729    
1730                            return array;
1731                    }
1732                    catch (Exception e) {
1733                            throw processException(e);
1734                    }
1735                    finally {
1736                            closeSession(session);
1737                    }
1738            }
1739    
1740            protected DLFolder getByGroupId_PrevAndNext(Session session,
1741                    DLFolder dlFolder, long groupId,
1742                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
1743                    StringBundler query = null;
1744    
1745                    if (orderByComparator != null) {
1746                            query = new StringBundler(6 +
1747                                            (orderByComparator.getOrderByFields().length * 6));
1748                    }
1749                    else {
1750                            query = new StringBundler(3);
1751                    }
1752    
1753                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1754    
1755                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1756    
1757                    if (orderByComparator != null) {
1758                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1759    
1760                            if (orderByConditionFields.length > 0) {
1761                                    query.append(WHERE_AND);
1762                            }
1763    
1764                            for (int i = 0; i < orderByConditionFields.length; i++) {
1765                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1766                                    query.append(orderByConditionFields[i]);
1767    
1768                                    if ((i + 1) < orderByConditionFields.length) {
1769                                            if (orderByComparator.isAscending() ^ previous) {
1770                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1771                                            }
1772                                            else {
1773                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1774                                            }
1775                                    }
1776                                    else {
1777                                            if (orderByComparator.isAscending() ^ previous) {
1778                                                    query.append(WHERE_GREATER_THAN);
1779                                            }
1780                                            else {
1781                                                    query.append(WHERE_LESSER_THAN);
1782                                            }
1783                                    }
1784                            }
1785    
1786                            query.append(ORDER_BY_CLAUSE);
1787    
1788                            String[] orderByFields = orderByComparator.getOrderByFields();
1789    
1790                            for (int i = 0; i < orderByFields.length; i++) {
1791                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1792                                    query.append(orderByFields[i]);
1793    
1794                                    if ((i + 1) < orderByFields.length) {
1795                                            if (orderByComparator.isAscending() ^ previous) {
1796                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1797                                            }
1798                                            else {
1799                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1800                                            }
1801                                    }
1802                                    else {
1803                                            if (orderByComparator.isAscending() ^ previous) {
1804                                                    query.append(ORDER_BY_ASC);
1805                                            }
1806                                            else {
1807                                                    query.append(ORDER_BY_DESC);
1808                                            }
1809                                    }
1810                            }
1811                    }
1812                    else {
1813                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1814                    }
1815    
1816                    String sql = query.toString();
1817    
1818                    Query q = session.createQuery(sql);
1819    
1820                    q.setFirstResult(0);
1821                    q.setMaxResults(2);
1822    
1823                    QueryPos qPos = QueryPos.getInstance(q);
1824    
1825                    qPos.add(groupId);
1826    
1827                    if (orderByComparator != null) {
1828                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1829    
1830                            for (Object value : values) {
1831                                    qPos.add(value);
1832                            }
1833                    }
1834    
1835                    List<DLFolder> list = q.list();
1836    
1837                    if (list.size() == 2) {
1838                            return list.get(1);
1839                    }
1840                    else {
1841                            return null;
1842                    }
1843            }
1844    
1845            /**
1846             * Returns all the document library folders that the user has permission to view where groupId = &#63;.
1847             *
1848             * @param groupId the group ID
1849             * @return the matching document library folders that the user has permission to view
1850             */
1851            @Override
1852            public List<DLFolder> filterFindByGroupId(long groupId) {
1853                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1854                            QueryUtil.ALL_POS, null);
1855            }
1856    
1857            /**
1858             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63;.
1859             *
1860             * <p>
1861             * 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.
1862             * </p>
1863             *
1864             * @param groupId the group ID
1865             * @param start the lower bound of the range of document library folders
1866             * @param end the upper bound of the range of document library folders (not inclusive)
1867             * @return the range of matching document library folders that the user has permission to view
1868             */
1869            @Override
1870            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end) {
1871                    return filterFindByGroupId(groupId, start, end, null);
1872            }
1873    
1874            /**
1875             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63;.
1876             *
1877             * <p>
1878             * 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.
1879             * </p>
1880             *
1881             * @param groupId the group ID
1882             * @param start the lower bound of the range of document library folders
1883             * @param end the upper bound of the range of document library folders (not inclusive)
1884             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1885             * @return the ordered range of matching document library folders that the user has permission to view
1886             */
1887            @Override
1888            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end,
1889                    OrderByComparator<DLFolder> orderByComparator) {
1890                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1891                            return findByGroupId(groupId, start, end, orderByComparator);
1892                    }
1893    
1894                    StringBundler query = null;
1895    
1896                    if (orderByComparator != null) {
1897                            query = new StringBundler(3 +
1898                                            (orderByComparator.getOrderByFields().length * 3));
1899                    }
1900                    else {
1901                            query = new StringBundler(3);
1902                    }
1903    
1904                    if (getDB().isSupportsInlineDistinct()) {
1905                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1906                    }
1907                    else {
1908                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1909                    }
1910    
1911                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1912    
1913                    if (!getDB().isSupportsInlineDistinct()) {
1914                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1915                    }
1916    
1917                    if (orderByComparator != null) {
1918                            if (getDB().isSupportsInlineDistinct()) {
1919                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1920                                            orderByComparator, true);
1921                            }
1922                            else {
1923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1924                                            orderByComparator, true);
1925                            }
1926                    }
1927                    else {
1928                            if (getDB().isSupportsInlineDistinct()) {
1929                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1930                            }
1931                            else {
1932                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
1933                            }
1934                    }
1935    
1936                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1937                                    DLFolder.class.getName(),
1938                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1939    
1940                    Session session = null;
1941    
1942                    try {
1943                            session = openSession();
1944    
1945                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1946    
1947                            if (getDB().isSupportsInlineDistinct()) {
1948                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
1949                            }
1950                            else {
1951                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
1952                            }
1953    
1954                            QueryPos qPos = QueryPos.getInstance(q);
1955    
1956                            qPos.add(groupId);
1957    
1958                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
1959                    }
1960                    catch (Exception e) {
1961                            throw processException(e);
1962                    }
1963                    finally {
1964                            closeSession(session);
1965                    }
1966            }
1967    
1968            /**
1969             * 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;.
1970             *
1971             * @param folderId the primary key of the current document library folder
1972             * @param groupId the group ID
1973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1974             * @return the previous, current, and next document library folder
1975             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
1976             */
1977            @Override
1978            public DLFolder[] filterFindByGroupId_PrevAndNext(long folderId,
1979                    long groupId, OrderByComparator<DLFolder> orderByComparator)
1980                    throws NoSuchFolderException {
1981                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1982                            return findByGroupId_PrevAndNext(folderId, groupId,
1983                                    orderByComparator);
1984                    }
1985    
1986                    DLFolder dlFolder = findByPrimaryKey(folderId);
1987    
1988                    Session session = null;
1989    
1990                    try {
1991                            session = openSession();
1992    
1993                            DLFolder[] array = new DLFolderImpl[3];
1994    
1995                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1996                                            groupId, orderByComparator, true);
1997    
1998                            array[1] = dlFolder;
1999    
2000                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFolder,
2001                                            groupId, orderByComparator, false);
2002    
2003                            return array;
2004                    }
2005                    catch (Exception e) {
2006                            throw processException(e);
2007                    }
2008                    finally {
2009                            closeSession(session);
2010                    }
2011            }
2012    
2013            protected DLFolder filterGetByGroupId_PrevAndNext(Session session,
2014                    DLFolder dlFolder, long groupId,
2015                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
2016                    StringBundler query = null;
2017    
2018                    if (orderByComparator != null) {
2019                            query = new StringBundler(6 +
2020                                            (orderByComparator.getOrderByFields().length * 6));
2021                    }
2022                    else {
2023                            query = new StringBundler(3);
2024                    }
2025    
2026                    if (getDB().isSupportsInlineDistinct()) {
2027                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
2028                    }
2029                    else {
2030                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2031                    }
2032    
2033                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2034    
2035                    if (!getDB().isSupportsInlineDistinct()) {
2036                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2037                    }
2038    
2039                    if (orderByComparator != null) {
2040                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2041    
2042                            if (orderByConditionFields.length > 0) {
2043                                    query.append(WHERE_AND);
2044                            }
2045    
2046                            for (int i = 0; i < orderByConditionFields.length; i++) {
2047                                    if (getDB().isSupportsInlineDistinct()) {
2048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2049                                    }
2050                                    else {
2051                                            query.append(_ORDER_BY_ENTITY_TABLE);
2052                                    }
2053    
2054                                    query.append(orderByConditionFields[i]);
2055    
2056                                    if ((i + 1) < orderByConditionFields.length) {
2057                                            if (orderByComparator.isAscending() ^ previous) {
2058                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2059                                            }
2060                                            else {
2061                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2062                                            }
2063                                    }
2064                                    else {
2065                                            if (orderByComparator.isAscending() ^ previous) {
2066                                                    query.append(WHERE_GREATER_THAN);
2067                                            }
2068                                            else {
2069                                                    query.append(WHERE_LESSER_THAN);
2070                                            }
2071                                    }
2072                            }
2073    
2074                            query.append(ORDER_BY_CLAUSE);
2075    
2076                            String[] orderByFields = orderByComparator.getOrderByFields();
2077    
2078                            for (int i = 0; i < orderByFields.length; i++) {
2079                                    if (getDB().isSupportsInlineDistinct()) {
2080                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2081                                    }
2082                                    else {
2083                                            query.append(_ORDER_BY_ENTITY_TABLE);
2084                                    }
2085    
2086                                    query.append(orderByFields[i]);
2087    
2088                                    if ((i + 1) < orderByFields.length) {
2089                                            if (orderByComparator.isAscending() ^ previous) {
2090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2091                                            }
2092                                            else {
2093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2094                                            }
2095                                    }
2096                                    else {
2097                                            if (orderByComparator.isAscending() ^ previous) {
2098                                                    query.append(ORDER_BY_ASC);
2099                                            }
2100                                            else {
2101                                                    query.append(ORDER_BY_DESC);
2102                                            }
2103                                    }
2104                            }
2105                    }
2106                    else {
2107                            if (getDB().isSupportsInlineDistinct()) {
2108                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2109                            }
2110                            else {
2111                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
2112                            }
2113                    }
2114    
2115                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2116                                    DLFolder.class.getName(),
2117                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2118    
2119                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2120    
2121                    q.setFirstResult(0);
2122                    q.setMaxResults(2);
2123    
2124                    if (getDB().isSupportsInlineDistinct()) {
2125                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2126                    }
2127                    else {
2128                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2129                    }
2130    
2131                    QueryPos qPos = QueryPos.getInstance(q);
2132    
2133                    qPos.add(groupId);
2134    
2135                    if (orderByComparator != null) {
2136                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2137    
2138                            for (Object value : values) {
2139                                    qPos.add(value);
2140                            }
2141                    }
2142    
2143                    List<DLFolder> list = q.list();
2144    
2145                    if (list.size() == 2) {
2146                            return list.get(1);
2147                    }
2148                    else {
2149                            return null;
2150                    }
2151            }
2152    
2153            /**
2154             * Removes all the document library folders where groupId = &#63; from the database.
2155             *
2156             * @param groupId the group ID
2157             */
2158            @Override
2159            public void removeByGroupId(long groupId) {
2160                    for (DLFolder dlFolder : findByGroupId(groupId, QueryUtil.ALL_POS,
2161                                    QueryUtil.ALL_POS, null)) {
2162                            remove(dlFolder);
2163                    }
2164            }
2165    
2166            /**
2167             * Returns the number of document library folders where groupId = &#63;.
2168             *
2169             * @param groupId the group ID
2170             * @return the number of matching document library folders
2171             */
2172            @Override
2173            public int countByGroupId(long groupId) {
2174                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2175    
2176                    Object[] finderArgs = new Object[] { groupId };
2177    
2178                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2179                                    this);
2180    
2181                    if (count == null) {
2182                            StringBundler query = new StringBundler(2);
2183    
2184                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
2185    
2186                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2187    
2188                            String sql = query.toString();
2189    
2190                            Session session = null;
2191    
2192                            try {
2193                                    session = openSession();
2194    
2195                                    Query q = session.createQuery(sql);
2196    
2197                                    QueryPos qPos = QueryPos.getInstance(q);
2198    
2199                                    qPos.add(groupId);
2200    
2201                                    count = (Long)q.uniqueResult();
2202    
2203                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2204                            }
2205                            catch (Exception e) {
2206                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2207    
2208                                    throw processException(e);
2209                            }
2210                            finally {
2211                                    closeSession(session);
2212                            }
2213                    }
2214    
2215                    return count.intValue();
2216            }
2217    
2218            /**
2219             * Returns the number of document library folders that the user has permission to view where groupId = &#63;.
2220             *
2221             * @param groupId the group ID
2222             * @return the number of matching document library folders that the user has permission to view
2223             */
2224            @Override
2225            public int filterCountByGroupId(long groupId) {
2226                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2227                            return countByGroupId(groupId);
2228                    }
2229    
2230                    StringBundler query = new StringBundler(2);
2231    
2232                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
2233    
2234                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2235    
2236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2237                                    DLFolder.class.getName(),
2238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2239    
2240                    Session session = null;
2241    
2242                    try {
2243                            session = openSession();
2244    
2245                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2246    
2247                            q.addScalar(COUNT_COLUMN_NAME,
2248                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2249    
2250                            QueryPos qPos = QueryPos.getInstance(q);
2251    
2252                            qPos.add(groupId);
2253    
2254                            Long count = (Long)q.uniqueResult();
2255    
2256                            return count.intValue();
2257                    }
2258                    catch (Exception e) {
2259                            throw processException(e);
2260                    }
2261                    finally {
2262                            closeSession(session);
2263                    }
2264            }
2265    
2266            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
2267            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2268                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2269                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2270                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2271                            new String[] {
2272                                    Long.class.getName(),
2273                                    
2274                            Integer.class.getName(), Integer.class.getName(),
2275                                    OrderByComparator.class.getName()
2276                            });
2277            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2278                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2279                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2280                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2281                            new String[] { Long.class.getName() },
2282                            DLFolderModelImpl.COMPANYID_COLUMN_BITMASK |
2283                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2284                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
2285            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2286                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2287                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2288                            new String[] { Long.class.getName() });
2289    
2290            /**
2291             * Returns all the document library folders where companyId = &#63;.
2292             *
2293             * @param companyId the company ID
2294             * @return the matching document library folders
2295             */
2296            @Override
2297            public List<DLFolder> findByCompanyId(long companyId) {
2298                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2299                            null);
2300            }
2301    
2302            /**
2303             * Returns a range of all the document library folders where companyId = &#63;.
2304             *
2305             * <p>
2306             * 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.
2307             * </p>
2308             *
2309             * @param companyId the company ID
2310             * @param start the lower bound of the range of document library folders
2311             * @param end the upper bound of the range of document library folders (not inclusive)
2312             * @return the range of matching document library folders
2313             */
2314            @Override
2315            public List<DLFolder> findByCompanyId(long companyId, int start, int end) {
2316                    return findByCompanyId(companyId, start, end, null);
2317            }
2318    
2319            /**
2320             * Returns an ordered range of all the document library folders where companyId = &#63;.
2321             *
2322             * <p>
2323             * 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.
2324             * </p>
2325             *
2326             * @param companyId the company ID
2327             * @param start the lower bound of the range of document library folders
2328             * @param end the upper bound of the range of document library folders (not inclusive)
2329             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2330             * @return the ordered range of matching document library folders
2331             */
2332            @Override
2333            public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2334                    OrderByComparator<DLFolder> orderByComparator) {
2335                    boolean pagination = true;
2336                    FinderPath finderPath = null;
2337                    Object[] finderArgs = null;
2338    
2339                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2340                                    (orderByComparator == null)) {
2341                            pagination = false;
2342                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2343                            finderArgs = new Object[] { companyId };
2344                    }
2345                    else {
2346                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2347                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2348                    }
2349    
2350                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2351                                    finderArgs, this);
2352    
2353                    if ((list != null) && !list.isEmpty()) {
2354                            for (DLFolder dlFolder : list) {
2355                                    if ((companyId != dlFolder.getCompanyId())) {
2356                                            list = null;
2357    
2358                                            break;
2359                                    }
2360                            }
2361                    }
2362    
2363                    if (list == null) {
2364                            StringBundler query = null;
2365    
2366                            if (orderByComparator != null) {
2367                                    query = new StringBundler(3 +
2368                                                    (orderByComparator.getOrderByFields().length * 3));
2369                            }
2370                            else {
2371                                    query = new StringBundler(3);
2372                            }
2373    
2374                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2375    
2376                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2377    
2378                            if (orderByComparator != null) {
2379                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2380                                            orderByComparator);
2381                            }
2382                            else
2383                             if (pagination) {
2384                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2385                            }
2386    
2387                            String sql = query.toString();
2388    
2389                            Session session = null;
2390    
2391                            try {
2392                                    session = openSession();
2393    
2394                                    Query q = session.createQuery(sql);
2395    
2396                                    QueryPos qPos = QueryPos.getInstance(q);
2397    
2398                                    qPos.add(companyId);
2399    
2400                                    if (!pagination) {
2401                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2402                                                            start, end, false);
2403    
2404                                            Collections.sort(list);
2405    
2406                                            list = Collections.unmodifiableList(list);
2407                                    }
2408                                    else {
2409                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2410                                                            start, end);
2411                                    }
2412    
2413                                    cacheResult(list);
2414    
2415                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2416                            }
2417                            catch (Exception e) {
2418                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2419    
2420                                    throw processException(e);
2421                            }
2422                            finally {
2423                                    closeSession(session);
2424                            }
2425                    }
2426    
2427                    return list;
2428            }
2429    
2430            /**
2431             * Returns the first document library folder in the ordered set where companyId = &#63;.
2432             *
2433             * @param companyId the company ID
2434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2435             * @return the first matching document library folder
2436             * @throws NoSuchFolderException if a matching document library folder could not be found
2437             */
2438            @Override
2439            public DLFolder findByCompanyId_First(long companyId,
2440                    OrderByComparator<DLFolder> orderByComparator)
2441                    throws NoSuchFolderException {
2442                    DLFolder dlFolder = fetchByCompanyId_First(companyId, orderByComparator);
2443    
2444                    if (dlFolder != null) {
2445                            return dlFolder;
2446                    }
2447    
2448                    StringBundler msg = new StringBundler(4);
2449    
2450                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2451    
2452                    msg.append("companyId=");
2453                    msg.append(companyId);
2454    
2455                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2456    
2457                    throw new NoSuchFolderException(msg.toString());
2458            }
2459    
2460            /**
2461             * Returns the first document library folder in the ordered set where companyId = &#63;.
2462             *
2463             * @param companyId the company ID
2464             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2465             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
2466             */
2467            @Override
2468            public DLFolder fetchByCompanyId_First(long companyId,
2469                    OrderByComparator<DLFolder> orderByComparator) {
2470                    List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2471    
2472                    if (!list.isEmpty()) {
2473                            return list.get(0);
2474                    }
2475    
2476                    return null;
2477            }
2478    
2479            /**
2480             * Returns the last document library folder in the ordered set where companyId = &#63;.
2481             *
2482             * @param companyId the company ID
2483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2484             * @return the last matching document library folder
2485             * @throws NoSuchFolderException if a matching document library folder could not be found
2486             */
2487            @Override
2488            public DLFolder findByCompanyId_Last(long companyId,
2489                    OrderByComparator<DLFolder> orderByComparator)
2490                    throws NoSuchFolderException {
2491                    DLFolder dlFolder = fetchByCompanyId_Last(companyId, orderByComparator);
2492    
2493                    if (dlFolder != null) {
2494                            return dlFolder;
2495                    }
2496    
2497                    StringBundler msg = new StringBundler(4);
2498    
2499                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2500    
2501                    msg.append("companyId=");
2502                    msg.append(companyId);
2503    
2504                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2505    
2506                    throw new NoSuchFolderException(msg.toString());
2507            }
2508    
2509            /**
2510             * Returns the last document library folder in the ordered set where companyId = &#63;.
2511             *
2512             * @param companyId the company ID
2513             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2514             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
2515             */
2516            @Override
2517            public DLFolder fetchByCompanyId_Last(long companyId,
2518                    OrderByComparator<DLFolder> orderByComparator) {
2519                    int count = countByCompanyId(companyId);
2520    
2521                    if (count == 0) {
2522                            return null;
2523                    }
2524    
2525                    List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
2526                                    orderByComparator);
2527    
2528                    if (!list.isEmpty()) {
2529                            return list.get(0);
2530                    }
2531    
2532                    return null;
2533            }
2534    
2535            /**
2536             * Returns the document library folders before and after the current document library folder in the ordered set where companyId = &#63;.
2537             *
2538             * @param folderId the primary key of the current document library folder
2539             * @param companyId the company ID
2540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2541             * @return the previous, current, and next document library folder
2542             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
2543             */
2544            @Override
2545            public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
2546                    long companyId, OrderByComparator<DLFolder> orderByComparator)
2547                    throws NoSuchFolderException {
2548                    DLFolder dlFolder = findByPrimaryKey(folderId);
2549    
2550                    Session session = null;
2551    
2552                    try {
2553                            session = openSession();
2554    
2555                            DLFolder[] array = new DLFolderImpl[3];
2556    
2557                            array[0] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2558                                            orderByComparator, true);
2559    
2560                            array[1] = dlFolder;
2561    
2562                            array[2] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2563                                            orderByComparator, false);
2564    
2565                            return array;
2566                    }
2567                    catch (Exception e) {
2568                            throw processException(e);
2569                    }
2570                    finally {
2571                            closeSession(session);
2572                    }
2573            }
2574    
2575            protected DLFolder getByCompanyId_PrevAndNext(Session session,
2576                    DLFolder dlFolder, long companyId,
2577                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
2578                    StringBundler query = null;
2579    
2580                    if (orderByComparator != null) {
2581                            query = new StringBundler(6 +
2582                                            (orderByComparator.getOrderByFields().length * 6));
2583                    }
2584                    else {
2585                            query = new StringBundler(3);
2586                    }
2587    
2588                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
2589    
2590                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2591    
2592                    if (orderByComparator != null) {
2593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2594    
2595                            if (orderByConditionFields.length > 0) {
2596                                    query.append(WHERE_AND);
2597                            }
2598    
2599                            for (int i = 0; i < orderByConditionFields.length; i++) {
2600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2601                                    query.append(orderByConditionFields[i]);
2602    
2603                                    if ((i + 1) < orderByConditionFields.length) {
2604                                            if (orderByComparator.isAscending() ^ previous) {
2605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2606                                            }
2607                                            else {
2608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2609                                            }
2610                                    }
2611                                    else {
2612                                            if (orderByComparator.isAscending() ^ previous) {
2613                                                    query.append(WHERE_GREATER_THAN);
2614                                            }
2615                                            else {
2616                                                    query.append(WHERE_LESSER_THAN);
2617                                            }
2618                                    }
2619                            }
2620    
2621                            query.append(ORDER_BY_CLAUSE);
2622    
2623                            String[] orderByFields = orderByComparator.getOrderByFields();
2624    
2625                            for (int i = 0; i < orderByFields.length; i++) {
2626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2627                                    query.append(orderByFields[i]);
2628    
2629                                    if ((i + 1) < orderByFields.length) {
2630                                            if (orderByComparator.isAscending() ^ previous) {
2631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2632                                            }
2633                                            else {
2634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2635                                            }
2636                                    }
2637                                    else {
2638                                            if (orderByComparator.isAscending() ^ previous) {
2639                                                    query.append(ORDER_BY_ASC);
2640                                            }
2641                                            else {
2642                                                    query.append(ORDER_BY_DESC);
2643                                            }
2644                                    }
2645                            }
2646                    }
2647                    else {
2648                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2649                    }
2650    
2651                    String sql = query.toString();
2652    
2653                    Query q = session.createQuery(sql);
2654    
2655                    q.setFirstResult(0);
2656                    q.setMaxResults(2);
2657    
2658                    QueryPos qPos = QueryPos.getInstance(q);
2659    
2660                    qPos.add(companyId);
2661    
2662                    if (orderByComparator != null) {
2663                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2664    
2665                            for (Object value : values) {
2666                                    qPos.add(value);
2667                            }
2668                    }
2669    
2670                    List<DLFolder> list = q.list();
2671    
2672                    if (list.size() == 2) {
2673                            return list.get(1);
2674                    }
2675                    else {
2676                            return null;
2677                    }
2678            }
2679    
2680            /**
2681             * Removes all the document library folders where companyId = &#63; from the database.
2682             *
2683             * @param companyId the company ID
2684             */
2685            @Override
2686            public void removeByCompanyId(long companyId) {
2687                    for (DLFolder dlFolder : findByCompanyId(companyId, QueryUtil.ALL_POS,
2688                                    QueryUtil.ALL_POS, null)) {
2689                            remove(dlFolder);
2690                    }
2691            }
2692    
2693            /**
2694             * Returns the number of document library folders where companyId = &#63;.
2695             *
2696             * @param companyId the company ID
2697             * @return the number of matching document library folders
2698             */
2699            @Override
2700            public int countByCompanyId(long companyId) {
2701                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2702    
2703                    Object[] finderArgs = new Object[] { companyId };
2704    
2705                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2706                                    this);
2707    
2708                    if (count == null) {
2709                            StringBundler query = new StringBundler(2);
2710    
2711                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
2712    
2713                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2714    
2715                            String sql = query.toString();
2716    
2717                            Session session = null;
2718    
2719                            try {
2720                                    session = openSession();
2721    
2722                                    Query q = session.createQuery(sql);
2723    
2724                                    QueryPos qPos = QueryPos.getInstance(q);
2725    
2726                                    qPos.add(companyId);
2727    
2728                                    count = (Long)q.uniqueResult();
2729    
2730                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2731                            }
2732                            catch (Exception e) {
2733                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2734    
2735                                    throw processException(e);
2736                            }
2737                            finally {
2738                                    closeSession(session);
2739                            }
2740                    }
2741    
2742                    return count.intValue();
2743            }
2744    
2745            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
2746            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
2747                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2748                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2749                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRepositoryId",
2750                            new String[] {
2751                                    Long.class.getName(),
2752                                    
2753                            Integer.class.getName(), Integer.class.getName(),
2754                                    OrderByComparator.class.getName()
2755                            });
2756            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
2757                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2758                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
2759                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
2760                            new String[] { Long.class.getName() },
2761                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
2762                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2763                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
2764            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
2765                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2766                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
2767                            new String[] { Long.class.getName() });
2768    
2769            /**
2770             * Returns all the document library folders where repositoryId = &#63;.
2771             *
2772             * @param repositoryId the repository ID
2773             * @return the matching document library folders
2774             */
2775            @Override
2776            public List<DLFolder> findByRepositoryId(long repositoryId) {
2777                    return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
2778                            QueryUtil.ALL_POS, null);
2779            }
2780    
2781            /**
2782             * Returns a range of all the document library folders where repositoryId = &#63;.
2783             *
2784             * <p>
2785             * 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.
2786             * </p>
2787             *
2788             * @param repositoryId the repository ID
2789             * @param start the lower bound of the range of document library folders
2790             * @param end the upper bound of the range of document library folders (not inclusive)
2791             * @return the range of matching document library folders
2792             */
2793            @Override
2794            public List<DLFolder> findByRepositoryId(long repositoryId, int start,
2795                    int end) {
2796                    return findByRepositoryId(repositoryId, start, end, null);
2797            }
2798    
2799            /**
2800             * Returns an ordered range of all the document library folders where repositoryId = &#63;.
2801             *
2802             * <p>
2803             * 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.
2804             * </p>
2805             *
2806             * @param repositoryId the repository ID
2807             * @param start the lower bound of the range of document library folders
2808             * @param end the upper bound of the range of document library folders (not inclusive)
2809             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2810             * @return the ordered range of matching document library folders
2811             */
2812            @Override
2813            public List<DLFolder> findByRepositoryId(long repositoryId, int start,
2814                    int end, OrderByComparator<DLFolder> orderByComparator) {
2815                    boolean pagination = true;
2816                    FinderPath finderPath = null;
2817                    Object[] finderArgs = null;
2818    
2819                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2820                                    (orderByComparator == null)) {
2821                            pagination = false;
2822                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
2823                            finderArgs = new Object[] { repositoryId };
2824                    }
2825                    else {
2826                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
2827                            finderArgs = new Object[] {
2828                                            repositoryId,
2829                                            
2830                                            start, end, orderByComparator
2831                                    };
2832                    }
2833    
2834                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2835                                    finderArgs, this);
2836    
2837                    if ((list != null) && !list.isEmpty()) {
2838                            for (DLFolder dlFolder : list) {
2839                                    if ((repositoryId != dlFolder.getRepositoryId())) {
2840                                            list = null;
2841    
2842                                            break;
2843                                    }
2844                            }
2845                    }
2846    
2847                    if (list == null) {
2848                            StringBundler query = null;
2849    
2850                            if (orderByComparator != null) {
2851                                    query = new StringBundler(3 +
2852                                                    (orderByComparator.getOrderByFields().length * 3));
2853                            }
2854                            else {
2855                                    query = new StringBundler(3);
2856                            }
2857    
2858                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2859    
2860                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2861    
2862                            if (orderByComparator != null) {
2863                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2864                                            orderByComparator);
2865                            }
2866                            else
2867                             if (pagination) {
2868                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2869                            }
2870    
2871                            String sql = query.toString();
2872    
2873                            Session session = null;
2874    
2875                            try {
2876                                    session = openSession();
2877    
2878                                    Query q = session.createQuery(sql);
2879    
2880                                    QueryPos qPos = QueryPos.getInstance(q);
2881    
2882                                    qPos.add(repositoryId);
2883    
2884                                    if (!pagination) {
2885                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2886                                                            start, end, false);
2887    
2888                                            Collections.sort(list);
2889    
2890                                            list = Collections.unmodifiableList(list);
2891                                    }
2892                                    else {
2893                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
2894                                                            start, end);
2895                                    }
2896    
2897                                    cacheResult(list);
2898    
2899                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2900                            }
2901                            catch (Exception e) {
2902                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2903    
2904                                    throw processException(e);
2905                            }
2906                            finally {
2907                                    closeSession(session);
2908                            }
2909                    }
2910    
2911                    return list;
2912            }
2913    
2914            /**
2915             * Returns the first document library folder in the ordered set where repositoryId = &#63;.
2916             *
2917             * @param repositoryId the repository ID
2918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2919             * @return the first matching document library folder
2920             * @throws NoSuchFolderException if a matching document library folder could not be found
2921             */
2922            @Override
2923            public DLFolder findByRepositoryId_First(long repositoryId,
2924                    OrderByComparator<DLFolder> orderByComparator)
2925                    throws NoSuchFolderException {
2926                    DLFolder dlFolder = fetchByRepositoryId_First(repositoryId,
2927                                    orderByComparator);
2928    
2929                    if (dlFolder != null) {
2930                            return dlFolder;
2931                    }
2932    
2933                    StringBundler msg = new StringBundler(4);
2934    
2935                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2936    
2937                    msg.append("repositoryId=");
2938                    msg.append(repositoryId);
2939    
2940                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2941    
2942                    throw new NoSuchFolderException(msg.toString());
2943            }
2944    
2945            /**
2946             * Returns the first document library folder in the ordered set where repositoryId = &#63;.
2947             *
2948             * @param repositoryId the repository ID
2949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2950             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
2951             */
2952            @Override
2953            public DLFolder fetchByRepositoryId_First(long repositoryId,
2954                    OrderByComparator<DLFolder> orderByComparator) {
2955                    List<DLFolder> list = findByRepositoryId(repositoryId, 0, 1,
2956                                    orderByComparator);
2957    
2958                    if (!list.isEmpty()) {
2959                            return list.get(0);
2960                    }
2961    
2962                    return null;
2963            }
2964    
2965            /**
2966             * Returns the last document library folder in the ordered set where repositoryId = &#63;.
2967             *
2968             * @param repositoryId the repository ID
2969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2970             * @return the last matching document library folder
2971             * @throws NoSuchFolderException if a matching document library folder could not be found
2972             */
2973            @Override
2974            public DLFolder findByRepositoryId_Last(long repositoryId,
2975                    OrderByComparator<DLFolder> orderByComparator)
2976                    throws NoSuchFolderException {
2977                    DLFolder dlFolder = fetchByRepositoryId_Last(repositoryId,
2978                                    orderByComparator);
2979    
2980                    if (dlFolder != null) {
2981                            return dlFolder;
2982                    }
2983    
2984                    StringBundler msg = new StringBundler(4);
2985    
2986                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2987    
2988                    msg.append("repositoryId=");
2989                    msg.append(repositoryId);
2990    
2991                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2992    
2993                    throw new NoSuchFolderException(msg.toString());
2994            }
2995    
2996            /**
2997             * Returns the last document library folder in the ordered set where repositoryId = &#63;.
2998             *
2999             * @param repositoryId the repository ID
3000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3001             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
3002             */
3003            @Override
3004            public DLFolder fetchByRepositoryId_Last(long repositoryId,
3005                    OrderByComparator<DLFolder> orderByComparator) {
3006                    int count = countByRepositoryId(repositoryId);
3007    
3008                    if (count == 0) {
3009                            return null;
3010                    }
3011    
3012                    List<DLFolder> list = findByRepositoryId(repositoryId, count - 1,
3013                                    count, orderByComparator);
3014    
3015                    if (!list.isEmpty()) {
3016                            return list.get(0);
3017                    }
3018    
3019                    return null;
3020            }
3021    
3022            /**
3023             * Returns the document library folders before and after the current document library folder in the ordered set where repositoryId = &#63;.
3024             *
3025             * @param folderId the primary key of the current document library folder
3026             * @param repositoryId the repository ID
3027             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3028             * @return the previous, current, and next document library folder
3029             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3030             */
3031            @Override
3032            public DLFolder[] findByRepositoryId_PrevAndNext(long folderId,
3033                    long repositoryId, OrderByComparator<DLFolder> orderByComparator)
3034                    throws NoSuchFolderException {
3035                    DLFolder dlFolder = findByPrimaryKey(folderId);
3036    
3037                    Session session = null;
3038    
3039                    try {
3040                            session = openSession();
3041    
3042                            DLFolder[] array = new DLFolderImpl[3];
3043    
3044                            array[0] = getByRepositoryId_PrevAndNext(session, dlFolder,
3045                                            repositoryId, orderByComparator, true);
3046    
3047                            array[1] = dlFolder;
3048    
3049                            array[2] = getByRepositoryId_PrevAndNext(session, dlFolder,
3050                                            repositoryId, orderByComparator, false);
3051    
3052                            return array;
3053                    }
3054                    catch (Exception e) {
3055                            throw processException(e);
3056                    }
3057                    finally {
3058                            closeSession(session);
3059                    }
3060            }
3061    
3062            protected DLFolder getByRepositoryId_PrevAndNext(Session session,
3063                    DLFolder dlFolder, long repositoryId,
3064                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
3065                    StringBundler query = null;
3066    
3067                    if (orderByComparator != null) {
3068                            query = new StringBundler(6 +
3069                                            (orderByComparator.getOrderByFields().length * 6));
3070                    }
3071                    else {
3072                            query = new StringBundler(3);
3073                    }
3074    
3075                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
3076    
3077                    query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3078    
3079                    if (orderByComparator != null) {
3080                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3081    
3082                            if (orderByConditionFields.length > 0) {
3083                                    query.append(WHERE_AND);
3084                            }
3085    
3086                            for (int i = 0; i < orderByConditionFields.length; i++) {
3087                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3088                                    query.append(orderByConditionFields[i]);
3089    
3090                                    if ((i + 1) < orderByConditionFields.length) {
3091                                            if (orderByComparator.isAscending() ^ previous) {
3092                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3093                                            }
3094                                            else {
3095                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3096                                            }
3097                                    }
3098                                    else {
3099                                            if (orderByComparator.isAscending() ^ previous) {
3100                                                    query.append(WHERE_GREATER_THAN);
3101                                            }
3102                                            else {
3103                                                    query.append(WHERE_LESSER_THAN);
3104                                            }
3105                                    }
3106                            }
3107    
3108                            query.append(ORDER_BY_CLAUSE);
3109    
3110                            String[] orderByFields = orderByComparator.getOrderByFields();
3111    
3112                            for (int i = 0; i < orderByFields.length; i++) {
3113                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3114                                    query.append(orderByFields[i]);
3115    
3116                                    if ((i + 1) < orderByFields.length) {
3117                                            if (orderByComparator.isAscending() ^ previous) {
3118                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3119                                            }
3120                                            else {
3121                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3122                                            }
3123                                    }
3124                                    else {
3125                                            if (orderByComparator.isAscending() ^ previous) {
3126                                                    query.append(ORDER_BY_ASC);
3127                                            }
3128                                            else {
3129                                                    query.append(ORDER_BY_DESC);
3130                                            }
3131                                    }
3132                            }
3133                    }
3134                    else {
3135                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3136                    }
3137    
3138                    String sql = query.toString();
3139    
3140                    Query q = session.createQuery(sql);
3141    
3142                    q.setFirstResult(0);
3143                    q.setMaxResults(2);
3144    
3145                    QueryPos qPos = QueryPos.getInstance(q);
3146    
3147                    qPos.add(repositoryId);
3148    
3149                    if (orderByComparator != null) {
3150                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3151    
3152                            for (Object value : values) {
3153                                    qPos.add(value);
3154                            }
3155                    }
3156    
3157                    List<DLFolder> list = q.list();
3158    
3159                    if (list.size() == 2) {
3160                            return list.get(1);
3161                    }
3162                    else {
3163                            return null;
3164                    }
3165            }
3166    
3167            /**
3168             * Removes all the document library folders where repositoryId = &#63; from the database.
3169             *
3170             * @param repositoryId the repository ID
3171             */
3172            @Override
3173            public void removeByRepositoryId(long repositoryId) {
3174                    for (DLFolder dlFolder : findByRepositoryId(repositoryId,
3175                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3176                            remove(dlFolder);
3177                    }
3178            }
3179    
3180            /**
3181             * Returns the number of document library folders where repositoryId = &#63;.
3182             *
3183             * @param repositoryId the repository ID
3184             * @return the number of matching document library folders
3185             */
3186            @Override
3187            public int countByRepositoryId(long repositoryId) {
3188                    FinderPath finderPath = FINDER_PATH_COUNT_BY_REPOSITORYID;
3189    
3190                    Object[] finderArgs = new Object[] { repositoryId };
3191    
3192                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3193                                    this);
3194    
3195                    if (count == null) {
3196                            StringBundler query = new StringBundler(2);
3197    
3198                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
3199    
3200                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3201    
3202                            String sql = query.toString();
3203    
3204                            Session session = null;
3205    
3206                            try {
3207                                    session = openSession();
3208    
3209                                    Query q = session.createQuery(sql);
3210    
3211                                    QueryPos qPos = QueryPos.getInstance(q);
3212    
3213                                    qPos.add(repositoryId);
3214    
3215                                    count = (Long)q.uniqueResult();
3216    
3217                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3218                            }
3219                            catch (Exception e) {
3220                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3221    
3222                                    throw processException(e);
3223                            }
3224                            finally {
3225                                    closeSession(session);
3226                            }
3227                    }
3228    
3229                    return count.intValue();
3230            }
3231    
3232            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFolder.repositoryId = ?";
3233            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3234                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
3235                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
3236                            new String[] {
3237                                    Long.class.getName(), Long.class.getName(),
3238                                    
3239                            Integer.class.getName(), Integer.class.getName(),
3240                                    OrderByComparator.class.getName()
3241                            });
3242            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3243                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
3244                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
3245                            new String[] { Long.class.getName(), Long.class.getName() },
3246                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
3247                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
3248                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
3249            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3250                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
3251                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
3252                            new String[] { Long.class.getName(), Long.class.getName() });
3253    
3254            /**
3255             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3256             *
3257             * @param groupId the group ID
3258             * @param parentFolderId the parent folder ID
3259             * @return the matching document library folders
3260             */
3261            @Override
3262            public List<DLFolder> findByG_P(long groupId, long parentFolderId) {
3263                    return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3264                            QueryUtil.ALL_POS, null);
3265            }
3266    
3267            /**
3268             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3269             *
3270             * <p>
3271             * 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.
3272             * </p>
3273             *
3274             * @param groupId the group ID
3275             * @param parentFolderId the parent folder ID
3276             * @param start the lower bound of the range of document library folders
3277             * @param end the upper bound of the range of document library folders (not inclusive)
3278             * @return the range of matching document library folders
3279             */
3280            @Override
3281            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
3282                    int start, int end) {
3283                    return findByG_P(groupId, parentFolderId, start, end, null);
3284            }
3285    
3286            /**
3287             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
3288             *
3289             * <p>
3290             * 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.
3291             * </p>
3292             *
3293             * @param groupId the group ID
3294             * @param parentFolderId the parent folder ID
3295             * @param start the lower bound of the range of document library folders
3296             * @param end the upper bound of the range of document library folders (not inclusive)
3297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3298             * @return the ordered range of matching document library folders
3299             */
3300            @Override
3301            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
3302                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
3303                    boolean pagination = true;
3304                    FinderPath finderPath = null;
3305                    Object[] finderArgs = null;
3306    
3307                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3308                                    (orderByComparator == null)) {
3309                            pagination = false;
3310                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
3311                            finderArgs = new Object[] { groupId, parentFolderId };
3312                    }
3313                    else {
3314                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
3315                            finderArgs = new Object[] {
3316                                            groupId, parentFolderId,
3317                                            
3318                                            start, end, orderByComparator
3319                                    };
3320                    }
3321    
3322                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3323                                    finderArgs, this);
3324    
3325                    if ((list != null) && !list.isEmpty()) {
3326                            for (DLFolder dlFolder : list) {
3327                                    if ((groupId != dlFolder.getGroupId()) ||
3328                                                    (parentFolderId != dlFolder.getParentFolderId())) {
3329                                            list = null;
3330    
3331                                            break;
3332                                    }
3333                            }
3334                    }
3335    
3336                    if (list == null) {
3337                            StringBundler query = null;
3338    
3339                            if (orderByComparator != null) {
3340                                    query = new StringBundler(4 +
3341                                                    (orderByComparator.getOrderByFields().length * 3));
3342                            }
3343                            else {
3344                                    query = new StringBundler(4);
3345                            }
3346    
3347                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
3348    
3349                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3350    
3351                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3352    
3353                            if (orderByComparator != null) {
3354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3355                                            orderByComparator);
3356                            }
3357                            else
3358                             if (pagination) {
3359                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3360                            }
3361    
3362                            String sql = query.toString();
3363    
3364                            Session session = null;
3365    
3366                            try {
3367                                    session = openSession();
3368    
3369                                    Query q = session.createQuery(sql);
3370    
3371                                    QueryPos qPos = QueryPos.getInstance(q);
3372    
3373                                    qPos.add(groupId);
3374    
3375                                    qPos.add(parentFolderId);
3376    
3377                                    if (!pagination) {
3378                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3379                                                            start, end, false);
3380    
3381                                            Collections.sort(list);
3382    
3383                                            list = Collections.unmodifiableList(list);
3384                                    }
3385                                    else {
3386                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
3387                                                            start, end);
3388                                    }
3389    
3390                                    cacheResult(list);
3391    
3392                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3393                            }
3394                            catch (Exception e) {
3395                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3396    
3397                                    throw processException(e);
3398                            }
3399                            finally {
3400                                    closeSession(session);
3401                            }
3402                    }
3403    
3404                    return list;
3405            }
3406    
3407            /**
3408             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3409             *
3410             * @param groupId the group ID
3411             * @param parentFolderId the parent folder ID
3412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3413             * @return the first matching document library folder
3414             * @throws NoSuchFolderException if a matching document library folder could not be found
3415             */
3416            @Override
3417            public DLFolder findByG_P_First(long groupId, long parentFolderId,
3418                    OrderByComparator<DLFolder> orderByComparator)
3419                    throws NoSuchFolderException {
3420                    DLFolder dlFolder = fetchByG_P_First(groupId, parentFolderId,
3421                                    orderByComparator);
3422    
3423                    if (dlFolder != null) {
3424                            return dlFolder;
3425                    }
3426    
3427                    StringBundler msg = new StringBundler(6);
3428    
3429                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3430    
3431                    msg.append("groupId=");
3432                    msg.append(groupId);
3433    
3434                    msg.append(", parentFolderId=");
3435                    msg.append(parentFolderId);
3436    
3437                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3438    
3439                    throw new NoSuchFolderException(msg.toString());
3440            }
3441    
3442            /**
3443             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3444             *
3445             * @param groupId the group ID
3446             * @param parentFolderId the parent folder ID
3447             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3448             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
3449             */
3450            @Override
3451            public DLFolder fetchByG_P_First(long groupId, long parentFolderId,
3452                    OrderByComparator<DLFolder> orderByComparator) {
3453                    List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
3454                                    orderByComparator);
3455    
3456                    if (!list.isEmpty()) {
3457                            return list.get(0);
3458                    }
3459    
3460                    return null;
3461            }
3462    
3463            /**
3464             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3465             *
3466             * @param groupId the group ID
3467             * @param parentFolderId the parent folder ID
3468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3469             * @return the last matching document library folder
3470             * @throws NoSuchFolderException if a matching document library folder could not be found
3471             */
3472            @Override
3473            public DLFolder findByG_P_Last(long groupId, long parentFolderId,
3474                    OrderByComparator<DLFolder> orderByComparator)
3475                    throws NoSuchFolderException {
3476                    DLFolder dlFolder = fetchByG_P_Last(groupId, parentFolderId,
3477                                    orderByComparator);
3478    
3479                    if (dlFolder != null) {
3480                            return dlFolder;
3481                    }
3482    
3483                    StringBundler msg = new StringBundler(6);
3484    
3485                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3486    
3487                    msg.append("groupId=");
3488                    msg.append(groupId);
3489    
3490                    msg.append(", parentFolderId=");
3491                    msg.append(parentFolderId);
3492    
3493                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3494    
3495                    throw new NoSuchFolderException(msg.toString());
3496            }
3497    
3498            /**
3499             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3500             *
3501             * @param groupId the group ID
3502             * @param parentFolderId the parent folder ID
3503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3504             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
3505             */
3506            @Override
3507            public DLFolder fetchByG_P_Last(long groupId, long parentFolderId,
3508                    OrderByComparator<DLFolder> orderByComparator) {
3509                    int count = countByG_P(groupId, parentFolderId);
3510    
3511                    if (count == 0) {
3512                            return null;
3513                    }
3514    
3515                    List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
3516                                    count, orderByComparator);
3517    
3518                    if (!list.isEmpty()) {
3519                            return list.get(0);
3520                    }
3521    
3522                    return null;
3523            }
3524    
3525            /**
3526             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3527             *
3528             * @param folderId the primary key of the current document library folder
3529             * @param groupId the group ID
3530             * @param parentFolderId the parent folder ID
3531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3532             * @return the previous, current, and next document library folder
3533             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3534             */
3535            @Override
3536            public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
3537                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
3538                    throws NoSuchFolderException {
3539                    DLFolder dlFolder = findByPrimaryKey(folderId);
3540    
3541                    Session session = null;
3542    
3543                    try {
3544                            session = openSession();
3545    
3546                            DLFolder[] array = new DLFolderImpl[3];
3547    
3548                            array[0] = getByG_P_PrevAndNext(session, dlFolder, groupId,
3549                                            parentFolderId, orderByComparator, true);
3550    
3551                            array[1] = dlFolder;
3552    
3553                            array[2] = getByG_P_PrevAndNext(session, dlFolder, groupId,
3554                                            parentFolderId, orderByComparator, false);
3555    
3556                            return array;
3557                    }
3558                    catch (Exception e) {
3559                            throw processException(e);
3560                    }
3561                    finally {
3562                            closeSession(session);
3563                    }
3564            }
3565    
3566            protected DLFolder getByG_P_PrevAndNext(Session session, DLFolder dlFolder,
3567                    long groupId, long parentFolderId,
3568                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
3569                    StringBundler query = null;
3570    
3571                    if (orderByComparator != null) {
3572                            query = new StringBundler(6 +
3573                                            (orderByComparator.getOrderByFields().length * 6));
3574                    }
3575                    else {
3576                            query = new StringBundler(3);
3577                    }
3578    
3579                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
3580    
3581                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3582    
3583                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3584    
3585                    if (orderByComparator != null) {
3586                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3587    
3588                            if (orderByConditionFields.length > 0) {
3589                                    query.append(WHERE_AND);
3590                            }
3591    
3592                            for (int i = 0; i < orderByConditionFields.length; i++) {
3593                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3594                                    query.append(orderByConditionFields[i]);
3595    
3596                                    if ((i + 1) < orderByConditionFields.length) {
3597                                            if (orderByComparator.isAscending() ^ previous) {
3598                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3599                                            }
3600                                            else {
3601                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3602                                            }
3603                                    }
3604                                    else {
3605                                            if (orderByComparator.isAscending() ^ previous) {
3606                                                    query.append(WHERE_GREATER_THAN);
3607                                            }
3608                                            else {
3609                                                    query.append(WHERE_LESSER_THAN);
3610                                            }
3611                                    }
3612                            }
3613    
3614                            query.append(ORDER_BY_CLAUSE);
3615    
3616                            String[] orderByFields = orderByComparator.getOrderByFields();
3617    
3618                            for (int i = 0; i < orderByFields.length; i++) {
3619                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3620                                    query.append(orderByFields[i]);
3621    
3622                                    if ((i + 1) < orderByFields.length) {
3623                                            if (orderByComparator.isAscending() ^ previous) {
3624                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3625                                            }
3626                                            else {
3627                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3628                                            }
3629                                    }
3630                                    else {
3631                                            if (orderByComparator.isAscending() ^ previous) {
3632                                                    query.append(ORDER_BY_ASC);
3633                                            }
3634                                            else {
3635                                                    query.append(ORDER_BY_DESC);
3636                                            }
3637                                    }
3638                            }
3639                    }
3640                    else {
3641                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3642                    }
3643    
3644                    String sql = query.toString();
3645    
3646                    Query q = session.createQuery(sql);
3647    
3648                    q.setFirstResult(0);
3649                    q.setMaxResults(2);
3650    
3651                    QueryPos qPos = QueryPos.getInstance(q);
3652    
3653                    qPos.add(groupId);
3654    
3655                    qPos.add(parentFolderId);
3656    
3657                    if (orderByComparator != null) {
3658                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3659    
3660                            for (Object value : values) {
3661                                    qPos.add(value);
3662                            }
3663                    }
3664    
3665                    List<DLFolder> list = q.list();
3666    
3667                    if (list.size() == 2) {
3668                            return list.get(1);
3669                    }
3670                    else {
3671                            return null;
3672                    }
3673            }
3674    
3675            /**
3676             * Returns all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3677             *
3678             * @param groupId the group ID
3679             * @param parentFolderId the parent folder ID
3680             * @return the matching document library folders that the user has permission to view
3681             */
3682            @Override
3683            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId) {
3684                    return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3685                            QueryUtil.ALL_POS, null);
3686            }
3687    
3688            /**
3689             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3690             *
3691             * <p>
3692             * 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.
3693             * </p>
3694             *
3695             * @param groupId the group ID
3696             * @param parentFolderId the parent folder ID
3697             * @param start the lower bound of the range of document library folders
3698             * @param end the upper bound of the range of document library folders (not inclusive)
3699             * @return the range of matching document library folders that the user has permission to view
3700             */
3701            @Override
3702            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3703                    int start, int end) {
3704                    return filterFindByG_P(groupId, parentFolderId, start, end, null);
3705            }
3706    
3707            /**
3708             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63;.
3709             *
3710             * <p>
3711             * 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.
3712             * </p>
3713             *
3714             * @param groupId the group ID
3715             * @param parentFolderId the parent folder ID
3716             * @param start the lower bound of the range of document library folders
3717             * @param end the upper bound of the range of document library folders (not inclusive)
3718             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3719             * @return the ordered range of matching document library folders that the user has permission to view
3720             */
3721            @Override
3722            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3723                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
3724                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3725                            return findByG_P(groupId, parentFolderId, start, end,
3726                                    orderByComparator);
3727                    }
3728    
3729                    StringBundler query = null;
3730    
3731                    if (orderByComparator != null) {
3732                            query = new StringBundler(4 +
3733                                            (orderByComparator.getOrderByFields().length * 3));
3734                    }
3735                    else {
3736                            query = new StringBundler(4);
3737                    }
3738    
3739                    if (getDB().isSupportsInlineDistinct()) {
3740                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3741                    }
3742                    else {
3743                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3744                    }
3745    
3746                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3747    
3748                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3749    
3750                    if (!getDB().isSupportsInlineDistinct()) {
3751                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3752                    }
3753    
3754                    if (orderByComparator != null) {
3755                            if (getDB().isSupportsInlineDistinct()) {
3756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3757                                            orderByComparator, true);
3758                            }
3759                            else {
3760                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3761                                            orderByComparator, true);
3762                            }
3763                    }
3764                    else {
3765                            if (getDB().isSupportsInlineDistinct()) {
3766                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3767                            }
3768                            else {
3769                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
3770                            }
3771                    }
3772    
3773                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3774                                    DLFolder.class.getName(),
3775                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3776    
3777                    Session session = null;
3778    
3779                    try {
3780                            session = openSession();
3781    
3782                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3783    
3784                            if (getDB().isSupportsInlineDistinct()) {
3785                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3786                            }
3787                            else {
3788                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3789                            }
3790    
3791                            QueryPos qPos = QueryPos.getInstance(q);
3792    
3793                            qPos.add(groupId);
3794    
3795                            qPos.add(parentFolderId);
3796    
3797                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
3798                    }
3799                    catch (Exception e) {
3800                            throw processException(e);
3801                    }
3802                    finally {
3803                            closeSession(session);
3804                    }
3805            }
3806    
3807            /**
3808             * 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;.
3809             *
3810             * @param folderId the primary key of the current document library folder
3811             * @param groupId the group ID
3812             * @param parentFolderId the parent folder ID
3813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3814             * @return the previous, current, and next document library folder
3815             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
3816             */
3817            @Override
3818            public DLFolder[] filterFindByG_P_PrevAndNext(long folderId, long groupId,
3819                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
3820                    throws NoSuchFolderException {
3821                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3822                            return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3823                                    orderByComparator);
3824                    }
3825    
3826                    DLFolder dlFolder = findByPrimaryKey(folderId);
3827    
3828                    Session session = null;
3829    
3830                    try {
3831                            session = openSession();
3832    
3833                            DLFolder[] array = new DLFolderImpl[3];
3834    
3835                            array[0] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3836                                            parentFolderId, orderByComparator, true);
3837    
3838                            array[1] = dlFolder;
3839    
3840                            array[2] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3841                                            parentFolderId, orderByComparator, false);
3842    
3843                            return array;
3844                    }
3845                    catch (Exception e) {
3846                            throw processException(e);
3847                    }
3848                    finally {
3849                            closeSession(session);
3850                    }
3851            }
3852    
3853            protected DLFolder filterGetByG_P_PrevAndNext(Session session,
3854                    DLFolder dlFolder, long groupId, long parentFolderId,
3855                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
3856                    StringBundler query = null;
3857    
3858                    if (orderByComparator != null) {
3859                            query = new StringBundler(6 +
3860                                            (orderByComparator.getOrderByFields().length * 6));
3861                    }
3862                    else {
3863                            query = new StringBundler(3);
3864                    }
3865    
3866                    if (getDB().isSupportsInlineDistinct()) {
3867                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3868                    }
3869                    else {
3870                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3871                    }
3872    
3873                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3874    
3875                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3876    
3877                    if (!getDB().isSupportsInlineDistinct()) {
3878                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3879                    }
3880    
3881                    if (orderByComparator != null) {
3882                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3883    
3884                            if (orderByConditionFields.length > 0) {
3885                                    query.append(WHERE_AND);
3886                            }
3887    
3888                            for (int i = 0; i < orderByConditionFields.length; i++) {
3889                                    if (getDB().isSupportsInlineDistinct()) {
3890                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3891                                    }
3892                                    else {
3893                                            query.append(_ORDER_BY_ENTITY_TABLE);
3894                                    }
3895    
3896                                    query.append(orderByConditionFields[i]);
3897    
3898                                    if ((i + 1) < orderByConditionFields.length) {
3899                                            if (orderByComparator.isAscending() ^ previous) {
3900                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3901                                            }
3902                                            else {
3903                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3904                                            }
3905                                    }
3906                                    else {
3907                                            if (orderByComparator.isAscending() ^ previous) {
3908                                                    query.append(WHERE_GREATER_THAN);
3909                                            }
3910                                            else {
3911                                                    query.append(WHERE_LESSER_THAN);
3912                                            }
3913                                    }
3914                            }
3915    
3916                            query.append(ORDER_BY_CLAUSE);
3917    
3918                            String[] orderByFields = orderByComparator.getOrderByFields();
3919    
3920                            for (int i = 0; i < orderByFields.length; i++) {
3921                                    if (getDB().isSupportsInlineDistinct()) {
3922                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3923                                    }
3924                                    else {
3925                                            query.append(_ORDER_BY_ENTITY_TABLE);
3926                                    }
3927    
3928                                    query.append(orderByFields[i]);
3929    
3930                                    if ((i + 1) < orderByFields.length) {
3931                                            if (orderByComparator.isAscending() ^ previous) {
3932                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3933                                            }
3934                                            else {
3935                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3936                                            }
3937                                    }
3938                                    else {
3939                                            if (orderByComparator.isAscending() ^ previous) {
3940                                                    query.append(ORDER_BY_ASC);
3941                                            }
3942                                            else {
3943                                                    query.append(ORDER_BY_DESC);
3944                                            }
3945                                    }
3946                            }
3947                    }
3948                    else {
3949                            if (getDB().isSupportsInlineDistinct()) {
3950                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3951                            }
3952                            else {
3953                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
3954                            }
3955                    }
3956    
3957                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3958                                    DLFolder.class.getName(),
3959                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3960    
3961                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3962    
3963                    q.setFirstResult(0);
3964                    q.setMaxResults(2);
3965    
3966                    if (getDB().isSupportsInlineDistinct()) {
3967                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3968                    }
3969                    else {
3970                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3971                    }
3972    
3973                    QueryPos qPos = QueryPos.getInstance(q);
3974    
3975                    qPos.add(groupId);
3976    
3977                    qPos.add(parentFolderId);
3978    
3979                    if (orderByComparator != null) {
3980                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3981    
3982                            for (Object value : values) {
3983                                    qPos.add(value);
3984                            }
3985                    }
3986    
3987                    List<DLFolder> list = q.list();
3988    
3989                    if (list.size() == 2) {
3990                            return list.get(1);
3991                    }
3992                    else {
3993                            return null;
3994                    }
3995            }
3996    
3997            /**
3998             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; from the database.
3999             *
4000             * @param groupId the group ID
4001             * @param parentFolderId the parent folder ID
4002             */
4003            @Override
4004            public void removeByG_P(long groupId, long parentFolderId) {
4005                    for (DLFolder dlFolder : findByG_P(groupId, parentFolderId,
4006                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4007                            remove(dlFolder);
4008                    }
4009            }
4010    
4011            /**
4012             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63;.
4013             *
4014             * @param groupId the group ID
4015             * @param parentFolderId the parent folder ID
4016             * @return the number of matching document library folders
4017             */
4018            @Override
4019            public int countByG_P(long groupId, long parentFolderId) {
4020                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
4021    
4022                    Object[] finderArgs = new Object[] { groupId, parentFolderId };
4023    
4024                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4025                                    this);
4026    
4027                    if (count == null) {
4028                            StringBundler query = new StringBundler(3);
4029    
4030                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4031    
4032                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4033    
4034                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4035    
4036                            String sql = query.toString();
4037    
4038                            Session session = null;
4039    
4040                            try {
4041                                    session = openSession();
4042    
4043                                    Query q = session.createQuery(sql);
4044    
4045                                    QueryPos qPos = QueryPos.getInstance(q);
4046    
4047                                    qPos.add(groupId);
4048    
4049                                    qPos.add(parentFolderId);
4050    
4051                                    count = (Long)q.uniqueResult();
4052    
4053                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4054                            }
4055                            catch (Exception e) {
4056                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4057    
4058                                    throw processException(e);
4059                            }
4060                            finally {
4061                                    closeSession(session);
4062                            }
4063                    }
4064    
4065                    return count.intValue();
4066            }
4067    
4068            /**
4069             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
4070             *
4071             * @param groupId the group ID
4072             * @param parentFolderId the parent folder ID
4073             * @return the number of matching document library folders that the user has permission to view
4074             */
4075            @Override
4076            public int filterCountByG_P(long groupId, long parentFolderId) {
4077                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4078                            return countByG_P(groupId, parentFolderId);
4079                    }
4080    
4081                    StringBundler query = new StringBundler(3);
4082    
4083                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
4084    
4085                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4086    
4087                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4088    
4089                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4090                                    DLFolder.class.getName(),
4091                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4092    
4093                    Session session = null;
4094    
4095                    try {
4096                            session = openSession();
4097    
4098                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4099    
4100                            q.addScalar(COUNT_COLUMN_NAME,
4101                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4102    
4103                            QueryPos qPos = QueryPos.getInstance(q);
4104    
4105                            qPos.add(groupId);
4106    
4107                            qPos.add(parentFolderId);
4108    
4109                            Long count = (Long)q.uniqueResult();
4110    
4111                            return count.intValue();
4112                    }
4113                    catch (Exception e) {
4114                            throw processException(e);
4115                    }
4116                    finally {
4117                            closeSession(session);
4118                    }
4119            }
4120    
4121            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
4122            private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
4123            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4124                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
4126                            new String[] {
4127                                    Long.class.getName(), Integer.class.getName(),
4128                                    
4129                            Integer.class.getName(), Integer.class.getName(),
4130                                    OrderByComparator.class.getName()
4131                            });
4132            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4133                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4134                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
4135                            new String[] { Long.class.getName(), Integer.class.getName() });
4136    
4137            /**
4138             * Returns all the document library folders where companyId = &#63; and status &ne; &#63;.
4139             *
4140             * @param companyId the company ID
4141             * @param status the status
4142             * @return the matching document library folders
4143             */
4144            @Override
4145            public List<DLFolder> findByC_NotS(long companyId, int status) {
4146                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
4147                            QueryUtil.ALL_POS, null);
4148            }
4149    
4150            /**
4151             * Returns a range of all the document library folders where companyId = &#63; and status &ne; &#63;.
4152             *
4153             * <p>
4154             * 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.
4155             * </p>
4156             *
4157             * @param companyId the company ID
4158             * @param status the status
4159             * @param start the lower bound of the range of document library folders
4160             * @param end the upper bound of the range of document library folders (not inclusive)
4161             * @return the range of matching document library folders
4162             */
4163            @Override
4164            public List<DLFolder> findByC_NotS(long companyId, int status, int start,
4165                    int end) {
4166                    return findByC_NotS(companyId, status, start, end, null);
4167            }
4168    
4169            /**
4170             * Returns an ordered range of all the document library folders where companyId = &#63; and status &ne; &#63;.
4171             *
4172             * <p>
4173             * 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.
4174             * </p>
4175             *
4176             * @param companyId the company ID
4177             * @param status the status
4178             * @param start the lower bound of the range of document library folders
4179             * @param end the upper bound of the range of document library folders (not inclusive)
4180             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4181             * @return the ordered range of matching document library folders
4182             */
4183            @Override
4184            public List<DLFolder> findByC_NotS(long companyId, int status, int start,
4185                    int end, OrderByComparator<DLFolder> orderByComparator) {
4186                    boolean pagination = true;
4187                    FinderPath finderPath = null;
4188                    Object[] finderArgs = null;
4189    
4190                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
4191                    finderArgs = new Object[] {
4192                                    companyId, status,
4193                                    
4194                                    start, end, orderByComparator
4195                            };
4196    
4197                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
4198                                    finderArgs, this);
4199    
4200                    if ((list != null) && !list.isEmpty()) {
4201                            for (DLFolder dlFolder : list) {
4202                                    if ((companyId != dlFolder.getCompanyId()) ||
4203                                                    (status == dlFolder.getStatus())) {
4204                                            list = null;
4205    
4206                                            break;
4207                                    }
4208                            }
4209                    }
4210    
4211                    if (list == null) {
4212                            StringBundler query = null;
4213    
4214                            if (orderByComparator != null) {
4215                                    query = new StringBundler(4 +
4216                                                    (orderByComparator.getOrderByFields().length * 3));
4217                            }
4218                            else {
4219                                    query = new StringBundler(4);
4220                            }
4221    
4222                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4223    
4224                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4225    
4226                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4227    
4228                            if (orderByComparator != null) {
4229                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4230                                            orderByComparator);
4231                            }
4232                            else
4233                             if (pagination) {
4234                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4235                            }
4236    
4237                            String sql = query.toString();
4238    
4239                            Session session = null;
4240    
4241                            try {
4242                                    session = openSession();
4243    
4244                                    Query q = session.createQuery(sql);
4245    
4246                                    QueryPos qPos = QueryPos.getInstance(q);
4247    
4248                                    qPos.add(companyId);
4249    
4250                                    qPos.add(status);
4251    
4252                                    if (!pagination) {
4253                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4254                                                            start, end, false);
4255    
4256                                            Collections.sort(list);
4257    
4258                                            list = Collections.unmodifiableList(list);
4259                                    }
4260                                    else {
4261                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4262                                                            start, end);
4263                                    }
4264    
4265                                    cacheResult(list);
4266    
4267                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4268                            }
4269                            catch (Exception e) {
4270                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4271    
4272                                    throw processException(e);
4273                            }
4274                            finally {
4275                                    closeSession(session);
4276                            }
4277                    }
4278    
4279                    return list;
4280            }
4281    
4282            /**
4283             * Returns the first document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4284             *
4285             * @param companyId the company ID
4286             * @param status the status
4287             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4288             * @return the first matching document library folder
4289             * @throws NoSuchFolderException if a matching document library folder could not be found
4290             */
4291            @Override
4292            public DLFolder findByC_NotS_First(long companyId, int status,
4293                    OrderByComparator<DLFolder> orderByComparator)
4294                    throws NoSuchFolderException {
4295                    DLFolder dlFolder = fetchByC_NotS_First(companyId, status,
4296                                    orderByComparator);
4297    
4298                    if (dlFolder != null) {
4299                            return dlFolder;
4300                    }
4301    
4302                    StringBundler msg = new StringBundler(6);
4303    
4304                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4305    
4306                    msg.append("companyId=");
4307                    msg.append(companyId);
4308    
4309                    msg.append(", status=");
4310                    msg.append(status);
4311    
4312                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4313    
4314                    throw new NoSuchFolderException(msg.toString());
4315            }
4316    
4317            /**
4318             * Returns the first document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4319             *
4320             * @param companyId the company ID
4321             * @param status the status
4322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4323             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
4324             */
4325            @Override
4326            public DLFolder fetchByC_NotS_First(long companyId, int status,
4327                    OrderByComparator<DLFolder> orderByComparator) {
4328                    List<DLFolder> list = findByC_NotS(companyId, status, 0, 1,
4329                                    orderByComparator);
4330    
4331                    if (!list.isEmpty()) {
4332                            return list.get(0);
4333                    }
4334    
4335                    return null;
4336            }
4337    
4338            /**
4339             * Returns the last document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4340             *
4341             * @param companyId the company ID
4342             * @param status the status
4343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4344             * @return the last matching document library folder
4345             * @throws NoSuchFolderException if a matching document library folder could not be found
4346             */
4347            @Override
4348            public DLFolder findByC_NotS_Last(long companyId, int status,
4349                    OrderByComparator<DLFolder> orderByComparator)
4350                    throws NoSuchFolderException {
4351                    DLFolder dlFolder = fetchByC_NotS_Last(companyId, status,
4352                                    orderByComparator);
4353    
4354                    if (dlFolder != null) {
4355                            return dlFolder;
4356                    }
4357    
4358                    StringBundler msg = new StringBundler(6);
4359    
4360                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4361    
4362                    msg.append("companyId=");
4363                    msg.append(companyId);
4364    
4365                    msg.append(", status=");
4366                    msg.append(status);
4367    
4368                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4369    
4370                    throw new NoSuchFolderException(msg.toString());
4371            }
4372    
4373            /**
4374             * Returns the last document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4375             *
4376             * @param companyId the company ID
4377             * @param status the status
4378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4379             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
4380             */
4381            @Override
4382            public DLFolder fetchByC_NotS_Last(long companyId, int status,
4383                    OrderByComparator<DLFolder> orderByComparator) {
4384                    int count = countByC_NotS(companyId, status);
4385    
4386                    if (count == 0) {
4387                            return null;
4388                    }
4389    
4390                    List<DLFolder> list = findByC_NotS(companyId, status, count - 1, count,
4391                                    orderByComparator);
4392    
4393                    if (!list.isEmpty()) {
4394                            return list.get(0);
4395                    }
4396    
4397                    return null;
4398            }
4399    
4400            /**
4401             * Returns the document library folders before and after the current document library folder in the ordered set where companyId = &#63; and status &ne; &#63;.
4402             *
4403             * @param folderId the primary key of the current document library folder
4404             * @param companyId the company ID
4405             * @param status the status
4406             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4407             * @return the previous, current, and next document library folder
4408             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
4409             */
4410            @Override
4411            public DLFolder[] findByC_NotS_PrevAndNext(long folderId, long companyId,
4412                    int status, OrderByComparator<DLFolder> orderByComparator)
4413                    throws NoSuchFolderException {
4414                    DLFolder dlFolder = findByPrimaryKey(folderId);
4415    
4416                    Session session = null;
4417    
4418                    try {
4419                            session = openSession();
4420    
4421                            DLFolder[] array = new DLFolderImpl[3];
4422    
4423                            array[0] = getByC_NotS_PrevAndNext(session, dlFolder, companyId,
4424                                            status, orderByComparator, true);
4425    
4426                            array[1] = dlFolder;
4427    
4428                            array[2] = getByC_NotS_PrevAndNext(session, dlFolder, companyId,
4429                                            status, orderByComparator, false);
4430    
4431                            return array;
4432                    }
4433                    catch (Exception e) {
4434                            throw processException(e);
4435                    }
4436                    finally {
4437                            closeSession(session);
4438                    }
4439            }
4440    
4441            protected DLFolder getByC_NotS_PrevAndNext(Session session,
4442                    DLFolder dlFolder, long companyId, int status,
4443                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
4444                    StringBundler query = null;
4445    
4446                    if (orderByComparator != null) {
4447                            query = new StringBundler(6 +
4448                                            (orderByComparator.getOrderByFields().length * 6));
4449                    }
4450                    else {
4451                            query = new StringBundler(3);
4452                    }
4453    
4454                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
4455    
4456                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4457    
4458                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4459    
4460                    if (orderByComparator != null) {
4461                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4462    
4463                            if (orderByConditionFields.length > 0) {
4464                                    query.append(WHERE_AND);
4465                            }
4466    
4467                            for (int i = 0; i < orderByConditionFields.length; i++) {
4468                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4469                                    query.append(orderByConditionFields[i]);
4470    
4471                                    if ((i + 1) < orderByConditionFields.length) {
4472                                            if (orderByComparator.isAscending() ^ previous) {
4473                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4474                                            }
4475                                            else {
4476                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4477                                            }
4478                                    }
4479                                    else {
4480                                            if (orderByComparator.isAscending() ^ previous) {
4481                                                    query.append(WHERE_GREATER_THAN);
4482                                            }
4483                                            else {
4484                                                    query.append(WHERE_LESSER_THAN);
4485                                            }
4486                                    }
4487                            }
4488    
4489                            query.append(ORDER_BY_CLAUSE);
4490    
4491                            String[] orderByFields = orderByComparator.getOrderByFields();
4492    
4493                            for (int i = 0; i < orderByFields.length; i++) {
4494                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4495                                    query.append(orderByFields[i]);
4496    
4497                                    if ((i + 1) < orderByFields.length) {
4498                                            if (orderByComparator.isAscending() ^ previous) {
4499                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4500                                            }
4501                                            else {
4502                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4503                                            }
4504                                    }
4505                                    else {
4506                                            if (orderByComparator.isAscending() ^ previous) {
4507                                                    query.append(ORDER_BY_ASC);
4508                                            }
4509                                            else {
4510                                                    query.append(ORDER_BY_DESC);
4511                                            }
4512                                    }
4513                            }
4514                    }
4515                    else {
4516                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4517                    }
4518    
4519                    String sql = query.toString();
4520    
4521                    Query q = session.createQuery(sql);
4522    
4523                    q.setFirstResult(0);
4524                    q.setMaxResults(2);
4525    
4526                    QueryPos qPos = QueryPos.getInstance(q);
4527    
4528                    qPos.add(companyId);
4529    
4530                    qPos.add(status);
4531    
4532                    if (orderByComparator != null) {
4533                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4534    
4535                            for (Object value : values) {
4536                                    qPos.add(value);
4537                            }
4538                    }
4539    
4540                    List<DLFolder> list = q.list();
4541    
4542                    if (list.size() == 2) {
4543                            return list.get(1);
4544                    }
4545                    else {
4546                            return null;
4547                    }
4548            }
4549    
4550            /**
4551             * Removes all the document library folders where companyId = &#63; and status &ne; &#63; from the database.
4552             *
4553             * @param companyId the company ID
4554             * @param status the status
4555             */
4556            @Override
4557            public void removeByC_NotS(long companyId, int status) {
4558                    for (DLFolder dlFolder : findByC_NotS(companyId, status,
4559                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4560                            remove(dlFolder);
4561                    }
4562            }
4563    
4564            /**
4565             * Returns the number of document library folders where companyId = &#63; and status &ne; &#63;.
4566             *
4567             * @param companyId the company ID
4568             * @param status the status
4569             * @return the number of matching document library folders
4570             */
4571            @Override
4572            public int countByC_NotS(long companyId, int status) {
4573                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
4574    
4575                    Object[] finderArgs = new Object[] { companyId, status };
4576    
4577                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4578                                    this);
4579    
4580                    if (count == null) {
4581                            StringBundler query = new StringBundler(3);
4582    
4583                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4584    
4585                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4586    
4587                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4588    
4589                            String sql = query.toString();
4590    
4591                            Session session = null;
4592    
4593                            try {
4594                                    session = openSession();
4595    
4596                                    Query q = session.createQuery(sql);
4597    
4598                                    QueryPos qPos = QueryPos.getInstance(q);
4599    
4600                                    qPos.add(companyId);
4601    
4602                                    qPos.add(status);
4603    
4604                                    count = (Long)q.uniqueResult();
4605    
4606                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4607                            }
4608                            catch (Exception e) {
4609                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4610    
4611                                    throw processException(e);
4612                            }
4613                            finally {
4614                                    closeSession(session);
4615                            }
4616                    }
4617    
4618                    return count.intValue();
4619            }
4620    
4621            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "dlFolder.companyId = ? AND ";
4622            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "dlFolder.status != ?";
4623            public static final FinderPath FINDER_PATH_FETCH_BY_R_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4624                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4625                            FINDER_CLASS_NAME_ENTITY, "fetchByR_M",
4626                            new String[] { Long.class.getName(), Boolean.class.getName() },
4627                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
4628                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK);
4629            public static final FinderPath FINDER_PATH_COUNT_BY_R_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4630                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4631                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_M",
4632                            new String[] { Long.class.getName(), Boolean.class.getName() });
4633    
4634            /**
4635             * Returns the document library folder where repositoryId = &#63; and mountPoint = &#63; or throws a {@link NoSuchFolderException} if it could not be found.
4636             *
4637             * @param repositoryId the repository ID
4638             * @param mountPoint the mount point
4639             * @return the matching document library folder
4640             * @throws NoSuchFolderException if a matching document library folder could not be found
4641             */
4642            @Override
4643            public DLFolder findByR_M(long repositoryId, boolean mountPoint)
4644                    throws NoSuchFolderException {
4645                    DLFolder dlFolder = fetchByR_M(repositoryId, mountPoint);
4646    
4647                    if (dlFolder == null) {
4648                            StringBundler msg = new StringBundler(6);
4649    
4650                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4651    
4652                            msg.append("repositoryId=");
4653                            msg.append(repositoryId);
4654    
4655                            msg.append(", mountPoint=");
4656                            msg.append(mountPoint);
4657    
4658                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4659    
4660                            if (_log.isWarnEnabled()) {
4661                                    _log.warn(msg.toString());
4662                            }
4663    
4664                            throw new NoSuchFolderException(msg.toString());
4665                    }
4666    
4667                    return dlFolder;
4668            }
4669    
4670            /**
4671             * 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.
4672             *
4673             * @param repositoryId the repository ID
4674             * @param mountPoint the mount point
4675             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4676             */
4677            @Override
4678            public DLFolder fetchByR_M(long repositoryId, boolean mountPoint) {
4679                    return fetchByR_M(repositoryId, mountPoint, true);
4680            }
4681    
4682            /**
4683             * 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.
4684             *
4685             * @param repositoryId the repository ID
4686             * @param mountPoint the mount point
4687             * @param retrieveFromCache whether to use the finder cache
4688             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4689             */
4690            @Override
4691            public DLFolder fetchByR_M(long repositoryId, boolean mountPoint,
4692                    boolean retrieveFromCache) {
4693                    Object[] finderArgs = new Object[] { repositoryId, mountPoint };
4694    
4695                    Object result = null;
4696    
4697                    if (retrieveFromCache) {
4698                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_M,
4699                                            finderArgs, this);
4700                    }
4701    
4702                    if (result instanceof DLFolder) {
4703                            DLFolder dlFolder = (DLFolder)result;
4704    
4705                            if ((repositoryId != dlFolder.getRepositoryId()) ||
4706                                            (mountPoint != dlFolder.getMountPoint())) {
4707                                    result = null;
4708                            }
4709                    }
4710    
4711                    if (result == null) {
4712                            StringBundler query = new StringBundler(4);
4713    
4714                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4715    
4716                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
4717    
4718                            query.append(_FINDER_COLUMN_R_M_MOUNTPOINT_2);
4719    
4720                            String sql = query.toString();
4721    
4722                            Session session = null;
4723    
4724                            try {
4725                                    session = openSession();
4726    
4727                                    Query q = session.createQuery(sql);
4728    
4729                                    QueryPos qPos = QueryPos.getInstance(q);
4730    
4731                                    qPos.add(repositoryId);
4732    
4733                                    qPos.add(mountPoint);
4734    
4735                                    List<DLFolder> list = q.list();
4736    
4737                                    if (list.isEmpty()) {
4738                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
4739                                                    finderArgs, list);
4740                                    }
4741                                    else {
4742                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
4743                                                    _log.warn(
4744                                                            "DLFolderPersistenceImpl.fetchByR_M(long, boolean, boolean) with parameters (" +
4745                                                            StringUtil.merge(finderArgs) +
4746                                                            ") 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.");
4747                                            }
4748    
4749                                            DLFolder dlFolder = list.get(0);
4750    
4751                                            result = dlFolder;
4752    
4753                                            cacheResult(dlFolder);
4754    
4755                                            if ((dlFolder.getRepositoryId() != repositoryId) ||
4756                                                            (dlFolder.getMountPoint() != mountPoint)) {
4757                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
4758                                                            finderArgs, dlFolder);
4759                                            }
4760                                    }
4761                            }
4762                            catch (Exception e) {
4763                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M,
4764                                            finderArgs);
4765    
4766                                    throw processException(e);
4767                            }
4768                            finally {
4769                                    closeSession(session);
4770                            }
4771                    }
4772    
4773                    if (result instanceof List<?>) {
4774                            return null;
4775                    }
4776                    else {
4777                            return (DLFolder)result;
4778                    }
4779            }
4780    
4781            /**
4782             * Removes the document library folder where repositoryId = &#63; and mountPoint = &#63; from the database.
4783             *
4784             * @param repositoryId the repository ID
4785             * @param mountPoint the mount point
4786             * @return the document library folder that was removed
4787             */
4788            @Override
4789            public DLFolder removeByR_M(long repositoryId, boolean mountPoint)
4790                    throws NoSuchFolderException {
4791                    DLFolder dlFolder = findByR_M(repositoryId, mountPoint);
4792    
4793                    return remove(dlFolder);
4794            }
4795    
4796            /**
4797             * Returns the number of document library folders where repositoryId = &#63; and mountPoint = &#63;.
4798             *
4799             * @param repositoryId the repository ID
4800             * @param mountPoint the mount point
4801             * @return the number of matching document library folders
4802             */
4803            @Override
4804            public int countByR_M(long repositoryId, boolean mountPoint) {
4805                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_M;
4806    
4807                    Object[] finderArgs = new Object[] { repositoryId, mountPoint };
4808    
4809                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4810                                    this);
4811    
4812                    if (count == null) {
4813                            StringBundler query = new StringBundler(3);
4814    
4815                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
4816    
4817                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
4818    
4819                            query.append(_FINDER_COLUMN_R_M_MOUNTPOINT_2);
4820    
4821                            String sql = query.toString();
4822    
4823                            Session session = null;
4824    
4825                            try {
4826                                    session = openSession();
4827    
4828                                    Query q = session.createQuery(sql);
4829    
4830                                    QueryPos qPos = QueryPos.getInstance(q);
4831    
4832                                    qPos.add(repositoryId);
4833    
4834                                    qPos.add(mountPoint);
4835    
4836                                    count = (Long)q.uniqueResult();
4837    
4838                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4839                            }
4840                            catch (Exception e) {
4841                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4842    
4843                                    throw processException(e);
4844                            }
4845                            finally {
4846                                    closeSession(session);
4847                            }
4848                    }
4849    
4850                    return count.intValue();
4851            }
4852    
4853            private static final String _FINDER_COLUMN_R_M_REPOSITORYID_2 = "dlFolder.repositoryId = ? AND ";
4854            private static final String _FINDER_COLUMN_R_M_MOUNTPOINT_2 = "dlFolder.mountPoint = ?";
4855            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4856                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4857                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_P",
4858                            new String[] {
4859                                    Long.class.getName(), Long.class.getName(),
4860                                    
4861                            Integer.class.getName(), Integer.class.getName(),
4862                                    OrderByComparator.class.getName()
4863                            });
4864            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4865                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
4866                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_P",
4867                            new String[] { Long.class.getName(), Long.class.getName() },
4868                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK |
4869                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
4870                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
4871            public static final FinderPath FINDER_PATH_COUNT_BY_R_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
4872                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4873                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_P",
4874                            new String[] { Long.class.getName(), Long.class.getName() });
4875    
4876            /**
4877             * Returns all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
4878             *
4879             * @param repositoryId the repository ID
4880             * @param parentFolderId the parent folder ID
4881             * @return the matching document library folders
4882             */
4883            @Override
4884            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId) {
4885                    return findByR_P(repositoryId, parentFolderId, QueryUtil.ALL_POS,
4886                            QueryUtil.ALL_POS, null);
4887            }
4888    
4889            /**
4890             * Returns a range of all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
4891             *
4892             * <p>
4893             * 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.
4894             * </p>
4895             *
4896             * @param repositoryId the repository ID
4897             * @param parentFolderId the parent folder ID
4898             * @param start the lower bound of the range of document library folders
4899             * @param end the upper bound of the range of document library folders (not inclusive)
4900             * @return the range of matching document library folders
4901             */
4902            @Override
4903            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId,
4904                    int start, int end) {
4905                    return findByR_P(repositoryId, parentFolderId, start, end, null);
4906            }
4907    
4908            /**
4909             * Returns an ordered range of all the document library folders where repositoryId = &#63; and parentFolderId = &#63;.
4910             *
4911             * <p>
4912             * 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.
4913             * </p>
4914             *
4915             * @param repositoryId the repository ID
4916             * @param parentFolderId the parent folder ID
4917             * @param start the lower bound of the range of document library folders
4918             * @param end the upper bound of the range of document library folders (not inclusive)
4919             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4920             * @return the ordered range of matching document library folders
4921             */
4922            @Override
4923            public List<DLFolder> findByR_P(long repositoryId, long parentFolderId,
4924                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
4925                    boolean pagination = true;
4926                    FinderPath finderPath = null;
4927                    Object[] finderArgs = null;
4928    
4929                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4930                                    (orderByComparator == null)) {
4931                            pagination = false;
4932                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P;
4933                            finderArgs = new Object[] { repositoryId, parentFolderId };
4934                    }
4935                    else {
4936                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_P;
4937                            finderArgs = new Object[] {
4938                                            repositoryId, parentFolderId,
4939                                            
4940                                            start, end, orderByComparator
4941                                    };
4942                    }
4943    
4944                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
4945                                    finderArgs, this);
4946    
4947                    if ((list != null) && !list.isEmpty()) {
4948                            for (DLFolder dlFolder : list) {
4949                                    if ((repositoryId != dlFolder.getRepositoryId()) ||
4950                                                    (parentFolderId != dlFolder.getParentFolderId())) {
4951                                            list = null;
4952    
4953                                            break;
4954                                    }
4955                            }
4956                    }
4957    
4958                    if (list == null) {
4959                            StringBundler query = null;
4960    
4961                            if (orderByComparator != null) {
4962                                    query = new StringBundler(4 +
4963                                                    (orderByComparator.getOrderByFields().length * 3));
4964                            }
4965                            else {
4966                                    query = new StringBundler(4);
4967                            }
4968    
4969                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4970    
4971                            query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
4972    
4973                            query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
4974    
4975                            if (orderByComparator != null) {
4976                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4977                                            orderByComparator);
4978                            }
4979                            else
4980                             if (pagination) {
4981                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4982                            }
4983    
4984                            String sql = query.toString();
4985    
4986                            Session session = null;
4987    
4988                            try {
4989                                    session = openSession();
4990    
4991                                    Query q = session.createQuery(sql);
4992    
4993                                    QueryPos qPos = QueryPos.getInstance(q);
4994    
4995                                    qPos.add(repositoryId);
4996    
4997                                    qPos.add(parentFolderId);
4998    
4999                                    if (!pagination) {
5000                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5001                                                            start, end, false);
5002    
5003                                            Collections.sort(list);
5004    
5005                                            list = Collections.unmodifiableList(list);
5006                                    }
5007                                    else {
5008                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5009                                                            start, end);
5010                                    }
5011    
5012                                    cacheResult(list);
5013    
5014                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5015                            }
5016                            catch (Exception e) {
5017                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5018    
5019                                    throw processException(e);
5020                            }
5021                            finally {
5022                                    closeSession(session);
5023                            }
5024                    }
5025    
5026                    return list;
5027            }
5028    
5029            /**
5030             * Returns the first document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5031             *
5032             * @param repositoryId the repository ID
5033             * @param parentFolderId the parent folder ID
5034             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5035             * @return the first matching document library folder
5036             * @throws NoSuchFolderException if a matching document library folder could not be found
5037             */
5038            @Override
5039            public DLFolder findByR_P_First(long repositoryId, long parentFolderId,
5040                    OrderByComparator<DLFolder> orderByComparator)
5041                    throws NoSuchFolderException {
5042                    DLFolder dlFolder = fetchByR_P_First(repositoryId, parentFolderId,
5043                                    orderByComparator);
5044    
5045                    if (dlFolder != null) {
5046                            return dlFolder;
5047                    }
5048    
5049                    StringBundler msg = new StringBundler(6);
5050    
5051                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5052    
5053                    msg.append("repositoryId=");
5054                    msg.append(repositoryId);
5055    
5056                    msg.append(", parentFolderId=");
5057                    msg.append(parentFolderId);
5058    
5059                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5060    
5061                    throw new NoSuchFolderException(msg.toString());
5062            }
5063    
5064            /**
5065             * Returns the first document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5066             *
5067             * @param repositoryId the repository ID
5068             * @param parentFolderId the parent folder ID
5069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5070             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
5071             */
5072            @Override
5073            public DLFolder fetchByR_P_First(long repositoryId, long parentFolderId,
5074                    OrderByComparator<DLFolder> orderByComparator) {
5075                    List<DLFolder> list = findByR_P(repositoryId, parentFolderId, 0, 1,
5076                                    orderByComparator);
5077    
5078                    if (!list.isEmpty()) {
5079                            return list.get(0);
5080                    }
5081    
5082                    return null;
5083            }
5084    
5085            /**
5086             * Returns the last document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5087             *
5088             * @param repositoryId the repository ID
5089             * @param parentFolderId the parent folder ID
5090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5091             * @return the last matching document library folder
5092             * @throws NoSuchFolderException if a matching document library folder could not be found
5093             */
5094            @Override
5095            public DLFolder findByR_P_Last(long repositoryId, long parentFolderId,
5096                    OrderByComparator<DLFolder> orderByComparator)
5097                    throws NoSuchFolderException {
5098                    DLFolder dlFolder = fetchByR_P_Last(repositoryId, parentFolderId,
5099                                    orderByComparator);
5100    
5101                    if (dlFolder != null) {
5102                            return dlFolder;
5103                    }
5104    
5105                    StringBundler msg = new StringBundler(6);
5106    
5107                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5108    
5109                    msg.append("repositoryId=");
5110                    msg.append(repositoryId);
5111    
5112                    msg.append(", parentFolderId=");
5113                    msg.append(parentFolderId);
5114    
5115                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5116    
5117                    throw new NoSuchFolderException(msg.toString());
5118            }
5119    
5120            /**
5121             * Returns the last document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5122             *
5123             * @param repositoryId the repository ID
5124             * @param parentFolderId the parent folder ID
5125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5126             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
5127             */
5128            @Override
5129            public DLFolder fetchByR_P_Last(long repositoryId, long parentFolderId,
5130                    OrderByComparator<DLFolder> orderByComparator) {
5131                    int count = countByR_P(repositoryId, parentFolderId);
5132    
5133                    if (count == 0) {
5134                            return null;
5135                    }
5136    
5137                    List<DLFolder> list = findByR_P(repositoryId, parentFolderId,
5138                                    count - 1, count, orderByComparator);
5139    
5140                    if (!list.isEmpty()) {
5141                            return list.get(0);
5142                    }
5143    
5144                    return null;
5145            }
5146    
5147            /**
5148             * Returns the document library folders before and after the current document library folder in the ordered set where repositoryId = &#63; and parentFolderId = &#63;.
5149             *
5150             * @param folderId the primary key of the current document library folder
5151             * @param repositoryId the repository ID
5152             * @param parentFolderId the parent folder ID
5153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5154             * @return the previous, current, and next document library folder
5155             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
5156             */
5157            @Override
5158            public DLFolder[] findByR_P_PrevAndNext(long folderId, long repositoryId,
5159                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
5160                    throws NoSuchFolderException {
5161                    DLFolder dlFolder = findByPrimaryKey(folderId);
5162    
5163                    Session session = null;
5164    
5165                    try {
5166                            session = openSession();
5167    
5168                            DLFolder[] array = new DLFolderImpl[3];
5169    
5170                            array[0] = getByR_P_PrevAndNext(session, dlFolder, repositoryId,
5171                                            parentFolderId, orderByComparator, true);
5172    
5173                            array[1] = dlFolder;
5174    
5175                            array[2] = getByR_P_PrevAndNext(session, dlFolder, repositoryId,
5176                                            parentFolderId, orderByComparator, false);
5177    
5178                            return array;
5179                    }
5180                    catch (Exception e) {
5181                            throw processException(e);
5182                    }
5183                    finally {
5184                            closeSession(session);
5185                    }
5186            }
5187    
5188            protected DLFolder getByR_P_PrevAndNext(Session session, DLFolder dlFolder,
5189                    long repositoryId, long parentFolderId,
5190                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
5191                    StringBundler query = null;
5192    
5193                    if (orderByComparator != null) {
5194                            query = new StringBundler(6 +
5195                                            (orderByComparator.getOrderByFields().length * 6));
5196                    }
5197                    else {
5198                            query = new StringBundler(3);
5199                    }
5200    
5201                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
5202    
5203                    query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
5204    
5205                    query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
5206    
5207                    if (orderByComparator != null) {
5208                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5209    
5210                            if (orderByConditionFields.length > 0) {
5211                                    query.append(WHERE_AND);
5212                            }
5213    
5214                            for (int i = 0; i < orderByConditionFields.length; i++) {
5215                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5216                                    query.append(orderByConditionFields[i]);
5217    
5218                                    if ((i + 1) < orderByConditionFields.length) {
5219                                            if (orderByComparator.isAscending() ^ previous) {
5220                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5221                                            }
5222                                            else {
5223                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5224                                            }
5225                                    }
5226                                    else {
5227                                            if (orderByComparator.isAscending() ^ previous) {
5228                                                    query.append(WHERE_GREATER_THAN);
5229                                            }
5230                                            else {
5231                                                    query.append(WHERE_LESSER_THAN);
5232                                            }
5233                                    }
5234                            }
5235    
5236                            query.append(ORDER_BY_CLAUSE);
5237    
5238                            String[] orderByFields = orderByComparator.getOrderByFields();
5239    
5240                            for (int i = 0; i < orderByFields.length; i++) {
5241                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5242                                    query.append(orderByFields[i]);
5243    
5244                                    if ((i + 1) < orderByFields.length) {
5245                                            if (orderByComparator.isAscending() ^ previous) {
5246                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5247                                            }
5248                                            else {
5249                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5250                                            }
5251                                    }
5252                                    else {
5253                                            if (orderByComparator.isAscending() ^ previous) {
5254                                                    query.append(ORDER_BY_ASC);
5255                                            }
5256                                            else {
5257                                                    query.append(ORDER_BY_DESC);
5258                                            }
5259                                    }
5260                            }
5261                    }
5262                    else {
5263                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5264                    }
5265    
5266                    String sql = query.toString();
5267    
5268                    Query q = session.createQuery(sql);
5269    
5270                    q.setFirstResult(0);
5271                    q.setMaxResults(2);
5272    
5273                    QueryPos qPos = QueryPos.getInstance(q);
5274    
5275                    qPos.add(repositoryId);
5276    
5277                    qPos.add(parentFolderId);
5278    
5279                    if (orderByComparator != null) {
5280                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
5281    
5282                            for (Object value : values) {
5283                                    qPos.add(value);
5284                            }
5285                    }
5286    
5287                    List<DLFolder> list = q.list();
5288    
5289                    if (list.size() == 2) {
5290                            return list.get(1);
5291                    }
5292                    else {
5293                            return null;
5294                    }
5295            }
5296    
5297            /**
5298             * Removes all the document library folders where repositoryId = &#63; and parentFolderId = &#63; from the database.
5299             *
5300             * @param repositoryId the repository ID
5301             * @param parentFolderId the parent folder ID
5302             */
5303            @Override
5304            public void removeByR_P(long repositoryId, long parentFolderId) {
5305                    for (DLFolder dlFolder : findByR_P(repositoryId, parentFolderId,
5306                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5307                            remove(dlFolder);
5308                    }
5309            }
5310    
5311            /**
5312             * Returns the number of document library folders where repositoryId = &#63; and parentFolderId = &#63;.
5313             *
5314             * @param repositoryId the repository ID
5315             * @param parentFolderId the parent folder ID
5316             * @return the number of matching document library folders
5317             */
5318            @Override
5319            public int countByR_P(long repositoryId, long parentFolderId) {
5320                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_P;
5321    
5322                    Object[] finderArgs = new Object[] { repositoryId, parentFolderId };
5323    
5324                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5325                                    this);
5326    
5327                    if (count == null) {
5328                            StringBundler query = new StringBundler(3);
5329    
5330                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5331    
5332                            query.append(_FINDER_COLUMN_R_P_REPOSITORYID_2);
5333    
5334                            query.append(_FINDER_COLUMN_R_P_PARENTFOLDERID_2);
5335    
5336                            String sql = query.toString();
5337    
5338                            Session session = null;
5339    
5340                            try {
5341                                    session = openSession();
5342    
5343                                    Query q = session.createQuery(sql);
5344    
5345                                    QueryPos qPos = QueryPos.getInstance(q);
5346    
5347                                    qPos.add(repositoryId);
5348    
5349                                    qPos.add(parentFolderId);
5350    
5351                                    count = (Long)q.uniqueResult();
5352    
5353                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5354                            }
5355                            catch (Exception e) {
5356                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5357    
5358                                    throw processException(e);
5359                            }
5360                            finally {
5361                                    closeSession(session);
5362                            }
5363                    }
5364    
5365                    return count.intValue();
5366            }
5367    
5368            private static final String _FINDER_COLUMN_R_P_REPOSITORYID_2 = "dlFolder.repositoryId = ? AND ";
5369            private static final String _FINDER_COLUMN_R_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
5370            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5371                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5372                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_N",
5373                            new String[] {
5374                                    Long.class.getName(), String.class.getName(),
5375                                    
5376                            Integer.class.getName(), Integer.class.getName(),
5377                                    OrderByComparator.class.getName()
5378                            });
5379            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5380                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5381                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_N",
5382                            new String[] { Long.class.getName(), String.class.getName() },
5383                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
5384                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
5385            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5386                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
5387                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
5388                            new String[] { Long.class.getName(), String.class.getName() });
5389    
5390            /**
5391             * Returns all the document library folders where parentFolderId = &#63; and name = &#63;.
5392             *
5393             * @param parentFolderId the parent folder ID
5394             * @param name the name
5395             * @return the matching document library folders
5396             */
5397            @Override
5398            public List<DLFolder> findByP_N(long parentFolderId, String name) {
5399                    return findByP_N(parentFolderId, name, QueryUtil.ALL_POS,
5400                            QueryUtil.ALL_POS, null);
5401            }
5402    
5403            /**
5404             * Returns a range of all the document library folders where parentFolderId = &#63; and name = &#63;.
5405             *
5406             * <p>
5407             * 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.
5408             * </p>
5409             *
5410             * @param parentFolderId the parent folder ID
5411             * @param name the name
5412             * @param start the lower bound of the range of document library folders
5413             * @param end the upper bound of the range of document library folders (not inclusive)
5414             * @return the range of matching document library folders
5415             */
5416            @Override
5417            public List<DLFolder> findByP_N(long parentFolderId, String name,
5418                    int start, int end) {
5419                    return findByP_N(parentFolderId, name, start, end, null);
5420            }
5421    
5422            /**
5423             * Returns an ordered range of all the document library folders where parentFolderId = &#63; and name = &#63;.
5424             *
5425             * <p>
5426             * 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.
5427             * </p>
5428             *
5429             * @param parentFolderId the parent folder ID
5430             * @param name the name
5431             * @param start the lower bound of the range of document library folders
5432             * @param end the upper bound of the range of document library folders (not inclusive)
5433             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5434             * @return the ordered range of matching document library folders
5435             */
5436            @Override
5437            public List<DLFolder> findByP_N(long parentFolderId, String name,
5438                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
5439                    boolean pagination = true;
5440                    FinderPath finderPath = null;
5441                    Object[] finderArgs = null;
5442    
5443                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5444                                    (orderByComparator == null)) {
5445                            pagination = false;
5446                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
5447                            finderArgs = new Object[] { parentFolderId, name };
5448                    }
5449                    else {
5450                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
5451                            finderArgs = new Object[] {
5452                                            parentFolderId, name,
5453                                            
5454                                            start, end, orderByComparator
5455                                    };
5456                    }
5457    
5458                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
5459                                    finderArgs, this);
5460    
5461                    if ((list != null) && !list.isEmpty()) {
5462                            for (DLFolder dlFolder : list) {
5463                                    if ((parentFolderId != dlFolder.getParentFolderId()) ||
5464                                                    !Validator.equals(name, dlFolder.getName())) {
5465                                            list = null;
5466    
5467                                            break;
5468                                    }
5469                            }
5470                    }
5471    
5472                    if (list == null) {
5473                            StringBundler query = null;
5474    
5475                            if (orderByComparator != null) {
5476                                    query = new StringBundler(4 +
5477                                                    (orderByComparator.getOrderByFields().length * 3));
5478                            }
5479                            else {
5480                                    query = new StringBundler(4);
5481                            }
5482    
5483                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
5484    
5485                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5486    
5487                            boolean bindName = false;
5488    
5489                            if (name == null) {
5490                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5491                            }
5492                            else if (name.equals(StringPool.BLANK)) {
5493                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
5494                            }
5495                            else {
5496                                    bindName = true;
5497    
5498                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
5499                            }
5500    
5501                            if (orderByComparator != null) {
5502                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5503                                            orderByComparator);
5504                            }
5505                            else
5506                             if (pagination) {
5507                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5508                            }
5509    
5510                            String sql = query.toString();
5511    
5512                            Session session = null;
5513    
5514                            try {
5515                                    session = openSession();
5516    
5517                                    Query q = session.createQuery(sql);
5518    
5519                                    QueryPos qPos = QueryPos.getInstance(q);
5520    
5521                                    qPos.add(parentFolderId);
5522    
5523                                    if (bindName) {
5524                                            qPos.add(name);
5525                                    }
5526    
5527                                    if (!pagination) {
5528                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5529                                                            start, end, false);
5530    
5531                                            Collections.sort(list);
5532    
5533                                            list = Collections.unmodifiableList(list);
5534                                    }
5535                                    else {
5536                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
5537                                                            start, end);
5538                                    }
5539    
5540                                    cacheResult(list);
5541    
5542                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5543                            }
5544                            catch (Exception e) {
5545                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5546    
5547                                    throw processException(e);
5548                            }
5549                            finally {
5550                                    closeSession(session);
5551                            }
5552                    }
5553    
5554                    return list;
5555            }
5556    
5557            /**
5558             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5559             *
5560             * @param parentFolderId the parent folder ID
5561             * @param name the name
5562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5563             * @return the first matching document library folder
5564             * @throws NoSuchFolderException if a matching document library folder could not be found
5565             */
5566            @Override
5567            public DLFolder findByP_N_First(long parentFolderId, String name,
5568                    OrderByComparator<DLFolder> orderByComparator)
5569                    throws NoSuchFolderException {
5570                    DLFolder dlFolder = fetchByP_N_First(parentFolderId, name,
5571                                    orderByComparator);
5572    
5573                    if (dlFolder != null) {
5574                            return dlFolder;
5575                    }
5576    
5577                    StringBundler msg = new StringBundler(6);
5578    
5579                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5580    
5581                    msg.append("parentFolderId=");
5582                    msg.append(parentFolderId);
5583    
5584                    msg.append(", name=");
5585                    msg.append(name);
5586    
5587                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5588    
5589                    throw new NoSuchFolderException(msg.toString());
5590            }
5591    
5592            /**
5593             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5594             *
5595             * @param parentFolderId the parent folder ID
5596             * @param name the name
5597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5598             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
5599             */
5600            @Override
5601            public DLFolder fetchByP_N_First(long parentFolderId, String name,
5602                    OrderByComparator<DLFolder> orderByComparator) {
5603                    List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
5604                                    orderByComparator);
5605    
5606                    if (!list.isEmpty()) {
5607                            return list.get(0);
5608                    }
5609    
5610                    return null;
5611            }
5612    
5613            /**
5614             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5615             *
5616             * @param parentFolderId the parent folder ID
5617             * @param name the name
5618             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5619             * @return the last matching document library folder
5620             * @throws NoSuchFolderException if a matching document library folder could not be found
5621             */
5622            @Override
5623            public DLFolder findByP_N_Last(long parentFolderId, String name,
5624                    OrderByComparator<DLFolder> orderByComparator)
5625                    throws NoSuchFolderException {
5626                    DLFolder dlFolder = fetchByP_N_Last(parentFolderId, name,
5627                                    orderByComparator);
5628    
5629                    if (dlFolder != null) {
5630                            return dlFolder;
5631                    }
5632    
5633                    StringBundler msg = new StringBundler(6);
5634    
5635                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5636    
5637                    msg.append("parentFolderId=");
5638                    msg.append(parentFolderId);
5639    
5640                    msg.append(", name=");
5641                    msg.append(name);
5642    
5643                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5644    
5645                    throw new NoSuchFolderException(msg.toString());
5646            }
5647    
5648            /**
5649             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5650             *
5651             * @param parentFolderId the parent folder ID
5652             * @param name the name
5653             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5654             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
5655             */
5656            @Override
5657            public DLFolder fetchByP_N_Last(long parentFolderId, String name,
5658                    OrderByComparator<DLFolder> orderByComparator) {
5659                    int count = countByP_N(parentFolderId, name);
5660    
5661                    if (count == 0) {
5662                            return null;
5663                    }
5664    
5665                    List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
5666                                    orderByComparator);
5667    
5668                    if (!list.isEmpty()) {
5669                            return list.get(0);
5670                    }
5671    
5672                    return null;
5673            }
5674    
5675            /**
5676             * Returns the document library folders before and after the current document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
5677             *
5678             * @param folderId the primary key of the current document library folder
5679             * @param parentFolderId the parent folder ID
5680             * @param name the name
5681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5682             * @return the previous, current, and next document library folder
5683             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
5684             */
5685            @Override
5686            public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
5687                    String name, OrderByComparator<DLFolder> orderByComparator)
5688                    throws NoSuchFolderException {
5689                    DLFolder dlFolder = findByPrimaryKey(folderId);
5690    
5691                    Session session = null;
5692    
5693                    try {
5694                            session = openSession();
5695    
5696                            DLFolder[] array = new DLFolderImpl[3];
5697    
5698                            array[0] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
5699                                            name, orderByComparator, true);
5700    
5701                            array[1] = dlFolder;
5702    
5703                            array[2] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
5704                                            name, orderByComparator, false);
5705    
5706                            return array;
5707                    }
5708                    catch (Exception e) {
5709                            throw processException(e);
5710                    }
5711                    finally {
5712                            closeSession(session);
5713                    }
5714            }
5715    
5716            protected DLFolder getByP_N_PrevAndNext(Session session, DLFolder dlFolder,
5717                    long parentFolderId, String name,
5718                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
5719                    StringBundler query = null;
5720    
5721                    if (orderByComparator != null) {
5722                            query = new StringBundler(6 +
5723                                            (orderByComparator.getOrderByFields().length * 6));
5724                    }
5725                    else {
5726                            query = new StringBundler(3);
5727                    }
5728    
5729                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
5730    
5731                    query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5732    
5733                    boolean bindName = false;
5734    
5735                    if (name == null) {
5736                            query.append(_FINDER_COLUMN_P_N_NAME_1);
5737                    }
5738                    else if (name.equals(StringPool.BLANK)) {
5739                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5740                    }
5741                    else {
5742                            bindName = true;
5743    
5744                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5745                    }
5746    
5747                    if (orderByComparator != null) {
5748                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5749    
5750                            if (orderByConditionFields.length > 0) {
5751                                    query.append(WHERE_AND);
5752                            }
5753    
5754                            for (int i = 0; i < orderByConditionFields.length; i++) {
5755                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5756                                    query.append(orderByConditionFields[i]);
5757    
5758                                    if ((i + 1) < orderByConditionFields.length) {
5759                                            if (orderByComparator.isAscending() ^ previous) {
5760                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5761                                            }
5762                                            else {
5763                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5764                                            }
5765                                    }
5766                                    else {
5767                                            if (orderByComparator.isAscending() ^ previous) {
5768                                                    query.append(WHERE_GREATER_THAN);
5769                                            }
5770                                            else {
5771                                                    query.append(WHERE_LESSER_THAN);
5772                                            }
5773                                    }
5774                            }
5775    
5776                            query.append(ORDER_BY_CLAUSE);
5777    
5778                            String[] orderByFields = orderByComparator.getOrderByFields();
5779    
5780                            for (int i = 0; i < orderByFields.length; i++) {
5781                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5782                                    query.append(orderByFields[i]);
5783    
5784                                    if ((i + 1) < orderByFields.length) {
5785                                            if (orderByComparator.isAscending() ^ previous) {
5786                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5787                                            }
5788                                            else {
5789                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5790                                            }
5791                                    }
5792                                    else {
5793                                            if (orderByComparator.isAscending() ^ previous) {
5794                                                    query.append(ORDER_BY_ASC);
5795                                            }
5796                                            else {
5797                                                    query.append(ORDER_BY_DESC);
5798                                            }
5799                                    }
5800                            }
5801                    }
5802                    else {
5803                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
5804                    }
5805    
5806                    String sql = query.toString();
5807    
5808                    Query q = session.createQuery(sql);
5809    
5810                    q.setFirstResult(0);
5811                    q.setMaxResults(2);
5812    
5813                    QueryPos qPos = QueryPos.getInstance(q);
5814    
5815                    qPos.add(parentFolderId);
5816    
5817                    if (bindName) {
5818                            qPos.add(name);
5819                    }
5820    
5821                    if (orderByComparator != null) {
5822                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
5823    
5824                            for (Object value : values) {
5825                                    qPos.add(value);
5826                            }
5827                    }
5828    
5829                    List<DLFolder> list = q.list();
5830    
5831                    if (list.size() == 2) {
5832                            return list.get(1);
5833                    }
5834                    else {
5835                            return null;
5836                    }
5837            }
5838    
5839            /**
5840             * Removes all the document library folders where parentFolderId = &#63; and name = &#63; from the database.
5841             *
5842             * @param parentFolderId the parent folder ID
5843             * @param name the name
5844             */
5845            @Override
5846            public void removeByP_N(long parentFolderId, String name) {
5847                    for (DLFolder dlFolder : findByP_N(parentFolderId, name,
5848                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5849                            remove(dlFolder);
5850                    }
5851            }
5852    
5853            /**
5854             * Returns the number of document library folders where parentFolderId = &#63; and name = &#63;.
5855             *
5856             * @param parentFolderId the parent folder ID
5857             * @param name the name
5858             * @return the number of matching document library folders
5859             */
5860            @Override
5861            public int countByP_N(long parentFolderId, String name) {
5862                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5863    
5864                    Object[] finderArgs = new Object[] { parentFolderId, name };
5865    
5866                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5867                                    this);
5868    
5869                    if (count == null) {
5870                            StringBundler query = new StringBundler(3);
5871    
5872                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5873    
5874                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5875    
5876                            boolean bindName = false;
5877    
5878                            if (name == null) {
5879                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5880                            }
5881                            else if (name.equals(StringPool.BLANK)) {
5882                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
5883                            }
5884                            else {
5885                                    bindName = true;
5886    
5887                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
5888                            }
5889    
5890                            String sql = query.toString();
5891    
5892                            Session session = null;
5893    
5894                            try {
5895                                    session = openSession();
5896    
5897                                    Query q = session.createQuery(sql);
5898    
5899                                    QueryPos qPos = QueryPos.getInstance(q);
5900    
5901                                    qPos.add(parentFolderId);
5902    
5903                                    if (bindName) {
5904                                            qPos.add(name);
5905                                    }
5906    
5907                                    count = (Long)q.uniqueResult();
5908    
5909                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5910                            }
5911                            catch (Exception e) {
5912                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5913    
5914                                    throw processException(e);
5915                            }
5916                            finally {
5917                                    closeSession(session);
5918                            }
5919                    }
5920    
5921                    return count.intValue();
5922            }
5923    
5924            private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
5925            private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
5926            private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
5927            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = '')";
5928            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5929                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5930                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P",
5931                            new String[] {
5932                                    Long.class.getName(), Boolean.class.getName(),
5933                                    Long.class.getName(),
5934                                    
5935                            Integer.class.getName(), Integer.class.getName(),
5936                                    OrderByComparator.class.getName()
5937                            });
5938            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5939                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
5940                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P",
5941                            new String[] {
5942                                    Long.class.getName(), Boolean.class.getName(),
5943                                    Long.class.getName()
5944                            },
5945                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
5946                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
5947                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
5948                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
5949            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
5950                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
5951                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P",
5952                            new String[] {
5953                                    Long.class.getName(), Boolean.class.getName(),
5954                                    Long.class.getName()
5955                            });
5956    
5957            /**
5958             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
5959             *
5960             * @param groupId the group ID
5961             * @param mountPoint the mount point
5962             * @param parentFolderId the parent folder ID
5963             * @return the matching document library folders
5964             */
5965            @Override
5966            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
5967                    long parentFolderId) {
5968                    return findByG_M_P(groupId, mountPoint, parentFolderId,
5969                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5970            }
5971    
5972            /**
5973             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
5974             *
5975             * <p>
5976             * 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.
5977             * </p>
5978             *
5979             * @param groupId the group ID
5980             * @param mountPoint the mount point
5981             * @param parentFolderId the parent folder ID
5982             * @param start the lower bound of the range of document library folders
5983             * @param end the upper bound of the range of document library folders (not inclusive)
5984             * @return the range of matching document library folders
5985             */
5986            @Override
5987            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
5988                    long parentFolderId, int start, int end) {
5989                    return findByG_M_P(groupId, mountPoint, parentFolderId, start, end, null);
5990            }
5991    
5992            /**
5993             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
5994             *
5995             * <p>
5996             * 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.
5997             * </p>
5998             *
5999             * @param groupId the group ID
6000             * @param mountPoint the mount point
6001             * @param parentFolderId the parent folder ID
6002             * @param start the lower bound of the range of document library folders
6003             * @param end the upper bound of the range of document library folders (not inclusive)
6004             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6005             * @return the ordered range of matching document library folders
6006             */
6007            @Override
6008            public List<DLFolder> findByG_M_P(long groupId, boolean mountPoint,
6009                    long parentFolderId, int start, int end,
6010                    OrderByComparator<DLFolder> orderByComparator) {
6011                    boolean pagination = true;
6012                    FinderPath finderPath = null;
6013                    Object[] finderArgs = null;
6014    
6015                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6016                                    (orderByComparator == null)) {
6017                            pagination = false;
6018                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P;
6019                            finderArgs = new Object[] { groupId, mountPoint, parentFolderId };
6020                    }
6021                    else {
6022                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P;
6023                            finderArgs = new Object[] {
6024                                            groupId, mountPoint, parentFolderId,
6025                                            
6026                                            start, end, orderByComparator
6027                                    };
6028                    }
6029    
6030                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
6031                                    finderArgs, this);
6032    
6033                    if ((list != null) && !list.isEmpty()) {
6034                            for (DLFolder dlFolder : list) {
6035                                    if ((groupId != dlFolder.getGroupId()) ||
6036                                                    (mountPoint != dlFolder.getMountPoint()) ||
6037                                                    (parentFolderId != dlFolder.getParentFolderId())) {
6038                                            list = null;
6039    
6040                                            break;
6041                                    }
6042                            }
6043                    }
6044    
6045                    if (list == null) {
6046                            StringBundler query = null;
6047    
6048                            if (orderByComparator != null) {
6049                                    query = new StringBundler(5 +
6050                                                    (orderByComparator.getOrderByFields().length * 3));
6051                            }
6052                            else {
6053                                    query = new StringBundler(5);
6054                            }
6055    
6056                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
6057    
6058                            query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6059    
6060                            query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6061    
6062                            query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6063    
6064                            if (orderByComparator != null) {
6065                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6066                                            orderByComparator);
6067                            }
6068                            else
6069                             if (pagination) {
6070                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6071                            }
6072    
6073                            String sql = query.toString();
6074    
6075                            Session session = null;
6076    
6077                            try {
6078                                    session = openSession();
6079    
6080                                    Query q = session.createQuery(sql);
6081    
6082                                    QueryPos qPos = QueryPos.getInstance(q);
6083    
6084                                    qPos.add(groupId);
6085    
6086                                    qPos.add(mountPoint);
6087    
6088                                    qPos.add(parentFolderId);
6089    
6090                                    if (!pagination) {
6091                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
6092                                                            start, end, false);
6093    
6094                                            Collections.sort(list);
6095    
6096                                            list = Collections.unmodifiableList(list);
6097                                    }
6098                                    else {
6099                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
6100                                                            start, end);
6101                                    }
6102    
6103                                    cacheResult(list);
6104    
6105                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6106                            }
6107                            catch (Exception e) {
6108                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6109    
6110                                    throw processException(e);
6111                            }
6112                            finally {
6113                                    closeSession(session);
6114                            }
6115                    }
6116    
6117                    return list;
6118            }
6119    
6120            /**
6121             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6122             *
6123             * @param groupId the group ID
6124             * @param mountPoint the mount point
6125             * @param parentFolderId the parent folder ID
6126             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6127             * @return the first matching document library folder
6128             * @throws NoSuchFolderException if a matching document library folder could not be found
6129             */
6130            @Override
6131            public DLFolder findByG_M_P_First(long groupId, boolean mountPoint,
6132                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
6133                    throws NoSuchFolderException {
6134                    DLFolder dlFolder = fetchByG_M_P_First(groupId, mountPoint,
6135                                    parentFolderId, orderByComparator);
6136    
6137                    if (dlFolder != null) {
6138                            return dlFolder;
6139                    }
6140    
6141                    StringBundler msg = new StringBundler(8);
6142    
6143                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6144    
6145                    msg.append("groupId=");
6146                    msg.append(groupId);
6147    
6148                    msg.append(", mountPoint=");
6149                    msg.append(mountPoint);
6150    
6151                    msg.append(", parentFolderId=");
6152                    msg.append(parentFolderId);
6153    
6154                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6155    
6156                    throw new NoSuchFolderException(msg.toString());
6157            }
6158    
6159            /**
6160             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6161             *
6162             * @param groupId the group ID
6163             * @param mountPoint the mount point
6164             * @param parentFolderId the parent folder ID
6165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6166             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
6167             */
6168            @Override
6169            public DLFolder fetchByG_M_P_First(long groupId, boolean mountPoint,
6170                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator) {
6171                    List<DLFolder> list = findByG_M_P(groupId, mountPoint, parentFolderId,
6172                                    0, 1, orderByComparator);
6173    
6174                    if (!list.isEmpty()) {
6175                            return list.get(0);
6176                    }
6177    
6178                    return null;
6179            }
6180    
6181            /**
6182             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6183             *
6184             * @param groupId the group ID
6185             * @param mountPoint the mount point
6186             * @param parentFolderId the parent folder ID
6187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6188             * @return the last matching document library folder
6189             * @throws NoSuchFolderException if a matching document library folder could not be found
6190             */
6191            @Override
6192            public DLFolder findByG_M_P_Last(long groupId, boolean mountPoint,
6193                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator)
6194                    throws NoSuchFolderException {
6195                    DLFolder dlFolder = fetchByG_M_P_Last(groupId, mountPoint,
6196                                    parentFolderId, orderByComparator);
6197    
6198                    if (dlFolder != null) {
6199                            return dlFolder;
6200                    }
6201    
6202                    StringBundler msg = new StringBundler(8);
6203    
6204                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6205    
6206                    msg.append("groupId=");
6207                    msg.append(groupId);
6208    
6209                    msg.append(", mountPoint=");
6210                    msg.append(mountPoint);
6211    
6212                    msg.append(", parentFolderId=");
6213                    msg.append(parentFolderId);
6214    
6215                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6216    
6217                    throw new NoSuchFolderException(msg.toString());
6218            }
6219    
6220            /**
6221             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6222             *
6223             * @param groupId the group ID
6224             * @param mountPoint the mount point
6225             * @param parentFolderId the parent folder ID
6226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6227             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
6228             */
6229            @Override
6230            public DLFolder fetchByG_M_P_Last(long groupId, boolean mountPoint,
6231                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator) {
6232                    int count = countByG_M_P(groupId, mountPoint, parentFolderId);
6233    
6234                    if (count == 0) {
6235                            return null;
6236                    }
6237    
6238                    List<DLFolder> list = findByG_M_P(groupId, mountPoint, parentFolderId,
6239                                    count - 1, count, orderByComparator);
6240    
6241                    if (!list.isEmpty()) {
6242                            return list.get(0);
6243                    }
6244    
6245                    return null;
6246            }
6247    
6248            /**
6249             * 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;.
6250             *
6251             * @param folderId the primary key of the current document library folder
6252             * @param groupId the group ID
6253             * @param mountPoint the mount point
6254             * @param parentFolderId the parent folder ID
6255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6256             * @return the previous, current, and next document library folder
6257             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
6258             */
6259            @Override
6260            public DLFolder[] findByG_M_P_PrevAndNext(long folderId, long groupId,
6261                    boolean mountPoint, long parentFolderId,
6262                    OrderByComparator<DLFolder> orderByComparator)
6263                    throws NoSuchFolderException {
6264                    DLFolder dlFolder = findByPrimaryKey(folderId);
6265    
6266                    Session session = null;
6267    
6268                    try {
6269                            session = openSession();
6270    
6271                            DLFolder[] array = new DLFolderImpl[3];
6272    
6273                            array[0] = getByG_M_P_PrevAndNext(session, dlFolder, groupId,
6274                                            mountPoint, parentFolderId, orderByComparator, true);
6275    
6276                            array[1] = dlFolder;
6277    
6278                            array[2] = getByG_M_P_PrevAndNext(session, dlFolder, groupId,
6279                                            mountPoint, parentFolderId, orderByComparator, false);
6280    
6281                            return array;
6282                    }
6283                    catch (Exception e) {
6284                            throw processException(e);
6285                    }
6286                    finally {
6287                            closeSession(session);
6288                    }
6289            }
6290    
6291            protected DLFolder getByG_M_P_PrevAndNext(Session session,
6292                    DLFolder dlFolder, long groupId, boolean mountPoint,
6293                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator,
6294                    boolean previous) {
6295                    StringBundler query = null;
6296    
6297                    if (orderByComparator != null) {
6298                            query = new StringBundler(6 +
6299                                            (orderByComparator.getOrderByFields().length * 6));
6300                    }
6301                    else {
6302                            query = new StringBundler(3);
6303                    }
6304    
6305                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
6306    
6307                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6308    
6309                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6310    
6311                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6312    
6313                    if (orderByComparator != null) {
6314                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6315    
6316                            if (orderByConditionFields.length > 0) {
6317                                    query.append(WHERE_AND);
6318                            }
6319    
6320                            for (int i = 0; i < orderByConditionFields.length; i++) {
6321                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6322                                    query.append(orderByConditionFields[i]);
6323    
6324                                    if ((i + 1) < orderByConditionFields.length) {
6325                                            if (orderByComparator.isAscending() ^ previous) {
6326                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6327                                            }
6328                                            else {
6329                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6330                                            }
6331                                    }
6332                                    else {
6333                                            if (orderByComparator.isAscending() ^ previous) {
6334                                                    query.append(WHERE_GREATER_THAN);
6335                                            }
6336                                            else {
6337                                                    query.append(WHERE_LESSER_THAN);
6338                                            }
6339                                    }
6340                            }
6341    
6342                            query.append(ORDER_BY_CLAUSE);
6343    
6344                            String[] orderByFields = orderByComparator.getOrderByFields();
6345    
6346                            for (int i = 0; i < orderByFields.length; i++) {
6347                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6348                                    query.append(orderByFields[i]);
6349    
6350                                    if ((i + 1) < orderByFields.length) {
6351                                            if (orderByComparator.isAscending() ^ previous) {
6352                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6353                                            }
6354                                            else {
6355                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6356                                            }
6357                                    }
6358                                    else {
6359                                            if (orderByComparator.isAscending() ^ previous) {
6360                                                    query.append(ORDER_BY_ASC);
6361                                            }
6362                                            else {
6363                                                    query.append(ORDER_BY_DESC);
6364                                            }
6365                                    }
6366                            }
6367                    }
6368                    else {
6369                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6370                    }
6371    
6372                    String sql = query.toString();
6373    
6374                    Query q = session.createQuery(sql);
6375    
6376                    q.setFirstResult(0);
6377                    q.setMaxResults(2);
6378    
6379                    QueryPos qPos = QueryPos.getInstance(q);
6380    
6381                    qPos.add(groupId);
6382    
6383                    qPos.add(mountPoint);
6384    
6385                    qPos.add(parentFolderId);
6386    
6387                    if (orderByComparator != null) {
6388                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
6389    
6390                            for (Object value : values) {
6391                                    qPos.add(value);
6392                            }
6393                    }
6394    
6395                    List<DLFolder> list = q.list();
6396    
6397                    if (list.size() == 2) {
6398                            return list.get(1);
6399                    }
6400                    else {
6401                            return null;
6402                    }
6403            }
6404    
6405            /**
6406             * Returns all the document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6407             *
6408             * @param groupId the group ID
6409             * @param mountPoint the mount point
6410             * @param parentFolderId the parent folder ID
6411             * @return the matching document library folders that the user has permission to view
6412             */
6413            @Override
6414            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6415                    long parentFolderId) {
6416                    return filterFindByG_M_P(groupId, mountPoint, parentFolderId,
6417                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6418            }
6419    
6420            /**
6421             * 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;.
6422             *
6423             * <p>
6424             * 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.
6425             * </p>
6426             *
6427             * @param groupId the group ID
6428             * @param mountPoint the mount point
6429             * @param parentFolderId the parent folder ID
6430             * @param start the lower bound of the range of document library folders
6431             * @param end the upper bound of the range of document library folders (not inclusive)
6432             * @return the range of matching document library folders that the user has permission to view
6433             */
6434            @Override
6435            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6436                    long parentFolderId, int start, int end) {
6437                    return filterFindByG_M_P(groupId, mountPoint, parentFolderId, start,
6438                            end, null);
6439            }
6440    
6441            /**
6442             * 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;.
6443             *
6444             * <p>
6445             * 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.
6446             * </p>
6447             *
6448             * @param groupId the group ID
6449             * @param mountPoint the mount point
6450             * @param parentFolderId the parent folder ID
6451             * @param start the lower bound of the range of document library folders
6452             * @param end the upper bound of the range of document library folders (not inclusive)
6453             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6454             * @return the ordered range of matching document library folders that the user has permission to view
6455             */
6456            @Override
6457            public List<DLFolder> filterFindByG_M_P(long groupId, boolean mountPoint,
6458                    long parentFolderId, int start, int end,
6459                    OrderByComparator<DLFolder> orderByComparator) {
6460                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6461                            return findByG_M_P(groupId, mountPoint, parentFolderId, start, end,
6462                                    orderByComparator);
6463                    }
6464    
6465                    StringBundler query = null;
6466    
6467                    if (orderByComparator != null) {
6468                            query = new StringBundler(5 +
6469                                            (orderByComparator.getOrderByFields().length * 3));
6470                    }
6471                    else {
6472                            query = new StringBundler(5);
6473                    }
6474    
6475                    if (getDB().isSupportsInlineDistinct()) {
6476                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
6477                    }
6478                    else {
6479                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
6480                    }
6481    
6482                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6483    
6484                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6485    
6486                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6487    
6488                    if (!getDB().isSupportsInlineDistinct()) {
6489                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
6490                    }
6491    
6492                    if (orderByComparator != null) {
6493                            if (getDB().isSupportsInlineDistinct()) {
6494                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6495                                            orderByComparator, true);
6496                            }
6497                            else {
6498                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6499                                            orderByComparator, true);
6500                            }
6501                    }
6502                    else {
6503                            if (getDB().isSupportsInlineDistinct()) {
6504                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6505                            }
6506                            else {
6507                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
6508                            }
6509                    }
6510    
6511                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6512                                    DLFolder.class.getName(),
6513                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6514    
6515                    Session session = null;
6516    
6517                    try {
6518                            session = openSession();
6519    
6520                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6521    
6522                            if (getDB().isSupportsInlineDistinct()) {
6523                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
6524                            }
6525                            else {
6526                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
6527                            }
6528    
6529                            QueryPos qPos = QueryPos.getInstance(q);
6530    
6531                            qPos.add(groupId);
6532    
6533                            qPos.add(mountPoint);
6534    
6535                            qPos.add(parentFolderId);
6536    
6537                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
6538                    }
6539                    catch (Exception e) {
6540                            throw processException(e);
6541                    }
6542                    finally {
6543                            closeSession(session);
6544                    }
6545            }
6546    
6547            /**
6548             * 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;.
6549             *
6550             * @param folderId the primary key of the current document library folder
6551             * @param groupId the group ID
6552             * @param mountPoint the mount point
6553             * @param parentFolderId the parent folder ID
6554             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6555             * @return the previous, current, and next document library folder
6556             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
6557             */
6558            @Override
6559            public DLFolder[] filterFindByG_M_P_PrevAndNext(long folderId,
6560                    long groupId, boolean mountPoint, long parentFolderId,
6561                    OrderByComparator<DLFolder> orderByComparator)
6562                    throws NoSuchFolderException {
6563                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6564                            return findByG_M_P_PrevAndNext(folderId, groupId, mountPoint,
6565                                    parentFolderId, orderByComparator);
6566                    }
6567    
6568                    DLFolder dlFolder = findByPrimaryKey(folderId);
6569    
6570                    Session session = null;
6571    
6572                    try {
6573                            session = openSession();
6574    
6575                            DLFolder[] array = new DLFolderImpl[3];
6576    
6577                            array[0] = filterGetByG_M_P_PrevAndNext(session, dlFolder, groupId,
6578                                            mountPoint, parentFolderId, orderByComparator, true);
6579    
6580                            array[1] = dlFolder;
6581    
6582                            array[2] = filterGetByG_M_P_PrevAndNext(session, dlFolder, groupId,
6583                                            mountPoint, parentFolderId, orderByComparator, false);
6584    
6585                            return array;
6586                    }
6587                    catch (Exception e) {
6588                            throw processException(e);
6589                    }
6590                    finally {
6591                            closeSession(session);
6592                    }
6593            }
6594    
6595            protected DLFolder filterGetByG_M_P_PrevAndNext(Session session,
6596                    DLFolder dlFolder, long groupId, boolean mountPoint,
6597                    long parentFolderId, OrderByComparator<DLFolder> orderByComparator,
6598                    boolean previous) {
6599                    StringBundler query = null;
6600    
6601                    if (orderByComparator != null) {
6602                            query = new StringBundler(6 +
6603                                            (orderByComparator.getOrderByFields().length * 6));
6604                    }
6605                    else {
6606                            query = new StringBundler(3);
6607                    }
6608    
6609                    if (getDB().isSupportsInlineDistinct()) {
6610                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
6611                    }
6612                    else {
6613                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
6614                    }
6615    
6616                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6617    
6618                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6619    
6620                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6621    
6622                    if (!getDB().isSupportsInlineDistinct()) {
6623                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
6624                    }
6625    
6626                    if (orderByComparator != null) {
6627                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6628    
6629                            if (orderByConditionFields.length > 0) {
6630                                    query.append(WHERE_AND);
6631                            }
6632    
6633                            for (int i = 0; i < orderByConditionFields.length; i++) {
6634                                    if (getDB().isSupportsInlineDistinct()) {
6635                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6636                                    }
6637                                    else {
6638                                            query.append(_ORDER_BY_ENTITY_TABLE);
6639                                    }
6640    
6641                                    query.append(orderByConditionFields[i]);
6642    
6643                                    if ((i + 1) < orderByConditionFields.length) {
6644                                            if (orderByComparator.isAscending() ^ previous) {
6645                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6646                                            }
6647                                            else {
6648                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6649                                            }
6650                                    }
6651                                    else {
6652                                            if (orderByComparator.isAscending() ^ previous) {
6653                                                    query.append(WHERE_GREATER_THAN);
6654                                            }
6655                                            else {
6656                                                    query.append(WHERE_LESSER_THAN);
6657                                            }
6658                                    }
6659                            }
6660    
6661                            query.append(ORDER_BY_CLAUSE);
6662    
6663                            String[] orderByFields = orderByComparator.getOrderByFields();
6664    
6665                            for (int i = 0; i < orderByFields.length; i++) {
6666                                    if (getDB().isSupportsInlineDistinct()) {
6667                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6668                                    }
6669                                    else {
6670                                            query.append(_ORDER_BY_ENTITY_TABLE);
6671                                    }
6672    
6673                                    query.append(orderByFields[i]);
6674    
6675                                    if ((i + 1) < orderByFields.length) {
6676                                            if (orderByComparator.isAscending() ^ previous) {
6677                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6678                                            }
6679                                            else {
6680                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6681                                            }
6682                                    }
6683                                    else {
6684                                            if (orderByComparator.isAscending() ^ previous) {
6685                                                    query.append(ORDER_BY_ASC);
6686                                            }
6687                                            else {
6688                                                    query.append(ORDER_BY_DESC);
6689                                            }
6690                                    }
6691                            }
6692                    }
6693                    else {
6694                            if (getDB().isSupportsInlineDistinct()) {
6695                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
6696                            }
6697                            else {
6698                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
6699                            }
6700                    }
6701    
6702                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6703                                    DLFolder.class.getName(),
6704                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6705    
6706                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
6707    
6708                    q.setFirstResult(0);
6709                    q.setMaxResults(2);
6710    
6711                    if (getDB().isSupportsInlineDistinct()) {
6712                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
6713                    }
6714                    else {
6715                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
6716                    }
6717    
6718                    QueryPos qPos = QueryPos.getInstance(q);
6719    
6720                    qPos.add(groupId);
6721    
6722                    qPos.add(mountPoint);
6723    
6724                    qPos.add(parentFolderId);
6725    
6726                    if (orderByComparator != null) {
6727                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
6728    
6729                            for (Object value : values) {
6730                                    qPos.add(value);
6731                            }
6732                    }
6733    
6734                    List<DLFolder> list = q.list();
6735    
6736                    if (list.size() == 2) {
6737                            return list.get(1);
6738                    }
6739                    else {
6740                            return null;
6741                    }
6742            }
6743    
6744            /**
6745             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; from the database.
6746             *
6747             * @param groupId the group ID
6748             * @param mountPoint the mount point
6749             * @param parentFolderId the parent folder ID
6750             */
6751            @Override
6752            public void removeByG_M_P(long groupId, boolean mountPoint,
6753                    long parentFolderId) {
6754                    for (DLFolder dlFolder : findByG_M_P(groupId, mountPoint,
6755                                    parentFolderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6756                            remove(dlFolder);
6757                    }
6758            }
6759    
6760            /**
6761             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6762             *
6763             * @param groupId the group ID
6764             * @param mountPoint the mount point
6765             * @param parentFolderId the parent folder ID
6766             * @return the number of matching document library folders
6767             */
6768            @Override
6769            public int countByG_M_P(long groupId, boolean mountPoint,
6770                    long parentFolderId) {
6771                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P;
6772    
6773                    Object[] finderArgs = new Object[] { groupId, mountPoint, parentFolderId };
6774    
6775                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6776                                    this);
6777    
6778                    if (count == null) {
6779                            StringBundler query = new StringBundler(4);
6780    
6781                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
6782    
6783                            query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6784    
6785                            query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6786    
6787                            query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6788    
6789                            String sql = query.toString();
6790    
6791                            Session session = null;
6792    
6793                            try {
6794                                    session = openSession();
6795    
6796                                    Query q = session.createQuery(sql);
6797    
6798                                    QueryPos qPos = QueryPos.getInstance(q);
6799    
6800                                    qPos.add(groupId);
6801    
6802                                    qPos.add(mountPoint);
6803    
6804                                    qPos.add(parentFolderId);
6805    
6806                                    count = (Long)q.uniqueResult();
6807    
6808                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6809                            }
6810                            catch (Exception e) {
6811                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6812    
6813                                    throw processException(e);
6814                            }
6815                            finally {
6816                                    closeSession(session);
6817                            }
6818                    }
6819    
6820                    return count.intValue();
6821            }
6822    
6823            /**
6824             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63;.
6825             *
6826             * @param groupId the group ID
6827             * @param mountPoint the mount point
6828             * @param parentFolderId the parent folder ID
6829             * @return the number of matching document library folders that the user has permission to view
6830             */
6831            @Override
6832            public int filterCountByG_M_P(long groupId, boolean mountPoint,
6833                    long parentFolderId) {
6834                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6835                            return countByG_M_P(groupId, mountPoint, parentFolderId);
6836                    }
6837    
6838                    StringBundler query = new StringBundler(4);
6839    
6840                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
6841    
6842                    query.append(_FINDER_COLUMN_G_M_P_GROUPID_2);
6843    
6844                    query.append(_FINDER_COLUMN_G_M_P_MOUNTPOINT_2);
6845    
6846                    query.append(_FINDER_COLUMN_G_M_P_PARENTFOLDERID_2);
6847    
6848                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6849                                    DLFolder.class.getName(),
6850                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6851    
6852                    Session session = null;
6853    
6854                    try {
6855                            session = openSession();
6856    
6857                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6858    
6859                            q.addScalar(COUNT_COLUMN_NAME,
6860                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6861    
6862                            QueryPos qPos = QueryPos.getInstance(q);
6863    
6864                            qPos.add(groupId);
6865    
6866                            qPos.add(mountPoint);
6867    
6868                            qPos.add(parentFolderId);
6869    
6870                            Long count = (Long)q.uniqueResult();
6871    
6872                            return count.intValue();
6873                    }
6874                    catch (Exception e) {
6875                            throw processException(e);
6876                    }
6877                    finally {
6878                            closeSession(session);
6879                    }
6880            }
6881    
6882            private static final String _FINDER_COLUMN_G_M_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
6883            private static final String _FINDER_COLUMN_G_M_P_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
6884            private static final String _FINDER_COLUMN_G_M_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
6885            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
6886                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
6887                            FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
6888                            new String[] {
6889                                    Long.class.getName(), Long.class.getName(),
6890                                    String.class.getName()
6891                            },
6892                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
6893                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
6894                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
6895            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
6896                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
6897                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
6898                            new String[] {
6899                                    Long.class.getName(), Long.class.getName(),
6900                                    String.class.getName()
6901                            });
6902    
6903            /**
6904             * 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.
6905             *
6906             * @param groupId the group ID
6907             * @param parentFolderId the parent folder ID
6908             * @param name the name
6909             * @return the matching document library folder
6910             * @throws NoSuchFolderException if a matching document library folder could not be found
6911             */
6912            @Override
6913            public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
6914                    throws NoSuchFolderException {
6915                    DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
6916    
6917                    if (dlFolder == null) {
6918                            StringBundler msg = new StringBundler(8);
6919    
6920                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6921    
6922                            msg.append("groupId=");
6923                            msg.append(groupId);
6924    
6925                            msg.append(", parentFolderId=");
6926                            msg.append(parentFolderId);
6927    
6928                            msg.append(", name=");
6929                            msg.append(name);
6930    
6931                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6932    
6933                            if (_log.isWarnEnabled()) {
6934                                    _log.warn(msg.toString());
6935                            }
6936    
6937                            throw new NoSuchFolderException(msg.toString());
6938                    }
6939    
6940                    return dlFolder;
6941            }
6942    
6943            /**
6944             * 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.
6945             *
6946             * @param groupId the group ID
6947             * @param parentFolderId the parent folder ID
6948             * @param name the name
6949             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
6950             */
6951            @Override
6952            public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name) {
6953                    return fetchByG_P_N(groupId, parentFolderId, name, true);
6954            }
6955    
6956            /**
6957             * 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.
6958             *
6959             * @param groupId the group ID
6960             * @param parentFolderId the parent folder ID
6961             * @param name the name
6962             * @param retrieveFromCache whether to use the finder cache
6963             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
6964             */
6965            @Override
6966            public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
6967                    String name, boolean retrieveFromCache) {
6968                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
6969    
6970                    Object result = null;
6971    
6972                    if (retrieveFromCache) {
6973                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
6974                                            finderArgs, this);
6975                    }
6976    
6977                    if (result instanceof DLFolder) {
6978                            DLFolder dlFolder = (DLFolder)result;
6979    
6980                            if ((groupId != dlFolder.getGroupId()) ||
6981                                            (parentFolderId != dlFolder.getParentFolderId()) ||
6982                                            !Validator.equals(name, dlFolder.getName())) {
6983                                    result = null;
6984                            }
6985                    }
6986    
6987                    if (result == null) {
6988                            StringBundler query = new StringBundler(5);
6989    
6990                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
6991    
6992                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
6993    
6994                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
6995    
6996                            boolean bindName = false;
6997    
6998                            if (name == null) {
6999                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7000                            }
7001                            else if (name.equals(StringPool.BLANK)) {
7002                                    query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7003                            }
7004                            else {
7005                                    bindName = true;
7006    
7007                                    query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7008                            }
7009    
7010                            String sql = query.toString();
7011    
7012                            Session session = null;
7013    
7014                            try {
7015                                    session = openSession();
7016    
7017                                    Query q = session.createQuery(sql);
7018    
7019                                    QueryPos qPos = QueryPos.getInstance(q);
7020    
7021                                    qPos.add(groupId);
7022    
7023                                    qPos.add(parentFolderId);
7024    
7025                                    if (bindName) {
7026                                            qPos.add(name);
7027                                    }
7028    
7029                                    List<DLFolder> list = q.list();
7030    
7031                                    if (list.isEmpty()) {
7032                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
7033                                                    finderArgs, list);
7034                                    }
7035                                    else {
7036                                            DLFolder dlFolder = list.get(0);
7037    
7038                                            result = dlFolder;
7039    
7040                                            cacheResult(dlFolder);
7041    
7042                                            if ((dlFolder.getGroupId() != groupId) ||
7043                                                            (dlFolder.getParentFolderId() != parentFolderId) ||
7044                                                            (dlFolder.getName() == null) ||
7045                                                            !dlFolder.getName().equals(name)) {
7046                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
7047                                                            finderArgs, dlFolder);
7048                                            }
7049                                    }
7050                            }
7051                            catch (Exception e) {
7052                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
7053                                            finderArgs);
7054    
7055                                    throw processException(e);
7056                            }
7057                            finally {
7058                                    closeSession(session);
7059                            }
7060                    }
7061    
7062                    if (result instanceof List<?>) {
7063                            return null;
7064                    }
7065                    else {
7066                            return (DLFolder)result;
7067                    }
7068            }
7069    
7070            /**
7071             * Removes the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; from the database.
7072             *
7073             * @param groupId the group ID
7074             * @param parentFolderId the parent folder ID
7075             * @param name the name
7076             * @return the document library folder that was removed
7077             */
7078            @Override
7079            public DLFolder removeByG_P_N(long groupId, long parentFolderId, String name)
7080                    throws NoSuchFolderException {
7081                    DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
7082    
7083                    return remove(dlFolder);
7084            }
7085    
7086            /**
7087             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and name = &#63;.
7088             *
7089             * @param groupId the group ID
7090             * @param parentFolderId the parent folder ID
7091             * @param name the name
7092             * @return the number of matching document library folders
7093             */
7094            @Override
7095            public int countByG_P_N(long groupId, long parentFolderId, String name) {
7096                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N;
7097    
7098                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
7099    
7100                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7101                                    this);
7102    
7103                    if (count == null) {
7104                            StringBundler query = new StringBundler(4);
7105    
7106                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
7107    
7108                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
7109    
7110                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
7111    
7112                            boolean bindName = false;
7113    
7114                            if (name == null) {
7115                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
7116                            }
7117                            else if (name.equals(StringPool.BLANK)) {
7118                                    query.append(_FINDER_COLUMN_G_P_N_NAME_3);
7119                            }
7120                            else {
7121                                    bindName = true;
7122    
7123                                    query.append(_FINDER_COLUMN_G_P_N_NAME_2);
7124                            }
7125    
7126                            String sql = query.toString();
7127    
7128                            Session session = null;
7129    
7130                            try {
7131                                    session = openSession();
7132    
7133                                    Query q = session.createQuery(sql);
7134    
7135                                    QueryPos qPos = QueryPos.getInstance(q);
7136    
7137                                    qPos.add(groupId);
7138    
7139                                    qPos.add(parentFolderId);
7140    
7141                                    if (bindName) {
7142                                            qPos.add(name);
7143                                    }
7144    
7145                                    count = (Long)q.uniqueResult();
7146    
7147                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7148                            }
7149                            catch (Exception e) {
7150                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7151    
7152                                    throw processException(e);
7153                            }
7154                            finally {
7155                                    closeSession(session);
7156                            }
7157                    }
7158    
7159                    return count.intValue();
7160            }
7161    
7162            private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
7163            private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
7164            private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
7165            private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
7166            private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = '')";
7167            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_C_P_NOTS =
7168                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7169                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7170                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByF_C_P_NotS",
7171                            new String[] {
7172                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7173                                    Integer.class.getName(),
7174                                    
7175                            Integer.class.getName(), Integer.class.getName(),
7176                                    OrderByComparator.class.getName()
7177                            });
7178            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_F_C_P_NOTS =
7179                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7180                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
7181                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByF_C_P_NotS",
7182                            new String[] {
7183                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7184                                    Integer.class.getName()
7185                            });
7186    
7187            /**
7188             * Returns all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7189             *
7190             * @param folderId the folder ID
7191             * @param companyId the company ID
7192             * @param parentFolderId the parent folder ID
7193             * @param status the status
7194             * @return the matching document library folders
7195             */
7196            @Override
7197            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7198                    long parentFolderId, int status) {
7199                    return findByF_C_P_NotS(folderId, companyId, parentFolderId, status,
7200                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7201            }
7202    
7203            /**
7204             * Returns a range of all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7205             *
7206             * <p>
7207             * 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.
7208             * </p>
7209             *
7210             * @param folderId the folder ID
7211             * @param companyId the company ID
7212             * @param parentFolderId the parent folder ID
7213             * @param status the status
7214             * @param start the lower bound of the range of document library folders
7215             * @param end the upper bound of the range of document library folders (not inclusive)
7216             * @return the range of matching document library folders
7217             */
7218            @Override
7219            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7220                    long parentFolderId, int status, int start, int end) {
7221                    return findByF_C_P_NotS(folderId, companyId, parentFolderId, status,
7222                            start, end, null);
7223            }
7224    
7225            /**
7226             * Returns an ordered range of all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7227             *
7228             * <p>
7229             * 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.
7230             * </p>
7231             *
7232             * @param folderId the folder ID
7233             * @param companyId the company ID
7234             * @param parentFolderId the parent folder ID
7235             * @param status the status
7236             * @param start the lower bound of the range of document library folders
7237             * @param end the upper bound of the range of document library folders (not inclusive)
7238             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7239             * @return the ordered range of matching document library folders
7240             */
7241            @Override
7242            public List<DLFolder> findByF_C_P_NotS(long folderId, long companyId,
7243                    long parentFolderId, int status, int start, int end,
7244                    OrderByComparator<DLFolder> orderByComparator) {
7245                    boolean pagination = true;
7246                    FinderPath finderPath = null;
7247                    Object[] finderArgs = null;
7248    
7249                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_C_P_NOTS;
7250                    finderArgs = new Object[] {
7251                                    folderId, companyId, parentFolderId, status,
7252                                    
7253                                    start, end, orderByComparator
7254                            };
7255    
7256                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
7257                                    finderArgs, this);
7258    
7259                    if ((list != null) && !list.isEmpty()) {
7260                            for (DLFolder dlFolder : list) {
7261                                    if ((folderId >= dlFolder.getFolderId()) ||
7262                                                    (companyId != dlFolder.getCompanyId()) ||
7263                                                    (parentFolderId != dlFolder.getParentFolderId()) ||
7264                                                    (status == dlFolder.getStatus())) {
7265                                            list = null;
7266    
7267                                            break;
7268                                    }
7269                            }
7270                    }
7271    
7272                    if (list == null) {
7273                            StringBundler query = null;
7274    
7275                            if (orderByComparator != null) {
7276                                    query = new StringBundler(6 +
7277                                                    (orderByComparator.getOrderByFields().length * 3));
7278                            }
7279                            else {
7280                                    query = new StringBundler(6);
7281                            }
7282    
7283                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
7284    
7285                            query.append(_FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2);
7286    
7287                            query.append(_FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2);
7288    
7289                            query.append(_FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2);
7290    
7291                            query.append(_FINDER_COLUMN_F_C_P_NOTS_STATUS_2);
7292    
7293                            if (orderByComparator != null) {
7294                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7295                                            orderByComparator);
7296                            }
7297                            else
7298                             if (pagination) {
7299                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
7300                            }
7301    
7302                            String sql = query.toString();
7303    
7304                            Session session = null;
7305    
7306                            try {
7307                                    session = openSession();
7308    
7309                                    Query q = session.createQuery(sql);
7310    
7311                                    QueryPos qPos = QueryPos.getInstance(q);
7312    
7313                                    qPos.add(folderId);
7314    
7315                                    qPos.add(companyId);
7316    
7317                                    qPos.add(parentFolderId);
7318    
7319                                    qPos.add(status);
7320    
7321                                    if (!pagination) {
7322                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7323                                                            start, end, false);
7324    
7325                                            Collections.sort(list);
7326    
7327                                            list = Collections.unmodifiableList(list);
7328                                    }
7329                                    else {
7330                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7331                                                            start, end);
7332                                    }
7333    
7334                                    cacheResult(list);
7335    
7336                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7337                            }
7338                            catch (Exception e) {
7339                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7340    
7341                                    throw processException(e);
7342                            }
7343                            finally {
7344                                    closeSession(session);
7345                            }
7346                    }
7347    
7348                    return list;
7349            }
7350    
7351            /**
7352             * Returns the first document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7353             *
7354             * @param folderId the folder ID
7355             * @param companyId the company ID
7356             * @param parentFolderId the parent folder ID
7357             * @param status the status
7358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7359             * @return the first matching document library folder
7360             * @throws NoSuchFolderException if a matching document library folder could not be found
7361             */
7362            @Override
7363            public DLFolder findByF_C_P_NotS_First(long folderId, long companyId,
7364                    long parentFolderId, int status,
7365                    OrderByComparator<DLFolder> orderByComparator)
7366                    throws NoSuchFolderException {
7367                    DLFolder dlFolder = fetchByF_C_P_NotS_First(folderId, companyId,
7368                                    parentFolderId, status, orderByComparator);
7369    
7370                    if (dlFolder != null) {
7371                            return dlFolder;
7372                    }
7373    
7374                    StringBundler msg = new StringBundler(10);
7375    
7376                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7377    
7378                    msg.append("folderId=");
7379                    msg.append(folderId);
7380    
7381                    msg.append(", companyId=");
7382                    msg.append(companyId);
7383    
7384                    msg.append(", parentFolderId=");
7385                    msg.append(parentFolderId);
7386    
7387                    msg.append(", status=");
7388                    msg.append(status);
7389    
7390                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7391    
7392                    throw new NoSuchFolderException(msg.toString());
7393            }
7394    
7395            /**
7396             * Returns the first document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7397             *
7398             * @param folderId the folder ID
7399             * @param companyId the company ID
7400             * @param parentFolderId the parent folder ID
7401             * @param status the status
7402             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7403             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
7404             */
7405            @Override
7406            public DLFolder fetchByF_C_P_NotS_First(long folderId, long companyId,
7407                    long parentFolderId, int status,
7408                    OrderByComparator<DLFolder> orderByComparator) {
7409                    List<DLFolder> list = findByF_C_P_NotS(folderId, companyId,
7410                                    parentFolderId, status, 0, 1, orderByComparator);
7411    
7412                    if (!list.isEmpty()) {
7413                            return list.get(0);
7414                    }
7415    
7416                    return null;
7417            }
7418    
7419            /**
7420             * Returns the last document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7421             *
7422             * @param folderId the folder ID
7423             * @param companyId the company ID
7424             * @param parentFolderId the parent folder ID
7425             * @param status the status
7426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7427             * @return the last matching document library folder
7428             * @throws NoSuchFolderException if a matching document library folder could not be found
7429             */
7430            @Override
7431            public DLFolder findByF_C_P_NotS_Last(long folderId, long companyId,
7432                    long parentFolderId, int status,
7433                    OrderByComparator<DLFolder> orderByComparator)
7434                    throws NoSuchFolderException {
7435                    DLFolder dlFolder = fetchByF_C_P_NotS_Last(folderId, companyId,
7436                                    parentFolderId, status, orderByComparator);
7437    
7438                    if (dlFolder != null) {
7439                            return dlFolder;
7440                    }
7441    
7442                    StringBundler msg = new StringBundler(10);
7443    
7444                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7445    
7446                    msg.append("folderId=");
7447                    msg.append(folderId);
7448    
7449                    msg.append(", companyId=");
7450                    msg.append(companyId);
7451    
7452                    msg.append(", parentFolderId=");
7453                    msg.append(parentFolderId);
7454    
7455                    msg.append(", status=");
7456                    msg.append(status);
7457    
7458                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7459    
7460                    throw new NoSuchFolderException(msg.toString());
7461            }
7462    
7463            /**
7464             * Returns the last document library folder in the ordered set where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7465             *
7466             * @param folderId the folder ID
7467             * @param companyId the company ID
7468             * @param parentFolderId the parent folder ID
7469             * @param status the status
7470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7471             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
7472             */
7473            @Override
7474            public DLFolder fetchByF_C_P_NotS_Last(long folderId, long companyId,
7475                    long parentFolderId, int status,
7476                    OrderByComparator<DLFolder> orderByComparator) {
7477                    int count = countByF_C_P_NotS(folderId, companyId, parentFolderId,
7478                                    status);
7479    
7480                    if (count == 0) {
7481                            return null;
7482                    }
7483    
7484                    List<DLFolder> list = findByF_C_P_NotS(folderId, companyId,
7485                                    parentFolderId, status, count - 1, count, orderByComparator);
7486    
7487                    if (!list.isEmpty()) {
7488                            return list.get(0);
7489                    }
7490    
7491                    return null;
7492            }
7493    
7494            /**
7495             * Removes all the document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63; from the database.
7496             *
7497             * @param folderId the folder ID
7498             * @param companyId the company ID
7499             * @param parentFolderId the parent folder ID
7500             * @param status the status
7501             */
7502            @Override
7503            public void removeByF_C_P_NotS(long folderId, long companyId,
7504                    long parentFolderId, int status) {
7505                    for (DLFolder dlFolder : findByF_C_P_NotS(folderId, companyId,
7506                                    parentFolderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7507                                    null)) {
7508                            remove(dlFolder);
7509                    }
7510            }
7511    
7512            /**
7513             * Returns the number of document library folders where folderId &gt; &#63; and companyId = &#63; and parentFolderId = &#63; and status &ne; &#63;.
7514             *
7515             * @param folderId the folder ID
7516             * @param companyId the company ID
7517             * @param parentFolderId the parent folder ID
7518             * @param status the status
7519             * @return the number of matching document library folders
7520             */
7521            @Override
7522            public int countByF_C_P_NotS(long folderId, long companyId,
7523                    long parentFolderId, int status) {
7524                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_F_C_P_NOTS;
7525    
7526                    Object[] finderArgs = new Object[] {
7527                                    folderId, companyId, parentFolderId, status
7528                            };
7529    
7530                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7531                                    this);
7532    
7533                    if (count == null) {
7534                            StringBundler query = new StringBundler(5);
7535    
7536                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
7537    
7538                            query.append(_FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2);
7539    
7540                            query.append(_FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2);
7541    
7542                            query.append(_FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2);
7543    
7544                            query.append(_FINDER_COLUMN_F_C_P_NOTS_STATUS_2);
7545    
7546                            String sql = query.toString();
7547    
7548                            Session session = null;
7549    
7550                            try {
7551                                    session = openSession();
7552    
7553                                    Query q = session.createQuery(sql);
7554    
7555                                    QueryPos qPos = QueryPos.getInstance(q);
7556    
7557                                    qPos.add(folderId);
7558    
7559                                    qPos.add(companyId);
7560    
7561                                    qPos.add(parentFolderId);
7562    
7563                                    qPos.add(status);
7564    
7565                                    count = (Long)q.uniqueResult();
7566    
7567                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7568                            }
7569                            catch (Exception e) {
7570                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7571    
7572                                    throw processException(e);
7573                            }
7574                            finally {
7575                                    closeSession(session);
7576                            }
7577                    }
7578    
7579                    return count.intValue();
7580            }
7581    
7582            private static final String _FINDER_COLUMN_F_C_P_NOTS_FOLDERID_2 = "dlFolder.folderId > ? AND ";
7583            private static final String _FINDER_COLUMN_F_C_P_NOTS_COMPANYID_2 = "dlFolder.companyId = ? AND ";
7584            private static final String _FINDER_COLUMN_F_C_P_NOTS_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
7585            private static final String _FINDER_COLUMN_F_C_P_NOTS_STATUS_2 = "dlFolder.status != ?";
7586            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7587                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7588                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P_H",
7589                            new String[] {
7590                                    Long.class.getName(), Boolean.class.getName(),
7591                                    Long.class.getName(), Boolean.class.getName(),
7592                                    
7593                            Integer.class.getName(), Integer.class.getName(),
7594                                    OrderByComparator.class.getName()
7595                            });
7596            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H =
7597                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7598                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
7599                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P_H",
7600                            new String[] {
7601                                    Long.class.getName(), Boolean.class.getName(),
7602                                    Long.class.getName(), Boolean.class.getName()
7603                            },
7604                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
7605                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
7606                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
7607                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
7608                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
7609            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P_H = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
7610                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
7611                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P_H",
7612                            new String[] {
7613                                    Long.class.getName(), Boolean.class.getName(),
7614                                    Long.class.getName(), Boolean.class.getName()
7615                            });
7616    
7617            /**
7618             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7619             *
7620             * @param groupId the group ID
7621             * @param mountPoint the mount point
7622             * @param parentFolderId the parent folder ID
7623             * @param hidden the hidden
7624             * @return the matching document library folders
7625             */
7626            @Override
7627            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7628                    long parentFolderId, boolean hidden) {
7629                    return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
7630                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7631            }
7632    
7633            /**
7634             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7635             *
7636             * <p>
7637             * 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.
7638             * </p>
7639             *
7640             * @param groupId the group ID
7641             * @param mountPoint the mount point
7642             * @param parentFolderId the parent folder ID
7643             * @param hidden the hidden
7644             * @param start the lower bound of the range of document library folders
7645             * @param end the upper bound of the range of document library folders (not inclusive)
7646             * @return the range of matching document library folders
7647             */
7648            @Override
7649            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7650                    long parentFolderId, boolean hidden, int start, int end) {
7651                    return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
7652                            start, end, null);
7653            }
7654    
7655            /**
7656             * Returns an ordered range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7657             *
7658             * <p>
7659             * 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.
7660             * </p>
7661             *
7662             * @param groupId the group ID
7663             * @param mountPoint the mount point
7664             * @param parentFolderId the parent folder ID
7665             * @param hidden the hidden
7666             * @param start the lower bound of the range of document library folders
7667             * @param end the upper bound of the range of document library folders (not inclusive)
7668             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7669             * @return the ordered range of matching document library folders
7670             */
7671            @Override
7672            public List<DLFolder> findByG_M_P_H(long groupId, boolean mountPoint,
7673                    long parentFolderId, boolean hidden, int start, int end,
7674                    OrderByComparator<DLFolder> orderByComparator) {
7675                    boolean pagination = true;
7676                    FinderPath finderPath = null;
7677                    Object[] finderArgs = null;
7678    
7679                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7680                                    (orderByComparator == null)) {
7681                            pagination = false;
7682                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H;
7683                            finderArgs = new Object[] {
7684                                            groupId, mountPoint, parentFolderId, hidden
7685                                    };
7686                    }
7687                    else {
7688                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H;
7689                            finderArgs = new Object[] {
7690                                            groupId, mountPoint, parentFolderId, hidden,
7691                                            
7692                                            start, end, orderByComparator
7693                                    };
7694                    }
7695    
7696                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
7697                                    finderArgs, this);
7698    
7699                    if ((list != null) && !list.isEmpty()) {
7700                            for (DLFolder dlFolder : list) {
7701                                    if ((groupId != dlFolder.getGroupId()) ||
7702                                                    (mountPoint != dlFolder.getMountPoint()) ||
7703                                                    (parentFolderId != dlFolder.getParentFolderId()) ||
7704                                                    (hidden != dlFolder.getHidden())) {
7705                                            list = null;
7706    
7707                                            break;
7708                                    }
7709                            }
7710                    }
7711    
7712                    if (list == null) {
7713                            StringBundler query = null;
7714    
7715                            if (orderByComparator != null) {
7716                                    query = new StringBundler(6 +
7717                                                    (orderByComparator.getOrderByFields().length * 3));
7718                            }
7719                            else {
7720                                    query = new StringBundler(6);
7721                            }
7722    
7723                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
7724    
7725                            query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
7726    
7727                            query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
7728    
7729                            query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
7730    
7731                            query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
7732    
7733                            if (orderByComparator != null) {
7734                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7735                                            orderByComparator);
7736                            }
7737                            else
7738                             if (pagination) {
7739                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
7740                            }
7741    
7742                            String sql = query.toString();
7743    
7744                            Session session = null;
7745    
7746                            try {
7747                                    session = openSession();
7748    
7749                                    Query q = session.createQuery(sql);
7750    
7751                                    QueryPos qPos = QueryPos.getInstance(q);
7752    
7753                                    qPos.add(groupId);
7754    
7755                                    qPos.add(mountPoint);
7756    
7757                                    qPos.add(parentFolderId);
7758    
7759                                    qPos.add(hidden);
7760    
7761                                    if (!pagination) {
7762                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7763                                                            start, end, false);
7764    
7765                                            Collections.sort(list);
7766    
7767                                            list = Collections.unmodifiableList(list);
7768                                    }
7769                                    else {
7770                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
7771                                                            start, end);
7772                                    }
7773    
7774                                    cacheResult(list);
7775    
7776                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7777                            }
7778                            catch (Exception e) {
7779                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7780    
7781                                    throw processException(e);
7782                            }
7783                            finally {
7784                                    closeSession(session);
7785                            }
7786                    }
7787    
7788                    return list;
7789            }
7790    
7791            /**
7792             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7793             *
7794             * @param groupId the group ID
7795             * @param mountPoint the mount point
7796             * @param parentFolderId the parent folder ID
7797             * @param hidden the hidden
7798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7799             * @return the first matching document library folder
7800             * @throws NoSuchFolderException if a matching document library folder could not be found
7801             */
7802            @Override
7803            public DLFolder findByG_M_P_H_First(long groupId, boolean mountPoint,
7804                    long parentFolderId, boolean hidden,
7805                    OrderByComparator<DLFolder> orderByComparator)
7806                    throws NoSuchFolderException {
7807                    DLFolder dlFolder = fetchByG_M_P_H_First(groupId, mountPoint,
7808                                    parentFolderId, hidden, orderByComparator);
7809    
7810                    if (dlFolder != null) {
7811                            return dlFolder;
7812                    }
7813    
7814                    StringBundler msg = new StringBundler(10);
7815    
7816                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7817    
7818                    msg.append("groupId=");
7819                    msg.append(groupId);
7820    
7821                    msg.append(", mountPoint=");
7822                    msg.append(mountPoint);
7823    
7824                    msg.append(", parentFolderId=");
7825                    msg.append(parentFolderId);
7826    
7827                    msg.append(", hidden=");
7828                    msg.append(hidden);
7829    
7830                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7831    
7832                    throw new NoSuchFolderException(msg.toString());
7833            }
7834    
7835            /**
7836             * Returns the first document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7837             *
7838             * @param groupId the group ID
7839             * @param mountPoint the mount point
7840             * @param parentFolderId the parent folder ID
7841             * @param hidden the hidden
7842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7843             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
7844             */
7845            @Override
7846            public DLFolder fetchByG_M_P_H_First(long groupId, boolean mountPoint,
7847                    long parentFolderId, boolean hidden,
7848                    OrderByComparator<DLFolder> orderByComparator) {
7849                    List<DLFolder> list = findByG_M_P_H(groupId, mountPoint,
7850                                    parentFolderId, hidden, 0, 1, orderByComparator);
7851    
7852                    if (!list.isEmpty()) {
7853                            return list.get(0);
7854                    }
7855    
7856                    return null;
7857            }
7858    
7859            /**
7860             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7861             *
7862             * @param groupId the group ID
7863             * @param mountPoint the mount point
7864             * @param parentFolderId the parent folder ID
7865             * @param hidden the hidden
7866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7867             * @return the last matching document library folder
7868             * @throws NoSuchFolderException if a matching document library folder could not be found
7869             */
7870            @Override
7871            public DLFolder findByG_M_P_H_Last(long groupId, boolean mountPoint,
7872                    long parentFolderId, boolean hidden,
7873                    OrderByComparator<DLFolder> orderByComparator)
7874                    throws NoSuchFolderException {
7875                    DLFolder dlFolder = fetchByG_M_P_H_Last(groupId, mountPoint,
7876                                    parentFolderId, hidden, orderByComparator);
7877    
7878                    if (dlFolder != null) {
7879                            return dlFolder;
7880                    }
7881    
7882                    StringBundler msg = new StringBundler(10);
7883    
7884                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7885    
7886                    msg.append("groupId=");
7887                    msg.append(groupId);
7888    
7889                    msg.append(", mountPoint=");
7890                    msg.append(mountPoint);
7891    
7892                    msg.append(", parentFolderId=");
7893                    msg.append(parentFolderId);
7894    
7895                    msg.append(", hidden=");
7896                    msg.append(hidden);
7897    
7898                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7899    
7900                    throw new NoSuchFolderException(msg.toString());
7901            }
7902    
7903            /**
7904             * Returns the last document library folder in the ordered set where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
7905             *
7906             * @param groupId the group ID
7907             * @param mountPoint the mount point
7908             * @param parentFolderId the parent folder ID
7909             * @param hidden the hidden
7910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7911             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
7912             */
7913            @Override
7914            public DLFolder fetchByG_M_P_H_Last(long groupId, boolean mountPoint,
7915                    long parentFolderId, boolean hidden,
7916                    OrderByComparator<DLFolder> orderByComparator) {
7917                    int count = countByG_M_P_H(groupId, mountPoint, parentFolderId, hidden);
7918    
7919                    if (count == 0) {
7920                            return null;
7921                    }
7922    
7923                    List<DLFolder> list = findByG_M_P_H(groupId, mountPoint,
7924                                    parentFolderId, hidden, count - 1, count, orderByComparator);
7925    
7926                    if (!list.isEmpty()) {
7927                            return list.get(0);
7928                    }
7929    
7930                    return null;
7931            }
7932    
7933            /**
7934             * 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;.
7935             *
7936             * @param folderId the primary key of the current document library folder
7937             * @param groupId the group ID
7938             * @param mountPoint the mount point
7939             * @param parentFolderId the parent folder ID
7940             * @param hidden the hidden
7941             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7942             * @return the previous, current, and next document library folder
7943             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
7944             */
7945            @Override
7946            public DLFolder[] findByG_M_P_H_PrevAndNext(long folderId, long groupId,
7947                    boolean mountPoint, long parentFolderId, boolean hidden,
7948                    OrderByComparator<DLFolder> orderByComparator)
7949                    throws NoSuchFolderException {
7950                    DLFolder dlFolder = findByPrimaryKey(folderId);
7951    
7952                    Session session = null;
7953    
7954                    try {
7955                            session = openSession();
7956    
7957                            DLFolder[] array = new DLFolderImpl[3];
7958    
7959                            array[0] = getByG_M_P_H_PrevAndNext(session, dlFolder, groupId,
7960                                            mountPoint, parentFolderId, hidden, orderByComparator, true);
7961    
7962                            array[1] = dlFolder;
7963    
7964                            array[2] = getByG_M_P_H_PrevAndNext(session, dlFolder, groupId,
7965                                            mountPoint, parentFolderId, hidden, orderByComparator, false);
7966    
7967                            return array;
7968                    }
7969                    catch (Exception e) {
7970                            throw processException(e);
7971                    }
7972                    finally {
7973                            closeSession(session);
7974                    }
7975            }
7976    
7977            protected DLFolder getByG_M_P_H_PrevAndNext(Session session,
7978                    DLFolder dlFolder, long groupId, boolean mountPoint,
7979                    long parentFolderId, boolean hidden,
7980                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
7981                    StringBundler query = null;
7982    
7983                    if (orderByComparator != null) {
7984                            query = new StringBundler(6 +
7985                                            (orderByComparator.getOrderByFields().length * 6));
7986                    }
7987                    else {
7988                            query = new StringBundler(3);
7989                    }
7990    
7991                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
7992    
7993                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
7994    
7995                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
7996    
7997                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
7998    
7999                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
8000    
8001                    if (orderByComparator != null) {
8002                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8003    
8004                            if (orderByConditionFields.length > 0) {
8005                                    query.append(WHERE_AND);
8006                            }
8007    
8008                            for (int i = 0; i < orderByConditionFields.length; i++) {
8009                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8010                                    query.append(orderByConditionFields[i]);
8011    
8012                                    if ((i + 1) < orderByConditionFields.length) {
8013                                            if (orderByComparator.isAscending() ^ previous) {
8014                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8015                                            }
8016                                            else {
8017                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8018                                            }
8019                                    }
8020                                    else {
8021                                            if (orderByComparator.isAscending() ^ previous) {
8022                                                    query.append(WHERE_GREATER_THAN);
8023                                            }
8024                                            else {
8025                                                    query.append(WHERE_LESSER_THAN);
8026                                            }
8027                                    }
8028                            }
8029    
8030                            query.append(ORDER_BY_CLAUSE);
8031    
8032                            String[] orderByFields = orderByComparator.getOrderByFields();
8033    
8034                            for (int i = 0; i < orderByFields.length; i++) {
8035                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8036                                    query.append(orderByFields[i]);
8037    
8038                                    if ((i + 1) < orderByFields.length) {
8039                                            if (orderByComparator.isAscending() ^ previous) {
8040                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8041                                            }
8042                                            else {
8043                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8044                                            }
8045                                    }
8046                                    else {
8047                                            if (orderByComparator.isAscending() ^ previous) {
8048                                                    query.append(ORDER_BY_ASC);
8049                                            }
8050                                            else {
8051                                                    query.append(ORDER_BY_DESC);
8052                                            }
8053                                    }
8054                            }
8055                    }
8056                    else {
8057                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8058                    }
8059    
8060                    String sql = query.toString();
8061    
8062                    Query q = session.createQuery(sql);
8063    
8064                    q.setFirstResult(0);
8065                    q.setMaxResults(2);
8066    
8067                    QueryPos qPos = QueryPos.getInstance(q);
8068    
8069                    qPos.add(groupId);
8070    
8071                    qPos.add(mountPoint);
8072    
8073                    qPos.add(parentFolderId);
8074    
8075                    qPos.add(hidden);
8076    
8077                    if (orderByComparator != null) {
8078                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
8079    
8080                            for (Object value : values) {
8081                                    qPos.add(value);
8082                            }
8083                    }
8084    
8085                    List<DLFolder> list = q.list();
8086    
8087                    if (list.size() == 2) {
8088                            return list.get(1);
8089                    }
8090                    else {
8091                            return null;
8092                    }
8093            }
8094    
8095            /**
8096             * 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;.
8097             *
8098             * @param groupId the group ID
8099             * @param mountPoint the mount point
8100             * @param parentFolderId the parent folder ID
8101             * @param hidden the hidden
8102             * @return the matching document library folders that the user has permission to view
8103             */
8104            @Override
8105            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8106                    long parentFolderId, boolean hidden) {
8107                    return filterFindByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8108                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8109            }
8110    
8111            /**
8112             * 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;.
8113             *
8114             * <p>
8115             * 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.
8116             * </p>
8117             *
8118             * @param groupId the group ID
8119             * @param mountPoint the mount point
8120             * @param parentFolderId the parent folder ID
8121             * @param hidden the hidden
8122             * @param start the lower bound of the range of document library folders
8123             * @param end the upper bound of the range of document library folders (not inclusive)
8124             * @return the range of matching document library folders that the user has permission to view
8125             */
8126            @Override
8127            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8128                    long parentFolderId, boolean hidden, int start, int end) {
8129                    return filterFindByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8130                            start, end, null);
8131            }
8132    
8133            /**
8134             * 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;.
8135             *
8136             * <p>
8137             * 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.
8138             * </p>
8139             *
8140             * @param groupId the group ID
8141             * @param mountPoint the mount point
8142             * @param parentFolderId the parent folder ID
8143             * @param hidden the hidden
8144             * @param start the lower bound of the range of document library folders
8145             * @param end the upper bound of the range of document library folders (not inclusive)
8146             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8147             * @return the ordered range of matching document library folders that the user has permission to view
8148             */
8149            @Override
8150            public List<DLFolder> filterFindByG_M_P_H(long groupId, boolean mountPoint,
8151                    long parentFolderId, boolean hidden, int start, int end,
8152                    OrderByComparator<DLFolder> orderByComparator) {
8153                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8154                            return findByG_M_P_H(groupId, mountPoint, parentFolderId, hidden,
8155                                    start, end, orderByComparator);
8156                    }
8157    
8158                    StringBundler query = null;
8159    
8160                    if (orderByComparator != null) {
8161                            query = new StringBundler(6 +
8162                                            (orderByComparator.getOrderByFields().length * 3));
8163                    }
8164                    else {
8165                            query = new StringBundler(6);
8166                    }
8167    
8168                    if (getDB().isSupportsInlineDistinct()) {
8169                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
8170                    }
8171                    else {
8172                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
8173                    }
8174    
8175                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8176    
8177                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8178    
8179                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8180    
8181                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8182    
8183                    if (!getDB().isSupportsInlineDistinct()) {
8184                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
8185                    }
8186    
8187                    if (orderByComparator != null) {
8188                            if (getDB().isSupportsInlineDistinct()) {
8189                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8190                                            orderByComparator, true);
8191                            }
8192                            else {
8193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8194                                            orderByComparator, true);
8195                            }
8196                    }
8197                    else {
8198                            if (getDB().isSupportsInlineDistinct()) {
8199                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8200                            }
8201                            else {
8202                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
8203                            }
8204                    }
8205    
8206                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8207                                    DLFolder.class.getName(),
8208                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8209    
8210                    Session session = null;
8211    
8212                    try {
8213                            session = openSession();
8214    
8215                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8216    
8217                            if (getDB().isSupportsInlineDistinct()) {
8218                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
8219                            }
8220                            else {
8221                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
8222                            }
8223    
8224                            QueryPos qPos = QueryPos.getInstance(q);
8225    
8226                            qPos.add(groupId);
8227    
8228                            qPos.add(mountPoint);
8229    
8230                            qPos.add(parentFolderId);
8231    
8232                            qPos.add(hidden);
8233    
8234                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
8235                    }
8236                    catch (Exception e) {
8237                            throw processException(e);
8238                    }
8239                    finally {
8240                            closeSession(session);
8241                    }
8242            }
8243    
8244            /**
8245             * 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;.
8246             *
8247             * @param folderId the primary key of the current document library folder
8248             * @param groupId the group ID
8249             * @param mountPoint the mount point
8250             * @param parentFolderId the parent folder ID
8251             * @param hidden the hidden
8252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8253             * @return the previous, current, and next document library folder
8254             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
8255             */
8256            @Override
8257            public DLFolder[] filterFindByG_M_P_H_PrevAndNext(long folderId,
8258                    long groupId, boolean mountPoint, long parentFolderId, boolean hidden,
8259                    OrderByComparator<DLFolder> orderByComparator)
8260                    throws NoSuchFolderException {
8261                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8262                            return findByG_M_P_H_PrevAndNext(folderId, groupId, mountPoint,
8263                                    parentFolderId, hidden, orderByComparator);
8264                    }
8265    
8266                    DLFolder dlFolder = findByPrimaryKey(folderId);
8267    
8268                    Session session = null;
8269    
8270                    try {
8271                            session = openSession();
8272    
8273                            DLFolder[] array = new DLFolderImpl[3];
8274    
8275                            array[0] = filterGetByG_M_P_H_PrevAndNext(session, dlFolder,
8276                                            groupId, mountPoint, parentFolderId, hidden,
8277                                            orderByComparator, true);
8278    
8279                            array[1] = dlFolder;
8280    
8281                            array[2] = filterGetByG_M_P_H_PrevAndNext(session, dlFolder,
8282                                            groupId, mountPoint, parentFolderId, hidden,
8283                                            orderByComparator, false);
8284    
8285                            return array;
8286                    }
8287                    catch (Exception e) {
8288                            throw processException(e);
8289                    }
8290                    finally {
8291                            closeSession(session);
8292                    }
8293            }
8294    
8295            protected DLFolder filterGetByG_M_P_H_PrevAndNext(Session session,
8296                    DLFolder dlFolder, long groupId, boolean mountPoint,
8297                    long parentFolderId, boolean hidden,
8298                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
8299                    StringBundler query = null;
8300    
8301                    if (orderByComparator != null) {
8302                            query = new StringBundler(6 +
8303                                            (orderByComparator.getOrderByFields().length * 6));
8304                    }
8305                    else {
8306                            query = new StringBundler(3);
8307                    }
8308    
8309                    if (getDB().isSupportsInlineDistinct()) {
8310                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
8311                    }
8312                    else {
8313                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
8314                    }
8315    
8316                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8317    
8318                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8319    
8320                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8321    
8322                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8323    
8324                    if (!getDB().isSupportsInlineDistinct()) {
8325                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
8326                    }
8327    
8328                    if (orderByComparator != null) {
8329                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8330    
8331                            if (orderByConditionFields.length > 0) {
8332                                    query.append(WHERE_AND);
8333                            }
8334    
8335                            for (int i = 0; i < orderByConditionFields.length; i++) {
8336                                    if (getDB().isSupportsInlineDistinct()) {
8337                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8338                                    }
8339                                    else {
8340                                            query.append(_ORDER_BY_ENTITY_TABLE);
8341                                    }
8342    
8343                                    query.append(orderByConditionFields[i]);
8344    
8345                                    if ((i + 1) < orderByConditionFields.length) {
8346                                            if (orderByComparator.isAscending() ^ previous) {
8347                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8348                                            }
8349                                            else {
8350                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8351                                            }
8352                                    }
8353                                    else {
8354                                            if (orderByComparator.isAscending() ^ previous) {
8355                                                    query.append(WHERE_GREATER_THAN);
8356                                            }
8357                                            else {
8358                                                    query.append(WHERE_LESSER_THAN);
8359                                            }
8360                                    }
8361                            }
8362    
8363                            query.append(ORDER_BY_CLAUSE);
8364    
8365                            String[] orderByFields = orderByComparator.getOrderByFields();
8366    
8367                            for (int i = 0; i < orderByFields.length; i++) {
8368                                    if (getDB().isSupportsInlineDistinct()) {
8369                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8370                                    }
8371                                    else {
8372                                            query.append(_ORDER_BY_ENTITY_TABLE);
8373                                    }
8374    
8375                                    query.append(orderByFields[i]);
8376    
8377                                    if ((i + 1) < orderByFields.length) {
8378                                            if (orderByComparator.isAscending() ^ previous) {
8379                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8380                                            }
8381                                            else {
8382                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8383                                            }
8384                                    }
8385                                    else {
8386                                            if (orderByComparator.isAscending() ^ previous) {
8387                                                    query.append(ORDER_BY_ASC);
8388                                            }
8389                                            else {
8390                                                    query.append(ORDER_BY_DESC);
8391                                            }
8392                                    }
8393                            }
8394                    }
8395                    else {
8396                            if (getDB().isSupportsInlineDistinct()) {
8397                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8398                            }
8399                            else {
8400                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
8401                            }
8402                    }
8403    
8404                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8405                                    DLFolder.class.getName(),
8406                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8407    
8408                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8409    
8410                    q.setFirstResult(0);
8411                    q.setMaxResults(2);
8412    
8413                    if (getDB().isSupportsInlineDistinct()) {
8414                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
8415                    }
8416                    else {
8417                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
8418                    }
8419    
8420                    QueryPos qPos = QueryPos.getInstance(q);
8421    
8422                    qPos.add(groupId);
8423    
8424                    qPos.add(mountPoint);
8425    
8426                    qPos.add(parentFolderId);
8427    
8428                    qPos.add(hidden);
8429    
8430                    if (orderByComparator != null) {
8431                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
8432    
8433                            for (Object value : values) {
8434                                    qPos.add(value);
8435                            }
8436                    }
8437    
8438                    List<DLFolder> list = q.list();
8439    
8440                    if (list.size() == 2) {
8441                            return list.get(1);
8442                    }
8443                    else {
8444                            return null;
8445                    }
8446            }
8447    
8448            /**
8449             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; from the database.
8450             *
8451             * @param groupId the group ID
8452             * @param mountPoint the mount point
8453             * @param parentFolderId the parent folder ID
8454             * @param hidden the hidden
8455             */
8456            @Override
8457            public void removeByG_M_P_H(long groupId, boolean mountPoint,
8458                    long parentFolderId, boolean hidden) {
8459                    for (DLFolder dlFolder : findByG_M_P_H(groupId, mountPoint,
8460                                    parentFolderId, hidden, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
8461                                    null)) {
8462                            remove(dlFolder);
8463                    }
8464            }
8465    
8466            /**
8467             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63;.
8468             *
8469             * @param groupId the group ID
8470             * @param mountPoint the mount point
8471             * @param parentFolderId the parent folder ID
8472             * @param hidden the hidden
8473             * @return the number of matching document library folders
8474             */
8475            @Override
8476            public int countByG_M_P_H(long groupId, boolean mountPoint,
8477                    long parentFolderId, boolean hidden) {
8478                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P_H;
8479    
8480                    Object[] finderArgs = new Object[] {
8481                                    groupId, mountPoint, parentFolderId, hidden
8482                            };
8483    
8484                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8485                                    this);
8486    
8487                    if (count == null) {
8488                            StringBundler query = new StringBundler(5);
8489    
8490                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
8491    
8492                            query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8493    
8494                            query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8495    
8496                            query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8497    
8498                            query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2);
8499    
8500                            String sql = query.toString();
8501    
8502                            Session session = null;
8503    
8504                            try {
8505                                    session = openSession();
8506    
8507                                    Query q = session.createQuery(sql);
8508    
8509                                    QueryPos qPos = QueryPos.getInstance(q);
8510    
8511                                    qPos.add(groupId);
8512    
8513                                    qPos.add(mountPoint);
8514    
8515                                    qPos.add(parentFolderId);
8516    
8517                                    qPos.add(hidden);
8518    
8519                                    count = (Long)q.uniqueResult();
8520    
8521                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8522                            }
8523                            catch (Exception e) {
8524                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8525    
8526                                    throw processException(e);
8527                            }
8528                            finally {
8529                                    closeSession(session);
8530                            }
8531                    }
8532    
8533                    return count.intValue();
8534            }
8535    
8536            /**
8537             * 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;.
8538             *
8539             * @param groupId the group ID
8540             * @param mountPoint the mount point
8541             * @param parentFolderId the parent folder ID
8542             * @param hidden the hidden
8543             * @return the number of matching document library folders that the user has permission to view
8544             */
8545            @Override
8546            public int filterCountByG_M_P_H(long groupId, boolean mountPoint,
8547                    long parentFolderId, boolean hidden) {
8548                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8549                            return countByG_M_P_H(groupId, mountPoint, parentFolderId, hidden);
8550                    }
8551    
8552                    StringBundler query = new StringBundler(5);
8553    
8554                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
8555    
8556                    query.append(_FINDER_COLUMN_G_M_P_H_GROUPID_2);
8557    
8558                    query.append(_FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2);
8559    
8560                    query.append(_FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2);
8561    
8562                    query.append(_FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL);
8563    
8564                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8565                                    DLFolder.class.getName(),
8566                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8567    
8568                    Session session = null;
8569    
8570                    try {
8571                            session = openSession();
8572    
8573                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8574    
8575                            q.addScalar(COUNT_COLUMN_NAME,
8576                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8577    
8578                            QueryPos qPos = QueryPos.getInstance(q);
8579    
8580                            qPos.add(groupId);
8581    
8582                            qPos.add(mountPoint);
8583    
8584                            qPos.add(parentFolderId);
8585    
8586                            qPos.add(hidden);
8587    
8588                            Long count = (Long)q.uniqueResult();
8589    
8590                            return count.intValue();
8591                    }
8592                    catch (Exception e) {
8593                            throw processException(e);
8594                    }
8595                    finally {
8596                            closeSession(session);
8597                    }
8598            }
8599    
8600            private static final String _FINDER_COLUMN_G_M_P_H_GROUPID_2 = "dlFolder.groupId = ? AND ";
8601            private static final String _FINDER_COLUMN_G_M_P_H_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
8602            private static final String _FINDER_COLUMN_G_M_P_H_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
8603            private static final String _FINDER_COLUMN_G_M_P_H_HIDDEN_2 = "dlFolder.hidden = ?";
8604            private static final String _FINDER_COLUMN_G_M_P_H_HIDDEN_2_SQL = "dlFolder.hidden_ = ?";
8605            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
8606                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
8607                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_H_S",
8608                            new String[] {
8609                                    Long.class.getName(), Long.class.getName(),
8610                                    Boolean.class.getName(), Integer.class.getName(),
8611                                    
8612                            Integer.class.getName(), Integer.class.getName(),
8613                                    OrderByComparator.class.getName()
8614                            });
8615            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S =
8616                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
8617                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
8618                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_H_S",
8619                            new String[] {
8620                                    Long.class.getName(), Long.class.getName(),
8621                                    Boolean.class.getName(), Integer.class.getName()
8622                            },
8623                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
8624                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
8625                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
8626                            DLFolderModelImpl.STATUS_COLUMN_BITMASK |
8627                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
8628            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
8629                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
8630                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_H_S",
8631                            new String[] {
8632                                    Long.class.getName(), Long.class.getName(),
8633                                    Boolean.class.getName(), Integer.class.getName()
8634                            });
8635    
8636            /**
8637             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8638             *
8639             * @param groupId the group ID
8640             * @param parentFolderId the parent folder ID
8641             * @param hidden the hidden
8642             * @param status the status
8643             * @return the matching document library folders
8644             */
8645            @Override
8646            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
8647                    boolean hidden, int status) {
8648                    return findByG_P_H_S(groupId, parentFolderId, hidden, status,
8649                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8650            }
8651    
8652            /**
8653             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8654             *
8655             * <p>
8656             * 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.
8657             * </p>
8658             *
8659             * @param groupId the group ID
8660             * @param parentFolderId the parent folder ID
8661             * @param hidden the hidden
8662             * @param status the status
8663             * @param start the lower bound of the range of document library folders
8664             * @param end the upper bound of the range of document library folders (not inclusive)
8665             * @return the range of matching document library folders
8666             */
8667            @Override
8668            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
8669                    boolean hidden, int status, int start, int end) {
8670                    return findByG_P_H_S(groupId, parentFolderId, hidden, status, start,
8671                            end, null);
8672            }
8673    
8674            /**
8675             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8676             *
8677             * <p>
8678             * 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.
8679             * </p>
8680             *
8681             * @param groupId the group ID
8682             * @param parentFolderId the parent folder ID
8683             * @param hidden the hidden
8684             * @param status the status
8685             * @param start the lower bound of the range of document library folders
8686             * @param end the upper bound of the range of document library folders (not inclusive)
8687             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8688             * @return the ordered range of matching document library folders
8689             */
8690            @Override
8691            public List<DLFolder> findByG_P_H_S(long groupId, long parentFolderId,
8692                    boolean hidden, int status, int start, int end,
8693                    OrderByComparator<DLFolder> orderByComparator) {
8694                    boolean pagination = true;
8695                    FinderPath finderPath = null;
8696                    Object[] finderArgs = null;
8697    
8698                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8699                                    (orderByComparator == null)) {
8700                            pagination = false;
8701                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S;
8702                            finderArgs = new Object[] { groupId, parentFolderId, hidden, status };
8703                    }
8704                    else {
8705                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_H_S;
8706                            finderArgs = new Object[] {
8707                                            groupId, parentFolderId, hidden, status,
8708                                            
8709                                            start, end, orderByComparator
8710                                    };
8711                    }
8712    
8713                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
8714                                    finderArgs, this);
8715    
8716                    if ((list != null) && !list.isEmpty()) {
8717                            for (DLFolder dlFolder : list) {
8718                                    if ((groupId != dlFolder.getGroupId()) ||
8719                                                    (parentFolderId != dlFolder.getParentFolderId()) ||
8720                                                    (hidden != dlFolder.getHidden()) ||
8721                                                    (status != dlFolder.getStatus())) {
8722                                            list = null;
8723    
8724                                            break;
8725                                    }
8726                            }
8727                    }
8728    
8729                    if (list == null) {
8730                            StringBundler query = null;
8731    
8732                            if (orderByComparator != null) {
8733                                    query = new StringBundler(6 +
8734                                                    (orderByComparator.getOrderByFields().length * 3));
8735                            }
8736                            else {
8737                                    query = new StringBundler(6);
8738                            }
8739    
8740                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
8741    
8742                            query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
8743    
8744                            query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
8745    
8746                            query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
8747    
8748                            query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
8749    
8750                            if (orderByComparator != null) {
8751                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8752                                            orderByComparator);
8753                            }
8754                            else
8755                             if (pagination) {
8756                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
8757                            }
8758    
8759                            String sql = query.toString();
8760    
8761                            Session session = null;
8762    
8763                            try {
8764                                    session = openSession();
8765    
8766                                    Query q = session.createQuery(sql);
8767    
8768                                    QueryPos qPos = QueryPos.getInstance(q);
8769    
8770                                    qPos.add(groupId);
8771    
8772                                    qPos.add(parentFolderId);
8773    
8774                                    qPos.add(hidden);
8775    
8776                                    qPos.add(status);
8777    
8778                                    if (!pagination) {
8779                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
8780                                                            start, end, false);
8781    
8782                                            Collections.sort(list);
8783    
8784                                            list = Collections.unmodifiableList(list);
8785                                    }
8786                                    else {
8787                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
8788                                                            start, end);
8789                                    }
8790    
8791                                    cacheResult(list);
8792    
8793                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8794                            }
8795                            catch (Exception e) {
8796                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8797    
8798                                    throw processException(e);
8799                            }
8800                            finally {
8801                                    closeSession(session);
8802                            }
8803                    }
8804    
8805                    return list;
8806            }
8807    
8808            /**
8809             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8810             *
8811             * @param groupId the group ID
8812             * @param parentFolderId the parent folder ID
8813             * @param hidden the hidden
8814             * @param status the status
8815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8816             * @return the first matching document library folder
8817             * @throws NoSuchFolderException if a matching document library folder could not be found
8818             */
8819            @Override
8820            public DLFolder findByG_P_H_S_First(long groupId, long parentFolderId,
8821                    boolean hidden, int status,
8822                    OrderByComparator<DLFolder> orderByComparator)
8823                    throws NoSuchFolderException {
8824                    DLFolder dlFolder = fetchByG_P_H_S_First(groupId, parentFolderId,
8825                                    hidden, status, orderByComparator);
8826    
8827                    if (dlFolder != null) {
8828                            return dlFolder;
8829                    }
8830    
8831                    StringBundler msg = new StringBundler(10);
8832    
8833                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8834    
8835                    msg.append("groupId=");
8836                    msg.append(groupId);
8837    
8838                    msg.append(", parentFolderId=");
8839                    msg.append(parentFolderId);
8840    
8841                    msg.append(", hidden=");
8842                    msg.append(hidden);
8843    
8844                    msg.append(", status=");
8845                    msg.append(status);
8846    
8847                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8848    
8849                    throw new NoSuchFolderException(msg.toString());
8850            }
8851    
8852            /**
8853             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8854             *
8855             * @param groupId the group ID
8856             * @param parentFolderId the parent folder ID
8857             * @param hidden the hidden
8858             * @param status the status
8859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8860             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
8861             */
8862            @Override
8863            public DLFolder fetchByG_P_H_S_First(long groupId, long parentFolderId,
8864                    boolean hidden, int status,
8865                    OrderByComparator<DLFolder> orderByComparator) {
8866                    List<DLFolder> list = findByG_P_H_S(groupId, parentFolderId, hidden,
8867                                    status, 0, 1, orderByComparator);
8868    
8869                    if (!list.isEmpty()) {
8870                            return list.get(0);
8871                    }
8872    
8873                    return null;
8874            }
8875    
8876            /**
8877             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8878             *
8879             * @param groupId the group ID
8880             * @param parentFolderId the parent folder ID
8881             * @param hidden the hidden
8882             * @param status the status
8883             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8884             * @return the last matching document library folder
8885             * @throws NoSuchFolderException if a matching document library folder could not be found
8886             */
8887            @Override
8888            public DLFolder findByG_P_H_S_Last(long groupId, long parentFolderId,
8889                    boolean hidden, int status,
8890                    OrderByComparator<DLFolder> orderByComparator)
8891                    throws NoSuchFolderException {
8892                    DLFolder dlFolder = fetchByG_P_H_S_Last(groupId, parentFolderId,
8893                                    hidden, status, orderByComparator);
8894    
8895                    if (dlFolder != null) {
8896                            return dlFolder;
8897                    }
8898    
8899                    StringBundler msg = new StringBundler(10);
8900    
8901                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8902    
8903                    msg.append("groupId=");
8904                    msg.append(groupId);
8905    
8906                    msg.append(", parentFolderId=");
8907                    msg.append(parentFolderId);
8908    
8909                    msg.append(", hidden=");
8910                    msg.append(hidden);
8911    
8912                    msg.append(", status=");
8913                    msg.append(status);
8914    
8915                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8916    
8917                    throw new NoSuchFolderException(msg.toString());
8918            }
8919    
8920            /**
8921             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
8922             *
8923             * @param groupId the group ID
8924             * @param parentFolderId the parent folder ID
8925             * @param hidden the hidden
8926             * @param status the status
8927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8928             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
8929             */
8930            @Override
8931            public DLFolder fetchByG_P_H_S_Last(long groupId, long parentFolderId,
8932                    boolean hidden, int status,
8933                    OrderByComparator<DLFolder> orderByComparator) {
8934                    int count = countByG_P_H_S(groupId, parentFolderId, hidden, status);
8935    
8936                    if (count == 0) {
8937                            return null;
8938                    }
8939    
8940                    List<DLFolder> list = findByG_P_H_S(groupId, parentFolderId, hidden,
8941                                    status, count - 1, count, orderByComparator);
8942    
8943                    if (!list.isEmpty()) {
8944                            return list.get(0);
8945                    }
8946    
8947                    return null;
8948            }
8949    
8950            /**
8951             * 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;.
8952             *
8953             * @param folderId the primary key of the current document library folder
8954             * @param groupId the group ID
8955             * @param parentFolderId the parent folder ID
8956             * @param hidden the hidden
8957             * @param status the status
8958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8959             * @return the previous, current, and next document library folder
8960             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
8961             */
8962            @Override
8963            public DLFolder[] findByG_P_H_S_PrevAndNext(long folderId, long groupId,
8964                    long parentFolderId, boolean hidden, int status,
8965                    OrderByComparator<DLFolder> orderByComparator)
8966                    throws NoSuchFolderException {
8967                    DLFolder dlFolder = findByPrimaryKey(folderId);
8968    
8969                    Session session = null;
8970    
8971                    try {
8972                            session = openSession();
8973    
8974                            DLFolder[] array = new DLFolderImpl[3];
8975    
8976                            array[0] = getByG_P_H_S_PrevAndNext(session, dlFolder, groupId,
8977                                            parentFolderId, hidden, status, orderByComparator, true);
8978    
8979                            array[1] = dlFolder;
8980    
8981                            array[2] = getByG_P_H_S_PrevAndNext(session, dlFolder, groupId,
8982                                            parentFolderId, hidden, status, orderByComparator, false);
8983    
8984                            return array;
8985                    }
8986                    catch (Exception e) {
8987                            throw processException(e);
8988                    }
8989                    finally {
8990                            closeSession(session);
8991                    }
8992            }
8993    
8994            protected DLFolder getByG_P_H_S_PrevAndNext(Session session,
8995                    DLFolder dlFolder, long groupId, long parentFolderId, boolean hidden,
8996                    int status, OrderByComparator<DLFolder> orderByComparator,
8997                    boolean previous) {
8998                    StringBundler query = null;
8999    
9000                    if (orderByComparator != null) {
9001                            query = new StringBundler(6 +
9002                                            (orderByComparator.getOrderByFields().length * 6));
9003                    }
9004                    else {
9005                            query = new StringBundler(3);
9006                    }
9007    
9008                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
9009    
9010                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
9011    
9012                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
9013    
9014                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
9015    
9016                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
9017    
9018                    if (orderByComparator != null) {
9019                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9020    
9021                            if (orderByConditionFields.length > 0) {
9022                                    query.append(WHERE_AND);
9023                            }
9024    
9025                            for (int i = 0; i < orderByConditionFields.length; i++) {
9026                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9027                                    query.append(orderByConditionFields[i]);
9028    
9029                                    if ((i + 1) < orderByConditionFields.length) {
9030                                            if (orderByComparator.isAscending() ^ previous) {
9031                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9032                                            }
9033                                            else {
9034                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9035                                            }
9036                                    }
9037                                    else {
9038                                            if (orderByComparator.isAscending() ^ previous) {
9039                                                    query.append(WHERE_GREATER_THAN);
9040                                            }
9041                                            else {
9042                                                    query.append(WHERE_LESSER_THAN);
9043                                            }
9044                                    }
9045                            }
9046    
9047                            query.append(ORDER_BY_CLAUSE);
9048    
9049                            String[] orderByFields = orderByComparator.getOrderByFields();
9050    
9051                            for (int i = 0; i < orderByFields.length; i++) {
9052                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9053                                    query.append(orderByFields[i]);
9054    
9055                                    if ((i + 1) < orderByFields.length) {
9056                                            if (orderByComparator.isAscending() ^ previous) {
9057                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9058                                            }
9059                                            else {
9060                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9061                                            }
9062                                    }
9063                                    else {
9064                                            if (orderByComparator.isAscending() ^ previous) {
9065                                                    query.append(ORDER_BY_ASC);
9066                                            }
9067                                            else {
9068                                                    query.append(ORDER_BY_DESC);
9069                                            }
9070                                    }
9071                            }
9072                    }
9073                    else {
9074                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9075                    }
9076    
9077                    String sql = query.toString();
9078    
9079                    Query q = session.createQuery(sql);
9080    
9081                    q.setFirstResult(0);
9082                    q.setMaxResults(2);
9083    
9084                    QueryPos qPos = QueryPos.getInstance(q);
9085    
9086                    qPos.add(groupId);
9087    
9088                    qPos.add(parentFolderId);
9089    
9090                    qPos.add(hidden);
9091    
9092                    qPos.add(status);
9093    
9094                    if (orderByComparator != null) {
9095                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
9096    
9097                            for (Object value : values) {
9098                                    qPos.add(value);
9099                            }
9100                    }
9101    
9102                    List<DLFolder> list = q.list();
9103    
9104                    if (list.size() == 2) {
9105                            return list.get(1);
9106                    }
9107                    else {
9108                            return null;
9109                    }
9110            }
9111    
9112            /**
9113             * 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;.
9114             *
9115             * @param groupId the group ID
9116             * @param parentFolderId the parent folder ID
9117             * @param hidden the hidden
9118             * @param status the status
9119             * @return the matching document library folders that the user has permission to view
9120             */
9121            @Override
9122            public List<DLFolder> filterFindByG_P_H_S(long groupId,
9123                    long parentFolderId, boolean hidden, int status) {
9124                    return filterFindByG_P_H_S(groupId, parentFolderId, hidden, status,
9125                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9126            }
9127    
9128            /**
9129             * 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;.
9130             *
9131             * <p>
9132             * 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.
9133             * </p>
9134             *
9135             * @param groupId the group ID
9136             * @param parentFolderId the parent folder ID
9137             * @param hidden the hidden
9138             * @param status the status
9139             * @param start the lower bound of the range of document library folders
9140             * @param end the upper bound of the range of document library folders (not inclusive)
9141             * @return the range of matching document library folders that the user has permission to view
9142             */
9143            @Override
9144            public List<DLFolder> filterFindByG_P_H_S(long groupId,
9145                    long parentFolderId, boolean hidden, int status, int start, int end) {
9146                    return filterFindByG_P_H_S(groupId, parentFolderId, hidden, status,
9147                            start, end, null);
9148            }
9149    
9150            /**
9151             * 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;.
9152             *
9153             * <p>
9154             * 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.
9155             * </p>
9156             *
9157             * @param groupId the group ID
9158             * @param parentFolderId the parent folder ID
9159             * @param hidden the hidden
9160             * @param status the status
9161             * @param start the lower bound of the range of document library folders
9162             * @param end the upper bound of the range of document library folders (not inclusive)
9163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9164             * @return the ordered range of matching document library folders that the user has permission to view
9165             */
9166            @Override
9167            public List<DLFolder> filterFindByG_P_H_S(long groupId,
9168                    long parentFolderId, boolean hidden, int status, int start, int end,
9169                    OrderByComparator<DLFolder> orderByComparator) {
9170                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9171                            return findByG_P_H_S(groupId, parentFolderId, hidden, status,
9172                                    start, end, orderByComparator);
9173                    }
9174    
9175                    StringBundler query = null;
9176    
9177                    if (orderByComparator != null) {
9178                            query = new StringBundler(6 +
9179                                            (orderByComparator.getOrderByFields().length * 3));
9180                    }
9181                    else {
9182                            query = new StringBundler(6);
9183                    }
9184    
9185                    if (getDB().isSupportsInlineDistinct()) {
9186                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
9187                    }
9188                    else {
9189                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
9190                    }
9191    
9192                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
9193    
9194                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
9195    
9196                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
9197    
9198                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
9199    
9200                    if (!getDB().isSupportsInlineDistinct()) {
9201                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
9202                    }
9203    
9204                    if (orderByComparator != null) {
9205                            if (getDB().isSupportsInlineDistinct()) {
9206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9207                                            orderByComparator, true);
9208                            }
9209                            else {
9210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9211                                            orderByComparator, true);
9212                            }
9213                    }
9214                    else {
9215                            if (getDB().isSupportsInlineDistinct()) {
9216                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9217                            }
9218                            else {
9219                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
9220                            }
9221                    }
9222    
9223                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9224                                    DLFolder.class.getName(),
9225                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9226    
9227                    Session session = null;
9228    
9229                    try {
9230                            session = openSession();
9231    
9232                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9233    
9234                            if (getDB().isSupportsInlineDistinct()) {
9235                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
9236                            }
9237                            else {
9238                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
9239                            }
9240    
9241                            QueryPos qPos = QueryPos.getInstance(q);
9242    
9243                            qPos.add(groupId);
9244    
9245                            qPos.add(parentFolderId);
9246    
9247                            qPos.add(hidden);
9248    
9249                            qPos.add(status);
9250    
9251                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
9252                    }
9253                    catch (Exception e) {
9254                            throw processException(e);
9255                    }
9256                    finally {
9257                            closeSession(session);
9258                    }
9259            }
9260    
9261            /**
9262             * 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;.
9263             *
9264             * @param folderId the primary key of the current document library folder
9265             * @param groupId the group ID
9266             * @param parentFolderId the parent folder ID
9267             * @param hidden the hidden
9268             * @param status the status
9269             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9270             * @return the previous, current, and next document library folder
9271             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
9272             */
9273            @Override
9274            public DLFolder[] filterFindByG_P_H_S_PrevAndNext(long folderId,
9275                    long groupId, long parentFolderId, boolean hidden, int status,
9276                    OrderByComparator<DLFolder> orderByComparator)
9277                    throws NoSuchFolderException {
9278                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9279                            return findByG_P_H_S_PrevAndNext(folderId, groupId, parentFolderId,
9280                                    hidden, status, orderByComparator);
9281                    }
9282    
9283                    DLFolder dlFolder = findByPrimaryKey(folderId);
9284    
9285                    Session session = null;
9286    
9287                    try {
9288                            session = openSession();
9289    
9290                            DLFolder[] array = new DLFolderImpl[3];
9291    
9292                            array[0] = filterGetByG_P_H_S_PrevAndNext(session, dlFolder,
9293                                            groupId, parentFolderId, hidden, status, orderByComparator,
9294                                            true);
9295    
9296                            array[1] = dlFolder;
9297    
9298                            array[2] = filterGetByG_P_H_S_PrevAndNext(session, dlFolder,
9299                                            groupId, parentFolderId, hidden, status, orderByComparator,
9300                                            false);
9301    
9302                            return array;
9303                    }
9304                    catch (Exception e) {
9305                            throw processException(e);
9306                    }
9307                    finally {
9308                            closeSession(session);
9309                    }
9310            }
9311    
9312            protected DLFolder filterGetByG_P_H_S_PrevAndNext(Session session,
9313                    DLFolder dlFolder, long groupId, long parentFolderId, boolean hidden,
9314                    int status, OrderByComparator<DLFolder> orderByComparator,
9315                    boolean previous) {
9316                    StringBundler query = null;
9317    
9318                    if (orderByComparator != null) {
9319                            query = new StringBundler(6 +
9320                                            (orderByComparator.getOrderByFields().length * 6));
9321                    }
9322                    else {
9323                            query = new StringBundler(3);
9324                    }
9325    
9326                    if (getDB().isSupportsInlineDistinct()) {
9327                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
9328                    }
9329                    else {
9330                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
9331                    }
9332    
9333                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
9334    
9335                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
9336    
9337                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
9338    
9339                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
9340    
9341                    if (!getDB().isSupportsInlineDistinct()) {
9342                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
9343                    }
9344    
9345                    if (orderByComparator != null) {
9346                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9347    
9348                            if (orderByConditionFields.length > 0) {
9349                                    query.append(WHERE_AND);
9350                            }
9351    
9352                            for (int i = 0; i < orderByConditionFields.length; i++) {
9353                                    if (getDB().isSupportsInlineDistinct()) {
9354                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9355                                    }
9356                                    else {
9357                                            query.append(_ORDER_BY_ENTITY_TABLE);
9358                                    }
9359    
9360                                    query.append(orderByConditionFields[i]);
9361    
9362                                    if ((i + 1) < orderByConditionFields.length) {
9363                                            if (orderByComparator.isAscending() ^ previous) {
9364                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9365                                            }
9366                                            else {
9367                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9368                                            }
9369                                    }
9370                                    else {
9371                                            if (orderByComparator.isAscending() ^ previous) {
9372                                                    query.append(WHERE_GREATER_THAN);
9373                                            }
9374                                            else {
9375                                                    query.append(WHERE_LESSER_THAN);
9376                                            }
9377                                    }
9378                            }
9379    
9380                            query.append(ORDER_BY_CLAUSE);
9381    
9382                            String[] orderByFields = orderByComparator.getOrderByFields();
9383    
9384                            for (int i = 0; i < orderByFields.length; i++) {
9385                                    if (getDB().isSupportsInlineDistinct()) {
9386                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9387                                    }
9388                                    else {
9389                                            query.append(_ORDER_BY_ENTITY_TABLE);
9390                                    }
9391    
9392                                    query.append(orderByFields[i]);
9393    
9394                                    if ((i + 1) < orderByFields.length) {
9395                                            if (orderByComparator.isAscending() ^ previous) {
9396                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9397                                            }
9398                                            else {
9399                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9400                                            }
9401                                    }
9402                                    else {
9403                                            if (orderByComparator.isAscending() ^ previous) {
9404                                                    query.append(ORDER_BY_ASC);
9405                                            }
9406                                            else {
9407                                                    query.append(ORDER_BY_DESC);
9408                                            }
9409                                    }
9410                            }
9411                    }
9412                    else {
9413                            if (getDB().isSupportsInlineDistinct()) {
9414                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9415                            }
9416                            else {
9417                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
9418                            }
9419                    }
9420    
9421                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9422                                    DLFolder.class.getName(),
9423                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9424    
9425                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9426    
9427                    q.setFirstResult(0);
9428                    q.setMaxResults(2);
9429    
9430                    if (getDB().isSupportsInlineDistinct()) {
9431                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
9432                    }
9433                    else {
9434                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
9435                    }
9436    
9437                    QueryPos qPos = QueryPos.getInstance(q);
9438    
9439                    qPos.add(groupId);
9440    
9441                    qPos.add(parentFolderId);
9442    
9443                    qPos.add(hidden);
9444    
9445                    qPos.add(status);
9446    
9447                    if (orderByComparator != null) {
9448                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
9449    
9450                            for (Object value : values) {
9451                                    qPos.add(value);
9452                            }
9453                    }
9454    
9455                    List<DLFolder> list = q.list();
9456    
9457                    if (list.size() == 2) {
9458                            return list.get(1);
9459                    }
9460                    else {
9461                            return null;
9462                    }
9463            }
9464    
9465            /**
9466             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63; from the database.
9467             *
9468             * @param groupId the group ID
9469             * @param parentFolderId the parent folder ID
9470             * @param hidden the hidden
9471             * @param status the status
9472             */
9473            @Override
9474            public void removeByG_P_H_S(long groupId, long parentFolderId,
9475                    boolean hidden, int status) {
9476                    for (DLFolder dlFolder : findByG_P_H_S(groupId, parentFolderId, hidden,
9477                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9478                            remove(dlFolder);
9479                    }
9480            }
9481    
9482            /**
9483             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
9484             *
9485             * @param groupId the group ID
9486             * @param parentFolderId the parent folder ID
9487             * @param hidden the hidden
9488             * @param status the status
9489             * @return the number of matching document library folders
9490             */
9491            @Override
9492            public int countByG_P_H_S(long groupId, long parentFolderId,
9493                    boolean hidden, int status) {
9494                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_H_S;
9495    
9496                    Object[] finderArgs = new Object[] {
9497                                    groupId, parentFolderId, hidden, status
9498                            };
9499    
9500                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9501                                    this);
9502    
9503                    if (count == null) {
9504                            StringBundler query = new StringBundler(5);
9505    
9506                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
9507    
9508                            query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
9509    
9510                            query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
9511    
9512                            query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2);
9513    
9514                            query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
9515    
9516                            String sql = query.toString();
9517    
9518                            Session session = null;
9519    
9520                            try {
9521                                    session = openSession();
9522    
9523                                    Query q = session.createQuery(sql);
9524    
9525                                    QueryPos qPos = QueryPos.getInstance(q);
9526    
9527                                    qPos.add(groupId);
9528    
9529                                    qPos.add(parentFolderId);
9530    
9531                                    qPos.add(hidden);
9532    
9533                                    qPos.add(status);
9534    
9535                                    count = (Long)q.uniqueResult();
9536    
9537                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9538                            }
9539                            catch (Exception e) {
9540                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9541    
9542                                    throw processException(e);
9543                            }
9544                            finally {
9545                                    closeSession(session);
9546                            }
9547                    }
9548    
9549                    return count.intValue();
9550            }
9551    
9552            /**
9553             * 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;.
9554             *
9555             * @param groupId the group ID
9556             * @param parentFolderId the parent folder ID
9557             * @param hidden the hidden
9558             * @param status the status
9559             * @return the number of matching document library folders that the user has permission to view
9560             */
9561            @Override
9562            public int filterCountByG_P_H_S(long groupId, long parentFolderId,
9563                    boolean hidden, int status) {
9564                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9565                            return countByG_P_H_S(groupId, parentFolderId, hidden, status);
9566                    }
9567    
9568                    StringBundler query = new StringBundler(5);
9569    
9570                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
9571    
9572                    query.append(_FINDER_COLUMN_G_P_H_S_GROUPID_2);
9573    
9574                    query.append(_FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2);
9575    
9576                    query.append(_FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL);
9577    
9578                    query.append(_FINDER_COLUMN_G_P_H_S_STATUS_2);
9579    
9580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9581                                    DLFolder.class.getName(),
9582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9583    
9584                    Session session = null;
9585    
9586                    try {
9587                            session = openSession();
9588    
9589                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9590    
9591                            q.addScalar(COUNT_COLUMN_NAME,
9592                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9593    
9594                            QueryPos qPos = QueryPos.getInstance(q);
9595    
9596                            qPos.add(groupId);
9597    
9598                            qPos.add(parentFolderId);
9599    
9600                            qPos.add(hidden);
9601    
9602                            qPos.add(status);
9603    
9604                            Long count = (Long)q.uniqueResult();
9605    
9606                            return count.intValue();
9607                    }
9608                    catch (Exception e) {
9609                            throw processException(e);
9610                    }
9611                    finally {
9612                            closeSession(session);
9613                    }
9614            }
9615    
9616            private static final String _FINDER_COLUMN_G_P_H_S_GROUPID_2 = "dlFolder.groupId = ? AND ";
9617            private static final String _FINDER_COLUMN_G_P_H_S_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
9618            private static final String _FINDER_COLUMN_G_P_H_S_HIDDEN_2 = "dlFolder.hidden = ? AND ";
9619            private static final String _FINDER_COLUMN_G_P_H_S_HIDDEN_2_SQL = "dlFolder.hidden_ = ? AND ";
9620            private static final String _FINDER_COLUMN_G_P_H_S_STATUS_2 = "dlFolder.status = ?";
9621            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H_S =
9622                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
9623                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
9624                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_M_P_H_S",
9625                            new String[] {
9626                                    Long.class.getName(), Boolean.class.getName(),
9627                                    Long.class.getName(), Boolean.class.getName(),
9628                                    Integer.class.getName(),
9629                                    
9630                            Integer.class.getName(), Integer.class.getName(),
9631                                    OrderByComparator.class.getName()
9632                            });
9633            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S =
9634                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
9635                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
9636                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_M_P_H_S",
9637                            new String[] {
9638                                    Long.class.getName(), Boolean.class.getName(),
9639                                    Long.class.getName(), Boolean.class.getName(),
9640                                    Integer.class.getName()
9641                            },
9642                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
9643                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK |
9644                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
9645                            DLFolderModelImpl.HIDDEN_COLUMN_BITMASK |
9646                            DLFolderModelImpl.STATUS_COLUMN_BITMASK |
9647                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
9648            public static final FinderPath FINDER_PATH_COUNT_BY_G_M_P_H_S = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
9649                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
9650                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_M_P_H_S",
9651                            new String[] {
9652                                    Long.class.getName(), Boolean.class.getName(),
9653                                    Long.class.getName(), Boolean.class.getName(),
9654                                    Integer.class.getName()
9655                            });
9656    
9657            /**
9658             * Returns all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
9659             *
9660             * @param groupId the group ID
9661             * @param mountPoint the mount point
9662             * @param parentFolderId the parent folder ID
9663             * @param hidden the hidden
9664             * @param status the status
9665             * @return the matching document library folders
9666             */
9667            @Override
9668            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
9669                    long parentFolderId, boolean hidden, int status) {
9670                    return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
9671                            status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9672            }
9673    
9674            /**
9675             * Returns a range of all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
9676             *
9677             * <p>
9678             * 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.
9679             * </p>
9680             *
9681             * @param groupId the group ID
9682             * @param mountPoint the mount point
9683             * @param parentFolderId the parent folder ID
9684             * @param hidden the hidden
9685             * @param status the status
9686             * @param start the lower bound of the range of document library folders
9687             * @param end the upper bound of the range of document library folders (not inclusive)
9688             * @return the range of matching document library folders
9689             */
9690            @Override
9691            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
9692                    long parentFolderId, boolean hidden, int status, int start, int end) {
9693                    return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
9694                            status, start, end, null);
9695            }
9696    
9697            /**
9698             * 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;.
9699             *
9700             * <p>
9701             * 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.
9702             * </p>
9703             *
9704             * @param groupId the group ID
9705             * @param mountPoint the mount point
9706             * @param parentFolderId the parent folder ID
9707             * @param hidden the hidden
9708             * @param status the status
9709             * @param start the lower bound of the range of document library folders
9710             * @param end the upper bound of the range of document library folders (not inclusive)
9711             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9712             * @return the ordered range of matching document library folders
9713             */
9714            @Override
9715            public List<DLFolder> findByG_M_P_H_S(long groupId, boolean mountPoint,
9716                    long parentFolderId, boolean hidden, int status, int start, int end,
9717                    OrderByComparator<DLFolder> orderByComparator) {
9718                    boolean pagination = true;
9719                    FinderPath finderPath = null;
9720                    Object[] finderArgs = null;
9721    
9722                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9723                                    (orderByComparator == null)) {
9724                            pagination = false;
9725                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S;
9726                            finderArgs = new Object[] {
9727                                            groupId, mountPoint, parentFolderId, hidden, status
9728                                    };
9729                    }
9730                    else {
9731                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_M_P_H_S;
9732                            finderArgs = new Object[] {
9733                                            groupId, mountPoint, parentFolderId, hidden, status,
9734                                            
9735                                            start, end, orderByComparator
9736                                    };
9737                    }
9738    
9739                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
9740                                    finderArgs, this);
9741    
9742                    if ((list != null) && !list.isEmpty()) {
9743                            for (DLFolder dlFolder : list) {
9744                                    if ((groupId != dlFolder.getGroupId()) ||
9745                                                    (mountPoint != dlFolder.getMountPoint()) ||
9746                                                    (parentFolderId != dlFolder.getParentFolderId()) ||
9747                                                    (hidden != dlFolder.getHidden()) ||
9748                                                    (status != dlFolder.getStatus())) {
9749                                            list = null;
9750    
9751                                            break;
9752                                    }
9753                            }
9754                    }
9755    
9756                    if (list == null) {
9757                            StringBundler query = null;
9758    
9759                            if (orderByComparator != null) {
9760                                    query = new StringBundler(7 +
9761                                                    (orderByComparator.getOrderByFields().length * 3));
9762                            }
9763                            else {
9764                                    query = new StringBundler(7);
9765                            }
9766    
9767                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
9768    
9769                            query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
9770    
9771                            query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
9772    
9773                            query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
9774    
9775                            query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
9776    
9777                            query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
9778    
9779                            if (orderByComparator != null) {
9780                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9781                                            orderByComparator);
9782                            }
9783                            else
9784                             if (pagination) {
9785                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
9786                            }
9787    
9788                            String sql = query.toString();
9789    
9790                            Session session = null;
9791    
9792                            try {
9793                                    session = openSession();
9794    
9795                                    Query q = session.createQuery(sql);
9796    
9797                                    QueryPos qPos = QueryPos.getInstance(q);
9798    
9799                                    qPos.add(groupId);
9800    
9801                                    qPos.add(mountPoint);
9802    
9803                                    qPos.add(parentFolderId);
9804    
9805                                    qPos.add(hidden);
9806    
9807                                    qPos.add(status);
9808    
9809                                    if (!pagination) {
9810                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
9811                                                            start, end, false);
9812    
9813                                            Collections.sort(list);
9814    
9815                                            list = Collections.unmodifiableList(list);
9816                                    }
9817                                    else {
9818                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
9819                                                            start, end);
9820                                    }
9821    
9822                                    cacheResult(list);
9823    
9824                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9825                            }
9826                            catch (Exception e) {
9827                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9828    
9829                                    throw processException(e);
9830                            }
9831                            finally {
9832                                    closeSession(session);
9833                            }
9834                    }
9835    
9836                    return list;
9837            }
9838    
9839            /**
9840             * 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;.
9841             *
9842             * @param groupId the group ID
9843             * @param mountPoint the mount point
9844             * @param parentFolderId the parent folder ID
9845             * @param hidden the hidden
9846             * @param status the status
9847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9848             * @return the first matching document library folder
9849             * @throws NoSuchFolderException if a matching document library folder could not be found
9850             */
9851            @Override
9852            public DLFolder findByG_M_P_H_S_First(long groupId, boolean mountPoint,
9853                    long parentFolderId, boolean hidden, int status,
9854                    OrderByComparator<DLFolder> orderByComparator)
9855                    throws NoSuchFolderException {
9856                    DLFolder dlFolder = fetchByG_M_P_H_S_First(groupId, mountPoint,
9857                                    parentFolderId, hidden, status, orderByComparator);
9858    
9859                    if (dlFolder != null) {
9860                            return dlFolder;
9861                    }
9862    
9863                    StringBundler msg = new StringBundler(12);
9864    
9865                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9866    
9867                    msg.append("groupId=");
9868                    msg.append(groupId);
9869    
9870                    msg.append(", mountPoint=");
9871                    msg.append(mountPoint);
9872    
9873                    msg.append(", parentFolderId=");
9874                    msg.append(parentFolderId);
9875    
9876                    msg.append(", hidden=");
9877                    msg.append(hidden);
9878    
9879                    msg.append(", status=");
9880                    msg.append(status);
9881    
9882                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9883    
9884                    throw new NoSuchFolderException(msg.toString());
9885            }
9886    
9887            /**
9888             * 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;.
9889             *
9890             * @param groupId the group ID
9891             * @param mountPoint the mount point
9892             * @param parentFolderId the parent folder ID
9893             * @param hidden the hidden
9894             * @param status the status
9895             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9896             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
9897             */
9898            @Override
9899            public DLFolder fetchByG_M_P_H_S_First(long groupId, boolean mountPoint,
9900                    long parentFolderId, boolean hidden, int status,
9901                    OrderByComparator<DLFolder> orderByComparator) {
9902                    List<DLFolder> list = findByG_M_P_H_S(groupId, mountPoint,
9903                                    parentFolderId, hidden, status, 0, 1, orderByComparator);
9904    
9905                    if (!list.isEmpty()) {
9906                            return list.get(0);
9907                    }
9908    
9909                    return null;
9910            }
9911    
9912            /**
9913             * 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;.
9914             *
9915             * @param groupId the group ID
9916             * @param mountPoint the mount point
9917             * @param parentFolderId the parent folder ID
9918             * @param hidden the hidden
9919             * @param status the status
9920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9921             * @return the last matching document library folder
9922             * @throws NoSuchFolderException if a matching document library folder could not be found
9923             */
9924            @Override
9925            public DLFolder findByG_M_P_H_S_Last(long groupId, boolean mountPoint,
9926                    long parentFolderId, boolean hidden, int status,
9927                    OrderByComparator<DLFolder> orderByComparator)
9928                    throws NoSuchFolderException {
9929                    DLFolder dlFolder = fetchByG_M_P_H_S_Last(groupId, mountPoint,
9930                                    parentFolderId, hidden, status, orderByComparator);
9931    
9932                    if (dlFolder != null) {
9933                            return dlFolder;
9934                    }
9935    
9936                    StringBundler msg = new StringBundler(12);
9937    
9938                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9939    
9940                    msg.append("groupId=");
9941                    msg.append(groupId);
9942    
9943                    msg.append(", mountPoint=");
9944                    msg.append(mountPoint);
9945    
9946                    msg.append(", parentFolderId=");
9947                    msg.append(parentFolderId);
9948    
9949                    msg.append(", hidden=");
9950                    msg.append(hidden);
9951    
9952                    msg.append(", status=");
9953                    msg.append(status);
9954    
9955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9956    
9957                    throw new NoSuchFolderException(msg.toString());
9958            }
9959    
9960            /**
9961             * 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;.
9962             *
9963             * @param groupId the group ID
9964             * @param mountPoint the mount point
9965             * @param parentFolderId the parent folder ID
9966             * @param hidden the hidden
9967             * @param status the status
9968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9969             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
9970             */
9971            @Override
9972            public DLFolder fetchByG_M_P_H_S_Last(long groupId, boolean mountPoint,
9973                    long parentFolderId, boolean hidden, int status,
9974                    OrderByComparator<DLFolder> orderByComparator) {
9975                    int count = countByG_M_P_H_S(groupId, mountPoint, parentFolderId,
9976                                    hidden, status);
9977    
9978                    if (count == 0) {
9979                            return null;
9980                    }
9981    
9982                    List<DLFolder> list = findByG_M_P_H_S(groupId, mountPoint,
9983                                    parentFolderId, hidden, status, count - 1, count,
9984                                    orderByComparator);
9985    
9986                    if (!list.isEmpty()) {
9987                            return list.get(0);
9988                    }
9989    
9990                    return null;
9991            }
9992    
9993            /**
9994             * 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;.
9995             *
9996             * @param folderId the primary key of the current document library folder
9997             * @param groupId the group ID
9998             * @param mountPoint the mount point
9999             * @param parentFolderId the parent folder ID
10000             * @param hidden the hidden
10001             * @param status the status
10002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10003             * @return the previous, current, and next document library folder
10004             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10005             */
10006            @Override
10007            public DLFolder[] findByG_M_P_H_S_PrevAndNext(long folderId, long groupId,
10008                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
10009                    OrderByComparator<DLFolder> orderByComparator)
10010                    throws NoSuchFolderException {
10011                    DLFolder dlFolder = findByPrimaryKey(folderId);
10012    
10013                    Session session = null;
10014    
10015                    try {
10016                            session = openSession();
10017    
10018                            DLFolder[] array = new DLFolderImpl[3];
10019    
10020                            array[0] = getByG_M_P_H_S_PrevAndNext(session, dlFolder, groupId,
10021                                            mountPoint, parentFolderId, hidden, status,
10022                                            orderByComparator, true);
10023    
10024                            array[1] = dlFolder;
10025    
10026                            array[2] = getByG_M_P_H_S_PrevAndNext(session, dlFolder, groupId,
10027                                            mountPoint, parentFolderId, hidden, status,
10028                                            orderByComparator, false);
10029    
10030                            return array;
10031                    }
10032                    catch (Exception e) {
10033                            throw processException(e);
10034                    }
10035                    finally {
10036                            closeSession(session);
10037                    }
10038            }
10039    
10040            protected DLFolder getByG_M_P_H_S_PrevAndNext(Session session,
10041                    DLFolder dlFolder, long groupId, boolean mountPoint,
10042                    long parentFolderId, boolean hidden, int status,
10043                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
10044                    StringBundler query = null;
10045    
10046                    if (orderByComparator != null) {
10047                            query = new StringBundler(6 +
10048                                            (orderByComparator.getOrderByFields().length * 6));
10049                    }
10050                    else {
10051                            query = new StringBundler(3);
10052                    }
10053    
10054                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
10055    
10056                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
10057    
10058                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
10059    
10060                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
10061    
10062                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
10063    
10064                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
10065    
10066                    if (orderByComparator != null) {
10067                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10068    
10069                            if (orderByConditionFields.length > 0) {
10070                                    query.append(WHERE_AND);
10071                            }
10072    
10073                            for (int i = 0; i < orderByConditionFields.length; i++) {
10074                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10075                                    query.append(orderByConditionFields[i]);
10076    
10077                                    if ((i + 1) < orderByConditionFields.length) {
10078                                            if (orderByComparator.isAscending() ^ previous) {
10079                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10080                                            }
10081                                            else {
10082                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10083                                            }
10084                                    }
10085                                    else {
10086                                            if (orderByComparator.isAscending() ^ previous) {
10087                                                    query.append(WHERE_GREATER_THAN);
10088                                            }
10089                                            else {
10090                                                    query.append(WHERE_LESSER_THAN);
10091                                            }
10092                                    }
10093                            }
10094    
10095                            query.append(ORDER_BY_CLAUSE);
10096    
10097                            String[] orderByFields = orderByComparator.getOrderByFields();
10098    
10099                            for (int i = 0; i < orderByFields.length; i++) {
10100                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10101                                    query.append(orderByFields[i]);
10102    
10103                                    if ((i + 1) < orderByFields.length) {
10104                                            if (orderByComparator.isAscending() ^ previous) {
10105                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10106                                            }
10107                                            else {
10108                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10109                                            }
10110                                    }
10111                                    else {
10112                                            if (orderByComparator.isAscending() ^ previous) {
10113                                                    query.append(ORDER_BY_ASC);
10114                                            }
10115                                            else {
10116                                                    query.append(ORDER_BY_DESC);
10117                                            }
10118                                    }
10119                            }
10120                    }
10121                    else {
10122                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10123                    }
10124    
10125                    String sql = query.toString();
10126    
10127                    Query q = session.createQuery(sql);
10128    
10129                    q.setFirstResult(0);
10130                    q.setMaxResults(2);
10131    
10132                    QueryPos qPos = QueryPos.getInstance(q);
10133    
10134                    qPos.add(groupId);
10135    
10136                    qPos.add(mountPoint);
10137    
10138                    qPos.add(parentFolderId);
10139    
10140                    qPos.add(hidden);
10141    
10142                    qPos.add(status);
10143    
10144                    if (orderByComparator != null) {
10145                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
10146    
10147                            for (Object value : values) {
10148                                    qPos.add(value);
10149                            }
10150                    }
10151    
10152                    List<DLFolder> list = q.list();
10153    
10154                    if (list.size() == 2) {
10155                            return list.get(1);
10156                    }
10157                    else {
10158                            return null;
10159                    }
10160            }
10161    
10162            /**
10163             * 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;.
10164             *
10165             * @param groupId the group ID
10166             * @param mountPoint the mount point
10167             * @param parentFolderId the parent folder ID
10168             * @param hidden the hidden
10169             * @param status the status
10170             * @return the matching document library folders that the user has permission to view
10171             */
10172            @Override
10173            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
10174                    boolean mountPoint, long parentFolderId, boolean hidden, int status) {
10175                    return filterFindByG_M_P_H_S(groupId, mountPoint, parentFolderId,
10176                            hidden, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10177            }
10178    
10179            /**
10180             * 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;.
10181             *
10182             * <p>
10183             * 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.
10184             * </p>
10185             *
10186             * @param groupId the group ID
10187             * @param mountPoint the mount point
10188             * @param parentFolderId the parent folder ID
10189             * @param hidden the hidden
10190             * @param status the status
10191             * @param start the lower bound of the range of document library folders
10192             * @param end the upper bound of the range of document library folders (not inclusive)
10193             * @return the range of matching document library folders that the user has permission to view
10194             */
10195            @Override
10196            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
10197                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
10198                    int start, int end) {
10199                    return filterFindByG_M_P_H_S(groupId, mountPoint, parentFolderId,
10200                            hidden, status, start, end, null);
10201            }
10202    
10203            /**
10204             * 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;.
10205             *
10206             * <p>
10207             * 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.
10208             * </p>
10209             *
10210             * @param groupId the group ID
10211             * @param mountPoint the mount point
10212             * @param parentFolderId the parent folder ID
10213             * @param hidden the hidden
10214             * @param status the status
10215             * @param start the lower bound of the range of document library folders
10216             * @param end the upper bound of the range of document library folders (not inclusive)
10217             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10218             * @return the ordered range of matching document library folders that the user has permission to view
10219             */
10220            @Override
10221            public List<DLFolder> filterFindByG_M_P_H_S(long groupId,
10222                    boolean mountPoint, long parentFolderId, boolean hidden, int status,
10223                    int start, int end, OrderByComparator<DLFolder> orderByComparator) {
10224                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10225                            return findByG_M_P_H_S(groupId, mountPoint, parentFolderId, hidden,
10226                                    status, start, end, orderByComparator);
10227                    }
10228    
10229                    StringBundler query = null;
10230    
10231                    if (orderByComparator != null) {
10232                            query = new StringBundler(7 +
10233                                            (orderByComparator.getOrderByFields().length * 3));
10234                    }
10235                    else {
10236                            query = new StringBundler(7);
10237                    }
10238    
10239                    if (getDB().isSupportsInlineDistinct()) {
10240                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
10241                    }
10242                    else {
10243                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
10244                    }
10245    
10246                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
10247    
10248                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
10249    
10250                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
10251    
10252                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
10253    
10254                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
10255    
10256                    if (!getDB().isSupportsInlineDistinct()) {
10257                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
10258                    }
10259    
10260                    if (orderByComparator != null) {
10261                            if (getDB().isSupportsInlineDistinct()) {
10262                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10263                                            orderByComparator, true);
10264                            }
10265                            else {
10266                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10267                                            orderByComparator, true);
10268                            }
10269                    }
10270                    else {
10271                            if (getDB().isSupportsInlineDistinct()) {
10272                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10273                            }
10274                            else {
10275                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
10276                            }
10277                    }
10278    
10279                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10280                                    DLFolder.class.getName(),
10281                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10282    
10283                    Session session = null;
10284    
10285                    try {
10286                            session = openSession();
10287    
10288                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10289    
10290                            if (getDB().isSupportsInlineDistinct()) {
10291                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
10292                            }
10293                            else {
10294                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
10295                            }
10296    
10297                            QueryPos qPos = QueryPos.getInstance(q);
10298    
10299                            qPos.add(groupId);
10300    
10301                            qPos.add(mountPoint);
10302    
10303                            qPos.add(parentFolderId);
10304    
10305                            qPos.add(hidden);
10306    
10307                            qPos.add(status);
10308    
10309                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
10310                    }
10311                    catch (Exception e) {
10312                            throw processException(e);
10313                    }
10314                    finally {
10315                            closeSession(session);
10316                    }
10317            }
10318    
10319            /**
10320             * 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;.
10321             *
10322             * @param folderId the primary key of the current document library folder
10323             * @param groupId the group ID
10324             * @param mountPoint the mount point
10325             * @param parentFolderId the parent folder ID
10326             * @param hidden the hidden
10327             * @param status the status
10328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10329             * @return the previous, current, and next document library folder
10330             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10331             */
10332            @Override
10333            public DLFolder[] filterFindByG_M_P_H_S_PrevAndNext(long folderId,
10334                    long groupId, boolean mountPoint, long parentFolderId, boolean hidden,
10335                    int status, OrderByComparator<DLFolder> orderByComparator)
10336                    throws NoSuchFolderException {
10337                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10338                            return findByG_M_P_H_S_PrevAndNext(folderId, groupId, mountPoint,
10339                                    parentFolderId, hidden, status, orderByComparator);
10340                    }
10341    
10342                    DLFolder dlFolder = findByPrimaryKey(folderId);
10343    
10344                    Session session = null;
10345    
10346                    try {
10347                            session = openSession();
10348    
10349                            DLFolder[] array = new DLFolderImpl[3];
10350    
10351                            array[0] = filterGetByG_M_P_H_S_PrevAndNext(session, dlFolder,
10352                                            groupId, mountPoint, parentFolderId, hidden, status,
10353                                            orderByComparator, true);
10354    
10355                            array[1] = dlFolder;
10356    
10357                            array[2] = filterGetByG_M_P_H_S_PrevAndNext(session, dlFolder,
10358                                            groupId, mountPoint, parentFolderId, hidden, status,
10359                                            orderByComparator, false);
10360    
10361                            return array;
10362                    }
10363                    catch (Exception e) {
10364                            throw processException(e);
10365                    }
10366                    finally {
10367                            closeSession(session);
10368                    }
10369            }
10370    
10371            protected DLFolder filterGetByG_M_P_H_S_PrevAndNext(Session session,
10372                    DLFolder dlFolder, long groupId, boolean mountPoint,
10373                    long parentFolderId, boolean hidden, int status,
10374                    OrderByComparator<DLFolder> orderByComparator, boolean previous) {
10375                    StringBundler query = null;
10376    
10377                    if (orderByComparator != null) {
10378                            query = new StringBundler(6 +
10379                                            (orderByComparator.getOrderByFields().length * 6));
10380                    }
10381                    else {
10382                            query = new StringBundler(3);
10383                    }
10384    
10385                    if (getDB().isSupportsInlineDistinct()) {
10386                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
10387                    }
10388                    else {
10389                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
10390                    }
10391    
10392                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
10393    
10394                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
10395    
10396                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
10397    
10398                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
10399    
10400                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
10401    
10402                    if (!getDB().isSupportsInlineDistinct()) {
10403                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
10404                    }
10405    
10406                    if (orderByComparator != null) {
10407                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10408    
10409                            if (orderByConditionFields.length > 0) {
10410                                    query.append(WHERE_AND);
10411                            }
10412    
10413                            for (int i = 0; i < orderByConditionFields.length; i++) {
10414                                    if (getDB().isSupportsInlineDistinct()) {
10415                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10416                                    }
10417                                    else {
10418                                            query.append(_ORDER_BY_ENTITY_TABLE);
10419                                    }
10420    
10421                                    query.append(orderByConditionFields[i]);
10422    
10423                                    if ((i + 1) < orderByConditionFields.length) {
10424                                            if (orderByComparator.isAscending() ^ previous) {
10425                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10426                                            }
10427                                            else {
10428                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10429                                            }
10430                                    }
10431                                    else {
10432                                            if (orderByComparator.isAscending() ^ previous) {
10433                                                    query.append(WHERE_GREATER_THAN);
10434                                            }
10435                                            else {
10436                                                    query.append(WHERE_LESSER_THAN);
10437                                            }
10438                                    }
10439                            }
10440    
10441                            query.append(ORDER_BY_CLAUSE);
10442    
10443                            String[] orderByFields = orderByComparator.getOrderByFields();
10444    
10445                            for (int i = 0; i < orderByFields.length; i++) {
10446                                    if (getDB().isSupportsInlineDistinct()) {
10447                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10448                                    }
10449                                    else {
10450                                            query.append(_ORDER_BY_ENTITY_TABLE);
10451                                    }
10452    
10453                                    query.append(orderByFields[i]);
10454    
10455                                    if ((i + 1) < orderByFields.length) {
10456                                            if (orderByComparator.isAscending() ^ previous) {
10457                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10458                                            }
10459                                            else {
10460                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10461                                            }
10462                                    }
10463                                    else {
10464                                            if (orderByComparator.isAscending() ^ previous) {
10465                                                    query.append(ORDER_BY_ASC);
10466                                            }
10467                                            else {
10468                                                    query.append(ORDER_BY_DESC);
10469                                            }
10470                                    }
10471                            }
10472                    }
10473                    else {
10474                            if (getDB().isSupportsInlineDistinct()) {
10475                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
10476                            }
10477                            else {
10478                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
10479                            }
10480                    }
10481    
10482                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10483                                    DLFolder.class.getName(),
10484                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10485    
10486                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10487    
10488                    q.setFirstResult(0);
10489                    q.setMaxResults(2);
10490    
10491                    if (getDB().isSupportsInlineDistinct()) {
10492                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
10493                    }
10494                    else {
10495                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
10496                    }
10497    
10498                    QueryPos qPos = QueryPos.getInstance(q);
10499    
10500                    qPos.add(groupId);
10501    
10502                    qPos.add(mountPoint);
10503    
10504                    qPos.add(parentFolderId);
10505    
10506                    qPos.add(hidden);
10507    
10508                    qPos.add(status);
10509    
10510                    if (orderByComparator != null) {
10511                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
10512    
10513                            for (Object value : values) {
10514                                    qPos.add(value);
10515                            }
10516                    }
10517    
10518                    List<DLFolder> list = q.list();
10519    
10520                    if (list.size() == 2) {
10521                            return list.get(1);
10522                    }
10523                    else {
10524                            return null;
10525                    }
10526            }
10527    
10528            /**
10529             * Removes all the document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63; from the database.
10530             *
10531             * @param groupId the group ID
10532             * @param mountPoint the mount point
10533             * @param parentFolderId the parent folder ID
10534             * @param hidden the hidden
10535             * @param status the status
10536             */
10537            @Override
10538            public void removeByG_M_P_H_S(long groupId, boolean mountPoint,
10539                    long parentFolderId, boolean hidden, int status) {
10540                    for (DLFolder dlFolder : findByG_M_P_H_S(groupId, mountPoint,
10541                                    parentFolderId, hidden, status, QueryUtil.ALL_POS,
10542                                    QueryUtil.ALL_POS, null)) {
10543                            remove(dlFolder);
10544                    }
10545            }
10546    
10547            /**
10548             * Returns the number of document library folders where groupId = &#63; and mountPoint = &#63; and parentFolderId = &#63; and hidden = &#63; and status = &#63;.
10549             *
10550             * @param groupId the group ID
10551             * @param mountPoint the mount point
10552             * @param parentFolderId the parent folder ID
10553             * @param hidden the hidden
10554             * @param status the status
10555             * @return the number of matching document library folders
10556             */
10557            @Override
10558            public int countByG_M_P_H_S(long groupId, boolean mountPoint,
10559                    long parentFolderId, boolean hidden, int status) {
10560                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_M_P_H_S;
10561    
10562                    Object[] finderArgs = new Object[] {
10563                                    groupId, mountPoint, parentFolderId, hidden, status
10564                            };
10565    
10566                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10567                                    this);
10568    
10569                    if (count == null) {
10570                            StringBundler query = new StringBundler(6);
10571    
10572                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
10573    
10574                            query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
10575    
10576                            query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
10577    
10578                            query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
10579    
10580                            query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2);
10581    
10582                            query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
10583    
10584                            String sql = query.toString();
10585    
10586                            Session session = null;
10587    
10588                            try {
10589                                    session = openSession();
10590    
10591                                    Query q = session.createQuery(sql);
10592    
10593                                    QueryPos qPos = QueryPos.getInstance(q);
10594    
10595                                    qPos.add(groupId);
10596    
10597                                    qPos.add(mountPoint);
10598    
10599                                    qPos.add(parentFolderId);
10600    
10601                                    qPos.add(hidden);
10602    
10603                                    qPos.add(status);
10604    
10605                                    count = (Long)q.uniqueResult();
10606    
10607                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10608                            }
10609                            catch (Exception e) {
10610                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10611    
10612                                    throw processException(e);
10613                            }
10614                            finally {
10615                                    closeSession(session);
10616                            }
10617                    }
10618    
10619                    return count.intValue();
10620            }
10621    
10622            /**
10623             * 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;.
10624             *
10625             * @param groupId the group ID
10626             * @param mountPoint the mount point
10627             * @param parentFolderId the parent folder ID
10628             * @param hidden the hidden
10629             * @param status the status
10630             * @return the number of matching document library folders that the user has permission to view
10631             */
10632            @Override
10633            public int filterCountByG_M_P_H_S(long groupId, boolean mountPoint,
10634                    long parentFolderId, boolean hidden, int status) {
10635                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10636                            return countByG_M_P_H_S(groupId, mountPoint, parentFolderId,
10637                                    hidden, status);
10638                    }
10639    
10640                    StringBundler query = new StringBundler(6);
10641    
10642                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
10643    
10644                    query.append(_FINDER_COLUMN_G_M_P_H_S_GROUPID_2);
10645    
10646                    query.append(_FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2);
10647    
10648                    query.append(_FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2);
10649    
10650                    query.append(_FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL);
10651    
10652                    query.append(_FINDER_COLUMN_G_M_P_H_S_STATUS_2);
10653    
10654                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10655                                    DLFolder.class.getName(),
10656                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10657    
10658                    Session session = null;
10659    
10660                    try {
10661                            session = openSession();
10662    
10663                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10664    
10665                            q.addScalar(COUNT_COLUMN_NAME,
10666                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10667    
10668                            QueryPos qPos = QueryPos.getInstance(q);
10669    
10670                            qPos.add(groupId);
10671    
10672                            qPos.add(mountPoint);
10673    
10674                            qPos.add(parentFolderId);
10675    
10676                            qPos.add(hidden);
10677    
10678                            qPos.add(status);
10679    
10680                            Long count = (Long)q.uniqueResult();
10681    
10682                            return count.intValue();
10683                    }
10684                    catch (Exception e) {
10685                            throw processException(e);
10686                    }
10687                    finally {
10688                            closeSession(session);
10689                    }
10690            }
10691    
10692            private static final String _FINDER_COLUMN_G_M_P_H_S_GROUPID_2 = "dlFolder.groupId = ? AND ";
10693            private static final String _FINDER_COLUMN_G_M_P_H_S_MOUNTPOINT_2 = "dlFolder.mountPoint = ? AND ";
10694            private static final String _FINDER_COLUMN_G_M_P_H_S_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
10695            private static final String _FINDER_COLUMN_G_M_P_H_S_HIDDEN_2 = "dlFolder.hidden = ? AND ";
10696            private static final String _FINDER_COLUMN_G_M_P_H_S_HIDDEN_2_SQL = "dlFolder.hidden_ = ? AND ";
10697            private static final String _FINDER_COLUMN_G_M_P_H_S_STATUS_2 = "dlFolder.status = ?";
10698    
10699            public DLFolderPersistenceImpl() {
10700                    setModelClass(DLFolder.class);
10701            }
10702    
10703            /**
10704             * Caches the document library folder in the entity cache if it is enabled.
10705             *
10706             * @param dlFolder the document library folder
10707             */
10708            @Override
10709            public void cacheResult(DLFolder dlFolder) {
10710                    EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10711                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
10712    
10713                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10714                            new Object[] { dlFolder.getUuid(), dlFolder.getGroupId() }, dlFolder);
10715    
10716                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
10717                            new Object[] { dlFolder.getRepositoryId(), dlFolder.getMountPoint() },
10718                            dlFolder);
10719    
10720                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
10721                            new Object[] {
10722                                    dlFolder.getGroupId(), dlFolder.getParentFolderId(),
10723                                    dlFolder.getName()
10724                            }, dlFolder);
10725    
10726                    dlFolder.resetOriginalValues();
10727            }
10728    
10729            /**
10730             * Caches the document library folders in the entity cache if it is enabled.
10731             *
10732             * @param dlFolders the document library folders
10733             */
10734            @Override
10735            public void cacheResult(List<DLFolder> dlFolders) {
10736                    for (DLFolder dlFolder : dlFolders) {
10737                            if (EntityCacheUtil.getResult(
10738                                                    DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10739                                                    DLFolderImpl.class, dlFolder.getPrimaryKey()) == null) {
10740                                    cacheResult(dlFolder);
10741                            }
10742                            else {
10743                                    dlFolder.resetOriginalValues();
10744                            }
10745                    }
10746            }
10747    
10748            /**
10749             * Clears the cache for all document library folders.
10750             *
10751             * <p>
10752             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10753             * </p>
10754             */
10755            @Override
10756            public void clearCache() {
10757                    EntityCacheUtil.clearCache(DLFolderImpl.class);
10758    
10759                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10760                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10761                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10762            }
10763    
10764            /**
10765             * Clears the cache for the document library folder.
10766             *
10767             * <p>
10768             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10769             * </p>
10770             */
10771            @Override
10772            public void clearCache(DLFolder dlFolder) {
10773                    EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10774                            DLFolderImpl.class, dlFolder.getPrimaryKey());
10775    
10776                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10777                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10778    
10779                    clearUniqueFindersCache(dlFolder);
10780            }
10781    
10782            @Override
10783            public void clearCache(List<DLFolder> dlFolders) {
10784                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10785                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10786    
10787                    for (DLFolder dlFolder : dlFolders) {
10788                            EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
10789                                    DLFolderImpl.class, dlFolder.getPrimaryKey());
10790    
10791                            clearUniqueFindersCache(dlFolder);
10792                    }
10793            }
10794    
10795            protected void cacheUniqueFindersCache(DLFolder dlFolder) {
10796                    if (dlFolder.isNew()) {
10797                            Object[] args = new Object[] {
10798                                            dlFolder.getUuid(), dlFolder.getGroupId()
10799                                    };
10800    
10801                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10802                                    Long.valueOf(1));
10803                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10804                                    dlFolder);
10805    
10806                            args = new Object[] {
10807                                            dlFolder.getRepositoryId(), dlFolder.getMountPoint()
10808                                    };
10809    
10810                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
10811                                    Long.valueOf(1));
10812                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args, dlFolder);
10813    
10814                            args = new Object[] {
10815                                            dlFolder.getGroupId(), dlFolder.getParentFolderId(),
10816                                            dlFolder.getName()
10817                                    };
10818    
10819                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
10820                                    Long.valueOf(1));
10821                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args, dlFolder);
10822                    }
10823                    else {
10824                            DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
10825    
10826                            if ((dlFolderModelImpl.getColumnBitmask() &
10827                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10828                                    Object[] args = new Object[] {
10829                                                    dlFolder.getUuid(), dlFolder.getGroupId()
10830                                            };
10831    
10832                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10833                                            Long.valueOf(1));
10834                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10835                                            dlFolder);
10836                            }
10837    
10838                            if ((dlFolderModelImpl.getColumnBitmask() &
10839                                            FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
10840                                    Object[] args = new Object[] {
10841                                                    dlFolder.getRepositoryId(), dlFolder.getMountPoint()
10842                                            };
10843    
10844                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
10845                                            Long.valueOf(1));
10846                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args,
10847                                            dlFolder);
10848                            }
10849    
10850                            if ((dlFolderModelImpl.getColumnBitmask() &
10851                                            FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
10852                                    Object[] args = new Object[] {
10853                                                    dlFolder.getGroupId(), dlFolder.getParentFolderId(),
10854                                                    dlFolder.getName()
10855                                            };
10856    
10857                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
10858                                            Long.valueOf(1));
10859                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
10860                                            dlFolder);
10861                            }
10862                    }
10863            }
10864    
10865            protected void clearUniqueFindersCache(DLFolder dlFolder) {
10866                    DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
10867    
10868                    Object[] args = new Object[] { dlFolder.getUuid(), dlFolder.getGroupId() };
10869    
10870                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10871                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10872    
10873                    if ((dlFolderModelImpl.getColumnBitmask() &
10874                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10875                            args = new Object[] {
10876                                            dlFolderModelImpl.getOriginalUuid(),
10877                                            dlFolderModelImpl.getOriginalGroupId()
10878                                    };
10879    
10880                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10881                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10882                    }
10883    
10884                    args = new Object[] { dlFolder.getRepositoryId(), dlFolder.getMountPoint() };
10885    
10886                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
10887                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
10888    
10889                    if ((dlFolderModelImpl.getColumnBitmask() &
10890                                    FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
10891                            args = new Object[] {
10892                                            dlFolderModelImpl.getOriginalRepositoryId(),
10893                                            dlFolderModelImpl.getOriginalMountPoint()
10894                                    };
10895    
10896                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
10897                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
10898                    }
10899    
10900                    args = new Object[] {
10901                                    dlFolder.getGroupId(), dlFolder.getParentFolderId(),
10902                                    dlFolder.getName()
10903                            };
10904    
10905                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
10906                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
10907    
10908                    if ((dlFolderModelImpl.getColumnBitmask() &
10909                                    FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
10910                            args = new Object[] {
10911                                            dlFolderModelImpl.getOriginalGroupId(),
10912                                            dlFolderModelImpl.getOriginalParentFolderId(),
10913                                            dlFolderModelImpl.getOriginalName()
10914                                    };
10915    
10916                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
10917                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
10918                    }
10919            }
10920    
10921            /**
10922             * Creates a new document library folder with the primary key. Does not add the document library folder to the database.
10923             *
10924             * @param folderId the primary key for the new document library folder
10925             * @return the new document library folder
10926             */
10927            @Override
10928            public DLFolder create(long folderId) {
10929                    DLFolder dlFolder = new DLFolderImpl();
10930    
10931                    dlFolder.setNew(true);
10932                    dlFolder.setPrimaryKey(folderId);
10933    
10934                    String uuid = PortalUUIDUtil.generate();
10935    
10936                    dlFolder.setUuid(uuid);
10937    
10938                    return dlFolder;
10939            }
10940    
10941            /**
10942             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
10943             *
10944             * @param folderId the primary key of the document library folder
10945             * @return the document library folder that was removed
10946             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10947             */
10948            @Override
10949            public DLFolder remove(long folderId) throws NoSuchFolderException {
10950                    return remove((Serializable)folderId);
10951            }
10952    
10953            /**
10954             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
10955             *
10956             * @param primaryKey the primary key of the document library folder
10957             * @return the document library folder that was removed
10958             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
10959             */
10960            @Override
10961            public DLFolder remove(Serializable primaryKey)
10962                    throws NoSuchFolderException {
10963                    Session session = null;
10964    
10965                    try {
10966                            session = openSession();
10967    
10968                            DLFolder dlFolder = (DLFolder)session.get(DLFolderImpl.class,
10969                                            primaryKey);
10970    
10971                            if (dlFolder == null) {
10972                                    if (_log.isWarnEnabled()) {
10973                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10974                                    }
10975    
10976                                    throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10977                                            primaryKey);
10978                            }
10979    
10980                            return remove(dlFolder);
10981                    }
10982                    catch (NoSuchFolderException nsee) {
10983                            throw nsee;
10984                    }
10985                    catch (Exception e) {
10986                            throw processException(e);
10987                    }
10988                    finally {
10989                            closeSession(session);
10990                    }
10991            }
10992    
10993            @Override
10994            protected DLFolder removeImpl(DLFolder dlFolder) {
10995                    dlFolder = toUnwrappedModel(dlFolder);
10996    
10997                    dlFolderToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(dlFolder.getPrimaryKey());
10998    
10999                    Session session = null;
11000    
11001                    try {
11002                            session = openSession();
11003    
11004                            if (!session.contains(dlFolder)) {
11005                                    dlFolder = (DLFolder)session.get(DLFolderImpl.class,
11006                                                    dlFolder.getPrimaryKeyObj());
11007                            }
11008    
11009                            if (dlFolder != null) {
11010                                    session.delete(dlFolder);
11011                            }
11012                    }
11013                    catch (Exception e) {
11014                            throw processException(e);
11015                    }
11016                    finally {
11017                            closeSession(session);
11018                    }
11019    
11020                    if (dlFolder != null) {
11021                            clearCache(dlFolder);
11022                    }
11023    
11024                    return dlFolder;
11025            }
11026    
11027            @Override
11028            public DLFolder updateImpl(DLFolder dlFolder) {
11029                    dlFolder = toUnwrappedModel(dlFolder);
11030    
11031                    boolean isNew = dlFolder.isNew();
11032    
11033                    DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
11034    
11035                    if (Validator.isNull(dlFolder.getUuid())) {
11036                            String uuid = PortalUUIDUtil.generate();
11037    
11038                            dlFolder.setUuid(uuid);
11039                    }
11040    
11041                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
11042    
11043                    Date now = new Date();
11044    
11045                    if (isNew && (dlFolder.getCreateDate() == null)) {
11046                            if (serviceContext == null) {
11047                                    dlFolder.setCreateDate(now);
11048                            }
11049                            else {
11050                                    dlFolder.setCreateDate(serviceContext.getCreateDate(now));
11051                            }
11052                    }
11053    
11054                    if (!dlFolderModelImpl.hasSetModifiedDate()) {
11055                            if (serviceContext == null) {
11056                                    dlFolder.setModifiedDate(now);
11057                            }
11058                            else {
11059                                    dlFolder.setModifiedDate(serviceContext.getModifiedDate(now));
11060                            }
11061                    }
11062    
11063                    Session session = null;
11064    
11065                    try {
11066                            session = openSession();
11067    
11068                            if (dlFolder.isNew()) {
11069                                    session.save(dlFolder);
11070    
11071                                    dlFolder.setNew(false);
11072                            }
11073                            else {
11074                                    session.merge(dlFolder);
11075                            }
11076                    }
11077                    catch (Exception e) {
11078                            throw processException(e);
11079                    }
11080                    finally {
11081                            closeSession(session);
11082                    }
11083    
11084                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11085    
11086                    if (isNew || !DLFolderModelImpl.COLUMN_BITMASK_ENABLED) {
11087                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11088                    }
11089    
11090                    else {
11091                            if ((dlFolderModelImpl.getColumnBitmask() &
11092                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
11093                                    Object[] args = new Object[] { dlFolderModelImpl.getOriginalUuid() };
11094    
11095                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11096                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11097                                            args);
11098    
11099                                    args = new Object[] { dlFolderModelImpl.getUuid() };
11100    
11101                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11102                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11103                                            args);
11104                            }
11105    
11106                            if ((dlFolderModelImpl.getColumnBitmask() &
11107                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
11108                                    Object[] args = new Object[] {
11109                                                    dlFolderModelImpl.getOriginalUuid(),
11110                                                    dlFolderModelImpl.getOriginalCompanyId()
11111                                            };
11112    
11113                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11114                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11115                                            args);
11116    
11117                                    args = new Object[] {
11118                                                    dlFolderModelImpl.getUuid(),
11119                                                    dlFolderModelImpl.getCompanyId()
11120                                            };
11121    
11122                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11123                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11124                                            args);
11125                            }
11126    
11127                            if ((dlFolderModelImpl.getColumnBitmask() &
11128                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
11129                                    Object[] args = new Object[] {
11130                                                    dlFolderModelImpl.getOriginalGroupId()
11131                                            };
11132    
11133                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11134                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11135                                            args);
11136    
11137                                    args = new Object[] { dlFolderModelImpl.getGroupId() };
11138    
11139                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11140                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11141                                            args);
11142                            }
11143    
11144                            if ((dlFolderModelImpl.getColumnBitmask() &
11145                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
11146                                    Object[] args = new Object[] {
11147                                                    dlFolderModelImpl.getOriginalCompanyId()
11148                                            };
11149    
11150                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
11151                                            args);
11152                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
11153                                            args);
11154    
11155                                    args = new Object[] { dlFolderModelImpl.getCompanyId() };
11156    
11157                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
11158                                            args);
11159                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
11160                                            args);
11161                            }
11162    
11163                            if ((dlFolderModelImpl.getColumnBitmask() &
11164                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
11165                                    Object[] args = new Object[] {
11166                                                    dlFolderModelImpl.getOriginalRepositoryId()
11167                                            };
11168    
11169                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
11170                                            args);
11171                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
11172                                            args);
11173    
11174                                    args = new Object[] { dlFolderModelImpl.getRepositoryId() };
11175    
11176                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
11177                                            args);
11178                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
11179                                            args);
11180                            }
11181    
11182                            if ((dlFolderModelImpl.getColumnBitmask() &
11183                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
11184                                    Object[] args = new Object[] {
11185                                                    dlFolderModelImpl.getOriginalGroupId(),
11186                                                    dlFolderModelImpl.getOriginalParentFolderId()
11187                                            };
11188    
11189                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
11190                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
11191                                            args);
11192    
11193                                    args = new Object[] {
11194                                                    dlFolderModelImpl.getGroupId(),
11195                                                    dlFolderModelImpl.getParentFolderId()
11196                                            };
11197    
11198                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
11199                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
11200                                            args);
11201                            }
11202    
11203                            if ((dlFolderModelImpl.getColumnBitmask() &
11204                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P.getColumnBitmask()) != 0) {
11205                                    Object[] args = new Object[] {
11206                                                    dlFolderModelImpl.getOriginalRepositoryId(),
11207                                                    dlFolderModelImpl.getOriginalParentFolderId()
11208                                            };
11209    
11210                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_P, args);
11211                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P,
11212                                            args);
11213    
11214                                    args = new Object[] {
11215                                                    dlFolderModelImpl.getRepositoryId(),
11216                                                    dlFolderModelImpl.getParentFolderId()
11217                                            };
11218    
11219                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_P, args);
11220                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_P,
11221                                            args);
11222                            }
11223    
11224                            if ((dlFolderModelImpl.getColumnBitmask() &
11225                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
11226                                    Object[] args = new Object[] {
11227                                                    dlFolderModelImpl.getOriginalParentFolderId(),
11228                                                    dlFolderModelImpl.getOriginalName()
11229                                            };
11230    
11231                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11232                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11233                                            args);
11234    
11235                                    args = new Object[] {
11236                                                    dlFolderModelImpl.getParentFolderId(),
11237                                                    dlFolderModelImpl.getName()
11238                                            };
11239    
11240                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11241                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11242                                            args);
11243                            }
11244    
11245                            if ((dlFolderModelImpl.getColumnBitmask() &
11246                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P.getColumnBitmask()) != 0) {
11247                                    Object[] args = new Object[] {
11248                                                    dlFolderModelImpl.getOriginalGroupId(),
11249                                                    dlFolderModelImpl.getOriginalMountPoint(),
11250                                                    dlFolderModelImpl.getOriginalParentFolderId()
11251                                            };
11252    
11253                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P, args);
11254                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P,
11255                                            args);
11256    
11257                                    args = new Object[] {
11258                                                    dlFolderModelImpl.getGroupId(),
11259                                                    dlFolderModelImpl.getMountPoint(),
11260                                                    dlFolderModelImpl.getParentFolderId()
11261                                            };
11262    
11263                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P, args);
11264                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P,
11265                                            args);
11266                            }
11267    
11268                            if ((dlFolderModelImpl.getColumnBitmask() &
11269                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H.getColumnBitmask()) != 0) {
11270                                    Object[] args = new Object[] {
11271                                                    dlFolderModelImpl.getOriginalGroupId(),
11272                                                    dlFolderModelImpl.getOriginalMountPoint(),
11273                                                    dlFolderModelImpl.getOriginalParentFolderId(),
11274                                                    dlFolderModelImpl.getOriginalHidden()
11275                                            };
11276    
11277                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H, args);
11278                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H,
11279                                            args);
11280    
11281                                    args = new Object[] {
11282                                                    dlFolderModelImpl.getGroupId(),
11283                                                    dlFolderModelImpl.getMountPoint(),
11284                                                    dlFolderModelImpl.getParentFolderId(),
11285                                                    dlFolderModelImpl.getHidden()
11286                                            };
11287    
11288                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H, args);
11289                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H,
11290                                            args);
11291                            }
11292    
11293                            if ((dlFolderModelImpl.getColumnBitmask() &
11294                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S.getColumnBitmask()) != 0) {
11295                                    Object[] args = new Object[] {
11296                                                    dlFolderModelImpl.getOriginalGroupId(),
11297                                                    dlFolderModelImpl.getOriginalParentFolderId(),
11298                                                    dlFolderModelImpl.getOriginalHidden(),
11299                                                    dlFolderModelImpl.getOriginalStatus()
11300                                            };
11301    
11302                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_H_S, args);
11303                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S,
11304                                            args);
11305    
11306                                    args = new Object[] {
11307                                                    dlFolderModelImpl.getGroupId(),
11308                                                    dlFolderModelImpl.getParentFolderId(),
11309                                                    dlFolderModelImpl.getHidden(),
11310                                                    dlFolderModelImpl.getStatus()
11311                                            };
11312    
11313                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_H_S, args);
11314                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_H_S,
11315                                            args);
11316                            }
11317    
11318                            if ((dlFolderModelImpl.getColumnBitmask() &
11319                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S.getColumnBitmask()) != 0) {
11320                                    Object[] args = new Object[] {
11321                                                    dlFolderModelImpl.getOriginalGroupId(),
11322                                                    dlFolderModelImpl.getOriginalMountPoint(),
11323                                                    dlFolderModelImpl.getOriginalParentFolderId(),
11324                                                    dlFolderModelImpl.getOriginalHidden(),
11325                                                    dlFolderModelImpl.getOriginalStatus()
11326                                            };
11327    
11328                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H_S,
11329                                            args);
11330                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S,
11331                                            args);
11332    
11333                                    args = new Object[] {
11334                                                    dlFolderModelImpl.getGroupId(),
11335                                                    dlFolderModelImpl.getMountPoint(),
11336                                                    dlFolderModelImpl.getParentFolderId(),
11337                                                    dlFolderModelImpl.getHidden(),
11338                                                    dlFolderModelImpl.getStatus()
11339                                            };
11340    
11341                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_M_P_H_S,
11342                                            args);
11343                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_M_P_H_S,
11344                                            args);
11345                            }
11346                    }
11347    
11348                    EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11349                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder, false);
11350    
11351                    clearUniqueFindersCache(dlFolder);
11352                    cacheUniqueFindersCache(dlFolder);
11353    
11354                    dlFolder.resetOriginalValues();
11355    
11356                    return dlFolder;
11357            }
11358    
11359            protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
11360                    if (dlFolder instanceof DLFolderImpl) {
11361                            return dlFolder;
11362                    }
11363    
11364                    DLFolderImpl dlFolderImpl = new DLFolderImpl();
11365    
11366                    dlFolderImpl.setNew(dlFolder.isNew());
11367                    dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
11368    
11369                    dlFolderImpl.setUuid(dlFolder.getUuid());
11370                    dlFolderImpl.setFolderId(dlFolder.getFolderId());
11371                    dlFolderImpl.setGroupId(dlFolder.getGroupId());
11372                    dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
11373                    dlFolderImpl.setUserId(dlFolder.getUserId());
11374                    dlFolderImpl.setUserName(dlFolder.getUserName());
11375                    dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
11376                    dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
11377                    dlFolderImpl.setRepositoryId(dlFolder.getRepositoryId());
11378                    dlFolderImpl.setMountPoint(dlFolder.isMountPoint());
11379                    dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
11380                    dlFolderImpl.setTreePath(dlFolder.getTreePath());
11381                    dlFolderImpl.setName(dlFolder.getName());
11382                    dlFolderImpl.setDescription(dlFolder.getDescription());
11383                    dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
11384                    dlFolderImpl.setDefaultFileEntryTypeId(dlFolder.getDefaultFileEntryTypeId());
11385                    dlFolderImpl.setHidden(dlFolder.isHidden());
11386                    dlFolderImpl.setRestrictionType(dlFolder.getRestrictionType());
11387                    dlFolderImpl.setStatus(dlFolder.getStatus());
11388                    dlFolderImpl.setStatusByUserId(dlFolder.getStatusByUserId());
11389                    dlFolderImpl.setStatusByUserName(dlFolder.getStatusByUserName());
11390                    dlFolderImpl.setStatusDate(dlFolder.getStatusDate());
11391    
11392                    return dlFolderImpl;
11393            }
11394    
11395            /**
11396             * Returns the document library folder with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
11397             *
11398             * @param primaryKey the primary key of the document library folder
11399             * @return the document library folder
11400             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
11401             */
11402            @Override
11403            public DLFolder findByPrimaryKey(Serializable primaryKey)
11404                    throws NoSuchFolderException {
11405                    DLFolder dlFolder = fetchByPrimaryKey(primaryKey);
11406    
11407                    if (dlFolder == null) {
11408                            if (_log.isWarnEnabled()) {
11409                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11410                            }
11411    
11412                            throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11413                                    primaryKey);
11414                    }
11415    
11416                    return dlFolder;
11417            }
11418    
11419            /**
11420             * Returns the document library folder with the primary key or throws a {@link NoSuchFolderException} if it could not be found.
11421             *
11422             * @param folderId the primary key of the document library folder
11423             * @return the document library folder
11424             * @throws NoSuchFolderException if a document library folder with the primary key could not be found
11425             */
11426            @Override
11427            public DLFolder findByPrimaryKey(long folderId)
11428                    throws NoSuchFolderException {
11429                    return findByPrimaryKey((Serializable)folderId);
11430            }
11431    
11432            /**
11433             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
11434             *
11435             * @param primaryKey the primary key of the document library folder
11436             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
11437             */
11438            @Override
11439            public DLFolder fetchByPrimaryKey(Serializable primaryKey) {
11440                    DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11441                                    DLFolderImpl.class, primaryKey);
11442    
11443                    if (dlFolder == _nullDLFolder) {
11444                            return null;
11445                    }
11446    
11447                    if (dlFolder == null) {
11448                            Session session = null;
11449    
11450                            try {
11451                                    session = openSession();
11452    
11453                                    dlFolder = (DLFolder)session.get(DLFolderImpl.class, primaryKey);
11454    
11455                                    if (dlFolder != null) {
11456                                            cacheResult(dlFolder);
11457                                    }
11458                                    else {
11459                                            EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11460                                                    DLFolderImpl.class, primaryKey, _nullDLFolder);
11461                                    }
11462                            }
11463                            catch (Exception e) {
11464                                    EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11465                                            DLFolderImpl.class, primaryKey);
11466    
11467                                    throw processException(e);
11468                            }
11469                            finally {
11470                                    closeSession(session);
11471                            }
11472                    }
11473    
11474                    return dlFolder;
11475            }
11476    
11477            /**
11478             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
11479             *
11480             * @param folderId the primary key of the document library folder
11481             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
11482             */
11483            @Override
11484            public DLFolder fetchByPrimaryKey(long folderId) {
11485                    return fetchByPrimaryKey((Serializable)folderId);
11486            }
11487    
11488            @Override
11489            public Map<Serializable, DLFolder> fetchByPrimaryKeys(
11490                    Set<Serializable> primaryKeys) {
11491                    if (primaryKeys.isEmpty()) {
11492                            return Collections.emptyMap();
11493                    }
11494    
11495                    Map<Serializable, DLFolder> map = new HashMap<Serializable, DLFolder>();
11496    
11497                    if (primaryKeys.size() == 1) {
11498                            Iterator<Serializable> iterator = primaryKeys.iterator();
11499    
11500                            Serializable primaryKey = iterator.next();
11501    
11502                            DLFolder dlFolder = fetchByPrimaryKey(primaryKey);
11503    
11504                            if (dlFolder != null) {
11505                                    map.put(primaryKey, dlFolder);
11506                            }
11507    
11508                            return map;
11509                    }
11510    
11511                    Set<Serializable> uncachedPrimaryKeys = null;
11512    
11513                    for (Serializable primaryKey : primaryKeys) {
11514                            DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11515                                            DLFolderImpl.class, primaryKey);
11516    
11517                            if (dlFolder == null) {
11518                                    if (uncachedPrimaryKeys == null) {
11519                                            uncachedPrimaryKeys = new HashSet<Serializable>();
11520                                    }
11521    
11522                                    uncachedPrimaryKeys.add(primaryKey);
11523                            }
11524                            else {
11525                                    map.put(primaryKey, dlFolder);
11526                            }
11527                    }
11528    
11529                    if (uncachedPrimaryKeys == null) {
11530                            return map;
11531                    }
11532    
11533                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
11534                                    1);
11535    
11536                    query.append(_SQL_SELECT_DLFOLDER_WHERE_PKS_IN);
11537    
11538                    for (Serializable primaryKey : uncachedPrimaryKeys) {
11539                            query.append(String.valueOf(primaryKey));
11540    
11541                            query.append(StringPool.COMMA);
11542                    }
11543    
11544                    query.setIndex(query.index() - 1);
11545    
11546                    query.append(StringPool.CLOSE_PARENTHESIS);
11547    
11548                    String sql = query.toString();
11549    
11550                    Session session = null;
11551    
11552                    try {
11553                            session = openSession();
11554    
11555                            Query q = session.createQuery(sql);
11556    
11557                            for (DLFolder dlFolder : (List<DLFolder>)q.list()) {
11558                                    map.put(dlFolder.getPrimaryKeyObj(), dlFolder);
11559    
11560                                    cacheResult(dlFolder);
11561    
11562                                    uncachedPrimaryKeys.remove(dlFolder.getPrimaryKeyObj());
11563                            }
11564    
11565                            for (Serializable primaryKey : uncachedPrimaryKeys) {
11566                                    EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
11567                                            DLFolderImpl.class, primaryKey, _nullDLFolder);
11568                            }
11569                    }
11570                    catch (Exception e) {
11571                            throw processException(e);
11572                    }
11573                    finally {
11574                            closeSession(session);
11575                    }
11576    
11577                    return map;
11578            }
11579    
11580            /**
11581             * Returns all the document library folders.
11582             *
11583             * @return the document library folders
11584             */
11585            @Override
11586            public List<DLFolder> findAll() {
11587                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11588            }
11589    
11590            /**
11591             * Returns a range of all the document library folders.
11592             *
11593             * <p>
11594             * 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.
11595             * </p>
11596             *
11597             * @param start the lower bound of the range of document library folders
11598             * @param end the upper bound of the range of document library folders (not inclusive)
11599             * @return the range of document library folders
11600             */
11601            @Override
11602            public List<DLFolder> findAll(int start, int end) {
11603                    return findAll(start, end, null);
11604            }
11605    
11606            /**
11607             * Returns an ordered range of all the document library folders.
11608             *
11609             * <p>
11610             * 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.
11611             * </p>
11612             *
11613             * @param start the lower bound of the range of document library folders
11614             * @param end the upper bound of the range of document library folders (not inclusive)
11615             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11616             * @return the ordered range of document library folders
11617             */
11618            @Override
11619            public List<DLFolder> findAll(int start, int end,
11620                    OrderByComparator<DLFolder> orderByComparator) {
11621                    boolean pagination = true;
11622                    FinderPath finderPath = null;
11623                    Object[] finderArgs = null;
11624    
11625                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11626                                    (orderByComparator == null)) {
11627                            pagination = false;
11628                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11629                            finderArgs = FINDER_ARGS_EMPTY;
11630                    }
11631                    else {
11632                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11633                            finderArgs = new Object[] { start, end, orderByComparator };
11634                    }
11635    
11636                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
11637                                    finderArgs, this);
11638    
11639                    if (list == null) {
11640                            StringBundler query = null;
11641                            String sql = null;
11642    
11643                            if (orderByComparator != null) {
11644                                    query = new StringBundler(2 +
11645                                                    (orderByComparator.getOrderByFields().length * 3));
11646    
11647                                    query.append(_SQL_SELECT_DLFOLDER);
11648    
11649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11650                                            orderByComparator);
11651    
11652                                    sql = query.toString();
11653                            }
11654                            else {
11655                                    sql = _SQL_SELECT_DLFOLDER;
11656    
11657                                    if (pagination) {
11658                                            sql = sql.concat(DLFolderModelImpl.ORDER_BY_JPQL);
11659                                    }
11660                            }
11661    
11662                            Session session = null;
11663    
11664                            try {
11665                                    session = openSession();
11666    
11667                                    Query q = session.createQuery(sql);
11668    
11669                                    if (!pagination) {
11670                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
11671                                                            start, end, false);
11672    
11673                                            Collections.sort(list);
11674    
11675                                            list = Collections.unmodifiableList(list);
11676                                    }
11677                                    else {
11678                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
11679                                                            start, end);
11680                                    }
11681    
11682                                    cacheResult(list);
11683    
11684                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11685                            }
11686                            catch (Exception e) {
11687                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11688    
11689                                    throw processException(e);
11690                            }
11691                            finally {
11692                                    closeSession(session);
11693                            }
11694                    }
11695    
11696                    return list;
11697            }
11698    
11699            /**
11700             * Removes all the document library folders from the database.
11701             *
11702             */
11703            @Override
11704            public void removeAll() {
11705                    for (DLFolder dlFolder : findAll()) {
11706                            remove(dlFolder);
11707                    }
11708            }
11709    
11710            /**
11711             * Returns the number of document library folders.
11712             *
11713             * @return the number of document library folders
11714             */
11715            @Override
11716            public int countAll() {
11717                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11718                                    FINDER_ARGS_EMPTY, this);
11719    
11720                    if (count == null) {
11721                            Session session = null;
11722    
11723                            try {
11724                                    session = openSession();
11725    
11726                                    Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
11727    
11728                                    count = (Long)q.uniqueResult();
11729    
11730                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11731                                            FINDER_ARGS_EMPTY, count);
11732                            }
11733                            catch (Exception e) {
11734                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11735                                            FINDER_ARGS_EMPTY);
11736    
11737                                    throw processException(e);
11738                            }
11739                            finally {
11740                                    closeSession(session);
11741                            }
11742                    }
11743    
11744                    return count.intValue();
11745            }
11746    
11747            /**
11748             * Returns the primaryKeys of document library file entry types associated with the document library folder.
11749             *
11750             * @param pk the primary key of the document library folder
11751             * @return long[] of the primaryKeys of document library file entry types associated with the document library folder
11752             */
11753            @Override
11754            public long[] getDLFileEntryTypePrimaryKeys(long pk) {
11755                    long[] pks = dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(pk);
11756    
11757                    return pks.clone();
11758            }
11759    
11760            /**
11761             * Returns all the document library file entry types associated with the document library folder.
11762             *
11763             * @param pk the primary key of the document library folder
11764             * @return the document library file entry types associated with the document library folder
11765             */
11766            @Override
11767            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
11768                    long pk) {
11769                    return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11770            }
11771    
11772            /**
11773             * Returns a range of all the document library file entry types associated with the document library folder.
11774             *
11775             * <p>
11776             * 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.
11777             * </p>
11778             *
11779             * @param pk the primary key of the document library folder
11780             * @param start the lower bound of the range of document library folders
11781             * @param end the upper bound of the range of document library folders (not inclusive)
11782             * @return the range of document library file entry types associated with the document library folder
11783             */
11784            @Override
11785            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
11786                    long pk, int start, int end) {
11787                    return getDLFileEntryTypes(pk, start, end, null);
11788            }
11789    
11790            /**
11791             * Returns an ordered range of all the document library file entry types associated with the document library folder.
11792             *
11793             * <p>
11794             * 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.
11795             * </p>
11796             *
11797             * @param pk the primary key of the document library folder
11798             * @param start the lower bound of the range of document library folders
11799             * @param end the upper bound of the range of document library folders (not inclusive)
11800             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11801             * @return the ordered range of document library file entry types associated with the document library folder
11802             */
11803            @Override
11804            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
11805                    long pk, int start, int end,
11806                    OrderByComparator<com.liferay.portlet.documentlibrary.model.DLFileEntryType> orderByComparator) {
11807                    return dlFolderToDLFileEntryTypeTableMapper.getRightBaseModels(pk,
11808                            start, end, orderByComparator);
11809            }
11810    
11811            /**
11812             * Returns the number of document library file entry types associated with the document library folder.
11813             *
11814             * @param pk the primary key of the document library folder
11815             * @return the number of document library file entry types associated with the document library folder
11816             */
11817            @Override
11818            public int getDLFileEntryTypesSize(long pk) {
11819                    long[] pks = dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(pk);
11820    
11821                    return pks.length;
11822            }
11823    
11824            /**
11825             * Returns <code>true</code> if the document library file entry type is associated with the document library folder.
11826             *
11827             * @param pk the primary key of the document library folder
11828             * @param dlFileEntryTypePK the primary key of the document library file entry type
11829             * @return <code>true</code> if the document library file entry type is associated with the document library folder; <code>false</code> otherwise
11830             */
11831            @Override
11832            public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK) {
11833                    return dlFolderToDLFileEntryTypeTableMapper.containsTableMapping(pk,
11834                            dlFileEntryTypePK);
11835            }
11836    
11837            /**
11838             * Returns <code>true</code> if the document library folder has any document library file entry types associated with it.
11839             *
11840             * @param pk the primary key of the document library folder to check for associations with document library file entry types
11841             * @return <code>true</code> if the document library folder has any document library file entry types associated with it; <code>false</code> otherwise
11842             */
11843            @Override
11844            public boolean containsDLFileEntryTypes(long pk) {
11845                    if (getDLFileEntryTypesSize(pk) > 0) {
11846                            return true;
11847                    }
11848                    else {
11849                            return false;
11850                    }
11851            }
11852    
11853            /**
11854             * 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.
11855             *
11856             * @param pk the primary key of the document library folder
11857             * @param dlFileEntryTypePK the primary key of the document library file entry type
11858             */
11859            @Override
11860            public void addDLFileEntryType(long pk, long dlFileEntryTypePK) {
11861                    dlFolderToDLFileEntryTypeTableMapper.addTableMapping(pk,
11862                            dlFileEntryTypePK);
11863            }
11864    
11865            /**
11866             * 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.
11867             *
11868             * @param pk the primary key of the document library folder
11869             * @param dlFileEntryType the document library file entry type
11870             */
11871            @Override
11872            public void addDLFileEntryType(long pk,
11873                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType) {
11874                    dlFolderToDLFileEntryTypeTableMapper.addTableMapping(pk,
11875                            dlFileEntryType.getPrimaryKey());
11876            }
11877    
11878            /**
11879             * 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.
11880             *
11881             * @param pk the primary key of the document library folder
11882             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
11883             */
11884            @Override
11885            public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
11886                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
11887                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(pk,
11888                                    dlFileEntryTypePK);
11889                    }
11890            }
11891    
11892            /**
11893             * 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.
11894             *
11895             * @param pk the primary key of the document library folder
11896             * @param dlFileEntryTypes the document library file entry types
11897             */
11898            @Override
11899            public void addDLFileEntryTypes(long pk,
11900                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes) {
11901                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
11902                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(pk,
11903                                    dlFileEntryType.getPrimaryKey());
11904                    }
11905            }
11906    
11907            /**
11908             * 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.
11909             *
11910             * @param pk the primary key of the document library folder to clear the associated document library file entry types from
11911             */
11912            @Override
11913            public void clearDLFileEntryTypes(long pk) {
11914                    dlFolderToDLFileEntryTypeTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
11915            }
11916    
11917            /**
11918             * 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.
11919             *
11920             * @param pk the primary key of the document library folder
11921             * @param dlFileEntryTypePK the primary key of the document library file entry type
11922             */
11923            @Override
11924            public void removeDLFileEntryType(long pk, long dlFileEntryTypePK) {
11925                    dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
11926                            dlFileEntryTypePK);
11927            }
11928    
11929            /**
11930             * 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.
11931             *
11932             * @param pk the primary key of the document library folder
11933             * @param dlFileEntryType the document library file entry type
11934             */
11935            @Override
11936            public void removeDLFileEntryType(long pk,
11937                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType) {
11938                    dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
11939                            dlFileEntryType.getPrimaryKey());
11940            }
11941    
11942            /**
11943             * 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.
11944             *
11945             * @param pk the primary key of the document library folder
11946             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
11947             */
11948            @Override
11949            public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
11950                    for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
11951                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
11952                                    dlFileEntryTypePK);
11953                    }
11954            }
11955    
11956            /**
11957             * 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.
11958             *
11959             * @param pk the primary key of the document library folder
11960             * @param dlFileEntryTypes the document library file entry types
11961             */
11962            @Override
11963            public void removeDLFileEntryTypes(long pk,
11964                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes) {
11965                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
11966                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
11967                                    dlFileEntryType.getPrimaryKey());
11968                    }
11969            }
11970    
11971            /**
11972             * 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.
11973             *
11974             * @param pk the primary key of the document library folder
11975             * @param dlFileEntryTypePKs the primary keys of the document library file entry types to be associated with the document library folder
11976             */
11977            @Override
11978            public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs) {
11979                    Set<Long> newDLFileEntryTypePKsSet = SetUtil.fromArray(dlFileEntryTypePKs);
11980                    Set<Long> oldDLFileEntryTypePKsSet = SetUtil.fromArray(dlFolderToDLFileEntryTypeTableMapper.getRightPrimaryKeys(
11981                                            pk));
11982    
11983                    Set<Long> removeDLFileEntryTypePKsSet = new HashSet<Long>(oldDLFileEntryTypePKsSet);
11984    
11985                    removeDLFileEntryTypePKsSet.removeAll(newDLFileEntryTypePKsSet);
11986    
11987                    for (long removeDLFileEntryTypePK : removeDLFileEntryTypePKsSet) {
11988                            dlFolderToDLFileEntryTypeTableMapper.deleteTableMapping(pk,
11989                                    removeDLFileEntryTypePK);
11990                    }
11991    
11992                    newDLFileEntryTypePKsSet.removeAll(oldDLFileEntryTypePKsSet);
11993    
11994                    for (long newDLFileEntryTypePK : newDLFileEntryTypePKsSet) {
11995                            dlFolderToDLFileEntryTypeTableMapper.addTableMapping(pk,
11996                                    newDLFileEntryTypePK);
11997                    }
11998            }
11999    
12000            /**
12001             * 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.
12002             *
12003             * @param pk the primary key of the document library folder
12004             * @param dlFileEntryTypes the document library file entry types to be associated with the document library folder
12005             */
12006            @Override
12007            public void setDLFileEntryTypes(long pk,
12008                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes) {
12009                    try {
12010                            long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
12011    
12012                            for (int i = 0; i < dlFileEntryTypes.size(); i++) {
12013                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
12014                                            dlFileEntryTypes.get(i);
12015    
12016                                    dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
12017                            }
12018    
12019                            setDLFileEntryTypes(pk, dlFileEntryTypePKs);
12020                    }
12021                    catch (Exception e) {
12022                            throw processException(e);
12023                    }
12024            }
12025    
12026            @Override
12027            protected Set<String> getBadColumnNames() {
12028                    return _badColumnNames;
12029            }
12030    
12031            /**
12032             * Initializes the document library folder persistence.
12033             */
12034            public void afterPropertiesSet() {
12035                    dlFolderToDLFileEntryTypeTableMapper = TableMapperFactory.getTableMapper("DLFileEntryTypes_DLFolders",
12036                                    "folderId", "fileEntryTypeId", this, dlFileEntryTypePersistence);
12037            }
12038    
12039            public void destroy() {
12040                    EntityCacheUtil.removeCache(DLFolderImpl.class.getName());
12041                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12042                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12043                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12044    
12045                    TableMapperFactory.removeTableMapper("DLFileEntryTypes_DLFolders");
12046            }
12047    
12048            @BeanReference(type = DLFileEntryTypePersistence.class)
12049            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
12050            protected TableMapper<DLFolder, com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFolderToDLFileEntryTypeTableMapper;
12051            private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
12052            private static final String _SQL_SELECT_DLFOLDER_WHERE_PKS_IN = "SELECT dlFolder FROM DLFolder dlFolder WHERE folderId IN (";
12053            private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
12054            private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
12055            private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
12056            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFolder.folderId";
12057            private static final String _FILTER_SQL_SELECT_DLFOLDER_WHERE = "SELECT DISTINCT {dlFolder.*} FROM DLFolder dlFolder WHERE ";
12058            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
12059                    "SELECT {DLFolder.*} FROM (SELECT DISTINCT dlFolder.folderId FROM DLFolder dlFolder WHERE ";
12060            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
12061                    ") TEMP_TABLE INNER JOIN DLFolder ON TEMP_TABLE.folderId = DLFolder.folderId";
12062            private static final String _FILTER_SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(DISTINCT dlFolder.folderId) AS COUNT_VALUE FROM DLFolder dlFolder WHERE ";
12063            private static final String _FILTER_ENTITY_ALIAS = "dlFolder";
12064            private static final String _FILTER_ENTITY_TABLE = "DLFolder";
12065            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
12066            private static final String _ORDER_BY_ENTITY_TABLE = "DLFolder.";
12067            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
12068            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
12069            private static final Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
12070            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12071                                    "uuid", "hidden"
12072                            });
12073            private static final DLFolder _nullDLFolder = new DLFolderImpl() {
12074                            @Override
12075                            public Object clone() {
12076                                    return this;
12077                            }
12078    
12079                            @Override
12080                            public CacheModel<DLFolder> toCacheModel() {
12081                                    return _nullDLFolderCacheModel;
12082                            }
12083                    };
12084    
12085            private static final CacheModel<DLFolder> _nullDLFolderCacheModel = new CacheModel<DLFolder>() {
12086                            @Override
12087                            public DLFolder toEntityModel() {
12088                                    return _nullDLFolder;
12089                            }
12090                    };
12091    }