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