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