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