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