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