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