001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.kernel.util.Validator;
044    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045    import com.liferay.portal.model.CacheModel;
046    import com.liferay.portal.model.ModelListener;
047    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048    import com.liferay.portal.service.persistence.BatchSessionUtil;
049    import com.liferay.portal.service.persistence.GroupPersistence;
050    import com.liferay.portal.service.persistence.LockPersistence;
051    import com.liferay.portal.service.persistence.ResourcePersistence;
052    import com.liferay.portal.service.persistence.UserPersistence;
053    import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
054    import com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence;
055    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
056    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
057    
058    import com.liferay.portlet.documentlibrary.NoSuchFolderException;
059    import com.liferay.portlet.documentlibrary.model.DLFolder;
060    import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
061    import com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl;
062    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
063    
064    import java.io.Serializable;
065    
066    import java.util.ArrayList;
067    import java.util.Collections;
068    import java.util.List;
069    import java.util.Set;
070    
071    /**
072     * The persistence implementation for the document library folder service.
073     *
074     * <p>
075     * Caching information and settings can be found in <code>portal.properties</code>
076     * </p>
077     *
078     * @author Brian Wing Shun Chan
079     * @see DLFolderPersistence
080     * @see DLFolderUtil
081     * @generated
082     */
083    public class DLFolderPersistenceImpl extends BasePersistenceImpl<DLFolder>
084            implements DLFolderPersistence {
085            /*
086             * NOTE FOR DEVELOPERS:
087             *
088             * Never modify or reference this class directly. Always use {@link DLFolderUtil} to access the document library folder persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
089             */
090            public static final String FINDER_CLASS_NAME_ENTITY = DLFolderImpl.class.getName();
091            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List1";
093            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094                    ".List2";
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
096                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
105                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
107                            new String[] { String.class.getName() },
108                            DLFolderModelImpl.UUID_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
110                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112                            new String[] { String.class.getName() });
113            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
114                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
115                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
116                            new String[] { String.class.getName(), Long.class.getName() },
117                            DLFolderModelImpl.UUID_COLUMN_BITMASK |
118                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
119            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
120                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
122                            new String[] { String.class.getName(), Long.class.getName() });
123            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
124                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
126                            new String[] {
127                                    Long.class.getName(),
128                                    
129                            "java.lang.Integer", "java.lang.Integer",
130                                    "com.liferay.portal.kernel.util.OrderByComparator"
131                            });
132            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
133                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
134                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
136                            new String[] { Long.class.getName() },
137                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK);
138            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
139                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
140                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
141                            new String[] { Long.class.getName() });
142            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
143                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
144                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
145                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
146                            new String[] {
147                                    Long.class.getName(),
148                                    
149                            "java.lang.Integer", "java.lang.Integer",
150                                    "com.liferay.portal.kernel.util.OrderByComparator"
151                            });
152            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
153                    new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
154                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
155                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
156                            new String[] { Long.class.getName() },
157                            DLFolderModelImpl.COMPANYID_COLUMN_BITMASK);
158            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
159                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
160                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
161                            new String[] { Long.class.getName() });
162            public static final FinderPath FINDER_PATH_FETCH_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
163                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
164                            FINDER_CLASS_NAME_ENTITY, "fetchByRepositoryId",
165                            new String[] { Long.class.getName() },
166                            DLFolderModelImpl.REPOSITORYID_COLUMN_BITMASK);
167            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
168                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
170                            new String[] { Long.class.getName() });
171            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
172                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
173                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P",
174                            new String[] {
175                                    Long.class.getName(), Long.class.getName(),
176                                    
177                            "java.lang.Integer", "java.lang.Integer",
178                                    "com.liferay.portal.kernel.util.OrderByComparator"
179                            });
180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
181                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
182                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
183                            new String[] { Long.class.getName(), Long.class.getName() },
184                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
185                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK);
186            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
187                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
189                            new String[] { Long.class.getName(), Long.class.getName() });
190            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
191                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
192                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_N",
193                            new String[] {
194                                    Long.class.getName(), String.class.getName(),
195                                    
196                            "java.lang.Integer", "java.lang.Integer",
197                                    "com.liferay.portal.kernel.util.OrderByComparator"
198                            });
199            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
200                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
201                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_N",
202                            new String[] { Long.class.getName(), String.class.getName() },
203                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
204                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
205            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
206                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
207                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
208                            new String[] { Long.class.getName(), String.class.getName() });
209            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
210                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
211                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_M",
212                            new String[] {
213                                    Long.class.getName(), Long.class.getName(),
214                                    Boolean.class.getName(),
215                                    
216                            "java.lang.Integer", "java.lang.Integer",
217                                    "com.liferay.portal.kernel.util.OrderByComparator"
218                            });
219            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
220                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
221                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_M",
222                            new String[] {
223                                    Long.class.getName(), Long.class.getName(),
224                                    Boolean.class.getName()
225                            },
226                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
227                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
228                            DLFolderModelImpl.MOUNTPOINT_COLUMN_BITMASK);
229            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_M = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
230                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
231                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_M",
232                            new String[] {
233                                    Long.class.getName(), Long.class.getName(),
234                                    Boolean.class.getName()
235                            });
236            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
237                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
238                            FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
239                            new String[] {
240                                    Long.class.getName(), Long.class.getName(),
241                                    String.class.getName()
242                            },
243                            DLFolderModelImpl.GROUPID_COLUMN_BITMASK |
244                            DLFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
245                            DLFolderModelImpl.NAME_COLUMN_BITMASK);
246            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
247                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
248                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
249                            new String[] {
250                                    Long.class.getName(), Long.class.getName(),
251                                    String.class.getName()
252                            });
253            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
254                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
255                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
256            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
257                            DLFolderModelImpl.FINDER_CACHE_ENABLED, DLFolderImpl.class,
258                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
259            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
260                            DLFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
261                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
262    
263            /**
264             * Caches the document library folder in the entity cache if it is enabled.
265             *
266             * @param dlFolder the document library folder
267             */
268            public void cacheResult(DLFolder dlFolder) {
269                    EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
270                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
271    
272                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
273                            new Object[] { dlFolder.getUuid(), Long.valueOf(
274                                            dlFolder.getGroupId()) }, dlFolder);
275    
276                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
277                            new Object[] { Long.valueOf(dlFolder.getRepositoryId()) }, dlFolder);
278    
279                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
280                            new Object[] {
281                                    Long.valueOf(dlFolder.getGroupId()),
282                                    Long.valueOf(dlFolder.getParentFolderId()),
283                                    
284                            dlFolder.getName()
285                            }, dlFolder);
286    
287                    dlFolder.resetOriginalValues();
288            }
289    
290            /**
291             * Caches the document library folders in the entity cache if it is enabled.
292             *
293             * @param dlFolders the document library folders
294             */
295            public void cacheResult(List<DLFolder> dlFolders) {
296                    for (DLFolder dlFolder : dlFolders) {
297                            if (EntityCacheUtil.getResult(
298                                                    DLFolderModelImpl.ENTITY_CACHE_ENABLED,
299                                                    DLFolderImpl.class, dlFolder.getPrimaryKey()) == null) {
300                                    cacheResult(dlFolder);
301                            }
302                            else {
303                                    dlFolder.resetOriginalValues();
304                            }
305                    }
306            }
307    
308            /**
309             * Clears the cache for all document library folders.
310             *
311             * <p>
312             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
313             * </p>
314             */
315            @Override
316            public void clearCache() {
317                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
318                            CacheRegistryUtil.clear(DLFolderImpl.class.getName());
319                    }
320    
321                    EntityCacheUtil.clearCache(DLFolderImpl.class.getName());
322    
323                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
324                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
325                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
326            }
327    
328            /**
329             * Clears the cache for the document library folder.
330             *
331             * <p>
332             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
333             * </p>
334             */
335            @Override
336            public void clearCache(DLFolder dlFolder) {
337                    EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
338                            DLFolderImpl.class, dlFolder.getPrimaryKey());
339    
340                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
341                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
342    
343                    clearUniqueFindersCache(dlFolder);
344            }
345    
346            @Override
347            public void clearCache(List<DLFolder> dlFolders) {
348                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
349                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
350    
351                    for (DLFolder dlFolder : dlFolders) {
352                            EntityCacheUtil.removeResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
353                                    DLFolderImpl.class, dlFolder.getPrimaryKey());
354    
355                            clearUniqueFindersCache(dlFolder);
356                    }
357            }
358    
359            protected void cacheUniqueFindersCache(DLFolder dlFolder) {
360                    if (dlFolder.isNew()) {
361                            Object[] args = new Object[] {
362                                            dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
363                                    };
364    
365                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
366                                    Long.valueOf(1));
367                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
368                                    dlFolder);
369    
370                            args = new Object[] { Long.valueOf(dlFolder.getRepositoryId()) };
371    
372                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args,
373                                    Long.valueOf(1));
374                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID, args,
375                                    dlFolder);
376    
377                            args = new Object[] {
378                                            Long.valueOf(dlFolder.getGroupId()),
379                                            Long.valueOf(dlFolder.getParentFolderId()),
380                                            
381                                            dlFolder.getName()
382                                    };
383    
384                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
385                                    Long.valueOf(1));
386                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args, dlFolder);
387                    }
388                    else {
389                            DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
390    
391                            if ((dlFolderModelImpl.getColumnBitmask() &
392                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
393                                    Object[] args = new Object[] {
394                                                    dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
395                                            };
396    
397                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
398                                            Long.valueOf(1));
399                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
400                                            dlFolder);
401                            }
402    
403                            if ((dlFolderModelImpl.getColumnBitmask() &
404                                            FINDER_PATH_FETCH_BY_REPOSITORYID.getColumnBitmask()) != 0) {
405                                    Object[] args = new Object[] {
406                                                    Long.valueOf(dlFolder.getRepositoryId())
407                                            };
408    
409                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
410                                            args, Long.valueOf(1));
411                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
412                                            args, dlFolder);
413                            }
414    
415                            if ((dlFolderModelImpl.getColumnBitmask() &
416                                            FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
417                                    Object[] args = new Object[] {
418                                                    Long.valueOf(dlFolder.getGroupId()),
419                                                    Long.valueOf(dlFolder.getParentFolderId()),
420                                                    
421                                                    dlFolder.getName()
422                                            };
423    
424                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
425                                            Long.valueOf(1));
426                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
427                                            dlFolder);
428                            }
429                    }
430            }
431    
432            protected void clearUniqueFindersCache(DLFolder dlFolder) {
433                    DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
434    
435                    Object[] args = new Object[] {
436                                    dlFolder.getUuid(), Long.valueOf(dlFolder.getGroupId())
437                            };
438    
439                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
440                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
441    
442                    if ((dlFolderModelImpl.getColumnBitmask() &
443                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
444                            args = new Object[] {
445                                            dlFolderModelImpl.getOriginalUuid(),
446                                            Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
447                                    };
448    
449                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
450                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
451                    }
452    
453                    args = new Object[] { Long.valueOf(dlFolder.getRepositoryId()) };
454    
455                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
456                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID, args);
457    
458                    if ((dlFolderModelImpl.getColumnBitmask() &
459                                    FINDER_PATH_FETCH_BY_REPOSITORYID.getColumnBitmask()) != 0) {
460                            args = new Object[] {
461                                            Long.valueOf(dlFolderModelImpl.getOriginalRepositoryId())
462                                    };
463    
464                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
465                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID, args);
466                    }
467    
468                    args = new Object[] {
469                                    Long.valueOf(dlFolder.getGroupId()),
470                                    Long.valueOf(dlFolder.getParentFolderId()),
471                                    
472                                    dlFolder.getName()
473                            };
474    
475                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
476                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
477    
478                    if ((dlFolderModelImpl.getColumnBitmask() &
479                                    FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
480                            args = new Object[] {
481                                            Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
482                                            Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
483                                            
484                                            dlFolderModelImpl.getOriginalName()
485                                    };
486    
487                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
488                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
489                    }
490            }
491    
492            /**
493             * Creates a new document library folder with the primary key. Does not add the document library folder to the database.
494             *
495             * @param folderId the primary key for the new document library folder
496             * @return the new document library folder
497             */
498            public DLFolder create(long folderId) {
499                    DLFolder dlFolder = new DLFolderImpl();
500    
501                    dlFolder.setNew(true);
502                    dlFolder.setPrimaryKey(folderId);
503    
504                    String uuid = PortalUUIDUtil.generate();
505    
506                    dlFolder.setUuid(uuid);
507    
508                    return dlFolder;
509            }
510    
511            /**
512             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
513             *
514             * @param folderId the primary key of the document library folder
515             * @return the document library folder that was removed
516             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
517             * @throws SystemException if a system exception occurred
518             */
519            public DLFolder remove(long folderId)
520                    throws NoSuchFolderException, SystemException {
521                    return remove(Long.valueOf(folderId));
522            }
523    
524            /**
525             * Removes the document library folder with the primary key from the database. Also notifies the appropriate model listeners.
526             *
527             * @param primaryKey the primary key of the document library folder
528             * @return the document library folder that was removed
529             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
530             * @throws SystemException if a system exception occurred
531             */
532            @Override
533            public DLFolder remove(Serializable primaryKey)
534                    throws NoSuchFolderException, SystemException {
535                    Session session = null;
536    
537                    try {
538                            session = openSession();
539    
540                            DLFolder dlFolder = (DLFolder)session.get(DLFolderImpl.class,
541                                            primaryKey);
542    
543                            if (dlFolder == null) {
544                                    if (_log.isWarnEnabled()) {
545                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
546                                    }
547    
548                                    throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
549                                            primaryKey);
550                            }
551    
552                            return remove(dlFolder);
553                    }
554                    catch (NoSuchFolderException nsee) {
555                            throw nsee;
556                    }
557                    catch (Exception e) {
558                            throw processException(e);
559                    }
560                    finally {
561                            closeSession(session);
562                    }
563            }
564    
565            @Override
566            protected DLFolder removeImpl(DLFolder dlFolder) throws SystemException {
567                    dlFolder = toUnwrappedModel(dlFolder);
568    
569                    try {
570                            clearDLFileEntryTypes.clear(dlFolder.getPrimaryKey());
571                    }
572                    catch (Exception e) {
573                            throw processException(e);
574                    }
575                    finally {
576                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
577                    }
578    
579                    Session session = null;
580    
581                    try {
582                            session = openSession();
583    
584                            BatchSessionUtil.delete(session, dlFolder);
585                    }
586                    catch (Exception e) {
587                            throw processException(e);
588                    }
589                    finally {
590                            closeSession(session);
591                    }
592    
593                    clearCache(dlFolder);
594    
595                    return dlFolder;
596            }
597    
598            @Override
599            public DLFolder updateImpl(
600                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder,
601                    boolean merge) throws SystemException {
602                    dlFolder = toUnwrappedModel(dlFolder);
603    
604                    boolean isNew = dlFolder.isNew();
605    
606                    DLFolderModelImpl dlFolderModelImpl = (DLFolderModelImpl)dlFolder;
607    
608                    if (Validator.isNull(dlFolder.getUuid())) {
609                            String uuid = PortalUUIDUtil.generate();
610    
611                            dlFolder.setUuid(uuid);
612                    }
613    
614                    Session session = null;
615    
616                    try {
617                            session = openSession();
618    
619                            BatchSessionUtil.update(session, dlFolder, merge);
620    
621                            dlFolder.setNew(false);
622                    }
623                    catch (Exception e) {
624                            throw processException(e);
625                    }
626                    finally {
627                            closeSession(session);
628                    }
629    
630                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
631    
632                    if (isNew || !DLFolderModelImpl.COLUMN_BITMASK_ENABLED) {
633                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
634                    }
635    
636                    else {
637                            if ((dlFolderModelImpl.getColumnBitmask() &
638                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
639                                    Object[] args = new Object[] { dlFolderModelImpl.getOriginalUuid() };
640    
641                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
642                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
643                                            args);
644    
645                                    args = new Object[] { dlFolderModelImpl.getUuid() };
646    
647                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
648                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
649                                            args);
650                            }
651    
652                            if ((dlFolderModelImpl.getColumnBitmask() &
653                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
654                                    Object[] args = new Object[] {
655                                                    Long.valueOf(dlFolderModelImpl.getOriginalGroupId())
656                                            };
657    
658                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
659                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
660                                            args);
661    
662                                    args = new Object[] { Long.valueOf(dlFolderModelImpl.getGroupId()) };
663    
664                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
665                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
666                                            args);
667                            }
668    
669                            if ((dlFolderModelImpl.getColumnBitmask() &
670                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
671                                    Object[] args = new Object[] {
672                                                    Long.valueOf(dlFolderModelImpl.getOriginalCompanyId())
673                                            };
674    
675                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
676                                            args);
677                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
678                                            args);
679    
680                                    args = new Object[] {
681                                                    Long.valueOf(dlFolderModelImpl.getCompanyId())
682                                            };
683    
684                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
685                                            args);
686                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
687                                            args);
688                            }
689    
690                            if ((dlFolderModelImpl.getColumnBitmask() &
691                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
692                                    Object[] args = new Object[] {
693                                                    Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
694                                                    Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId())
695                                            };
696    
697                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
698                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
699                                            args);
700    
701                                    args = new Object[] {
702                                                    Long.valueOf(dlFolderModelImpl.getGroupId()),
703                                                    Long.valueOf(dlFolderModelImpl.getParentFolderId())
704                                            };
705    
706                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
707                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
708                                            args);
709                            }
710    
711                            if ((dlFolderModelImpl.getColumnBitmask() &
712                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
713                                    Object[] args = new Object[] {
714                                                    Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
715                                                    
716                                                    dlFolderModelImpl.getOriginalName()
717                                            };
718    
719                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
720                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
721                                            args);
722    
723                                    args = new Object[] {
724                                                    Long.valueOf(dlFolderModelImpl.getParentFolderId()),
725                                                    
726                                                    dlFolderModelImpl.getName()
727                                            };
728    
729                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
730                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
731                                            args);
732                            }
733    
734                            if ((dlFolderModelImpl.getColumnBitmask() &
735                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M.getColumnBitmask()) != 0) {
736                                    Object[] args = new Object[] {
737                                                    Long.valueOf(dlFolderModelImpl.getOriginalGroupId()),
738                                                    Long.valueOf(dlFolderModelImpl.getOriginalParentFolderId()),
739                                                    Boolean.valueOf(dlFolderModelImpl.getOriginalMountPoint())
740                                            };
741    
742                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
743                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
744                                            args);
745    
746                                    args = new Object[] {
747                                                    Long.valueOf(dlFolderModelImpl.getGroupId()),
748                                                    Long.valueOf(dlFolderModelImpl.getParentFolderId()),
749                                                    Boolean.valueOf(dlFolderModelImpl.getMountPoint())
750                                            };
751    
752                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_M, args);
753                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M,
754                                            args);
755                            }
756                    }
757    
758                    EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
759                            DLFolderImpl.class, dlFolder.getPrimaryKey(), dlFolder);
760    
761                    clearUniqueFindersCache(dlFolder);
762                    cacheUniqueFindersCache(dlFolder);
763    
764                    return dlFolder;
765            }
766    
767            protected DLFolder toUnwrappedModel(DLFolder dlFolder) {
768                    if (dlFolder instanceof DLFolderImpl) {
769                            return dlFolder;
770                    }
771    
772                    DLFolderImpl dlFolderImpl = new DLFolderImpl();
773    
774                    dlFolderImpl.setNew(dlFolder.isNew());
775                    dlFolderImpl.setPrimaryKey(dlFolder.getPrimaryKey());
776    
777                    dlFolderImpl.setUuid(dlFolder.getUuid());
778                    dlFolderImpl.setFolderId(dlFolder.getFolderId());
779                    dlFolderImpl.setGroupId(dlFolder.getGroupId());
780                    dlFolderImpl.setCompanyId(dlFolder.getCompanyId());
781                    dlFolderImpl.setUserId(dlFolder.getUserId());
782                    dlFolderImpl.setUserName(dlFolder.getUserName());
783                    dlFolderImpl.setCreateDate(dlFolder.getCreateDate());
784                    dlFolderImpl.setModifiedDate(dlFolder.getModifiedDate());
785                    dlFolderImpl.setRepositoryId(dlFolder.getRepositoryId());
786                    dlFolderImpl.setMountPoint(dlFolder.isMountPoint());
787                    dlFolderImpl.setParentFolderId(dlFolder.getParentFolderId());
788                    dlFolderImpl.setName(dlFolder.getName());
789                    dlFolderImpl.setDescription(dlFolder.getDescription());
790                    dlFolderImpl.setLastPostDate(dlFolder.getLastPostDate());
791                    dlFolderImpl.setDefaultFileEntryTypeId(dlFolder.getDefaultFileEntryTypeId());
792                    dlFolderImpl.setOverrideFileEntryTypes(dlFolder.isOverrideFileEntryTypes());
793    
794                    return dlFolderImpl;
795            }
796    
797            /**
798             * Returns the document library folder with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
799             *
800             * @param primaryKey the primary key of the document library folder
801             * @return the document library folder
802             * @throws com.liferay.portal.NoSuchModelException if a document library folder with the primary key could not be found
803             * @throws SystemException if a system exception occurred
804             */
805            @Override
806            public DLFolder findByPrimaryKey(Serializable primaryKey)
807                    throws NoSuchModelException, SystemException {
808                    return findByPrimaryKey(((Long)primaryKey).longValue());
809            }
810    
811            /**
812             * Returns the document library folder with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFolderException} if it could not be found.
813             *
814             * @param folderId the primary key of the document library folder
815             * @return the document library folder
816             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
817             * @throws SystemException if a system exception occurred
818             */
819            public DLFolder findByPrimaryKey(long folderId)
820                    throws NoSuchFolderException, SystemException {
821                    DLFolder dlFolder = fetchByPrimaryKey(folderId);
822    
823                    if (dlFolder == null) {
824                            if (_log.isWarnEnabled()) {
825                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
826                            }
827    
828                            throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
829                                    folderId);
830                    }
831    
832                    return dlFolder;
833            }
834    
835            /**
836             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
837             *
838             * @param primaryKey the primary key of the document library folder
839             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
840             * @throws SystemException if a system exception occurred
841             */
842            @Override
843            public DLFolder fetchByPrimaryKey(Serializable primaryKey)
844                    throws SystemException {
845                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
846            }
847    
848            /**
849             * Returns the document library folder with the primary key or returns <code>null</code> if it could not be found.
850             *
851             * @param folderId the primary key of the document library folder
852             * @return the document library folder, or <code>null</code> if a document library folder with the primary key could not be found
853             * @throws SystemException if a system exception occurred
854             */
855            public DLFolder fetchByPrimaryKey(long folderId) throws SystemException {
856                    DLFolder dlFolder = (DLFolder)EntityCacheUtil.getResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
857                                    DLFolderImpl.class, folderId);
858    
859                    if (dlFolder == _nullDLFolder) {
860                            return null;
861                    }
862    
863                    if (dlFolder == null) {
864                            Session session = null;
865    
866                            boolean hasException = false;
867    
868                            try {
869                                    session = openSession();
870    
871                                    dlFolder = (DLFolder)session.get(DLFolderImpl.class,
872                                                    Long.valueOf(folderId));
873                            }
874                            catch (Exception e) {
875                                    hasException = true;
876    
877                                    throw processException(e);
878                            }
879                            finally {
880                                    if (dlFolder != null) {
881                                            cacheResult(dlFolder);
882                                    }
883                                    else if (!hasException) {
884                                            EntityCacheUtil.putResult(DLFolderModelImpl.ENTITY_CACHE_ENABLED,
885                                                    DLFolderImpl.class, folderId, _nullDLFolder);
886                                    }
887    
888                                    closeSession(session);
889                            }
890                    }
891    
892                    return dlFolder;
893            }
894    
895            /**
896             * Returns all the document library folders where uuid = &#63;.
897             *
898             * @param uuid the uuid
899             * @return the matching document library folders
900             * @throws SystemException if a system exception occurred
901             */
902            public List<DLFolder> findByUuid(String uuid) throws SystemException {
903                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
904            }
905    
906            /**
907             * Returns a range of all the document library folders where uuid = &#63;.
908             *
909             * <p>
910             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
911             * </p>
912             *
913             * @param uuid the uuid
914             * @param start the lower bound of the range of document library folders
915             * @param end the upper bound of the range of document library folders (not inclusive)
916             * @return the range of matching document library folders
917             * @throws SystemException if a system exception occurred
918             */
919            public List<DLFolder> findByUuid(String uuid, int start, int end)
920                    throws SystemException {
921                    return findByUuid(uuid, start, end, null);
922            }
923    
924            /**
925             * Returns an ordered range of all the document library folders where uuid = &#63;.
926             *
927             * <p>
928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
929             * </p>
930             *
931             * @param uuid the uuid
932             * @param start the lower bound of the range of document library folders
933             * @param end the upper bound of the range of document library folders (not inclusive)
934             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
935             * @return the ordered range of matching document library folders
936             * @throws SystemException if a system exception occurred
937             */
938            public List<DLFolder> findByUuid(String uuid, int start, int end,
939                    OrderByComparator orderByComparator) throws SystemException {
940                    FinderPath finderPath = null;
941                    Object[] finderArgs = null;
942    
943                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
944                                    (orderByComparator == null)) {
945                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
946                            finderArgs = new Object[] { uuid };
947                    }
948                    else {
949                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
950                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
951                    }
952    
953                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
954                                    finderArgs, this);
955    
956                    if ((list != null) && !list.isEmpty()) {
957                            for (DLFolder dlFolder : list) {
958                                    if (!Validator.equals(uuid, dlFolder.getUuid())) {
959                                            list = null;
960    
961                                            break;
962                                    }
963                            }
964                    }
965    
966                    if (list == null) {
967                            StringBundler query = null;
968    
969                            if (orderByComparator != null) {
970                                    query = new StringBundler(3 +
971                                                    (orderByComparator.getOrderByFields().length * 3));
972                            }
973                            else {
974                                    query = new StringBundler(3);
975                            }
976    
977                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
978    
979                            if (uuid == null) {
980                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
981                            }
982                            else {
983                                    if (uuid.equals(StringPool.BLANK)) {
984                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
985                                    }
986                                    else {
987                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
988                                    }
989                            }
990    
991                            if (orderByComparator != null) {
992                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
993                                            orderByComparator);
994                            }
995    
996                            else {
997                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
998                            }
999    
1000                            String sql = query.toString();
1001    
1002                            Session session = null;
1003    
1004                            try {
1005                                    session = openSession();
1006    
1007                                    Query q = session.createQuery(sql);
1008    
1009                                    QueryPos qPos = QueryPos.getInstance(q);
1010    
1011                                    if (uuid != null) {
1012                                            qPos.add(uuid);
1013                                    }
1014    
1015                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1016                                                    end);
1017                            }
1018                            catch (Exception e) {
1019                                    throw processException(e);
1020                            }
1021                            finally {
1022                                    if (list == null) {
1023                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1024                                    }
1025                                    else {
1026                                            cacheResult(list);
1027    
1028                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1029                                    }
1030    
1031                                    closeSession(session);
1032                            }
1033                    }
1034    
1035                    return list;
1036            }
1037    
1038            /**
1039             * Returns the first document library folder in the ordered set where uuid = &#63;.
1040             *
1041             * @param uuid the uuid
1042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1043             * @return the first matching document library folder
1044             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
1045             * @throws SystemException if a system exception occurred
1046             */
1047            public DLFolder findByUuid_First(String uuid,
1048                    OrderByComparator orderByComparator)
1049                    throws NoSuchFolderException, SystemException {
1050                    DLFolder dlFolder = fetchByUuid_First(uuid, orderByComparator);
1051    
1052                    if (dlFolder != null) {
1053                            return dlFolder;
1054                    }
1055    
1056                    StringBundler msg = new StringBundler(4);
1057    
1058                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1059    
1060                    msg.append("uuid=");
1061                    msg.append(uuid);
1062    
1063                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1064    
1065                    throw new NoSuchFolderException(msg.toString());
1066            }
1067    
1068            /**
1069             * Returns the first document library folder in the ordered set where uuid = &#63;.
1070             *
1071             * @param uuid the uuid
1072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1073             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public DLFolder fetchByUuid_First(String uuid,
1077                    OrderByComparator orderByComparator) throws SystemException {
1078                    List<DLFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
1079    
1080                    if (!list.isEmpty()) {
1081                            return list.get(0);
1082                    }
1083    
1084                    return null;
1085            }
1086    
1087            /**
1088             * Returns the last document library folder in the ordered set where uuid = &#63;.
1089             *
1090             * @param uuid the uuid
1091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1092             * @return the last matching document library folder
1093             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
1094             * @throws SystemException if a system exception occurred
1095             */
1096            public DLFolder findByUuid_Last(String uuid,
1097                    OrderByComparator orderByComparator)
1098                    throws NoSuchFolderException, SystemException {
1099                    DLFolder dlFolder = fetchByUuid_Last(uuid, orderByComparator);
1100    
1101                    if (dlFolder != null) {
1102                            return dlFolder;
1103                    }
1104    
1105                    StringBundler msg = new StringBundler(4);
1106    
1107                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1108    
1109                    msg.append("uuid=");
1110                    msg.append(uuid);
1111    
1112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1113    
1114                    throw new NoSuchFolderException(msg.toString());
1115            }
1116    
1117            /**
1118             * Returns the last document library folder in the ordered set where uuid = &#63;.
1119             *
1120             * @param uuid the uuid
1121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1122             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1123             * @throws SystemException if a system exception occurred
1124             */
1125            public DLFolder fetchByUuid_Last(String uuid,
1126                    OrderByComparator orderByComparator) throws SystemException {
1127                    int count = countByUuid(uuid);
1128    
1129                    List<DLFolder> list = findByUuid(uuid, count - 1, count,
1130                                    orderByComparator);
1131    
1132                    if (!list.isEmpty()) {
1133                            return list.get(0);
1134                    }
1135    
1136                    return null;
1137            }
1138    
1139            /**
1140             * Returns the document library folders before and after the current document library folder in the ordered set where uuid = &#63;.
1141             *
1142             * @param folderId the primary key of the current document library folder
1143             * @param uuid the uuid
1144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1145             * @return the previous, current, and next document library folder
1146             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
1147             * @throws SystemException if a system exception occurred
1148             */
1149            public DLFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
1150                    OrderByComparator orderByComparator)
1151                    throws NoSuchFolderException, SystemException {
1152                    DLFolder dlFolder = findByPrimaryKey(folderId);
1153    
1154                    Session session = null;
1155    
1156                    try {
1157                            session = openSession();
1158    
1159                            DLFolder[] array = new DLFolderImpl[3];
1160    
1161                            array[0] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1162                                            orderByComparator, true);
1163    
1164                            array[1] = dlFolder;
1165    
1166                            array[2] = getByUuid_PrevAndNext(session, dlFolder, uuid,
1167                                            orderByComparator, false);
1168    
1169                            return array;
1170                    }
1171                    catch (Exception e) {
1172                            throw processException(e);
1173                    }
1174                    finally {
1175                            closeSession(session);
1176                    }
1177            }
1178    
1179            protected DLFolder getByUuid_PrevAndNext(Session session,
1180                    DLFolder dlFolder, String uuid, OrderByComparator orderByComparator,
1181                    boolean previous) {
1182                    StringBundler query = null;
1183    
1184                    if (orderByComparator != null) {
1185                            query = new StringBundler(6 +
1186                                            (orderByComparator.getOrderByFields().length * 6));
1187                    }
1188                    else {
1189                            query = new StringBundler(3);
1190                    }
1191    
1192                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1193    
1194                    if (uuid == null) {
1195                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1196                    }
1197                    else {
1198                            if (uuid.equals(StringPool.BLANK)) {
1199                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1200                            }
1201                            else {
1202                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1203                            }
1204                    }
1205    
1206                    if (orderByComparator != null) {
1207                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1208    
1209                            if (orderByConditionFields.length > 0) {
1210                                    query.append(WHERE_AND);
1211                            }
1212    
1213                            for (int i = 0; i < orderByConditionFields.length; i++) {
1214                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1215                                    query.append(orderByConditionFields[i]);
1216    
1217                                    if ((i + 1) < orderByConditionFields.length) {
1218                                            if (orderByComparator.isAscending() ^ previous) {
1219                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1220                                            }
1221                                            else {
1222                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1223                                            }
1224                                    }
1225                                    else {
1226                                            if (orderByComparator.isAscending() ^ previous) {
1227                                                    query.append(WHERE_GREATER_THAN);
1228                                            }
1229                                            else {
1230                                                    query.append(WHERE_LESSER_THAN);
1231                                            }
1232                                    }
1233                            }
1234    
1235                            query.append(ORDER_BY_CLAUSE);
1236    
1237                            String[] orderByFields = orderByComparator.getOrderByFields();
1238    
1239                            for (int i = 0; i < orderByFields.length; i++) {
1240                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1241                                    query.append(orderByFields[i]);
1242    
1243                                    if ((i + 1) < orderByFields.length) {
1244                                            if (orderByComparator.isAscending() ^ previous) {
1245                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1246                                            }
1247                                            else {
1248                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1249                                            }
1250                                    }
1251                                    else {
1252                                            if (orderByComparator.isAscending() ^ previous) {
1253                                                    query.append(ORDER_BY_ASC);
1254                                            }
1255                                            else {
1256                                                    query.append(ORDER_BY_DESC);
1257                                            }
1258                                    }
1259                            }
1260                    }
1261    
1262                    else {
1263                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1264                    }
1265    
1266                    String sql = query.toString();
1267    
1268                    Query q = session.createQuery(sql);
1269    
1270                    q.setFirstResult(0);
1271                    q.setMaxResults(2);
1272    
1273                    QueryPos qPos = QueryPos.getInstance(q);
1274    
1275                    if (uuid != null) {
1276                            qPos.add(uuid);
1277                    }
1278    
1279                    if (orderByComparator != null) {
1280                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1281    
1282                            for (Object value : values) {
1283                                    qPos.add(value);
1284                            }
1285                    }
1286    
1287                    List<DLFolder> list = q.list();
1288    
1289                    if (list.size() == 2) {
1290                            return list.get(1);
1291                    }
1292                    else {
1293                            return null;
1294                    }
1295            }
1296    
1297            /**
1298             * Returns the document library folder where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFolderException} if it could not be found.
1299             *
1300             * @param uuid the uuid
1301             * @param groupId the group ID
1302             * @return the matching document library folder
1303             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
1304             * @throws SystemException if a system exception occurred
1305             */
1306            public DLFolder findByUUID_G(String uuid, long groupId)
1307                    throws NoSuchFolderException, SystemException {
1308                    DLFolder dlFolder = fetchByUUID_G(uuid, groupId);
1309    
1310                    if (dlFolder == null) {
1311                            StringBundler msg = new StringBundler(6);
1312    
1313                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1314    
1315                            msg.append("uuid=");
1316                            msg.append(uuid);
1317    
1318                            msg.append(", groupId=");
1319                            msg.append(groupId);
1320    
1321                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1322    
1323                            if (_log.isWarnEnabled()) {
1324                                    _log.warn(msg.toString());
1325                            }
1326    
1327                            throw new NoSuchFolderException(msg.toString());
1328                    }
1329    
1330                    return dlFolder;
1331            }
1332    
1333            /**
1334             * Returns the document library folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1335             *
1336             * @param uuid the uuid
1337             * @param groupId the group ID
1338             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
1339             * @throws SystemException if a system exception occurred
1340             */
1341            public DLFolder fetchByUUID_G(String uuid, long groupId)
1342                    throws SystemException {
1343                    return fetchByUUID_G(uuid, groupId, true);
1344            }
1345    
1346            /**
1347             * Returns the document library folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1348             *
1349             * @param uuid the uuid
1350             * @param groupId the group ID
1351             * @param retrieveFromCache whether to use the finder cache
1352             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
1353             * @throws SystemException if a system exception occurred
1354             */
1355            public DLFolder fetchByUUID_G(String uuid, long groupId,
1356                    boolean retrieveFromCache) throws SystemException {
1357                    Object[] finderArgs = new Object[] { uuid, groupId };
1358    
1359                    Object result = null;
1360    
1361                    if (retrieveFromCache) {
1362                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1363                                            finderArgs, this);
1364                    }
1365    
1366                    if (result instanceof DLFolder) {
1367                            DLFolder dlFolder = (DLFolder)result;
1368    
1369                            if (!Validator.equals(uuid, dlFolder.getUuid()) ||
1370                                            (groupId != dlFolder.getGroupId())) {
1371                                    result = null;
1372                            }
1373                    }
1374    
1375                    if (result == null) {
1376                            StringBundler query = new StringBundler(4);
1377    
1378                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
1379    
1380                            if (uuid == null) {
1381                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1382                            }
1383                            else {
1384                                    if (uuid.equals(StringPool.BLANK)) {
1385                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1386                                    }
1387                                    else {
1388                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1389                                    }
1390                            }
1391    
1392                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1393    
1394                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1395    
1396                            String sql = query.toString();
1397    
1398                            Session session = null;
1399    
1400                            try {
1401                                    session = openSession();
1402    
1403                                    Query q = session.createQuery(sql);
1404    
1405                                    QueryPos qPos = QueryPos.getInstance(q);
1406    
1407                                    if (uuid != null) {
1408                                            qPos.add(uuid);
1409                                    }
1410    
1411                                    qPos.add(groupId);
1412    
1413                                    List<DLFolder> list = q.list();
1414    
1415                                    result = list;
1416    
1417                                    DLFolder dlFolder = null;
1418    
1419                                    if (list.isEmpty()) {
1420                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1421                                                    finderArgs, list);
1422                                    }
1423                                    else {
1424                                            dlFolder = list.get(0);
1425    
1426                                            cacheResult(dlFolder);
1427    
1428                                            if ((dlFolder.getUuid() == null) ||
1429                                                            !dlFolder.getUuid().equals(uuid) ||
1430                                                            (dlFolder.getGroupId() != groupId)) {
1431                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1432                                                            finderArgs, dlFolder);
1433                                            }
1434                                    }
1435    
1436                                    return dlFolder;
1437                            }
1438                            catch (Exception e) {
1439                                    throw processException(e);
1440                            }
1441                            finally {
1442                                    if (result == null) {
1443                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1444                                                    finderArgs);
1445                                    }
1446    
1447                                    closeSession(session);
1448                            }
1449                    }
1450                    else {
1451                            if (result instanceof List<?>) {
1452                                    return null;
1453                            }
1454                            else {
1455                                    return (DLFolder)result;
1456                            }
1457                    }
1458            }
1459    
1460            /**
1461             * Returns all the document library folders where groupId = &#63;.
1462             *
1463             * @param groupId the group ID
1464             * @return the matching document library folders
1465             * @throws SystemException if a system exception occurred
1466             */
1467            public List<DLFolder> findByGroupId(long groupId) throws SystemException {
1468                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1469            }
1470    
1471            /**
1472             * Returns a range of all the document library folders where groupId = &#63;.
1473             *
1474             * <p>
1475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1476             * </p>
1477             *
1478             * @param groupId the group ID
1479             * @param start the lower bound of the range of document library folders
1480             * @param end the upper bound of the range of document library folders (not inclusive)
1481             * @return the range of matching document library folders
1482             * @throws SystemException if a system exception occurred
1483             */
1484            public List<DLFolder> findByGroupId(long groupId, int start, int end)
1485                    throws SystemException {
1486                    return findByGroupId(groupId, start, end, null);
1487            }
1488    
1489            /**
1490             * Returns an ordered range of all the document library folders where groupId = &#63;.
1491             *
1492             * <p>
1493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1494             * </p>
1495             *
1496             * @param groupId the group ID
1497             * @param start the lower bound of the range of document library folders
1498             * @param end the upper bound of the range of document library folders (not inclusive)
1499             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1500             * @return the ordered range of matching document library folders
1501             * @throws SystemException if a system exception occurred
1502             */
1503            public List<DLFolder> findByGroupId(long groupId, int start, int end,
1504                    OrderByComparator orderByComparator) throws SystemException {
1505                    FinderPath finderPath = null;
1506                    Object[] finderArgs = null;
1507    
1508                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1509                                    (orderByComparator == null)) {
1510                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1511                            finderArgs = new Object[] { groupId };
1512                    }
1513                    else {
1514                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1515                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1516                    }
1517    
1518                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
1519                                    finderArgs, this);
1520    
1521                    if ((list != null) && !list.isEmpty()) {
1522                            for (DLFolder dlFolder : list) {
1523                                    if ((groupId != dlFolder.getGroupId())) {
1524                                            list = null;
1525    
1526                                            break;
1527                                    }
1528                            }
1529                    }
1530    
1531                    if (list == null) {
1532                            StringBundler query = null;
1533    
1534                            if (orderByComparator != null) {
1535                                    query = new StringBundler(3 +
1536                                                    (orderByComparator.getOrderByFields().length * 3));
1537                            }
1538                            else {
1539                                    query = new StringBundler(3);
1540                            }
1541    
1542                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
1543    
1544                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1545    
1546                            if (orderByComparator != null) {
1547                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1548                                            orderByComparator);
1549                            }
1550    
1551                            else {
1552                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1553                            }
1554    
1555                            String sql = query.toString();
1556    
1557                            Session session = null;
1558    
1559                            try {
1560                                    session = openSession();
1561    
1562                                    Query q = session.createQuery(sql);
1563    
1564                                    QueryPos qPos = QueryPos.getInstance(q);
1565    
1566                                    qPos.add(groupId);
1567    
1568                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
1569                                                    end);
1570                            }
1571                            catch (Exception e) {
1572                                    throw processException(e);
1573                            }
1574                            finally {
1575                                    if (list == null) {
1576                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1577                                    }
1578                                    else {
1579                                            cacheResult(list);
1580    
1581                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1582                                    }
1583    
1584                                    closeSession(session);
1585                            }
1586                    }
1587    
1588                    return list;
1589            }
1590    
1591            /**
1592             * Returns the first document library folder in the ordered set where groupId = &#63;.
1593             *
1594             * @param groupId the group ID
1595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1596             * @return the first matching document library folder
1597             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
1598             * @throws SystemException if a system exception occurred
1599             */
1600            public DLFolder findByGroupId_First(long groupId,
1601                    OrderByComparator orderByComparator)
1602                    throws NoSuchFolderException, SystemException {
1603                    DLFolder dlFolder = fetchByGroupId_First(groupId, orderByComparator);
1604    
1605                    if (dlFolder != null) {
1606                            return dlFolder;
1607                    }
1608    
1609                    StringBundler msg = new StringBundler(4);
1610    
1611                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612    
1613                    msg.append("groupId=");
1614                    msg.append(groupId);
1615    
1616                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1617    
1618                    throw new NoSuchFolderException(msg.toString());
1619            }
1620    
1621            /**
1622             * Returns the first document library folder in the ordered set where groupId = &#63;.
1623             *
1624             * @param groupId the group ID
1625             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1626             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
1627             * @throws SystemException if a system exception occurred
1628             */
1629            public DLFolder fetchByGroupId_First(long groupId,
1630                    OrderByComparator orderByComparator) throws SystemException {
1631                    List<DLFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1632    
1633                    if (!list.isEmpty()) {
1634                            return list.get(0);
1635                    }
1636    
1637                    return null;
1638            }
1639    
1640            /**
1641             * Returns the last document library folder in the ordered set where groupId = &#63;.
1642             *
1643             * @param groupId the group ID
1644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1645             * @return the last matching document library folder
1646             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
1647             * @throws SystemException if a system exception occurred
1648             */
1649            public DLFolder findByGroupId_Last(long groupId,
1650                    OrderByComparator orderByComparator)
1651                    throws NoSuchFolderException, SystemException {
1652                    DLFolder dlFolder = fetchByGroupId_Last(groupId, orderByComparator);
1653    
1654                    if (dlFolder != null) {
1655                            return dlFolder;
1656                    }
1657    
1658                    StringBundler msg = new StringBundler(4);
1659    
1660                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1661    
1662                    msg.append("groupId=");
1663                    msg.append(groupId);
1664    
1665                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1666    
1667                    throw new NoSuchFolderException(msg.toString());
1668            }
1669    
1670            /**
1671             * Returns the last document library folder in the ordered set where groupId = &#63;.
1672             *
1673             * @param groupId the group ID
1674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1675             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
1676             * @throws SystemException if a system exception occurred
1677             */
1678            public DLFolder fetchByGroupId_Last(long groupId,
1679                    OrderByComparator orderByComparator) throws SystemException {
1680                    int count = countByGroupId(groupId);
1681    
1682                    List<DLFolder> list = findByGroupId(groupId, count - 1, count,
1683                                    orderByComparator);
1684    
1685                    if (!list.isEmpty()) {
1686                            return list.get(0);
1687                    }
1688    
1689                    return null;
1690            }
1691    
1692            /**
1693             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63;.
1694             *
1695             * @param folderId the primary key of the current document library folder
1696             * @param groupId the group ID
1697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1698             * @return the previous, current, and next document library folder
1699             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
1700             * @throws SystemException if a system exception occurred
1701             */
1702            public DLFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1703                    OrderByComparator orderByComparator)
1704                    throws NoSuchFolderException, SystemException {
1705                    DLFolder dlFolder = findByPrimaryKey(folderId);
1706    
1707                    Session session = null;
1708    
1709                    try {
1710                            session = openSession();
1711    
1712                            DLFolder[] array = new DLFolderImpl[3];
1713    
1714                            array[0] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1715                                            orderByComparator, true);
1716    
1717                            array[1] = dlFolder;
1718    
1719                            array[2] = getByGroupId_PrevAndNext(session, dlFolder, groupId,
1720                                            orderByComparator, false);
1721    
1722                            return array;
1723                    }
1724                    catch (Exception e) {
1725                            throw processException(e);
1726                    }
1727                    finally {
1728                            closeSession(session);
1729                    }
1730            }
1731    
1732            protected DLFolder getByGroupId_PrevAndNext(Session session,
1733                    DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
1734                    boolean previous) {
1735                    StringBundler query = null;
1736    
1737                    if (orderByComparator != null) {
1738                            query = new StringBundler(6 +
1739                                            (orderByComparator.getOrderByFields().length * 6));
1740                    }
1741                    else {
1742                            query = new StringBundler(3);
1743                    }
1744    
1745                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
1746    
1747                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1748    
1749                    if (orderByComparator != null) {
1750                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1751    
1752                            if (orderByConditionFields.length > 0) {
1753                                    query.append(WHERE_AND);
1754                            }
1755    
1756                            for (int i = 0; i < orderByConditionFields.length; i++) {
1757                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1758                                    query.append(orderByConditionFields[i]);
1759    
1760                                    if ((i + 1) < orderByConditionFields.length) {
1761                                            if (orderByComparator.isAscending() ^ previous) {
1762                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1763                                            }
1764                                            else {
1765                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1766                                            }
1767                                    }
1768                                    else {
1769                                            if (orderByComparator.isAscending() ^ previous) {
1770                                                    query.append(WHERE_GREATER_THAN);
1771                                            }
1772                                            else {
1773                                                    query.append(WHERE_LESSER_THAN);
1774                                            }
1775                                    }
1776                            }
1777    
1778                            query.append(ORDER_BY_CLAUSE);
1779    
1780                            String[] orderByFields = orderByComparator.getOrderByFields();
1781    
1782                            for (int i = 0; i < orderByFields.length; i++) {
1783                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1784                                    query.append(orderByFields[i]);
1785    
1786                                    if ((i + 1) < orderByFields.length) {
1787                                            if (orderByComparator.isAscending() ^ previous) {
1788                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1789                                            }
1790                                            else {
1791                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1792                                            }
1793                                    }
1794                                    else {
1795                                            if (orderByComparator.isAscending() ^ previous) {
1796                                                    query.append(ORDER_BY_ASC);
1797                                            }
1798                                            else {
1799                                                    query.append(ORDER_BY_DESC);
1800                                            }
1801                                    }
1802                            }
1803                    }
1804    
1805                    else {
1806                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1807                    }
1808    
1809                    String sql = query.toString();
1810    
1811                    Query q = session.createQuery(sql);
1812    
1813                    q.setFirstResult(0);
1814                    q.setMaxResults(2);
1815    
1816                    QueryPos qPos = QueryPos.getInstance(q);
1817    
1818                    qPos.add(groupId);
1819    
1820                    if (orderByComparator != null) {
1821                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
1822    
1823                            for (Object value : values) {
1824                                    qPos.add(value);
1825                            }
1826                    }
1827    
1828                    List<DLFolder> list = q.list();
1829    
1830                    if (list.size() == 2) {
1831                            return list.get(1);
1832                    }
1833                    else {
1834                            return null;
1835                    }
1836            }
1837    
1838            /**
1839             * Returns all the document library folders that the user has permission to view where groupId = &#63;.
1840             *
1841             * @param groupId the group ID
1842             * @return the matching document library folders that the user has permission to view
1843             * @throws SystemException if a system exception occurred
1844             */
1845            public List<DLFolder> filterFindByGroupId(long groupId)
1846                    throws SystemException {
1847                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1848                            QueryUtil.ALL_POS, null);
1849            }
1850    
1851            /**
1852             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63;.
1853             *
1854             * <p>
1855             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1856             * </p>
1857             *
1858             * @param groupId the group ID
1859             * @param start the lower bound of the range of document library folders
1860             * @param end the upper bound of the range of document library folders (not inclusive)
1861             * @return the range of matching document library folders that the user has permission to view
1862             * @throws SystemException if a system exception occurred
1863             */
1864            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end)
1865                    throws SystemException {
1866                    return filterFindByGroupId(groupId, start, end, null);
1867            }
1868    
1869            /**
1870             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63;.
1871             *
1872             * <p>
1873             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1874             * </p>
1875             *
1876             * @param groupId the group ID
1877             * @param start the lower bound of the range of document library folders
1878             * @param end the upper bound of the range of document library folders (not inclusive)
1879             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1880             * @return the ordered range of matching document library folders that the user has permission to view
1881             * @throws SystemException if a system exception occurred
1882             */
1883            public List<DLFolder> filterFindByGroupId(long groupId, int start, int end,
1884                    OrderByComparator orderByComparator) throws SystemException {
1885                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1886                            return findByGroupId(groupId, start, end, orderByComparator);
1887                    }
1888    
1889                    StringBundler query = null;
1890    
1891                    if (orderByComparator != null) {
1892                            query = new StringBundler(3 +
1893                                            (orderByComparator.getOrderByFields().length * 3));
1894                    }
1895                    else {
1896                            query = new StringBundler(3);
1897                    }
1898    
1899                    if (getDB().isSupportsInlineDistinct()) {
1900                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
1901                    }
1902                    else {
1903                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1904                    }
1905    
1906                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1907    
1908                    if (!getDB().isSupportsInlineDistinct()) {
1909                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1910                    }
1911    
1912                    if (orderByComparator != null) {
1913                            if (getDB().isSupportsInlineDistinct()) {
1914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1915                                            orderByComparator);
1916                            }
1917                            else {
1918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1919                                            orderByComparator);
1920                            }
1921                    }
1922    
1923                    else {
1924                            if (getDB().isSupportsInlineDistinct()) {
1925                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
1926                            }
1927                            else {
1928                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
1929                            }
1930                    }
1931    
1932                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1933                                    DLFolder.class.getName(),
1934                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1935    
1936                    Session session = null;
1937    
1938                    try {
1939                            session = openSession();
1940    
1941                            SQLQuery q = session.createSQLQuery(sql);
1942    
1943                            if (getDB().isSupportsInlineDistinct()) {
1944                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
1945                            }
1946                            else {
1947                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
1948                            }
1949    
1950                            QueryPos qPos = QueryPos.getInstance(q);
1951    
1952                            qPos.add(groupId);
1953    
1954                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
1955                    }
1956                    catch (Exception e) {
1957                            throw processException(e);
1958                    }
1959                    finally {
1960                            closeSession(session);
1961                    }
1962            }
1963    
1964            /**
1965             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63;.
1966             *
1967             * @param folderId the primary key of the current document library folder
1968             * @param groupId the group ID
1969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1970             * @return the previous, current, and next document library folder
1971             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
1972             * @throws SystemException if a system exception occurred
1973             */
1974            public DLFolder[] filterFindByGroupId_PrevAndNext(long folderId,
1975                    long groupId, OrderByComparator orderByComparator)
1976                    throws NoSuchFolderException, SystemException {
1977                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1978                            return findByGroupId_PrevAndNext(folderId, groupId,
1979                                    orderByComparator);
1980                    }
1981    
1982                    DLFolder dlFolder = findByPrimaryKey(folderId);
1983    
1984                    Session session = null;
1985    
1986                    try {
1987                            session = openSession();
1988    
1989                            DLFolder[] array = new DLFolderImpl[3];
1990    
1991                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1992                                            groupId, orderByComparator, true);
1993    
1994                            array[1] = dlFolder;
1995    
1996                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFolder,
1997                                            groupId, orderByComparator, false);
1998    
1999                            return array;
2000                    }
2001                    catch (Exception e) {
2002                            throw processException(e);
2003                    }
2004                    finally {
2005                            closeSession(session);
2006                    }
2007            }
2008    
2009            protected DLFolder filterGetByGroupId_PrevAndNext(Session session,
2010                    DLFolder dlFolder, long groupId, OrderByComparator orderByComparator,
2011                    boolean previous) {
2012                    StringBundler query = null;
2013    
2014                    if (orderByComparator != null) {
2015                            query = new StringBundler(6 +
2016                                            (orderByComparator.getOrderByFields().length * 6));
2017                    }
2018                    else {
2019                            query = new StringBundler(3);
2020                    }
2021    
2022                    if (getDB().isSupportsInlineDistinct()) {
2023                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
2024                    }
2025                    else {
2026                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2027                    }
2028    
2029                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2030    
2031                    if (!getDB().isSupportsInlineDistinct()) {
2032                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2033                    }
2034    
2035                    if (orderByComparator != null) {
2036                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2037    
2038                            if (orderByConditionFields.length > 0) {
2039                                    query.append(WHERE_AND);
2040                            }
2041    
2042                            for (int i = 0; i < orderByConditionFields.length; i++) {
2043                                    if (getDB().isSupportsInlineDistinct()) {
2044                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2045                                    }
2046                                    else {
2047                                            query.append(_ORDER_BY_ENTITY_TABLE);
2048                                    }
2049    
2050                                    query.append(orderByConditionFields[i]);
2051    
2052                                    if ((i + 1) < orderByConditionFields.length) {
2053                                            if (orderByComparator.isAscending() ^ previous) {
2054                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2055                                            }
2056                                            else {
2057                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2058                                            }
2059                                    }
2060                                    else {
2061                                            if (orderByComparator.isAscending() ^ previous) {
2062                                                    query.append(WHERE_GREATER_THAN);
2063                                            }
2064                                            else {
2065                                                    query.append(WHERE_LESSER_THAN);
2066                                            }
2067                                    }
2068                            }
2069    
2070                            query.append(ORDER_BY_CLAUSE);
2071    
2072                            String[] orderByFields = orderByComparator.getOrderByFields();
2073    
2074                            for (int i = 0; i < orderByFields.length; i++) {
2075                                    if (getDB().isSupportsInlineDistinct()) {
2076                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2077                                    }
2078                                    else {
2079                                            query.append(_ORDER_BY_ENTITY_TABLE);
2080                                    }
2081    
2082                                    query.append(orderByFields[i]);
2083    
2084                                    if ((i + 1) < orderByFields.length) {
2085                                            if (orderByComparator.isAscending() ^ previous) {
2086                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2087                                            }
2088                                            else {
2089                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2090                                            }
2091                                    }
2092                                    else {
2093                                            if (orderByComparator.isAscending() ^ previous) {
2094                                                    query.append(ORDER_BY_ASC);
2095                                            }
2096                                            else {
2097                                                    query.append(ORDER_BY_DESC);
2098                                            }
2099                                    }
2100                            }
2101                    }
2102    
2103                    else {
2104                            if (getDB().isSupportsInlineDistinct()) {
2105                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2106                            }
2107                            else {
2108                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
2109                            }
2110                    }
2111    
2112                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2113                                    DLFolder.class.getName(),
2114                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2115    
2116                    SQLQuery q = session.createSQLQuery(sql);
2117    
2118                    q.setFirstResult(0);
2119                    q.setMaxResults(2);
2120    
2121                    if (getDB().isSupportsInlineDistinct()) {
2122                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
2123                    }
2124                    else {
2125                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
2126                    }
2127    
2128                    QueryPos qPos = QueryPos.getInstance(q);
2129    
2130                    qPos.add(groupId);
2131    
2132                    if (orderByComparator != null) {
2133                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2134    
2135                            for (Object value : values) {
2136                                    qPos.add(value);
2137                            }
2138                    }
2139    
2140                    List<DLFolder> list = q.list();
2141    
2142                    if (list.size() == 2) {
2143                            return list.get(1);
2144                    }
2145                    else {
2146                            return null;
2147                    }
2148            }
2149    
2150            /**
2151             * Returns all the document library folders where companyId = &#63;.
2152             *
2153             * @param companyId the company ID
2154             * @return the matching document library folders
2155             * @throws SystemException if a system exception occurred
2156             */
2157            public List<DLFolder> findByCompanyId(long companyId)
2158                    throws SystemException {
2159                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2160                            null);
2161            }
2162    
2163            /**
2164             * Returns a range of all the document library folders where companyId = &#63;.
2165             *
2166             * <p>
2167             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2168             * </p>
2169             *
2170             * @param companyId the company ID
2171             * @param start the lower bound of the range of document library folders
2172             * @param end the upper bound of the range of document library folders (not inclusive)
2173             * @return the range of matching document library folders
2174             * @throws SystemException if a system exception occurred
2175             */
2176            public List<DLFolder> findByCompanyId(long companyId, int start, int end)
2177                    throws SystemException {
2178                    return findByCompanyId(companyId, start, end, null);
2179            }
2180    
2181            /**
2182             * Returns an ordered range of all the document library folders where companyId = &#63;.
2183             *
2184             * <p>
2185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2186             * </p>
2187             *
2188             * @param companyId the company ID
2189             * @param start the lower bound of the range of document library folders
2190             * @param end the upper bound of the range of document library folders (not inclusive)
2191             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2192             * @return the ordered range of matching document library folders
2193             * @throws SystemException if a system exception occurred
2194             */
2195            public List<DLFolder> findByCompanyId(long companyId, int start, int end,
2196                    OrderByComparator orderByComparator) throws SystemException {
2197                    FinderPath finderPath = null;
2198                    Object[] finderArgs = null;
2199    
2200                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2201                                    (orderByComparator == null)) {
2202                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2203                            finderArgs = new Object[] { companyId };
2204                    }
2205                    else {
2206                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2207                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2208                    }
2209    
2210                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2211                                    finderArgs, this);
2212    
2213                    if ((list != null) && !list.isEmpty()) {
2214                            for (DLFolder dlFolder : list) {
2215                                    if ((companyId != dlFolder.getCompanyId())) {
2216                                            list = null;
2217    
2218                                            break;
2219                                    }
2220                            }
2221                    }
2222    
2223                    if (list == null) {
2224                            StringBundler query = null;
2225    
2226                            if (orderByComparator != null) {
2227                                    query = new StringBundler(3 +
2228                                                    (orderByComparator.getOrderByFields().length * 3));
2229                            }
2230                            else {
2231                                    query = new StringBundler(3);
2232                            }
2233    
2234                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2235    
2236                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2237    
2238                            if (orderByComparator != null) {
2239                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2240                                            orderByComparator);
2241                            }
2242    
2243                            else {
2244                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2245                            }
2246    
2247                            String sql = query.toString();
2248    
2249                            Session session = null;
2250    
2251                            try {
2252                                    session = openSession();
2253    
2254                                    Query q = session.createQuery(sql);
2255    
2256                                    QueryPos qPos = QueryPos.getInstance(q);
2257    
2258                                    qPos.add(companyId);
2259    
2260                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2261                                                    end);
2262                            }
2263                            catch (Exception e) {
2264                                    throw processException(e);
2265                            }
2266                            finally {
2267                                    if (list == null) {
2268                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2269                                    }
2270                                    else {
2271                                            cacheResult(list);
2272    
2273                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2274                                    }
2275    
2276                                    closeSession(session);
2277                            }
2278                    }
2279    
2280                    return list;
2281            }
2282    
2283            /**
2284             * Returns the first document library folder in the ordered set where companyId = &#63;.
2285             *
2286             * @param companyId the company ID
2287             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2288             * @return the first matching document library folder
2289             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
2290             * @throws SystemException if a system exception occurred
2291             */
2292            public DLFolder findByCompanyId_First(long companyId,
2293                    OrderByComparator orderByComparator)
2294                    throws NoSuchFolderException, SystemException {
2295                    DLFolder dlFolder = fetchByCompanyId_First(companyId, orderByComparator);
2296    
2297                    if (dlFolder != null) {
2298                            return dlFolder;
2299                    }
2300    
2301                    StringBundler msg = new StringBundler(4);
2302    
2303                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2304    
2305                    msg.append("companyId=");
2306                    msg.append(companyId);
2307    
2308                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2309    
2310                    throw new NoSuchFolderException(msg.toString());
2311            }
2312    
2313            /**
2314             * Returns the first document library folder in the ordered set where companyId = &#63;.
2315             *
2316             * @param companyId the company ID
2317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2318             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
2319             * @throws SystemException if a system exception occurred
2320             */
2321            public DLFolder fetchByCompanyId_First(long companyId,
2322                    OrderByComparator orderByComparator) throws SystemException {
2323                    List<DLFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2324    
2325                    if (!list.isEmpty()) {
2326                            return list.get(0);
2327                    }
2328    
2329                    return null;
2330            }
2331    
2332            /**
2333             * Returns the last document library folder in the ordered set where companyId = &#63;.
2334             *
2335             * @param companyId the company ID
2336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2337             * @return the last matching document library folder
2338             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
2339             * @throws SystemException if a system exception occurred
2340             */
2341            public DLFolder findByCompanyId_Last(long companyId,
2342                    OrderByComparator orderByComparator)
2343                    throws NoSuchFolderException, SystemException {
2344                    DLFolder dlFolder = fetchByCompanyId_Last(companyId, orderByComparator);
2345    
2346                    if (dlFolder != null) {
2347                            return dlFolder;
2348                    }
2349    
2350                    StringBundler msg = new StringBundler(4);
2351    
2352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2353    
2354                    msg.append("companyId=");
2355                    msg.append(companyId);
2356    
2357                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2358    
2359                    throw new NoSuchFolderException(msg.toString());
2360            }
2361    
2362            /**
2363             * Returns the last document library folder in the ordered set where companyId = &#63;.
2364             *
2365             * @param companyId the company ID
2366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2367             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
2368             * @throws SystemException if a system exception occurred
2369             */
2370            public DLFolder fetchByCompanyId_Last(long companyId,
2371                    OrderByComparator orderByComparator) throws SystemException {
2372                    int count = countByCompanyId(companyId);
2373    
2374                    List<DLFolder> list = findByCompanyId(companyId, count - 1, count,
2375                                    orderByComparator);
2376    
2377                    if (!list.isEmpty()) {
2378                            return list.get(0);
2379                    }
2380    
2381                    return null;
2382            }
2383    
2384            /**
2385             * Returns the document library folders before and after the current document library folder in the ordered set where companyId = &#63;.
2386             *
2387             * @param folderId the primary key of the current document library folder
2388             * @param companyId the company ID
2389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2390             * @return the previous, current, and next document library folder
2391             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
2392             * @throws SystemException if a system exception occurred
2393             */
2394            public DLFolder[] findByCompanyId_PrevAndNext(long folderId,
2395                    long companyId, OrderByComparator orderByComparator)
2396                    throws NoSuchFolderException, SystemException {
2397                    DLFolder dlFolder = findByPrimaryKey(folderId);
2398    
2399                    Session session = null;
2400    
2401                    try {
2402                            session = openSession();
2403    
2404                            DLFolder[] array = new DLFolderImpl[3];
2405    
2406                            array[0] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2407                                            orderByComparator, true);
2408    
2409                            array[1] = dlFolder;
2410    
2411                            array[2] = getByCompanyId_PrevAndNext(session, dlFolder, companyId,
2412                                            orderByComparator, false);
2413    
2414                            return array;
2415                    }
2416                    catch (Exception e) {
2417                            throw processException(e);
2418                    }
2419                    finally {
2420                            closeSession(session);
2421                    }
2422            }
2423    
2424            protected DLFolder getByCompanyId_PrevAndNext(Session session,
2425                    DLFolder dlFolder, long companyId, OrderByComparator orderByComparator,
2426                    boolean previous) {
2427                    StringBundler query = null;
2428    
2429                    if (orderByComparator != null) {
2430                            query = new StringBundler(6 +
2431                                            (orderByComparator.getOrderByFields().length * 6));
2432                    }
2433                    else {
2434                            query = new StringBundler(3);
2435                    }
2436    
2437                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
2438    
2439                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2440    
2441                    if (orderByComparator != null) {
2442                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2443    
2444                            if (orderByConditionFields.length > 0) {
2445                                    query.append(WHERE_AND);
2446                            }
2447    
2448                            for (int i = 0; i < orderByConditionFields.length; i++) {
2449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2450                                    query.append(orderByConditionFields[i]);
2451    
2452                                    if ((i + 1) < orderByConditionFields.length) {
2453                                            if (orderByComparator.isAscending() ^ previous) {
2454                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2455                                            }
2456                                            else {
2457                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2458                                            }
2459                                    }
2460                                    else {
2461                                            if (orderByComparator.isAscending() ^ previous) {
2462                                                    query.append(WHERE_GREATER_THAN);
2463                                            }
2464                                            else {
2465                                                    query.append(WHERE_LESSER_THAN);
2466                                            }
2467                                    }
2468                            }
2469    
2470                            query.append(ORDER_BY_CLAUSE);
2471    
2472                            String[] orderByFields = orderByComparator.getOrderByFields();
2473    
2474                            for (int i = 0; i < orderByFields.length; i++) {
2475                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2476                                    query.append(orderByFields[i]);
2477    
2478                                    if ((i + 1) < orderByFields.length) {
2479                                            if (orderByComparator.isAscending() ^ previous) {
2480                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2481                                            }
2482                                            else {
2483                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2484                                            }
2485                                    }
2486                                    else {
2487                                            if (orderByComparator.isAscending() ^ previous) {
2488                                                    query.append(ORDER_BY_ASC);
2489                                            }
2490                                            else {
2491                                                    query.append(ORDER_BY_DESC);
2492                                            }
2493                                    }
2494                            }
2495                    }
2496    
2497                    else {
2498                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2499                    }
2500    
2501                    String sql = query.toString();
2502    
2503                    Query q = session.createQuery(sql);
2504    
2505                    q.setFirstResult(0);
2506                    q.setMaxResults(2);
2507    
2508                    QueryPos qPos = QueryPos.getInstance(q);
2509    
2510                    qPos.add(companyId);
2511    
2512                    if (orderByComparator != null) {
2513                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
2514    
2515                            for (Object value : values) {
2516                                    qPos.add(value);
2517                            }
2518                    }
2519    
2520                    List<DLFolder> list = q.list();
2521    
2522                    if (list.size() == 2) {
2523                            return list.get(1);
2524                    }
2525                    else {
2526                            return null;
2527                    }
2528            }
2529    
2530            /**
2531             * Returns the document library folder where repositoryId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFolderException} if it could not be found.
2532             *
2533             * @param repositoryId the repository ID
2534             * @return the matching document library folder
2535             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
2536             * @throws SystemException if a system exception occurred
2537             */
2538            public DLFolder findByRepositoryId(long repositoryId)
2539                    throws NoSuchFolderException, SystemException {
2540                    DLFolder dlFolder = fetchByRepositoryId(repositoryId);
2541    
2542                    if (dlFolder == null) {
2543                            StringBundler msg = new StringBundler(4);
2544    
2545                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2546    
2547                            msg.append("repositoryId=");
2548                            msg.append(repositoryId);
2549    
2550                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2551    
2552                            if (_log.isWarnEnabled()) {
2553                                    _log.warn(msg.toString());
2554                            }
2555    
2556                            throw new NoSuchFolderException(msg.toString());
2557                    }
2558    
2559                    return dlFolder;
2560            }
2561    
2562            /**
2563             * Returns the document library folder where repositoryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2564             *
2565             * @param repositoryId the repository ID
2566             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
2567             * @throws SystemException if a system exception occurred
2568             */
2569            public DLFolder fetchByRepositoryId(long repositoryId)
2570                    throws SystemException {
2571                    return fetchByRepositoryId(repositoryId, true);
2572            }
2573    
2574            /**
2575             * Returns the document library folder where repositoryId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2576             *
2577             * @param repositoryId the repository ID
2578             * @param retrieveFromCache whether to use the finder cache
2579             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
2580             * @throws SystemException if a system exception occurred
2581             */
2582            public DLFolder fetchByRepositoryId(long repositoryId,
2583                    boolean retrieveFromCache) throws SystemException {
2584                    Object[] finderArgs = new Object[] { repositoryId };
2585    
2586                    Object result = null;
2587    
2588                    if (retrieveFromCache) {
2589                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2590                                            finderArgs, this);
2591                    }
2592    
2593                    if (result instanceof DLFolder) {
2594                            DLFolder dlFolder = (DLFolder)result;
2595    
2596                            if ((repositoryId != dlFolder.getRepositoryId())) {
2597                                    result = null;
2598                            }
2599                    }
2600    
2601                    if (result == null) {
2602                            StringBundler query = new StringBundler(3);
2603    
2604                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2605    
2606                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2607    
2608                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2609    
2610                            String sql = query.toString();
2611    
2612                            Session session = null;
2613    
2614                            try {
2615                                    session = openSession();
2616    
2617                                    Query q = session.createQuery(sql);
2618    
2619                                    QueryPos qPos = QueryPos.getInstance(q);
2620    
2621                                    qPos.add(repositoryId);
2622    
2623                                    List<DLFolder> list = q.list();
2624    
2625                                    result = list;
2626    
2627                                    DLFolder dlFolder = null;
2628    
2629                                    if (list.isEmpty()) {
2630                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2631                                                    finderArgs, list);
2632                                    }
2633                                    else {
2634                                            dlFolder = list.get(0);
2635    
2636                                            cacheResult(dlFolder);
2637    
2638                                            if ((dlFolder.getRepositoryId() != repositoryId)) {
2639                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2640                                                            finderArgs, dlFolder);
2641                                            }
2642                                    }
2643    
2644                                    return dlFolder;
2645                            }
2646                            catch (Exception e) {
2647                                    throw processException(e);
2648                            }
2649                            finally {
2650                                    if (result == null) {
2651                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_REPOSITORYID,
2652                                                    finderArgs);
2653                                    }
2654    
2655                                    closeSession(session);
2656                            }
2657                    }
2658                    else {
2659                            if (result instanceof List<?>) {
2660                                    return null;
2661                            }
2662                            else {
2663                                    return (DLFolder)result;
2664                            }
2665                    }
2666            }
2667    
2668            /**
2669             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63;.
2670             *
2671             * @param groupId the group ID
2672             * @param parentFolderId the parent folder ID
2673             * @return the matching document library folders
2674             * @throws SystemException if a system exception occurred
2675             */
2676            public List<DLFolder> findByG_P(long groupId, long parentFolderId)
2677                    throws SystemException {
2678                    return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2679                            QueryUtil.ALL_POS, null);
2680            }
2681    
2682            /**
2683             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
2684             *
2685             * <p>
2686             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2687             * </p>
2688             *
2689             * @param groupId the group ID
2690             * @param parentFolderId the parent folder ID
2691             * @param start the lower bound of the range of document library folders
2692             * @param end the upper bound of the range of document library folders (not inclusive)
2693             * @return the range of matching document library folders
2694             * @throws SystemException if a system exception occurred
2695             */
2696            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2697                    int start, int end) throws SystemException {
2698                    return findByG_P(groupId, parentFolderId, start, end, null);
2699            }
2700    
2701            /**
2702             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63;.
2703             *
2704             * <p>
2705             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2706             * </p>
2707             *
2708             * @param groupId the group ID
2709             * @param parentFolderId the parent folder ID
2710             * @param start the lower bound of the range of document library folders
2711             * @param end the upper bound of the range of document library folders (not inclusive)
2712             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2713             * @return the ordered range of matching document library folders
2714             * @throws SystemException if a system exception occurred
2715             */
2716            public List<DLFolder> findByG_P(long groupId, long parentFolderId,
2717                    int start, int end, OrderByComparator orderByComparator)
2718                    throws SystemException {
2719                    FinderPath finderPath = null;
2720                    Object[] finderArgs = null;
2721    
2722                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2723                                    (orderByComparator == null)) {
2724                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2725                            finderArgs = new Object[] { groupId, parentFolderId };
2726                    }
2727                    else {
2728                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2729                            finderArgs = new Object[] {
2730                                            groupId, parentFolderId,
2731                                            
2732                                            start, end, orderByComparator
2733                                    };
2734                    }
2735    
2736                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
2737                                    finderArgs, this);
2738    
2739                    if ((list != null) && !list.isEmpty()) {
2740                            for (DLFolder dlFolder : list) {
2741                                    if ((groupId != dlFolder.getGroupId()) ||
2742                                                    (parentFolderId != dlFolder.getParentFolderId())) {
2743                                            list = null;
2744    
2745                                            break;
2746                                    }
2747                            }
2748                    }
2749    
2750                    if (list == null) {
2751                            StringBundler query = null;
2752    
2753                            if (orderByComparator != null) {
2754                                    query = new StringBundler(4 +
2755                                                    (orderByComparator.getOrderByFields().length * 3));
2756                            }
2757                            else {
2758                                    query = new StringBundler(4);
2759                            }
2760    
2761                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
2762    
2763                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2764    
2765                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2766    
2767                            if (orderByComparator != null) {
2768                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2769                                            orderByComparator);
2770                            }
2771    
2772                            else {
2773                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
2774                            }
2775    
2776                            String sql = query.toString();
2777    
2778                            Session session = null;
2779    
2780                            try {
2781                                    session = openSession();
2782    
2783                                    Query q = session.createQuery(sql);
2784    
2785                                    QueryPos qPos = QueryPos.getInstance(q);
2786    
2787                                    qPos.add(groupId);
2788    
2789                                    qPos.add(parentFolderId);
2790    
2791                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
2792                                                    end);
2793                            }
2794                            catch (Exception e) {
2795                                    throw processException(e);
2796                            }
2797                            finally {
2798                                    if (list == null) {
2799                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2800                                    }
2801                                    else {
2802                                            cacheResult(list);
2803    
2804                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2805                                    }
2806    
2807                                    closeSession(session);
2808                            }
2809                    }
2810    
2811                    return list;
2812            }
2813    
2814            /**
2815             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2816             *
2817             * @param groupId the group ID
2818             * @param parentFolderId the parent folder ID
2819             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2820             * @return the first matching document library folder
2821             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
2822             * @throws SystemException if a system exception occurred
2823             */
2824            public DLFolder findByG_P_First(long groupId, long parentFolderId,
2825                    OrderByComparator orderByComparator)
2826                    throws NoSuchFolderException, SystemException {
2827                    DLFolder dlFolder = fetchByG_P_First(groupId, parentFolderId,
2828                                    orderByComparator);
2829    
2830                    if (dlFolder != null) {
2831                            return dlFolder;
2832                    }
2833    
2834                    StringBundler msg = new StringBundler(6);
2835    
2836                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2837    
2838                    msg.append("groupId=");
2839                    msg.append(groupId);
2840    
2841                    msg.append(", parentFolderId=");
2842                    msg.append(parentFolderId);
2843    
2844                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2845    
2846                    throw new NoSuchFolderException(msg.toString());
2847            }
2848    
2849            /**
2850             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2851             *
2852             * @param groupId the group ID
2853             * @param parentFolderId the parent folder ID
2854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2855             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
2856             * @throws SystemException if a system exception occurred
2857             */
2858            public DLFolder fetchByG_P_First(long groupId, long parentFolderId,
2859                    OrderByComparator orderByComparator) throws SystemException {
2860                    List<DLFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
2861                                    orderByComparator);
2862    
2863                    if (!list.isEmpty()) {
2864                            return list.get(0);
2865                    }
2866    
2867                    return null;
2868            }
2869    
2870            /**
2871             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2872             *
2873             * @param groupId the group ID
2874             * @param parentFolderId the parent folder ID
2875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2876             * @return the last matching document library folder
2877             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
2878             * @throws SystemException if a system exception occurred
2879             */
2880            public DLFolder findByG_P_Last(long groupId, long parentFolderId,
2881                    OrderByComparator orderByComparator)
2882                    throws NoSuchFolderException, SystemException {
2883                    DLFolder dlFolder = fetchByG_P_Last(groupId, parentFolderId,
2884                                    orderByComparator);
2885    
2886                    if (dlFolder != null) {
2887                            return dlFolder;
2888                    }
2889    
2890                    StringBundler msg = new StringBundler(6);
2891    
2892                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2893    
2894                    msg.append("groupId=");
2895                    msg.append(groupId);
2896    
2897                    msg.append(", parentFolderId=");
2898                    msg.append(parentFolderId);
2899    
2900                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2901    
2902                    throw new NoSuchFolderException(msg.toString());
2903            }
2904    
2905            /**
2906             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2907             *
2908             * @param groupId the group ID
2909             * @param parentFolderId the parent folder ID
2910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2911             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
2912             * @throws SystemException if a system exception occurred
2913             */
2914            public DLFolder fetchByG_P_Last(long groupId, long parentFolderId,
2915                    OrderByComparator orderByComparator) throws SystemException {
2916                    int count = countByG_P(groupId, parentFolderId);
2917    
2918                    List<DLFolder> list = findByG_P(groupId, parentFolderId, count - 1,
2919                                    count, orderByComparator);
2920    
2921                    if (!list.isEmpty()) {
2922                            return list.get(0);
2923                    }
2924    
2925                    return null;
2926            }
2927    
2928            /**
2929             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2930             *
2931             * @param folderId the primary key of the current document library folder
2932             * @param groupId the group ID
2933             * @param parentFolderId the parent folder ID
2934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2935             * @return the previous, current, and next document library folder
2936             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
2937             * @throws SystemException if a system exception occurred
2938             */
2939            public DLFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
2940                    long parentFolderId, OrderByComparator orderByComparator)
2941                    throws NoSuchFolderException, SystemException {
2942                    DLFolder dlFolder = findByPrimaryKey(folderId);
2943    
2944                    Session session = null;
2945    
2946                    try {
2947                            session = openSession();
2948    
2949                            DLFolder[] array = new DLFolderImpl[3];
2950    
2951                            array[0] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2952                                            parentFolderId, orderByComparator, true);
2953    
2954                            array[1] = dlFolder;
2955    
2956                            array[2] = getByG_P_PrevAndNext(session, dlFolder, groupId,
2957                                            parentFolderId, orderByComparator, false);
2958    
2959                            return array;
2960                    }
2961                    catch (Exception e) {
2962                            throw processException(e);
2963                    }
2964                    finally {
2965                            closeSession(session);
2966                    }
2967            }
2968    
2969            protected DLFolder getByG_P_PrevAndNext(Session session, DLFolder dlFolder,
2970                    long groupId, long parentFolderId, OrderByComparator orderByComparator,
2971                    boolean previous) {
2972                    StringBundler query = null;
2973    
2974                    if (orderByComparator != null) {
2975                            query = new StringBundler(6 +
2976                                            (orderByComparator.getOrderByFields().length * 6));
2977                    }
2978                    else {
2979                            query = new StringBundler(3);
2980                    }
2981    
2982                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
2983    
2984                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2985    
2986                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2987    
2988                    if (orderByComparator != null) {
2989                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2990    
2991                            if (orderByConditionFields.length > 0) {
2992                                    query.append(WHERE_AND);
2993                            }
2994    
2995                            for (int i = 0; i < orderByConditionFields.length; i++) {
2996                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2997                                    query.append(orderByConditionFields[i]);
2998    
2999                                    if ((i + 1) < orderByConditionFields.length) {
3000                                            if (orderByComparator.isAscending() ^ previous) {
3001                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3002                                            }
3003                                            else {
3004                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3005                                            }
3006                                    }
3007                                    else {
3008                                            if (orderByComparator.isAscending() ^ previous) {
3009                                                    query.append(WHERE_GREATER_THAN);
3010                                            }
3011                                            else {
3012                                                    query.append(WHERE_LESSER_THAN);
3013                                            }
3014                                    }
3015                            }
3016    
3017                            query.append(ORDER_BY_CLAUSE);
3018    
3019                            String[] orderByFields = orderByComparator.getOrderByFields();
3020    
3021                            for (int i = 0; i < orderByFields.length; i++) {
3022                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3023                                    query.append(orderByFields[i]);
3024    
3025                                    if ((i + 1) < orderByFields.length) {
3026                                            if (orderByComparator.isAscending() ^ previous) {
3027                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3028                                            }
3029                                            else {
3030                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3031                                            }
3032                                    }
3033                                    else {
3034                                            if (orderByComparator.isAscending() ^ previous) {
3035                                                    query.append(ORDER_BY_ASC);
3036                                            }
3037                                            else {
3038                                                    query.append(ORDER_BY_DESC);
3039                                            }
3040                                    }
3041                            }
3042                    }
3043    
3044                    else {
3045                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3046                    }
3047    
3048                    String sql = query.toString();
3049    
3050                    Query q = session.createQuery(sql);
3051    
3052                    q.setFirstResult(0);
3053                    q.setMaxResults(2);
3054    
3055                    QueryPos qPos = QueryPos.getInstance(q);
3056    
3057                    qPos.add(groupId);
3058    
3059                    qPos.add(parentFolderId);
3060    
3061                    if (orderByComparator != null) {
3062                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3063    
3064                            for (Object value : values) {
3065                                    qPos.add(value);
3066                            }
3067                    }
3068    
3069                    List<DLFolder> list = q.list();
3070    
3071                    if (list.size() == 2) {
3072                            return list.get(1);
3073                    }
3074                    else {
3075                            return null;
3076                    }
3077            }
3078    
3079            /**
3080             * Returns all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3081             *
3082             * @param groupId the group ID
3083             * @param parentFolderId the parent folder ID
3084             * @return the matching document library folders that the user has permission to view
3085             * @throws SystemException if a system exception occurred
3086             */
3087            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId)
3088                    throws SystemException {
3089                    return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3090                            QueryUtil.ALL_POS, null);
3091            }
3092    
3093            /**
3094             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3095             *
3096             * <p>
3097             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3098             * </p>
3099             *
3100             * @param groupId the group ID
3101             * @param parentFolderId the parent folder ID
3102             * @param start the lower bound of the range of document library folders
3103             * @param end the upper bound of the range of document library folders (not inclusive)
3104             * @return the range of matching document library folders that the user has permission to view
3105             * @throws SystemException if a system exception occurred
3106             */
3107            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3108                    int start, int end) throws SystemException {
3109                    return filterFindByG_P(groupId, parentFolderId, start, end, null);
3110            }
3111    
3112            /**
3113             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63;.
3114             *
3115             * <p>
3116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3117             * </p>
3118             *
3119             * @param groupId the group ID
3120             * @param parentFolderId the parent folder ID
3121             * @param start the lower bound of the range of document library folders
3122             * @param end the upper bound of the range of document library folders (not inclusive)
3123             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3124             * @return the ordered range of matching document library folders that the user has permission to view
3125             * @throws SystemException if a system exception occurred
3126             */
3127            public List<DLFolder> filterFindByG_P(long groupId, long parentFolderId,
3128                    int start, int end, OrderByComparator orderByComparator)
3129                    throws SystemException {
3130                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3131                            return findByG_P(groupId, parentFolderId, start, end,
3132                                    orderByComparator);
3133                    }
3134    
3135                    StringBundler query = null;
3136    
3137                    if (orderByComparator != null) {
3138                            query = new StringBundler(4 +
3139                                            (orderByComparator.getOrderByFields().length * 3));
3140                    }
3141                    else {
3142                            query = new StringBundler(4);
3143                    }
3144    
3145                    if (getDB().isSupportsInlineDistinct()) {
3146                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3147                    }
3148                    else {
3149                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3150                    }
3151    
3152                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3153    
3154                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3155    
3156                    if (!getDB().isSupportsInlineDistinct()) {
3157                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3158                    }
3159    
3160                    if (orderByComparator != null) {
3161                            if (getDB().isSupportsInlineDistinct()) {
3162                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3163                                            orderByComparator);
3164                            }
3165                            else {
3166                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3167                                            orderByComparator);
3168                            }
3169                    }
3170    
3171                    else {
3172                            if (getDB().isSupportsInlineDistinct()) {
3173                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3174                            }
3175                            else {
3176                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
3177                            }
3178                    }
3179    
3180                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3181                                    DLFolder.class.getName(),
3182                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3183    
3184                    Session session = null;
3185    
3186                    try {
3187                            session = openSession();
3188    
3189                            SQLQuery q = session.createSQLQuery(sql);
3190    
3191                            if (getDB().isSupportsInlineDistinct()) {
3192                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3193                            }
3194                            else {
3195                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3196                            }
3197    
3198                            QueryPos qPos = QueryPos.getInstance(q);
3199    
3200                            qPos.add(groupId);
3201    
3202                            qPos.add(parentFolderId);
3203    
3204                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
3205                    }
3206                    catch (Exception e) {
3207                            throw processException(e);
3208                    }
3209                    finally {
3210                            closeSession(session);
3211                    }
3212            }
3213    
3214            /**
3215             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3216             *
3217             * @param folderId the primary key of the current document library folder
3218             * @param groupId the group ID
3219             * @param parentFolderId the parent folder ID
3220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3221             * @return the previous, current, and next document library folder
3222             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
3223             * @throws SystemException if a system exception occurred
3224             */
3225            public DLFolder[] filterFindByG_P_PrevAndNext(long folderId, long groupId,
3226                    long parentFolderId, OrderByComparator orderByComparator)
3227                    throws NoSuchFolderException, SystemException {
3228                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3229                            return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3230                                    orderByComparator);
3231                    }
3232    
3233                    DLFolder dlFolder = findByPrimaryKey(folderId);
3234    
3235                    Session session = null;
3236    
3237                    try {
3238                            session = openSession();
3239    
3240                            DLFolder[] array = new DLFolderImpl[3];
3241    
3242                            array[0] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3243                                            parentFolderId, orderByComparator, true);
3244    
3245                            array[1] = dlFolder;
3246    
3247                            array[2] = filterGetByG_P_PrevAndNext(session, dlFolder, groupId,
3248                                            parentFolderId, orderByComparator, false);
3249    
3250                            return array;
3251                    }
3252                    catch (Exception e) {
3253                            throw processException(e);
3254                    }
3255                    finally {
3256                            closeSession(session);
3257                    }
3258            }
3259    
3260            protected DLFolder filterGetByG_P_PrevAndNext(Session session,
3261                    DLFolder dlFolder, long groupId, long parentFolderId,
3262                    OrderByComparator orderByComparator, boolean previous) {
3263                    StringBundler query = null;
3264    
3265                    if (orderByComparator != null) {
3266                            query = new StringBundler(6 +
3267                                            (orderByComparator.getOrderByFields().length * 6));
3268                    }
3269                    else {
3270                            query = new StringBundler(3);
3271                    }
3272    
3273                    if (getDB().isSupportsInlineDistinct()) {
3274                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
3275                    }
3276                    else {
3277                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3278                    }
3279    
3280                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3281    
3282                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3283    
3284                    if (!getDB().isSupportsInlineDistinct()) {
3285                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3286                    }
3287    
3288                    if (orderByComparator != null) {
3289                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3290    
3291                            if (orderByConditionFields.length > 0) {
3292                                    query.append(WHERE_AND);
3293                            }
3294    
3295                            for (int i = 0; i < orderByConditionFields.length; i++) {
3296                                    if (getDB().isSupportsInlineDistinct()) {
3297                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3298                                    }
3299                                    else {
3300                                            query.append(_ORDER_BY_ENTITY_TABLE);
3301                                    }
3302    
3303                                    query.append(orderByConditionFields[i]);
3304    
3305                                    if ((i + 1) < orderByConditionFields.length) {
3306                                            if (orderByComparator.isAscending() ^ previous) {
3307                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3308                                            }
3309                                            else {
3310                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3311                                            }
3312                                    }
3313                                    else {
3314                                            if (orderByComparator.isAscending() ^ previous) {
3315                                                    query.append(WHERE_GREATER_THAN);
3316                                            }
3317                                            else {
3318                                                    query.append(WHERE_LESSER_THAN);
3319                                            }
3320                                    }
3321                            }
3322    
3323                            query.append(ORDER_BY_CLAUSE);
3324    
3325                            String[] orderByFields = orderByComparator.getOrderByFields();
3326    
3327                            for (int i = 0; i < orderByFields.length; i++) {
3328                                    if (getDB().isSupportsInlineDistinct()) {
3329                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3330                                    }
3331                                    else {
3332                                            query.append(_ORDER_BY_ENTITY_TABLE);
3333                                    }
3334    
3335                                    query.append(orderByFields[i]);
3336    
3337                                    if ((i + 1) < orderByFields.length) {
3338                                            if (orderByComparator.isAscending() ^ previous) {
3339                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3340                                            }
3341                                            else {
3342                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3343                                            }
3344                                    }
3345                                    else {
3346                                            if (orderByComparator.isAscending() ^ previous) {
3347                                                    query.append(ORDER_BY_ASC);
3348                                            }
3349                                            else {
3350                                                    query.append(ORDER_BY_DESC);
3351                                            }
3352                                    }
3353                            }
3354                    }
3355    
3356                    else {
3357                            if (getDB().isSupportsInlineDistinct()) {
3358                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3359                            }
3360                            else {
3361                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
3362                            }
3363                    }
3364    
3365                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3366                                    DLFolder.class.getName(),
3367                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3368    
3369                    SQLQuery q = session.createSQLQuery(sql);
3370    
3371                    q.setFirstResult(0);
3372                    q.setMaxResults(2);
3373    
3374                    if (getDB().isSupportsInlineDistinct()) {
3375                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
3376                    }
3377                    else {
3378                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
3379                    }
3380    
3381                    QueryPos qPos = QueryPos.getInstance(q);
3382    
3383                    qPos.add(groupId);
3384    
3385                    qPos.add(parentFolderId);
3386    
3387                    if (orderByComparator != null) {
3388                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3389    
3390                            for (Object value : values) {
3391                                    qPos.add(value);
3392                            }
3393                    }
3394    
3395                    List<DLFolder> list = q.list();
3396    
3397                    if (list.size() == 2) {
3398                            return list.get(1);
3399                    }
3400                    else {
3401                            return null;
3402                    }
3403            }
3404    
3405            /**
3406             * Returns all the document library folders where parentFolderId = &#63; and name = &#63;.
3407             *
3408             * @param parentFolderId the parent folder ID
3409             * @param name the name
3410             * @return the matching document library folders
3411             * @throws SystemException if a system exception occurred
3412             */
3413            public List<DLFolder> findByP_N(long parentFolderId, String name)
3414                    throws SystemException {
3415                    return findByP_N(parentFolderId, name, QueryUtil.ALL_POS,
3416                            QueryUtil.ALL_POS, null);
3417            }
3418    
3419            /**
3420             * Returns a range of all the document library folders where parentFolderId = &#63; and name = &#63;.
3421             *
3422             * <p>
3423             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3424             * </p>
3425             *
3426             * @param parentFolderId the parent folder ID
3427             * @param name the name
3428             * @param start the lower bound of the range of document library folders
3429             * @param end the upper bound of the range of document library folders (not inclusive)
3430             * @return the range of matching document library folders
3431             * @throws SystemException if a system exception occurred
3432             */
3433            public List<DLFolder> findByP_N(long parentFolderId, String name,
3434                    int start, int end) throws SystemException {
3435                    return findByP_N(parentFolderId, name, start, end, null);
3436            }
3437    
3438            /**
3439             * Returns an ordered range of all the document library folders where parentFolderId = &#63; and name = &#63;.
3440             *
3441             * <p>
3442             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3443             * </p>
3444             *
3445             * @param parentFolderId the parent folder ID
3446             * @param name the name
3447             * @param start the lower bound of the range of document library folders
3448             * @param end the upper bound of the range of document library folders (not inclusive)
3449             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3450             * @return the ordered range of matching document library folders
3451             * @throws SystemException if a system exception occurred
3452             */
3453            public List<DLFolder> findByP_N(long parentFolderId, String name,
3454                    int start, int end, OrderByComparator orderByComparator)
3455                    throws SystemException {
3456                    FinderPath finderPath = null;
3457                    Object[] finderArgs = null;
3458    
3459                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3460                                    (orderByComparator == null)) {
3461                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3462                            finderArgs = new Object[] { parentFolderId, name };
3463                    }
3464                    else {
3465                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3466                            finderArgs = new Object[] {
3467                                            parentFolderId, name,
3468                                            
3469                                            start, end, orderByComparator
3470                                    };
3471                    }
3472    
3473                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3474                                    finderArgs, this);
3475    
3476                    if ((list != null) && !list.isEmpty()) {
3477                            for (DLFolder dlFolder : list) {
3478                                    if ((parentFolderId != dlFolder.getParentFolderId()) ||
3479                                                    !Validator.equals(name, dlFolder.getName())) {
3480                                            list = null;
3481    
3482                                            break;
3483                                    }
3484                            }
3485                    }
3486    
3487                    if (list == null) {
3488                            StringBundler query = null;
3489    
3490                            if (orderByComparator != null) {
3491                                    query = new StringBundler(4 +
3492                                                    (orderByComparator.getOrderByFields().length * 3));
3493                            }
3494                            else {
3495                                    query = new StringBundler(4);
3496                            }
3497    
3498                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
3499    
3500                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3501    
3502                            if (name == null) {
3503                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
3504                            }
3505                            else {
3506                                    if (name.equals(StringPool.BLANK)) {
3507                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
3508                                    }
3509                                    else {
3510                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
3511                                    }
3512                            }
3513    
3514                            if (orderByComparator != null) {
3515                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3516                                            orderByComparator);
3517                            }
3518    
3519                            else {
3520                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3521                            }
3522    
3523                            String sql = query.toString();
3524    
3525                            Session session = null;
3526    
3527                            try {
3528                                    session = openSession();
3529    
3530                                    Query q = session.createQuery(sql);
3531    
3532                                    QueryPos qPos = QueryPos.getInstance(q);
3533    
3534                                    qPos.add(parentFolderId);
3535    
3536                                    if (name != null) {
3537                                            qPos.add(name);
3538                                    }
3539    
3540                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3541                                                    end);
3542                            }
3543                            catch (Exception e) {
3544                                    throw processException(e);
3545                            }
3546                            finally {
3547                                    if (list == null) {
3548                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3549                                    }
3550                                    else {
3551                                            cacheResult(list);
3552    
3553                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3554                                    }
3555    
3556                                    closeSession(session);
3557                            }
3558                    }
3559    
3560                    return list;
3561            }
3562    
3563            /**
3564             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
3565             *
3566             * @param parentFolderId the parent folder ID
3567             * @param name the name
3568             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3569             * @return the first matching document library folder
3570             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
3571             * @throws SystemException if a system exception occurred
3572             */
3573            public DLFolder findByP_N_First(long parentFolderId, String name,
3574                    OrderByComparator orderByComparator)
3575                    throws NoSuchFolderException, SystemException {
3576                    DLFolder dlFolder = fetchByP_N_First(parentFolderId, name,
3577                                    orderByComparator);
3578    
3579                    if (dlFolder != null) {
3580                            return dlFolder;
3581                    }
3582    
3583                    StringBundler msg = new StringBundler(6);
3584    
3585                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3586    
3587                    msg.append("parentFolderId=");
3588                    msg.append(parentFolderId);
3589    
3590                    msg.append(", name=");
3591                    msg.append(name);
3592    
3593                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3594    
3595                    throw new NoSuchFolderException(msg.toString());
3596            }
3597    
3598            /**
3599             * Returns the first document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
3600             *
3601             * @param parentFolderId the parent folder ID
3602             * @param name the name
3603             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3604             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
3605             * @throws SystemException if a system exception occurred
3606             */
3607            public DLFolder fetchByP_N_First(long parentFolderId, String name,
3608                    OrderByComparator orderByComparator) throws SystemException {
3609                    List<DLFolder> list = findByP_N(parentFolderId, name, 0, 1,
3610                                    orderByComparator);
3611    
3612                    if (!list.isEmpty()) {
3613                            return list.get(0);
3614                    }
3615    
3616                    return null;
3617            }
3618    
3619            /**
3620             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
3621             *
3622             * @param parentFolderId the parent folder ID
3623             * @param name the name
3624             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3625             * @return the last matching document library folder
3626             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
3627             * @throws SystemException if a system exception occurred
3628             */
3629            public DLFolder findByP_N_Last(long parentFolderId, String name,
3630                    OrderByComparator orderByComparator)
3631                    throws NoSuchFolderException, SystemException {
3632                    DLFolder dlFolder = fetchByP_N_Last(parentFolderId, name,
3633                                    orderByComparator);
3634    
3635                    if (dlFolder != null) {
3636                            return dlFolder;
3637                    }
3638    
3639                    StringBundler msg = new StringBundler(6);
3640    
3641                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3642    
3643                    msg.append("parentFolderId=");
3644                    msg.append(parentFolderId);
3645    
3646                    msg.append(", name=");
3647                    msg.append(name);
3648    
3649                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3650    
3651                    throw new NoSuchFolderException(msg.toString());
3652            }
3653    
3654            /**
3655             * Returns the last document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
3656             *
3657             * @param parentFolderId the parent folder ID
3658             * @param name the name
3659             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3660             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
3661             * @throws SystemException if a system exception occurred
3662             */
3663            public DLFolder fetchByP_N_Last(long parentFolderId, String name,
3664                    OrderByComparator orderByComparator) throws SystemException {
3665                    int count = countByP_N(parentFolderId, name);
3666    
3667                    List<DLFolder> list = findByP_N(parentFolderId, name, count - 1, count,
3668                                    orderByComparator);
3669    
3670                    if (!list.isEmpty()) {
3671                            return list.get(0);
3672                    }
3673    
3674                    return null;
3675            }
3676    
3677            /**
3678             * Returns the document library folders before and after the current document library folder in the ordered set where parentFolderId = &#63; and name = &#63;.
3679             *
3680             * @param folderId the primary key of the current document library folder
3681             * @param parentFolderId the parent folder ID
3682             * @param name the name
3683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3684             * @return the previous, current, and next document library folder
3685             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
3686             * @throws SystemException if a system exception occurred
3687             */
3688            public DLFolder[] findByP_N_PrevAndNext(long folderId, long parentFolderId,
3689                    String name, OrderByComparator orderByComparator)
3690                    throws NoSuchFolderException, SystemException {
3691                    DLFolder dlFolder = findByPrimaryKey(folderId);
3692    
3693                    Session session = null;
3694    
3695                    try {
3696                            session = openSession();
3697    
3698                            DLFolder[] array = new DLFolderImpl[3];
3699    
3700                            array[0] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3701                                            name, orderByComparator, true);
3702    
3703                            array[1] = dlFolder;
3704    
3705                            array[2] = getByP_N_PrevAndNext(session, dlFolder, parentFolderId,
3706                                            name, orderByComparator, false);
3707    
3708                            return array;
3709                    }
3710                    catch (Exception e) {
3711                            throw processException(e);
3712                    }
3713                    finally {
3714                            closeSession(session);
3715                    }
3716            }
3717    
3718            protected DLFolder getByP_N_PrevAndNext(Session session, DLFolder dlFolder,
3719                    long parentFolderId, String name, OrderByComparator orderByComparator,
3720                    boolean previous) {
3721                    StringBundler query = null;
3722    
3723                    if (orderByComparator != null) {
3724                            query = new StringBundler(6 +
3725                                            (orderByComparator.getOrderByFields().length * 6));
3726                    }
3727                    else {
3728                            query = new StringBundler(3);
3729                    }
3730    
3731                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
3732    
3733                    query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
3734    
3735                    if (name == null) {
3736                            query.append(_FINDER_COLUMN_P_N_NAME_1);
3737                    }
3738                    else {
3739                            if (name.equals(StringPool.BLANK)) {
3740                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
3741                            }
3742                            else {
3743                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
3744                            }
3745                    }
3746    
3747                    if (orderByComparator != null) {
3748                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3749    
3750                            if (orderByConditionFields.length > 0) {
3751                                    query.append(WHERE_AND);
3752                            }
3753    
3754                            for (int i = 0; i < orderByConditionFields.length; i++) {
3755                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3756                                    query.append(orderByConditionFields[i]);
3757    
3758                                    if ((i + 1) < orderByConditionFields.length) {
3759                                            if (orderByComparator.isAscending() ^ previous) {
3760                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3761                                            }
3762                                            else {
3763                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3764                                            }
3765                                    }
3766                                    else {
3767                                            if (orderByComparator.isAscending() ^ previous) {
3768                                                    query.append(WHERE_GREATER_THAN);
3769                                            }
3770                                            else {
3771                                                    query.append(WHERE_LESSER_THAN);
3772                                            }
3773                                    }
3774                            }
3775    
3776                            query.append(ORDER_BY_CLAUSE);
3777    
3778                            String[] orderByFields = orderByComparator.getOrderByFields();
3779    
3780                            for (int i = 0; i < orderByFields.length; i++) {
3781                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3782                                    query.append(orderByFields[i]);
3783    
3784                                    if ((i + 1) < orderByFields.length) {
3785                                            if (orderByComparator.isAscending() ^ previous) {
3786                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3787                                            }
3788                                            else {
3789                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3790                                            }
3791                                    }
3792                                    else {
3793                                            if (orderByComparator.isAscending() ^ previous) {
3794                                                    query.append(ORDER_BY_ASC);
3795                                            }
3796                                            else {
3797                                                    query.append(ORDER_BY_DESC);
3798                                            }
3799                                    }
3800                            }
3801                    }
3802    
3803                    else {
3804                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3805                    }
3806    
3807                    String sql = query.toString();
3808    
3809                    Query q = session.createQuery(sql);
3810    
3811                    q.setFirstResult(0);
3812                    q.setMaxResults(2);
3813    
3814                    QueryPos qPos = QueryPos.getInstance(q);
3815    
3816                    qPos.add(parentFolderId);
3817    
3818                    if (name != null) {
3819                            qPos.add(name);
3820                    }
3821    
3822                    if (orderByComparator != null) {
3823                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
3824    
3825                            for (Object value : values) {
3826                                    qPos.add(value);
3827                            }
3828                    }
3829    
3830                    List<DLFolder> list = q.list();
3831    
3832                    if (list.size() == 2) {
3833                            return list.get(1);
3834                    }
3835                    else {
3836                            return null;
3837                    }
3838            }
3839    
3840            /**
3841             * Returns all the document library folders where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
3842             *
3843             * @param groupId the group ID
3844             * @param parentFolderId the parent folder ID
3845             * @param mountPoint the mount point
3846             * @return the matching document library folders
3847             * @throws SystemException if a system exception occurred
3848             */
3849            public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3850                    boolean mountPoint) throws SystemException {
3851                    return findByG_P_M(groupId, parentFolderId, mountPoint,
3852                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3853            }
3854    
3855            /**
3856             * Returns a range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
3857             *
3858             * <p>
3859             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3860             * </p>
3861             *
3862             * @param groupId the group ID
3863             * @param parentFolderId the parent folder ID
3864             * @param mountPoint the mount point
3865             * @param start the lower bound of the range of document library folders
3866             * @param end the upper bound of the range of document library folders (not inclusive)
3867             * @return the range of matching document library folders
3868             * @throws SystemException if a system exception occurred
3869             */
3870            public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3871                    boolean mountPoint, int start, int end) throws SystemException {
3872                    return findByG_P_M(groupId, parentFolderId, mountPoint, start, end, null);
3873            }
3874    
3875            /**
3876             * Returns an ordered range of all the document library folders where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
3877             *
3878             * <p>
3879             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3880             * </p>
3881             *
3882             * @param groupId the group ID
3883             * @param parentFolderId the parent folder ID
3884             * @param mountPoint the mount point
3885             * @param start the lower bound of the range of document library folders
3886             * @param end the upper bound of the range of document library folders (not inclusive)
3887             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3888             * @return the ordered range of matching document library folders
3889             * @throws SystemException if a system exception occurred
3890             */
3891            public List<DLFolder> findByG_P_M(long groupId, long parentFolderId,
3892                    boolean mountPoint, int start, int end,
3893                    OrderByComparator orderByComparator) throws SystemException {
3894                    FinderPath finderPath = null;
3895                    Object[] finderArgs = null;
3896    
3897                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3898                                    (orderByComparator == null)) {
3899                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_M;
3900                            finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
3901                    }
3902                    else {
3903                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M;
3904                            finderArgs = new Object[] {
3905                                            groupId, parentFolderId, mountPoint,
3906                                            
3907                                            start, end, orderByComparator
3908                                    };
3909                    }
3910    
3911                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
3912                                    finderArgs, this);
3913    
3914                    if ((list != null) && !list.isEmpty()) {
3915                            for (DLFolder dlFolder : list) {
3916                                    if ((groupId != dlFolder.getGroupId()) ||
3917                                                    (parentFolderId != dlFolder.getParentFolderId()) ||
3918                                                    (mountPoint != dlFolder.getMountPoint())) {
3919                                            list = null;
3920    
3921                                            break;
3922                                    }
3923                            }
3924                    }
3925    
3926                    if (list == null) {
3927                            StringBundler query = null;
3928    
3929                            if (orderByComparator != null) {
3930                                    query = new StringBundler(5 +
3931                                                    (orderByComparator.getOrderByFields().length * 3));
3932                            }
3933                            else {
3934                                    query = new StringBundler(5);
3935                            }
3936    
3937                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
3938    
3939                            query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
3940    
3941                            query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
3942    
3943                            query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
3944    
3945                            if (orderByComparator != null) {
3946                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3947                                            orderByComparator);
3948                            }
3949    
3950                            else {
3951                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
3952                            }
3953    
3954                            String sql = query.toString();
3955    
3956                            Session session = null;
3957    
3958                            try {
3959                                    session = openSession();
3960    
3961                                    Query q = session.createQuery(sql);
3962    
3963                                    QueryPos qPos = QueryPos.getInstance(q);
3964    
3965                                    qPos.add(groupId);
3966    
3967                                    qPos.add(parentFolderId);
3968    
3969                                    qPos.add(mountPoint);
3970    
3971                                    list = (List<DLFolder>)QueryUtil.list(q, getDialect(), start,
3972                                                    end);
3973                            }
3974                            catch (Exception e) {
3975                                    throw processException(e);
3976                            }
3977                            finally {
3978                                    if (list == null) {
3979                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3980                                    }
3981                                    else {
3982                                            cacheResult(list);
3983    
3984                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3985                                    }
3986    
3987                                    closeSession(session);
3988                            }
3989                    }
3990    
3991                    return list;
3992            }
3993    
3994            /**
3995             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
3996             *
3997             * @param groupId the group ID
3998             * @param parentFolderId the parent folder ID
3999             * @param mountPoint the mount point
4000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4001             * @return the first matching document library folder
4002             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
4003             * @throws SystemException if a system exception occurred
4004             */
4005            public DLFolder findByG_P_M_First(long groupId, long parentFolderId,
4006                    boolean mountPoint, OrderByComparator orderByComparator)
4007                    throws NoSuchFolderException, SystemException {
4008                    DLFolder dlFolder = fetchByG_P_M_First(groupId, parentFolderId,
4009                                    mountPoint, orderByComparator);
4010    
4011                    if (dlFolder != null) {
4012                            return dlFolder;
4013                    }
4014    
4015                    StringBundler msg = new StringBundler(8);
4016    
4017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4018    
4019                    msg.append("groupId=");
4020                    msg.append(groupId);
4021    
4022                    msg.append(", parentFolderId=");
4023                    msg.append(parentFolderId);
4024    
4025                    msg.append(", mountPoint=");
4026                    msg.append(mountPoint);
4027    
4028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4029    
4030                    throw new NoSuchFolderException(msg.toString());
4031            }
4032    
4033            /**
4034             * Returns the first document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4035             *
4036             * @param groupId the group ID
4037             * @param parentFolderId the parent folder ID
4038             * @param mountPoint the mount point
4039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4040             * @return the first matching document library folder, or <code>null</code> if a matching document library folder could not be found
4041             * @throws SystemException if a system exception occurred
4042             */
4043            public DLFolder fetchByG_P_M_First(long groupId, long parentFolderId,
4044                    boolean mountPoint, OrderByComparator orderByComparator)
4045                    throws SystemException {
4046                    List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
4047                                    0, 1, orderByComparator);
4048    
4049                    if (!list.isEmpty()) {
4050                            return list.get(0);
4051                    }
4052    
4053                    return null;
4054            }
4055    
4056            /**
4057             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4058             *
4059             * @param groupId the group ID
4060             * @param parentFolderId the parent folder ID
4061             * @param mountPoint the mount point
4062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4063             * @return the last matching document library folder
4064             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
4065             * @throws SystemException if a system exception occurred
4066             */
4067            public DLFolder findByG_P_M_Last(long groupId, long parentFolderId,
4068                    boolean mountPoint, OrderByComparator orderByComparator)
4069                    throws NoSuchFolderException, SystemException {
4070                    DLFolder dlFolder = fetchByG_P_M_Last(groupId, parentFolderId,
4071                                    mountPoint, orderByComparator);
4072    
4073                    if (dlFolder != null) {
4074                            return dlFolder;
4075                    }
4076    
4077                    StringBundler msg = new StringBundler(8);
4078    
4079                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4080    
4081                    msg.append("groupId=");
4082                    msg.append(groupId);
4083    
4084                    msg.append(", parentFolderId=");
4085                    msg.append(parentFolderId);
4086    
4087                    msg.append(", mountPoint=");
4088                    msg.append(mountPoint);
4089    
4090                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4091    
4092                    throw new NoSuchFolderException(msg.toString());
4093            }
4094    
4095            /**
4096             * Returns the last document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4097             *
4098             * @param groupId the group ID
4099             * @param parentFolderId the parent folder ID
4100             * @param mountPoint the mount point
4101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4102             * @return the last matching document library folder, or <code>null</code> if a matching document library folder could not be found
4103             * @throws SystemException if a system exception occurred
4104             */
4105            public DLFolder fetchByG_P_M_Last(long groupId, long parentFolderId,
4106                    boolean mountPoint, OrderByComparator orderByComparator)
4107                    throws SystemException {
4108                    int count = countByG_P_M(groupId, parentFolderId, mountPoint);
4109    
4110                    List<DLFolder> list = findByG_P_M(groupId, parentFolderId, mountPoint,
4111                                    count - 1, count, orderByComparator);
4112    
4113                    if (!list.isEmpty()) {
4114                            return list.get(0);
4115                    }
4116    
4117                    return null;
4118            }
4119    
4120            /**
4121             * Returns the document library folders before and after the current document library folder in the ordered set where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4122             *
4123             * @param folderId the primary key of the current document library folder
4124             * @param groupId the group ID
4125             * @param parentFolderId the parent folder ID
4126             * @param mountPoint the mount point
4127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4128             * @return the previous, current, and next document library folder
4129             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
4130             * @throws SystemException if a system exception occurred
4131             */
4132            public DLFolder[] findByG_P_M_PrevAndNext(long folderId, long groupId,
4133                    long parentFolderId, boolean mountPoint,
4134                    OrderByComparator orderByComparator)
4135                    throws NoSuchFolderException, SystemException {
4136                    DLFolder dlFolder = findByPrimaryKey(folderId);
4137    
4138                    Session session = null;
4139    
4140                    try {
4141                            session = openSession();
4142    
4143                            DLFolder[] array = new DLFolderImpl[3];
4144    
4145                            array[0] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
4146                                            parentFolderId, mountPoint, orderByComparator, true);
4147    
4148                            array[1] = dlFolder;
4149    
4150                            array[2] = getByG_P_M_PrevAndNext(session, dlFolder, groupId,
4151                                            parentFolderId, mountPoint, orderByComparator, false);
4152    
4153                            return array;
4154                    }
4155                    catch (Exception e) {
4156                            throw processException(e);
4157                    }
4158                    finally {
4159                            closeSession(session);
4160                    }
4161            }
4162    
4163            protected DLFolder getByG_P_M_PrevAndNext(Session session,
4164                    DLFolder dlFolder, long groupId, long parentFolderId,
4165                    boolean mountPoint, OrderByComparator orderByComparator,
4166                    boolean previous) {
4167                    StringBundler query = null;
4168    
4169                    if (orderByComparator != null) {
4170                            query = new StringBundler(6 +
4171                                            (orderByComparator.getOrderByFields().length * 6));
4172                    }
4173                    else {
4174                            query = new StringBundler(3);
4175                    }
4176    
4177                    query.append(_SQL_SELECT_DLFOLDER_WHERE);
4178    
4179                    query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4180    
4181                    query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4182    
4183                    query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4184    
4185                    if (orderByComparator != null) {
4186                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4187    
4188                            if (orderByConditionFields.length > 0) {
4189                                    query.append(WHERE_AND);
4190                            }
4191    
4192                            for (int i = 0; i < orderByConditionFields.length; i++) {
4193                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4194                                    query.append(orderByConditionFields[i]);
4195    
4196                                    if ((i + 1) < orderByConditionFields.length) {
4197                                            if (orderByComparator.isAscending() ^ previous) {
4198                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4199                                            }
4200                                            else {
4201                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4202                                            }
4203                                    }
4204                                    else {
4205                                            if (orderByComparator.isAscending() ^ previous) {
4206                                                    query.append(WHERE_GREATER_THAN);
4207                                            }
4208                                            else {
4209                                                    query.append(WHERE_LESSER_THAN);
4210                                            }
4211                                    }
4212                            }
4213    
4214                            query.append(ORDER_BY_CLAUSE);
4215    
4216                            String[] orderByFields = orderByComparator.getOrderByFields();
4217    
4218                            for (int i = 0; i < orderByFields.length; i++) {
4219                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4220                                    query.append(orderByFields[i]);
4221    
4222                                    if ((i + 1) < orderByFields.length) {
4223                                            if (orderByComparator.isAscending() ^ previous) {
4224                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4225                                            }
4226                                            else {
4227                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4228                                            }
4229                                    }
4230                                    else {
4231                                            if (orderByComparator.isAscending() ^ previous) {
4232                                                    query.append(ORDER_BY_ASC);
4233                                            }
4234                                            else {
4235                                                    query.append(ORDER_BY_DESC);
4236                                            }
4237                                    }
4238                            }
4239                    }
4240    
4241                    else {
4242                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4243                    }
4244    
4245                    String sql = query.toString();
4246    
4247                    Query q = session.createQuery(sql);
4248    
4249                    q.setFirstResult(0);
4250                    q.setMaxResults(2);
4251    
4252                    QueryPos qPos = QueryPos.getInstance(q);
4253    
4254                    qPos.add(groupId);
4255    
4256                    qPos.add(parentFolderId);
4257    
4258                    qPos.add(mountPoint);
4259    
4260                    if (orderByComparator != null) {
4261                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4262    
4263                            for (Object value : values) {
4264                                    qPos.add(value);
4265                            }
4266                    }
4267    
4268                    List<DLFolder> list = q.list();
4269    
4270                    if (list.size() == 2) {
4271                            return list.get(1);
4272                    }
4273                    else {
4274                            return null;
4275                    }
4276            }
4277    
4278            /**
4279             * Returns all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4280             *
4281             * @param groupId the group ID
4282             * @param parentFolderId the parent folder ID
4283             * @param mountPoint the mount point
4284             * @return the matching document library folders that the user has permission to view
4285             * @throws SystemException if a system exception occurred
4286             */
4287            public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4288                    boolean mountPoint) throws SystemException {
4289                    return filterFindByG_P_M(groupId, parentFolderId, mountPoint,
4290                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4291            }
4292    
4293            /**
4294             * Returns a range of all the document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4295             *
4296             * <p>
4297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4298             * </p>
4299             *
4300             * @param groupId the group ID
4301             * @param parentFolderId the parent folder ID
4302             * @param mountPoint the mount point
4303             * @param start the lower bound of the range of document library folders
4304             * @param end the upper bound of the range of document library folders (not inclusive)
4305             * @return the range of matching document library folders that the user has permission to view
4306             * @throws SystemException if a system exception occurred
4307             */
4308            public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4309                    boolean mountPoint, int start, int end) throws SystemException {
4310                    return filterFindByG_P_M(groupId, parentFolderId, mountPoint, start,
4311                            end, null);
4312            }
4313    
4314            /**
4315             * Returns an ordered range of all the document library folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4316             *
4317             * <p>
4318             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4319             * </p>
4320             *
4321             * @param groupId the group ID
4322             * @param parentFolderId the parent folder ID
4323             * @param mountPoint the mount point
4324             * @param start the lower bound of the range of document library folders
4325             * @param end the upper bound of the range of document library folders (not inclusive)
4326             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4327             * @return the ordered range of matching document library folders that the user has permission to view
4328             * @throws SystemException if a system exception occurred
4329             */
4330            public List<DLFolder> filterFindByG_P_M(long groupId, long parentFolderId,
4331                    boolean mountPoint, int start, int end,
4332                    OrderByComparator orderByComparator) throws SystemException {
4333                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4334                            return findByG_P_M(groupId, parentFolderId, mountPoint, start, end,
4335                                    orderByComparator);
4336                    }
4337    
4338                    StringBundler query = null;
4339    
4340                    if (orderByComparator != null) {
4341                            query = new StringBundler(5 +
4342                                            (orderByComparator.getOrderByFields().length * 3));
4343                    }
4344                    else {
4345                            query = new StringBundler(5);
4346                    }
4347    
4348                    if (getDB().isSupportsInlineDistinct()) {
4349                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4350                    }
4351                    else {
4352                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4353                    }
4354    
4355                    query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4356    
4357                    query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4358    
4359                    query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4360    
4361                    if (!getDB().isSupportsInlineDistinct()) {
4362                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4363                    }
4364    
4365                    if (orderByComparator != null) {
4366                            if (getDB().isSupportsInlineDistinct()) {
4367                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4368                                            orderByComparator);
4369                            }
4370                            else {
4371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4372                                            orderByComparator);
4373                            }
4374                    }
4375    
4376                    else {
4377                            if (getDB().isSupportsInlineDistinct()) {
4378                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4379                            }
4380                            else {
4381                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
4382                            }
4383                    }
4384    
4385                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4386                                    DLFolder.class.getName(),
4387                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4388    
4389                    Session session = null;
4390    
4391                    try {
4392                            session = openSession();
4393    
4394                            SQLQuery q = session.createSQLQuery(sql);
4395    
4396                            if (getDB().isSupportsInlineDistinct()) {
4397                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4398                            }
4399                            else {
4400                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4401                            }
4402    
4403                            QueryPos qPos = QueryPos.getInstance(q);
4404    
4405                            qPos.add(groupId);
4406    
4407                            qPos.add(parentFolderId);
4408    
4409                            qPos.add(mountPoint);
4410    
4411                            return (List<DLFolder>)QueryUtil.list(q, getDialect(), start, end);
4412                    }
4413                    catch (Exception e) {
4414                            throw processException(e);
4415                    }
4416                    finally {
4417                            closeSession(session);
4418                    }
4419            }
4420    
4421            /**
4422             * Returns the document library folders before and after the current document library folder in the ordered set of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
4423             *
4424             * @param folderId the primary key of the current document library folder
4425             * @param groupId the group ID
4426             * @param parentFolderId the parent folder ID
4427             * @param mountPoint the mount point
4428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4429             * @return the previous, current, and next document library folder
4430             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a document library folder with the primary key could not be found
4431             * @throws SystemException if a system exception occurred
4432             */
4433            public DLFolder[] filterFindByG_P_M_PrevAndNext(long folderId,
4434                    long groupId, long parentFolderId, boolean mountPoint,
4435                    OrderByComparator orderByComparator)
4436                    throws NoSuchFolderException, SystemException {
4437                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4438                            return findByG_P_M_PrevAndNext(folderId, groupId, parentFolderId,
4439                                    mountPoint, orderByComparator);
4440                    }
4441    
4442                    DLFolder dlFolder = findByPrimaryKey(folderId);
4443    
4444                    Session session = null;
4445    
4446                    try {
4447                            session = openSession();
4448    
4449                            DLFolder[] array = new DLFolderImpl[3];
4450    
4451                            array[0] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4452                                            parentFolderId, mountPoint, orderByComparator, true);
4453    
4454                            array[1] = dlFolder;
4455    
4456                            array[2] = filterGetByG_P_M_PrevAndNext(session, dlFolder, groupId,
4457                                            parentFolderId, mountPoint, orderByComparator, false);
4458    
4459                            return array;
4460                    }
4461                    catch (Exception e) {
4462                            throw processException(e);
4463                    }
4464                    finally {
4465                            closeSession(session);
4466                    }
4467            }
4468    
4469            protected DLFolder filterGetByG_P_M_PrevAndNext(Session session,
4470                    DLFolder dlFolder, long groupId, long parentFolderId,
4471                    boolean mountPoint, OrderByComparator orderByComparator,
4472                    boolean previous) {
4473                    StringBundler query = null;
4474    
4475                    if (orderByComparator != null) {
4476                            query = new StringBundler(6 +
4477                                            (orderByComparator.getOrderByFields().length * 6));
4478                    }
4479                    else {
4480                            query = new StringBundler(3);
4481                    }
4482    
4483                    if (getDB().isSupportsInlineDistinct()) {
4484                            query.append(_FILTER_SQL_SELECT_DLFOLDER_WHERE);
4485                    }
4486                    else {
4487                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4488                    }
4489    
4490                    query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
4491    
4492                    query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
4493    
4494                    query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
4495    
4496                    if (!getDB().isSupportsInlineDistinct()) {
4497                            query.append(_FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4498                    }
4499    
4500                    if (orderByComparator != null) {
4501                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4502    
4503                            if (orderByConditionFields.length > 0) {
4504                                    query.append(WHERE_AND);
4505                            }
4506    
4507                            for (int i = 0; i < orderByConditionFields.length; i++) {
4508                                    if (getDB().isSupportsInlineDistinct()) {
4509                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4510                                    }
4511                                    else {
4512                                            query.append(_ORDER_BY_ENTITY_TABLE);
4513                                    }
4514    
4515                                    query.append(orderByConditionFields[i]);
4516    
4517                                    if ((i + 1) < orderByConditionFields.length) {
4518                                            if (orderByComparator.isAscending() ^ previous) {
4519                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4520                                            }
4521                                            else {
4522                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4523                                            }
4524                                    }
4525                                    else {
4526                                            if (orderByComparator.isAscending() ^ previous) {
4527                                                    query.append(WHERE_GREATER_THAN);
4528                                            }
4529                                            else {
4530                                                    query.append(WHERE_LESSER_THAN);
4531                                            }
4532                                    }
4533                            }
4534    
4535                            query.append(ORDER_BY_CLAUSE);
4536    
4537                            String[] orderByFields = orderByComparator.getOrderByFields();
4538    
4539                            for (int i = 0; i < orderByFields.length; i++) {
4540                                    if (getDB().isSupportsInlineDistinct()) {
4541                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4542                                    }
4543                                    else {
4544                                            query.append(_ORDER_BY_ENTITY_TABLE);
4545                                    }
4546    
4547                                    query.append(orderByFields[i]);
4548    
4549                                    if ((i + 1) < orderByFields.length) {
4550                                            if (orderByComparator.isAscending() ^ previous) {
4551                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4552                                            }
4553                                            else {
4554                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4555                                            }
4556                                    }
4557                                    else {
4558                                            if (orderByComparator.isAscending() ^ previous) {
4559                                                    query.append(ORDER_BY_ASC);
4560                                            }
4561                                            else {
4562                                                    query.append(ORDER_BY_DESC);
4563                                            }
4564                                    }
4565                            }
4566                    }
4567    
4568                    else {
4569                            if (getDB().isSupportsInlineDistinct()) {
4570                                    query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4571                            }
4572                            else {
4573                                    query.append(DLFolderModelImpl.ORDER_BY_SQL);
4574                            }
4575                    }
4576    
4577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4578                                    DLFolder.class.getName(),
4579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4580    
4581                    SQLQuery q = session.createSQLQuery(sql);
4582    
4583                    q.setFirstResult(0);
4584                    q.setMaxResults(2);
4585    
4586                    if (getDB().isSupportsInlineDistinct()) {
4587                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFolderImpl.class);
4588                    }
4589                    else {
4590                            q.addEntity(_FILTER_ENTITY_TABLE, DLFolderImpl.class);
4591                    }
4592    
4593                    QueryPos qPos = QueryPos.getInstance(q);
4594    
4595                    qPos.add(groupId);
4596    
4597                    qPos.add(parentFolderId);
4598    
4599                    qPos.add(mountPoint);
4600    
4601                    if (orderByComparator != null) {
4602                            Object[] values = orderByComparator.getOrderByConditionValues(dlFolder);
4603    
4604                            for (Object value : values) {
4605                                    qPos.add(value);
4606                            }
4607                    }
4608    
4609                    List<DLFolder> list = q.list();
4610    
4611                    if (list.size() == 2) {
4612                            return list.get(1);
4613                    }
4614                    else {
4615                            return null;
4616                    }
4617            }
4618    
4619            /**
4620             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFolderException} if it could not be found.
4621             *
4622             * @param groupId the group ID
4623             * @param parentFolderId the parent folder ID
4624             * @param name the name
4625             * @return the matching document library folder
4626             * @throws com.liferay.portlet.documentlibrary.NoSuchFolderException if a matching document library folder could not be found
4627             * @throws SystemException if a system exception occurred
4628             */
4629            public DLFolder findByG_P_N(long groupId, long parentFolderId, String name)
4630                    throws NoSuchFolderException, SystemException {
4631                    DLFolder dlFolder = fetchByG_P_N(groupId, parentFolderId, name);
4632    
4633                    if (dlFolder == null) {
4634                            StringBundler msg = new StringBundler(8);
4635    
4636                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4637    
4638                            msg.append("groupId=");
4639                            msg.append(groupId);
4640    
4641                            msg.append(", parentFolderId=");
4642                            msg.append(parentFolderId);
4643    
4644                            msg.append(", name=");
4645                            msg.append(name);
4646    
4647                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4648    
4649                            if (_log.isWarnEnabled()) {
4650                                    _log.warn(msg.toString());
4651                            }
4652    
4653                            throw new NoSuchFolderException(msg.toString());
4654                    }
4655    
4656                    return dlFolder;
4657            }
4658    
4659            /**
4660             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4661             *
4662             * @param groupId the group ID
4663             * @param parentFolderId the parent folder ID
4664             * @param name the name
4665             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4666             * @throws SystemException if a system exception occurred
4667             */
4668            public DLFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
4669                    throws SystemException {
4670                    return fetchByG_P_N(groupId, parentFolderId, name, true);
4671            }
4672    
4673            /**
4674             * Returns the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4675             *
4676             * @param groupId the group ID
4677             * @param parentFolderId the parent folder ID
4678             * @param name the name
4679             * @param retrieveFromCache whether to use the finder cache
4680             * @return the matching document library folder, or <code>null</code> if a matching document library folder could not be found
4681             * @throws SystemException if a system exception occurred
4682             */
4683            public DLFolder fetchByG_P_N(long groupId, long parentFolderId,
4684                    String name, boolean retrieveFromCache) throws SystemException {
4685                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
4686    
4687                    Object result = null;
4688    
4689                    if (retrieveFromCache) {
4690                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
4691                                            finderArgs, this);
4692                    }
4693    
4694                    if (result instanceof DLFolder) {
4695                            DLFolder dlFolder = (DLFolder)result;
4696    
4697                            if ((groupId != dlFolder.getGroupId()) ||
4698                                            (parentFolderId != dlFolder.getParentFolderId()) ||
4699                                            !Validator.equals(name, dlFolder.getName())) {
4700                                    result = null;
4701                            }
4702                    }
4703    
4704                    if (result == null) {
4705                            StringBundler query = new StringBundler(5);
4706    
4707                            query.append(_SQL_SELECT_DLFOLDER_WHERE);
4708    
4709                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4710    
4711                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4712    
4713                            if (name == null) {
4714                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4715                            }
4716                            else {
4717                                    if (name.equals(StringPool.BLANK)) {
4718                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4719                                    }
4720                                    else {
4721                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4722                                    }
4723                            }
4724    
4725                            query.append(DLFolderModelImpl.ORDER_BY_JPQL);
4726    
4727                            String sql = query.toString();
4728    
4729                            Session session = null;
4730    
4731                            try {
4732                                    session = openSession();
4733    
4734                                    Query q = session.createQuery(sql);
4735    
4736                                    QueryPos qPos = QueryPos.getInstance(q);
4737    
4738                                    qPos.add(groupId);
4739    
4740                                    qPos.add(parentFolderId);
4741    
4742                                    if (name != null) {
4743                                            qPos.add(name);
4744                                    }
4745    
4746                                    List<DLFolder> list = q.list();
4747    
4748                                    result = list;
4749    
4750                                    DLFolder dlFolder = null;
4751    
4752                                    if (list.isEmpty()) {
4753                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4754                                                    finderArgs, list);
4755                                    }
4756                                    else {
4757                                            dlFolder = list.get(0);
4758    
4759                                            cacheResult(dlFolder);
4760    
4761                                            if ((dlFolder.getGroupId() != groupId) ||
4762                                                            (dlFolder.getParentFolderId() != parentFolderId) ||
4763                                                            (dlFolder.getName() == null) ||
4764                                                            !dlFolder.getName().equals(name)) {
4765                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4766                                                            finderArgs, dlFolder);
4767                                            }
4768                                    }
4769    
4770                                    return dlFolder;
4771                            }
4772                            catch (Exception e) {
4773                                    throw processException(e);
4774                            }
4775                            finally {
4776                                    if (result == null) {
4777                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
4778                                                    finderArgs);
4779                                    }
4780    
4781                                    closeSession(session);
4782                            }
4783                    }
4784                    else {
4785                            if (result instanceof List<?>) {
4786                                    return null;
4787                            }
4788                            else {
4789                                    return (DLFolder)result;
4790                            }
4791                    }
4792            }
4793    
4794            /**
4795             * Returns all the document library folders.
4796             *
4797             * @return the document library folders
4798             * @throws SystemException if a system exception occurred
4799             */
4800            public List<DLFolder> findAll() throws SystemException {
4801                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4802            }
4803    
4804            /**
4805             * Returns a range of all the document library folders.
4806             *
4807             * <p>
4808             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4809             * </p>
4810             *
4811             * @param start the lower bound of the range of document library folders
4812             * @param end the upper bound of the range of document library folders (not inclusive)
4813             * @return the range of document library folders
4814             * @throws SystemException if a system exception occurred
4815             */
4816            public List<DLFolder> findAll(int start, int end) throws SystemException {
4817                    return findAll(start, end, null);
4818            }
4819    
4820            /**
4821             * Returns an ordered range of all the document library folders.
4822             *
4823             * <p>
4824             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4825             * </p>
4826             *
4827             * @param start the lower bound of the range of document library folders
4828             * @param end the upper bound of the range of document library folders (not inclusive)
4829             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4830             * @return the ordered range of document library folders
4831             * @throws SystemException if a system exception occurred
4832             */
4833            public List<DLFolder> findAll(int start, int end,
4834                    OrderByComparator orderByComparator) throws SystemException {
4835                    FinderPath finderPath = null;
4836                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4837    
4838                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4839                                    (orderByComparator == null)) {
4840                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4841                            finderArgs = FINDER_ARGS_EMPTY;
4842                    }
4843                    else {
4844                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4845                            finderArgs = new Object[] { start, end, orderByComparator };
4846                    }
4847    
4848                    List<DLFolder> list = (List<DLFolder>)FinderCacheUtil.getResult(finderPath,
4849                                    finderArgs, this);
4850    
4851                    if (list == null) {
4852                            StringBundler query = null;
4853                            String sql = null;
4854    
4855                            if (orderByComparator != null) {
4856                                    query = new StringBundler(2 +
4857                                                    (orderByComparator.getOrderByFields().length * 3));
4858    
4859                                    query.append(_SQL_SELECT_DLFOLDER);
4860    
4861                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4862                                            orderByComparator);
4863    
4864                                    sql = query.toString();
4865                            }
4866                            else {
4867                                    sql = _SQL_SELECT_DLFOLDER.concat(DLFolderModelImpl.ORDER_BY_JPQL);
4868                            }
4869    
4870                            Session session = null;
4871    
4872                            try {
4873                                    session = openSession();
4874    
4875                                    Query q = session.createQuery(sql);
4876    
4877                                    if (orderByComparator == null) {
4878                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4879                                                            start, end, false);
4880    
4881                                            Collections.sort(list);
4882                                    }
4883                                    else {
4884                                            list = (List<DLFolder>)QueryUtil.list(q, getDialect(),
4885                                                            start, end);
4886                                    }
4887                            }
4888                            catch (Exception e) {
4889                                    throw processException(e);
4890                            }
4891                            finally {
4892                                    if (list == null) {
4893                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4894                                    }
4895                                    else {
4896                                            cacheResult(list);
4897    
4898                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4899                                    }
4900    
4901                                    closeSession(session);
4902                            }
4903                    }
4904    
4905                    return list;
4906            }
4907    
4908            /**
4909             * Removes all the document library folders where uuid = &#63; from the database.
4910             *
4911             * @param uuid the uuid
4912             * @throws SystemException if a system exception occurred
4913             */
4914            public void removeByUuid(String uuid) throws SystemException {
4915                    for (DLFolder dlFolder : findByUuid(uuid)) {
4916                            remove(dlFolder);
4917                    }
4918            }
4919    
4920            /**
4921             * Removes the document library folder where uuid = &#63; and groupId = &#63; from the database.
4922             *
4923             * @param uuid the uuid
4924             * @param groupId the group ID
4925             * @return the document library folder that was removed
4926             * @throws SystemException if a system exception occurred
4927             */
4928            public DLFolder removeByUUID_G(String uuid, long groupId)
4929                    throws NoSuchFolderException, SystemException {
4930                    DLFolder dlFolder = findByUUID_G(uuid, groupId);
4931    
4932                    return remove(dlFolder);
4933            }
4934    
4935            /**
4936             * Removes all the document library folders where groupId = &#63; from the database.
4937             *
4938             * @param groupId the group ID
4939             * @throws SystemException if a system exception occurred
4940             */
4941            public void removeByGroupId(long groupId) throws SystemException {
4942                    for (DLFolder dlFolder : findByGroupId(groupId)) {
4943                            remove(dlFolder);
4944                    }
4945            }
4946    
4947            /**
4948             * Removes all the document library folders where companyId = &#63; from the database.
4949             *
4950             * @param companyId the company ID
4951             * @throws SystemException if a system exception occurred
4952             */
4953            public void removeByCompanyId(long companyId) throws SystemException {
4954                    for (DLFolder dlFolder : findByCompanyId(companyId)) {
4955                            remove(dlFolder);
4956                    }
4957            }
4958    
4959            /**
4960             * Removes the document library folder where repositoryId = &#63; from the database.
4961             *
4962             * @param repositoryId the repository ID
4963             * @return the document library folder that was removed
4964             * @throws SystemException if a system exception occurred
4965             */
4966            public DLFolder removeByRepositoryId(long repositoryId)
4967                    throws NoSuchFolderException, SystemException {
4968                    DLFolder dlFolder = findByRepositoryId(repositoryId);
4969    
4970                    return remove(dlFolder);
4971            }
4972    
4973            /**
4974             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; from the database.
4975             *
4976             * @param groupId the group ID
4977             * @param parentFolderId the parent folder ID
4978             * @throws SystemException if a system exception occurred
4979             */
4980            public void removeByG_P(long groupId, long parentFolderId)
4981                    throws SystemException {
4982                    for (DLFolder dlFolder : findByG_P(groupId, parentFolderId)) {
4983                            remove(dlFolder);
4984                    }
4985            }
4986    
4987            /**
4988             * Removes all the document library folders where parentFolderId = &#63; and name = &#63; from the database.
4989             *
4990             * @param parentFolderId the parent folder ID
4991             * @param name the name
4992             * @throws SystemException if a system exception occurred
4993             */
4994            public void removeByP_N(long parentFolderId, String name)
4995                    throws SystemException {
4996                    for (DLFolder dlFolder : findByP_N(parentFolderId, name)) {
4997                            remove(dlFolder);
4998                    }
4999            }
5000    
5001            /**
5002             * Removes all the document library folders where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63; from the database.
5003             *
5004             * @param groupId the group ID
5005             * @param parentFolderId the parent folder ID
5006             * @param mountPoint the mount point
5007             * @throws SystemException if a system exception occurred
5008             */
5009            public void removeByG_P_M(long groupId, long parentFolderId,
5010                    boolean mountPoint) throws SystemException {
5011                    for (DLFolder dlFolder : findByG_P_M(groupId, parentFolderId, mountPoint)) {
5012                            remove(dlFolder);
5013                    }
5014            }
5015    
5016            /**
5017             * Removes the document library folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; from the database.
5018             *
5019             * @param groupId the group ID
5020             * @param parentFolderId the parent folder ID
5021             * @param name the name
5022             * @return the document library folder that was removed
5023             * @throws SystemException if a system exception occurred
5024             */
5025            public DLFolder removeByG_P_N(long groupId, long parentFolderId, String name)
5026                    throws NoSuchFolderException, SystemException {
5027                    DLFolder dlFolder = findByG_P_N(groupId, parentFolderId, name);
5028    
5029                    return remove(dlFolder);
5030            }
5031    
5032            /**
5033             * Removes all the document library folders from the database.
5034             *
5035             * @throws SystemException if a system exception occurred
5036             */
5037            public void removeAll() throws SystemException {
5038                    for (DLFolder dlFolder : findAll()) {
5039                            remove(dlFolder);
5040                    }
5041            }
5042    
5043            /**
5044             * Returns the number of document library folders where uuid = &#63;.
5045             *
5046             * @param uuid the uuid
5047             * @return the number of matching document library folders
5048             * @throws SystemException if a system exception occurred
5049             */
5050            public int countByUuid(String uuid) throws SystemException {
5051                    Object[] finderArgs = new Object[] { uuid };
5052    
5053                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
5054                                    finderArgs, this);
5055    
5056                    if (count == null) {
5057                            StringBundler query = new StringBundler(2);
5058    
5059                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5060    
5061                            if (uuid == null) {
5062                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
5063                            }
5064                            else {
5065                                    if (uuid.equals(StringPool.BLANK)) {
5066                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
5067                                    }
5068                                    else {
5069                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
5070                                    }
5071                            }
5072    
5073                            String sql = query.toString();
5074    
5075                            Session session = null;
5076    
5077                            try {
5078                                    session = openSession();
5079    
5080                                    Query q = session.createQuery(sql);
5081    
5082                                    QueryPos qPos = QueryPos.getInstance(q);
5083    
5084                                    if (uuid != null) {
5085                                            qPos.add(uuid);
5086                                    }
5087    
5088                                    count = (Long)q.uniqueResult();
5089                            }
5090                            catch (Exception e) {
5091                                    throw processException(e);
5092                            }
5093                            finally {
5094                                    if (count == null) {
5095                                            count = Long.valueOf(0);
5096                                    }
5097    
5098                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
5099                                            finderArgs, count);
5100    
5101                                    closeSession(session);
5102                            }
5103                    }
5104    
5105                    return count.intValue();
5106            }
5107    
5108            /**
5109             * Returns the number of document library folders where uuid = &#63; and groupId = &#63;.
5110             *
5111             * @param uuid the uuid
5112             * @param groupId the group ID
5113             * @return the number of matching document library folders
5114             * @throws SystemException if a system exception occurred
5115             */
5116            public int countByUUID_G(String uuid, long groupId)
5117                    throws SystemException {
5118                    Object[] finderArgs = new Object[] { uuid, groupId };
5119    
5120                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
5121                                    finderArgs, this);
5122    
5123                    if (count == null) {
5124                            StringBundler query = new StringBundler(3);
5125    
5126                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5127    
5128                            if (uuid == null) {
5129                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
5130                            }
5131                            else {
5132                                    if (uuid.equals(StringPool.BLANK)) {
5133                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
5134                                    }
5135                                    else {
5136                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
5137                                    }
5138                            }
5139    
5140                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
5141    
5142                            String sql = query.toString();
5143    
5144                            Session session = null;
5145    
5146                            try {
5147                                    session = openSession();
5148    
5149                                    Query q = session.createQuery(sql);
5150    
5151                                    QueryPos qPos = QueryPos.getInstance(q);
5152    
5153                                    if (uuid != null) {
5154                                            qPos.add(uuid);
5155                                    }
5156    
5157                                    qPos.add(groupId);
5158    
5159                                    count = (Long)q.uniqueResult();
5160                            }
5161                            catch (Exception e) {
5162                                    throw processException(e);
5163                            }
5164                            finally {
5165                                    if (count == null) {
5166                                            count = Long.valueOf(0);
5167                                    }
5168    
5169                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
5170                                            finderArgs, count);
5171    
5172                                    closeSession(session);
5173                            }
5174                    }
5175    
5176                    return count.intValue();
5177            }
5178    
5179            /**
5180             * Returns the number of document library folders where groupId = &#63;.
5181             *
5182             * @param groupId the group ID
5183             * @return the number of matching document library folders
5184             * @throws SystemException if a system exception occurred
5185             */
5186            public int countByGroupId(long groupId) throws SystemException {
5187                    Object[] finderArgs = new Object[] { groupId };
5188    
5189                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
5190                                    finderArgs, this);
5191    
5192                    if (count == null) {
5193                            StringBundler query = new StringBundler(2);
5194    
5195                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5196    
5197                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5198    
5199                            String sql = query.toString();
5200    
5201                            Session session = null;
5202    
5203                            try {
5204                                    session = openSession();
5205    
5206                                    Query q = session.createQuery(sql);
5207    
5208                                    QueryPos qPos = QueryPos.getInstance(q);
5209    
5210                                    qPos.add(groupId);
5211    
5212                                    count = (Long)q.uniqueResult();
5213                            }
5214                            catch (Exception e) {
5215                                    throw processException(e);
5216                            }
5217                            finally {
5218                                    if (count == null) {
5219                                            count = Long.valueOf(0);
5220                                    }
5221    
5222                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5223                                            finderArgs, count);
5224    
5225                                    closeSession(session);
5226                            }
5227                    }
5228    
5229                    return count.intValue();
5230            }
5231    
5232            /**
5233             * Returns the number of document library folders that the user has permission to view where groupId = &#63;.
5234             *
5235             * @param groupId the group ID
5236             * @return the number of matching document library folders that the user has permission to view
5237             * @throws SystemException if a system exception occurred
5238             */
5239            public int filterCountByGroupId(long groupId) throws SystemException {
5240                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5241                            return countByGroupId(groupId);
5242                    }
5243    
5244                    StringBundler query = new StringBundler(2);
5245    
5246                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5247    
5248                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5249    
5250                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5251                                    DLFolder.class.getName(),
5252                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5253    
5254                    Session session = null;
5255    
5256                    try {
5257                            session = openSession();
5258    
5259                            SQLQuery q = session.createSQLQuery(sql);
5260    
5261                            q.addScalar(COUNT_COLUMN_NAME,
5262                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5263    
5264                            QueryPos qPos = QueryPos.getInstance(q);
5265    
5266                            qPos.add(groupId);
5267    
5268                            Long count = (Long)q.uniqueResult();
5269    
5270                            return count.intValue();
5271                    }
5272                    catch (Exception e) {
5273                            throw processException(e);
5274                    }
5275                    finally {
5276                            closeSession(session);
5277                    }
5278            }
5279    
5280            /**
5281             * Returns the number of document library folders where companyId = &#63;.
5282             *
5283             * @param companyId the company ID
5284             * @return the number of matching document library folders
5285             * @throws SystemException if a system exception occurred
5286             */
5287            public int countByCompanyId(long companyId) throws SystemException {
5288                    Object[] finderArgs = new Object[] { companyId };
5289    
5290                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
5291                                    finderArgs, this);
5292    
5293                    if (count == null) {
5294                            StringBundler query = new StringBundler(2);
5295    
5296                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5297    
5298                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
5299    
5300                            String sql = query.toString();
5301    
5302                            Session session = null;
5303    
5304                            try {
5305                                    session = openSession();
5306    
5307                                    Query q = session.createQuery(sql);
5308    
5309                                    QueryPos qPos = QueryPos.getInstance(q);
5310    
5311                                    qPos.add(companyId);
5312    
5313                                    count = (Long)q.uniqueResult();
5314                            }
5315                            catch (Exception e) {
5316                                    throw processException(e);
5317                            }
5318                            finally {
5319                                    if (count == null) {
5320                                            count = Long.valueOf(0);
5321                                    }
5322    
5323                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
5324                                            finderArgs, count);
5325    
5326                                    closeSession(session);
5327                            }
5328                    }
5329    
5330                    return count.intValue();
5331            }
5332    
5333            /**
5334             * Returns the number of document library folders where repositoryId = &#63;.
5335             *
5336             * @param repositoryId the repository ID
5337             * @return the number of matching document library folders
5338             * @throws SystemException if a system exception occurred
5339             */
5340            public int countByRepositoryId(long repositoryId) throws SystemException {
5341                    Object[] finderArgs = new Object[] { repositoryId };
5342    
5343                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5344                                    finderArgs, this);
5345    
5346                    if (count == null) {
5347                            StringBundler query = new StringBundler(2);
5348    
5349                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5350    
5351                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
5352    
5353                            String sql = query.toString();
5354    
5355                            Session session = null;
5356    
5357                            try {
5358                                    session = openSession();
5359    
5360                                    Query q = session.createQuery(sql);
5361    
5362                                    QueryPos qPos = QueryPos.getInstance(q);
5363    
5364                                    qPos.add(repositoryId);
5365    
5366                                    count = (Long)q.uniqueResult();
5367                            }
5368                            catch (Exception e) {
5369                                    throw processException(e);
5370                            }
5371                            finally {
5372                                    if (count == null) {
5373                                            count = Long.valueOf(0);
5374                                    }
5375    
5376                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
5377                                            finderArgs, count);
5378    
5379                                    closeSession(session);
5380                            }
5381                    }
5382    
5383                    return count.intValue();
5384            }
5385    
5386            /**
5387             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63;.
5388             *
5389             * @param groupId the group ID
5390             * @param parentFolderId the parent folder ID
5391             * @return the number of matching document library folders
5392             * @throws SystemException if a system exception occurred
5393             */
5394            public int countByG_P(long groupId, long parentFolderId)
5395                    throws SystemException {
5396                    Object[] finderArgs = new Object[] { groupId, parentFolderId };
5397    
5398                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
5399                                    finderArgs, this);
5400    
5401                    if (count == null) {
5402                            StringBundler query = new StringBundler(3);
5403    
5404                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5405    
5406                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5407    
5408                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5409    
5410                            String sql = query.toString();
5411    
5412                            Session session = null;
5413    
5414                            try {
5415                                    session = openSession();
5416    
5417                                    Query q = session.createQuery(sql);
5418    
5419                                    QueryPos qPos = QueryPos.getInstance(q);
5420    
5421                                    qPos.add(groupId);
5422    
5423                                    qPos.add(parentFolderId);
5424    
5425                                    count = (Long)q.uniqueResult();
5426                            }
5427                            catch (Exception e) {
5428                                    throw processException(e);
5429                            }
5430                            finally {
5431                                    if (count == null) {
5432                                            count = Long.valueOf(0);
5433                                    }
5434    
5435                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
5436                                            count);
5437    
5438                                    closeSession(session);
5439                            }
5440                    }
5441    
5442                    return count.intValue();
5443            }
5444    
5445            /**
5446             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
5447             *
5448             * @param groupId the group ID
5449             * @param parentFolderId the parent folder ID
5450             * @return the number of matching document library folders that the user has permission to view
5451             * @throws SystemException if a system exception occurred
5452             */
5453            public int filterCountByG_P(long groupId, long parentFolderId)
5454                    throws SystemException {
5455                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5456                            return countByG_P(groupId, parentFolderId);
5457                    }
5458    
5459                    StringBundler query = new StringBundler(3);
5460    
5461                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5462    
5463                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
5464    
5465                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
5466    
5467                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5468                                    DLFolder.class.getName(),
5469                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5470    
5471                    Session session = null;
5472    
5473                    try {
5474                            session = openSession();
5475    
5476                            SQLQuery q = session.createSQLQuery(sql);
5477    
5478                            q.addScalar(COUNT_COLUMN_NAME,
5479                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5480    
5481                            QueryPos qPos = QueryPos.getInstance(q);
5482    
5483                            qPos.add(groupId);
5484    
5485                            qPos.add(parentFolderId);
5486    
5487                            Long count = (Long)q.uniqueResult();
5488    
5489                            return count.intValue();
5490                    }
5491                    catch (Exception e) {
5492                            throw processException(e);
5493                    }
5494                    finally {
5495                            closeSession(session);
5496                    }
5497            }
5498    
5499            /**
5500             * Returns the number of document library folders where parentFolderId = &#63; and name = &#63;.
5501             *
5502             * @param parentFolderId the parent folder ID
5503             * @param name the name
5504             * @return the number of matching document library folders
5505             * @throws SystemException if a system exception occurred
5506             */
5507            public int countByP_N(long parentFolderId, String name)
5508                    throws SystemException {
5509                    Object[] finderArgs = new Object[] { parentFolderId, name };
5510    
5511                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5512                                    finderArgs, this);
5513    
5514                    if (count == null) {
5515                            StringBundler query = new StringBundler(3);
5516    
5517                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5518    
5519                            query.append(_FINDER_COLUMN_P_N_PARENTFOLDERID_2);
5520    
5521                            if (name == null) {
5522                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5523                            }
5524                            else {
5525                                    if (name.equals(StringPool.BLANK)) {
5526                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5527                                    }
5528                                    else {
5529                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5530                                    }
5531                            }
5532    
5533                            String sql = query.toString();
5534    
5535                            Session session = null;
5536    
5537                            try {
5538                                    session = openSession();
5539    
5540                                    Query q = session.createQuery(sql);
5541    
5542                                    QueryPos qPos = QueryPos.getInstance(q);
5543    
5544                                    qPos.add(parentFolderId);
5545    
5546                                    if (name != null) {
5547                                            qPos.add(name);
5548                                    }
5549    
5550                                    count = (Long)q.uniqueResult();
5551                            }
5552                            catch (Exception e) {
5553                                    throw processException(e);
5554                            }
5555                            finally {
5556                                    if (count == null) {
5557                                            count = Long.valueOf(0);
5558                                    }
5559    
5560                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5561                                            count);
5562    
5563                                    closeSession(session);
5564                            }
5565                    }
5566    
5567                    return count.intValue();
5568            }
5569    
5570            /**
5571             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
5572             *
5573             * @param groupId the group ID
5574             * @param parentFolderId the parent folder ID
5575             * @param mountPoint the mount point
5576             * @return the number of matching document library folders
5577             * @throws SystemException if a system exception occurred
5578             */
5579            public int countByG_P_M(long groupId, long parentFolderId,
5580                    boolean mountPoint) throws SystemException {
5581                    Object[] finderArgs = new Object[] { groupId, parentFolderId, mountPoint };
5582    
5583                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_M,
5584                                    finderArgs, this);
5585    
5586                    if (count == null) {
5587                            StringBundler query = new StringBundler(4);
5588    
5589                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5590    
5591                            query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5592    
5593                            query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5594    
5595                            query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5596    
5597                            String sql = query.toString();
5598    
5599                            Session session = null;
5600    
5601                            try {
5602                                    session = openSession();
5603    
5604                                    Query q = session.createQuery(sql);
5605    
5606                                    QueryPos qPos = QueryPos.getInstance(q);
5607    
5608                                    qPos.add(groupId);
5609    
5610                                    qPos.add(parentFolderId);
5611    
5612                                    qPos.add(mountPoint);
5613    
5614                                    count = (Long)q.uniqueResult();
5615                            }
5616                            catch (Exception e) {
5617                                    throw processException(e);
5618                            }
5619                            finally {
5620                                    if (count == null) {
5621                                            count = Long.valueOf(0);
5622                                    }
5623    
5624                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_M,
5625                                            finderArgs, count);
5626    
5627                                    closeSession(session);
5628                            }
5629                    }
5630    
5631                    return count.intValue();
5632            }
5633    
5634            /**
5635             * Returns the number of document library folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63; and mountPoint = &#63;.
5636             *
5637             * @param groupId the group ID
5638             * @param parentFolderId the parent folder ID
5639             * @param mountPoint the mount point
5640             * @return the number of matching document library folders that the user has permission to view
5641             * @throws SystemException if a system exception occurred
5642             */
5643            public int filterCountByG_P_M(long groupId, long parentFolderId,
5644                    boolean mountPoint) throws SystemException {
5645                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5646                            return countByG_P_M(groupId, parentFolderId, mountPoint);
5647                    }
5648    
5649                    StringBundler query = new StringBundler(4);
5650    
5651                    query.append(_FILTER_SQL_COUNT_DLFOLDER_WHERE);
5652    
5653                    query.append(_FINDER_COLUMN_G_P_M_GROUPID_2);
5654    
5655                    query.append(_FINDER_COLUMN_G_P_M_PARENTFOLDERID_2);
5656    
5657                    query.append(_FINDER_COLUMN_G_P_M_MOUNTPOINT_2);
5658    
5659                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5660                                    DLFolder.class.getName(),
5661                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5662    
5663                    Session session = null;
5664    
5665                    try {
5666                            session = openSession();
5667    
5668                            SQLQuery q = session.createSQLQuery(sql);
5669    
5670                            q.addScalar(COUNT_COLUMN_NAME,
5671                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5672    
5673                            QueryPos qPos = QueryPos.getInstance(q);
5674    
5675                            qPos.add(groupId);
5676    
5677                            qPos.add(parentFolderId);
5678    
5679                            qPos.add(mountPoint);
5680    
5681                            Long count = (Long)q.uniqueResult();
5682    
5683                            return count.intValue();
5684                    }
5685                    catch (Exception e) {
5686                            throw processException(e);
5687                    }
5688                    finally {
5689                            closeSession(session);
5690                    }
5691            }
5692    
5693            /**
5694             * Returns the number of document library folders where groupId = &#63; and parentFolderId = &#63; and name = &#63;.
5695             *
5696             * @param groupId the group ID
5697             * @param parentFolderId the parent folder ID
5698             * @param name the name
5699             * @return the number of matching document library folders
5700             * @throws SystemException if a system exception occurred
5701             */
5702            public int countByG_P_N(long groupId, long parentFolderId, String name)
5703                    throws SystemException {
5704                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
5705    
5706                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
5707                                    finderArgs, this);
5708    
5709                    if (count == null) {
5710                            StringBundler query = new StringBundler(4);
5711    
5712                            query.append(_SQL_COUNT_DLFOLDER_WHERE);
5713    
5714                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
5715    
5716                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
5717    
5718                            if (name == null) {
5719                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
5720                            }
5721                            else {
5722                                    if (name.equals(StringPool.BLANK)) {
5723                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
5724                                    }
5725                                    else {
5726                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
5727                                    }
5728                            }
5729    
5730                            String sql = query.toString();
5731    
5732                            Session session = null;
5733    
5734                            try {
5735                                    session = openSession();
5736    
5737                                    Query q = session.createQuery(sql);
5738    
5739                                    QueryPos qPos = QueryPos.getInstance(q);
5740    
5741                                    qPos.add(groupId);
5742    
5743                                    qPos.add(parentFolderId);
5744    
5745                                    if (name != null) {
5746                                            qPos.add(name);
5747                                    }
5748    
5749                                    count = (Long)q.uniqueResult();
5750                            }
5751                            catch (Exception e) {
5752                                    throw processException(e);
5753                            }
5754                            finally {
5755                                    if (count == null) {
5756                                            count = Long.valueOf(0);
5757                                    }
5758    
5759                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
5760                                            finderArgs, count);
5761    
5762                                    closeSession(session);
5763                            }
5764                    }
5765    
5766                    return count.intValue();
5767            }
5768    
5769            /**
5770             * Returns the number of document library folders.
5771             *
5772             * @return the number of document library folders
5773             * @throws SystemException if a system exception occurred
5774             */
5775            public int countAll() throws SystemException {
5776                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5777                                    FINDER_ARGS_EMPTY, this);
5778    
5779                    if (count == null) {
5780                            Session session = null;
5781    
5782                            try {
5783                                    session = openSession();
5784    
5785                                    Query q = session.createQuery(_SQL_COUNT_DLFOLDER);
5786    
5787                                    count = (Long)q.uniqueResult();
5788                            }
5789                            catch (Exception e) {
5790                                    throw processException(e);
5791                            }
5792                            finally {
5793                                    if (count == null) {
5794                                            count = Long.valueOf(0);
5795                                    }
5796    
5797                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5798                                            FINDER_ARGS_EMPTY, count);
5799    
5800                                    closeSession(session);
5801                            }
5802                    }
5803    
5804                    return count.intValue();
5805            }
5806    
5807            /**
5808             * Returns all the document library file entry types associated with the document library folder.
5809             *
5810             * @param pk the primary key of the document library folder
5811             * @return the document library file entry types associated with the document library folder
5812             * @throws SystemException if a system exception occurred
5813             */
5814            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5815                    long pk) throws SystemException {
5816                    return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5817            }
5818    
5819            /**
5820             * Returns a range of all the document library file entry types associated with the document library folder.
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 pk the primary key of the document library folder
5827             * @param start the lower bound of the range of document library folders
5828             * @param end the upper bound of the range of document library folders (not inclusive)
5829             * @return the range of document library file entry types associated with the document library folder
5830             * @throws SystemException if a system exception occurred
5831             */
5832            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5833                    long pk, int start, int end) throws SystemException {
5834                    return getDLFileEntryTypes(pk, start, end, null);
5835            }
5836    
5837            public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5838                            DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5839                            com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class,
5840                            DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5841                            "getDLFileEntryTypes",
5842                            new String[] {
5843                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5844                                    "com.liferay.portal.kernel.util.OrderByComparator"
5845                            });
5846    
5847            static {
5848                    FINDER_PATH_GET_DLFILEENTRYTYPES.setCacheKeyGeneratorCacheName(null);
5849            }
5850    
5851            /**
5852             * Returns an ordered range of all the document library file entry types associated with the document library folder.
5853             *
5854             * <p>
5855             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5856             * </p>
5857             *
5858             * @param pk the primary key of the document library folder
5859             * @param start the lower bound of the range of document library folders
5860             * @param end the upper bound of the range of document library folders (not inclusive)
5861             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5862             * @return the ordered range of document library file entry types associated with the document library folder
5863             * @throws SystemException if a system exception occurred
5864             */
5865            public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
5866                    long pk, int start, int end, OrderByComparator orderByComparator)
5867                    throws SystemException {
5868                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5869    
5870                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5871                                    finderArgs, this);
5872    
5873                    if (list == null) {
5874                            Session session = null;
5875    
5876                            try {
5877                                    session = openSession();
5878    
5879                                    String sql = null;
5880    
5881                                    if (orderByComparator != null) {
5882                                            sql = _SQL_GETDLFILEENTRYTYPES.concat(ORDER_BY_CLAUSE)
5883                                                                                                      .concat(orderByComparator.getOrderBy());
5884                                    }
5885                                    else {
5886                                            sql = _SQL_GETDLFILEENTRYTYPES;
5887                                    }
5888    
5889                                    SQLQuery q = session.createSQLQuery(sql);
5890    
5891                                    q.addEntity("DLFileEntryType",
5892                                            com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class);
5893    
5894                                    QueryPos qPos = QueryPos.getInstance(q);
5895    
5896                                    qPos.add(pk);
5897    
5898                                    list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)QueryUtil.list(q,
5899                                                    getDialect(), start, end);
5900                            }
5901                            catch (Exception e) {
5902                                    throw processException(e);
5903                            }
5904                            finally {
5905                                    if (list == null) {
5906                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5907                                                    finderArgs);
5908                                    }
5909                                    else {
5910                                            dlFileEntryTypePersistence.cacheResult(list);
5911    
5912                                            FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
5913                                                    finderArgs, list);
5914                                    }
5915    
5916                                    closeSession(session);
5917                            }
5918                    }
5919    
5920                    return list;
5921            }
5922    
5923            public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5924                            DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5925                            Long.class,
5926                            DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5927                            "getDLFileEntryTypesSize", new String[] { Long.class.getName() });
5928    
5929            static {
5930                    FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE.setCacheKeyGeneratorCacheName(null);
5931            }
5932    
5933            /**
5934             * Returns the number of document library file entry types associated with the document library folder.
5935             *
5936             * @param pk the primary key of the document library folder
5937             * @return the number of document library file entry types associated with the document library folder
5938             * @throws SystemException if a system exception occurred
5939             */
5940            public int getDLFileEntryTypesSize(long pk) throws SystemException {
5941                    Object[] finderArgs = new Object[] { pk };
5942    
5943                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5944                                    finderArgs, this);
5945    
5946                    if (count == null) {
5947                            Session session = null;
5948    
5949                            try {
5950                                    session = openSession();
5951    
5952                                    SQLQuery q = session.createSQLQuery(_SQL_GETDLFILEENTRYTYPESSIZE);
5953    
5954                                    q.addScalar(COUNT_COLUMN_NAME,
5955                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
5956    
5957                                    QueryPos qPos = QueryPos.getInstance(q);
5958    
5959                                    qPos.add(pk);
5960    
5961                                    count = (Long)q.uniqueResult();
5962                            }
5963                            catch (Exception e) {
5964                                    throw processException(e);
5965                            }
5966                            finally {
5967                                    if (count == null) {
5968                                            count = Long.valueOf(0);
5969                                    }
5970    
5971                                    FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
5972                                            finderArgs, count);
5973    
5974                                    closeSession(session);
5975                            }
5976                    }
5977    
5978                    return count.intValue();
5979            }
5980    
5981            public static final FinderPath FINDER_PATH_CONTAINS_DLFILEENTRYTYPE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
5982                            DLFolderModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
5983                            Boolean.class,
5984                            DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
5985                            "containsDLFileEntryType",
5986                            new String[] { Long.class.getName(), Long.class.getName() });
5987    
5988            /**
5989             * Returns <code>true</code> if the document library file entry type is associated with the document library folder.
5990             *
5991             * @param pk the primary key of the document library folder
5992             * @param dlFileEntryTypePK the primary key of the document library file entry type
5993             * @return <code>true</code> if the document library file entry type is associated with the document library folder; <code>false</code> otherwise
5994             * @throws SystemException if a system exception occurred
5995             */
5996            public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK)
5997                    throws SystemException {
5998                    Object[] finderArgs = new Object[] { pk, dlFileEntryTypePK };
5999    
6000                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
6001                                    finderArgs, this);
6002    
6003                    if (value == null) {
6004                            try {
6005                                    value = Boolean.valueOf(containsDLFileEntryType.contains(pk,
6006                                                            dlFileEntryTypePK));
6007                            }
6008                            catch (Exception e) {
6009                                    throw processException(e);
6010                            }
6011                            finally {
6012                                    if (value == null) {
6013                                            value = Boolean.FALSE;
6014                                    }
6015    
6016                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
6017                                            finderArgs, value);
6018                            }
6019                    }
6020    
6021                    return value.booleanValue();
6022            }
6023    
6024            /**
6025             * Returns <code>true</code> if the document library folder has any document library file entry types associated with it.
6026             *
6027             * @param pk the primary key of the document library folder to check for associations with document library file entry types
6028             * @return <code>true</code> if the document library folder has any document library file entry types associated with it; <code>false</code> otherwise
6029             * @throws SystemException if a system exception occurred
6030             */
6031            public boolean containsDLFileEntryTypes(long pk) throws SystemException {
6032                    if (getDLFileEntryTypesSize(pk) > 0) {
6033                            return true;
6034                    }
6035                    else {
6036                            return false;
6037                    }
6038            }
6039    
6040            /**
6041             * Adds an association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6042             *
6043             * @param pk the primary key of the document library folder
6044             * @param dlFileEntryTypePK the primary key of the document library file entry type
6045             * @throws SystemException if a system exception occurred
6046             */
6047            public void addDLFileEntryType(long pk, long dlFileEntryTypePK)
6048                    throws SystemException {
6049                    try {
6050                            addDLFileEntryType.add(pk, dlFileEntryTypePK);
6051                    }
6052                    catch (Exception e) {
6053                            throw processException(e);
6054                    }
6055                    finally {
6056                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6057                    }
6058            }
6059    
6060            /**
6061             * Adds an association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6062             *
6063             * @param pk the primary key of the document library folder
6064             * @param dlFileEntryType the document library file entry type
6065             * @throws SystemException if a system exception occurred
6066             */
6067            public void addDLFileEntryType(long pk,
6068                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
6069                    throws SystemException {
6070                    try {
6071                            addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
6072                    }
6073                    catch (Exception e) {
6074                            throw processException(e);
6075                    }
6076                    finally {
6077                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6078                    }
6079            }
6080    
6081            /**
6082             * Adds an association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6083             *
6084             * @param pk the primary key of the document library folder
6085             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
6086             * @throws SystemException if a system exception occurred
6087             */
6088            public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
6089                    throws SystemException {
6090                    try {
6091                            for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
6092                                    addDLFileEntryType.add(pk, dlFileEntryTypePK);
6093                            }
6094                    }
6095                    catch (Exception e) {
6096                            throw processException(e);
6097                    }
6098                    finally {
6099                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6100                    }
6101            }
6102    
6103            /**
6104             * Adds an association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6105             *
6106             * @param pk the primary key of the document library folder
6107             * @param dlFileEntryTypes the document library file entry types
6108             * @throws SystemException if a system exception occurred
6109             */
6110            public void addDLFileEntryTypes(long pk,
6111                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
6112                    throws SystemException {
6113                    try {
6114                            for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6115                                    addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
6116                            }
6117                    }
6118                    catch (Exception e) {
6119                            throw processException(e);
6120                    }
6121                    finally {
6122                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6123                    }
6124            }
6125    
6126            /**
6127             * Clears all associations between the document library folder and its document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6128             *
6129             * @param pk the primary key of the document library folder to clear the associated document library file entry types from
6130             * @throws SystemException if a system exception occurred
6131             */
6132            public void clearDLFileEntryTypes(long pk) throws SystemException {
6133                    try {
6134                            clearDLFileEntryTypes.clear(pk);
6135                    }
6136                    catch (Exception e) {
6137                            throw processException(e);
6138                    }
6139                    finally {
6140                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6141                    }
6142            }
6143    
6144            /**
6145             * Removes the association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6146             *
6147             * @param pk the primary key of the document library folder
6148             * @param dlFileEntryTypePK the primary key of the document library file entry type
6149             * @throws SystemException if a system exception occurred
6150             */
6151            public void removeDLFileEntryType(long pk, long dlFileEntryTypePK)
6152                    throws SystemException {
6153                    try {
6154                            removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
6155                    }
6156                    catch (Exception e) {
6157                            throw processException(e);
6158                    }
6159                    finally {
6160                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6161                    }
6162            }
6163    
6164            /**
6165             * Removes the association between the document library folder and the document library file entry type. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6166             *
6167             * @param pk the primary key of the document library folder
6168             * @param dlFileEntryType the document library file entry type
6169             * @throws SystemException if a system exception occurred
6170             */
6171            public void removeDLFileEntryType(long pk,
6172                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
6173                    throws SystemException {
6174                    try {
6175                            removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
6176                    }
6177                    catch (Exception e) {
6178                            throw processException(e);
6179                    }
6180                    finally {
6181                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6182                    }
6183            }
6184    
6185            /**
6186             * Removes the association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6187             *
6188             * @param pk the primary key of the document library folder
6189             * @param dlFileEntryTypePKs the primary keys of the document library file entry types
6190             * @throws SystemException if a system exception occurred
6191             */
6192            public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
6193                    throws SystemException {
6194                    try {
6195                            for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
6196                                    removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
6197                            }
6198                    }
6199                    catch (Exception e) {
6200                            throw processException(e);
6201                    }
6202                    finally {
6203                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6204                    }
6205            }
6206    
6207            /**
6208             * Removes the association between the document library folder and the document library file entry types. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6209             *
6210             * @param pk the primary key of the document library folder
6211             * @param dlFileEntryTypes the document library file entry types
6212             * @throws SystemException if a system exception occurred
6213             */
6214            public void removeDLFileEntryTypes(long pk,
6215                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
6216                    throws SystemException {
6217                    try {
6218                            for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6219                                    removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
6220                            }
6221                    }
6222                    catch (Exception e) {
6223                            throw processException(e);
6224                    }
6225                    finally {
6226                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6227                    }
6228            }
6229    
6230            /**
6231             * Sets the document library file entry types associated with the document library folder, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6232             *
6233             * @param pk the primary key of the document library folder
6234             * @param dlFileEntryTypePKs the primary keys of the document library file entry types to be associated with the document library folder
6235             * @throws SystemException if a system exception occurred
6236             */
6237            public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
6238                    throws SystemException {
6239                    try {
6240                            Set<Long> dlFileEntryTypePKSet = SetUtil.fromArray(dlFileEntryTypePKs);
6241    
6242                            List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
6243                                    getDLFileEntryTypes(pk);
6244    
6245                            for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6246                                    if (!dlFileEntryTypePKSet.remove(
6247                                                            dlFileEntryType.getPrimaryKey())) {
6248                                            removeDLFileEntryType.remove(pk,
6249                                                    dlFileEntryType.getPrimaryKey());
6250                                    }
6251                            }
6252    
6253                            for (Long dlFileEntryTypePK : dlFileEntryTypePKSet) {
6254                                    addDLFileEntryType.add(pk, dlFileEntryTypePK);
6255                            }
6256                    }
6257                    catch (Exception e) {
6258                            throw processException(e);
6259                    }
6260                    finally {
6261                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6262                    }
6263            }
6264    
6265            /**
6266             * Sets the document library file entry types associated with the document library folder, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6267             *
6268             * @param pk the primary key of the document library folder
6269             * @param dlFileEntryTypes the document library file entry types to be associated with the document library folder
6270             * @throws SystemException if a system exception occurred
6271             */
6272            public void setDLFileEntryTypes(long pk,
6273                    List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
6274                    throws SystemException {
6275                    try {
6276                            long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
6277    
6278                            for (int i = 0; i < dlFileEntryTypes.size(); i++) {
6279                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
6280                                            dlFileEntryTypes.get(i);
6281    
6282                                    dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
6283                            }
6284    
6285                            setDLFileEntryTypes(pk, dlFileEntryTypePKs);
6286                    }
6287                    catch (Exception e) {
6288                            throw processException(e);
6289                    }
6290                    finally {
6291                            FinderCacheUtil.clearCache(DLFolderModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
6292                    }
6293            }
6294    
6295            /**
6296             * Initializes the document library folder persistence.
6297             */
6298            public void afterPropertiesSet() {
6299                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6300                                            com.liferay.portal.util.PropsUtil.get(
6301                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFolder")));
6302    
6303                    if (listenerClassNames.length > 0) {
6304                            try {
6305                                    List<ModelListener<DLFolder>> listenersList = new ArrayList<ModelListener<DLFolder>>();
6306    
6307                                    for (String listenerClassName : listenerClassNames) {
6308                                            Class<?> clazz = getClass();
6309    
6310                                            listenersList.add((ModelListener<DLFolder>)InstanceFactory.newInstance(
6311                                                            clazz.getClassLoader(), listenerClassName));
6312                                    }
6313    
6314                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6315                            }
6316                            catch (Exception e) {
6317                                    _log.error(e);
6318                            }
6319                    }
6320    
6321                    containsDLFileEntryType = new ContainsDLFileEntryType();
6322    
6323                    addDLFileEntryType = new AddDLFileEntryType();
6324                    clearDLFileEntryTypes = new ClearDLFileEntryTypes();
6325                    removeDLFileEntryType = new RemoveDLFileEntryType();
6326            }
6327    
6328            public void destroy() {
6329                    EntityCacheUtil.removeCache(DLFolderImpl.class.getName());
6330                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6331                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6332            }
6333    
6334            @BeanReference(type = DLContentPersistence.class)
6335            protected DLContentPersistence dlContentPersistence;
6336            @BeanReference(type = DLFileEntryPersistence.class)
6337            protected DLFileEntryPersistence dlFileEntryPersistence;
6338            @BeanReference(type = DLFileEntryMetadataPersistence.class)
6339            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
6340            @BeanReference(type = DLFileEntryTypePersistence.class)
6341            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
6342            @BeanReference(type = DLFileRankPersistence.class)
6343            protected DLFileRankPersistence dlFileRankPersistence;
6344            @BeanReference(type = DLFileShortcutPersistence.class)
6345            protected DLFileShortcutPersistence dlFileShortcutPersistence;
6346            @BeanReference(type = DLFileVersionPersistence.class)
6347            protected DLFileVersionPersistence dlFileVersionPersistence;
6348            @BeanReference(type = DLFolderPersistence.class)
6349            protected DLFolderPersistence dlFolderPersistence;
6350            @BeanReference(type = DLSyncPersistence.class)
6351            protected DLSyncPersistence dlSyncPersistence;
6352            @BeanReference(type = GroupPersistence.class)
6353            protected GroupPersistence groupPersistence;
6354            @BeanReference(type = LockPersistence.class)
6355            protected LockPersistence lockPersistence;
6356            @BeanReference(type = ResourcePersistence.class)
6357            protected ResourcePersistence resourcePersistence;
6358            @BeanReference(type = UserPersistence.class)
6359            protected UserPersistence userPersistence;
6360            @BeanReference(type = WebDAVPropsPersistence.class)
6361            protected WebDAVPropsPersistence webDAVPropsPersistence;
6362            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6363            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6364            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6365            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6366            @BeanReference(type = ExpandoValuePersistence.class)
6367            protected ExpandoValuePersistence expandoValuePersistence;
6368            protected ContainsDLFileEntryType containsDLFileEntryType;
6369            protected AddDLFileEntryType addDLFileEntryType;
6370            protected ClearDLFileEntryTypes clearDLFileEntryTypes;
6371            protected RemoveDLFileEntryType removeDLFileEntryType;
6372    
6373            protected class ContainsDLFileEntryType {
6374                    protected ContainsDLFileEntryType() {
6375                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6376                                            _SQL_CONTAINSDLFILEENTRYTYPE,
6377                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6378                                            RowMapper.COUNT);
6379                    }
6380    
6381                    protected boolean contains(long folderId, long fileEntryTypeId) {
6382                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6383                                                    new Long(folderId), new Long(fileEntryTypeId)
6384                                            });
6385    
6386                            if (results.size() > 0) {
6387                                    Integer count = results.get(0);
6388    
6389                                    if (count.intValue() > 0) {
6390                                            return true;
6391                                    }
6392                            }
6393    
6394                            return false;
6395                    }
6396    
6397                    private MappingSqlQuery<Integer> _mappingSqlQuery;
6398            }
6399    
6400            protected class AddDLFileEntryType {
6401                    protected AddDLFileEntryType() {
6402                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6403                                            "INSERT INTO DLFileEntryTypes_DLFolders (folderId, fileEntryTypeId) VALUES (?, ?)",
6404                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6405                    }
6406    
6407                    protected void add(long folderId, long fileEntryTypeId)
6408                            throws SystemException {
6409                            if (!containsDLFileEntryType.contains(folderId, fileEntryTypeId)) {
6410                                    ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6411                                            dlFileEntryTypePersistence.getListeners();
6412    
6413                                    for (ModelListener<DLFolder> listener : listeners) {
6414                                            listener.onBeforeAddAssociation(folderId,
6415                                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6416                                                    fileEntryTypeId);
6417                                    }
6418    
6419                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6420                                            listener.onBeforeAddAssociation(fileEntryTypeId,
6421                                                    DLFolder.class.getName(), folderId);
6422                                    }
6423    
6424                                    _sqlUpdate.update(new Object[] {
6425                                                    new Long(folderId), new Long(fileEntryTypeId)
6426                                            });
6427    
6428                                    for (ModelListener<DLFolder> listener : listeners) {
6429                                            listener.onAfterAddAssociation(folderId,
6430                                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6431                                                    fileEntryTypeId);
6432                                    }
6433    
6434                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6435                                            listener.onAfterAddAssociation(fileEntryTypeId,
6436                                                    DLFolder.class.getName(), folderId);
6437                                    }
6438                            }
6439                    }
6440    
6441                    private SqlUpdate _sqlUpdate;
6442            }
6443    
6444            protected class ClearDLFileEntryTypes {
6445                    protected ClearDLFileEntryTypes() {
6446                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6447                                            "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?",
6448                                            new int[] { java.sql.Types.BIGINT });
6449                    }
6450    
6451                    protected void clear(long folderId) throws SystemException {
6452                            ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6453                                    dlFileEntryTypePersistence.getListeners();
6454    
6455                            List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
6456                                    null;
6457    
6458                            if ((listeners.length > 0) ||
6459                                            (dlFileEntryTypeListeners.length > 0)) {
6460                                    dlFileEntryTypes = getDLFileEntryTypes(folderId);
6461    
6462                                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6463                                            for (ModelListener<DLFolder> listener : listeners) {
6464                                                    listener.onBeforeRemoveAssociation(folderId,
6465                                                            com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6466                                                            dlFileEntryType.getPrimaryKey());
6467                                            }
6468    
6469                                            for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6470                                                    listener.onBeforeRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6471                                                            DLFolder.class.getName(), folderId);
6472                                            }
6473                                    }
6474                            }
6475    
6476                            _sqlUpdate.update(new Object[] { new Long(folderId) });
6477    
6478                            if ((listeners.length > 0) ||
6479                                            (dlFileEntryTypeListeners.length > 0)) {
6480                                    for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
6481                                            for (ModelListener<DLFolder> listener : listeners) {
6482                                                    listener.onAfterRemoveAssociation(folderId,
6483                                                            com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6484                                                            dlFileEntryType.getPrimaryKey());
6485                                            }
6486    
6487                                            for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6488                                                    listener.onAfterRemoveAssociation(dlFileEntryType.getPrimaryKey(),
6489                                                            DLFolder.class.getName(), folderId);
6490                                            }
6491                                    }
6492                            }
6493                    }
6494    
6495                    private SqlUpdate _sqlUpdate;
6496            }
6497    
6498            protected class RemoveDLFileEntryType {
6499                    protected RemoveDLFileEntryType() {
6500                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6501                                            "DELETE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?",
6502                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6503                    }
6504    
6505                    protected void remove(long folderId, long fileEntryTypeId)
6506                            throws SystemException {
6507                            if (containsDLFileEntryType.contains(folderId, fileEntryTypeId)) {
6508                                    ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
6509                                            dlFileEntryTypePersistence.getListeners();
6510    
6511                                    for (ModelListener<DLFolder> listener : listeners) {
6512                                            listener.onBeforeRemoveAssociation(folderId,
6513                                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6514                                                    fileEntryTypeId);
6515                                    }
6516    
6517                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6518                                            listener.onBeforeRemoveAssociation(fileEntryTypeId,
6519                                                    DLFolder.class.getName(), folderId);
6520                                    }
6521    
6522                                    _sqlUpdate.update(new Object[] {
6523                                                    new Long(folderId), new Long(fileEntryTypeId)
6524                                            });
6525    
6526                                    for (ModelListener<DLFolder> listener : listeners) {
6527                                            listener.onAfterRemoveAssociation(folderId,
6528                                                    com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
6529                                                    fileEntryTypeId);
6530                                    }
6531    
6532                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
6533                                            listener.onAfterRemoveAssociation(fileEntryTypeId,
6534                                                    DLFolder.class.getName(), folderId);
6535                                    }
6536                            }
6537                    }
6538    
6539                    private SqlUpdate _sqlUpdate;
6540            }
6541    
6542            private static final String _SQL_SELECT_DLFOLDER = "SELECT dlFolder FROM DLFolder dlFolder";
6543            private static final String _SQL_SELECT_DLFOLDER_WHERE = "SELECT dlFolder FROM DLFolder dlFolder WHERE ";
6544            private static final String _SQL_COUNT_DLFOLDER = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder";
6545            private static final String _SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(dlFolder) FROM DLFolder dlFolder WHERE ";
6546            private static final String _SQL_GETDLFILEENTRYTYPES = "SELECT {DLFileEntryType.*} FROM DLFileEntryType INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.fileEntryTypeId = DLFileEntryType.fileEntryTypeId) WHERE (DLFileEntryTypes_DLFolders.folderId = ?)";
6547            private static final String _SQL_GETDLFILEENTRYTYPESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ?";
6548            private static final String _SQL_CONTAINSDLFILEENTRYTYPE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE folderId = ? AND fileEntryTypeId = ?";
6549            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFolder.uuid IS NULL";
6550            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFolder.uuid = ?";
6551            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?)";
6552            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFolder.uuid IS NULL AND ";
6553            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFolder.uuid = ? AND ";
6554            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFolder.uuid IS NULL OR dlFolder.uuid = ?) AND ";
6555            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFolder.groupId = ?";
6556            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFolder.groupId = ?";
6557            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFolder.companyId = ?";
6558            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFolder.repositoryId = ?";
6559            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "dlFolder.groupId = ? AND ";
6560            private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ?";
6561            private static final String _FINDER_COLUMN_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6562            private static final String _FINDER_COLUMN_P_N_NAME_1 = "dlFolder.name IS NULL";
6563            private static final String _FINDER_COLUMN_P_N_NAME_2 = "dlFolder.name = ?";
6564            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6565            private static final String _FINDER_COLUMN_G_P_M_GROUPID_2 = "dlFolder.groupId = ? AND ";
6566            private static final String _FINDER_COLUMN_G_P_M_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6567            private static final String _FINDER_COLUMN_G_P_M_MOUNTPOINT_2 = "dlFolder.mountPoint = ?";
6568            private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "dlFolder.groupId = ? AND ";
6569            private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "dlFolder.parentFolderId = ? AND ";
6570            private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "dlFolder.name IS NULL";
6571            private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "dlFolder.name = ?";
6572            private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(dlFolder.name IS NULL OR dlFolder.name = ?)";
6573            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFolder.folderId";
6574            private static final String _FILTER_SQL_SELECT_DLFOLDER_WHERE = "SELECT DISTINCT {dlFolder.*} FROM DLFolder dlFolder WHERE ";
6575            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
6576                    "SELECT {DLFolder.*} FROM (SELECT DISTINCT dlFolder.folderId FROM DLFolder dlFolder WHERE ";
6577            private static final String _FILTER_SQL_SELECT_DLFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
6578                    ") TEMP_TABLE INNER JOIN DLFolder ON TEMP_TABLE.folderId = DLFolder.folderId";
6579            private static final String _FILTER_SQL_COUNT_DLFOLDER_WHERE = "SELECT COUNT(DISTINCT dlFolder.folderId) AS COUNT_VALUE FROM DLFolder dlFolder WHERE ";
6580            private static final String _FILTER_ENTITY_ALIAS = "dlFolder";
6581            private static final String _FILTER_ENTITY_TABLE = "DLFolder";
6582            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFolder.";
6583            private static final String _ORDER_BY_ENTITY_TABLE = "DLFolder.";
6584            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFolder exists with the primary key ";
6585            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFolder exists with the key {";
6586            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6587            private static Log _log = LogFactoryUtil.getLog(DLFolderPersistenceImpl.class);
6588            private static DLFolder _nullDLFolder = new DLFolderImpl() {
6589                            @Override
6590                            public Object clone() {
6591                                    return this;
6592                            }
6593    
6594                            @Override
6595                            public CacheModel<DLFolder> toCacheModel() {
6596                                    return _nullDLFolderCacheModel;
6597                            }
6598                    };
6599    
6600            private static CacheModel<DLFolder> _nullDLFolderCacheModel = new CacheModel<DLFolder>() {
6601                            public DLFolder toEntityModel() {
6602                                    return _nullDLFolder;
6603                            }
6604                    };
6605    }