001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
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.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.ImagePersistence;
044    import com.liferay.portal.service.persistence.LockPersistence;
045    import com.liferay.portal.service.persistence.ResourcePersistence;
046    import com.liferay.portal.service.persistence.UserPersistence;
047    import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
048    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
049    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050    
051    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
052    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
053    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
054    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
055    import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
056    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
057    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
058    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
059    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
060    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
061    
062    import java.io.Serializable;
063    
064    import java.util.ArrayList;
065    import java.util.Collections;
066    import java.util.List;
067    
068    /**
069     * The persistence implementation for the document library file entry service.
070     *
071     * <p>
072     * Caching information and settings can be found in <code>portal.properties</code>
073     * </p>
074     *
075     * @author Brian Wing Shun Chan
076     * @see DLFileEntryPersistence
077     * @see DLFileEntryUtil
078     * @generated
079     */
080    public class DLFileEntryPersistenceImpl extends BasePersistenceImpl<DLFileEntry>
081            implements DLFileEntryPersistence {
082            /*
083             * NOTE FOR DEVELOPERS:
084             *
085             * 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.
086             */
087            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List1";
090            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List2";
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
095                            new String[] {
096                                    String.class.getName(),
097                                    
098                            "java.lang.Integer", "java.lang.Integer",
099                                    "com.liferay.portal.kernel.util.OrderByComparator"
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
102                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104                            new String[] { String.class.getName() },
105                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
107                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
109                            new String[] { String.class.getName() });
110            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
112                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
113                            new String[] { String.class.getName(), Long.class.getName() },
114                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
115                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
117                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
119                            new String[] { String.class.getName(), Long.class.getName() });
120            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
121                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
123                            new String[] {
124                                    Long.class.getName(),
125                                    
126                            "java.lang.Integer", "java.lang.Integer",
127                                    "com.liferay.portal.kernel.util.OrderByComparator"
128                            });
129            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
130                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
131                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
132                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
133                            new String[] { Long.class.getName() },
134                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
135            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
136                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
138                            new String[] { Long.class.getName() });
139            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
140                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
141                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
142                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
143                            new String[] {
144                                    Long.class.getName(),
145                                    
146                            "java.lang.Integer", "java.lang.Integer",
147                                    "com.liferay.portal.kernel.util.OrderByComparator"
148                            });
149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
150                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
151                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
152                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
153                            new String[] { Long.class.getName() },
154                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK);
155            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
158                            new String[] { Long.class.getName() });
159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
160                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
161                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
162                            new String[] {
163                                    Long.class.getName(), Long.class.getName(),
164                                    
165                            "java.lang.Integer", "java.lang.Integer",
166                                    "com.liferay.portal.kernel.util.OrderByComparator"
167                            });
168            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
169                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
171                            new String[] { Long.class.getName(), Long.class.getName() },
172                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
173                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK);
174            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
175                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
176                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
177                            new String[] { Long.class.getName(), Long.class.getName() });
178            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
179                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
180                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F",
181                            new String[] {
182                                    Long.class.getName(), Long.class.getName(),
183                                    
184                            "java.lang.Integer", "java.lang.Integer",
185                                    "com.liferay.portal.kernel.util.OrderByComparator"
186                            });
187            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
188                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
189                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
190                            new String[] { Long.class.getName(), Long.class.getName() },
191                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
192                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK);
193            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
194                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
195                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
196                            new String[] { Long.class.getName(), Long.class.getName() });
197            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
198                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
199                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
200                            new String[] {
201                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
202                                    
203                            "java.lang.Integer", "java.lang.Integer",
204                                    "com.liferay.portal.kernel.util.OrderByComparator"
205                            });
206            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
207                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
208                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
209                            new String[] {
210                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
211                            },
212                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
213                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
214                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK);
215            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
216                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F",
218                            new String[] {
219                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
220                            });
221            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
222                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
223                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
224                            new String[] {
225                                    Long.class.getName(), Long.class.getName(),
226                                    String.class.getName()
227                            },
228                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
229                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
230                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
231            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
232                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
233                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_N",
234                            new String[] {
235                                    Long.class.getName(), Long.class.getName(),
236                                    String.class.getName()
237                            });
238            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
239                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
240                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
241                            new String[] {
242                                    Long.class.getName(), Long.class.getName(),
243                                    String.class.getName()
244                            },
245                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
246                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
247                            DLFileEntryModelImpl.TITLE_COLUMN_BITMASK);
248            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
249                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
250                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T",
251                            new String[] {
252                                    Long.class.getName(), Long.class.getName(),
253                                    String.class.getName()
254                            });
255            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
256                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
257                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_F",
258                            new String[] {
259                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
260                                    
261                            "java.lang.Integer", "java.lang.Integer",
262                                    "com.liferay.portal.kernel.util.OrderByComparator"
263                            });
264            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
265                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
266                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_F",
267                            new String[] {
268                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
269                            },
270                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
271                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
272                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK);
273            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
274                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
275                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_F",
276                            new String[] {
277                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
278                            });
279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
280                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
281                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
282            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
283                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
284                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
285            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
286                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
287                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
288    
289            /**
290             * Caches the document library file entry in the entity cache if it is enabled.
291             *
292             * @param dlFileEntry the document library file entry
293             */
294            public void cacheResult(DLFileEntry dlFileEntry) {
295                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
296                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
297    
298                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
299                            new Object[] {
300                                    dlFileEntry.getUuid(), Long.valueOf(dlFileEntry.getGroupId())
301                            }, dlFileEntry);
302    
303                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
304                            new Object[] {
305                                    Long.valueOf(dlFileEntry.getGroupId()),
306                                    Long.valueOf(dlFileEntry.getFolderId()),
307                                    
308                            dlFileEntry.getName()
309                            }, dlFileEntry);
310    
311                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
312                            new Object[] {
313                                    Long.valueOf(dlFileEntry.getGroupId()),
314                                    Long.valueOf(dlFileEntry.getFolderId()),
315                                    
316                            dlFileEntry.getTitle()
317                            }, dlFileEntry);
318    
319                    dlFileEntry.resetOriginalValues();
320            }
321    
322            /**
323             * Caches the document library file entries in the entity cache if it is enabled.
324             *
325             * @param dlFileEntries the document library file entries
326             */
327            public void cacheResult(List<DLFileEntry> dlFileEntries) {
328                    for (DLFileEntry dlFileEntry : dlFileEntries) {
329                            if (EntityCacheUtil.getResult(
330                                                    DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
331                                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey()) == null) {
332                                    cacheResult(dlFileEntry);
333                            }
334                            else {
335                                    dlFileEntry.resetOriginalValues();
336                            }
337                    }
338            }
339    
340            /**
341             * Clears the cache for all document library file entries.
342             *
343             * <p>
344             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
345             * </p>
346             */
347            @Override
348            public void clearCache() {
349                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
350                            CacheRegistryUtil.clear(DLFileEntryImpl.class.getName());
351                    }
352    
353                    EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
354    
355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
357                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
358            }
359    
360            /**
361             * Clears the cache for the document library file entry.
362             *
363             * <p>
364             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
365             * </p>
366             */
367            @Override
368            public void clearCache(DLFileEntry dlFileEntry) {
369                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
370                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
371    
372                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
373                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
374    
375                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
376                            new Object[] {
377                                    dlFileEntry.getUuid(), Long.valueOf(dlFileEntry.getGroupId())
378                            });
379    
380                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
381                            new Object[] {
382                                    Long.valueOf(dlFileEntry.getGroupId()),
383                                    Long.valueOf(dlFileEntry.getFolderId()),
384                                    
385                            dlFileEntry.getName()
386                            });
387    
388                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
389                            new Object[] {
390                                    Long.valueOf(dlFileEntry.getGroupId()),
391                                    Long.valueOf(dlFileEntry.getFolderId()),
392                                    
393                            dlFileEntry.getTitle()
394                            });
395            }
396    
397            /**
398             * Creates a new document library file entry with the primary key. Does not add the document library file entry to the database.
399             *
400             * @param fileEntryId the primary key for the new document library file entry
401             * @return the new document library file entry
402             */
403            public DLFileEntry create(long fileEntryId) {
404                    DLFileEntry dlFileEntry = new DLFileEntryImpl();
405    
406                    dlFileEntry.setNew(true);
407                    dlFileEntry.setPrimaryKey(fileEntryId);
408    
409                    String uuid = PortalUUIDUtil.generate();
410    
411                    dlFileEntry.setUuid(uuid);
412    
413                    return dlFileEntry;
414            }
415    
416            /**
417             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
418             *
419             * @param primaryKey the primary key of the document library file entry
420             * @return the document library file entry that was removed
421             * @throws com.liferay.portal.NoSuchModelException if a document library file entry with the primary key could not be found
422             * @throws SystemException if a system exception occurred
423             */
424            @Override
425            public DLFileEntry remove(Serializable primaryKey)
426                    throws NoSuchModelException, SystemException {
427                    return remove(((Long)primaryKey).longValue());
428            }
429    
430            /**
431             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
432             *
433             * @param fileEntryId the primary key of the document library file entry
434             * @return the document library file entry that was removed
435             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
436             * @throws SystemException if a system exception occurred
437             */
438            public DLFileEntry remove(long fileEntryId)
439                    throws NoSuchFileEntryException, SystemException {
440                    Session session = null;
441    
442                    try {
443                            session = openSession();
444    
445                            DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
446                                            Long.valueOf(fileEntryId));
447    
448                            if (dlFileEntry == null) {
449                                    if (_log.isWarnEnabled()) {
450                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryId);
451                                    }
452    
453                                    throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
454                                            fileEntryId);
455                            }
456    
457                            return dlFileEntryPersistence.remove(dlFileEntry);
458                    }
459                    catch (NoSuchFileEntryException nsee) {
460                            throw nsee;
461                    }
462                    catch (Exception e) {
463                            throw processException(e);
464                    }
465                    finally {
466                            closeSession(session);
467                    }
468            }
469    
470            /**
471             * Removes the document library file entry from the database. Also notifies the appropriate model listeners.
472             *
473             * @param dlFileEntry the document library file entry
474             * @return the document library file entry that was removed
475             * @throws SystemException if a system exception occurred
476             */
477            @Override
478            public DLFileEntry remove(DLFileEntry dlFileEntry)
479                    throws SystemException {
480                    return super.remove(dlFileEntry);
481            }
482    
483            @Override
484            protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
485                    throws SystemException {
486                    dlFileEntry = toUnwrappedModel(dlFileEntry);
487    
488                    Session session = null;
489    
490                    try {
491                            session = openSession();
492    
493                            BatchSessionUtil.delete(session, dlFileEntry);
494                    }
495                    catch (Exception e) {
496                            throw processException(e);
497                    }
498                    finally {
499                            closeSession(session);
500                    }
501    
502                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
503                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
504    
505                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
506    
507                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
508                            new Object[] {
509                                    dlFileEntryModelImpl.getUuid(),
510                                    Long.valueOf(dlFileEntryModelImpl.getGroupId())
511                            });
512    
513                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
514                            new Object[] {
515                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
516                                    Long.valueOf(dlFileEntryModelImpl.getFolderId()),
517                                    
518                            dlFileEntryModelImpl.getName()
519                            });
520    
521                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
522                            new Object[] {
523                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
524                                    Long.valueOf(dlFileEntryModelImpl.getFolderId()),
525                                    
526                            dlFileEntryModelImpl.getTitle()
527                            });
528    
529                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
530                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
531    
532                    return dlFileEntry;
533            }
534    
535            @Override
536            public DLFileEntry updateImpl(
537                    com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
538                    boolean merge) throws SystemException {
539                    dlFileEntry = toUnwrappedModel(dlFileEntry);
540    
541                    boolean isNew = dlFileEntry.isNew();
542    
543                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
544    
545                    if (Validator.isNull(dlFileEntry.getUuid())) {
546                            String uuid = PortalUUIDUtil.generate();
547    
548                            dlFileEntry.setUuid(uuid);
549                    }
550    
551                    Session session = null;
552    
553                    try {
554                            session = openSession();
555    
556                            BatchSessionUtil.update(session, dlFileEntry, merge);
557    
558                            dlFileEntry.setNew(false);
559                    }
560                    catch (Exception e) {
561                            throw processException(e);
562                    }
563                    finally {
564                            closeSession(session);
565                    }
566    
567                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
568    
569                    if (isNew || !DLFileEntryModelImpl.COLUMN_BITMASK_ENABLED) {
570                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
571                    }
572    
573                    else {
574                            if ((dlFileEntryModelImpl.getColumnBitmask() &
575                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
576                                    Object[] args = new Object[] {
577                                                    dlFileEntryModelImpl.getOriginalUuid()
578                                            };
579    
580                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
581                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
582                                            args);
583    
584                                    args = new Object[] { dlFileEntryModelImpl.getUuid() };
585    
586                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
587                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
588                                            args);
589                            }
590    
591                            if ((dlFileEntryModelImpl.getColumnBitmask() &
592                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
593                                    Object[] args = new Object[] {
594                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId())
595                                            };
596    
597                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
598                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
599                                            args);
600    
601                                    args = new Object[] {
602                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId())
603                                            };
604    
605                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
606                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
607                                            args);
608                            }
609    
610                            if ((dlFileEntryModelImpl.getColumnBitmask() &
611                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
612                                    Object[] args = new Object[] {
613                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalCompanyId())
614                                            };
615    
616                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
617                                            args);
618                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
619                                            args);
620    
621                                    args = new Object[] {
622                                                    Long.valueOf(dlFileEntryModelImpl.getCompanyId())
623                                            };
624    
625                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
626                                            args);
627                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
628                                            args);
629                            }
630    
631                            if ((dlFileEntryModelImpl.getColumnBitmask() &
632                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
633                                    Object[] args = new Object[] {
634                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
635                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalUserId())
636                                            };
637    
638                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
639                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
640                                            args);
641    
642                                    args = new Object[] {
643                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
644                                                    Long.valueOf(dlFileEntryModelImpl.getUserId())
645                                            };
646    
647                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
648                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
649                                            args);
650                            }
651    
652                            if ((dlFileEntryModelImpl.getColumnBitmask() &
653                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
654                                    Object[] args = new Object[] {
655                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
656                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId())
657                                            };
658    
659                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
660                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
661                                            args);
662    
663                                    args = new Object[] {
664                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
665                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId())
666                                            };
667    
668                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
669                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
670                                            args);
671                            }
672    
673                            if ((dlFileEntryModelImpl.getColumnBitmask() &
674                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
675                                    Object[] args = new Object[] {
676                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
677                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalUserId()),
678                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId())
679                                            };
680    
681                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
682                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
683                                            args);
684    
685                                    args = new Object[] {
686                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
687                                                    Long.valueOf(dlFileEntryModelImpl.getUserId()),
688                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId())
689                                            };
690    
691                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
692                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
693                                            args);
694                            }
695    
696                            if ((dlFileEntryModelImpl.getColumnBitmask() &
697                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F.getColumnBitmask()) != 0) {
698                                    Object[] args = new Object[] {
699                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
700                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
701                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFileEntryTypeId())
702                                            };
703    
704                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
705                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
706                                            args);
707    
708                                    args = new Object[] {
709                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
710                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId()),
711                                                    Long.valueOf(dlFileEntryModelImpl.getFileEntryTypeId())
712                                            };
713    
714                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
715                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
716                                            args);
717                            }
718                    }
719    
720                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
721                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
722    
723                    if (isNew) {
724                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
725                                    new Object[] {
726                                            dlFileEntry.getUuid(),
727                                            Long.valueOf(dlFileEntry.getGroupId())
728                                    }, dlFileEntry);
729    
730                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
731                                    new Object[] {
732                                            Long.valueOf(dlFileEntry.getGroupId()),
733                                            Long.valueOf(dlFileEntry.getFolderId()),
734                                            
735                                    dlFileEntry.getName()
736                                    }, dlFileEntry);
737    
738                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
739                                    new Object[] {
740                                            Long.valueOf(dlFileEntry.getGroupId()),
741                                            Long.valueOf(dlFileEntry.getFolderId()),
742                                            
743                                    dlFileEntry.getTitle()
744                                    }, dlFileEntry);
745                    }
746                    else {
747                            if ((dlFileEntryModelImpl.getColumnBitmask() &
748                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
749                                    Object[] args = new Object[] {
750                                                    dlFileEntryModelImpl.getOriginalUuid(),
751                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId())
752                                            };
753    
754                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
755                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
756    
757                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
758                                            new Object[] {
759                                                    dlFileEntry.getUuid(),
760                                                    Long.valueOf(dlFileEntry.getGroupId())
761                                            }, dlFileEntry);
762                            }
763    
764                            if ((dlFileEntryModelImpl.getColumnBitmask() &
765                                            FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
766                                    Object[] args = new Object[] {
767                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
768                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
769                                                    
770                                                    dlFileEntryModelImpl.getOriginalName()
771                                            };
772    
773                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
774                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
775    
776                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
777                                            new Object[] {
778                                                    Long.valueOf(dlFileEntry.getGroupId()),
779                                                    Long.valueOf(dlFileEntry.getFolderId()),
780                                                    
781                                            dlFileEntry.getName()
782                                            }, dlFileEntry);
783                            }
784    
785                            if ((dlFileEntryModelImpl.getColumnBitmask() &
786                                            FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
787                                    Object[] args = new Object[] {
788                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
789                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
790                                                    
791                                                    dlFileEntryModelImpl.getOriginalTitle()
792                                            };
793    
794                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
795                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
796    
797                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
798                                            new Object[] {
799                                                    Long.valueOf(dlFileEntry.getGroupId()),
800                                                    Long.valueOf(dlFileEntry.getFolderId()),
801                                                    
802                                            dlFileEntry.getTitle()
803                                            }, dlFileEntry);
804                            }
805                    }
806    
807                    return dlFileEntry;
808            }
809    
810            protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
811                    if (dlFileEntry instanceof DLFileEntryImpl) {
812                            return dlFileEntry;
813                    }
814    
815                    DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
816    
817                    dlFileEntryImpl.setNew(dlFileEntry.isNew());
818                    dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
819    
820                    dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
821                    dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
822                    dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
823                    dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
824                    dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
825                    dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
826                    dlFileEntryImpl.setVersionUserId(dlFileEntry.getVersionUserId());
827                    dlFileEntryImpl.setVersionUserName(dlFileEntry.getVersionUserName());
828                    dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
829                    dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
830                    dlFileEntryImpl.setRepositoryId(dlFileEntry.getRepositoryId());
831                    dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
832                    dlFileEntryImpl.setName(dlFileEntry.getName());
833                    dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
834                    dlFileEntryImpl.setMimeType(dlFileEntry.getMimeType());
835                    dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
836                    dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
837                    dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
838                    dlFileEntryImpl.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
839                    dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
840                    dlFileEntryImpl.setSize(dlFileEntry.getSize());
841                    dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
842                    dlFileEntryImpl.setSmallImageId(dlFileEntry.getSmallImageId());
843                    dlFileEntryImpl.setLargeImageId(dlFileEntry.getLargeImageId());
844                    dlFileEntryImpl.setCustom1ImageId(dlFileEntry.getCustom1ImageId());
845                    dlFileEntryImpl.setCustom2ImageId(dlFileEntry.getCustom2ImageId());
846    
847                    return dlFileEntryImpl;
848            }
849    
850            /**
851             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
852             *
853             * @param primaryKey the primary key of the document library file entry
854             * @return the document library file entry
855             * @throws com.liferay.portal.NoSuchModelException if a document library file entry with the primary key could not be found
856             * @throws SystemException if a system exception occurred
857             */
858            @Override
859            public DLFileEntry findByPrimaryKey(Serializable primaryKey)
860                    throws NoSuchModelException, SystemException {
861                    return findByPrimaryKey(((Long)primaryKey).longValue());
862            }
863    
864            /**
865             * 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.
866             *
867             * @param fileEntryId the primary key of the document library file entry
868             * @return the document library file entry
869             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
870             * @throws SystemException if a system exception occurred
871             */
872            public DLFileEntry findByPrimaryKey(long fileEntryId)
873                    throws NoSuchFileEntryException, SystemException {
874                    DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
875    
876                    if (dlFileEntry == null) {
877                            if (_log.isWarnEnabled()) {
878                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryId);
879                            }
880    
881                            throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
882                                    fileEntryId);
883                    }
884    
885                    return dlFileEntry;
886            }
887    
888            /**
889             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
890             *
891             * @param primaryKey the primary key of the document library file entry
892             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
893             * @throws SystemException if a system exception occurred
894             */
895            @Override
896            public DLFileEntry fetchByPrimaryKey(Serializable primaryKey)
897                    throws SystemException {
898                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
899            }
900    
901            /**
902             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
903             *
904             * @param fileEntryId the primary key of the document library file entry
905             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
906             * @throws SystemException if a system exception occurred
907             */
908            public DLFileEntry fetchByPrimaryKey(long fileEntryId)
909                    throws SystemException {
910                    DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
911                                    DLFileEntryImpl.class, fileEntryId);
912    
913                    if (dlFileEntry == _nullDLFileEntry) {
914                            return null;
915                    }
916    
917                    if (dlFileEntry == null) {
918                            Session session = null;
919    
920                            boolean hasException = false;
921    
922                            try {
923                                    session = openSession();
924    
925                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
926                                                    Long.valueOf(fileEntryId));
927                            }
928                            catch (Exception e) {
929                                    hasException = true;
930    
931                                    throw processException(e);
932                            }
933                            finally {
934                                    if (dlFileEntry != null) {
935                                            cacheResult(dlFileEntry);
936                                    }
937                                    else if (!hasException) {
938                                            EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
939                                                    DLFileEntryImpl.class, fileEntryId, _nullDLFileEntry);
940                                    }
941    
942                                    closeSession(session);
943                            }
944                    }
945    
946                    return dlFileEntry;
947            }
948    
949            /**
950             * Returns all the document library file entries where uuid = &#63;.
951             *
952             * @param uuid the uuid
953             * @return the matching document library file entries
954             * @throws SystemException if a system exception occurred
955             */
956            public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
957                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
958            }
959    
960            /**
961             * Returns a range of all the document library file entries where uuid = &#63;.
962             *
963             * <p>
964             * 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.
965             * </p>
966             *
967             * @param uuid the uuid
968             * @param start the lower bound of the range of document library file entries
969             * @param end the upper bound of the range of document library file entries (not inclusive)
970             * @return the range of matching document library file entries
971             * @throws SystemException if a system exception occurred
972             */
973            public List<DLFileEntry> findByUuid(String uuid, int start, int end)
974                    throws SystemException {
975                    return findByUuid(uuid, start, end, null);
976            }
977    
978            /**
979             * Returns an ordered range of all the document library file entries where uuid = &#63;.
980             *
981             * <p>
982             * 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.
983             * </p>
984             *
985             * @param uuid the uuid
986             * @param start the lower bound of the range of document library file entries
987             * @param end the upper bound of the range of document library file entries (not inclusive)
988             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
989             * @return the ordered range of matching document library file entries
990             * @throws SystemException if a system exception occurred
991             */
992            public List<DLFileEntry> findByUuid(String uuid, int start, int end,
993                    OrderByComparator orderByComparator) throws SystemException {
994                    FinderPath finderPath = null;
995                    Object[] finderArgs = null;
996    
997                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
998                                    (orderByComparator == null)) {
999                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1000                            finderArgs = new Object[] { uuid };
1001                    }
1002                    else {
1003                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1004                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1005                    }
1006    
1007                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
1008                                    finderArgs, this);
1009    
1010                    if (list == null) {
1011                            StringBundler query = null;
1012    
1013                            if (orderByComparator != null) {
1014                                    query = new StringBundler(3 +
1015                                                    (orderByComparator.getOrderByFields().length * 3));
1016                            }
1017                            else {
1018                                    query = new StringBundler(3);
1019                            }
1020    
1021                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1022    
1023                            if (uuid == null) {
1024                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1025                            }
1026                            else {
1027                                    if (uuid.equals(StringPool.BLANK)) {
1028                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1029                                    }
1030                                    else {
1031                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1032                                    }
1033                            }
1034    
1035                            if (orderByComparator != null) {
1036                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1037                                            orderByComparator);
1038                            }
1039    
1040                            else {
1041                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1042                            }
1043    
1044                            String sql = query.toString();
1045    
1046                            Session session = null;
1047    
1048                            try {
1049                                    session = openSession();
1050    
1051                                    Query q = session.createQuery(sql);
1052    
1053                                    QueryPos qPos = QueryPos.getInstance(q);
1054    
1055                                    if (uuid != null) {
1056                                            qPos.add(uuid);
1057                                    }
1058    
1059                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1060                                                    start, end);
1061                            }
1062                            catch (Exception e) {
1063                                    throw processException(e);
1064                            }
1065                            finally {
1066                                    if (list == null) {
1067                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1068                                    }
1069                                    else {
1070                                            cacheResult(list);
1071    
1072                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1073                                    }
1074    
1075                                    closeSession(session);
1076                            }
1077                    }
1078    
1079                    return list;
1080            }
1081    
1082            /**
1083             * Returns the first document library file entry in the ordered set where uuid = &#63;.
1084             *
1085             * <p>
1086             * 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.
1087             * </p>
1088             *
1089             * @param uuid the uuid
1090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1091             * @return the first matching document library file entry
1092             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1093             * @throws SystemException if a system exception occurred
1094             */
1095            public DLFileEntry findByUuid_First(String uuid,
1096                    OrderByComparator orderByComparator)
1097                    throws NoSuchFileEntryException, SystemException {
1098                    List<DLFileEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
1099    
1100                    if (list.isEmpty()) {
1101                            StringBundler msg = new StringBundler(4);
1102    
1103                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1104    
1105                            msg.append("uuid=");
1106                            msg.append(uuid);
1107    
1108                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1109    
1110                            throw new NoSuchFileEntryException(msg.toString());
1111                    }
1112                    else {
1113                            return list.get(0);
1114                    }
1115            }
1116    
1117            /**
1118             * Returns the last document library file entry in the ordered set where uuid = &#63;.
1119             *
1120             * <p>
1121             * 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.
1122             * </p>
1123             *
1124             * @param uuid the uuid
1125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1126             * @return the last matching document library file entry
1127             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1128             * @throws SystemException if a system exception occurred
1129             */
1130            public DLFileEntry findByUuid_Last(String uuid,
1131                    OrderByComparator orderByComparator)
1132                    throws NoSuchFileEntryException, SystemException {
1133                    int count = countByUuid(uuid);
1134    
1135                    List<DLFileEntry> list = findByUuid(uuid, count - 1, count,
1136                                    orderByComparator);
1137    
1138                    if (list.isEmpty()) {
1139                            StringBundler msg = new StringBundler(4);
1140    
1141                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1142    
1143                            msg.append("uuid=");
1144                            msg.append(uuid);
1145    
1146                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1147    
1148                            throw new NoSuchFileEntryException(msg.toString());
1149                    }
1150                    else {
1151                            return list.get(0);
1152                    }
1153            }
1154    
1155            /**
1156             * Returns the document library file entries before and after the current document library file entry in the ordered set where uuid = &#63;.
1157             *
1158             * <p>
1159             * 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.
1160             * </p>
1161             *
1162             * @param fileEntryId the primary key of the current document library file entry
1163             * @param uuid the uuid
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_PrevAndNext(long fileEntryId, String uuid,
1170                    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_PrevAndNext(session, dlFileEntry, uuid,
1182                                            orderByComparator, true);
1183    
1184                            array[1] = dlFileEntry;
1185    
1186                            array[2] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
1187                                            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_PrevAndNext(Session session,
1200                    DLFileEntry dlFileEntry, String uuid,
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_UUID_1);
1216                    }
1217                    else {
1218                            if (uuid.equals(StringPool.BLANK)) {
1219                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1220                            }
1221                            else {
1222                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1223                            }
1224                    }
1225    
1226                    if (orderByComparator != null) {
1227                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1228    
1229                            if (orderByConditionFields.length > 0) {
1230                                    query.append(WHERE_AND);
1231                            }
1232    
1233                            for (int i = 0; i < orderByConditionFields.length; i++) {
1234                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1235                                    query.append(orderByConditionFields[i]);
1236    
1237                                    if ((i + 1) < orderByConditionFields.length) {
1238                                            if (orderByComparator.isAscending() ^ previous) {
1239                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1240                                            }
1241                                            else {
1242                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1243                                            }
1244                                    }
1245                                    else {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(WHERE_GREATER_THAN);
1248                                            }
1249                                            else {
1250                                                    query.append(WHERE_LESSER_THAN);
1251                                            }
1252                                    }
1253                            }
1254    
1255                            query.append(ORDER_BY_CLAUSE);
1256    
1257                            String[] orderByFields = orderByComparator.getOrderByFields();
1258    
1259                            for (int i = 0; i < orderByFields.length; i++) {
1260                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1261                                    query.append(orderByFields[i]);
1262    
1263                                    if ((i + 1) < orderByFields.length) {
1264                                            if (orderByComparator.isAscending() ^ previous) {
1265                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1266                                            }
1267                                            else {
1268                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1269                                            }
1270                                    }
1271                                    else {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(ORDER_BY_ASC);
1274                                            }
1275                                            else {
1276                                                    query.append(ORDER_BY_DESC);
1277                                            }
1278                                    }
1279                            }
1280                    }
1281    
1282                    else {
1283                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1284                    }
1285    
1286                    String sql = query.toString();
1287    
1288                    Query q = session.createQuery(sql);
1289    
1290                    q.setFirstResult(0);
1291                    q.setMaxResults(2);
1292    
1293                    QueryPos qPos = QueryPos.getInstance(q);
1294    
1295                    if (uuid != null) {
1296                            qPos.add(uuid);
1297                    }
1298    
1299                    if (orderByComparator != null) {
1300                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1301    
1302                            for (Object value : values) {
1303                                    qPos.add(value);
1304                            }
1305                    }
1306    
1307                    List<DLFileEntry> list = q.list();
1308    
1309                    if (list.size() == 2) {
1310                            return list.get(1);
1311                    }
1312                    else {
1313                            return null;
1314                    }
1315            }
1316    
1317            /**
1318             * 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.
1319             *
1320             * @param uuid the uuid
1321             * @param groupId the group ID
1322             * @return the matching document library file entry
1323             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1324             * @throws SystemException if a system exception occurred
1325             */
1326            public DLFileEntry findByUUID_G(String uuid, long groupId)
1327                    throws NoSuchFileEntryException, SystemException {
1328                    DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
1329    
1330                    if (dlFileEntry == null) {
1331                            StringBundler msg = new StringBundler(6);
1332    
1333                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1334    
1335                            msg.append("uuid=");
1336                            msg.append(uuid);
1337    
1338                            msg.append(", groupId=");
1339                            msg.append(groupId);
1340    
1341                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1342    
1343                            if (_log.isWarnEnabled()) {
1344                                    _log.warn(msg.toString());
1345                            }
1346    
1347                            throw new NoSuchFileEntryException(msg.toString());
1348                    }
1349    
1350                    return dlFileEntry;
1351            }
1352    
1353            /**
1354             * 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.
1355             *
1356             * @param uuid the uuid
1357             * @param groupId the group ID
1358             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1359             * @throws SystemException if a system exception occurred
1360             */
1361            public DLFileEntry fetchByUUID_G(String uuid, long groupId)
1362                    throws SystemException {
1363                    return fetchByUUID_G(uuid, groupId, true);
1364            }
1365    
1366            /**
1367             * 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.
1368             *
1369             * @param uuid the uuid
1370             * @param groupId the group ID
1371             * @param retrieveFromCache whether to use the finder cache
1372             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1373             * @throws SystemException if a system exception occurred
1374             */
1375            public DLFileEntry fetchByUUID_G(String uuid, long groupId,
1376                    boolean retrieveFromCache) throws SystemException {
1377                    Object[] finderArgs = new Object[] { uuid, groupId };
1378    
1379                    Object result = null;
1380    
1381                    if (retrieveFromCache) {
1382                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1383                                            finderArgs, this);
1384                    }
1385    
1386                    if (result == null) {
1387                            StringBundler query = new StringBundler(4);
1388    
1389                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1390    
1391                            if (uuid == null) {
1392                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1393                            }
1394                            else {
1395                                    if (uuid.equals(StringPool.BLANK)) {
1396                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1397                                    }
1398                                    else {
1399                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1400                                    }
1401                            }
1402    
1403                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1404    
1405                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1406    
1407                            String sql = query.toString();
1408    
1409                            Session session = null;
1410    
1411                            try {
1412                                    session = openSession();
1413    
1414                                    Query q = session.createQuery(sql);
1415    
1416                                    QueryPos qPos = QueryPos.getInstance(q);
1417    
1418                                    if (uuid != null) {
1419                                            qPos.add(uuid);
1420                                    }
1421    
1422                                    qPos.add(groupId);
1423    
1424                                    List<DLFileEntry> list = q.list();
1425    
1426                                    result = list;
1427    
1428                                    DLFileEntry dlFileEntry = null;
1429    
1430                                    if (list.isEmpty()) {
1431                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1432                                                    finderArgs, list);
1433                                    }
1434                                    else {
1435                                            dlFileEntry = list.get(0);
1436    
1437                                            cacheResult(dlFileEntry);
1438    
1439                                            if ((dlFileEntry.getUuid() == null) ||
1440                                                            !dlFileEntry.getUuid().equals(uuid) ||
1441                                                            (dlFileEntry.getGroupId() != groupId)) {
1442                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1443                                                            finderArgs, dlFileEntry);
1444                                            }
1445                                    }
1446    
1447                                    return dlFileEntry;
1448                            }
1449                            catch (Exception e) {
1450                                    throw processException(e);
1451                            }
1452                            finally {
1453                                    if (result == null) {
1454                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1455                                                    finderArgs);
1456                                    }
1457    
1458                                    closeSession(session);
1459                            }
1460                    }
1461                    else {
1462                            if (result instanceof List<?>) {
1463                                    return null;
1464                            }
1465                            else {
1466                                    return (DLFileEntry)result;
1467                            }
1468                    }
1469            }
1470    
1471            /**
1472             * Returns all the document library file entries where groupId = &#63;.
1473             *
1474             * @param groupId the group ID
1475             * @return the matching document library file entries
1476             * @throws SystemException if a system exception occurred
1477             */
1478            public List<DLFileEntry> findByGroupId(long groupId)
1479                    throws SystemException {
1480                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1481            }
1482    
1483            /**
1484             * Returns a range of all the document library file entries where groupId = &#63;.
1485             *
1486             * <p>
1487             * 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.
1488             * </p>
1489             *
1490             * @param groupId the group ID
1491             * @param start the lower bound of the range of document library file entries
1492             * @param end the upper bound of the range of document library file entries (not inclusive)
1493             * @return the range of matching document library file entries
1494             * @throws SystemException if a system exception occurred
1495             */
1496            public List<DLFileEntry> findByGroupId(long groupId, int start, int end)
1497                    throws SystemException {
1498                    return findByGroupId(groupId, start, end, null);
1499            }
1500    
1501            /**
1502             * Returns an ordered range of all the document library file entries where groupId = &#63;.
1503             *
1504             * <p>
1505             * 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.
1506             * </p>
1507             *
1508             * @param groupId the group ID
1509             * @param start the lower bound of the range of document library file entries
1510             * @param end the upper bound of the range of document library file entries (not inclusive)
1511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1512             * @return the ordered range of matching document library file entries
1513             * @throws SystemException if a system exception occurred
1514             */
1515            public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1516                    OrderByComparator orderByComparator) throws SystemException {
1517                    FinderPath finderPath = null;
1518                    Object[] finderArgs = null;
1519    
1520                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1521                                    (orderByComparator == null)) {
1522                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1523                            finderArgs = new Object[] { groupId };
1524                    }
1525                    else {
1526                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1527                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1528                    }
1529    
1530                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
1531                                    finderArgs, this);
1532    
1533                    if (list == null) {
1534                            StringBundler query = null;
1535    
1536                            if (orderByComparator != null) {
1537                                    query = new StringBundler(3 +
1538                                                    (orderByComparator.getOrderByFields().length * 3));
1539                            }
1540                            else {
1541                                    query = new StringBundler(3);
1542                            }
1543    
1544                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1545    
1546                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1547    
1548                            if (orderByComparator != null) {
1549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1550                                            orderByComparator);
1551                            }
1552    
1553                            else {
1554                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1555                            }
1556    
1557                            String sql = query.toString();
1558    
1559                            Session session = null;
1560    
1561                            try {
1562                                    session = openSession();
1563    
1564                                    Query q = session.createQuery(sql);
1565    
1566                                    QueryPos qPos = QueryPos.getInstance(q);
1567    
1568                                    qPos.add(groupId);
1569    
1570                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1571                                                    start, end);
1572                            }
1573                            catch (Exception e) {
1574                                    throw processException(e);
1575                            }
1576                            finally {
1577                                    if (list == null) {
1578                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1579                                    }
1580                                    else {
1581                                            cacheResult(list);
1582    
1583                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1584                                    }
1585    
1586                                    closeSession(session);
1587                            }
1588                    }
1589    
1590                    return list;
1591            }
1592    
1593            /**
1594             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1595             *
1596             * <p>
1597             * 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.
1598             * </p>
1599             *
1600             * @param groupId the group ID
1601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1602             * @return the first matching document library file entry
1603             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1604             * @throws SystemException if a system exception occurred
1605             */
1606            public DLFileEntry findByGroupId_First(long groupId,
1607                    OrderByComparator orderByComparator)
1608                    throws NoSuchFileEntryException, SystemException {
1609                    List<DLFileEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1610    
1611                    if (list.isEmpty()) {
1612                            StringBundler msg = new StringBundler(4);
1613    
1614                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1615    
1616                            msg.append("groupId=");
1617                            msg.append(groupId);
1618    
1619                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1620    
1621                            throw new NoSuchFileEntryException(msg.toString());
1622                    }
1623                    else {
1624                            return list.get(0);
1625                    }
1626            }
1627    
1628            /**
1629             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1630             *
1631             * <p>
1632             * 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.
1633             * </p>
1634             *
1635             * @param groupId the group ID
1636             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1637             * @return the last matching document library file entry
1638             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1639             * @throws SystemException if a system exception occurred
1640             */
1641            public DLFileEntry findByGroupId_Last(long groupId,
1642                    OrderByComparator orderByComparator)
1643                    throws NoSuchFileEntryException, SystemException {
1644                    int count = countByGroupId(groupId);
1645    
1646                    List<DLFileEntry> list = findByGroupId(groupId, count - 1, count,
1647                                    orderByComparator);
1648    
1649                    if (list.isEmpty()) {
1650                            StringBundler msg = new StringBundler(4);
1651    
1652                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653    
1654                            msg.append("groupId=");
1655                            msg.append(groupId);
1656    
1657                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1658    
1659                            throw new NoSuchFileEntryException(msg.toString());
1660                    }
1661                    else {
1662                            return list.get(0);
1663                    }
1664            }
1665    
1666            /**
1667             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63;.
1668             *
1669             * <p>
1670             * 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.
1671             * </p>
1672             *
1673             * @param fileEntryId the primary key of the current document library file entry
1674             * @param groupId the group ID
1675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1676             * @return the previous, current, and next document library file entry
1677             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
1678             * @throws SystemException if a system exception occurred
1679             */
1680            public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1681                    long groupId, OrderByComparator orderByComparator)
1682                    throws NoSuchFileEntryException, SystemException {
1683                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1684    
1685                    Session session = null;
1686    
1687                    try {
1688                            session = openSession();
1689    
1690                            DLFileEntry[] array = new DLFileEntryImpl[3];
1691    
1692                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1693                                            orderByComparator, true);
1694    
1695                            array[1] = dlFileEntry;
1696    
1697                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1698                                            orderByComparator, false);
1699    
1700                            return array;
1701                    }
1702                    catch (Exception e) {
1703                            throw processException(e);
1704                    }
1705                    finally {
1706                            closeSession(session);
1707                    }
1708            }
1709    
1710            protected DLFileEntry getByGroupId_PrevAndNext(Session session,
1711                    DLFileEntry dlFileEntry, long groupId,
1712                    OrderByComparator orderByComparator, boolean previous) {
1713                    StringBundler query = null;
1714    
1715                    if (orderByComparator != null) {
1716                            query = new StringBundler(6 +
1717                                            (orderByComparator.getOrderByFields().length * 6));
1718                    }
1719                    else {
1720                            query = new StringBundler(3);
1721                    }
1722    
1723                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1724    
1725                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1726    
1727                    if (orderByComparator != null) {
1728                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1729    
1730                            if (orderByConditionFields.length > 0) {
1731                                    query.append(WHERE_AND);
1732                            }
1733    
1734                            for (int i = 0; i < orderByConditionFields.length; i++) {
1735                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1736                                    query.append(orderByConditionFields[i]);
1737    
1738                                    if ((i + 1) < orderByConditionFields.length) {
1739                                            if (orderByComparator.isAscending() ^ previous) {
1740                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1741                                            }
1742                                            else {
1743                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1744                                            }
1745                                    }
1746                                    else {
1747                                            if (orderByComparator.isAscending() ^ previous) {
1748                                                    query.append(WHERE_GREATER_THAN);
1749                                            }
1750                                            else {
1751                                                    query.append(WHERE_LESSER_THAN);
1752                                            }
1753                                    }
1754                            }
1755    
1756                            query.append(ORDER_BY_CLAUSE);
1757    
1758                            String[] orderByFields = orderByComparator.getOrderByFields();
1759    
1760                            for (int i = 0; i < orderByFields.length; i++) {
1761                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1762                                    query.append(orderByFields[i]);
1763    
1764                                    if ((i + 1) < orderByFields.length) {
1765                                            if (orderByComparator.isAscending() ^ previous) {
1766                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1767                                            }
1768                                            else {
1769                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1770                                            }
1771                                    }
1772                                    else {
1773                                            if (orderByComparator.isAscending() ^ previous) {
1774                                                    query.append(ORDER_BY_ASC);
1775                                            }
1776                                            else {
1777                                                    query.append(ORDER_BY_DESC);
1778                                            }
1779                                    }
1780                            }
1781                    }
1782    
1783                    else {
1784                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1785                    }
1786    
1787                    String sql = query.toString();
1788    
1789                    Query q = session.createQuery(sql);
1790    
1791                    q.setFirstResult(0);
1792                    q.setMaxResults(2);
1793    
1794                    QueryPos qPos = QueryPos.getInstance(q);
1795    
1796                    qPos.add(groupId);
1797    
1798                    if (orderByComparator != null) {
1799                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1800    
1801                            for (Object value : values) {
1802                                    qPos.add(value);
1803                            }
1804                    }
1805    
1806                    List<DLFileEntry> list = q.list();
1807    
1808                    if (list.size() == 2) {
1809                            return list.get(1);
1810                    }
1811                    else {
1812                            return null;
1813                    }
1814            }
1815    
1816            /**
1817             * Returns all the document library file entries that the user has permission to view where groupId = &#63;.
1818             *
1819             * @param groupId the group ID
1820             * @return the matching document library file entries that the user has permission to view
1821             * @throws SystemException if a system exception occurred
1822             */
1823            public List<DLFileEntry> filterFindByGroupId(long groupId)
1824                    throws SystemException {
1825                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1826                            QueryUtil.ALL_POS, null);
1827            }
1828    
1829            /**
1830             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63;.
1831             *
1832             * <p>
1833             * 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.
1834             * </p>
1835             *
1836             * @param groupId the group ID
1837             * @param start the lower bound of the range of document library file entries
1838             * @param end the upper bound of the range of document library file entries (not inclusive)
1839             * @return the range of matching document library file entries that the user has permission to view
1840             * @throws SystemException if a system exception occurred
1841             */
1842            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1843                    int end) throws SystemException {
1844                    return filterFindByGroupId(groupId, start, end, null);
1845            }
1846    
1847            /**
1848             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63;.
1849             *
1850             * <p>
1851             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1852             * </p>
1853             *
1854             * @param groupId the group ID
1855             * @param start the lower bound of the range of document library file entries
1856             * @param end the upper bound of the range of document library file entries (not inclusive)
1857             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1858             * @return the ordered range of matching document library file entries that the user has permission to view
1859             * @throws SystemException if a system exception occurred
1860             */
1861            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1862                    int end, OrderByComparator orderByComparator) throws SystemException {
1863                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1864                            return findByGroupId(groupId, start, end, orderByComparator);
1865                    }
1866    
1867                    StringBundler query = null;
1868    
1869                    if (orderByComparator != null) {
1870                            query = new StringBundler(3 +
1871                                            (orderByComparator.getOrderByFields().length * 3));
1872                    }
1873                    else {
1874                            query = new StringBundler(3);
1875                    }
1876    
1877                    if (getDB().isSupportsInlineDistinct()) {
1878                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1879                    }
1880                    else {
1881                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
1882                    }
1883    
1884                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1885    
1886                    if (!getDB().isSupportsInlineDistinct()) {
1887                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
1888                    }
1889    
1890                    if (orderByComparator != null) {
1891                            if (getDB().isSupportsInlineDistinct()) {
1892                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1893                                            orderByComparator);
1894                            }
1895                            else {
1896                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1897                                            orderByComparator);
1898                            }
1899                    }
1900    
1901                    else {
1902                            if (getDB().isSupportsInlineDistinct()) {
1903                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1904                            }
1905                            else {
1906                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
1907                            }
1908                    }
1909    
1910                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1911                                    DLFileEntry.class.getName(),
1912                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1913    
1914                    Session session = null;
1915    
1916                    try {
1917                            session = openSession();
1918    
1919                            SQLQuery q = session.createSQLQuery(sql);
1920    
1921                            if (getDB().isSupportsInlineDistinct()) {
1922                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
1923                            }
1924                            else {
1925                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
1926                            }
1927    
1928                            QueryPos qPos = QueryPos.getInstance(q);
1929    
1930                            qPos.add(groupId);
1931    
1932                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
1933                    }
1934                    catch (Exception e) {
1935                            throw processException(e);
1936                    }
1937                    finally {
1938                            closeSession(session);
1939                    }
1940            }
1941    
1942            /**
1943             * 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;.
1944             *
1945             * @param fileEntryId the primary key of the current document library file entry
1946             * @param groupId the group ID
1947             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1948             * @return the previous, current, and next document library file entry
1949             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
1950             * @throws SystemException if a system exception occurred
1951             */
1952            public DLFileEntry[] filterFindByGroupId_PrevAndNext(long fileEntryId,
1953                    long groupId, OrderByComparator orderByComparator)
1954                    throws NoSuchFileEntryException, SystemException {
1955                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1956                            return findByGroupId_PrevAndNext(fileEntryId, groupId,
1957                                    orderByComparator);
1958                    }
1959    
1960                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1961    
1962                    Session session = null;
1963    
1964                    try {
1965                            session = openSession();
1966    
1967                            DLFileEntry[] array = new DLFileEntryImpl[3];
1968    
1969                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
1970                                            groupId, orderByComparator, true);
1971    
1972                            array[1] = dlFileEntry;
1973    
1974                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
1975                                            groupId, orderByComparator, false);
1976    
1977                            return array;
1978                    }
1979                    catch (Exception e) {
1980                            throw processException(e);
1981                    }
1982                    finally {
1983                            closeSession(session);
1984                    }
1985            }
1986    
1987            protected DLFileEntry filterGetByGroupId_PrevAndNext(Session session,
1988                    DLFileEntry dlFileEntry, long groupId,
1989                    OrderByComparator orderByComparator, boolean previous) {
1990                    StringBundler query = null;
1991    
1992                    if (orderByComparator != null) {
1993                            query = new StringBundler(6 +
1994                                            (orderByComparator.getOrderByFields().length * 6));
1995                    }
1996                    else {
1997                            query = new StringBundler(3);
1998                    }
1999    
2000                    if (getDB().isSupportsInlineDistinct()) {
2001                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2002                    }
2003                    else {
2004                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
2005                    }
2006    
2007                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2008    
2009                    if (!getDB().isSupportsInlineDistinct()) {
2010                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
2011                    }
2012    
2013                    if (orderByComparator != null) {
2014                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2015    
2016                            if (orderByConditionFields.length > 0) {
2017                                    query.append(WHERE_AND);
2018                            }
2019    
2020                            for (int i = 0; i < orderByConditionFields.length; i++) {
2021                                    if (getDB().isSupportsInlineDistinct()) {
2022                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2023                                    }
2024                                    else {
2025                                            query.append(_ORDER_BY_ENTITY_TABLE);
2026                                    }
2027    
2028                                    query.append(orderByConditionFields[i]);
2029    
2030                                    if ((i + 1) < orderByConditionFields.length) {
2031                                            if (orderByComparator.isAscending() ^ previous) {
2032                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2033                                            }
2034                                            else {
2035                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2036                                            }
2037                                    }
2038                                    else {
2039                                            if (orderByComparator.isAscending() ^ previous) {
2040                                                    query.append(WHERE_GREATER_THAN);
2041                                            }
2042                                            else {
2043                                                    query.append(WHERE_LESSER_THAN);
2044                                            }
2045                                    }
2046                            }
2047    
2048                            query.append(ORDER_BY_CLAUSE);
2049    
2050                            String[] orderByFields = orderByComparator.getOrderByFields();
2051    
2052                            for (int i = 0; i < orderByFields.length; i++) {
2053                                    if (getDB().isSupportsInlineDistinct()) {
2054                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2055                                    }
2056                                    else {
2057                                            query.append(_ORDER_BY_ENTITY_TABLE);
2058                                    }
2059    
2060                                    query.append(orderByFields[i]);
2061    
2062                                    if ((i + 1) < orderByFields.length) {
2063                                            if (orderByComparator.isAscending() ^ previous) {
2064                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2065                                            }
2066                                            else {
2067                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2068                                            }
2069                                    }
2070                                    else {
2071                                            if (orderByComparator.isAscending() ^ previous) {
2072                                                    query.append(ORDER_BY_ASC);
2073                                            }
2074                                            else {
2075                                                    query.append(ORDER_BY_DESC);
2076                                            }
2077                                    }
2078                            }
2079                    }
2080    
2081                    else {
2082                            if (getDB().isSupportsInlineDistinct()) {
2083                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2084                            }
2085                            else {
2086                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2087                            }
2088                    }
2089    
2090                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2091                                    DLFileEntry.class.getName(),
2092                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2093    
2094                    SQLQuery q = session.createSQLQuery(sql);
2095    
2096                    q.setFirstResult(0);
2097                    q.setMaxResults(2);
2098    
2099                    if (getDB().isSupportsInlineDistinct()) {
2100                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2101                    }
2102                    else {
2103                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2104                    }
2105    
2106                    QueryPos qPos = QueryPos.getInstance(q);
2107    
2108                    qPos.add(groupId);
2109    
2110                    if (orderByComparator != null) {
2111                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2112    
2113                            for (Object value : values) {
2114                                    qPos.add(value);
2115                            }
2116                    }
2117    
2118                    List<DLFileEntry> list = q.list();
2119    
2120                    if (list.size() == 2) {
2121                            return list.get(1);
2122                    }
2123                    else {
2124                            return null;
2125                    }
2126            }
2127    
2128            /**
2129             * Returns all the document library file entries where companyId = &#63;.
2130             *
2131             * @param companyId the company ID
2132             * @return the matching document library file entries
2133             * @throws SystemException if a system exception occurred
2134             */
2135            public List<DLFileEntry> findByCompanyId(long companyId)
2136                    throws SystemException {
2137                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2138                            null);
2139            }
2140    
2141            /**
2142             * Returns a range of all the document library file entries where companyId = &#63;.
2143             *
2144             * <p>
2145             * 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.
2146             * </p>
2147             *
2148             * @param companyId the company ID
2149             * @param start the lower bound of the range of document library file entries
2150             * @param end the upper bound of the range of document library file entries (not inclusive)
2151             * @return the range of matching document library file entries
2152             * @throws SystemException if a system exception occurred
2153             */
2154            public List<DLFileEntry> findByCompanyId(long companyId, int start, int end)
2155                    throws SystemException {
2156                    return findByCompanyId(companyId, start, end, null);
2157            }
2158    
2159            /**
2160             * Returns an ordered range of all the document library file entries where companyId = &#63;.
2161             *
2162             * <p>
2163             * 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.
2164             * </p>
2165             *
2166             * @param companyId the company ID
2167             * @param start the lower bound of the range of document library file entries
2168             * @param end the upper bound of the range of document library file entries (not inclusive)
2169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2170             * @return the ordered range of matching document library file entries
2171             * @throws SystemException if a system exception occurred
2172             */
2173            public List<DLFileEntry> findByCompanyId(long companyId, int start,
2174                    int end, OrderByComparator orderByComparator) throws SystemException {
2175                    FinderPath finderPath = null;
2176                    Object[] finderArgs = null;
2177    
2178                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2179                                    (orderByComparator == null)) {
2180                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2181                            finderArgs = new Object[] { companyId };
2182                    }
2183                    else {
2184                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2185                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2186                    }
2187    
2188                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2189                                    finderArgs, this);
2190    
2191                    if (list == null) {
2192                            StringBundler query = null;
2193    
2194                            if (orderByComparator != null) {
2195                                    query = new StringBundler(3 +
2196                                                    (orderByComparator.getOrderByFields().length * 3));
2197                            }
2198                            else {
2199                                    query = new StringBundler(3);
2200                            }
2201    
2202                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2203    
2204                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2205    
2206                            if (orderByComparator != null) {
2207                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2208                                            orderByComparator);
2209                            }
2210    
2211                            else {
2212                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2213                            }
2214    
2215                            String sql = query.toString();
2216    
2217                            Session session = null;
2218    
2219                            try {
2220                                    session = openSession();
2221    
2222                                    Query q = session.createQuery(sql);
2223    
2224                                    QueryPos qPos = QueryPos.getInstance(q);
2225    
2226                                    qPos.add(companyId);
2227    
2228                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2229                                                    start, end);
2230                            }
2231                            catch (Exception e) {
2232                                    throw processException(e);
2233                            }
2234                            finally {
2235                                    if (list == null) {
2236                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2237                                    }
2238                                    else {
2239                                            cacheResult(list);
2240    
2241                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2242                                    }
2243    
2244                                    closeSession(session);
2245                            }
2246                    }
2247    
2248                    return list;
2249            }
2250    
2251            /**
2252             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2253             *
2254             * <p>
2255             * 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.
2256             * </p>
2257             *
2258             * @param companyId the company ID
2259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2260             * @return the first matching document library file entry
2261             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2262             * @throws SystemException if a system exception occurred
2263             */
2264            public DLFileEntry findByCompanyId_First(long companyId,
2265                    OrderByComparator orderByComparator)
2266                    throws NoSuchFileEntryException, SystemException {
2267                    List<DLFileEntry> list = findByCompanyId(companyId, 0, 1,
2268                                    orderByComparator);
2269    
2270                    if (list.isEmpty()) {
2271                            StringBundler msg = new StringBundler(4);
2272    
2273                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2274    
2275                            msg.append("companyId=");
2276                            msg.append(companyId);
2277    
2278                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2279    
2280                            throw new NoSuchFileEntryException(msg.toString());
2281                    }
2282                    else {
2283                            return list.get(0);
2284                    }
2285            }
2286    
2287            /**
2288             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2289             *
2290             * <p>
2291             * 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.
2292             * </p>
2293             *
2294             * @param companyId the company ID
2295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2296             * @return the last matching document library file entry
2297             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2298             * @throws SystemException if a system exception occurred
2299             */
2300            public DLFileEntry findByCompanyId_Last(long companyId,
2301                    OrderByComparator orderByComparator)
2302                    throws NoSuchFileEntryException, SystemException {
2303                    int count = countByCompanyId(companyId);
2304    
2305                    List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
2306                                    orderByComparator);
2307    
2308                    if (list.isEmpty()) {
2309                            StringBundler msg = new StringBundler(4);
2310    
2311                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2312    
2313                            msg.append("companyId=");
2314                            msg.append(companyId);
2315    
2316                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2317    
2318                            throw new NoSuchFileEntryException(msg.toString());
2319                    }
2320                    else {
2321                            return list.get(0);
2322                    }
2323            }
2324    
2325            /**
2326             * Returns the document library file entries before and after the current document library file entry in the ordered set where companyId = &#63;.
2327             *
2328             * <p>
2329             * 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.
2330             * </p>
2331             *
2332             * @param fileEntryId the primary key of the current document library file entry
2333             * @param companyId the company ID
2334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2335             * @return the previous, current, and next document library file entry
2336             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2337             * @throws SystemException if a system exception occurred
2338             */
2339            public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
2340                    long companyId, OrderByComparator orderByComparator)
2341                    throws NoSuchFileEntryException, SystemException {
2342                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2343    
2344                    Session session = null;
2345    
2346                    try {
2347                            session = openSession();
2348    
2349                            DLFileEntry[] array = new DLFileEntryImpl[3];
2350    
2351                            array[0] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2352                                            companyId, orderByComparator, true);
2353    
2354                            array[1] = dlFileEntry;
2355    
2356                            array[2] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2357                                            companyId, orderByComparator, false);
2358    
2359                            return array;
2360                    }
2361                    catch (Exception e) {
2362                            throw processException(e);
2363                    }
2364                    finally {
2365                            closeSession(session);
2366                    }
2367            }
2368    
2369            protected DLFileEntry getByCompanyId_PrevAndNext(Session session,
2370                    DLFileEntry dlFileEntry, long companyId,
2371                    OrderByComparator orderByComparator, boolean previous) {
2372                    StringBundler query = null;
2373    
2374                    if (orderByComparator != null) {
2375                            query = new StringBundler(6 +
2376                                            (orderByComparator.getOrderByFields().length * 6));
2377                    }
2378                    else {
2379                            query = new StringBundler(3);
2380                    }
2381    
2382                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2383    
2384                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2385    
2386                    if (orderByComparator != null) {
2387                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2388    
2389                            if (orderByConditionFields.length > 0) {
2390                                    query.append(WHERE_AND);
2391                            }
2392    
2393                            for (int i = 0; i < orderByConditionFields.length; i++) {
2394                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2395                                    query.append(orderByConditionFields[i]);
2396    
2397                                    if ((i + 1) < orderByConditionFields.length) {
2398                                            if (orderByComparator.isAscending() ^ previous) {
2399                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2400                                            }
2401                                            else {
2402                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2403                                            }
2404                                    }
2405                                    else {
2406                                            if (orderByComparator.isAscending() ^ previous) {
2407                                                    query.append(WHERE_GREATER_THAN);
2408                                            }
2409                                            else {
2410                                                    query.append(WHERE_LESSER_THAN);
2411                                            }
2412                                    }
2413                            }
2414    
2415                            query.append(ORDER_BY_CLAUSE);
2416    
2417                            String[] orderByFields = orderByComparator.getOrderByFields();
2418    
2419                            for (int i = 0; i < orderByFields.length; i++) {
2420                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2421                                    query.append(orderByFields[i]);
2422    
2423                                    if ((i + 1) < orderByFields.length) {
2424                                            if (orderByComparator.isAscending() ^ previous) {
2425                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2426                                            }
2427                                            else {
2428                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2429                                            }
2430                                    }
2431                                    else {
2432                                            if (orderByComparator.isAscending() ^ previous) {
2433                                                    query.append(ORDER_BY_ASC);
2434                                            }
2435                                            else {
2436                                                    query.append(ORDER_BY_DESC);
2437                                            }
2438                                    }
2439                            }
2440                    }
2441    
2442                    else {
2443                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2444                    }
2445    
2446                    String sql = query.toString();
2447    
2448                    Query q = session.createQuery(sql);
2449    
2450                    q.setFirstResult(0);
2451                    q.setMaxResults(2);
2452    
2453                    QueryPos qPos = QueryPos.getInstance(q);
2454    
2455                    qPos.add(companyId);
2456    
2457                    if (orderByComparator != null) {
2458                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2459    
2460                            for (Object value : values) {
2461                                    qPos.add(value);
2462                            }
2463                    }
2464    
2465                    List<DLFileEntry> list = q.list();
2466    
2467                    if (list.size() == 2) {
2468                            return list.get(1);
2469                    }
2470                    else {
2471                            return null;
2472                    }
2473            }
2474    
2475            /**
2476             * Returns all the document library file entries where groupId = &#63; and userId = &#63;.
2477             *
2478             * @param groupId the group ID
2479             * @param userId the user ID
2480             * @return the matching document library file entries
2481             * @throws SystemException if a system exception occurred
2482             */
2483            public List<DLFileEntry> findByG_U(long groupId, long userId)
2484                    throws SystemException {
2485                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2486                            null);
2487            }
2488    
2489            /**
2490             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63;.
2491             *
2492             * <p>
2493             * 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.
2494             * </p>
2495             *
2496             * @param groupId the group ID
2497             * @param userId the user ID
2498             * @param start the lower bound of the range of document library file entries
2499             * @param end the upper bound of the range of document library file entries (not inclusive)
2500             * @return the range of matching document library file entries
2501             * @throws SystemException if a system exception occurred
2502             */
2503            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
2504                    int end) throws SystemException {
2505                    return findByG_U(groupId, userId, start, end, null);
2506            }
2507    
2508            /**
2509             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63;.
2510             *
2511             * <p>
2512             * 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.
2513             * </p>
2514             *
2515             * @param groupId the group ID
2516             * @param userId the user ID
2517             * @param start the lower bound of the range of document library file entries
2518             * @param end the upper bound of the range of document library file entries (not inclusive)
2519             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2520             * @return the ordered range of matching document library file entries
2521             * @throws SystemException if a system exception occurred
2522             */
2523            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
2524                    int end, OrderByComparator orderByComparator) throws SystemException {
2525                    FinderPath finderPath = null;
2526                    Object[] finderArgs = null;
2527    
2528                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2529                                    (orderByComparator == null)) {
2530                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
2531                            finderArgs = new Object[] { groupId, userId };
2532                    }
2533                    else {
2534                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
2535                            finderArgs = new Object[] {
2536                                            groupId, userId,
2537                                            
2538                                            start, end, orderByComparator
2539                                    };
2540                    }
2541    
2542                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2543                                    finderArgs, this);
2544    
2545                    if (list == null) {
2546                            StringBundler query = null;
2547    
2548                            if (orderByComparator != null) {
2549                                    query = new StringBundler(4 +
2550                                                    (orderByComparator.getOrderByFields().length * 3));
2551                            }
2552                            else {
2553                                    query = new StringBundler(4);
2554                            }
2555    
2556                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2557    
2558                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2559    
2560                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2561    
2562                            if (orderByComparator != null) {
2563                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2564                                            orderByComparator);
2565                            }
2566    
2567                            else {
2568                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2569                            }
2570    
2571                            String sql = query.toString();
2572    
2573                            Session session = null;
2574    
2575                            try {
2576                                    session = openSession();
2577    
2578                                    Query q = session.createQuery(sql);
2579    
2580                                    QueryPos qPos = QueryPos.getInstance(q);
2581    
2582                                    qPos.add(groupId);
2583    
2584                                    qPos.add(userId);
2585    
2586                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2587                                                    start, end);
2588                            }
2589                            catch (Exception e) {
2590                                    throw processException(e);
2591                            }
2592                            finally {
2593                                    if (list == null) {
2594                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2595                                    }
2596                                    else {
2597                                            cacheResult(list);
2598    
2599                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2600                                    }
2601    
2602                                    closeSession(session);
2603                            }
2604                    }
2605    
2606                    return list;
2607            }
2608    
2609            /**
2610             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
2611             *
2612             * <p>
2613             * 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.
2614             * </p>
2615             *
2616             * @param groupId the group ID
2617             * @param userId the user ID
2618             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2619             * @return the first matching document library file entry
2620             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2621             * @throws SystemException if a system exception occurred
2622             */
2623            public DLFileEntry findByG_U_First(long groupId, long userId,
2624                    OrderByComparator orderByComparator)
2625                    throws NoSuchFileEntryException, SystemException {
2626                    List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1,
2627                                    orderByComparator);
2628    
2629                    if (list.isEmpty()) {
2630                            StringBundler msg = new StringBundler(6);
2631    
2632                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2633    
2634                            msg.append("groupId=");
2635                            msg.append(groupId);
2636    
2637                            msg.append(", userId=");
2638                            msg.append(userId);
2639    
2640                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2641    
2642                            throw new NoSuchFileEntryException(msg.toString());
2643                    }
2644                    else {
2645                            return list.get(0);
2646                    }
2647            }
2648    
2649            /**
2650             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
2651             *
2652             * <p>
2653             * 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.
2654             * </p>
2655             *
2656             * @param groupId the group ID
2657             * @param userId the user ID
2658             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2659             * @return the last matching document library file entry
2660             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2661             * @throws SystemException if a system exception occurred
2662             */
2663            public DLFileEntry findByG_U_Last(long groupId, long userId,
2664                    OrderByComparator orderByComparator)
2665                    throws NoSuchFileEntryException, SystemException {
2666                    int count = countByG_U(groupId, userId);
2667    
2668                    List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
2669                                    orderByComparator);
2670    
2671                    if (list.isEmpty()) {
2672                            StringBundler msg = new StringBundler(6);
2673    
2674                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2675    
2676                            msg.append("groupId=");
2677                            msg.append(groupId);
2678    
2679                            msg.append(", userId=");
2680                            msg.append(userId);
2681    
2682                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2683    
2684                            throw new NoSuchFileEntryException(msg.toString());
2685                    }
2686                    else {
2687                            return list.get(0);
2688                    }
2689            }
2690    
2691            /**
2692             * 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;.
2693             *
2694             * <p>
2695             * 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.
2696             * </p>
2697             *
2698             * @param fileEntryId the primary key of the current document library file entry
2699             * @param groupId the group ID
2700             * @param userId the user ID
2701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2702             * @return the previous, current, and next document library file entry
2703             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2704             * @throws SystemException if a system exception occurred
2705             */
2706            public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
2707                    long userId, OrderByComparator orderByComparator)
2708                    throws NoSuchFileEntryException, SystemException {
2709                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2710    
2711                    Session session = null;
2712    
2713                    try {
2714                            session = openSession();
2715    
2716                            DLFileEntry[] array = new DLFileEntryImpl[3];
2717    
2718                            array[0] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2719                                            userId, orderByComparator, true);
2720    
2721                            array[1] = dlFileEntry;
2722    
2723                            array[2] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2724                                            userId, orderByComparator, false);
2725    
2726                            return array;
2727                    }
2728                    catch (Exception e) {
2729                            throw processException(e);
2730                    }
2731                    finally {
2732                            closeSession(session);
2733                    }
2734            }
2735    
2736            protected DLFileEntry getByG_U_PrevAndNext(Session session,
2737                    DLFileEntry dlFileEntry, long groupId, long userId,
2738                    OrderByComparator orderByComparator, boolean previous) {
2739                    StringBundler query = null;
2740    
2741                    if (orderByComparator != null) {
2742                            query = new StringBundler(6 +
2743                                            (orderByComparator.getOrderByFields().length * 6));
2744                    }
2745                    else {
2746                            query = new StringBundler(3);
2747                    }
2748    
2749                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2750    
2751                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2752    
2753                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2754    
2755                    if (orderByComparator != null) {
2756                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2757    
2758                            if (orderByConditionFields.length > 0) {
2759                                    query.append(WHERE_AND);
2760                            }
2761    
2762                            for (int i = 0; i < orderByConditionFields.length; i++) {
2763                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2764                                    query.append(orderByConditionFields[i]);
2765    
2766                                    if ((i + 1) < orderByConditionFields.length) {
2767                                            if (orderByComparator.isAscending() ^ previous) {
2768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2769                                            }
2770                                            else {
2771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2772                                            }
2773                                    }
2774                                    else {
2775                                            if (orderByComparator.isAscending() ^ previous) {
2776                                                    query.append(WHERE_GREATER_THAN);
2777                                            }
2778                                            else {
2779                                                    query.append(WHERE_LESSER_THAN);
2780                                            }
2781                                    }
2782                            }
2783    
2784                            query.append(ORDER_BY_CLAUSE);
2785    
2786                            String[] orderByFields = orderByComparator.getOrderByFields();
2787    
2788                            for (int i = 0; i < orderByFields.length; i++) {
2789                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2790                                    query.append(orderByFields[i]);
2791    
2792                                    if ((i + 1) < orderByFields.length) {
2793                                            if (orderByComparator.isAscending() ^ previous) {
2794                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2795                                            }
2796                                            else {
2797                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2798                                            }
2799                                    }
2800                                    else {
2801                                            if (orderByComparator.isAscending() ^ previous) {
2802                                                    query.append(ORDER_BY_ASC);
2803                                            }
2804                                            else {
2805                                                    query.append(ORDER_BY_DESC);
2806                                            }
2807                                    }
2808                            }
2809                    }
2810    
2811                    else {
2812                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2813                    }
2814    
2815                    String sql = query.toString();
2816    
2817                    Query q = session.createQuery(sql);
2818    
2819                    q.setFirstResult(0);
2820                    q.setMaxResults(2);
2821    
2822                    QueryPos qPos = QueryPos.getInstance(q);
2823    
2824                    qPos.add(groupId);
2825    
2826                    qPos.add(userId);
2827    
2828                    if (orderByComparator != null) {
2829                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2830    
2831                            for (Object value : values) {
2832                                    qPos.add(value);
2833                            }
2834                    }
2835    
2836                    List<DLFileEntry> list = q.list();
2837    
2838                    if (list.size() == 2) {
2839                            return list.get(1);
2840                    }
2841                    else {
2842                            return null;
2843                    }
2844            }
2845    
2846            /**
2847             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2848             *
2849             * @param groupId the group ID
2850             * @param userId the user ID
2851             * @return the matching document library file entries that the user has permission to view
2852             * @throws SystemException if a system exception occurred
2853             */
2854            public List<DLFileEntry> filterFindByG_U(long groupId, long userId)
2855                    throws SystemException {
2856                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2857                            QueryUtil.ALL_POS, null);
2858            }
2859    
2860            /**
2861             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2862             *
2863             * <p>
2864             * 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.
2865             * </p>
2866             *
2867             * @param groupId the group ID
2868             * @param userId the user ID
2869             * @param start the lower bound of the range of document library file entries
2870             * @param end the upper bound of the range of document library file entries (not inclusive)
2871             * @return the range of matching document library file entries that the user has permission to view
2872             * @throws SystemException if a system exception occurred
2873             */
2874            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2875                    int start, int end) throws SystemException {
2876                    return filterFindByG_U(groupId, userId, start, end, null);
2877            }
2878    
2879            /**
2880             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
2881             *
2882             * <p>
2883             * 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.
2884             * </p>
2885             *
2886             * @param groupId the group ID
2887             * @param userId the user ID
2888             * @param start the lower bound of the range of document library file entries
2889             * @param end the upper bound of the range of document library file entries (not inclusive)
2890             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2891             * @return the ordered range of matching document library file entries that the user has permission to view
2892             * @throws SystemException if a system exception occurred
2893             */
2894            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2895                    int start, int end, OrderByComparator orderByComparator)
2896                    throws SystemException {
2897                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2898                            return findByG_U(groupId, userId, start, end, orderByComparator);
2899                    }
2900    
2901                    StringBundler query = null;
2902    
2903                    if (orderByComparator != null) {
2904                            query = new StringBundler(4 +
2905                                            (orderByComparator.getOrderByFields().length * 3));
2906                    }
2907                    else {
2908                            query = new StringBundler(4);
2909                    }
2910    
2911                    if (getDB().isSupportsInlineDistinct()) {
2912                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2913                    }
2914                    else {
2915                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
2916                    }
2917    
2918                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2919    
2920                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2921    
2922                    if (!getDB().isSupportsInlineDistinct()) {
2923                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
2924                    }
2925    
2926                    if (orderByComparator != null) {
2927                            if (getDB().isSupportsInlineDistinct()) {
2928                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2929                                            orderByComparator);
2930                            }
2931                            else {
2932                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2933                                            orderByComparator);
2934                            }
2935                    }
2936    
2937                    else {
2938                            if (getDB().isSupportsInlineDistinct()) {
2939                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2940                            }
2941                            else {
2942                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2943                            }
2944                    }
2945    
2946                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2947                                    DLFileEntry.class.getName(),
2948                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2949    
2950                    Session session = null;
2951    
2952                    try {
2953                            session = openSession();
2954    
2955                            SQLQuery q = session.createSQLQuery(sql);
2956    
2957                            if (getDB().isSupportsInlineDistinct()) {
2958                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2959                            }
2960                            else {
2961                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2962                            }
2963    
2964                            QueryPos qPos = QueryPos.getInstance(q);
2965    
2966                            qPos.add(groupId);
2967    
2968                            qPos.add(userId);
2969    
2970                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
2971                    }
2972                    catch (Exception e) {
2973                            throw processException(e);
2974                    }
2975                    finally {
2976                            closeSession(session);
2977                    }
2978            }
2979    
2980            /**
2981             * 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;.
2982             *
2983             * @param fileEntryId the primary key of the current document library file entry
2984             * @param groupId the group ID
2985             * @param userId the user ID
2986             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2987             * @return the previous, current, and next document library file entry
2988             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2989             * @throws SystemException if a system exception occurred
2990             */
2991            public DLFileEntry[] filterFindByG_U_PrevAndNext(long fileEntryId,
2992                    long groupId, long userId, OrderByComparator orderByComparator)
2993                    throws NoSuchFileEntryException, SystemException {
2994                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2995                            return findByG_U_PrevAndNext(fileEntryId, groupId, userId,
2996                                    orderByComparator);
2997                    }
2998    
2999                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3000    
3001                    Session session = null;
3002    
3003                    try {
3004                            session = openSession();
3005    
3006                            DLFileEntry[] array = new DLFileEntryImpl[3];
3007    
3008                            array[0] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
3009                                            groupId, userId, orderByComparator, true);
3010    
3011                            array[1] = dlFileEntry;
3012    
3013                            array[2] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
3014                                            groupId, userId, orderByComparator, false);
3015    
3016                            return array;
3017                    }
3018                    catch (Exception e) {
3019                            throw processException(e);
3020                    }
3021                    finally {
3022                            closeSession(session);
3023                    }
3024            }
3025    
3026            protected DLFileEntry filterGetByG_U_PrevAndNext(Session session,
3027                    DLFileEntry dlFileEntry, long groupId, long userId,
3028                    OrderByComparator orderByComparator, boolean previous) {
3029                    StringBundler query = null;
3030    
3031                    if (orderByComparator != null) {
3032                            query = new StringBundler(6 +
3033                                            (orderByComparator.getOrderByFields().length * 6));
3034                    }
3035                    else {
3036                            query = new StringBundler(3);
3037                    }
3038    
3039                    if (getDB().isSupportsInlineDistinct()) {
3040                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3041                    }
3042                    else {
3043                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3044                    }
3045    
3046                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
3047    
3048                    query.append(_FINDER_COLUMN_G_U_USERID_2);
3049    
3050                    if (!getDB().isSupportsInlineDistinct()) {
3051                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3052                    }
3053    
3054                    if (orderByComparator != null) {
3055                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3056    
3057                            if (orderByConditionFields.length > 0) {
3058                                    query.append(WHERE_AND);
3059                            }
3060    
3061                            for (int i = 0; i < orderByConditionFields.length; i++) {
3062                                    if (getDB().isSupportsInlineDistinct()) {
3063                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3064                                    }
3065                                    else {
3066                                            query.append(_ORDER_BY_ENTITY_TABLE);
3067                                    }
3068    
3069                                    query.append(orderByConditionFields[i]);
3070    
3071                                    if ((i + 1) < orderByConditionFields.length) {
3072                                            if (orderByComparator.isAscending() ^ previous) {
3073                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3074                                            }
3075                                            else {
3076                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3077                                            }
3078                                    }
3079                                    else {
3080                                            if (orderByComparator.isAscending() ^ previous) {
3081                                                    query.append(WHERE_GREATER_THAN);
3082                                            }
3083                                            else {
3084                                                    query.append(WHERE_LESSER_THAN);
3085                                            }
3086                                    }
3087                            }
3088    
3089                            query.append(ORDER_BY_CLAUSE);
3090    
3091                            String[] orderByFields = orderByComparator.getOrderByFields();
3092    
3093                            for (int i = 0; i < orderByFields.length; i++) {
3094                                    if (getDB().isSupportsInlineDistinct()) {
3095                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3096                                    }
3097                                    else {
3098                                            query.append(_ORDER_BY_ENTITY_TABLE);
3099                                    }
3100    
3101                                    query.append(orderByFields[i]);
3102    
3103                                    if ((i + 1) < orderByFields.length) {
3104                                            if (orderByComparator.isAscending() ^ previous) {
3105                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3106                                            }
3107                                            else {
3108                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3109                                            }
3110                                    }
3111                                    else {
3112                                            if (orderByComparator.isAscending() ^ previous) {
3113                                                    query.append(ORDER_BY_ASC);
3114                                            }
3115                                            else {
3116                                                    query.append(ORDER_BY_DESC);
3117                                            }
3118                                    }
3119                            }
3120                    }
3121    
3122                    else {
3123                            if (getDB().isSupportsInlineDistinct()) {
3124                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3125                            }
3126                            else {
3127                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3128                            }
3129                    }
3130    
3131                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3132                                    DLFileEntry.class.getName(),
3133                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3134    
3135                    SQLQuery q = session.createSQLQuery(sql);
3136    
3137                    q.setFirstResult(0);
3138                    q.setMaxResults(2);
3139    
3140                    if (getDB().isSupportsInlineDistinct()) {
3141                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3142                    }
3143                    else {
3144                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
3145                    }
3146    
3147                    QueryPos qPos = QueryPos.getInstance(q);
3148    
3149                    qPos.add(groupId);
3150    
3151                    qPos.add(userId);
3152    
3153                    if (orderByComparator != null) {
3154                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3155    
3156                            for (Object value : values) {
3157                                    qPos.add(value);
3158                            }
3159                    }
3160    
3161                    List<DLFileEntry> list = q.list();
3162    
3163                    if (list.size() == 2) {
3164                            return list.get(1);
3165                    }
3166                    else {
3167                            return null;
3168                    }
3169            }
3170    
3171            /**
3172             * Returns all the document library file entries where groupId = &#63; and folderId = &#63;.
3173             *
3174             * @param groupId the group ID
3175             * @param folderId the folder ID
3176             * @return the matching document library file entries
3177             * @throws SystemException if a system exception occurred
3178             */
3179            public List<DLFileEntry> findByG_F(long groupId, long folderId)
3180                    throws SystemException {
3181                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
3182                            QueryUtil.ALL_POS, null);
3183            }
3184    
3185            /**
3186             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63;.
3187             *
3188             * <p>
3189             * 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.
3190             * </p>
3191             *
3192             * @param groupId the group ID
3193             * @param folderId the folder ID
3194             * @param start the lower bound of the range of document library file entries
3195             * @param end the upper bound of the range of document library file entries (not inclusive)
3196             * @return the range of matching document library file entries
3197             * @throws SystemException if a system exception occurred
3198             */
3199            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
3200                    int end) throws SystemException {
3201                    return findByG_F(groupId, folderId, start, end, null);
3202            }
3203    
3204            /**
3205             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;.
3206             *
3207             * <p>
3208             * 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.
3209             * </p>
3210             *
3211             * @param groupId the group ID
3212             * @param folderId the folder ID
3213             * @param start the lower bound of the range of document library file entries
3214             * @param end the upper bound of the range of document library file entries (not inclusive)
3215             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3216             * @return the ordered range of matching document library file entries
3217             * @throws SystemException if a system exception occurred
3218             */
3219            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
3220                    int end, OrderByComparator orderByComparator) throws SystemException {
3221                    FinderPath finderPath = null;
3222                    Object[] finderArgs = null;
3223    
3224                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3225                                    (orderByComparator == null)) {
3226                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
3227                            finderArgs = new Object[] { groupId, folderId };
3228                    }
3229                    else {
3230                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
3231                            finderArgs = new Object[] {
3232                                            groupId, folderId,
3233                                            
3234                                            start, end, orderByComparator
3235                                    };
3236                    }
3237    
3238                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3239                                    finderArgs, this);
3240    
3241                    if (list == null) {
3242                            StringBundler query = null;
3243    
3244                            if (orderByComparator != null) {
3245                                    query = new StringBundler(4 +
3246                                                    (orderByComparator.getOrderByFields().length * 3));
3247                            }
3248                            else {
3249                                    query = new StringBundler(4);
3250                            }
3251    
3252                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3253    
3254                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3255    
3256                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3257    
3258                            if (orderByComparator != null) {
3259                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3260                                            orderByComparator);
3261                            }
3262    
3263                            else {
3264                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3265                            }
3266    
3267                            String sql = query.toString();
3268    
3269                            Session session = null;
3270    
3271                            try {
3272                                    session = openSession();
3273    
3274                                    Query q = session.createQuery(sql);
3275    
3276                                    QueryPos qPos = QueryPos.getInstance(q);
3277    
3278                                    qPos.add(groupId);
3279    
3280                                    qPos.add(folderId);
3281    
3282                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3283                                                    start, end);
3284                            }
3285                            catch (Exception e) {
3286                                    throw processException(e);
3287                            }
3288                            finally {
3289                                    if (list == null) {
3290                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3291                                    }
3292                                    else {
3293                                            cacheResult(list);
3294    
3295                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3296                                    }
3297    
3298                                    closeSession(session);
3299                            }
3300                    }
3301    
3302                    return list;
3303            }
3304    
3305            /**
3306             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
3307             *
3308             * <p>
3309             * 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.
3310             * </p>
3311             *
3312             * @param groupId the group ID
3313             * @param folderId the folder ID
3314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3315             * @return the first matching document library file entry
3316             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
3317             * @throws SystemException if a system exception occurred
3318             */
3319            public DLFileEntry findByG_F_First(long groupId, long folderId,
3320                    OrderByComparator orderByComparator)
3321                    throws NoSuchFileEntryException, SystemException {
3322                    List<DLFileEntry> list = findByG_F(groupId, folderId, 0, 1,
3323                                    orderByComparator);
3324    
3325                    if (list.isEmpty()) {
3326                            StringBundler msg = new StringBundler(6);
3327    
3328                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3329    
3330                            msg.append("groupId=");
3331                            msg.append(groupId);
3332    
3333                            msg.append(", folderId=");
3334                            msg.append(folderId);
3335    
3336                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3337    
3338                            throw new NoSuchFileEntryException(msg.toString());
3339                    }
3340                    else {
3341                            return list.get(0);
3342                    }
3343            }
3344    
3345            /**
3346             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
3347             *
3348             * <p>
3349             * 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.
3350             * </p>
3351             *
3352             * @param groupId the group ID
3353             * @param folderId the folder ID
3354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3355             * @return the last matching document library file entry
3356             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
3357             * @throws SystemException if a system exception occurred
3358             */
3359            public DLFileEntry findByG_F_Last(long groupId, long folderId,
3360                    OrderByComparator orderByComparator)
3361                    throws NoSuchFileEntryException, SystemException {
3362                    int count = countByG_F(groupId, folderId);
3363    
3364                    List<DLFileEntry> list = findByG_F(groupId, folderId, count - 1, count,
3365                                    orderByComparator);
3366    
3367                    if (list.isEmpty()) {
3368                            StringBundler msg = new StringBundler(6);
3369    
3370                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3371    
3372                            msg.append("groupId=");
3373                            msg.append(groupId);
3374    
3375                            msg.append(", folderId=");
3376                            msg.append(folderId);
3377    
3378                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3379    
3380                            throw new NoSuchFileEntryException(msg.toString());
3381                    }
3382                    else {
3383                            return list.get(0);
3384                    }
3385            }
3386    
3387            /**
3388             * 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;.
3389             *
3390             * <p>
3391             * 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.
3392             * </p>
3393             *
3394             * @param fileEntryId the primary key of the current document library file entry
3395             * @param groupId the group ID
3396             * @param folderId the folder ID
3397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3398             * @return the previous, current, and next document library file entry
3399             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
3400             * @throws SystemException if a system exception occurred
3401             */
3402            public DLFileEntry[] findByG_F_PrevAndNext(long fileEntryId, long groupId,
3403                    long folderId, OrderByComparator orderByComparator)
3404                    throws NoSuchFileEntryException, SystemException {
3405                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3406    
3407                    Session session = null;
3408    
3409                    try {
3410                            session = openSession();
3411    
3412                            DLFileEntry[] array = new DLFileEntryImpl[3];
3413    
3414                            array[0] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
3415                                            folderId, orderByComparator, true);
3416    
3417                            array[1] = dlFileEntry;
3418    
3419                            array[2] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
3420                                            folderId, orderByComparator, false);
3421    
3422                            return array;
3423                    }
3424                    catch (Exception e) {
3425                            throw processException(e);
3426                    }
3427                    finally {
3428                            closeSession(session);
3429                    }
3430            }
3431    
3432            protected DLFileEntry getByG_F_PrevAndNext(Session session,
3433                    DLFileEntry dlFileEntry, long groupId, long folderId,
3434                    OrderByComparator orderByComparator, boolean previous) {
3435                    StringBundler query = null;
3436    
3437                    if (orderByComparator != null) {
3438                            query = new StringBundler(6 +
3439                                            (orderByComparator.getOrderByFields().length * 6));
3440                    }
3441                    else {
3442                            query = new StringBundler(3);
3443                    }
3444    
3445                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3446    
3447                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3448    
3449                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3450    
3451                    if (orderByComparator != null) {
3452                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3453    
3454                            if (orderByConditionFields.length > 0) {
3455                                    query.append(WHERE_AND);
3456                            }
3457    
3458                            for (int i = 0; i < orderByConditionFields.length; i++) {
3459                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3460                                    query.append(orderByConditionFields[i]);
3461    
3462                                    if ((i + 1) < orderByConditionFields.length) {
3463                                            if (orderByComparator.isAscending() ^ previous) {
3464                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3465                                            }
3466                                            else {
3467                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3468                                            }
3469                                    }
3470                                    else {
3471                                            if (orderByComparator.isAscending() ^ previous) {
3472                                                    query.append(WHERE_GREATER_THAN);
3473                                            }
3474                                            else {
3475                                                    query.append(WHERE_LESSER_THAN);
3476                                            }
3477                                    }
3478                            }
3479    
3480                            query.append(ORDER_BY_CLAUSE);
3481    
3482                            String[] orderByFields = orderByComparator.getOrderByFields();
3483    
3484                            for (int i = 0; i < orderByFields.length; i++) {
3485                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3486                                    query.append(orderByFields[i]);
3487    
3488                                    if ((i + 1) < orderByFields.length) {
3489                                            if (orderByComparator.isAscending() ^ previous) {
3490                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3491                                            }
3492                                            else {
3493                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3494                                            }
3495                                    }
3496                                    else {
3497                                            if (orderByComparator.isAscending() ^ previous) {
3498                                                    query.append(ORDER_BY_ASC);
3499                                            }
3500                                            else {
3501                                                    query.append(ORDER_BY_DESC);
3502                                            }
3503                                    }
3504                            }
3505                    }
3506    
3507                    else {
3508                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3509                    }
3510    
3511                    String sql = query.toString();
3512    
3513                    Query q = session.createQuery(sql);
3514    
3515                    q.setFirstResult(0);
3516                    q.setMaxResults(2);
3517    
3518                    QueryPos qPos = QueryPos.getInstance(q);
3519    
3520                    qPos.add(groupId);
3521    
3522                    qPos.add(folderId);
3523    
3524                    if (orderByComparator != null) {
3525                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3526    
3527                            for (Object value : values) {
3528                                    qPos.add(value);
3529                            }
3530                    }
3531    
3532                    List<DLFileEntry> list = q.list();
3533    
3534                    if (list.size() == 2) {
3535                            return list.get(1);
3536                    }
3537                    else {
3538                            return null;
3539                    }
3540            }
3541    
3542            /**
3543             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63;.
3544             *
3545             * <p>
3546             * 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.
3547             * </p>
3548             *
3549             * @param groupId the group ID
3550             * @param folderIds the folder IDs
3551             * @return the matching document library file entries
3552             * @throws SystemException if a system exception occurred
3553             */
3554            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds)
3555                    throws SystemException {
3556                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3557                            QueryUtil.ALL_POS, null);
3558            }
3559    
3560            /**
3561             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
3562             *
3563             * <p>
3564             * 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.
3565             * </p>
3566             *
3567             * @param groupId the group ID
3568             * @param folderIds the folder IDs
3569             * @param start the lower bound of the range of document library file entries
3570             * @param end the upper bound of the range of document library file entries (not inclusive)
3571             * @return the range of matching document library file entries
3572             * @throws SystemException if a system exception occurred
3573             */
3574            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
3575                    int start, int end) throws SystemException {
3576                    return findByG_F(groupId, folderIds, start, end, null);
3577            }
3578    
3579            /**
3580             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
3581             *
3582             * <p>
3583             * 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.
3584             * </p>
3585             *
3586             * @param groupId the group ID
3587             * @param folderIds the folder IDs
3588             * @param start the lower bound of the range of document library file entries
3589             * @param end the upper bound of the range of document library file entries (not inclusive)
3590             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3591             * @return the ordered range of matching document library file entries
3592             * @throws SystemException if a system exception occurred
3593             */
3594            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
3595                    int start, int end, OrderByComparator orderByComparator)
3596                    throws SystemException {
3597                    FinderPath finderPath = null;
3598                    Object[] finderArgs = null;
3599    
3600                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3601                                    (orderByComparator == null)) {
3602                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
3603                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3604                    }
3605                    else {
3606                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
3607                            finderArgs = new Object[] {
3608                                            groupId, StringUtil.merge(folderIds),
3609                                            
3610                                            start, end, orderByComparator
3611                                    };
3612                    }
3613    
3614                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3615                                    finderArgs, this);
3616    
3617                    if (list == null) {
3618                            StringBundler query = new StringBundler();
3619    
3620                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3621    
3622                            boolean conjunctionable = false;
3623    
3624                            if (conjunctionable) {
3625                                    query.append(WHERE_AND);
3626                            }
3627    
3628                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3629    
3630                            conjunctionable = true;
3631    
3632                            if ((folderIds == null) || (folderIds.length > 0)) {
3633                                    if (conjunctionable) {
3634                                            query.append(WHERE_AND);
3635                                    }
3636    
3637                                    query.append(StringPool.OPEN_PARENTHESIS);
3638    
3639                                    for (int i = 0; i < folderIds.length; i++) {
3640                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3641    
3642                                            if ((i + 1) < folderIds.length) {
3643                                                    query.append(WHERE_OR);
3644                                            }
3645                                    }
3646    
3647                                    query.append(StringPool.CLOSE_PARENTHESIS);
3648    
3649                                    conjunctionable = true;
3650                            }
3651    
3652                            if (orderByComparator != null) {
3653                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3654                                            orderByComparator);
3655                            }
3656    
3657                            else {
3658                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3659                            }
3660    
3661                            String sql = query.toString();
3662    
3663                            Session session = null;
3664    
3665                            try {
3666                                    session = openSession();
3667    
3668                                    Query q = session.createQuery(sql);
3669    
3670                                    QueryPos qPos = QueryPos.getInstance(q);
3671    
3672                                    qPos.add(groupId);
3673    
3674                                    if (folderIds != null) {
3675                                            qPos.add(folderIds);
3676                                    }
3677    
3678                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3679                                                    start, end);
3680                            }
3681                            catch (Exception e) {
3682                                    throw processException(e);
3683                            }
3684                            finally {
3685                                    if (list == null) {
3686                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3687                                    }
3688                                    else {
3689                                            cacheResult(list);
3690    
3691                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3692                                    }
3693    
3694                                    closeSession(session);
3695                            }
3696                    }
3697    
3698                    return list;
3699            }
3700    
3701            /**
3702             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3703             *
3704             * @param groupId the group ID
3705             * @param folderId the folder ID
3706             * @return the matching document library file entries that the user has permission to view
3707             * @throws SystemException if a system exception occurred
3708             */
3709            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId)
3710                    throws SystemException {
3711                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
3712                            QueryUtil.ALL_POS, null);
3713            }
3714    
3715            /**
3716             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3717             *
3718             * <p>
3719             * 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.
3720             * </p>
3721             *
3722             * @param groupId the group ID
3723             * @param folderId the folder ID
3724             * @param start the lower bound of the range of document library file entries
3725             * @param end the upper bound of the range of document library file entries (not inclusive)
3726             * @return the range of matching document library file entries that the user has permission to view
3727             * @throws SystemException if a system exception occurred
3728             */
3729            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
3730                    int start, int end) throws SystemException {
3731                    return filterFindByG_F(groupId, folderId, start, end, null);
3732            }
3733    
3734            /**
3735             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
3736             *
3737             * <p>
3738             * 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.
3739             * </p>
3740             *
3741             * @param groupId the group ID
3742             * @param folderId the folder ID
3743             * @param start the lower bound of the range of document library file entries
3744             * @param end the upper bound of the range of document library file entries (not inclusive)
3745             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3746             * @return the ordered range of matching document library file entries that the user has permission to view
3747             * @throws SystemException if a system exception occurred
3748             */
3749            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
3750                    int start, int end, OrderByComparator orderByComparator)
3751                    throws SystemException {
3752                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3753                            return findByG_F(groupId, folderId, start, end, orderByComparator);
3754                    }
3755    
3756                    StringBundler query = null;
3757    
3758                    if (orderByComparator != null) {
3759                            query = new StringBundler(4 +
3760                                            (orderByComparator.getOrderByFields().length * 3));
3761                    }
3762                    else {
3763                            query = new StringBundler(4);
3764                    }
3765    
3766                    if (getDB().isSupportsInlineDistinct()) {
3767                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3768                    }
3769                    else {
3770                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3771                    }
3772    
3773                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3774    
3775                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3776    
3777                    if (!getDB().isSupportsInlineDistinct()) {
3778                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3779                    }
3780    
3781                    if (orderByComparator != null) {
3782                            if (getDB().isSupportsInlineDistinct()) {
3783                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3784                                            orderByComparator);
3785                            }
3786                            else {
3787                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3788                                            orderByComparator);
3789                            }
3790                    }
3791    
3792                    else {
3793                            if (getDB().isSupportsInlineDistinct()) {
3794                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3795                            }
3796                            else {
3797                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3798                            }
3799                    }
3800    
3801                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3802                                    DLFileEntry.class.getName(),
3803                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3804    
3805                    Session session = null;
3806    
3807                    try {
3808                            session = openSession();
3809    
3810                            SQLQuery q = session.createSQLQuery(sql);
3811    
3812                            if (getDB().isSupportsInlineDistinct()) {
3813                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3814                            }
3815                            else {
3816                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
3817                            }
3818    
3819                            QueryPos qPos = QueryPos.getInstance(q);
3820    
3821                            qPos.add(groupId);
3822    
3823                            qPos.add(folderId);
3824    
3825                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3826                    }
3827                    catch (Exception e) {
3828                            throw processException(e);
3829                    }
3830                    finally {
3831                            closeSession(session);
3832                    }
3833            }
3834    
3835            /**
3836             * 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;.
3837             *
3838             * @param fileEntryId the primary key of the current document library file entry
3839             * @param groupId the group ID
3840             * @param folderId the folder ID
3841             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3842             * @return the previous, current, and next document library file entry
3843             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
3844             * @throws SystemException if a system exception occurred
3845             */
3846            public DLFileEntry[] filterFindByG_F_PrevAndNext(long fileEntryId,
3847                    long groupId, long folderId, OrderByComparator orderByComparator)
3848                    throws NoSuchFileEntryException, SystemException {
3849                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3850                            return findByG_F_PrevAndNext(fileEntryId, groupId, folderId,
3851                                    orderByComparator);
3852                    }
3853    
3854                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3855    
3856                    Session session = null;
3857    
3858                    try {
3859                            session = openSession();
3860    
3861                            DLFileEntry[] array = new DLFileEntryImpl[3];
3862    
3863                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
3864                                            groupId, folderId, orderByComparator, true);
3865    
3866                            array[1] = dlFileEntry;
3867    
3868                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
3869                                            groupId, folderId, orderByComparator, false);
3870    
3871                            return array;
3872                    }
3873                    catch (Exception e) {
3874                            throw processException(e);
3875                    }
3876                    finally {
3877                            closeSession(session);
3878                    }
3879            }
3880    
3881            protected DLFileEntry filterGetByG_F_PrevAndNext(Session session,
3882                    DLFileEntry dlFileEntry, long groupId, long folderId,
3883                    OrderByComparator orderByComparator, boolean previous) {
3884                    StringBundler query = null;
3885    
3886                    if (orderByComparator != null) {
3887                            query = new StringBundler(6 +
3888                                            (orderByComparator.getOrderByFields().length * 6));
3889                    }
3890                    else {
3891                            query = new StringBundler(3);
3892                    }
3893    
3894                    if (getDB().isSupportsInlineDistinct()) {
3895                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3896                    }
3897                    else {
3898                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3899                    }
3900    
3901                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3902    
3903                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3904    
3905                    if (!getDB().isSupportsInlineDistinct()) {
3906                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3907                    }
3908    
3909                    if (orderByComparator != null) {
3910                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3911    
3912                            if (orderByConditionFields.length > 0) {
3913                                    query.append(WHERE_AND);
3914                            }
3915    
3916                            for (int i = 0; i < orderByConditionFields.length; i++) {
3917                                    if (getDB().isSupportsInlineDistinct()) {
3918                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3919                                    }
3920                                    else {
3921                                            query.append(_ORDER_BY_ENTITY_TABLE);
3922                                    }
3923    
3924                                    query.append(orderByConditionFields[i]);
3925    
3926                                    if ((i + 1) < orderByConditionFields.length) {
3927                                            if (orderByComparator.isAscending() ^ previous) {
3928                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3929                                            }
3930                                            else {
3931                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3932                                            }
3933                                    }
3934                                    else {
3935                                            if (orderByComparator.isAscending() ^ previous) {
3936                                                    query.append(WHERE_GREATER_THAN);
3937                                            }
3938                                            else {
3939                                                    query.append(WHERE_LESSER_THAN);
3940                                            }
3941                                    }
3942                            }
3943    
3944                            query.append(ORDER_BY_CLAUSE);
3945    
3946                            String[] orderByFields = orderByComparator.getOrderByFields();
3947    
3948                            for (int i = 0; i < orderByFields.length; i++) {
3949                                    if (getDB().isSupportsInlineDistinct()) {
3950                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3951                                    }
3952                                    else {
3953                                            query.append(_ORDER_BY_ENTITY_TABLE);
3954                                    }
3955    
3956                                    query.append(orderByFields[i]);
3957    
3958                                    if ((i + 1) < orderByFields.length) {
3959                                            if (orderByComparator.isAscending() ^ previous) {
3960                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3961                                            }
3962                                            else {
3963                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3964                                            }
3965                                    }
3966                                    else {
3967                                            if (orderByComparator.isAscending() ^ previous) {
3968                                                    query.append(ORDER_BY_ASC);
3969                                            }
3970                                            else {
3971                                                    query.append(ORDER_BY_DESC);
3972                                            }
3973                                    }
3974                            }
3975                    }
3976    
3977                    else {
3978                            if (getDB().isSupportsInlineDistinct()) {
3979                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3980                            }
3981                            else {
3982                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3983                            }
3984                    }
3985    
3986                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3987                                    DLFileEntry.class.getName(),
3988                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3989    
3990                    SQLQuery q = session.createSQLQuery(sql);
3991    
3992                    q.setFirstResult(0);
3993                    q.setMaxResults(2);
3994    
3995                    if (getDB().isSupportsInlineDistinct()) {
3996                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3997                    }
3998                    else {
3999                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4000                    }
4001    
4002                    QueryPos qPos = QueryPos.getInstance(q);
4003    
4004                    qPos.add(groupId);
4005    
4006                    qPos.add(folderId);
4007    
4008                    if (orderByComparator != null) {
4009                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4010    
4011                            for (Object value : values) {
4012                                    qPos.add(value);
4013                            }
4014                    }
4015    
4016                    List<DLFileEntry> list = q.list();
4017    
4018                    if (list.size() == 2) {
4019                            return list.get(1);
4020                    }
4021                    else {
4022                            return null;
4023                    }
4024            }
4025    
4026            /**
4027             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4028             *
4029             * @param groupId the group ID
4030             * @param folderIds the folder IDs
4031             * @return the matching document library file entries that the user has permission to view
4032             * @throws SystemException if a system exception occurred
4033             */
4034            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds)
4035                    throws SystemException {
4036                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
4037                            QueryUtil.ALL_POS, null);
4038            }
4039    
4040            /**
4041             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4042             *
4043             * <p>
4044             * 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.
4045             * </p>
4046             *
4047             * @param groupId the group ID
4048             * @param folderIds the folder IDs
4049             * @param start the lower bound of the range of document library file entries
4050             * @param end the upper bound of the range of document library file entries (not inclusive)
4051             * @return the range of matching document library file entries that the user has permission to view
4052             * @throws SystemException if a system exception occurred
4053             */
4054            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
4055                    int start, int end) throws SystemException {
4056                    return filterFindByG_F(groupId, folderIds, start, end, null);
4057            }
4058    
4059            /**
4060             * 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;.
4061             *
4062             * <p>
4063             * 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.
4064             * </p>
4065             *
4066             * @param groupId the group ID
4067             * @param folderIds the folder IDs
4068             * @param start the lower bound of the range of document library file entries
4069             * @param end the upper bound of the range of document library file entries (not inclusive)
4070             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4071             * @return the ordered range of matching document library file entries that the user has permission to view
4072             * @throws SystemException if a system exception occurred
4073             */
4074            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
4075                    int start, int end, OrderByComparator orderByComparator)
4076                    throws SystemException {
4077                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4078                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
4079                    }
4080    
4081                    StringBundler query = new StringBundler();
4082    
4083                    if (getDB().isSupportsInlineDistinct()) {
4084                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4085                    }
4086                    else {
4087                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4088                    }
4089    
4090                    boolean conjunctionable = false;
4091    
4092                    if (conjunctionable) {
4093                            query.append(WHERE_AND);
4094                    }
4095    
4096                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
4097    
4098                    conjunctionable = true;
4099    
4100                    if ((folderIds == null) || (folderIds.length > 0)) {
4101                            if (conjunctionable) {
4102                                    query.append(WHERE_AND);
4103                            }
4104    
4105                            query.append(StringPool.OPEN_PARENTHESIS);
4106    
4107                            for (int i = 0; i < folderIds.length; i++) {
4108                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
4109    
4110                                    if ((i + 1) < folderIds.length) {
4111                                            query.append(WHERE_OR);
4112                                    }
4113                            }
4114    
4115                            query.append(StringPool.CLOSE_PARENTHESIS);
4116    
4117                            conjunctionable = true;
4118                    }
4119    
4120                    if (!getDB().isSupportsInlineDistinct()) {
4121                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4122                    }
4123    
4124                    if (orderByComparator != null) {
4125                            if (getDB().isSupportsInlineDistinct()) {
4126                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4127                                            orderByComparator);
4128                            }
4129                            else {
4130                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4131                                            orderByComparator);
4132                            }
4133                    }
4134    
4135                    else {
4136                            if (getDB().isSupportsInlineDistinct()) {
4137                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4138                            }
4139                            else {
4140                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4141                            }
4142                    }
4143    
4144                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4145                                    DLFileEntry.class.getName(),
4146                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4147    
4148                    Session session = null;
4149    
4150                    try {
4151                            session = openSession();
4152    
4153                            SQLQuery q = session.createSQLQuery(sql);
4154    
4155                            if (getDB().isSupportsInlineDistinct()) {
4156                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4157                            }
4158                            else {
4159                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4160                            }
4161    
4162                            QueryPos qPos = QueryPos.getInstance(q);
4163    
4164                            qPos.add(groupId);
4165    
4166                            if (folderIds != null) {
4167                                    qPos.add(folderIds);
4168                            }
4169    
4170                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
4171                    }
4172                    catch (Exception e) {
4173                            throw processException(e);
4174                    }
4175                    finally {
4176                            closeSession(session);
4177                    }
4178            }
4179    
4180            /**
4181             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4182             *
4183             * @param groupId the group ID
4184             * @param userId the user ID
4185             * @param folderId the folder ID
4186             * @return the matching document library file entries
4187             * @throws SystemException if a system exception occurred
4188             */
4189            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4190                    long folderId) throws SystemException {
4191                    return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
4192                            QueryUtil.ALL_POS, null);
4193            }
4194    
4195            /**
4196             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4197             *
4198             * <p>
4199             * 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.
4200             * </p>
4201             *
4202             * @param groupId the group ID
4203             * @param userId the user ID
4204             * @param folderId the folder ID
4205             * @param start the lower bound of the range of document library file entries
4206             * @param end the upper bound of the range of document library file entries (not inclusive)
4207             * @return the range of matching document library file entries
4208             * @throws SystemException if a system exception occurred
4209             */
4210            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4211                    long folderId, int start, int end) throws SystemException {
4212                    return findByG_U_F(groupId, userId, folderId, start, end, null);
4213            }
4214    
4215            /**
4216             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4217             *
4218             * <p>
4219             * 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.
4220             * </p>
4221             *
4222             * @param groupId the group ID
4223             * @param userId the user ID
4224             * @param folderId the folder ID
4225             * @param start the lower bound of the range of document library file entries
4226             * @param end the upper bound of the range of document library file entries (not inclusive)
4227             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4228             * @return the ordered range of matching document library file entries
4229             * @throws SystemException if a system exception occurred
4230             */
4231            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4232                    long folderId, int start, int end, OrderByComparator orderByComparator)
4233                    throws SystemException {
4234                    FinderPath finderPath = null;
4235                    Object[] finderArgs = null;
4236    
4237                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4238                                    (orderByComparator == null)) {
4239                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
4240                            finderArgs = new Object[] { groupId, userId, folderId };
4241                    }
4242                    else {
4243                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
4244                            finderArgs = new Object[] {
4245                                            groupId, userId, folderId,
4246                                            
4247                                            start, end, orderByComparator
4248                                    };
4249                    }
4250    
4251                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
4252                                    finderArgs, this);
4253    
4254                    if (list == null) {
4255                            StringBundler query = null;
4256    
4257                            if (orderByComparator != null) {
4258                                    query = new StringBundler(5 +
4259                                                    (orderByComparator.getOrderByFields().length * 3));
4260                            }
4261                            else {
4262                                    query = new StringBundler(5);
4263                            }
4264    
4265                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4266    
4267                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4268    
4269                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4270    
4271                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4272    
4273                            if (orderByComparator != null) {
4274                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4275                                            orderByComparator);
4276                            }
4277    
4278                            else {
4279                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4280                            }
4281    
4282                            String sql = query.toString();
4283    
4284                            Session session = null;
4285    
4286                            try {
4287                                    session = openSession();
4288    
4289                                    Query q = session.createQuery(sql);
4290    
4291                                    QueryPos qPos = QueryPos.getInstance(q);
4292    
4293                                    qPos.add(groupId);
4294    
4295                                    qPos.add(userId);
4296    
4297                                    qPos.add(folderId);
4298    
4299                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4300                                                    start, end);
4301                            }
4302                            catch (Exception e) {
4303                                    throw processException(e);
4304                            }
4305                            finally {
4306                                    if (list == null) {
4307                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4308                                    }
4309                                    else {
4310                                            cacheResult(list);
4311    
4312                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4313                                    }
4314    
4315                                    closeSession(session);
4316                            }
4317                    }
4318    
4319                    return list;
4320            }
4321    
4322            /**
4323             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
4324             *
4325             * <p>
4326             * 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.
4327             * </p>
4328             *
4329             * @param groupId the group ID
4330             * @param userId the user ID
4331             * @param folderId the folder ID
4332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4333             * @return the first matching document library file entry
4334             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
4335             * @throws SystemException if a system exception occurred
4336             */
4337            public DLFileEntry findByG_U_F_First(long groupId, long userId,
4338                    long folderId, OrderByComparator orderByComparator)
4339                    throws NoSuchFileEntryException, SystemException {
4340                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
4341                                    orderByComparator);
4342    
4343                    if (list.isEmpty()) {
4344                            StringBundler msg = new StringBundler(8);
4345    
4346                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4347    
4348                            msg.append("groupId=");
4349                            msg.append(groupId);
4350    
4351                            msg.append(", userId=");
4352                            msg.append(userId);
4353    
4354                            msg.append(", folderId=");
4355                            msg.append(folderId);
4356    
4357                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4358    
4359                            throw new NoSuchFileEntryException(msg.toString());
4360                    }
4361                    else {
4362                            return list.get(0);
4363                    }
4364            }
4365    
4366            /**
4367             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
4368             *
4369             * <p>
4370             * 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.
4371             * </p>
4372             *
4373             * @param groupId the group ID
4374             * @param userId the user ID
4375             * @param folderId the folder ID
4376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4377             * @return the last matching document library file entry
4378             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
4379             * @throws SystemException if a system exception occurred
4380             */
4381            public DLFileEntry findByG_U_F_Last(long groupId, long userId,
4382                    long folderId, OrderByComparator orderByComparator)
4383                    throws NoSuchFileEntryException, SystemException {
4384                    int count = countByG_U_F(groupId, userId, folderId);
4385    
4386                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
4387                                    count - 1, count, orderByComparator);
4388    
4389                    if (list.isEmpty()) {
4390                            StringBundler msg = new StringBundler(8);
4391    
4392                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4393    
4394                            msg.append("groupId=");
4395                            msg.append(groupId);
4396    
4397                            msg.append(", userId=");
4398                            msg.append(userId);
4399    
4400                            msg.append(", folderId=");
4401                            msg.append(folderId);
4402    
4403                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4404    
4405                            throw new NoSuchFileEntryException(msg.toString());
4406                    }
4407                    else {
4408                            return list.get(0);
4409                    }
4410            }
4411    
4412            /**
4413             * 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;.
4414             *
4415             * <p>
4416             * 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.
4417             * </p>
4418             *
4419             * @param fileEntryId the primary key of the current document library file entry
4420             * @param groupId the group ID
4421             * @param userId the user ID
4422             * @param folderId the folder ID
4423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4424             * @return the previous, current, and next document library file entry
4425             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
4426             * @throws SystemException if a system exception occurred
4427             */
4428            public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
4429                    long groupId, long userId, long folderId,
4430                    OrderByComparator orderByComparator)
4431                    throws NoSuchFileEntryException, SystemException {
4432                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4433    
4434                    Session session = null;
4435    
4436                    try {
4437                            session = openSession();
4438    
4439                            DLFileEntry[] array = new DLFileEntryImpl[3];
4440    
4441                            array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
4442                                            userId, folderId, orderByComparator, true);
4443    
4444                            array[1] = dlFileEntry;
4445    
4446                            array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
4447                                            userId, folderId, orderByComparator, false);
4448    
4449                            return array;
4450                    }
4451                    catch (Exception e) {
4452                            throw processException(e);
4453                    }
4454                    finally {
4455                            closeSession(session);
4456                    }
4457            }
4458    
4459            protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
4460                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
4461                    OrderByComparator orderByComparator, boolean previous) {
4462                    StringBundler query = null;
4463    
4464                    if (orderByComparator != null) {
4465                            query = new StringBundler(6 +
4466                                            (orderByComparator.getOrderByFields().length * 6));
4467                    }
4468                    else {
4469                            query = new StringBundler(3);
4470                    }
4471    
4472                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4473    
4474                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4475    
4476                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4477    
4478                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4479    
4480                    if (orderByComparator != null) {
4481                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4482    
4483                            if (orderByConditionFields.length > 0) {
4484                                    query.append(WHERE_AND);
4485                            }
4486    
4487                            for (int i = 0; i < orderByConditionFields.length; i++) {
4488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4489                                    query.append(orderByConditionFields[i]);
4490    
4491                                    if ((i + 1) < orderByConditionFields.length) {
4492                                            if (orderByComparator.isAscending() ^ previous) {
4493                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4494                                            }
4495                                            else {
4496                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4497                                            }
4498                                    }
4499                                    else {
4500                                            if (orderByComparator.isAscending() ^ previous) {
4501                                                    query.append(WHERE_GREATER_THAN);
4502                                            }
4503                                            else {
4504                                                    query.append(WHERE_LESSER_THAN);
4505                                            }
4506                                    }
4507                            }
4508    
4509                            query.append(ORDER_BY_CLAUSE);
4510    
4511                            String[] orderByFields = orderByComparator.getOrderByFields();
4512    
4513                            for (int i = 0; i < orderByFields.length; i++) {
4514                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4515                                    query.append(orderByFields[i]);
4516    
4517                                    if ((i + 1) < orderByFields.length) {
4518                                            if (orderByComparator.isAscending() ^ previous) {
4519                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4520                                            }
4521                                            else {
4522                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4523                                            }
4524                                    }
4525                                    else {
4526                                            if (orderByComparator.isAscending() ^ previous) {
4527                                                    query.append(ORDER_BY_ASC);
4528                                            }
4529                                            else {
4530                                                    query.append(ORDER_BY_DESC);
4531                                            }
4532                                    }
4533                            }
4534                    }
4535    
4536                    else {
4537                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4538                    }
4539    
4540                    String sql = query.toString();
4541    
4542                    Query q = session.createQuery(sql);
4543    
4544                    q.setFirstResult(0);
4545                    q.setMaxResults(2);
4546    
4547                    QueryPos qPos = QueryPos.getInstance(q);
4548    
4549                    qPos.add(groupId);
4550    
4551                    qPos.add(userId);
4552    
4553                    qPos.add(folderId);
4554    
4555                    if (orderByComparator != null) {
4556                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4557    
4558                            for (Object value : values) {
4559                                    qPos.add(value);
4560                            }
4561                    }
4562    
4563                    List<DLFileEntry> list = q.list();
4564    
4565                    if (list.size() == 2) {
4566                            return list.get(1);
4567                    }
4568                    else {
4569                            return null;
4570                    }
4571            }
4572    
4573            /**
4574             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4575             *
4576             * <p>
4577             * 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.
4578             * </p>
4579             *
4580             * @param groupId the group ID
4581             * @param userId the user ID
4582             * @param folderIds the folder IDs
4583             * @return the matching document library file entries
4584             * @throws SystemException if a system exception occurred
4585             */
4586            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4587                    long[] folderIds) throws SystemException {
4588                    return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
4589                            QueryUtil.ALL_POS, null);
4590            }
4591    
4592            /**
4593             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4594             *
4595             * <p>
4596             * 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.
4597             * </p>
4598             *
4599             * @param groupId the group ID
4600             * @param userId the user ID
4601             * @param folderIds the folder IDs
4602             * @param start the lower bound of the range of document library file entries
4603             * @param end the upper bound of the range of document library file entries (not inclusive)
4604             * @return the range of matching document library file entries
4605             * @throws SystemException if a system exception occurred
4606             */
4607            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4608                    long[] folderIds, int start, int end) throws SystemException {
4609                    return findByG_U_F(groupId, userId, folderIds, start, end, null);
4610            }
4611    
4612            /**
4613             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4614             *
4615             * <p>
4616             * 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.
4617             * </p>
4618             *
4619             * @param groupId the group ID
4620             * @param userId the user ID
4621             * @param folderIds the folder IDs
4622             * @param start the lower bound of the range of document library file entries
4623             * @param end the upper bound of the range of document library file entries (not inclusive)
4624             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4625             * @return the ordered range of matching document library file entries
4626             * @throws SystemException if a system exception occurred
4627             */
4628            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4629                    long[] folderIds, int start, int end,
4630                    OrderByComparator orderByComparator) throws SystemException {
4631                    FinderPath finderPath = null;
4632                    Object[] finderArgs = null;
4633    
4634                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4635                                    (orderByComparator == null)) {
4636                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
4637                            finderArgs = new Object[] {
4638                                            groupId, userId, StringUtil.merge(folderIds)
4639                                    };
4640                    }
4641                    else {
4642                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
4643                            finderArgs = new Object[] {
4644                                            groupId, userId, StringUtil.merge(folderIds),
4645                                            
4646                                            start, end, orderByComparator
4647                                    };
4648                    }
4649    
4650                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
4651                                    finderArgs, this);
4652    
4653                    if (list == null) {
4654                            StringBundler query = new StringBundler();
4655    
4656                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4657    
4658                            boolean conjunctionable = false;
4659    
4660                            if (conjunctionable) {
4661                                    query.append(WHERE_AND);
4662                            }
4663    
4664                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
4665    
4666                            conjunctionable = true;
4667    
4668                            if (conjunctionable) {
4669                                    query.append(WHERE_AND);
4670                            }
4671    
4672                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
4673    
4674                            conjunctionable = true;
4675    
4676                            if ((folderIds == null) || (folderIds.length > 0)) {
4677                                    if (conjunctionable) {
4678                                            query.append(WHERE_AND);
4679                                    }
4680    
4681                                    query.append(StringPool.OPEN_PARENTHESIS);
4682    
4683                                    for (int i = 0; i < folderIds.length; i++) {
4684                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
4685    
4686                                            if ((i + 1) < folderIds.length) {
4687                                                    query.append(WHERE_OR);
4688                                            }
4689                                    }
4690    
4691                                    query.append(StringPool.CLOSE_PARENTHESIS);
4692    
4693                                    conjunctionable = true;
4694                            }
4695    
4696                            if (orderByComparator != null) {
4697                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4698                                            orderByComparator);
4699                            }
4700    
4701                            else {
4702                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4703                            }
4704    
4705                            String sql = query.toString();
4706    
4707                            Session session = null;
4708    
4709                            try {
4710                                    session = openSession();
4711    
4712                                    Query q = session.createQuery(sql);
4713    
4714                                    QueryPos qPos = QueryPos.getInstance(q);
4715    
4716                                    qPos.add(groupId);
4717    
4718                                    qPos.add(userId);
4719    
4720                                    if (folderIds != null) {
4721                                            qPos.add(folderIds);
4722                                    }
4723    
4724                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4725                                                    start, end);
4726                            }
4727                            catch (Exception e) {
4728                                    throw processException(e);
4729                            }
4730                            finally {
4731                                    if (list == null) {
4732                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4733                                    }
4734                                    else {
4735                                            cacheResult(list);
4736    
4737                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4738                                    }
4739    
4740                                    closeSession(session);
4741                            }
4742                    }
4743    
4744                    return list;
4745            }
4746    
4747            /**
4748             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
4749             *
4750             * @param groupId the group ID
4751             * @param userId the user ID
4752             * @param folderId the folder ID
4753             * @return the matching document library file entries that the user has permission to view
4754             * @throws SystemException if a system exception occurred
4755             */
4756            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4757                    long folderId) throws SystemException {
4758                    return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
4759                            QueryUtil.ALL_POS, null);
4760            }
4761    
4762            /**
4763             * 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;.
4764             *
4765             * <p>
4766             * 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.
4767             * </p>
4768             *
4769             * @param groupId the group ID
4770             * @param userId the user ID
4771             * @param folderId the folder ID
4772             * @param start the lower bound of the range of document library file entries
4773             * @param end the upper bound of the range of document library file entries (not inclusive)
4774             * @return the range of matching document library file entries that the user has permission to view
4775             * @throws SystemException if a system exception occurred
4776             */
4777            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4778                    long folderId, int start, int end) throws SystemException {
4779                    return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
4780            }
4781    
4782            /**
4783             * 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;.
4784             *
4785             * <p>
4786             * 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.
4787             * </p>
4788             *
4789             * @param groupId the group ID
4790             * @param userId the user ID
4791             * @param folderId the folder ID
4792             * @param start the lower bound of the range of document library file entries
4793             * @param end the upper bound of the range of document library file entries (not inclusive)
4794             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4795             * @return the ordered range of matching document library file entries that the user has permission to view
4796             * @throws SystemException if a system exception occurred
4797             */
4798            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4799                    long folderId, int start, int end, OrderByComparator orderByComparator)
4800                    throws SystemException {
4801                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4802                            return findByG_U_F(groupId, userId, folderId, start, end,
4803                                    orderByComparator);
4804                    }
4805    
4806                    StringBundler query = null;
4807    
4808                    if (orderByComparator != null) {
4809                            query = new StringBundler(5 +
4810                                            (orderByComparator.getOrderByFields().length * 3));
4811                    }
4812                    else {
4813                            query = new StringBundler(5);
4814                    }
4815    
4816                    if (getDB().isSupportsInlineDistinct()) {
4817                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4818                    }
4819                    else {
4820                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4821                    }
4822    
4823                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4824    
4825                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4826    
4827                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4828    
4829                    if (!getDB().isSupportsInlineDistinct()) {
4830                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4831                    }
4832    
4833                    if (orderByComparator != null) {
4834                            if (getDB().isSupportsInlineDistinct()) {
4835                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4836                                            orderByComparator);
4837                            }
4838                            else {
4839                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4840                                            orderByComparator);
4841                            }
4842                    }
4843    
4844                    else {
4845                            if (getDB().isSupportsInlineDistinct()) {
4846                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4847                            }
4848                            else {
4849                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4850                            }
4851                    }
4852    
4853                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4854                                    DLFileEntry.class.getName(),
4855                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4856    
4857                    Session session = null;
4858    
4859                    try {
4860                            session = openSession();
4861    
4862                            SQLQuery q = session.createSQLQuery(sql);
4863    
4864                            if (getDB().isSupportsInlineDistinct()) {
4865                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4866                            }
4867                            else {
4868                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4869                            }
4870    
4871                            QueryPos qPos = QueryPos.getInstance(q);
4872    
4873                            qPos.add(groupId);
4874    
4875                            qPos.add(userId);
4876    
4877                            qPos.add(folderId);
4878    
4879                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
4880                    }
4881                    catch (Exception e) {
4882                            throw processException(e);
4883                    }
4884                    finally {
4885                            closeSession(session);
4886                    }
4887            }
4888    
4889            /**
4890             * 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;.
4891             *
4892             * @param fileEntryId the primary key of the current document library file entry
4893             * @param groupId the group ID
4894             * @param userId the user ID
4895             * @param folderId the folder ID
4896             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4897             * @return the previous, current, and next document library file entry
4898             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
4899             * @throws SystemException if a system exception occurred
4900             */
4901            public DLFileEntry[] filterFindByG_U_F_PrevAndNext(long fileEntryId,
4902                    long groupId, long userId, long folderId,
4903                    OrderByComparator orderByComparator)
4904                    throws NoSuchFileEntryException, SystemException {
4905                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4906                            return findByG_U_F_PrevAndNext(fileEntryId, groupId, userId,
4907                                    folderId, orderByComparator);
4908                    }
4909    
4910                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4911    
4912                    Session session = null;
4913    
4914                    try {
4915                            session = openSession();
4916    
4917                            DLFileEntry[] array = new DLFileEntryImpl[3];
4918    
4919                            array[0] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
4920                                            groupId, userId, folderId, orderByComparator, true);
4921    
4922                            array[1] = dlFileEntry;
4923    
4924                            array[2] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
4925                                            groupId, userId, folderId, orderByComparator, false);
4926    
4927                            return array;
4928                    }
4929                    catch (Exception e) {
4930                            throw processException(e);
4931                    }
4932                    finally {
4933                            closeSession(session);
4934                    }
4935            }
4936    
4937            protected DLFileEntry filterGetByG_U_F_PrevAndNext(Session session,
4938                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
4939                    OrderByComparator orderByComparator, boolean previous) {
4940                    StringBundler query = null;
4941    
4942                    if (orderByComparator != null) {
4943                            query = new StringBundler(6 +
4944                                            (orderByComparator.getOrderByFields().length * 6));
4945                    }
4946                    else {
4947                            query = new StringBundler(3);
4948                    }
4949    
4950                    if (getDB().isSupportsInlineDistinct()) {
4951                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4952                    }
4953                    else {
4954                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4955                    }
4956    
4957                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4958    
4959                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4960    
4961                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4962    
4963                    if (!getDB().isSupportsInlineDistinct()) {
4964                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4965                    }
4966    
4967                    if (orderByComparator != null) {
4968                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4969    
4970                            if (orderByConditionFields.length > 0) {
4971                                    query.append(WHERE_AND);
4972                            }
4973    
4974                            for (int i = 0; i < orderByConditionFields.length; i++) {
4975                                    if (getDB().isSupportsInlineDistinct()) {
4976                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4977                                    }
4978                                    else {
4979                                            query.append(_ORDER_BY_ENTITY_TABLE);
4980                                    }
4981    
4982                                    query.append(orderByConditionFields[i]);
4983    
4984                                    if ((i + 1) < orderByConditionFields.length) {
4985                                            if (orderByComparator.isAscending() ^ previous) {
4986                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4987                                            }
4988                                            else {
4989                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4990                                            }
4991                                    }
4992                                    else {
4993                                            if (orderByComparator.isAscending() ^ previous) {
4994                                                    query.append(WHERE_GREATER_THAN);
4995                                            }
4996                                            else {
4997                                                    query.append(WHERE_LESSER_THAN);
4998                                            }
4999                                    }
5000                            }
5001    
5002                            query.append(ORDER_BY_CLAUSE);
5003    
5004                            String[] orderByFields = orderByComparator.getOrderByFields();
5005    
5006                            for (int i = 0; i < orderByFields.length; i++) {
5007                                    if (getDB().isSupportsInlineDistinct()) {
5008                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5009                                    }
5010                                    else {
5011                                            query.append(_ORDER_BY_ENTITY_TABLE);
5012                                    }
5013    
5014                                    query.append(orderByFields[i]);
5015    
5016                                    if ((i + 1) < orderByFields.length) {
5017                                            if (orderByComparator.isAscending() ^ previous) {
5018                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5019                                            }
5020                                            else {
5021                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5022                                            }
5023                                    }
5024                                    else {
5025                                            if (orderByComparator.isAscending() ^ previous) {
5026                                                    query.append(ORDER_BY_ASC);
5027                                            }
5028                                            else {
5029                                                    query.append(ORDER_BY_DESC);
5030                                            }
5031                                    }
5032                            }
5033                    }
5034    
5035                    else {
5036                            if (getDB().isSupportsInlineDistinct()) {
5037                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5038                            }
5039                            else {
5040                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5041                            }
5042                    }
5043    
5044                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5045                                    DLFileEntry.class.getName(),
5046                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5047    
5048                    SQLQuery q = session.createSQLQuery(sql);
5049    
5050                    q.setFirstResult(0);
5051                    q.setMaxResults(2);
5052    
5053                    if (getDB().isSupportsInlineDistinct()) {
5054                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5055                    }
5056                    else {
5057                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5058                    }
5059    
5060                    QueryPos qPos = QueryPos.getInstance(q);
5061    
5062                    qPos.add(groupId);
5063    
5064                    qPos.add(userId);
5065    
5066                    qPos.add(folderId);
5067    
5068                    if (orderByComparator != null) {
5069                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5070    
5071                            for (Object value : values) {
5072                                    qPos.add(value);
5073                            }
5074                    }
5075    
5076                    List<DLFileEntry> list = q.list();
5077    
5078                    if (list.size() == 2) {
5079                            return list.get(1);
5080                    }
5081                    else {
5082                            return null;
5083                    }
5084            }
5085    
5086            /**
5087             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
5088             *
5089             * @param groupId the group ID
5090             * @param userId the user ID
5091             * @param folderIds the folder IDs
5092             * @return the matching document library file entries that the user has permission to view
5093             * @throws SystemException if a system exception occurred
5094             */
5095            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5096                    long[] folderIds) throws SystemException {
5097                    return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
5098                            QueryUtil.ALL_POS, null);
5099            }
5100    
5101            /**
5102             * 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;.
5103             *
5104             * <p>
5105             * 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.
5106             * </p>
5107             *
5108             * @param groupId the group ID
5109             * @param userId the user ID
5110             * @param folderIds the folder IDs
5111             * @param start the lower bound of the range of document library file entries
5112             * @param end the upper bound of the range of document library file entries (not inclusive)
5113             * @return the range of matching document library file entries that the user has permission to view
5114             * @throws SystemException if a system exception occurred
5115             */
5116            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5117                    long[] folderIds, int start, int end) throws SystemException {
5118                    return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
5119            }
5120    
5121            /**
5122             * 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;.
5123             *
5124             * <p>
5125             * 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.
5126             * </p>
5127             *
5128             * @param groupId the group ID
5129             * @param userId the user ID
5130             * @param folderIds the folder IDs
5131             * @param start the lower bound of the range of document library file entries
5132             * @param end the upper bound of the range of document library file entries (not inclusive)
5133             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5134             * @return the ordered range of matching document library file entries that the user has permission to view
5135             * @throws SystemException if a system exception occurred
5136             */
5137            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5138                    long[] folderIds, int start, int end,
5139                    OrderByComparator orderByComparator) throws SystemException {
5140                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5141                            return findByG_U_F(groupId, userId, folderIds, start, end,
5142                                    orderByComparator);
5143                    }
5144    
5145                    StringBundler query = new StringBundler();
5146    
5147                    if (getDB().isSupportsInlineDistinct()) {
5148                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5149                    }
5150                    else {
5151                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5152                    }
5153    
5154                    boolean conjunctionable = false;
5155    
5156                    if (conjunctionable) {
5157                            query.append(WHERE_AND);
5158                    }
5159    
5160                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
5161    
5162                    conjunctionable = true;
5163    
5164                    if (conjunctionable) {
5165                            query.append(WHERE_AND);
5166                    }
5167    
5168                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
5169    
5170                    conjunctionable = true;
5171    
5172                    if ((folderIds == null) || (folderIds.length > 0)) {
5173                            if (conjunctionable) {
5174                                    query.append(WHERE_AND);
5175                            }
5176    
5177                            query.append(StringPool.OPEN_PARENTHESIS);
5178    
5179                            for (int i = 0; i < folderIds.length; i++) {
5180                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
5181    
5182                                    if ((i + 1) < folderIds.length) {
5183                                            query.append(WHERE_OR);
5184                                    }
5185                            }
5186    
5187                            query.append(StringPool.CLOSE_PARENTHESIS);
5188    
5189                            conjunctionable = true;
5190                    }
5191    
5192                    if (!getDB().isSupportsInlineDistinct()) {
5193                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5194                    }
5195    
5196                    if (orderByComparator != null) {
5197                            if (getDB().isSupportsInlineDistinct()) {
5198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5199                                            orderByComparator);
5200                            }
5201                            else {
5202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5203                                            orderByComparator);
5204                            }
5205                    }
5206    
5207                    else {
5208                            if (getDB().isSupportsInlineDistinct()) {
5209                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5210                            }
5211                            else {
5212                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5213                            }
5214                    }
5215    
5216                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5217                                    DLFileEntry.class.getName(),
5218                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5219    
5220                    Session session = null;
5221    
5222                    try {
5223                            session = openSession();
5224    
5225                            SQLQuery q = session.createSQLQuery(sql);
5226    
5227                            if (getDB().isSupportsInlineDistinct()) {
5228                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5229                            }
5230                            else {
5231                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5232                            }
5233    
5234                            QueryPos qPos = QueryPos.getInstance(q);
5235    
5236                            qPos.add(groupId);
5237    
5238                            qPos.add(userId);
5239    
5240                            if (folderIds != null) {
5241                                    qPos.add(folderIds);
5242                            }
5243    
5244                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
5245                    }
5246                    catch (Exception e) {
5247                            throw processException(e);
5248                    }
5249                    finally {
5250                            closeSession(session);
5251                    }
5252            }
5253    
5254            /**
5255             * 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.
5256             *
5257             * @param groupId the group ID
5258             * @param folderId the folder ID
5259             * @param name the name
5260             * @return the matching document library file entry
5261             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5262             * @throws SystemException if a system exception occurred
5263             */
5264            public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
5265                    throws NoSuchFileEntryException, SystemException {
5266                    DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
5267    
5268                    if (dlFileEntry == null) {
5269                            StringBundler msg = new StringBundler(8);
5270    
5271                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5272    
5273                            msg.append("groupId=");
5274                            msg.append(groupId);
5275    
5276                            msg.append(", folderId=");
5277                            msg.append(folderId);
5278    
5279                            msg.append(", name=");
5280                            msg.append(name);
5281    
5282                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5283    
5284                            if (_log.isWarnEnabled()) {
5285                                    _log.warn(msg.toString());
5286                            }
5287    
5288                            throw new NoSuchFileEntryException(msg.toString());
5289                    }
5290    
5291                    return dlFileEntry;
5292            }
5293    
5294            /**
5295             * 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.
5296             *
5297             * @param groupId the group ID
5298             * @param folderId the folder ID
5299             * @param name the name
5300             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5301             * @throws SystemException if a system exception occurred
5302             */
5303            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name)
5304                    throws SystemException {
5305                    return fetchByG_F_N(groupId, folderId, name, true);
5306            }
5307    
5308            /**
5309             * 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.
5310             *
5311             * @param groupId the group ID
5312             * @param folderId the folder ID
5313             * @param name the name
5314             * @param retrieveFromCache whether to use the finder cache
5315             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5316             * @throws SystemException if a system exception occurred
5317             */
5318            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
5319                    boolean retrieveFromCache) throws SystemException {
5320                    Object[] finderArgs = new Object[] { groupId, folderId, name };
5321    
5322                    Object result = null;
5323    
5324                    if (retrieveFromCache) {
5325                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N,
5326                                            finderArgs, this);
5327                    }
5328    
5329                    if (result == null) {
5330                            StringBundler query = new StringBundler(5);
5331    
5332                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5333    
5334                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
5335    
5336                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
5337    
5338                            if (name == null) {
5339                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
5340                            }
5341                            else {
5342                                    if (name.equals(StringPool.BLANK)) {
5343                                            query.append(_FINDER_COLUMN_G_F_N_NAME_3);
5344                                    }
5345                                    else {
5346                                            query.append(_FINDER_COLUMN_G_F_N_NAME_2);
5347                                    }
5348                            }
5349    
5350                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5351    
5352                            String sql = query.toString();
5353    
5354                            Session session = null;
5355    
5356                            try {
5357                                    session = openSession();
5358    
5359                                    Query q = session.createQuery(sql);
5360    
5361                                    QueryPos qPos = QueryPos.getInstance(q);
5362    
5363                                    qPos.add(groupId);
5364    
5365                                    qPos.add(folderId);
5366    
5367                                    if (name != null) {
5368                                            qPos.add(name);
5369                                    }
5370    
5371                                    List<DLFileEntry> list = q.list();
5372    
5373                                    result = list;
5374    
5375                                    DLFileEntry dlFileEntry = null;
5376    
5377                                    if (list.isEmpty()) {
5378                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
5379                                                    finderArgs, list);
5380                                    }
5381                                    else {
5382                                            dlFileEntry = list.get(0);
5383    
5384                                            cacheResult(dlFileEntry);
5385    
5386                                            if ((dlFileEntry.getGroupId() != groupId) ||
5387                                                            (dlFileEntry.getFolderId() != folderId) ||
5388                                                            (dlFileEntry.getName() == null) ||
5389                                                            !dlFileEntry.getName().equals(name)) {
5390                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
5391                                                            finderArgs, dlFileEntry);
5392                                            }
5393                                    }
5394    
5395                                    return dlFileEntry;
5396                            }
5397                            catch (Exception e) {
5398                                    throw processException(e);
5399                            }
5400                            finally {
5401                                    if (result == null) {
5402                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
5403                                                    finderArgs);
5404                                    }
5405    
5406                                    closeSession(session);
5407                            }
5408                    }
5409                    else {
5410                            if (result instanceof List<?>) {
5411                                    return null;
5412                            }
5413                            else {
5414                                    return (DLFileEntry)result;
5415                            }
5416                    }
5417            }
5418    
5419            /**
5420             * 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.
5421             *
5422             * @param groupId the group ID
5423             * @param folderId the folder ID
5424             * @param title the title
5425             * @return the matching document library file entry
5426             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5427             * @throws SystemException if a system exception occurred
5428             */
5429            public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
5430                    throws NoSuchFileEntryException, SystemException {
5431                    DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
5432    
5433                    if (dlFileEntry == null) {
5434                            StringBundler msg = new StringBundler(8);
5435    
5436                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5437    
5438                            msg.append("groupId=");
5439                            msg.append(groupId);
5440    
5441                            msg.append(", folderId=");
5442                            msg.append(folderId);
5443    
5444                            msg.append(", title=");
5445                            msg.append(title);
5446    
5447                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5448    
5449                            if (_log.isWarnEnabled()) {
5450                                    _log.warn(msg.toString());
5451                            }
5452    
5453                            throw new NoSuchFileEntryException(msg.toString());
5454                    }
5455    
5456                    return dlFileEntry;
5457            }
5458    
5459            /**
5460             * 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.
5461             *
5462             * @param groupId the group ID
5463             * @param folderId the folder ID
5464             * @param title the title
5465             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5466             * @throws SystemException if a system exception occurred
5467             */
5468            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title)
5469                    throws SystemException {
5470                    return fetchByG_F_T(groupId, folderId, title, true);
5471            }
5472    
5473            /**
5474             * 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.
5475             *
5476             * @param groupId the group ID
5477             * @param folderId the folder ID
5478             * @param title the title
5479             * @param retrieveFromCache whether to use the finder cache
5480             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5481             * @throws SystemException if a system exception occurred
5482             */
5483            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
5484                    boolean retrieveFromCache) throws SystemException {
5485                    Object[] finderArgs = new Object[] { groupId, folderId, title };
5486    
5487                    Object result = null;
5488    
5489                    if (retrieveFromCache) {
5490                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_T,
5491                                            finderArgs, this);
5492                    }
5493    
5494                    if (result == null) {
5495                            StringBundler query = new StringBundler(5);
5496    
5497                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5498    
5499                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
5500    
5501                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
5502    
5503                            if (title == null) {
5504                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
5505                            }
5506                            else {
5507                                    if (title.equals(StringPool.BLANK)) {
5508                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
5509                                    }
5510                                    else {
5511                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
5512                                    }
5513                            }
5514    
5515                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5516    
5517                            String sql = query.toString();
5518    
5519                            Session session = null;
5520    
5521                            try {
5522                                    session = openSession();
5523    
5524                                    Query q = session.createQuery(sql);
5525    
5526                                    QueryPos qPos = QueryPos.getInstance(q);
5527    
5528                                    qPos.add(groupId);
5529    
5530                                    qPos.add(folderId);
5531    
5532                                    if (title != null) {
5533                                            qPos.add(title);
5534                                    }
5535    
5536                                    List<DLFileEntry> list = q.list();
5537    
5538                                    result = list;
5539    
5540                                    DLFileEntry dlFileEntry = null;
5541    
5542                                    if (list.isEmpty()) {
5543                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
5544                                                    finderArgs, list);
5545                                    }
5546                                    else {
5547                                            dlFileEntry = list.get(0);
5548    
5549                                            cacheResult(dlFileEntry);
5550    
5551                                            if ((dlFileEntry.getGroupId() != groupId) ||
5552                                                            (dlFileEntry.getFolderId() != folderId) ||
5553                                                            (dlFileEntry.getTitle() == null) ||
5554                                                            !dlFileEntry.getTitle().equals(title)) {
5555                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
5556                                                            finderArgs, dlFileEntry);
5557                                            }
5558                                    }
5559    
5560                                    return dlFileEntry;
5561                            }
5562                            catch (Exception e) {
5563                                    throw processException(e);
5564                            }
5565                            finally {
5566                                    if (result == null) {
5567                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
5568                                                    finderArgs);
5569                                    }
5570    
5571                                    closeSession(session);
5572                            }
5573                    }
5574                    else {
5575                            if (result instanceof List<?>) {
5576                                    return null;
5577                            }
5578                            else {
5579                                    return (DLFileEntry)result;
5580                            }
5581                    }
5582            }
5583    
5584            /**
5585             * Returns all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5586             *
5587             * @param groupId the group ID
5588             * @param folderId the folder ID
5589             * @param fileEntryTypeId the file entry type ID
5590             * @return the matching document library file entries
5591             * @throws SystemException if a system exception occurred
5592             */
5593            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5594                    long fileEntryTypeId) throws SystemException {
5595                    return findByG_F_F(groupId, folderId, fileEntryTypeId,
5596                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5597            }
5598    
5599            /**
5600             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5601             *
5602             * <p>
5603             * 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.
5604             * </p>
5605             *
5606             * @param groupId the group ID
5607             * @param folderId the folder ID
5608             * @param fileEntryTypeId the file entry type ID
5609             * @param start the lower bound of the range of document library file entries
5610             * @param end the upper bound of the range of document library file entries (not inclusive)
5611             * @return the range of matching document library file entries
5612             * @throws SystemException if a system exception occurred
5613             */
5614            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5615                    long fileEntryTypeId, int start, int end) throws SystemException {
5616                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end, null);
5617            }
5618    
5619            /**
5620             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5621             *
5622             * <p>
5623             * 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.
5624             * </p>
5625             *
5626             * @param groupId the group ID
5627             * @param folderId the folder ID
5628             * @param fileEntryTypeId the file entry type ID
5629             * @param start the lower bound of the range of document library file entries
5630             * @param end the upper bound of the range of document library file entries (not inclusive)
5631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5632             * @return the ordered range of matching document library file entries
5633             * @throws SystemException if a system exception occurred
5634             */
5635            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5636                    long fileEntryTypeId, int start, int end,
5637                    OrderByComparator orderByComparator) throws SystemException {
5638                    FinderPath finderPath = null;
5639                    Object[] finderArgs = null;
5640    
5641                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5642                                    (orderByComparator == null)) {
5643                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
5644                            finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
5645                    }
5646                    else {
5647                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
5648                            finderArgs = new Object[] {
5649                                            groupId, folderId, fileEntryTypeId,
5650                                            
5651                                            start, end, orderByComparator
5652                                    };
5653                    }
5654    
5655                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
5656                                    finderArgs, this);
5657    
5658                    if (list == null) {
5659                            StringBundler query = null;
5660    
5661                            if (orderByComparator != null) {
5662                                    query = new StringBundler(5 +
5663                                                    (orderByComparator.getOrderByFields().length * 3));
5664                            }
5665                            else {
5666                                    query = new StringBundler(5);
5667                            }
5668    
5669                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5670    
5671                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
5672    
5673                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
5674    
5675                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
5676    
5677                            if (orderByComparator != null) {
5678                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5679                                            orderByComparator);
5680                            }
5681    
5682                            else {
5683                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5684                            }
5685    
5686                            String sql = query.toString();
5687    
5688                            Session session = null;
5689    
5690                            try {
5691                                    session = openSession();
5692    
5693                                    Query q = session.createQuery(sql);
5694    
5695                                    QueryPos qPos = QueryPos.getInstance(q);
5696    
5697                                    qPos.add(groupId);
5698    
5699                                    qPos.add(folderId);
5700    
5701                                    qPos.add(fileEntryTypeId);
5702    
5703                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5704                                                    start, end);
5705                            }
5706                            catch (Exception e) {
5707                                    throw processException(e);
5708                            }
5709                            finally {
5710                                    if (list == null) {
5711                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5712                                    }
5713                                    else {
5714                                            cacheResult(list);
5715    
5716                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5717                                    }
5718    
5719                                    closeSession(session);
5720                            }
5721                    }
5722    
5723                    return list;
5724            }
5725    
5726            /**
5727             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5728             *
5729             * <p>
5730             * 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.
5731             * </p>
5732             *
5733             * @param groupId the group ID
5734             * @param folderId the folder ID
5735             * @param fileEntryTypeId the file entry type ID
5736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5737             * @return the first matching document library file entry
5738             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5739             * @throws SystemException if a system exception occurred
5740             */
5741            public DLFileEntry findByG_F_F_First(long groupId, long folderId,
5742                    long fileEntryTypeId, OrderByComparator orderByComparator)
5743                    throws NoSuchFileEntryException, SystemException {
5744                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
5745                                    fileEntryTypeId, 0, 1, orderByComparator);
5746    
5747                    if (list.isEmpty()) {
5748                            StringBundler msg = new StringBundler(8);
5749    
5750                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5751    
5752                            msg.append("groupId=");
5753                            msg.append(groupId);
5754    
5755                            msg.append(", folderId=");
5756                            msg.append(folderId);
5757    
5758                            msg.append(", fileEntryTypeId=");
5759                            msg.append(fileEntryTypeId);
5760    
5761                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5762    
5763                            throw new NoSuchFileEntryException(msg.toString());
5764                    }
5765                    else {
5766                            return list.get(0);
5767                    }
5768            }
5769    
5770            /**
5771             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5772             *
5773             * <p>
5774             * 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.
5775             * </p>
5776             *
5777             * @param groupId the group ID
5778             * @param folderId the folder ID
5779             * @param fileEntryTypeId the file entry type ID
5780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5781             * @return the last matching document library file entry
5782             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5783             * @throws SystemException if a system exception occurred
5784             */
5785            public DLFileEntry findByG_F_F_Last(long groupId, long folderId,
5786                    long fileEntryTypeId, OrderByComparator orderByComparator)
5787                    throws NoSuchFileEntryException, SystemException {
5788                    int count = countByG_F_F(groupId, folderId, fileEntryTypeId);
5789    
5790                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
5791                                    fileEntryTypeId, count - 1, count, orderByComparator);
5792    
5793                    if (list.isEmpty()) {
5794                            StringBundler msg = new StringBundler(8);
5795    
5796                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5797    
5798                            msg.append("groupId=");
5799                            msg.append(groupId);
5800    
5801                            msg.append(", folderId=");
5802                            msg.append(folderId);
5803    
5804                            msg.append(", fileEntryTypeId=");
5805                            msg.append(fileEntryTypeId);
5806    
5807                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5808    
5809                            throw new NoSuchFileEntryException(msg.toString());
5810                    }
5811                    else {
5812                            return list.get(0);
5813                    }
5814            }
5815    
5816            /**
5817             * 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;.
5818             *
5819             * <p>
5820             * 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.
5821             * </p>
5822             *
5823             * @param fileEntryId the primary key of the current document library file entry
5824             * @param groupId the group ID
5825             * @param folderId the folder ID
5826             * @param fileEntryTypeId the file entry type ID
5827             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5828             * @return the previous, current, and next document library file entry
5829             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
5830             * @throws SystemException if a system exception occurred
5831             */
5832            public DLFileEntry[] findByG_F_F_PrevAndNext(long fileEntryId,
5833                    long groupId, long folderId, long fileEntryTypeId,
5834                    OrderByComparator orderByComparator)
5835                    throws NoSuchFileEntryException, SystemException {
5836                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5837    
5838                    Session session = null;
5839    
5840                    try {
5841                            session = openSession();
5842    
5843                            DLFileEntry[] array = new DLFileEntryImpl[3];
5844    
5845                            array[0] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
5846                                            folderId, fileEntryTypeId, orderByComparator, true);
5847    
5848                            array[1] = dlFileEntry;
5849    
5850                            array[2] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
5851                                            folderId, fileEntryTypeId, orderByComparator, false);
5852    
5853                            return array;
5854                    }
5855                    catch (Exception e) {
5856                            throw processException(e);
5857                    }
5858                    finally {
5859                            closeSession(session);
5860                    }
5861            }
5862    
5863            protected DLFileEntry getByG_F_F_PrevAndNext(Session session,
5864                    DLFileEntry dlFileEntry, long groupId, long folderId,
5865                    long fileEntryTypeId, OrderByComparator orderByComparator,
5866                    boolean previous) {
5867                    StringBundler query = null;
5868    
5869                    if (orderByComparator != null) {
5870                            query = new StringBundler(6 +
5871                                            (orderByComparator.getOrderByFields().length * 6));
5872                    }
5873                    else {
5874                            query = new StringBundler(3);
5875                    }
5876    
5877                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5878    
5879                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
5880    
5881                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
5882    
5883                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
5884    
5885                    if (orderByComparator != null) {
5886                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5887    
5888                            if (orderByConditionFields.length > 0) {
5889                                    query.append(WHERE_AND);
5890                            }
5891    
5892                            for (int i = 0; i < orderByConditionFields.length; i++) {
5893                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5894                                    query.append(orderByConditionFields[i]);
5895    
5896                                    if ((i + 1) < orderByConditionFields.length) {
5897                                            if (orderByComparator.isAscending() ^ previous) {
5898                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5899                                            }
5900                                            else {
5901                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5902                                            }
5903                                    }
5904                                    else {
5905                                            if (orderByComparator.isAscending() ^ previous) {
5906                                                    query.append(WHERE_GREATER_THAN);
5907                                            }
5908                                            else {
5909                                                    query.append(WHERE_LESSER_THAN);
5910                                            }
5911                                    }
5912                            }
5913    
5914                            query.append(ORDER_BY_CLAUSE);
5915    
5916                            String[] orderByFields = orderByComparator.getOrderByFields();
5917    
5918                            for (int i = 0; i < orderByFields.length; i++) {
5919                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5920                                    query.append(orderByFields[i]);
5921    
5922                                    if ((i + 1) < orderByFields.length) {
5923                                            if (orderByComparator.isAscending() ^ previous) {
5924                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5925                                            }
5926                                            else {
5927                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5928                                            }
5929                                    }
5930                                    else {
5931                                            if (orderByComparator.isAscending() ^ previous) {
5932                                                    query.append(ORDER_BY_ASC);
5933                                            }
5934                                            else {
5935                                                    query.append(ORDER_BY_DESC);
5936                                            }
5937                                    }
5938                            }
5939                    }
5940    
5941                    else {
5942                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5943                    }
5944    
5945                    String sql = query.toString();
5946    
5947                    Query q = session.createQuery(sql);
5948    
5949                    q.setFirstResult(0);
5950                    q.setMaxResults(2);
5951    
5952                    QueryPos qPos = QueryPos.getInstance(q);
5953    
5954                    qPos.add(groupId);
5955    
5956                    qPos.add(folderId);
5957    
5958                    qPos.add(fileEntryTypeId);
5959    
5960                    if (orderByComparator != null) {
5961                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5962    
5963                            for (Object value : values) {
5964                                    qPos.add(value);
5965                            }
5966                    }
5967    
5968                    List<DLFileEntry> list = q.list();
5969    
5970                    if (list.size() == 2) {
5971                            return list.get(1);
5972                    }
5973                    else {
5974                            return null;
5975                    }
5976            }
5977    
5978            /**
5979             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
5980             *
5981             * <p>
5982             * 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.
5983             * </p>
5984             *
5985             * @param groupId the group ID
5986             * @param folderIds the folder IDs
5987             * @param fileEntryTypeId the file entry type ID
5988             * @return the matching document library file entries
5989             * @throws SystemException if a system exception occurred
5990             */
5991            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
5992                    long fileEntryTypeId) throws SystemException {
5993                    return findByG_F_F(groupId, folderIds, fileEntryTypeId,
5994                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5995            }
5996    
5997            /**
5998             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
5999             *
6000             * <p>
6001             * 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.
6002             * </p>
6003             *
6004             * @param groupId the group ID
6005             * @param folderIds the folder IDs
6006             * @param fileEntryTypeId the file entry type ID
6007             * @param start the lower bound of the range of document library file entries
6008             * @param end the upper bound of the range of document library file entries (not inclusive)
6009             * @return the range of matching document library file entries
6010             * @throws SystemException if a system exception occurred
6011             */
6012            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
6013                    long fileEntryTypeId, int start, int end) throws SystemException {
6014                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, null);
6015            }
6016    
6017            /**
6018             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
6019             *
6020             * <p>
6021             * 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.
6022             * </p>
6023             *
6024             * @param groupId the group ID
6025             * @param folderIds the folder IDs
6026             * @param fileEntryTypeId the file entry type ID
6027             * @param start the lower bound of the range of document library file entries
6028             * @param end the upper bound of the range of document library file entries (not inclusive)
6029             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6030             * @return the ordered range of matching document library file entries
6031             * @throws SystemException if a system exception occurred
6032             */
6033            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
6034                    long fileEntryTypeId, int start, int end,
6035                    OrderByComparator orderByComparator) throws SystemException {
6036                    FinderPath finderPath = null;
6037                    Object[] finderArgs = null;
6038    
6039                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6040                                    (orderByComparator == null)) {
6041                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
6042                            finderArgs = new Object[] {
6043                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId
6044                                    };
6045                    }
6046                    else {
6047                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
6048                            finderArgs = new Object[] {
6049                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId,
6050                                            
6051                                            start, end, orderByComparator
6052                                    };
6053                    }
6054    
6055                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6056                                    finderArgs, this);
6057    
6058                    if (list == null) {
6059                            StringBundler query = new StringBundler();
6060    
6061                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6062    
6063                            boolean conjunctionable = false;
6064    
6065                            if (conjunctionable) {
6066                                    query.append(WHERE_AND);
6067                            }
6068    
6069                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
6070    
6071                            conjunctionable = true;
6072    
6073                            if ((folderIds == null) || (folderIds.length > 0)) {
6074                                    if (conjunctionable) {
6075                                            query.append(WHERE_AND);
6076                                    }
6077    
6078                                    query.append(StringPool.OPEN_PARENTHESIS);
6079    
6080                                    for (int i = 0; i < folderIds.length; i++) {
6081                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
6082    
6083                                            if ((i + 1) < folderIds.length) {
6084                                                    query.append(WHERE_OR);
6085                                            }
6086                                    }
6087    
6088                                    query.append(StringPool.CLOSE_PARENTHESIS);
6089    
6090                                    conjunctionable = true;
6091                            }
6092    
6093                            if (conjunctionable) {
6094                                    query.append(WHERE_AND);
6095                            }
6096    
6097                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
6098    
6099                            conjunctionable = true;
6100    
6101                            if (orderByComparator != null) {
6102                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6103                                            orderByComparator);
6104                            }
6105    
6106                            else {
6107                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6108                            }
6109    
6110                            String sql = query.toString();
6111    
6112                            Session session = null;
6113    
6114                            try {
6115                                    session = openSession();
6116    
6117                                    Query q = session.createQuery(sql);
6118    
6119                                    QueryPos qPos = QueryPos.getInstance(q);
6120    
6121                                    qPos.add(groupId);
6122    
6123                                    if (folderIds != null) {
6124                                            qPos.add(folderIds);
6125                                    }
6126    
6127                                    qPos.add(fileEntryTypeId);
6128    
6129                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6130                                                    start, end);
6131                            }
6132                            catch (Exception e) {
6133                                    throw processException(e);
6134                            }
6135                            finally {
6136                                    if (list == null) {
6137                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6138                                    }
6139                                    else {
6140                                            cacheResult(list);
6141    
6142                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6143                                    }
6144    
6145                                    closeSession(session);
6146                            }
6147                    }
6148    
6149                    return list;
6150            }
6151    
6152            /**
6153             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
6154             *
6155             * @param groupId the group ID
6156             * @param folderId the folder ID
6157             * @param fileEntryTypeId the file entry type ID
6158             * @return the matching document library file entries that the user has permission to view
6159             * @throws SystemException if a system exception occurred
6160             */
6161            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6162                    long fileEntryTypeId) throws SystemException {
6163                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId,
6164                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6165            }
6166    
6167            /**
6168             * 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;.
6169             *
6170             * <p>
6171             * 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.
6172             * </p>
6173             *
6174             * @param groupId the group ID
6175             * @param folderId the folder ID
6176             * @param fileEntryTypeId the file entry type ID
6177             * @param start the lower bound of the range of document library file entries
6178             * @param end the upper bound of the range of document library file entries (not inclusive)
6179             * @return the range of matching document library file entries that the user has permission to view
6180             * @throws SystemException if a system exception occurred
6181             */
6182            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6183                    long fileEntryTypeId, int start, int end) throws SystemException {
6184                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId, start,
6185                            end, null);
6186            }
6187    
6188            /**
6189             * 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;.
6190             *
6191             * <p>
6192             * 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.
6193             * </p>
6194             *
6195             * @param groupId the group ID
6196             * @param folderId the folder ID
6197             * @param fileEntryTypeId the file entry type ID
6198             * @param start the lower bound of the range of document library file entries
6199             * @param end the upper bound of the range of document library file entries (not inclusive)
6200             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6201             * @return the ordered range of matching document library file entries that the user has permission to view
6202             * @throws SystemException if a system exception occurred
6203             */
6204            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6205                    long fileEntryTypeId, int start, int end,
6206                    OrderByComparator orderByComparator) throws SystemException {
6207                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6208                            return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
6209                                    orderByComparator);
6210                    }
6211    
6212                    StringBundler query = null;
6213    
6214                    if (orderByComparator != null) {
6215                            query = new StringBundler(5 +
6216                                            (orderByComparator.getOrderByFields().length * 3));
6217                    }
6218                    else {
6219                            query = new StringBundler(5);
6220                    }
6221    
6222                    if (getDB().isSupportsInlineDistinct()) {
6223                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6224                    }
6225                    else {
6226                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6227                    }
6228    
6229                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
6230    
6231                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
6232    
6233                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
6234    
6235                    if (!getDB().isSupportsInlineDistinct()) {
6236                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6237                    }
6238    
6239                    if (orderByComparator != null) {
6240                            if (getDB().isSupportsInlineDistinct()) {
6241                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6242                                            orderByComparator);
6243                            }
6244                            else {
6245                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6246                                            orderByComparator);
6247                            }
6248                    }
6249    
6250                    else {
6251                            if (getDB().isSupportsInlineDistinct()) {
6252                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6253                            }
6254                            else {
6255                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6256                            }
6257                    }
6258    
6259                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6260                                    DLFileEntry.class.getName(),
6261                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6262    
6263                    Session session = null;
6264    
6265                    try {
6266                            session = openSession();
6267    
6268                            SQLQuery q = session.createSQLQuery(sql);
6269    
6270                            if (getDB().isSupportsInlineDistinct()) {
6271                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6272                            }
6273                            else {
6274                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6275                            }
6276    
6277                            QueryPos qPos = QueryPos.getInstance(q);
6278    
6279                            qPos.add(groupId);
6280    
6281                            qPos.add(folderId);
6282    
6283                            qPos.add(fileEntryTypeId);
6284    
6285                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6286                    }
6287                    catch (Exception e) {
6288                            throw processException(e);
6289                    }
6290                    finally {
6291                            closeSession(session);
6292                    }
6293            }
6294    
6295            /**
6296             * 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;.
6297             *
6298             * @param fileEntryId the primary key of the current document library file entry
6299             * @param groupId the group ID
6300             * @param folderId the folder ID
6301             * @param fileEntryTypeId the file entry type ID
6302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6303             * @return the previous, current, and next document library file entry
6304             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
6305             * @throws SystemException if a system exception occurred
6306             */
6307            public DLFileEntry[] filterFindByG_F_F_PrevAndNext(long fileEntryId,
6308                    long groupId, long folderId, long fileEntryTypeId,
6309                    OrderByComparator orderByComparator)
6310                    throws NoSuchFileEntryException, SystemException {
6311                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6312                            return findByG_F_F_PrevAndNext(fileEntryId, groupId, folderId,
6313                                    fileEntryTypeId, orderByComparator);
6314                    }
6315    
6316                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
6317    
6318                    Session session = null;
6319    
6320                    try {
6321                            session = openSession();
6322    
6323                            DLFileEntry[] array = new DLFileEntryImpl[3];
6324    
6325                            array[0] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
6326                                            groupId, folderId, fileEntryTypeId, orderByComparator, true);
6327    
6328                            array[1] = dlFileEntry;
6329    
6330                            array[2] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
6331                                            groupId, folderId, fileEntryTypeId, orderByComparator, false);
6332    
6333                            return array;
6334                    }
6335                    catch (Exception e) {
6336                            throw processException(e);
6337                    }
6338                    finally {
6339                            closeSession(session);
6340                    }
6341            }
6342    
6343            protected DLFileEntry filterGetByG_F_F_PrevAndNext(Session session,
6344                    DLFileEntry dlFileEntry, long groupId, long folderId,
6345                    long fileEntryTypeId, OrderByComparator orderByComparator,
6346                    boolean previous) {
6347                    StringBundler query = null;
6348    
6349                    if (orderByComparator != null) {
6350                            query = new StringBundler(6 +
6351                                            (orderByComparator.getOrderByFields().length * 6));
6352                    }
6353                    else {
6354                            query = new StringBundler(3);
6355                    }
6356    
6357                    if (getDB().isSupportsInlineDistinct()) {
6358                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6359                    }
6360                    else {
6361                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6362                    }
6363    
6364                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
6365    
6366                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
6367    
6368                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
6369    
6370                    if (!getDB().isSupportsInlineDistinct()) {
6371                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6372                    }
6373    
6374                    if (orderByComparator != null) {
6375                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6376    
6377                            if (orderByConditionFields.length > 0) {
6378                                    query.append(WHERE_AND);
6379                            }
6380    
6381                            for (int i = 0; i < orderByConditionFields.length; i++) {
6382                                    if (getDB().isSupportsInlineDistinct()) {
6383                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6384                                    }
6385                                    else {
6386                                            query.append(_ORDER_BY_ENTITY_TABLE);
6387                                    }
6388    
6389                                    query.append(orderByConditionFields[i]);
6390    
6391                                    if ((i + 1) < orderByConditionFields.length) {
6392                                            if (orderByComparator.isAscending() ^ previous) {
6393                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6394                                            }
6395                                            else {
6396                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6397                                            }
6398                                    }
6399                                    else {
6400                                            if (orderByComparator.isAscending() ^ previous) {
6401                                                    query.append(WHERE_GREATER_THAN);
6402                                            }
6403                                            else {
6404                                                    query.append(WHERE_LESSER_THAN);
6405                                            }
6406                                    }
6407                            }
6408    
6409                            query.append(ORDER_BY_CLAUSE);
6410    
6411                            String[] orderByFields = orderByComparator.getOrderByFields();
6412    
6413                            for (int i = 0; i < orderByFields.length; i++) {
6414                                    if (getDB().isSupportsInlineDistinct()) {
6415                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6416                                    }
6417                                    else {
6418                                            query.append(_ORDER_BY_ENTITY_TABLE);
6419                                    }
6420    
6421                                    query.append(orderByFields[i]);
6422    
6423                                    if ((i + 1) < orderByFields.length) {
6424                                            if (orderByComparator.isAscending() ^ previous) {
6425                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6426                                            }
6427                                            else {
6428                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6429                                            }
6430                                    }
6431                                    else {
6432                                            if (orderByComparator.isAscending() ^ previous) {
6433                                                    query.append(ORDER_BY_ASC);
6434                                            }
6435                                            else {
6436                                                    query.append(ORDER_BY_DESC);
6437                                            }
6438                                    }
6439                            }
6440                    }
6441    
6442                    else {
6443                            if (getDB().isSupportsInlineDistinct()) {
6444                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6445                            }
6446                            else {
6447                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6448                            }
6449                    }
6450    
6451                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6452                                    DLFileEntry.class.getName(),
6453                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6454    
6455                    SQLQuery q = session.createSQLQuery(sql);
6456    
6457                    q.setFirstResult(0);
6458                    q.setMaxResults(2);
6459    
6460                    if (getDB().isSupportsInlineDistinct()) {
6461                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6462                    }
6463                    else {
6464                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6465                    }
6466    
6467                    QueryPos qPos = QueryPos.getInstance(q);
6468    
6469                    qPos.add(groupId);
6470    
6471                    qPos.add(folderId);
6472    
6473                    qPos.add(fileEntryTypeId);
6474    
6475                    if (orderByComparator != null) {
6476                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
6477    
6478                            for (Object value : values) {
6479                                    qPos.add(value);
6480                            }
6481                    }
6482    
6483                    List<DLFileEntry> list = q.list();
6484    
6485                    if (list.size() == 2) {
6486                            return list.get(1);
6487                    }
6488                    else {
6489                            return null;
6490                    }
6491            }
6492    
6493            /**
6494             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
6495             *
6496             * @param groupId the group ID
6497             * @param folderIds the folder IDs
6498             * @param fileEntryTypeId the file entry type ID
6499             * @return the matching document library file entries that the user has permission to view
6500             * @throws SystemException if a system exception occurred
6501             */
6502            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6503                    long fileEntryTypeId) throws SystemException {
6504                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId,
6505                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6506            }
6507    
6508            /**
6509             * 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;.
6510             *
6511             * <p>
6512             * 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.
6513             * </p>
6514             *
6515             * @param groupId the group ID
6516             * @param folderIds the folder IDs
6517             * @param fileEntryTypeId the file entry type ID
6518             * @param start the lower bound of the range of document library file entries
6519             * @param end the upper bound of the range of document library file entries (not inclusive)
6520             * @return the range of matching document library file entries that the user has permission to view
6521             * @throws SystemException if a system exception occurred
6522             */
6523            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6524                    long fileEntryTypeId, int start, int end) throws SystemException {
6525                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId, start,
6526                            end, null);
6527            }
6528    
6529            /**
6530             * 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;.
6531             *
6532             * <p>
6533             * 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.
6534             * </p>
6535             *
6536             * @param groupId the group ID
6537             * @param folderIds the folder IDs
6538             * @param fileEntryTypeId the file entry type ID
6539             * @param start the lower bound of the range of document library file entries
6540             * @param end the upper bound of the range of document library file entries (not inclusive)
6541             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6542             * @return the ordered range of matching document library file entries that the user has permission to view
6543             * @throws SystemException if a system exception occurred
6544             */
6545            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6546                    long fileEntryTypeId, int start, int end,
6547                    OrderByComparator orderByComparator) throws SystemException {
6548                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6549                            return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
6550                                    orderByComparator);
6551                    }
6552    
6553                    StringBundler query = new StringBundler();
6554    
6555                    if (getDB().isSupportsInlineDistinct()) {
6556                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6557                    }
6558                    else {
6559                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6560                    }
6561    
6562                    boolean conjunctionable = false;
6563    
6564                    if (conjunctionable) {
6565                            query.append(WHERE_AND);
6566                    }
6567    
6568                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
6569    
6570                    conjunctionable = true;
6571    
6572                    if ((folderIds == null) || (folderIds.length > 0)) {
6573                            if (conjunctionable) {
6574                                    query.append(WHERE_AND);
6575                            }
6576    
6577                            query.append(StringPool.OPEN_PARENTHESIS);
6578    
6579                            for (int i = 0; i < folderIds.length; i++) {
6580                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
6581    
6582                                    if ((i + 1) < folderIds.length) {
6583                                            query.append(WHERE_OR);
6584                                    }
6585                            }
6586    
6587                            query.append(StringPool.CLOSE_PARENTHESIS);
6588    
6589                            conjunctionable = true;
6590                    }
6591    
6592                    if (conjunctionable) {
6593                            query.append(WHERE_AND);
6594                    }
6595    
6596                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
6597    
6598                    conjunctionable = true;
6599    
6600                    if (!getDB().isSupportsInlineDistinct()) {
6601                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6602                    }
6603    
6604                    if (orderByComparator != null) {
6605                            if (getDB().isSupportsInlineDistinct()) {
6606                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6607                                            orderByComparator);
6608                            }
6609                            else {
6610                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6611                                            orderByComparator);
6612                            }
6613                    }
6614    
6615                    else {
6616                            if (getDB().isSupportsInlineDistinct()) {
6617                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6618                            }
6619                            else {
6620                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6621                            }
6622                    }
6623    
6624                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6625                                    DLFileEntry.class.getName(),
6626                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6627    
6628                    Session session = null;
6629    
6630                    try {
6631                            session = openSession();
6632    
6633                            SQLQuery q = session.createSQLQuery(sql);
6634    
6635                            if (getDB().isSupportsInlineDistinct()) {
6636                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6637                            }
6638                            else {
6639                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6640                            }
6641    
6642                            QueryPos qPos = QueryPos.getInstance(q);
6643    
6644                            qPos.add(groupId);
6645    
6646                            if (folderIds != null) {
6647                                    qPos.add(folderIds);
6648                            }
6649    
6650                            qPos.add(fileEntryTypeId);
6651    
6652                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6653                    }
6654                    catch (Exception e) {
6655                            throw processException(e);
6656                    }
6657                    finally {
6658                            closeSession(session);
6659                    }
6660            }
6661    
6662            /**
6663             * Returns all the document library file entries.
6664             *
6665             * @return the document library file entries
6666             * @throws SystemException if a system exception occurred
6667             */
6668            public List<DLFileEntry> findAll() throws SystemException {
6669                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6670            }
6671    
6672            /**
6673             * Returns a range of all the document library file entries.
6674             *
6675             * <p>
6676             * 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.
6677             * </p>
6678             *
6679             * @param start the lower bound of the range of document library file entries
6680             * @param end the upper bound of the range of document library file entries (not inclusive)
6681             * @return the range of document library file entries
6682             * @throws SystemException if a system exception occurred
6683             */
6684            public List<DLFileEntry> findAll(int start, int end)
6685                    throws SystemException {
6686                    return findAll(start, end, null);
6687            }
6688    
6689            /**
6690             * Returns an ordered range of all the document library file entries.
6691             *
6692             * <p>
6693             * 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.
6694             * </p>
6695             *
6696             * @param start the lower bound of the range of document library file entries
6697             * @param end the upper bound of the range of document library file entries (not inclusive)
6698             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6699             * @return the ordered range of document library file entries
6700             * @throws SystemException if a system exception occurred
6701             */
6702            public List<DLFileEntry> findAll(int start, int end,
6703                    OrderByComparator orderByComparator) throws SystemException {
6704                    FinderPath finderPath = null;
6705                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
6706    
6707                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6708                                    (orderByComparator == null)) {
6709                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6710                            finderArgs = FINDER_ARGS_EMPTY;
6711                    }
6712                    else {
6713                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6714                            finderArgs = new Object[] { start, end, orderByComparator };
6715                    }
6716    
6717                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6718                                    finderArgs, this);
6719    
6720                    if (list == null) {
6721                            StringBundler query = null;
6722                            String sql = null;
6723    
6724                            if (orderByComparator != null) {
6725                                    query = new StringBundler(2 +
6726                                                    (orderByComparator.getOrderByFields().length * 3));
6727    
6728                                    query.append(_SQL_SELECT_DLFILEENTRY);
6729    
6730                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6731                                            orderByComparator);
6732    
6733                                    sql = query.toString();
6734                            }
6735                            else {
6736                                    sql = _SQL_SELECT_DLFILEENTRY.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
6737                            }
6738    
6739                            Session session = null;
6740    
6741                            try {
6742                                    session = openSession();
6743    
6744                                    Query q = session.createQuery(sql);
6745    
6746                                    if (orderByComparator == null) {
6747                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6748                                                            start, end, false);
6749    
6750                                            Collections.sort(list);
6751                                    }
6752                                    else {
6753                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6754                                                            start, end);
6755                                    }
6756                            }
6757                            catch (Exception e) {
6758                                    throw processException(e);
6759                            }
6760                            finally {
6761                                    if (list == null) {
6762                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6763                                    }
6764                                    else {
6765                                            cacheResult(list);
6766    
6767                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6768                                    }
6769    
6770                                    closeSession(session);
6771                            }
6772                    }
6773    
6774                    return list;
6775            }
6776    
6777            /**
6778             * Removes all the document library file entries where uuid = &#63; from the database.
6779             *
6780             * @param uuid the uuid
6781             * @throws SystemException if a system exception occurred
6782             */
6783            public void removeByUuid(String uuid) throws SystemException {
6784                    for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
6785                            dlFileEntryPersistence.remove(dlFileEntry);
6786                    }
6787            }
6788    
6789            /**
6790             * Removes the document library file entry where uuid = &#63; and groupId = &#63; from the database.
6791             *
6792             * @param uuid the uuid
6793             * @param groupId the group ID
6794             * @throws SystemException if a system exception occurred
6795             */
6796            public void removeByUUID_G(String uuid, long groupId)
6797                    throws NoSuchFileEntryException, SystemException {
6798                    DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
6799    
6800                    dlFileEntryPersistence.remove(dlFileEntry);
6801            }
6802    
6803            /**
6804             * Removes all the document library file entries where groupId = &#63; from the database.
6805             *
6806             * @param groupId the group ID
6807             * @throws SystemException if a system exception occurred
6808             */
6809            public void removeByGroupId(long groupId) throws SystemException {
6810                    for (DLFileEntry dlFileEntry : findByGroupId(groupId)) {
6811                            dlFileEntryPersistence.remove(dlFileEntry);
6812                    }
6813            }
6814    
6815            /**
6816             * Removes all the document library file entries where companyId = &#63; from the database.
6817             *
6818             * @param companyId the company ID
6819             * @throws SystemException if a system exception occurred
6820             */
6821            public void removeByCompanyId(long companyId) throws SystemException {
6822                    for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
6823                            dlFileEntryPersistence.remove(dlFileEntry);
6824                    }
6825            }
6826    
6827            /**
6828             * Removes all the document library file entries where groupId = &#63; and userId = &#63; from the database.
6829             *
6830             * @param groupId the group ID
6831             * @param userId the user ID
6832             * @throws SystemException if a system exception occurred
6833             */
6834            public void removeByG_U(long groupId, long userId)
6835                    throws SystemException {
6836                    for (DLFileEntry dlFileEntry : findByG_U(groupId, userId)) {
6837                            dlFileEntryPersistence.remove(dlFileEntry);
6838                    }
6839            }
6840    
6841            /**
6842             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; from the database.
6843             *
6844             * @param groupId the group ID
6845             * @param folderId the folder ID
6846             * @throws SystemException if a system exception occurred
6847             */
6848            public void removeByG_F(long groupId, long folderId)
6849                    throws SystemException {
6850                    for (DLFileEntry dlFileEntry : findByG_F(groupId, folderId)) {
6851                            dlFileEntryPersistence.remove(dlFileEntry);
6852                    }
6853            }
6854    
6855            /**
6856             * Removes all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63; from the database.
6857             *
6858             * @param groupId the group ID
6859             * @param userId the user ID
6860             * @param folderId the folder ID
6861             * @throws SystemException if a system exception occurred
6862             */
6863            public void removeByG_U_F(long groupId, long userId, long folderId)
6864                    throws SystemException {
6865                    for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId)) {
6866                            dlFileEntryPersistence.remove(dlFileEntry);
6867                    }
6868            }
6869    
6870            /**
6871             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; from the database.
6872             *
6873             * @param groupId the group ID
6874             * @param folderId the folder ID
6875             * @param name the name
6876             * @throws SystemException if a system exception occurred
6877             */
6878            public void removeByG_F_N(long groupId, long folderId, String name)
6879                    throws NoSuchFileEntryException, SystemException {
6880                    DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
6881    
6882                    dlFileEntryPersistence.remove(dlFileEntry);
6883            }
6884    
6885            /**
6886             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; from the database.
6887             *
6888             * @param groupId the group ID
6889             * @param folderId the folder ID
6890             * @param title the title
6891             * @throws SystemException if a system exception occurred
6892             */
6893            public void removeByG_F_T(long groupId, long folderId, String title)
6894                    throws NoSuchFileEntryException, SystemException {
6895                    DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
6896    
6897                    dlFileEntryPersistence.remove(dlFileEntry);
6898            }
6899    
6900            /**
6901             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63; from the database.
6902             *
6903             * @param groupId the group ID
6904             * @param folderId the folder ID
6905             * @param fileEntryTypeId the file entry type ID
6906             * @throws SystemException if a system exception occurred
6907             */
6908            public void removeByG_F_F(long groupId, long folderId, long fileEntryTypeId)
6909                    throws SystemException {
6910                    for (DLFileEntry dlFileEntry : findByG_F_F(groupId, folderId,
6911                                    fileEntryTypeId)) {
6912                            dlFileEntryPersistence.remove(dlFileEntry);
6913                    }
6914            }
6915    
6916            /**
6917             * Removes all the document library file entries from the database.
6918             *
6919             * @throws SystemException if a system exception occurred
6920             */
6921            public void removeAll() throws SystemException {
6922                    for (DLFileEntry dlFileEntry : findAll()) {
6923                            dlFileEntryPersistence.remove(dlFileEntry);
6924                    }
6925            }
6926    
6927            /**
6928             * Returns the number of document library file entries where uuid = &#63;.
6929             *
6930             * @param uuid the uuid
6931             * @return the number of matching document library file entries
6932             * @throws SystemException if a system exception occurred
6933             */
6934            public int countByUuid(String uuid) throws SystemException {
6935                    Object[] finderArgs = new Object[] { uuid };
6936    
6937                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
6938                                    finderArgs, this);
6939    
6940                    if (count == null) {
6941                            StringBundler query = new StringBundler(2);
6942    
6943                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6944    
6945                            if (uuid == null) {
6946                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
6947                            }
6948                            else {
6949                                    if (uuid.equals(StringPool.BLANK)) {
6950                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
6951                                    }
6952                                    else {
6953                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
6954                                    }
6955                            }
6956    
6957                            String sql = query.toString();
6958    
6959                            Session session = null;
6960    
6961                            try {
6962                                    session = openSession();
6963    
6964                                    Query q = session.createQuery(sql);
6965    
6966                                    QueryPos qPos = QueryPos.getInstance(q);
6967    
6968                                    if (uuid != null) {
6969                                            qPos.add(uuid);
6970                                    }
6971    
6972                                    count = (Long)q.uniqueResult();
6973                            }
6974                            catch (Exception e) {
6975                                    throw processException(e);
6976                            }
6977                            finally {
6978                                    if (count == null) {
6979                                            count = Long.valueOf(0);
6980                                    }
6981    
6982                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
6983                                            finderArgs, count);
6984    
6985                                    closeSession(session);
6986                            }
6987                    }
6988    
6989                    return count.intValue();
6990            }
6991    
6992            /**
6993             * Returns the number of document library file entries where uuid = &#63; and groupId = &#63;.
6994             *
6995             * @param uuid the uuid
6996             * @param groupId the group ID
6997             * @return the number of matching document library file entries
6998             * @throws SystemException if a system exception occurred
6999             */
7000            public int countByUUID_G(String uuid, long groupId)
7001                    throws SystemException {
7002                    Object[] finderArgs = new Object[] { uuid, groupId };
7003    
7004                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
7005                                    finderArgs, this);
7006    
7007                    if (count == null) {
7008                            StringBundler query = new StringBundler(3);
7009    
7010                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7011    
7012                            if (uuid == null) {
7013                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
7014                            }
7015                            else {
7016                                    if (uuid.equals(StringPool.BLANK)) {
7017                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
7018                                    }
7019                                    else {
7020                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
7021                                    }
7022                            }
7023    
7024                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
7025    
7026                            String sql = query.toString();
7027    
7028                            Session session = null;
7029    
7030                            try {
7031                                    session = openSession();
7032    
7033                                    Query q = session.createQuery(sql);
7034    
7035                                    QueryPos qPos = QueryPos.getInstance(q);
7036    
7037                                    if (uuid != null) {
7038                                            qPos.add(uuid);
7039                                    }
7040    
7041                                    qPos.add(groupId);
7042    
7043                                    count = (Long)q.uniqueResult();
7044                            }
7045                            catch (Exception e) {
7046                                    throw processException(e);
7047                            }
7048                            finally {
7049                                    if (count == null) {
7050                                            count = Long.valueOf(0);
7051                                    }
7052    
7053                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
7054                                            finderArgs, count);
7055    
7056                                    closeSession(session);
7057                            }
7058                    }
7059    
7060                    return count.intValue();
7061            }
7062    
7063            /**
7064             * Returns the number of document library file entries where groupId = &#63;.
7065             *
7066             * @param groupId the group ID
7067             * @return the number of matching document library file entries
7068             * @throws SystemException if a system exception occurred
7069             */
7070            public int countByGroupId(long groupId) throws SystemException {
7071                    Object[] finderArgs = new Object[] { groupId };
7072    
7073                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7074                                    finderArgs, this);
7075    
7076                    if (count == null) {
7077                            StringBundler query = new StringBundler(2);
7078    
7079                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7080    
7081                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7082    
7083                            String sql = query.toString();
7084    
7085                            Session session = null;
7086    
7087                            try {
7088                                    session = openSession();
7089    
7090                                    Query q = session.createQuery(sql);
7091    
7092                                    QueryPos qPos = QueryPos.getInstance(q);
7093    
7094                                    qPos.add(groupId);
7095    
7096                                    count = (Long)q.uniqueResult();
7097                            }
7098                            catch (Exception e) {
7099                                    throw processException(e);
7100                            }
7101                            finally {
7102                                    if (count == null) {
7103                                            count = Long.valueOf(0);
7104                                    }
7105    
7106                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
7107                                            finderArgs, count);
7108    
7109                                    closeSession(session);
7110                            }
7111                    }
7112    
7113                    return count.intValue();
7114            }
7115    
7116            /**
7117             * Returns the number of document library file entries that the user has permission to view where groupId = &#63;.
7118             *
7119             * @param groupId the group ID
7120             * @return the number of matching document library file entries that the user has permission to view
7121             * @throws SystemException if a system exception occurred
7122             */
7123            public int filterCountByGroupId(long groupId) throws SystemException {
7124                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7125                            return countByGroupId(groupId);
7126                    }
7127    
7128                    StringBundler query = new StringBundler(2);
7129    
7130                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7131    
7132                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7133    
7134                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7135                                    DLFileEntry.class.getName(),
7136                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7137    
7138                    Session session = null;
7139    
7140                    try {
7141                            session = openSession();
7142    
7143                            SQLQuery q = session.createSQLQuery(sql);
7144    
7145                            q.addScalar(COUNT_COLUMN_NAME,
7146                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7147    
7148                            QueryPos qPos = QueryPos.getInstance(q);
7149    
7150                            qPos.add(groupId);
7151    
7152                            Long count = (Long)q.uniqueResult();
7153    
7154                            return count.intValue();
7155                    }
7156                    catch (Exception e) {
7157                            throw processException(e);
7158                    }
7159                    finally {
7160                            closeSession(session);
7161                    }
7162            }
7163    
7164            /**
7165             * Returns the number of document library file entries where companyId = &#63;.
7166             *
7167             * @param companyId the company ID
7168             * @return the number of matching document library file entries
7169             * @throws SystemException if a system exception occurred
7170             */
7171            public int countByCompanyId(long companyId) throws SystemException {
7172                    Object[] finderArgs = new Object[] { companyId };
7173    
7174                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
7175                                    finderArgs, this);
7176    
7177                    if (count == null) {
7178                            StringBundler query = new StringBundler(2);
7179    
7180                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7181    
7182                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
7183    
7184                            String sql = query.toString();
7185    
7186                            Session session = null;
7187    
7188                            try {
7189                                    session = openSession();
7190    
7191                                    Query q = session.createQuery(sql);
7192    
7193                                    QueryPos qPos = QueryPos.getInstance(q);
7194    
7195                                    qPos.add(companyId);
7196    
7197                                    count = (Long)q.uniqueResult();
7198                            }
7199                            catch (Exception e) {
7200                                    throw processException(e);
7201                            }
7202                            finally {
7203                                    if (count == null) {
7204                                            count = Long.valueOf(0);
7205                                    }
7206    
7207                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
7208                                            finderArgs, count);
7209    
7210                                    closeSession(session);
7211                            }
7212                    }
7213    
7214                    return count.intValue();
7215            }
7216    
7217            /**
7218             * Returns the number of document library file entries where groupId = &#63; and userId = &#63;.
7219             *
7220             * @param groupId the group ID
7221             * @param userId the user ID
7222             * @return the number of matching document library file entries
7223             * @throws SystemException if a system exception occurred
7224             */
7225            public int countByG_U(long groupId, long userId) throws SystemException {
7226                    Object[] finderArgs = new Object[] { groupId, userId };
7227    
7228                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
7229                                    finderArgs, this);
7230    
7231                    if (count == null) {
7232                            StringBundler query = new StringBundler(3);
7233    
7234                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7235    
7236                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7237    
7238                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7239    
7240                            String sql = query.toString();
7241    
7242                            Session session = null;
7243    
7244                            try {
7245                                    session = openSession();
7246    
7247                                    Query q = session.createQuery(sql);
7248    
7249                                    QueryPos qPos = QueryPos.getInstance(q);
7250    
7251                                    qPos.add(groupId);
7252    
7253                                    qPos.add(userId);
7254    
7255                                    count = (Long)q.uniqueResult();
7256                            }
7257                            catch (Exception e) {
7258                                    throw processException(e);
7259                            }
7260                            finally {
7261                                    if (count == null) {
7262                                            count = Long.valueOf(0);
7263                                    }
7264    
7265                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
7266                                            count);
7267    
7268                                    closeSession(session);
7269                            }
7270                    }
7271    
7272                    return count.intValue();
7273            }
7274    
7275            /**
7276             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
7277             *
7278             * @param groupId the group ID
7279             * @param userId the user ID
7280             * @return the number of matching document library file entries that the user has permission to view
7281             * @throws SystemException if a system exception occurred
7282             */
7283            public int filterCountByG_U(long groupId, long userId)
7284                    throws SystemException {
7285                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7286                            return countByG_U(groupId, userId);
7287                    }
7288    
7289                    StringBundler query = new StringBundler(3);
7290    
7291                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7292    
7293                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7294    
7295                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7296    
7297                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7298                                    DLFileEntry.class.getName(),
7299                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7300    
7301                    Session session = null;
7302    
7303                    try {
7304                            session = openSession();
7305    
7306                            SQLQuery q = session.createSQLQuery(sql);
7307    
7308                            q.addScalar(COUNT_COLUMN_NAME,
7309                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7310    
7311                            QueryPos qPos = QueryPos.getInstance(q);
7312    
7313                            qPos.add(groupId);
7314    
7315                            qPos.add(userId);
7316    
7317                            Long count = (Long)q.uniqueResult();
7318    
7319                            return count.intValue();
7320                    }
7321                    catch (Exception e) {
7322                            throw processException(e);
7323                    }
7324                    finally {
7325                            closeSession(session);
7326                    }
7327            }
7328    
7329            /**
7330             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63;.
7331             *
7332             * @param groupId the group ID
7333             * @param folderId the folder ID
7334             * @return the number of matching document library file entries
7335             * @throws SystemException if a system exception occurred
7336             */
7337            public int countByG_F(long groupId, long folderId)
7338                    throws SystemException {
7339                    Object[] finderArgs = new Object[] { groupId, folderId };
7340    
7341                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
7342                                    finderArgs, this);
7343    
7344                    if (count == null) {
7345                            StringBundler query = new StringBundler(3);
7346    
7347                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7348    
7349                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7350    
7351                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7352    
7353                            String sql = query.toString();
7354    
7355                            Session session = null;
7356    
7357                            try {
7358                                    session = openSession();
7359    
7360                                    Query q = session.createQuery(sql);
7361    
7362                                    QueryPos qPos = QueryPos.getInstance(q);
7363    
7364                                    qPos.add(groupId);
7365    
7366                                    qPos.add(folderId);
7367    
7368                                    count = (Long)q.uniqueResult();
7369                            }
7370                            catch (Exception e) {
7371                                    throw processException(e);
7372                            }
7373                            finally {
7374                                    if (count == null) {
7375                                            count = Long.valueOf(0);
7376                                    }
7377    
7378                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
7379                                            count);
7380    
7381                                    closeSession(session);
7382                            }
7383                    }
7384    
7385                    return count.intValue();
7386            }
7387    
7388            /**
7389             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63;.
7390             *
7391             * @param groupId the group ID
7392             * @param folderIds the folder IDs
7393             * @return the number of matching document library file entries
7394             * @throws SystemException if a system exception occurred
7395             */
7396            public int countByG_F(long groupId, long[] folderIds)
7397                    throws SystemException {
7398                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7399    
7400                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
7401                                    finderArgs, this);
7402    
7403                    if (count == null) {
7404                            StringBundler query = new StringBundler();
7405    
7406                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7407    
7408                            boolean conjunctionable = false;
7409    
7410                            if (conjunctionable) {
7411                                    query.append(WHERE_AND);
7412                            }
7413    
7414                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7415    
7416                            conjunctionable = true;
7417    
7418                            if ((folderIds == null) || (folderIds.length > 0)) {
7419                                    if (conjunctionable) {
7420                                            query.append(WHERE_AND);
7421                                    }
7422    
7423                                    query.append(StringPool.OPEN_PARENTHESIS);
7424    
7425                                    for (int i = 0; i < folderIds.length; i++) {
7426                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7427    
7428                                            if ((i + 1) < folderIds.length) {
7429                                                    query.append(WHERE_OR);
7430                                            }
7431                                    }
7432    
7433                                    query.append(StringPool.CLOSE_PARENTHESIS);
7434    
7435                                    conjunctionable = true;
7436                            }
7437    
7438                            String sql = query.toString();
7439    
7440                            Session session = null;
7441    
7442                            try {
7443                                    session = openSession();
7444    
7445                                    Query q = session.createQuery(sql);
7446    
7447                                    QueryPos qPos = QueryPos.getInstance(q);
7448    
7449                                    qPos.add(groupId);
7450    
7451                                    if (folderIds != null) {
7452                                            qPos.add(folderIds);
7453                                    }
7454    
7455                                    count = (Long)q.uniqueResult();
7456                            }
7457                            catch (Exception e) {
7458                                    throw processException(e);
7459                            }
7460                            finally {
7461                                    if (count == null) {
7462                                            count = Long.valueOf(0);
7463                                    }
7464    
7465                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
7466                                            count);
7467    
7468                                    closeSession(session);
7469                            }
7470                    }
7471    
7472                    return count.intValue();
7473            }
7474    
7475            /**
7476             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
7477             *
7478             * @param groupId the group ID
7479             * @param folderId the folder ID
7480             * @return the number of matching document library file entries that the user has permission to view
7481             * @throws SystemException if a system exception occurred
7482             */
7483            public int filterCountByG_F(long groupId, long folderId)
7484                    throws SystemException {
7485                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7486                            return countByG_F(groupId, folderId);
7487                    }
7488    
7489                    StringBundler query = new StringBundler(3);
7490    
7491                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7492    
7493                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7494    
7495                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7496    
7497                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7498                                    DLFileEntry.class.getName(),
7499                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7500    
7501                    Session session = null;
7502    
7503                    try {
7504                            session = openSession();
7505    
7506                            SQLQuery q = session.createSQLQuery(sql);
7507    
7508                            q.addScalar(COUNT_COLUMN_NAME,
7509                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7510    
7511                            QueryPos qPos = QueryPos.getInstance(q);
7512    
7513                            qPos.add(groupId);
7514    
7515                            qPos.add(folderId);
7516    
7517                            Long count = (Long)q.uniqueResult();
7518    
7519                            return count.intValue();
7520                    }
7521                    catch (Exception e) {
7522                            throw processException(e);
7523                    }
7524                    finally {
7525                            closeSession(session);
7526                    }
7527            }
7528    
7529            /**
7530             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7531             *
7532             * @param groupId the group ID
7533             * @param folderIds the folder IDs
7534             * @return the number of matching document library file entries that the user has permission to view
7535             * @throws SystemException if a system exception occurred
7536             */
7537            public int filterCountByG_F(long groupId, long[] folderIds)
7538                    throws SystemException {
7539                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7540                            return countByG_F(groupId, folderIds);
7541                    }
7542    
7543                    StringBundler query = new StringBundler();
7544    
7545                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7546    
7547                    boolean conjunctionable = false;
7548    
7549                    if (conjunctionable) {
7550                            query.append(WHERE_AND);
7551                    }
7552    
7553                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7554    
7555                    conjunctionable = true;
7556    
7557                    if ((folderIds == null) || (folderIds.length > 0)) {
7558                            if (conjunctionable) {
7559                                    query.append(WHERE_AND);
7560                            }
7561    
7562                            query.append(StringPool.OPEN_PARENTHESIS);
7563    
7564                            for (int i = 0; i < folderIds.length; i++) {
7565                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7566    
7567                                    if ((i + 1) < folderIds.length) {
7568                                            query.append(WHERE_OR);
7569                                    }
7570                            }
7571    
7572                            query.append(StringPool.CLOSE_PARENTHESIS);
7573    
7574                            conjunctionable = true;
7575                    }
7576    
7577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7578                                    DLFileEntry.class.getName(),
7579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7580    
7581                    Session session = null;
7582    
7583                    try {
7584                            session = openSession();
7585    
7586                            SQLQuery q = session.createSQLQuery(sql);
7587    
7588                            q.addScalar(COUNT_COLUMN_NAME,
7589                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7590    
7591                            QueryPos qPos = QueryPos.getInstance(q);
7592    
7593                            qPos.add(groupId);
7594    
7595                            if (folderIds != null) {
7596                                    qPos.add(folderIds);
7597                            }
7598    
7599                            Long count = (Long)q.uniqueResult();
7600    
7601                            return count.intValue();
7602                    }
7603                    catch (Exception e) {
7604                            throw processException(e);
7605                    }
7606                    finally {
7607                            closeSession(session);
7608                    }
7609            }
7610    
7611            /**
7612             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7613             *
7614             * @param groupId the group ID
7615             * @param userId the user ID
7616             * @param folderId the folder ID
7617             * @return the number of matching document library file entries
7618             * @throws SystemException if a system exception occurred
7619             */
7620            public int countByG_U_F(long groupId, long userId, long folderId)
7621                    throws SystemException {
7622                    Object[] finderArgs = new Object[] { groupId, userId, folderId };
7623    
7624                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
7625                                    finderArgs, this);
7626    
7627                    if (count == null) {
7628                            StringBundler query = new StringBundler(4);
7629    
7630                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7631    
7632                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7633    
7634                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7635    
7636                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7637    
7638                            String sql = query.toString();
7639    
7640                            Session session = null;
7641    
7642                            try {
7643                                    session = openSession();
7644    
7645                                    Query q = session.createQuery(sql);
7646    
7647                                    QueryPos qPos = QueryPos.getInstance(q);
7648    
7649                                    qPos.add(groupId);
7650    
7651                                    qPos.add(userId);
7652    
7653                                    qPos.add(folderId);
7654    
7655                                    count = (Long)q.uniqueResult();
7656                            }
7657                            catch (Exception e) {
7658                                    throw processException(e);
7659                            }
7660                            finally {
7661                                    if (count == null) {
7662                                            count = Long.valueOf(0);
7663                                    }
7664    
7665                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
7666                                            finderArgs, count);
7667    
7668                                    closeSession(session);
7669                            }
7670                    }
7671    
7672                    return count.intValue();
7673            }
7674    
7675            /**
7676             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7677             *
7678             * @param groupId the group ID
7679             * @param userId the user ID
7680             * @param folderIds the folder IDs
7681             * @return the number of matching document library file entries
7682             * @throws SystemException if a system exception occurred
7683             */
7684            public int countByG_U_F(long groupId, long userId, long[] folderIds)
7685                    throws SystemException {
7686                    Object[] finderArgs = new Object[] {
7687                                    groupId, userId, StringUtil.merge(folderIds)
7688                            };
7689    
7690                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
7691                                    finderArgs, this);
7692    
7693                    if (count == null) {
7694                            StringBundler query = new StringBundler();
7695    
7696                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7697    
7698                            boolean conjunctionable = false;
7699    
7700                            if (conjunctionable) {
7701                                    query.append(WHERE_AND);
7702                            }
7703    
7704                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7705    
7706                            conjunctionable = true;
7707    
7708                            if (conjunctionable) {
7709                                    query.append(WHERE_AND);
7710                            }
7711    
7712                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7713    
7714                            conjunctionable = true;
7715    
7716                            if ((folderIds == null) || (folderIds.length > 0)) {
7717                                    if (conjunctionable) {
7718                                            query.append(WHERE_AND);
7719                                    }
7720    
7721                                    query.append(StringPool.OPEN_PARENTHESIS);
7722    
7723                                    for (int i = 0; i < folderIds.length; i++) {
7724                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7725    
7726                                            if ((i + 1) < folderIds.length) {
7727                                                    query.append(WHERE_OR);
7728                                            }
7729                                    }
7730    
7731                                    query.append(StringPool.CLOSE_PARENTHESIS);
7732    
7733                                    conjunctionable = true;
7734                            }
7735    
7736                            String sql = query.toString();
7737    
7738                            Session session = null;
7739    
7740                            try {
7741                                    session = openSession();
7742    
7743                                    Query q = session.createQuery(sql);
7744    
7745                                    QueryPos qPos = QueryPos.getInstance(q);
7746    
7747                                    qPos.add(groupId);
7748    
7749                                    qPos.add(userId);
7750    
7751                                    if (folderIds != null) {
7752                                            qPos.add(folderIds);
7753                                    }
7754    
7755                                    count = (Long)q.uniqueResult();
7756                            }
7757                            catch (Exception e) {
7758                                    throw processException(e);
7759                            }
7760                            finally {
7761                                    if (count == null) {
7762                                            count = Long.valueOf(0);
7763                                    }
7764    
7765                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
7766                                            finderArgs, count);
7767    
7768                                    closeSession(session);
7769                            }
7770                    }
7771    
7772                    return count.intValue();
7773            }
7774    
7775            /**
7776             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
7777             *
7778             * @param groupId the group ID
7779             * @param userId the user ID
7780             * @param folderId the folder ID
7781             * @return the number of matching document library file entries that the user has permission to view
7782             * @throws SystemException if a system exception occurred
7783             */
7784            public int filterCountByG_U_F(long groupId, long userId, long folderId)
7785                    throws SystemException {
7786                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7787                            return countByG_U_F(groupId, userId, folderId);
7788                    }
7789    
7790                    StringBundler query = new StringBundler(4);
7791    
7792                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7793    
7794                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7795    
7796                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7797    
7798                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7799    
7800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7801                                    DLFileEntry.class.getName(),
7802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7803    
7804                    Session session = null;
7805    
7806                    try {
7807                            session = openSession();
7808    
7809                            SQLQuery q = session.createSQLQuery(sql);
7810    
7811                            q.addScalar(COUNT_COLUMN_NAME,
7812                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7813    
7814                            QueryPos qPos = QueryPos.getInstance(q);
7815    
7816                            qPos.add(groupId);
7817    
7818                            qPos.add(userId);
7819    
7820                            qPos.add(folderId);
7821    
7822                            Long count = (Long)q.uniqueResult();
7823    
7824                            return count.intValue();
7825                    }
7826                    catch (Exception e) {
7827                            throw processException(e);
7828                    }
7829                    finally {
7830                            closeSession(session);
7831                    }
7832            }
7833    
7834            /**
7835             * 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;.
7836             *
7837             * @param groupId the group ID
7838             * @param userId the user ID
7839             * @param folderIds the folder IDs
7840             * @return the number of matching document library file entries that the user has permission to view
7841             * @throws SystemException if a system exception occurred
7842             */
7843            public int filterCountByG_U_F(long groupId, long userId, long[] folderIds)
7844                    throws SystemException {
7845                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7846                            return countByG_U_F(groupId, userId, folderIds);
7847                    }
7848    
7849                    StringBundler query = new StringBundler();
7850    
7851                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7852    
7853                    boolean conjunctionable = false;
7854    
7855                    if (conjunctionable) {
7856                            query.append(WHERE_AND);
7857                    }
7858    
7859                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7860    
7861                    conjunctionable = true;
7862    
7863                    if (conjunctionable) {
7864                            query.append(WHERE_AND);
7865                    }
7866    
7867                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7868    
7869                    conjunctionable = true;
7870    
7871                    if ((folderIds == null) || (folderIds.length > 0)) {
7872                            if (conjunctionable) {
7873                                    query.append(WHERE_AND);
7874                            }
7875    
7876                            query.append(StringPool.OPEN_PARENTHESIS);
7877    
7878                            for (int i = 0; i < folderIds.length; i++) {
7879                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7880    
7881                                    if ((i + 1) < folderIds.length) {
7882                                            query.append(WHERE_OR);
7883                                    }
7884                            }
7885    
7886                            query.append(StringPool.CLOSE_PARENTHESIS);
7887    
7888                            conjunctionable = true;
7889                    }
7890    
7891                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7892                                    DLFileEntry.class.getName(),
7893                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7894    
7895                    Session session = null;
7896    
7897                    try {
7898                            session = openSession();
7899    
7900                            SQLQuery q = session.createSQLQuery(sql);
7901    
7902                            q.addScalar(COUNT_COLUMN_NAME,
7903                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7904    
7905                            QueryPos qPos = QueryPos.getInstance(q);
7906    
7907                            qPos.add(groupId);
7908    
7909                            qPos.add(userId);
7910    
7911                            if (folderIds != null) {
7912                                    qPos.add(folderIds);
7913                            }
7914    
7915                            Long count = (Long)q.uniqueResult();
7916    
7917                            return count.intValue();
7918                    }
7919                    catch (Exception e) {
7920                            throw processException(e);
7921                    }
7922                    finally {
7923                            closeSession(session);
7924                    }
7925            }
7926    
7927            /**
7928             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and name = &#63;.
7929             *
7930             * @param groupId the group ID
7931             * @param folderId the folder ID
7932             * @param name the name
7933             * @return the number of matching document library file entries
7934             * @throws SystemException if a system exception occurred
7935             */
7936            public int countByG_F_N(long groupId, long folderId, String name)
7937                    throws SystemException {
7938                    Object[] finderArgs = new Object[] { groupId, folderId, name };
7939    
7940                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N,
7941                                    finderArgs, this);
7942    
7943                    if (count == null) {
7944                            StringBundler query = new StringBundler(4);
7945    
7946                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7947    
7948                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
7949    
7950                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
7951    
7952                            if (name == null) {
7953                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
7954                            }
7955                            else {
7956                                    if (name.equals(StringPool.BLANK)) {
7957                                            query.append(_FINDER_COLUMN_G_F_N_NAME_3);
7958                                    }
7959                                    else {
7960                                            query.append(_FINDER_COLUMN_G_F_N_NAME_2);
7961                                    }
7962                            }
7963    
7964                            String sql = query.toString();
7965    
7966                            Session session = null;
7967    
7968                            try {
7969                                    session = openSession();
7970    
7971                                    Query q = session.createQuery(sql);
7972    
7973                                    QueryPos qPos = QueryPos.getInstance(q);
7974    
7975                                    qPos.add(groupId);
7976    
7977                                    qPos.add(folderId);
7978    
7979                                    if (name != null) {
7980                                            qPos.add(name);
7981                                    }
7982    
7983                                    count = (Long)q.uniqueResult();
7984                            }
7985                            catch (Exception e) {
7986                                    throw processException(e);
7987                            }
7988                            finally {
7989                                    if (count == null) {
7990                                            count = Long.valueOf(0);
7991                                    }
7992    
7993                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N,
7994                                            finderArgs, count);
7995    
7996                                    closeSession(session);
7997                            }
7998                    }
7999    
8000                    return count.intValue();
8001            }
8002    
8003            /**
8004             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and title = &#63;.
8005             *
8006             * @param groupId the group ID
8007             * @param folderId the folder ID
8008             * @param title the title
8009             * @return the number of matching document library file entries
8010             * @throws SystemException if a system exception occurred
8011             */
8012            public int countByG_F_T(long groupId, long folderId, String title)
8013                    throws SystemException {
8014                    Object[] finderArgs = new Object[] { groupId, folderId, title };
8015    
8016                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_T,
8017                                    finderArgs, this);
8018    
8019                    if (count == null) {
8020                            StringBundler query = new StringBundler(4);
8021    
8022                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8023    
8024                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
8025    
8026                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
8027    
8028                            if (title == null) {
8029                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
8030                            }
8031                            else {
8032                                    if (title.equals(StringPool.BLANK)) {
8033                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
8034                                    }
8035                                    else {
8036                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
8037                                    }
8038                            }
8039    
8040                            String sql = query.toString();
8041    
8042                            Session session = null;
8043    
8044                            try {
8045                                    session = openSession();
8046    
8047                                    Query q = session.createQuery(sql);
8048    
8049                                    QueryPos qPos = QueryPos.getInstance(q);
8050    
8051                                    qPos.add(groupId);
8052    
8053                                    qPos.add(folderId);
8054    
8055                                    if (title != null) {
8056                                            qPos.add(title);
8057                                    }
8058    
8059                                    count = (Long)q.uniqueResult();
8060                            }
8061                            catch (Exception e) {
8062                                    throw processException(e);
8063                            }
8064                            finally {
8065                                    if (count == null) {
8066                                            count = Long.valueOf(0);
8067                                    }
8068    
8069                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T,
8070                                            finderArgs, count);
8071    
8072                                    closeSession(session);
8073                            }
8074                    }
8075    
8076                    return count.intValue();
8077            }
8078    
8079            /**
8080             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8081             *
8082             * @param groupId the group ID
8083             * @param folderId the folder ID
8084             * @param fileEntryTypeId the file entry type ID
8085             * @return the number of matching document library file entries
8086             * @throws SystemException if a system exception occurred
8087             */
8088            public int countByG_F_F(long groupId, long folderId, long fileEntryTypeId)
8089                    throws SystemException {
8090                    Object[] finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
8091    
8092                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_F,
8093                                    finderArgs, this);
8094    
8095                    if (count == null) {
8096                            StringBundler query = new StringBundler(4);
8097    
8098                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8099    
8100                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
8101    
8102                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
8103    
8104                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
8105    
8106                            String sql = query.toString();
8107    
8108                            Session session = null;
8109    
8110                            try {
8111                                    session = openSession();
8112    
8113                                    Query q = session.createQuery(sql);
8114    
8115                                    QueryPos qPos = QueryPos.getInstance(q);
8116    
8117                                    qPos.add(groupId);
8118    
8119                                    qPos.add(folderId);
8120    
8121                                    qPos.add(fileEntryTypeId);
8122    
8123                                    count = (Long)q.uniqueResult();
8124                            }
8125                            catch (Exception e) {
8126                                    throw processException(e);
8127                            }
8128                            finally {
8129                                    if (count == null) {
8130                                            count = Long.valueOf(0);
8131                                    }
8132    
8133                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_F,
8134                                            finderArgs, count);
8135    
8136                                    closeSession(session);
8137                            }
8138                    }
8139    
8140                    return count.intValue();
8141            }
8142    
8143            /**
8144             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
8145             *
8146             * @param groupId the group ID
8147             * @param folderIds the folder IDs
8148             * @param fileEntryTypeId the file entry type ID
8149             * @return the number of matching document library file entries
8150             * @throws SystemException if a system exception occurred
8151             */
8152            public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId)
8153                    throws SystemException {
8154                    Object[] finderArgs = new Object[] {
8155                                    groupId, StringUtil.merge(folderIds), fileEntryTypeId
8156                            };
8157    
8158                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_F,
8159                                    finderArgs, this);
8160    
8161                    if (count == null) {
8162                            StringBundler query = new StringBundler();
8163    
8164                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8165    
8166                            boolean conjunctionable = false;
8167    
8168                            if (conjunctionable) {
8169                                    query.append(WHERE_AND);
8170                            }
8171    
8172                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
8173    
8174                            conjunctionable = true;
8175    
8176                            if ((folderIds == null) || (folderIds.length > 0)) {
8177                                    if (conjunctionable) {
8178                                            query.append(WHERE_AND);
8179                                    }
8180    
8181                                    query.append(StringPool.OPEN_PARENTHESIS);
8182    
8183                                    for (int i = 0; i < folderIds.length; i++) {
8184                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
8185    
8186                                            if ((i + 1) < folderIds.length) {
8187                                                    query.append(WHERE_OR);
8188                                            }
8189                                    }
8190    
8191                                    query.append(StringPool.CLOSE_PARENTHESIS);
8192    
8193                                    conjunctionable = true;
8194                            }
8195    
8196                            if (conjunctionable) {
8197                                    query.append(WHERE_AND);
8198                            }
8199    
8200                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
8201    
8202                            conjunctionable = true;
8203    
8204                            String sql = query.toString();
8205    
8206                            Session session = null;
8207    
8208                            try {
8209                                    session = openSession();
8210    
8211                                    Query q = session.createQuery(sql);
8212    
8213                                    QueryPos qPos = QueryPos.getInstance(q);
8214    
8215                                    qPos.add(groupId);
8216    
8217                                    if (folderIds != null) {
8218                                            qPos.add(folderIds);
8219                                    }
8220    
8221                                    qPos.add(fileEntryTypeId);
8222    
8223                                    count = (Long)q.uniqueResult();
8224                            }
8225                            catch (Exception e) {
8226                                    throw processException(e);
8227                            }
8228                            finally {
8229                                    if (count == null) {
8230                                            count = Long.valueOf(0);
8231                                    }
8232    
8233                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_F,
8234                                            finderArgs, count);
8235    
8236                                    closeSession(session);
8237                            }
8238                    }
8239    
8240                    return count.intValue();
8241            }
8242    
8243            /**
8244             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8245             *
8246             * @param groupId the group ID
8247             * @param folderId the folder ID
8248             * @param fileEntryTypeId the file entry type ID
8249             * @return the number of matching document library file entries that the user has permission to view
8250             * @throws SystemException if a system exception occurred
8251             */
8252            public int filterCountByG_F_F(long groupId, long folderId,
8253                    long fileEntryTypeId) throws SystemException {
8254                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8255                            return countByG_F_F(groupId, folderId, fileEntryTypeId);
8256                    }
8257    
8258                    StringBundler query = new StringBundler(4);
8259    
8260                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8261    
8262                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
8263    
8264                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
8265    
8266                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
8267    
8268                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8269                                    DLFileEntry.class.getName(),
8270                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8271    
8272                    Session session = null;
8273    
8274                    try {
8275                            session = openSession();
8276    
8277                            SQLQuery q = session.createSQLQuery(sql);
8278    
8279                            q.addScalar(COUNT_COLUMN_NAME,
8280                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8281    
8282                            QueryPos qPos = QueryPos.getInstance(q);
8283    
8284                            qPos.add(groupId);
8285    
8286                            qPos.add(folderId);
8287    
8288                            qPos.add(fileEntryTypeId);
8289    
8290                            Long count = (Long)q.uniqueResult();
8291    
8292                            return count.intValue();
8293                    }
8294                    catch (Exception e) {
8295                            throw processException(e);
8296                    }
8297                    finally {
8298                            closeSession(session);
8299                    }
8300            }
8301    
8302            /**
8303             * 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;.
8304             *
8305             * @param groupId the group ID
8306             * @param folderIds the folder IDs
8307             * @param fileEntryTypeId the file entry type ID
8308             * @return the number of matching document library file entries that the user has permission to view
8309             * @throws SystemException if a system exception occurred
8310             */
8311            public int filterCountByG_F_F(long groupId, long[] folderIds,
8312                    long fileEntryTypeId) throws SystemException {
8313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8314                            return countByG_F_F(groupId, folderIds, fileEntryTypeId);
8315                    }
8316    
8317                    StringBundler query = new StringBundler();
8318    
8319                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8320    
8321                    boolean conjunctionable = false;
8322    
8323                    if (conjunctionable) {
8324                            query.append(WHERE_AND);
8325                    }
8326    
8327                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
8328    
8329                    conjunctionable = true;
8330    
8331                    if ((folderIds == null) || (folderIds.length > 0)) {
8332                            if (conjunctionable) {
8333                                    query.append(WHERE_AND);
8334                            }
8335    
8336                            query.append(StringPool.OPEN_PARENTHESIS);
8337    
8338                            for (int i = 0; i < folderIds.length; i++) {
8339                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
8340    
8341                                    if ((i + 1) < folderIds.length) {
8342                                            query.append(WHERE_OR);
8343                                    }
8344                            }
8345    
8346                            query.append(StringPool.CLOSE_PARENTHESIS);
8347    
8348                            conjunctionable = true;
8349                    }
8350    
8351                    if (conjunctionable) {
8352                            query.append(WHERE_AND);
8353                    }
8354    
8355                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
8356    
8357                    conjunctionable = true;
8358    
8359                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8360                                    DLFileEntry.class.getName(),
8361                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8362    
8363                    Session session = null;
8364    
8365                    try {
8366                            session = openSession();
8367    
8368                            SQLQuery q = session.createSQLQuery(sql);
8369    
8370                            q.addScalar(COUNT_COLUMN_NAME,
8371                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8372    
8373                            QueryPos qPos = QueryPos.getInstance(q);
8374    
8375                            qPos.add(groupId);
8376    
8377                            if (folderIds != null) {
8378                                    qPos.add(folderIds);
8379                            }
8380    
8381                            qPos.add(fileEntryTypeId);
8382    
8383                            Long count = (Long)q.uniqueResult();
8384    
8385                            return count.intValue();
8386                    }
8387                    catch (Exception e) {
8388                            throw processException(e);
8389                    }
8390                    finally {
8391                            closeSession(session);
8392                    }
8393            }
8394    
8395            /**
8396             * Returns the number of document library file entries.
8397             *
8398             * @return the number of document library file entries
8399             * @throws SystemException if a system exception occurred
8400             */
8401            public int countAll() throws SystemException {
8402                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
8403                                    FINDER_ARGS_EMPTY, this);
8404    
8405                    if (count == null) {
8406                            Session session = null;
8407    
8408                            try {
8409                                    session = openSession();
8410    
8411                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
8412    
8413                                    count = (Long)q.uniqueResult();
8414                            }
8415                            catch (Exception e) {
8416                                    throw processException(e);
8417                            }
8418                            finally {
8419                                    if (count == null) {
8420                                            count = Long.valueOf(0);
8421                                    }
8422    
8423                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
8424                                            FINDER_ARGS_EMPTY, count);
8425    
8426                                    closeSession(session);
8427                            }
8428                    }
8429    
8430                    return count.intValue();
8431            }
8432    
8433            /**
8434             * Initializes the document library file entry persistence.
8435             */
8436            public void afterPropertiesSet() {
8437                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8438                                            com.liferay.portal.util.PropsUtil.get(
8439                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
8440    
8441                    if (listenerClassNames.length > 0) {
8442                            try {
8443                                    List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
8444    
8445                                    for (String listenerClassName : listenerClassNames) {
8446                                            listenersList.add((ModelListener<DLFileEntry>)InstanceFactory.newInstance(
8447                                                            listenerClassName));
8448                                    }
8449    
8450                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8451                            }
8452                            catch (Exception e) {
8453                                    _log.error(e);
8454                            }
8455                    }
8456            }
8457    
8458            public void destroy() {
8459                    EntityCacheUtil.removeCache(DLFileEntryImpl.class.getName());
8460                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
8461                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8462            }
8463    
8464            @BeanReference(type = DLContentPersistence.class)
8465            protected DLContentPersistence dlContentPersistence;
8466            @BeanReference(type = DLFileEntryPersistence.class)
8467            protected DLFileEntryPersistence dlFileEntryPersistence;
8468            @BeanReference(type = DLFileEntryMetadataPersistence.class)
8469            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
8470            @BeanReference(type = DLFileEntryTypePersistence.class)
8471            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
8472            @BeanReference(type = DLFileRankPersistence.class)
8473            protected DLFileRankPersistence dlFileRankPersistence;
8474            @BeanReference(type = DLFileShortcutPersistence.class)
8475            protected DLFileShortcutPersistence dlFileShortcutPersistence;
8476            @BeanReference(type = DLFileVersionPersistence.class)
8477            protected DLFileVersionPersistence dlFileVersionPersistence;
8478            @BeanReference(type = DLFolderPersistence.class)
8479            protected DLFolderPersistence dlFolderPersistence;
8480            @BeanReference(type = DLSyncPersistence.class)
8481            protected DLSyncPersistence dlSyncPersistence;
8482            @BeanReference(type = ImagePersistence.class)
8483            protected ImagePersistence imagePersistence;
8484            @BeanReference(type = LockPersistence.class)
8485            protected LockPersistence lockPersistence;
8486            @BeanReference(type = ResourcePersistence.class)
8487            protected ResourcePersistence resourcePersistence;
8488            @BeanReference(type = UserPersistence.class)
8489            protected UserPersistence userPersistence;
8490            @BeanReference(type = WebDAVPropsPersistence.class)
8491            protected WebDAVPropsPersistence webDAVPropsPersistence;
8492            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
8493            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
8494            @BeanReference(type = AssetCategoryPersistence.class)
8495            protected AssetCategoryPersistence assetCategoryPersistence;
8496            @BeanReference(type = AssetEntryPersistence.class)
8497            protected AssetEntryPersistence assetEntryPersistence;
8498            @BeanReference(type = AssetLinkPersistence.class)
8499            protected AssetLinkPersistence assetLinkPersistence;
8500            @BeanReference(type = AssetTagPersistence.class)
8501            protected AssetTagPersistence assetTagPersistence;
8502            @BeanReference(type = DDMStructurePersistence.class)
8503            protected DDMStructurePersistence ddmStructurePersistence;
8504            @BeanReference(type = ExpandoValuePersistence.class)
8505            protected ExpandoValuePersistence expandoValuePersistence;
8506            private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
8507            private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
8508            private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
8509            private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
8510            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntry.uuid IS NULL";
8511            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntry.uuid = ?";
8512            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?)";
8513            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
8514            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntry.uuid = ? AND ";
8515            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?) AND ";
8516            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntry.groupId = ?";
8517            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntry.groupId = ?";
8518            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileEntry.companyId = ?";
8519            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8520            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileEntry.userId = ?";
8521            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8522            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8523                    _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8524            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
8525            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8526                    _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8527            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8528            private static final String _FINDER_COLUMN_G_U_F_GROUPID_5 = "(" +
8529                    _removeConjunction(_FINDER_COLUMN_G_U_F_GROUPID_2) + ")";
8530            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
8531            private static final String _FINDER_COLUMN_G_U_F_USERID_5 = "(" +
8532                    _removeConjunction(_FINDER_COLUMN_G_U_F_USERID_2) + ")";
8533            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
8534            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_5 = "(" +
8535                    _removeConjunction(_FINDER_COLUMN_G_U_F_FOLDERID_2) + ")";
8536            private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8537            private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8538            private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
8539            private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
8540            private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = ?)";
8541            private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8542            private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8543            private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
8544            private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
8545            private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = ?)";
8546            private static final String _FINDER_COLUMN_G_F_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8547            private static final String _FINDER_COLUMN_G_F_F_GROUPID_5 = "(" +
8548                    _removeConjunction(_FINDER_COLUMN_G_F_F_GROUPID_2) + ")";
8549            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8550            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_5 = "(" +
8551                    _removeConjunction(_FINDER_COLUMN_G_F_F_FOLDERID_2) + ")";
8552            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2 = "dlFileEntry.fileEntryTypeId = ?";
8553            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5 = "(" +
8554                    _removeConjunction(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2) + ")";
8555    
8556            private static String _removeConjunction(String sql) {
8557                    int pos = sql.indexOf(" AND ");
8558    
8559                    if (pos != -1) {
8560                            sql = sql.substring(0, pos);
8561                    }
8562    
8563                    return sql;
8564            }
8565    
8566            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntry.fileEntryId";
8567            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
8568            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1 =
8569                    "SELECT {DLFileEntry.*} FROM (SELECT DISTINCT dlFileEntry.fileEntryId FROM DLFileEntry dlFileEntry WHERE ";
8570            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2 =
8571                    ") TEMP_TABLE INNER JOIN DLFileEntry ON TEMP_TABLE.fileEntryId = DLFileEntry.fileEntryId";
8572            private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
8573            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
8574            private static final String _FILTER_ENTITY_TABLE = "DLFileEntry";
8575            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
8576            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntry.";
8577            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
8578            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
8579            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8580            private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
8581            private static DLFileEntry _nullDLFileEntry = new DLFileEntryImpl() {
8582                            @Override
8583                            public Object clone() {
8584                                    return this;
8585                            }
8586    
8587                            @Override
8588                            public CacheModel<DLFileEntry> toCacheModel() {
8589                                    return _nullDLFileEntryCacheModel;
8590                            }
8591                    };
8592    
8593            private static CacheModel<DLFileEntry> _nullDLFileEntryCacheModel = new CacheModel<DLFileEntry>() {
8594                            public DLFileEntry toEntityModel() {
8595                                    return _nullDLFileEntry;
8596                            }
8597                    };
8598    }