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