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