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