001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
048    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
049    import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
050    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
051    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
052    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    
060    /**
061     * The persistence implementation for the document library file shortcut service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see DLFileShortcutPersistence
069     * @see DLFileShortcutUtil
070     * @generated
071     */
072    public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl<DLFileShortcut>
073            implements DLFileShortcutPersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. Always use {@link DLFileShortcutUtil} to access the document library file shortcut persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
085                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
086                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
087                            "findByUuid",
088                            new String[] {
089                                    String.class.getName(),
090                                    
091                            "java.lang.Integer", "java.lang.Integer",
092                                    "com.liferay.portal.kernel.util.OrderByComparator"
093                            });
094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
095                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
096                            DLFileShortcutImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
098                            new String[] { String.class.getName() },
099                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK);
100            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
101                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
103                            new String[] { String.class.getName() });
104            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
105                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
106                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_ENTITY,
107                            "fetchByUUID_G",
108                            new String[] { String.class.getName(), Long.class.getName() },
109                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
110                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
112                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
114                            new String[] { String.class.getName(), Long.class.getName() });
115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID =
116                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
117                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
118                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
119                            "findByToFileEntryId",
120                            new String[] {
121                                    Long.class.getName(),
122                                    
123                            "java.lang.Integer", "java.lang.Integer",
124                                    "com.liferay.portal.kernel.util.OrderByComparator"
125                            });
126            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID =
127                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
128                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
129                            DLFileShortcutImpl.class,
130                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByToFileEntryId",
131                            new String[] { Long.class.getName() },
132                            DLFileShortcutModelImpl.TOFILEENTRYID_COLUMN_BITMASK);
133            public static final FinderPath FINDER_PATH_COUNT_BY_TOFILEENTRYID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
134                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByToFileEntryId",
136                            new String[] { Long.class.getName() });
137            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
138                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
139                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
140                            "findByG_F",
141                            new String[] {
142                                    Long.class.getName(), Long.class.getName(),
143                                    
144                            "java.lang.Integer", "java.lang.Integer",
145                                    "com.liferay.portal.kernel.util.OrderByComparator"
146                            });
147            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
148                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
149                            DLFileShortcutImpl.class,
150                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
151                            new String[] { Long.class.getName(), Long.class.getName() },
152                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
153                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK);
154            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
155                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
156                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
157                            new String[] { Long.class.getName(), Long.class.getName() });
158            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
159                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
160                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
161                            "findByG_F_S",
162                            new String[] {
163                                    Long.class.getName(), Long.class.getName(),
164                                    Integer.class.getName(),
165                                    
166                            "java.lang.Integer", "java.lang.Integer",
167                                    "com.liferay.portal.kernel.util.OrderByComparator"
168                            });
169            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
170                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
171                            DLFileShortcutImpl.class,
172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S",
173                            new String[] {
174                                    Long.class.getName(), Long.class.getName(),
175                                    Integer.class.getName()
176                            },
177                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
178                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
179                            DLFileShortcutModelImpl.STATUS_COLUMN_BITMASK);
180            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
181                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
182                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
183                            new String[] {
184                                    Long.class.getName(), Long.class.getName(),
185                                    Integer.class.getName()
186                            });
187            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
188                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
189                            DLFileShortcutImpl.class,
190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
191            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
192                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
193                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
194                            "findAll", new String[0]);
195            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
196                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
197                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
198    
199            /**
200             * Caches the document library file shortcut in the entity cache if it is enabled.
201             *
202             * @param dlFileShortcut the document library file shortcut
203             */
204            public void cacheResult(DLFileShortcut dlFileShortcut) {
205                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
206                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
207                            dlFileShortcut);
208    
209                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
210                            new Object[] {
211                                    dlFileShortcut.getUuid(),
212                                    Long.valueOf(dlFileShortcut.getGroupId())
213                            }, dlFileShortcut);
214    
215                    dlFileShortcut.resetOriginalValues();
216            }
217    
218            /**
219             * Caches the document library file shortcuts in the entity cache if it is enabled.
220             *
221             * @param dlFileShortcuts the document library file shortcuts
222             */
223            public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
224                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
225                            if (EntityCacheUtil.getResult(
226                                                    DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
227                                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey()) == null) {
228                                    cacheResult(dlFileShortcut);
229                            }
230                            else {
231                                    dlFileShortcut.resetOriginalValues();
232                            }
233                    }
234            }
235    
236            /**
237             * Clears the cache for all document library file shortcuts.
238             *
239             * <p>
240             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
241             * </p>
242             */
243            @Override
244            public void clearCache() {
245                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
246                            CacheRegistryUtil.clear(DLFileShortcutImpl.class.getName());
247                    }
248    
249                    EntityCacheUtil.clearCache(DLFileShortcutImpl.class.getName());
250    
251                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
252                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
253                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
254            }
255    
256            /**
257             * Clears the cache for the document library file shortcut.
258             *
259             * <p>
260             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
261             * </p>
262             */
263            @Override
264            public void clearCache(DLFileShortcut dlFileShortcut) {
265                    EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
266                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
267    
268                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
269                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
270    
271                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
272                            new Object[] {
273                                    dlFileShortcut.getUuid(),
274                                    Long.valueOf(dlFileShortcut.getGroupId())
275                            });
276            }
277    
278            /**
279             * Creates a new document library file shortcut with the primary key. Does not add the document library file shortcut to the database.
280             *
281             * @param fileShortcutId the primary key for the new document library file shortcut
282             * @return the new document library file shortcut
283             */
284            public DLFileShortcut create(long fileShortcutId) {
285                    DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
286    
287                    dlFileShortcut.setNew(true);
288                    dlFileShortcut.setPrimaryKey(fileShortcutId);
289    
290                    String uuid = PortalUUIDUtil.generate();
291    
292                    dlFileShortcut.setUuid(uuid);
293    
294                    return dlFileShortcut;
295            }
296    
297            /**
298             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
299             *
300             * @param primaryKey the primary key of the document library file shortcut
301             * @return the document library file shortcut that was removed
302             * @throws com.liferay.portal.NoSuchModelException if a document library file shortcut with the primary key could not be found
303             * @throws SystemException if a system exception occurred
304             */
305            @Override
306            public DLFileShortcut remove(Serializable primaryKey)
307                    throws NoSuchModelException, SystemException {
308                    return remove(((Long)primaryKey).longValue());
309            }
310    
311            /**
312             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
313             *
314             * @param fileShortcutId the primary key of the document library file shortcut
315             * @return the document library file shortcut that was removed
316             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
317             * @throws SystemException if a system exception occurred
318             */
319            public DLFileShortcut remove(long fileShortcutId)
320                    throws NoSuchFileShortcutException, SystemException {
321                    Session session = null;
322    
323                    try {
324                            session = openSession();
325    
326                            DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
327                                            Long.valueOf(fileShortcutId));
328    
329                            if (dlFileShortcut == null) {
330                                    if (_log.isWarnEnabled()) {
331                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
332                                                    fileShortcutId);
333                                    }
334    
335                                    throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
336                                            fileShortcutId);
337                            }
338    
339                            return dlFileShortcutPersistence.remove(dlFileShortcut);
340                    }
341                    catch (NoSuchFileShortcutException nsee) {
342                            throw nsee;
343                    }
344                    catch (Exception e) {
345                            throw processException(e);
346                    }
347                    finally {
348                            closeSession(session);
349                    }
350            }
351    
352            /**
353             * Removes the document library file shortcut from the database. Also notifies the appropriate model listeners.
354             *
355             * @param dlFileShortcut the document library file shortcut
356             * @return the document library file shortcut that was removed
357             * @throws SystemException if a system exception occurred
358             */
359            @Override
360            public DLFileShortcut remove(DLFileShortcut dlFileShortcut)
361                    throws SystemException {
362                    return super.remove(dlFileShortcut);
363            }
364    
365            @Override
366            protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
367                    throws SystemException {
368                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
369    
370                    Session session = null;
371    
372                    try {
373                            session = openSession();
374    
375                            BatchSessionUtil.delete(session, dlFileShortcut);
376                    }
377                    catch (Exception e) {
378                            throw processException(e);
379                    }
380                    finally {
381                            closeSession(session);
382                    }
383    
384                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
385                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
386    
387                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
388    
389                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
390                            new Object[] {
391                                    dlFileShortcutModelImpl.getUuid(),
392                                    Long.valueOf(dlFileShortcutModelImpl.getGroupId())
393                            });
394    
395                    EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
396                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
397    
398                    return dlFileShortcut;
399            }
400    
401            @Override
402            public DLFileShortcut updateImpl(
403                    com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
404                    boolean merge) throws SystemException {
405                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
406    
407                    boolean isNew = dlFileShortcut.isNew();
408    
409                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
410    
411                    if (Validator.isNull(dlFileShortcut.getUuid())) {
412                            String uuid = PortalUUIDUtil.generate();
413    
414                            dlFileShortcut.setUuid(uuid);
415                    }
416    
417                    Session session = null;
418    
419                    try {
420                            session = openSession();
421    
422                            BatchSessionUtil.update(session, dlFileShortcut, merge);
423    
424                            dlFileShortcut.setNew(false);
425                    }
426                    catch (Exception e) {
427                            throw processException(e);
428                    }
429                    finally {
430                            closeSession(session);
431                    }
432    
433                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
434    
435                    if (isNew || !DLFileShortcutModelImpl.COLUMN_BITMASK_ENABLED) {
436                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
437                    }
438    
439                    else {
440                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
441                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
442                                    Object[] args = new Object[] {
443                                                    dlFileShortcutModelImpl.getOriginalUuid()
444                                            };
445    
446                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
448                                            args);
449    
450                                    args = new Object[] { dlFileShortcutModelImpl.getUuid() };
451    
452                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
453                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
454                                            args);
455                            }
456    
457                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
458                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID.getColumnBitmask()) != 0) {
459                                    Object[] args = new Object[] {
460                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalToFileEntryId())
461                                            };
462    
463                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
464                                            args);
465                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
466                                            args);
467    
468                                    args = new Object[] {
469                                                    Long.valueOf(dlFileShortcutModelImpl.getToFileEntryId())
470                                            };
471    
472                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
473                                            args);
474                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
475                                            args);
476                            }
477    
478                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
479                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
480                                    Object[] args = new Object[] {
481                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId()),
482                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalFolderId())
483                                            };
484    
485                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
486                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
487                                            args);
488    
489                                    args = new Object[] {
490                                                    Long.valueOf(dlFileShortcutModelImpl.getGroupId()),
491                                                    Long.valueOf(dlFileShortcutModelImpl.getFolderId())
492                                            };
493    
494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
496                                            args);
497                            }
498    
499                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
500                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
501                                    Object[] args = new Object[] {
502                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId()),
503                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalFolderId()),
504                                                    Integer.valueOf(dlFileShortcutModelImpl.getOriginalStatus())
505                                            };
506    
507                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
508                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
509                                            args);
510    
511                                    args = new Object[] {
512                                                    Long.valueOf(dlFileShortcutModelImpl.getGroupId()),
513                                                    Long.valueOf(dlFileShortcutModelImpl.getFolderId()),
514                                                    Integer.valueOf(dlFileShortcutModelImpl.getStatus())
515                                            };
516    
517                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
518                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
519                                            args);
520                            }
521                    }
522    
523                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
524                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
525                            dlFileShortcut);
526    
527                    if (isNew) {
528                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
529                                    new Object[] {
530                                            dlFileShortcut.getUuid(),
531                                            Long.valueOf(dlFileShortcut.getGroupId())
532                                    }, dlFileShortcut);
533                    }
534                    else {
535                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
536                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
537                                    Object[] args = new Object[] {
538                                                    dlFileShortcutModelImpl.getOriginalUuid(),
539                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId())
540                                            };
541    
542                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
543                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
544    
545                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
546                                            new Object[] {
547                                                    dlFileShortcut.getUuid(),
548                                                    Long.valueOf(dlFileShortcut.getGroupId())
549                                            }, dlFileShortcut);
550                            }
551                    }
552    
553                    return dlFileShortcut;
554            }
555    
556            protected DLFileShortcut toUnwrappedModel(DLFileShortcut dlFileShortcut) {
557                    if (dlFileShortcut instanceof DLFileShortcutImpl) {
558                            return dlFileShortcut;
559                    }
560    
561                    DLFileShortcutImpl dlFileShortcutImpl = new DLFileShortcutImpl();
562    
563                    dlFileShortcutImpl.setNew(dlFileShortcut.isNew());
564                    dlFileShortcutImpl.setPrimaryKey(dlFileShortcut.getPrimaryKey());
565    
566                    dlFileShortcutImpl.setUuid(dlFileShortcut.getUuid());
567                    dlFileShortcutImpl.setFileShortcutId(dlFileShortcut.getFileShortcutId());
568                    dlFileShortcutImpl.setGroupId(dlFileShortcut.getGroupId());
569                    dlFileShortcutImpl.setCompanyId(dlFileShortcut.getCompanyId());
570                    dlFileShortcutImpl.setUserId(dlFileShortcut.getUserId());
571                    dlFileShortcutImpl.setUserName(dlFileShortcut.getUserName());
572                    dlFileShortcutImpl.setCreateDate(dlFileShortcut.getCreateDate());
573                    dlFileShortcutImpl.setModifiedDate(dlFileShortcut.getModifiedDate());
574                    dlFileShortcutImpl.setRepositoryId(dlFileShortcut.getRepositoryId());
575                    dlFileShortcutImpl.setFolderId(dlFileShortcut.getFolderId());
576                    dlFileShortcutImpl.setToFileEntryId(dlFileShortcut.getToFileEntryId());
577                    dlFileShortcutImpl.setStatus(dlFileShortcut.getStatus());
578                    dlFileShortcutImpl.setStatusByUserId(dlFileShortcut.getStatusByUserId());
579                    dlFileShortcutImpl.setStatusByUserName(dlFileShortcut.getStatusByUserName());
580                    dlFileShortcutImpl.setStatusDate(dlFileShortcut.getStatusDate());
581    
582                    return dlFileShortcutImpl;
583            }
584    
585            /**
586             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
587             *
588             * @param primaryKey the primary key of the document library file shortcut
589             * @return the document library file shortcut
590             * @throws com.liferay.portal.NoSuchModelException if a document library file shortcut with the primary key could not be found
591             * @throws SystemException if a system exception occurred
592             */
593            @Override
594            public DLFileShortcut findByPrimaryKey(Serializable primaryKey)
595                    throws NoSuchModelException, SystemException {
596                    return findByPrimaryKey(((Long)primaryKey).longValue());
597            }
598    
599            /**
600             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
601             *
602             * @param fileShortcutId the primary key of the document library file shortcut
603             * @return the document library file shortcut
604             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
605             * @throws SystemException if a system exception occurred
606             */
607            public DLFileShortcut findByPrimaryKey(long fileShortcutId)
608                    throws NoSuchFileShortcutException, SystemException {
609                    DLFileShortcut dlFileShortcut = fetchByPrimaryKey(fileShortcutId);
610    
611                    if (dlFileShortcut == null) {
612                            if (_log.isWarnEnabled()) {
613                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileShortcutId);
614                            }
615    
616                            throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
617                                    fileShortcutId);
618                    }
619    
620                    return dlFileShortcut;
621            }
622    
623            /**
624             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
625             *
626             * @param primaryKey the primary key of the document library file shortcut
627             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
628             * @throws SystemException if a system exception occurred
629             */
630            @Override
631            public DLFileShortcut fetchByPrimaryKey(Serializable primaryKey)
632                    throws SystemException {
633                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
634            }
635    
636            /**
637             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
638             *
639             * @param fileShortcutId the primary key of the document library file shortcut
640             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
641             * @throws SystemException if a system exception occurred
642             */
643            public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
644                    throws SystemException {
645                    DLFileShortcut dlFileShortcut = (DLFileShortcut)EntityCacheUtil.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
646                                    DLFileShortcutImpl.class, fileShortcutId);
647    
648                    if (dlFileShortcut == _nullDLFileShortcut) {
649                            return null;
650                    }
651    
652                    if (dlFileShortcut == null) {
653                            Session session = null;
654    
655                            boolean hasException = false;
656    
657                            try {
658                                    session = openSession();
659    
660                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
661                                                    Long.valueOf(fileShortcutId));
662                            }
663                            catch (Exception e) {
664                                    hasException = true;
665    
666                                    throw processException(e);
667                            }
668                            finally {
669                                    if (dlFileShortcut != null) {
670                                            cacheResult(dlFileShortcut);
671                                    }
672                                    else if (!hasException) {
673                                            EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
674                                                    DLFileShortcutImpl.class, fileShortcutId,
675                                                    _nullDLFileShortcut);
676                                    }
677    
678                                    closeSession(session);
679                            }
680                    }
681    
682                    return dlFileShortcut;
683            }
684    
685            /**
686             * Returns all the document library file shortcuts where uuid = &#63;.
687             *
688             * @param uuid the uuid
689             * @return the matching document library file shortcuts
690             * @throws SystemException if a system exception occurred
691             */
692            public List<DLFileShortcut> findByUuid(String uuid)
693                    throws SystemException {
694                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
695            }
696    
697            /**
698             * Returns a range of all the document library file shortcuts where uuid = &#63;.
699             *
700             * <p>
701             * 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.
702             * </p>
703             *
704             * @param uuid the uuid
705             * @param start the lower bound of the range of document library file shortcuts
706             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
707             * @return the range of matching document library file shortcuts
708             * @throws SystemException if a system exception occurred
709             */
710            public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
711                    throws SystemException {
712                    return findByUuid(uuid, start, end, null);
713            }
714    
715            /**
716             * Returns an ordered range of all the document library file shortcuts where uuid = &#63;.
717             *
718             * <p>
719             * 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.
720             * </p>
721             *
722             * @param uuid the uuid
723             * @param start the lower bound of the range of document library file shortcuts
724             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
725             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
726             * @return the ordered range of matching document library file shortcuts
727             * @throws SystemException if a system exception occurred
728             */
729            public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
730                    OrderByComparator orderByComparator) throws SystemException {
731                    FinderPath finderPath = null;
732                    Object[] finderArgs = null;
733    
734                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
735                                    (orderByComparator == null)) {
736                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
737                            finderArgs = new Object[] { uuid };
738                    }
739                    else {
740                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
741                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
742                    }
743    
744                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
745                                    finderArgs, this);
746    
747                    if (list == null) {
748                            StringBundler query = null;
749    
750                            if (orderByComparator != null) {
751                                    query = new StringBundler(3 +
752                                                    (orderByComparator.getOrderByFields().length * 3));
753                            }
754                            else {
755                                    query = new StringBundler(2);
756                            }
757    
758                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
759    
760                            if (uuid == null) {
761                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
762                            }
763                            else {
764                                    if (uuid.equals(StringPool.BLANK)) {
765                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
766                                    }
767                                    else {
768                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
769                                    }
770                            }
771    
772                            if (orderByComparator != null) {
773                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
774                                            orderByComparator);
775                            }
776    
777                            String sql = query.toString();
778    
779                            Session session = null;
780    
781                            try {
782                                    session = openSession();
783    
784                                    Query q = session.createQuery(sql);
785    
786                                    QueryPos qPos = QueryPos.getInstance(q);
787    
788                                    if (uuid != null) {
789                                            qPos.add(uuid);
790                                    }
791    
792                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
793                                                    start, end);
794                            }
795                            catch (Exception e) {
796                                    throw processException(e);
797                            }
798                            finally {
799                                    if (list == null) {
800                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
801                                    }
802                                    else {
803                                            cacheResult(list);
804    
805                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
806                                    }
807    
808                                    closeSession(session);
809                            }
810                    }
811    
812                    return list;
813            }
814    
815            /**
816             * Returns the first document library file shortcut in the ordered set where uuid = &#63;.
817             *
818             * <p>
819             * 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.
820             * </p>
821             *
822             * @param uuid the uuid
823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
824             * @return the first matching document library file shortcut
825             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
826             * @throws SystemException if a system exception occurred
827             */
828            public DLFileShortcut findByUuid_First(String uuid,
829                    OrderByComparator orderByComparator)
830                    throws NoSuchFileShortcutException, SystemException {
831                    List<DLFileShortcut> list = findByUuid(uuid, 0, 1, orderByComparator);
832    
833                    if (list.isEmpty()) {
834                            StringBundler msg = new StringBundler(4);
835    
836                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
837    
838                            msg.append("uuid=");
839                            msg.append(uuid);
840    
841                            msg.append(StringPool.CLOSE_CURLY_BRACE);
842    
843                            throw new NoSuchFileShortcutException(msg.toString());
844                    }
845                    else {
846                            return list.get(0);
847                    }
848            }
849    
850            /**
851             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
852             *
853             * <p>
854             * 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.
855             * </p>
856             *
857             * @param uuid the uuid
858             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
859             * @return the last matching document library file shortcut
860             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
861             * @throws SystemException if a system exception occurred
862             */
863            public DLFileShortcut findByUuid_Last(String uuid,
864                    OrderByComparator orderByComparator)
865                    throws NoSuchFileShortcutException, SystemException {
866                    int count = countByUuid(uuid);
867    
868                    List<DLFileShortcut> list = findByUuid(uuid, count - 1, count,
869                                    orderByComparator);
870    
871                    if (list.isEmpty()) {
872                            StringBundler msg = new StringBundler(4);
873    
874                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
875    
876                            msg.append("uuid=");
877                            msg.append(uuid);
878    
879                            msg.append(StringPool.CLOSE_CURLY_BRACE);
880    
881                            throw new NoSuchFileShortcutException(msg.toString());
882                    }
883                    else {
884                            return list.get(0);
885                    }
886            }
887    
888            /**
889             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where uuid = &#63;.
890             *
891             * <p>
892             * 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.
893             * </p>
894             *
895             * @param fileShortcutId the primary key of the current document library file shortcut
896             * @param uuid the uuid
897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
898             * @return the previous, current, and next document library file shortcut
899             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
900             * @throws SystemException if a system exception occurred
901             */
902            public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
903                    String uuid, OrderByComparator orderByComparator)
904                    throws NoSuchFileShortcutException, SystemException {
905                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
906    
907                    Session session = null;
908    
909                    try {
910                            session = openSession();
911    
912                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
913    
914                            array[0] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
915                                            orderByComparator, true);
916    
917                            array[1] = dlFileShortcut;
918    
919                            array[2] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
920                                            orderByComparator, false);
921    
922                            return array;
923                    }
924                    catch (Exception e) {
925                            throw processException(e);
926                    }
927                    finally {
928                            closeSession(session);
929                    }
930            }
931    
932            protected DLFileShortcut getByUuid_PrevAndNext(Session session,
933                    DLFileShortcut dlFileShortcut, String uuid,
934                    OrderByComparator orderByComparator, boolean previous) {
935                    StringBundler query = null;
936    
937                    if (orderByComparator != null) {
938                            query = new StringBundler(6 +
939                                            (orderByComparator.getOrderByFields().length * 6));
940                    }
941                    else {
942                            query = new StringBundler(3);
943                    }
944    
945                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
946    
947                    if (uuid == null) {
948                            query.append(_FINDER_COLUMN_UUID_UUID_1);
949                    }
950                    else {
951                            if (uuid.equals(StringPool.BLANK)) {
952                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
953                            }
954                            else {
955                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
956                            }
957                    }
958    
959                    if (orderByComparator != null) {
960                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
961    
962                            if (orderByConditionFields.length > 0) {
963                                    query.append(WHERE_AND);
964                            }
965    
966                            for (int i = 0; i < orderByConditionFields.length; i++) {
967                                    query.append(_ORDER_BY_ENTITY_ALIAS);
968                                    query.append(orderByConditionFields[i]);
969    
970                                    if ((i + 1) < orderByConditionFields.length) {
971                                            if (orderByComparator.isAscending() ^ previous) {
972                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
973                                            }
974                                            else {
975                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
976                                            }
977                                    }
978                                    else {
979                                            if (orderByComparator.isAscending() ^ previous) {
980                                                    query.append(WHERE_GREATER_THAN);
981                                            }
982                                            else {
983                                                    query.append(WHERE_LESSER_THAN);
984                                            }
985                                    }
986                            }
987    
988                            query.append(ORDER_BY_CLAUSE);
989    
990                            String[] orderByFields = orderByComparator.getOrderByFields();
991    
992                            for (int i = 0; i < orderByFields.length; i++) {
993                                    query.append(_ORDER_BY_ENTITY_ALIAS);
994                                    query.append(orderByFields[i]);
995    
996                                    if ((i + 1) < orderByFields.length) {
997                                            if (orderByComparator.isAscending() ^ previous) {
998                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
999                                            }
1000                                            else {
1001                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1002                                            }
1003                                    }
1004                                    else {
1005                                            if (orderByComparator.isAscending() ^ previous) {
1006                                                    query.append(ORDER_BY_ASC);
1007                                            }
1008                                            else {
1009                                                    query.append(ORDER_BY_DESC);
1010                                            }
1011                                    }
1012                            }
1013                    }
1014    
1015                    String sql = query.toString();
1016    
1017                    Query q = session.createQuery(sql);
1018    
1019                    q.setFirstResult(0);
1020                    q.setMaxResults(2);
1021    
1022                    QueryPos qPos = QueryPos.getInstance(q);
1023    
1024                    if (uuid != null) {
1025                            qPos.add(uuid);
1026                    }
1027    
1028                    if (orderByComparator != null) {
1029                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1030    
1031                            for (Object value : values) {
1032                                    qPos.add(value);
1033                            }
1034                    }
1035    
1036                    List<DLFileShortcut> list = q.list();
1037    
1038                    if (list.size() == 2) {
1039                            return list.get(1);
1040                    }
1041                    else {
1042                            return null;
1043                    }
1044            }
1045    
1046            /**
1047             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
1048             *
1049             * @param uuid the uuid
1050             * @param groupId the group ID
1051             * @return the matching document library file shortcut
1052             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1053             * @throws SystemException if a system exception occurred
1054             */
1055            public DLFileShortcut findByUUID_G(String uuid, long groupId)
1056                    throws NoSuchFileShortcutException, SystemException {
1057                    DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
1058    
1059                    if (dlFileShortcut == null) {
1060                            StringBundler msg = new StringBundler(6);
1061    
1062                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1063    
1064                            msg.append("uuid=");
1065                            msg.append(uuid);
1066    
1067                            msg.append(", groupId=");
1068                            msg.append(groupId);
1069    
1070                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1071    
1072                            if (_log.isWarnEnabled()) {
1073                                    _log.warn(msg.toString());
1074                            }
1075    
1076                            throw new NoSuchFileShortcutException(msg.toString());
1077                    }
1078    
1079                    return dlFileShortcut;
1080            }
1081    
1082            /**
1083             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1084             *
1085             * @param uuid the uuid
1086             * @param groupId the group ID
1087             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1088             * @throws SystemException if a system exception occurred
1089             */
1090            public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
1091                    throws SystemException {
1092                    return fetchByUUID_G(uuid, groupId, true);
1093            }
1094    
1095            /**
1096             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1097             *
1098             * @param uuid the uuid
1099             * @param groupId the group ID
1100             * @param retrieveFromCache whether to use the finder cache
1101             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1102             * @throws SystemException if a system exception occurred
1103             */
1104            public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
1105                    boolean retrieveFromCache) throws SystemException {
1106                    Object[] finderArgs = new Object[] { uuid, groupId };
1107    
1108                    Object result = null;
1109    
1110                    if (retrieveFromCache) {
1111                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1112                                            finderArgs, this);
1113                    }
1114    
1115                    if (result == null) {
1116                            StringBundler query = new StringBundler(3);
1117    
1118                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1119    
1120                            if (uuid == null) {
1121                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1122                            }
1123                            else {
1124                                    if (uuid.equals(StringPool.BLANK)) {
1125                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1126                                    }
1127                                    else {
1128                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1129                                    }
1130                            }
1131    
1132                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1133    
1134                            String sql = query.toString();
1135    
1136                            Session session = null;
1137    
1138                            try {
1139                                    session = openSession();
1140    
1141                                    Query q = session.createQuery(sql);
1142    
1143                                    QueryPos qPos = QueryPos.getInstance(q);
1144    
1145                                    if (uuid != null) {
1146                                            qPos.add(uuid);
1147                                    }
1148    
1149                                    qPos.add(groupId);
1150    
1151                                    List<DLFileShortcut> list = q.list();
1152    
1153                                    result = list;
1154    
1155                                    DLFileShortcut dlFileShortcut = null;
1156    
1157                                    if (list.isEmpty()) {
1158                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1159                                                    finderArgs, list);
1160                                    }
1161                                    else {
1162                                            dlFileShortcut = list.get(0);
1163    
1164                                            cacheResult(dlFileShortcut);
1165    
1166                                            if ((dlFileShortcut.getUuid() == null) ||
1167                                                            !dlFileShortcut.getUuid().equals(uuid) ||
1168                                                            (dlFileShortcut.getGroupId() != groupId)) {
1169                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1170                                                            finderArgs, dlFileShortcut);
1171                                            }
1172                                    }
1173    
1174                                    return dlFileShortcut;
1175                            }
1176                            catch (Exception e) {
1177                                    throw processException(e);
1178                            }
1179                            finally {
1180                                    if (result == null) {
1181                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1182                                                    finderArgs);
1183                                    }
1184    
1185                                    closeSession(session);
1186                            }
1187                    }
1188                    else {
1189                            if (result instanceof List<?>) {
1190                                    return null;
1191                            }
1192                            else {
1193                                    return (DLFileShortcut)result;
1194                            }
1195                    }
1196            }
1197    
1198            /**
1199             * Returns all the document library file shortcuts where toFileEntryId = &#63;.
1200             *
1201             * @param toFileEntryId the to file entry ID
1202             * @return the matching document library file shortcuts
1203             * @throws SystemException if a system exception occurred
1204             */
1205            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId)
1206                    throws SystemException {
1207                    return findByToFileEntryId(toFileEntryId, QueryUtil.ALL_POS,
1208                            QueryUtil.ALL_POS, null);
1209            }
1210    
1211            /**
1212             * Returns a range of all the document library file shortcuts where toFileEntryId = &#63;.
1213             *
1214             * <p>
1215             * 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.
1216             * </p>
1217             *
1218             * @param toFileEntryId the to file entry ID
1219             * @param start the lower bound of the range of document library file shortcuts
1220             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1221             * @return the range of matching document library file shortcuts
1222             * @throws SystemException if a system exception occurred
1223             */
1224            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1225                    int start, int end) throws SystemException {
1226                    return findByToFileEntryId(toFileEntryId, start, end, null);
1227            }
1228    
1229            /**
1230             * Returns an ordered range of all the document library file shortcuts where toFileEntryId = &#63;.
1231             *
1232             * <p>
1233             * 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.
1234             * </p>
1235             *
1236             * @param toFileEntryId the to file entry ID
1237             * @param start the lower bound of the range of document library file shortcuts
1238             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1239             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1240             * @return the ordered range of matching document library file shortcuts
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1244                    int start, int end, OrderByComparator orderByComparator)
1245                    throws SystemException {
1246                    FinderPath finderPath = null;
1247                    Object[] finderArgs = null;
1248    
1249                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1250                                    (orderByComparator == null)) {
1251                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID;
1252                            finderArgs = new Object[] { toFileEntryId };
1253                    }
1254                    else {
1255                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID;
1256                            finderArgs = new Object[] {
1257                                            toFileEntryId,
1258                                            
1259                                            start, end, orderByComparator
1260                                    };
1261                    }
1262    
1263                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
1264                                    finderArgs, this);
1265    
1266                    if (list == null) {
1267                            StringBundler query = null;
1268    
1269                            if (orderByComparator != null) {
1270                                    query = new StringBundler(3 +
1271                                                    (orderByComparator.getOrderByFields().length * 3));
1272                            }
1273                            else {
1274                                    query = new StringBundler(2);
1275                            }
1276    
1277                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1278    
1279                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1280    
1281                            if (orderByComparator != null) {
1282                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1283                                            orderByComparator);
1284                            }
1285    
1286                            String sql = query.toString();
1287    
1288                            Session session = null;
1289    
1290                            try {
1291                                    session = openSession();
1292    
1293                                    Query q = session.createQuery(sql);
1294    
1295                                    QueryPos qPos = QueryPos.getInstance(q);
1296    
1297                                    qPos.add(toFileEntryId);
1298    
1299                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1300                                                    start, end);
1301                            }
1302                            catch (Exception e) {
1303                                    throw processException(e);
1304                            }
1305                            finally {
1306                                    if (list == null) {
1307                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1308                                    }
1309                                    else {
1310                                            cacheResult(list);
1311    
1312                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1313                                    }
1314    
1315                                    closeSession(session);
1316                            }
1317                    }
1318    
1319                    return list;
1320            }
1321    
1322            /**
1323             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
1324             *
1325             * <p>
1326             * 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.
1327             * </p>
1328             *
1329             * @param toFileEntryId the to file entry ID
1330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1331             * @return the first matching document library file shortcut
1332             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1333             * @throws SystemException if a system exception occurred
1334             */
1335            public DLFileShortcut findByToFileEntryId_First(long toFileEntryId,
1336                    OrderByComparator orderByComparator)
1337                    throws NoSuchFileShortcutException, SystemException {
1338                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId, 0, 1,
1339                                    orderByComparator);
1340    
1341                    if (list.isEmpty()) {
1342                            StringBundler msg = new StringBundler(4);
1343    
1344                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1345    
1346                            msg.append("toFileEntryId=");
1347                            msg.append(toFileEntryId);
1348    
1349                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1350    
1351                            throw new NoSuchFileShortcutException(msg.toString());
1352                    }
1353                    else {
1354                            return list.get(0);
1355                    }
1356            }
1357    
1358            /**
1359             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
1360             *
1361             * <p>
1362             * 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.
1363             * </p>
1364             *
1365             * @param toFileEntryId the to file entry ID
1366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1367             * @return the last matching document library file shortcut
1368             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1369             * @throws SystemException if a system exception occurred
1370             */
1371            public DLFileShortcut findByToFileEntryId_Last(long toFileEntryId,
1372                    OrderByComparator orderByComparator)
1373                    throws NoSuchFileShortcutException, SystemException {
1374                    int count = countByToFileEntryId(toFileEntryId);
1375    
1376                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId,
1377                                    count - 1, count, orderByComparator);
1378    
1379                    if (list.isEmpty()) {
1380                            StringBundler msg = new StringBundler(4);
1381    
1382                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1383    
1384                            msg.append("toFileEntryId=");
1385                            msg.append(toFileEntryId);
1386    
1387                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1388    
1389                            throw new NoSuchFileShortcutException(msg.toString());
1390                    }
1391                    else {
1392                            return list.get(0);
1393                    }
1394            }
1395    
1396            /**
1397             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where toFileEntryId = &#63;.
1398             *
1399             * <p>
1400             * 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.
1401             * </p>
1402             *
1403             * @param fileShortcutId the primary key of the current document library file shortcut
1404             * @param toFileEntryId the to file entry ID
1405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1406             * @return the previous, current, and next document library file shortcut
1407             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1408             * @throws SystemException if a system exception occurred
1409             */
1410            public DLFileShortcut[] findByToFileEntryId_PrevAndNext(
1411                    long fileShortcutId, long toFileEntryId,
1412                    OrderByComparator orderByComparator)
1413                    throws NoSuchFileShortcutException, SystemException {
1414                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1415    
1416                    Session session = null;
1417    
1418                    try {
1419                            session = openSession();
1420    
1421                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1422    
1423                            array[0] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1424                                            toFileEntryId, orderByComparator, true);
1425    
1426                            array[1] = dlFileShortcut;
1427    
1428                            array[2] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1429                                            toFileEntryId, orderByComparator, false);
1430    
1431                            return array;
1432                    }
1433                    catch (Exception e) {
1434                            throw processException(e);
1435                    }
1436                    finally {
1437                            closeSession(session);
1438                    }
1439            }
1440    
1441            protected DLFileShortcut getByToFileEntryId_PrevAndNext(Session session,
1442                    DLFileShortcut dlFileShortcut, long toFileEntryId,
1443                    OrderByComparator orderByComparator, boolean previous) {
1444                    StringBundler query = null;
1445    
1446                    if (orderByComparator != null) {
1447                            query = new StringBundler(6 +
1448                                            (orderByComparator.getOrderByFields().length * 6));
1449                    }
1450                    else {
1451                            query = new StringBundler(3);
1452                    }
1453    
1454                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1455    
1456                    query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1457    
1458                    if (orderByComparator != null) {
1459                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1460    
1461                            if (orderByConditionFields.length > 0) {
1462                                    query.append(WHERE_AND);
1463                            }
1464    
1465                            for (int i = 0; i < orderByConditionFields.length; i++) {
1466                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1467                                    query.append(orderByConditionFields[i]);
1468    
1469                                    if ((i + 1) < orderByConditionFields.length) {
1470                                            if (orderByComparator.isAscending() ^ previous) {
1471                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1472                                            }
1473                                            else {
1474                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1475                                            }
1476                                    }
1477                                    else {
1478                                            if (orderByComparator.isAscending() ^ previous) {
1479                                                    query.append(WHERE_GREATER_THAN);
1480                                            }
1481                                            else {
1482                                                    query.append(WHERE_LESSER_THAN);
1483                                            }
1484                                    }
1485                            }
1486    
1487                            query.append(ORDER_BY_CLAUSE);
1488    
1489                            String[] orderByFields = orderByComparator.getOrderByFields();
1490    
1491                            for (int i = 0; i < orderByFields.length; i++) {
1492                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1493                                    query.append(orderByFields[i]);
1494    
1495                                    if ((i + 1) < orderByFields.length) {
1496                                            if (orderByComparator.isAscending() ^ previous) {
1497                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1498                                            }
1499                                            else {
1500                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1501                                            }
1502                                    }
1503                                    else {
1504                                            if (orderByComparator.isAscending() ^ previous) {
1505                                                    query.append(ORDER_BY_ASC);
1506                                            }
1507                                            else {
1508                                                    query.append(ORDER_BY_DESC);
1509                                            }
1510                                    }
1511                            }
1512                    }
1513    
1514                    String sql = query.toString();
1515    
1516                    Query q = session.createQuery(sql);
1517    
1518                    q.setFirstResult(0);
1519                    q.setMaxResults(2);
1520    
1521                    QueryPos qPos = QueryPos.getInstance(q);
1522    
1523                    qPos.add(toFileEntryId);
1524    
1525                    if (orderByComparator != null) {
1526                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1527    
1528                            for (Object value : values) {
1529                                    qPos.add(value);
1530                            }
1531                    }
1532    
1533                    List<DLFileShortcut> list = q.list();
1534    
1535                    if (list.size() == 2) {
1536                            return list.get(1);
1537                    }
1538                    else {
1539                            return null;
1540                    }
1541            }
1542    
1543            /**
1544             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1545             *
1546             * @param groupId the group ID
1547             * @param folderId the folder ID
1548             * @return the matching document library file shortcuts
1549             * @throws SystemException if a system exception occurred
1550             */
1551            public List<DLFileShortcut> findByG_F(long groupId, long folderId)
1552                    throws SystemException {
1553                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
1554                            QueryUtil.ALL_POS, null);
1555            }
1556    
1557            /**
1558             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1559             *
1560             * <p>
1561             * 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.
1562             * </p>
1563             *
1564             * @param groupId the group ID
1565             * @param folderId the folder ID
1566             * @param start the lower bound of the range of document library file shortcuts
1567             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1568             * @return the range of matching document library file shortcuts
1569             * @throws SystemException if a system exception occurred
1570             */
1571            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1572                    int start, int end) throws SystemException {
1573                    return findByG_F(groupId, folderId, start, end, null);
1574            }
1575    
1576            /**
1577             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1578             *
1579             * <p>
1580             * 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.
1581             * </p>
1582             *
1583             * @param groupId the group ID
1584             * @param folderId the folder ID
1585             * @param start the lower bound of the range of document library file shortcuts
1586             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1587             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1588             * @return the ordered range of matching document library file shortcuts
1589             * @throws SystemException if a system exception occurred
1590             */
1591            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1592                    int start, int end, OrderByComparator orderByComparator)
1593                    throws SystemException {
1594                    FinderPath finderPath = null;
1595                    Object[] finderArgs = null;
1596    
1597                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1598                                    (orderByComparator == null)) {
1599                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
1600                            finderArgs = new Object[] { groupId, folderId };
1601                    }
1602                    else {
1603                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
1604                            finderArgs = new Object[] {
1605                                            groupId, folderId,
1606                                            
1607                                            start, end, orderByComparator
1608                                    };
1609                    }
1610    
1611                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
1612                                    finderArgs, this);
1613    
1614                    if (list == null) {
1615                            StringBundler query = null;
1616    
1617                            if (orderByComparator != null) {
1618                                    query = new StringBundler(4 +
1619                                                    (orderByComparator.getOrderByFields().length * 3));
1620                            }
1621                            else {
1622                                    query = new StringBundler(3);
1623                            }
1624    
1625                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1626    
1627                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1628    
1629                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1630    
1631                            if (orderByComparator != null) {
1632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1633                                            orderByComparator);
1634                            }
1635    
1636                            String sql = query.toString();
1637    
1638                            Session session = null;
1639    
1640                            try {
1641                                    session = openSession();
1642    
1643                                    Query q = session.createQuery(sql);
1644    
1645                                    QueryPos qPos = QueryPos.getInstance(q);
1646    
1647                                    qPos.add(groupId);
1648    
1649                                    qPos.add(folderId);
1650    
1651                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1652                                                    start, end);
1653                            }
1654                            catch (Exception e) {
1655                                    throw processException(e);
1656                            }
1657                            finally {
1658                                    if (list == null) {
1659                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1660                                    }
1661                                    else {
1662                                            cacheResult(list);
1663    
1664                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1665                                    }
1666    
1667                                    closeSession(session);
1668                            }
1669                    }
1670    
1671                    return list;
1672            }
1673    
1674            /**
1675             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
1676             *
1677             * <p>
1678             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1679             * </p>
1680             *
1681             * @param groupId the group ID
1682             * @param folderId the folder ID
1683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1684             * @return the first matching document library file shortcut
1685             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1686             * @throws SystemException if a system exception occurred
1687             */
1688            public DLFileShortcut findByG_F_First(long groupId, long folderId,
1689                    OrderByComparator orderByComparator)
1690                    throws NoSuchFileShortcutException, SystemException {
1691                    List<DLFileShortcut> list = findByG_F(groupId, folderId, 0, 1,
1692                                    orderByComparator);
1693    
1694                    if (list.isEmpty()) {
1695                            StringBundler msg = new StringBundler(6);
1696    
1697                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1698    
1699                            msg.append("groupId=");
1700                            msg.append(groupId);
1701    
1702                            msg.append(", folderId=");
1703                            msg.append(folderId);
1704    
1705                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1706    
1707                            throw new NoSuchFileShortcutException(msg.toString());
1708                    }
1709                    else {
1710                            return list.get(0);
1711                    }
1712            }
1713    
1714            /**
1715             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
1716             *
1717             * <p>
1718             * 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.
1719             * </p>
1720             *
1721             * @param groupId the group ID
1722             * @param folderId the folder ID
1723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1724             * @return the last matching document library file shortcut
1725             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1726             * @throws SystemException if a system exception occurred
1727             */
1728            public DLFileShortcut findByG_F_Last(long groupId, long folderId,
1729                    OrderByComparator orderByComparator)
1730                    throws NoSuchFileShortcutException, SystemException {
1731                    int count = countByG_F(groupId, folderId);
1732    
1733                    List<DLFileShortcut> list = findByG_F(groupId, folderId, count - 1,
1734                                    count, orderByComparator);
1735    
1736                    if (list.isEmpty()) {
1737                            StringBundler msg = new StringBundler(6);
1738    
1739                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1740    
1741                            msg.append("groupId=");
1742                            msg.append(groupId);
1743    
1744                            msg.append(", folderId=");
1745                            msg.append(folderId);
1746    
1747                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1748    
1749                            throw new NoSuchFileShortcutException(msg.toString());
1750                    }
1751                    else {
1752                            return list.get(0);
1753                    }
1754            }
1755    
1756            /**
1757             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
1758             *
1759             * <p>
1760             * 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.
1761             * </p>
1762             *
1763             * @param fileShortcutId the primary key of the current document library file shortcut
1764             * @param groupId the group ID
1765             * @param folderId the folder ID
1766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1767             * @return the previous, current, and next document library file shortcut
1768             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1769             * @throws SystemException if a system exception occurred
1770             */
1771            public DLFileShortcut[] findByG_F_PrevAndNext(long fileShortcutId,
1772                    long groupId, long folderId, OrderByComparator orderByComparator)
1773                    throws NoSuchFileShortcutException, SystemException {
1774                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1775    
1776                    Session session = null;
1777    
1778                    try {
1779                            session = openSession();
1780    
1781                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1782    
1783                            array[0] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1784                                            folderId, orderByComparator, true);
1785    
1786                            array[1] = dlFileShortcut;
1787    
1788                            array[2] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1789                                            folderId, orderByComparator, false);
1790    
1791                            return array;
1792                    }
1793                    catch (Exception e) {
1794                            throw processException(e);
1795                    }
1796                    finally {
1797                            closeSession(session);
1798                    }
1799            }
1800    
1801            protected DLFileShortcut getByG_F_PrevAndNext(Session session,
1802                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
1803                    OrderByComparator orderByComparator, boolean previous) {
1804                    StringBundler query = null;
1805    
1806                    if (orderByComparator != null) {
1807                            query = new StringBundler(6 +
1808                                            (orderByComparator.getOrderByFields().length * 6));
1809                    }
1810                    else {
1811                            query = new StringBundler(3);
1812                    }
1813    
1814                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1815    
1816                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1817    
1818                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1819    
1820                    if (orderByComparator != null) {
1821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1822    
1823                            if (orderByConditionFields.length > 0) {
1824                                    query.append(WHERE_AND);
1825                            }
1826    
1827                            for (int i = 0; i < orderByConditionFields.length; i++) {
1828                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1829                                    query.append(orderByConditionFields[i]);
1830    
1831                                    if ((i + 1) < orderByConditionFields.length) {
1832                                            if (orderByComparator.isAscending() ^ previous) {
1833                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1834                                            }
1835                                            else {
1836                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1837                                            }
1838                                    }
1839                                    else {
1840                                            if (orderByComparator.isAscending() ^ previous) {
1841                                                    query.append(WHERE_GREATER_THAN);
1842                                            }
1843                                            else {
1844                                                    query.append(WHERE_LESSER_THAN);
1845                                            }
1846                                    }
1847                            }
1848    
1849                            query.append(ORDER_BY_CLAUSE);
1850    
1851                            String[] orderByFields = orderByComparator.getOrderByFields();
1852    
1853                            for (int i = 0; i < orderByFields.length; i++) {
1854                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1855                                    query.append(orderByFields[i]);
1856    
1857                                    if ((i + 1) < orderByFields.length) {
1858                                            if (orderByComparator.isAscending() ^ previous) {
1859                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1860                                            }
1861                                            else {
1862                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1863                                            }
1864                                    }
1865                                    else {
1866                                            if (orderByComparator.isAscending() ^ previous) {
1867                                                    query.append(ORDER_BY_ASC);
1868                                            }
1869                                            else {
1870                                                    query.append(ORDER_BY_DESC);
1871                                            }
1872                                    }
1873                            }
1874                    }
1875    
1876                    String sql = query.toString();
1877    
1878                    Query q = session.createQuery(sql);
1879    
1880                    q.setFirstResult(0);
1881                    q.setMaxResults(2);
1882    
1883                    QueryPos qPos = QueryPos.getInstance(q);
1884    
1885                    qPos.add(groupId);
1886    
1887                    qPos.add(folderId);
1888    
1889                    if (orderByComparator != null) {
1890                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1891    
1892                            for (Object value : values) {
1893                                    qPos.add(value);
1894                            }
1895                    }
1896    
1897                    List<DLFileShortcut> list = q.list();
1898    
1899                    if (list.size() == 2) {
1900                            return list.get(1);
1901                    }
1902                    else {
1903                            return null;
1904                    }
1905            }
1906    
1907            /**
1908             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
1909             *
1910             * @param groupId the group ID
1911             * @param folderId the folder ID
1912             * @return the matching document library file shortcuts that the user has permission to view
1913             * @throws SystemException if a system exception occurred
1914             */
1915            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId)
1916                    throws SystemException {
1917                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
1918                            QueryUtil.ALL_POS, null);
1919            }
1920    
1921            /**
1922             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
1923             *
1924             * <p>
1925             * 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.
1926             * </p>
1927             *
1928             * @param groupId the group ID
1929             * @param folderId the folder ID
1930             * @param start the lower bound of the range of document library file shortcuts
1931             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1932             * @return the range of matching document library file shortcuts that the user has permission to view
1933             * @throws SystemException if a system exception occurred
1934             */
1935            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1936                    int start, int end) throws SystemException {
1937                    return filterFindByG_F(groupId, folderId, start, end, null);
1938            }
1939    
1940            /**
1941             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63;.
1942             *
1943             * <p>
1944             * 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.
1945             * </p>
1946             *
1947             * @param groupId the group ID
1948             * @param folderId the folder ID
1949             * @param start the lower bound of the range of document library file shortcuts
1950             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1951             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1952             * @return the ordered range of matching document library file shortcuts that the user has permission to view
1953             * @throws SystemException if a system exception occurred
1954             */
1955            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1956                    int start, int end, OrderByComparator orderByComparator)
1957                    throws SystemException {
1958                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1959                            return findByG_F(groupId, folderId, start, end, orderByComparator);
1960                    }
1961    
1962                    StringBundler query = null;
1963    
1964                    if (orderByComparator != null) {
1965                            query = new StringBundler(4 +
1966                                            (orderByComparator.getOrderByFields().length * 3));
1967                    }
1968                    else {
1969                            query = new StringBundler(3);
1970                    }
1971    
1972                    if (getDB().isSupportsInlineDistinct()) {
1973                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
1974                    }
1975                    else {
1976                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
1977                    }
1978    
1979                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1980    
1981                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1982    
1983                    if (!getDB().isSupportsInlineDistinct()) {
1984                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
1985                    }
1986    
1987                    if (orderByComparator != null) {
1988                            if (getDB().isSupportsInlineDistinct()) {
1989                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1990                                            orderByComparator);
1991                            }
1992                            else {
1993                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1994                                            orderByComparator);
1995                            }
1996                    }
1997    
1998                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1999                                    DLFileShortcut.class.getName(),
2000                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2001    
2002                    Session session = null;
2003    
2004                    try {
2005                            session = openSession();
2006    
2007                            SQLQuery q = session.createSQLQuery(sql);
2008    
2009                            if (getDB().isSupportsInlineDistinct()) {
2010                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2011                            }
2012                            else {
2013                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2014                            }
2015    
2016                            QueryPos qPos = QueryPos.getInstance(q);
2017    
2018                            qPos.add(groupId);
2019    
2020                            qPos.add(folderId);
2021    
2022                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2023                                    end);
2024                    }
2025                    catch (Exception e) {
2026                            throw processException(e);
2027                    }
2028                    finally {
2029                            closeSession(session);
2030                    }
2031            }
2032    
2033            /**
2034             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2035             *
2036             * @param fileShortcutId the primary key of the current document library file shortcut
2037             * @param groupId the group ID
2038             * @param folderId the folder ID
2039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2040             * @return the previous, current, and next document library file shortcut
2041             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2042             * @throws SystemException if a system exception occurred
2043             */
2044            public DLFileShortcut[] filterFindByG_F_PrevAndNext(long fileShortcutId,
2045                    long groupId, long folderId, OrderByComparator orderByComparator)
2046                    throws NoSuchFileShortcutException, SystemException {
2047                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2048                            return findByG_F_PrevAndNext(fileShortcutId, groupId, folderId,
2049                                    orderByComparator);
2050                    }
2051    
2052                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2053    
2054                    Session session = null;
2055    
2056                    try {
2057                            session = openSession();
2058    
2059                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2060    
2061                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2062                                            groupId, folderId, orderByComparator, true);
2063    
2064                            array[1] = dlFileShortcut;
2065    
2066                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2067                                            groupId, folderId, orderByComparator, false);
2068    
2069                            return array;
2070                    }
2071                    catch (Exception e) {
2072                            throw processException(e);
2073                    }
2074                    finally {
2075                            closeSession(session);
2076                    }
2077            }
2078    
2079            protected DLFileShortcut filterGetByG_F_PrevAndNext(Session session,
2080                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
2081                    OrderByComparator orderByComparator, boolean previous) {
2082                    StringBundler query = null;
2083    
2084                    if (orderByComparator != null) {
2085                            query = new StringBundler(6 +
2086                                            (orderByComparator.getOrderByFields().length * 6));
2087                    }
2088                    else {
2089                            query = new StringBundler(3);
2090                    }
2091    
2092                    if (getDB().isSupportsInlineDistinct()) {
2093                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2094                    }
2095                    else {
2096                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2097                    }
2098    
2099                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2100    
2101                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2102    
2103                    if (!getDB().isSupportsInlineDistinct()) {
2104                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2105                    }
2106    
2107                    if (orderByComparator != null) {
2108                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2109    
2110                            if (orderByConditionFields.length > 0) {
2111                                    query.append(WHERE_AND);
2112                            }
2113    
2114                            for (int i = 0; i < orderByConditionFields.length; i++) {
2115                                    if (getDB().isSupportsInlineDistinct()) {
2116                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2117                                    }
2118                                    else {
2119                                            query.append(_ORDER_BY_ENTITY_TABLE);
2120                                    }
2121    
2122                                    query.append(orderByConditionFields[i]);
2123    
2124                                    if ((i + 1) < orderByConditionFields.length) {
2125                                            if (orderByComparator.isAscending() ^ previous) {
2126                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2127                                            }
2128                                            else {
2129                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2130                                            }
2131                                    }
2132                                    else {
2133                                            if (orderByComparator.isAscending() ^ previous) {
2134                                                    query.append(WHERE_GREATER_THAN);
2135                                            }
2136                                            else {
2137                                                    query.append(WHERE_LESSER_THAN);
2138                                            }
2139                                    }
2140                            }
2141    
2142                            query.append(ORDER_BY_CLAUSE);
2143    
2144                            String[] orderByFields = orderByComparator.getOrderByFields();
2145    
2146                            for (int i = 0; i < orderByFields.length; i++) {
2147                                    if (getDB().isSupportsInlineDistinct()) {
2148                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2149                                    }
2150                                    else {
2151                                            query.append(_ORDER_BY_ENTITY_TABLE);
2152                                    }
2153    
2154                                    query.append(orderByFields[i]);
2155    
2156                                    if ((i + 1) < orderByFields.length) {
2157                                            if (orderByComparator.isAscending() ^ previous) {
2158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2159                                            }
2160                                            else {
2161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2162                                            }
2163                                    }
2164                                    else {
2165                                            if (orderByComparator.isAscending() ^ previous) {
2166                                                    query.append(ORDER_BY_ASC);
2167                                            }
2168                                            else {
2169                                                    query.append(ORDER_BY_DESC);
2170                                            }
2171                                    }
2172                            }
2173                    }
2174    
2175                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2176                                    DLFileShortcut.class.getName(),
2177                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2178    
2179                    SQLQuery q = session.createSQLQuery(sql);
2180    
2181                    q.setFirstResult(0);
2182                    q.setMaxResults(2);
2183    
2184                    if (getDB().isSupportsInlineDistinct()) {
2185                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2186                    }
2187                    else {
2188                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2189                    }
2190    
2191                    QueryPos qPos = QueryPos.getInstance(q);
2192    
2193                    qPos.add(groupId);
2194    
2195                    qPos.add(folderId);
2196    
2197                    if (orderByComparator != null) {
2198                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2199    
2200                            for (Object value : values) {
2201                                    qPos.add(value);
2202                            }
2203                    }
2204    
2205                    List<DLFileShortcut> list = q.list();
2206    
2207                    if (list.size() == 2) {
2208                            return list.get(1);
2209                    }
2210                    else {
2211                            return null;
2212                    }
2213            }
2214    
2215            /**
2216             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2217             *
2218             * @param groupId the group ID
2219             * @param folderId the folder ID
2220             * @param status the status
2221             * @return the matching document library file shortcuts
2222             * @throws SystemException if a system exception occurred
2223             */
2224            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2225                    int status) throws SystemException {
2226                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
2227                            QueryUtil.ALL_POS, null);
2228            }
2229    
2230            /**
2231             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2232             *
2233             * <p>
2234             * 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.
2235             * </p>
2236             *
2237             * @param groupId the group ID
2238             * @param folderId the folder ID
2239             * @param status the status
2240             * @param start the lower bound of the range of document library file shortcuts
2241             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2242             * @return the range of matching document library file shortcuts
2243             * @throws SystemException if a system exception occurred
2244             */
2245            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2246                    int status, int start, int end) throws SystemException {
2247                    return findByG_F_S(groupId, folderId, status, start, end, null);
2248            }
2249    
2250            /**
2251             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2252             *
2253             * <p>
2254             * 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.
2255             * </p>
2256             *
2257             * @param groupId the group ID
2258             * @param folderId the folder ID
2259             * @param status the status
2260             * @param start the lower bound of the range of document library file shortcuts
2261             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2262             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2263             * @return the ordered range of matching document library file shortcuts
2264             * @throws SystemException if a system exception occurred
2265             */
2266            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2267                    int status, int start, int end, OrderByComparator orderByComparator)
2268                    throws SystemException {
2269                    FinderPath finderPath = null;
2270                    Object[] finderArgs = null;
2271    
2272                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2273                                    (orderByComparator == null)) {
2274                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
2275                            finderArgs = new Object[] { groupId, folderId, status };
2276                    }
2277                    else {
2278                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
2279                            finderArgs = new Object[] {
2280                                            groupId, folderId, status,
2281                                            
2282                                            start, end, orderByComparator
2283                                    };
2284                    }
2285    
2286                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2287                                    finderArgs, this);
2288    
2289                    if (list == null) {
2290                            StringBundler query = null;
2291    
2292                            if (orderByComparator != null) {
2293                                    query = new StringBundler(5 +
2294                                                    (orderByComparator.getOrderByFields().length * 3));
2295                            }
2296                            else {
2297                                    query = new StringBundler(4);
2298                            }
2299    
2300                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2301    
2302                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2303    
2304                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2305    
2306                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2307    
2308                            if (orderByComparator != null) {
2309                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2310                                            orderByComparator);
2311                            }
2312    
2313                            String sql = query.toString();
2314    
2315                            Session session = null;
2316    
2317                            try {
2318                                    session = openSession();
2319    
2320                                    Query q = session.createQuery(sql);
2321    
2322                                    QueryPos qPos = QueryPos.getInstance(q);
2323    
2324                                    qPos.add(groupId);
2325    
2326                                    qPos.add(folderId);
2327    
2328                                    qPos.add(status);
2329    
2330                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
2331                                                    start, end);
2332                            }
2333                            catch (Exception e) {
2334                                    throw processException(e);
2335                            }
2336                            finally {
2337                                    if (list == null) {
2338                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2339                                    }
2340                                    else {
2341                                            cacheResult(list);
2342    
2343                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2344                                    }
2345    
2346                                    closeSession(session);
2347                            }
2348                    }
2349    
2350                    return list;
2351            }
2352    
2353            /**
2354             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
2355             *
2356             * <p>
2357             * 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.
2358             * </p>
2359             *
2360             * @param groupId the group ID
2361             * @param folderId the folder ID
2362             * @param status the status
2363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2364             * @return the first matching document library file shortcut
2365             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2366             * @throws SystemException if a system exception occurred
2367             */
2368            public DLFileShortcut findByG_F_S_First(long groupId, long folderId,
2369                    int status, OrderByComparator orderByComparator)
2370                    throws NoSuchFileShortcutException, SystemException {
2371                    List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status, 0,
2372                                    1, orderByComparator);
2373    
2374                    if (list.isEmpty()) {
2375                            StringBundler msg = new StringBundler(8);
2376    
2377                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2378    
2379                            msg.append("groupId=");
2380                            msg.append(groupId);
2381    
2382                            msg.append(", folderId=");
2383                            msg.append(folderId);
2384    
2385                            msg.append(", status=");
2386                            msg.append(status);
2387    
2388                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2389    
2390                            throw new NoSuchFileShortcutException(msg.toString());
2391                    }
2392                    else {
2393                            return list.get(0);
2394                    }
2395            }
2396    
2397            /**
2398             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
2399             *
2400             * <p>
2401             * 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.
2402             * </p>
2403             *
2404             * @param groupId the group ID
2405             * @param folderId the folder ID
2406             * @param status the status
2407             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2408             * @return the last matching document library file shortcut
2409             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2410             * @throws SystemException if a system exception occurred
2411             */
2412            public DLFileShortcut findByG_F_S_Last(long groupId, long folderId,
2413                    int status, OrderByComparator orderByComparator)
2414                    throws NoSuchFileShortcutException, SystemException {
2415                    int count = countByG_F_S(groupId, folderId, status);
2416    
2417                    List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status,
2418                                    count - 1, count, orderByComparator);
2419    
2420                    if (list.isEmpty()) {
2421                            StringBundler msg = new StringBundler(8);
2422    
2423                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2424    
2425                            msg.append("groupId=");
2426                            msg.append(groupId);
2427    
2428                            msg.append(", folderId=");
2429                            msg.append(folderId);
2430    
2431                            msg.append(", status=");
2432                            msg.append(status);
2433    
2434                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2435    
2436                            throw new NoSuchFileShortcutException(msg.toString());
2437                    }
2438                    else {
2439                            return list.get(0);
2440                    }
2441            }
2442    
2443            /**
2444             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
2445             *
2446             * <p>
2447             * 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.
2448             * </p>
2449             *
2450             * @param fileShortcutId the primary key of the current document library file shortcut
2451             * @param groupId the group ID
2452             * @param folderId the folder ID
2453             * @param status the status
2454             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2455             * @return the previous, current, and next document library file shortcut
2456             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2457             * @throws SystemException if a system exception occurred
2458             */
2459            public DLFileShortcut[] findByG_F_S_PrevAndNext(long fileShortcutId,
2460                    long groupId, long folderId, int status,
2461                    OrderByComparator orderByComparator)
2462                    throws NoSuchFileShortcutException, SystemException {
2463                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2464    
2465                    Session session = null;
2466    
2467                    try {
2468                            session = openSession();
2469    
2470                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2471    
2472                            array[0] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
2473                                            folderId, status, orderByComparator, true);
2474    
2475                            array[1] = dlFileShortcut;
2476    
2477                            array[2] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
2478                                            folderId, status, orderByComparator, false);
2479    
2480                            return array;
2481                    }
2482                    catch (Exception e) {
2483                            throw processException(e);
2484                    }
2485                    finally {
2486                            closeSession(session);
2487                    }
2488            }
2489    
2490            protected DLFileShortcut getByG_F_S_PrevAndNext(Session session,
2491                    DLFileShortcut dlFileShortcut, long groupId, long folderId, int status,
2492                    OrderByComparator orderByComparator, boolean previous) {
2493                    StringBundler query = null;
2494    
2495                    if (orderByComparator != null) {
2496                            query = new StringBundler(6 +
2497                                            (orderByComparator.getOrderByFields().length * 6));
2498                    }
2499                    else {
2500                            query = new StringBundler(3);
2501                    }
2502    
2503                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2504    
2505                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2506    
2507                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2508    
2509                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2510    
2511                    if (orderByComparator != null) {
2512                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2513    
2514                            if (orderByConditionFields.length > 0) {
2515                                    query.append(WHERE_AND);
2516                            }
2517    
2518                            for (int i = 0; i < orderByConditionFields.length; i++) {
2519                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2520                                    query.append(orderByConditionFields[i]);
2521    
2522                                    if ((i + 1) < orderByConditionFields.length) {
2523                                            if (orderByComparator.isAscending() ^ previous) {
2524                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2525                                            }
2526                                            else {
2527                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2528                                            }
2529                                    }
2530                                    else {
2531                                            if (orderByComparator.isAscending() ^ previous) {
2532                                                    query.append(WHERE_GREATER_THAN);
2533                                            }
2534                                            else {
2535                                                    query.append(WHERE_LESSER_THAN);
2536                                            }
2537                                    }
2538                            }
2539    
2540                            query.append(ORDER_BY_CLAUSE);
2541    
2542                            String[] orderByFields = orderByComparator.getOrderByFields();
2543    
2544                            for (int i = 0; i < orderByFields.length; i++) {
2545                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2546                                    query.append(orderByFields[i]);
2547    
2548                                    if ((i + 1) < orderByFields.length) {
2549                                            if (orderByComparator.isAscending() ^ previous) {
2550                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2551                                            }
2552                                            else {
2553                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2554                                            }
2555                                    }
2556                                    else {
2557                                            if (orderByComparator.isAscending() ^ previous) {
2558                                                    query.append(ORDER_BY_ASC);
2559                                            }
2560                                            else {
2561                                                    query.append(ORDER_BY_DESC);
2562                                            }
2563                                    }
2564                            }
2565                    }
2566    
2567                    String sql = query.toString();
2568    
2569                    Query q = session.createQuery(sql);
2570    
2571                    q.setFirstResult(0);
2572                    q.setMaxResults(2);
2573    
2574                    QueryPos qPos = QueryPos.getInstance(q);
2575    
2576                    qPos.add(groupId);
2577    
2578                    qPos.add(folderId);
2579    
2580                    qPos.add(status);
2581    
2582                    if (orderByComparator != null) {
2583                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2584    
2585                            for (Object value : values) {
2586                                    qPos.add(value);
2587                            }
2588                    }
2589    
2590                    List<DLFileShortcut> list = q.list();
2591    
2592                    if (list.size() == 2) {
2593                            return list.get(1);
2594                    }
2595                    else {
2596                            return null;
2597                    }
2598            }
2599    
2600            /**
2601             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2602             *
2603             * @param groupId the group ID
2604             * @param folderId the folder ID
2605             * @param status the status
2606             * @return the matching document library file shortcuts that the user has permission to view
2607             * @throws SystemException if a system exception occurred
2608             */
2609            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2610                    int status) throws SystemException {
2611                    return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
2612                            QueryUtil.ALL_POS, null);
2613            }
2614    
2615            /**
2616             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2617             *
2618             * <p>
2619             * 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.
2620             * </p>
2621             *
2622             * @param groupId the group ID
2623             * @param folderId the folder ID
2624             * @param status the status
2625             * @param start the lower bound of the range of document library file shortcuts
2626             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2627             * @return the range of matching document library file shortcuts that the user has permission to view
2628             * @throws SystemException if a system exception occurred
2629             */
2630            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2631                    int status, int start, int end) throws SystemException {
2632                    return filterFindByG_F_S(groupId, folderId, status, start, end, null);
2633            }
2634    
2635            /**
2636             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2637             *
2638             * <p>
2639             * 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.
2640             * </p>
2641             *
2642             * @param groupId the group ID
2643             * @param folderId the folder ID
2644             * @param status the status
2645             * @param start the lower bound of the range of document library file shortcuts
2646             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2647             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2648             * @return the ordered range of matching document library file shortcuts that the user has permission to view
2649             * @throws SystemException if a system exception occurred
2650             */
2651            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2652                    int status, int start, int end, OrderByComparator orderByComparator)
2653                    throws SystemException {
2654                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2655                            return findByG_F_S(groupId, folderId, status, start, end,
2656                                    orderByComparator);
2657                    }
2658    
2659                    StringBundler query = null;
2660    
2661                    if (orderByComparator != null) {
2662                            query = new StringBundler(5 +
2663                                            (orderByComparator.getOrderByFields().length * 3));
2664                    }
2665                    else {
2666                            query = new StringBundler(4);
2667                    }
2668    
2669                    if (getDB().isSupportsInlineDistinct()) {
2670                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2671                    }
2672                    else {
2673                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2674                    }
2675    
2676                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2677    
2678                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2679    
2680                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2681    
2682                    if (!getDB().isSupportsInlineDistinct()) {
2683                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2684                    }
2685    
2686                    if (orderByComparator != null) {
2687                            if (getDB().isSupportsInlineDistinct()) {
2688                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2689                                            orderByComparator);
2690                            }
2691                            else {
2692                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2693                                            orderByComparator);
2694                            }
2695                    }
2696    
2697                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2698                                    DLFileShortcut.class.getName(),
2699                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2700    
2701                    Session session = null;
2702    
2703                    try {
2704                            session = openSession();
2705    
2706                            SQLQuery q = session.createSQLQuery(sql);
2707    
2708                            if (getDB().isSupportsInlineDistinct()) {
2709                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2710                            }
2711                            else {
2712                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2713                            }
2714    
2715                            QueryPos qPos = QueryPos.getInstance(q);
2716    
2717                            qPos.add(groupId);
2718    
2719                            qPos.add(folderId);
2720    
2721                            qPos.add(status);
2722    
2723                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2724                                    end);
2725                    }
2726                    catch (Exception e) {
2727                            throw processException(e);
2728                    }
2729                    finally {
2730                            closeSession(session);
2731                    }
2732            }
2733    
2734            /**
2735             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2736             *
2737             * @param fileShortcutId the primary key of the current document library file shortcut
2738             * @param groupId the group ID
2739             * @param folderId the folder ID
2740             * @param status the status
2741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2742             * @return the previous, current, and next document library file shortcut
2743             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2744             * @throws SystemException if a system exception occurred
2745             */
2746            public DLFileShortcut[] filterFindByG_F_S_PrevAndNext(long fileShortcutId,
2747                    long groupId, long folderId, int status,
2748                    OrderByComparator orderByComparator)
2749                    throws NoSuchFileShortcutException, SystemException {
2750                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2751                            return findByG_F_S_PrevAndNext(fileShortcutId, groupId, folderId,
2752                                    status, orderByComparator);
2753                    }
2754    
2755                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2756    
2757                    Session session = null;
2758    
2759                    try {
2760                            session = openSession();
2761    
2762                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2763    
2764                            array[0] = filterGetByG_F_S_PrevAndNext(session, dlFileShortcut,
2765                                            groupId, folderId, status, orderByComparator, true);
2766    
2767                            array[1] = dlFileShortcut;
2768    
2769                            array[2] = filterGetByG_F_S_PrevAndNext(session, dlFileShortcut,
2770                                            groupId, folderId, status, orderByComparator, false);
2771    
2772                            return array;
2773                    }
2774                    catch (Exception e) {
2775                            throw processException(e);
2776                    }
2777                    finally {
2778                            closeSession(session);
2779                    }
2780            }
2781    
2782            protected DLFileShortcut filterGetByG_F_S_PrevAndNext(Session session,
2783                    DLFileShortcut dlFileShortcut, long groupId, long folderId, int status,
2784                    OrderByComparator orderByComparator, boolean previous) {
2785                    StringBundler query = null;
2786    
2787                    if (orderByComparator != null) {
2788                            query = new StringBundler(6 +
2789                                            (orderByComparator.getOrderByFields().length * 6));
2790                    }
2791                    else {
2792                            query = new StringBundler(3);
2793                    }
2794    
2795                    if (getDB().isSupportsInlineDistinct()) {
2796                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2797                    }
2798                    else {
2799                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2800                    }
2801    
2802                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2803    
2804                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2805    
2806                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2807    
2808                    if (!getDB().isSupportsInlineDistinct()) {
2809                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2810                    }
2811    
2812                    if (orderByComparator != null) {
2813                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2814    
2815                            if (orderByConditionFields.length > 0) {
2816                                    query.append(WHERE_AND);
2817                            }
2818    
2819                            for (int i = 0; i < orderByConditionFields.length; i++) {
2820                                    if (getDB().isSupportsInlineDistinct()) {
2821                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2822                                    }
2823                                    else {
2824                                            query.append(_ORDER_BY_ENTITY_TABLE);
2825                                    }
2826    
2827                                    query.append(orderByConditionFields[i]);
2828    
2829                                    if ((i + 1) < orderByConditionFields.length) {
2830                                            if (orderByComparator.isAscending() ^ previous) {
2831                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2832                                            }
2833                                            else {
2834                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2835                                            }
2836                                    }
2837                                    else {
2838                                            if (orderByComparator.isAscending() ^ previous) {
2839                                                    query.append(WHERE_GREATER_THAN);
2840                                            }
2841                                            else {
2842                                                    query.append(WHERE_LESSER_THAN);
2843                                            }
2844                                    }
2845                            }
2846    
2847                            query.append(ORDER_BY_CLAUSE);
2848    
2849                            String[] orderByFields = orderByComparator.getOrderByFields();
2850    
2851                            for (int i = 0; i < orderByFields.length; i++) {
2852                                    if (getDB().isSupportsInlineDistinct()) {
2853                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2854                                    }
2855                                    else {
2856                                            query.append(_ORDER_BY_ENTITY_TABLE);
2857                                    }
2858    
2859                                    query.append(orderByFields[i]);
2860    
2861                                    if ((i + 1) < orderByFields.length) {
2862                                            if (orderByComparator.isAscending() ^ previous) {
2863                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2864                                            }
2865                                            else {
2866                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2867                                            }
2868                                    }
2869                                    else {
2870                                            if (orderByComparator.isAscending() ^ previous) {
2871                                                    query.append(ORDER_BY_ASC);
2872                                            }
2873                                            else {
2874                                                    query.append(ORDER_BY_DESC);
2875                                            }
2876                                    }
2877                            }
2878                    }
2879    
2880                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2881                                    DLFileShortcut.class.getName(),
2882                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2883    
2884                    SQLQuery q = session.createSQLQuery(sql);
2885    
2886                    q.setFirstResult(0);
2887                    q.setMaxResults(2);
2888    
2889                    if (getDB().isSupportsInlineDistinct()) {
2890                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2891                    }
2892                    else {
2893                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2894                    }
2895    
2896                    QueryPos qPos = QueryPos.getInstance(q);
2897    
2898                    qPos.add(groupId);
2899    
2900                    qPos.add(folderId);
2901    
2902                    qPos.add(status);
2903    
2904                    if (orderByComparator != null) {
2905                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2906    
2907                            for (Object value : values) {
2908                                    qPos.add(value);
2909                            }
2910                    }
2911    
2912                    List<DLFileShortcut> list = q.list();
2913    
2914                    if (list.size() == 2) {
2915                            return list.get(1);
2916                    }
2917                    else {
2918                            return null;
2919                    }
2920            }
2921    
2922            /**
2923             * Returns all the document library file shortcuts.
2924             *
2925             * @return the document library file shortcuts
2926             * @throws SystemException if a system exception occurred
2927             */
2928            public List<DLFileShortcut> findAll() throws SystemException {
2929                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2930            }
2931    
2932            /**
2933             * Returns a range of all the document library file shortcuts.
2934             *
2935             * <p>
2936             * 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.
2937             * </p>
2938             *
2939             * @param start the lower bound of the range of document library file shortcuts
2940             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2941             * @return the range of document library file shortcuts
2942             * @throws SystemException if a system exception occurred
2943             */
2944            public List<DLFileShortcut> findAll(int start, int end)
2945                    throws SystemException {
2946                    return findAll(start, end, null);
2947            }
2948    
2949            /**
2950             * Returns an ordered range of all the document library file shortcuts.
2951             *
2952             * <p>
2953             * 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.
2954             * </p>
2955             *
2956             * @param start the lower bound of the range of document library file shortcuts
2957             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2958             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2959             * @return the ordered range of document library file shortcuts
2960             * @throws SystemException if a system exception occurred
2961             */
2962            public List<DLFileShortcut> findAll(int start, int end,
2963                    OrderByComparator orderByComparator) throws SystemException {
2964                    FinderPath finderPath = null;
2965                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2966    
2967                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2968                                    (orderByComparator == null)) {
2969                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2970                            finderArgs = FINDER_ARGS_EMPTY;
2971                    }
2972                    else {
2973                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2974                            finderArgs = new Object[] { start, end, orderByComparator };
2975                    }
2976    
2977                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2978                                    finderArgs, this);
2979    
2980                    if (list == null) {
2981                            StringBundler query = null;
2982                            String sql = null;
2983    
2984                            if (orderByComparator != null) {
2985                                    query = new StringBundler(2 +
2986                                                    (orderByComparator.getOrderByFields().length * 3));
2987    
2988                                    query.append(_SQL_SELECT_DLFILESHORTCUT);
2989    
2990                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2991                                            orderByComparator);
2992    
2993                                    sql = query.toString();
2994                            }
2995                            else {
2996                                    sql = _SQL_SELECT_DLFILESHORTCUT;
2997                            }
2998    
2999                            Session session = null;
3000    
3001                            try {
3002                                    session = openSession();
3003    
3004                                    Query q = session.createQuery(sql);
3005    
3006                                    if (orderByComparator == null) {
3007                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3008                                                            getDialect(), start, end, false);
3009    
3010                                            Collections.sort(list);
3011                                    }
3012                                    else {
3013                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3014                                                            getDialect(), start, end);
3015                                    }
3016                            }
3017                            catch (Exception e) {
3018                                    throw processException(e);
3019                            }
3020                            finally {
3021                                    if (list == null) {
3022                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3023                                    }
3024                                    else {
3025                                            cacheResult(list);
3026    
3027                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3028                                    }
3029    
3030                                    closeSession(session);
3031                            }
3032                    }
3033    
3034                    return list;
3035            }
3036    
3037            /**
3038             * Removes all the document library file shortcuts where uuid = &#63; from the database.
3039             *
3040             * @param uuid the uuid
3041             * @throws SystemException if a system exception occurred
3042             */
3043            public void removeByUuid(String uuid) throws SystemException {
3044                    for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
3045                            dlFileShortcutPersistence.remove(dlFileShortcut);
3046                    }
3047            }
3048    
3049            /**
3050             * Removes the document library file shortcut where uuid = &#63; and groupId = &#63; from the database.
3051             *
3052             * @param uuid the uuid
3053             * @param groupId the group ID
3054             * @throws SystemException if a system exception occurred
3055             */
3056            public void removeByUUID_G(String uuid, long groupId)
3057                    throws NoSuchFileShortcutException, SystemException {
3058                    DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
3059    
3060                    dlFileShortcutPersistence.remove(dlFileShortcut);
3061            }
3062    
3063            /**
3064             * Removes all the document library file shortcuts where toFileEntryId = &#63; from the database.
3065             *
3066             * @param toFileEntryId the to file entry ID
3067             * @throws SystemException if a system exception occurred
3068             */
3069            public void removeByToFileEntryId(long toFileEntryId)
3070                    throws SystemException {
3071                    for (DLFileShortcut dlFileShortcut : findByToFileEntryId(toFileEntryId)) {
3072                            dlFileShortcutPersistence.remove(dlFileShortcut);
3073                    }
3074            }
3075    
3076            /**
3077             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; from the database.
3078             *
3079             * @param groupId the group ID
3080             * @param folderId the folder ID
3081             * @throws SystemException if a system exception occurred
3082             */
3083            public void removeByG_F(long groupId, long folderId)
3084                    throws SystemException {
3085                    for (DLFileShortcut dlFileShortcut : findByG_F(groupId, folderId)) {
3086                            dlFileShortcutPersistence.remove(dlFileShortcut);
3087                    }
3088            }
3089    
3090            /**
3091             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
3092             *
3093             * @param groupId the group ID
3094             * @param folderId the folder ID
3095             * @param status the status
3096             * @throws SystemException if a system exception occurred
3097             */
3098            public void removeByG_F_S(long groupId, long folderId, int status)
3099                    throws SystemException {
3100                    for (DLFileShortcut dlFileShortcut : findByG_F_S(groupId, folderId,
3101                                    status)) {
3102                            dlFileShortcutPersistence.remove(dlFileShortcut);
3103                    }
3104            }
3105    
3106            /**
3107             * Removes all the document library file shortcuts from the database.
3108             *
3109             * @throws SystemException if a system exception occurred
3110             */
3111            public void removeAll() throws SystemException {
3112                    for (DLFileShortcut dlFileShortcut : findAll()) {
3113                            dlFileShortcutPersistence.remove(dlFileShortcut);
3114                    }
3115            }
3116    
3117            /**
3118             * Returns the number of document library file shortcuts where uuid = &#63;.
3119             *
3120             * @param uuid the uuid
3121             * @return the number of matching document library file shortcuts
3122             * @throws SystemException if a system exception occurred
3123             */
3124            public int countByUuid(String uuid) throws SystemException {
3125                    Object[] finderArgs = new Object[] { uuid };
3126    
3127                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3128                                    finderArgs, this);
3129    
3130                    if (count == null) {
3131                            StringBundler query = new StringBundler(2);
3132    
3133                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3134    
3135                            if (uuid == null) {
3136                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3137                            }
3138                            else {
3139                                    if (uuid.equals(StringPool.BLANK)) {
3140                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
3141                                    }
3142                                    else {
3143                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
3144                                    }
3145                            }
3146    
3147                            String sql = query.toString();
3148    
3149                            Session session = null;
3150    
3151                            try {
3152                                    session = openSession();
3153    
3154                                    Query q = session.createQuery(sql);
3155    
3156                                    QueryPos qPos = QueryPos.getInstance(q);
3157    
3158                                    if (uuid != null) {
3159                                            qPos.add(uuid);
3160                                    }
3161    
3162                                    count = (Long)q.uniqueResult();
3163                            }
3164                            catch (Exception e) {
3165                                    throw processException(e);
3166                            }
3167                            finally {
3168                                    if (count == null) {
3169                                            count = Long.valueOf(0);
3170                                    }
3171    
3172                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3173                                            finderArgs, count);
3174    
3175                                    closeSession(session);
3176                            }
3177                    }
3178    
3179                    return count.intValue();
3180            }
3181    
3182            /**
3183             * Returns the number of document library file shortcuts where uuid = &#63; and groupId = &#63;.
3184             *
3185             * @param uuid the uuid
3186             * @param groupId the group ID
3187             * @return the number of matching document library file shortcuts
3188             * @throws SystemException if a system exception occurred
3189             */
3190            public int countByUUID_G(String uuid, long groupId)
3191                    throws SystemException {
3192                    Object[] finderArgs = new Object[] { uuid, groupId };
3193    
3194                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3195                                    finderArgs, this);
3196    
3197                    if (count == null) {
3198                            StringBundler query = new StringBundler(3);
3199    
3200                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3201    
3202                            if (uuid == null) {
3203                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3204                            }
3205                            else {
3206                                    if (uuid.equals(StringPool.BLANK)) {
3207                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3208                                    }
3209                                    else {
3210                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3211                                    }
3212                            }
3213    
3214                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3215    
3216                            String sql = query.toString();
3217    
3218                            Session session = null;
3219    
3220                            try {
3221                                    session = openSession();
3222    
3223                                    Query q = session.createQuery(sql);
3224    
3225                                    QueryPos qPos = QueryPos.getInstance(q);
3226    
3227                                    if (uuid != null) {
3228                                            qPos.add(uuid);
3229                                    }
3230    
3231                                    qPos.add(groupId);
3232    
3233                                    count = (Long)q.uniqueResult();
3234                            }
3235                            catch (Exception e) {
3236                                    throw processException(e);
3237                            }
3238                            finally {
3239                                    if (count == null) {
3240                                            count = Long.valueOf(0);
3241                                    }
3242    
3243                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3244                                            finderArgs, count);
3245    
3246                                    closeSession(session);
3247                            }
3248                    }
3249    
3250                    return count.intValue();
3251            }
3252    
3253            /**
3254             * Returns the number of document library file shortcuts where toFileEntryId = &#63;.
3255             *
3256             * @param toFileEntryId the to file entry ID
3257             * @return the number of matching document library file shortcuts
3258             * @throws SystemException if a system exception occurred
3259             */
3260            public int countByToFileEntryId(long toFileEntryId)
3261                    throws SystemException {
3262                    Object[] finderArgs = new Object[] { toFileEntryId };
3263    
3264                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
3265                                    finderArgs, this);
3266    
3267                    if (count == null) {
3268                            StringBundler query = new StringBundler(2);
3269    
3270                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3271    
3272                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
3273    
3274                            String sql = query.toString();
3275    
3276                            Session session = null;
3277    
3278                            try {
3279                                    session = openSession();
3280    
3281                                    Query q = session.createQuery(sql);
3282    
3283                                    QueryPos qPos = QueryPos.getInstance(q);
3284    
3285                                    qPos.add(toFileEntryId);
3286    
3287                                    count = (Long)q.uniqueResult();
3288                            }
3289                            catch (Exception e) {
3290                                    throw processException(e);
3291                            }
3292                            finally {
3293                                    if (count == null) {
3294                                            count = Long.valueOf(0);
3295                                    }
3296    
3297                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
3298                                            finderArgs, count);
3299    
3300                                    closeSession(session);
3301                            }
3302                    }
3303    
3304                    return count.intValue();
3305            }
3306    
3307            /**
3308             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63;.
3309             *
3310             * @param groupId the group ID
3311             * @param folderId the folder ID
3312             * @return the number of matching document library file shortcuts
3313             * @throws SystemException if a system exception occurred
3314             */
3315            public int countByG_F(long groupId, long folderId)
3316                    throws SystemException {
3317                    Object[] finderArgs = new Object[] { groupId, folderId };
3318    
3319                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
3320                                    finderArgs, this);
3321    
3322                    if (count == null) {
3323                            StringBundler query = new StringBundler(3);
3324    
3325                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3326    
3327                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3328    
3329                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3330    
3331                            String sql = query.toString();
3332    
3333                            Session session = null;
3334    
3335                            try {
3336                                    session = openSession();
3337    
3338                                    Query q = session.createQuery(sql);
3339    
3340                                    QueryPos qPos = QueryPos.getInstance(q);
3341    
3342                                    qPos.add(groupId);
3343    
3344                                    qPos.add(folderId);
3345    
3346                                    count = (Long)q.uniqueResult();
3347                            }
3348                            catch (Exception e) {
3349                                    throw processException(e);
3350                            }
3351                            finally {
3352                                    if (count == null) {
3353                                            count = Long.valueOf(0);
3354                                    }
3355    
3356                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
3357                                            count);
3358    
3359                                    closeSession(session);
3360                            }
3361                    }
3362    
3363                    return count.intValue();
3364            }
3365    
3366            /**
3367             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
3368             *
3369             * @param groupId the group ID
3370             * @param folderId the folder ID
3371             * @return the number of matching document library file shortcuts that the user has permission to view
3372             * @throws SystemException if a system exception occurred
3373             */
3374            public int filterCountByG_F(long groupId, long folderId)
3375                    throws SystemException {
3376                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3377                            return countByG_F(groupId, folderId);
3378                    }
3379    
3380                    StringBundler query = new StringBundler(3);
3381    
3382                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3383    
3384                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3385    
3386                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3387    
3388                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3389                                    DLFileShortcut.class.getName(),
3390                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3391    
3392                    Session session = null;
3393    
3394                    try {
3395                            session = openSession();
3396    
3397                            SQLQuery q = session.createSQLQuery(sql);
3398    
3399                            q.addScalar(COUNT_COLUMN_NAME,
3400                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3401    
3402                            QueryPos qPos = QueryPos.getInstance(q);
3403    
3404                            qPos.add(groupId);
3405    
3406                            qPos.add(folderId);
3407    
3408                            Long count = (Long)q.uniqueResult();
3409    
3410                            return count.intValue();
3411                    }
3412                    catch (Exception e) {
3413                            throw processException(e);
3414                    }
3415                    finally {
3416                            closeSession(session);
3417                    }
3418            }
3419    
3420            /**
3421             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
3422             *
3423             * @param groupId the group ID
3424             * @param folderId the folder ID
3425             * @param status the status
3426             * @return the number of matching document library file shortcuts
3427             * @throws SystemException if a system exception occurred
3428             */
3429            public int countByG_F_S(long groupId, long folderId, int status)
3430                    throws SystemException {
3431                    Object[] finderArgs = new Object[] { groupId, folderId, status };
3432    
3433                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_S,
3434                                    finderArgs, this);
3435    
3436                    if (count == null) {
3437                            StringBundler query = new StringBundler(4);
3438    
3439                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3440    
3441                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3442    
3443                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3444    
3445                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3446    
3447                            String sql = query.toString();
3448    
3449                            Session session = null;
3450    
3451                            try {
3452                                    session = openSession();
3453    
3454                                    Query q = session.createQuery(sql);
3455    
3456                                    QueryPos qPos = QueryPos.getInstance(q);
3457    
3458                                    qPos.add(groupId);
3459    
3460                                    qPos.add(folderId);
3461    
3462                                    qPos.add(status);
3463    
3464                                    count = (Long)q.uniqueResult();
3465                            }
3466                            catch (Exception e) {
3467                                    throw processException(e);
3468                            }
3469                            finally {
3470                                    if (count == null) {
3471                                            count = Long.valueOf(0);
3472                                    }
3473    
3474                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_S,
3475                                            finderArgs, count);
3476    
3477                                    closeSession(session);
3478                            }
3479                    }
3480    
3481                    return count.intValue();
3482            }
3483    
3484            /**
3485             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
3486             *
3487             * @param groupId the group ID
3488             * @param folderId the folder ID
3489             * @param status the status
3490             * @return the number of matching document library file shortcuts that the user has permission to view
3491             * @throws SystemException if a system exception occurred
3492             */
3493            public int filterCountByG_F_S(long groupId, long folderId, int status)
3494                    throws SystemException {
3495                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3496                            return countByG_F_S(groupId, folderId, status);
3497                    }
3498    
3499                    StringBundler query = new StringBundler(4);
3500    
3501                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3502    
3503                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3504    
3505                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3506    
3507                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3508    
3509                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3510                                    DLFileShortcut.class.getName(),
3511                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3512    
3513                    Session session = null;
3514    
3515                    try {
3516                            session = openSession();
3517    
3518                            SQLQuery q = session.createSQLQuery(sql);
3519    
3520                            q.addScalar(COUNT_COLUMN_NAME,
3521                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3522    
3523                            QueryPos qPos = QueryPos.getInstance(q);
3524    
3525                            qPos.add(groupId);
3526    
3527                            qPos.add(folderId);
3528    
3529                            qPos.add(status);
3530    
3531                            Long count = (Long)q.uniqueResult();
3532    
3533                            return count.intValue();
3534                    }
3535                    catch (Exception e) {
3536                            throw processException(e);
3537                    }
3538                    finally {
3539                            closeSession(session);
3540                    }
3541            }
3542    
3543            /**
3544             * Returns the number of document library file shortcuts.
3545             *
3546             * @return the number of document library file shortcuts
3547             * @throws SystemException if a system exception occurred
3548             */
3549            public int countAll() throws SystemException {
3550                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3551                                    FINDER_ARGS_EMPTY, this);
3552    
3553                    if (count == null) {
3554                            Session session = null;
3555    
3556                            try {
3557                                    session = openSession();
3558    
3559                                    Query q = session.createQuery(_SQL_COUNT_DLFILESHORTCUT);
3560    
3561                                    count = (Long)q.uniqueResult();
3562                            }
3563                            catch (Exception e) {
3564                                    throw processException(e);
3565                            }
3566                            finally {
3567                                    if (count == null) {
3568                                            count = Long.valueOf(0);
3569                                    }
3570    
3571                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3572                                            FINDER_ARGS_EMPTY, count);
3573    
3574                                    closeSession(session);
3575                            }
3576                    }
3577    
3578                    return count.intValue();
3579            }
3580    
3581            /**
3582             * Initializes the document library file shortcut persistence.
3583             */
3584            public void afterPropertiesSet() {
3585                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3586                                            com.liferay.portal.util.PropsUtil.get(
3587                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
3588    
3589                    if (listenerClassNames.length > 0) {
3590                            try {
3591                                    List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
3592    
3593                                    for (String listenerClassName : listenerClassNames) {
3594                                            listenersList.add((ModelListener<DLFileShortcut>)InstanceFactory.newInstance(
3595                                                            listenerClassName));
3596                                    }
3597    
3598                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3599                            }
3600                            catch (Exception e) {
3601                                    _log.error(e);
3602                            }
3603                    }
3604            }
3605    
3606            public void destroy() {
3607                    EntityCacheUtil.removeCache(DLFileShortcutImpl.class.getName());
3608                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3609                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3610            }
3611    
3612            @BeanReference(type = DLContentPersistence.class)
3613            protected DLContentPersistence dlContentPersistence;
3614            @BeanReference(type = DLFileEntryPersistence.class)
3615            protected DLFileEntryPersistence dlFileEntryPersistence;
3616            @BeanReference(type = DLFileEntryMetadataPersistence.class)
3617            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
3618            @BeanReference(type = DLFileEntryTypePersistence.class)
3619            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
3620            @BeanReference(type = DLFileRankPersistence.class)
3621            protected DLFileRankPersistence dlFileRankPersistence;
3622            @BeanReference(type = DLFileShortcutPersistence.class)
3623            protected DLFileShortcutPersistence dlFileShortcutPersistence;
3624            @BeanReference(type = DLFileVersionPersistence.class)
3625            protected DLFileVersionPersistence dlFileVersionPersistence;
3626            @BeanReference(type = DLFolderPersistence.class)
3627            protected DLFolderPersistence dlFolderPersistence;
3628            @BeanReference(type = DLSyncPersistence.class)
3629            protected DLSyncPersistence dlSyncPersistence;
3630            @BeanReference(type = ResourcePersistence.class)
3631            protected ResourcePersistence resourcePersistence;
3632            @BeanReference(type = UserPersistence.class)
3633            protected UserPersistence userPersistence;
3634            @BeanReference(type = AssetEntryPersistence.class)
3635            protected AssetEntryPersistence assetEntryPersistence;
3636            @BeanReference(type = AssetTagPersistence.class)
3637            protected AssetTagPersistence assetTagPersistence;
3638            private static final String _SQL_SELECT_DLFILESHORTCUT = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut";
3639            private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ";
3640            private static final String _SQL_COUNT_DLFILESHORTCUT = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut";
3641            private static final String _SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut WHERE ";
3642            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileShortcut.uuid IS NULL";
3643            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileShortcut.uuid = ?";
3644            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?)";
3645            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
3646            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileShortcut.uuid = ? AND ";
3647            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?) AND ";
3648            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileShortcut.groupId = ?";
3649            private static final String _FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2 = "dlFileShortcut.toFileEntryId = ?";
3650            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3651            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileShortcut.folderId = ?";
3652            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3653            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
3654            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "dlFileShortcut.status = ?";
3655            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileShortcut.fileShortcutId";
3656            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT DISTINCT {dlFileShortcut.*} FROM DLFileShortcut dlFileShortcut WHERE ";
3657            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1 =
3658                    "SELECT {DLFileShortcut.*} FROM (SELECT DISTINCT dlFileShortcut.fileShortcutId FROM DLFileShortcut dlFileShortcut WHERE ";
3659            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2 =
3660                    ") TEMP_TABLE INNER JOIN DLFileShortcut ON TEMP_TABLE.fileShortcutId = DLFileShortcut.fileShortcutId";
3661            private static final String _FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(DISTINCT dlFileShortcut.fileShortcutId) AS COUNT_VALUE FROM DLFileShortcut dlFileShortcut WHERE ";
3662            private static final String _FILTER_ENTITY_ALIAS = "dlFileShortcut";
3663            private static final String _FILTER_ENTITY_TABLE = "DLFileShortcut";
3664            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileShortcut.";
3665            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileShortcut.";
3666            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileShortcut exists with the primary key ";
3667            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileShortcut exists with the key {";
3668            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3669            private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
3670            private static DLFileShortcut _nullDLFileShortcut = new DLFileShortcutImpl() {
3671                            @Override
3672                            public Object clone() {
3673                                    return this;
3674                            }
3675    
3676                            @Override
3677                            public CacheModel<DLFileShortcut> toCacheModel() {
3678                                    return _nullDLFileShortcutCacheModel;
3679                            }
3680                    };
3681    
3682            private static CacheModel<DLFileShortcut> _nullDLFileShortcutCacheModel = new CacheModel<DLFileShortcut>() {
3683                            public DLFileShortcut toEntityModel() {
3684                                    return _nullDLFileShortcut;
3685                            }
3686                    };
3687    }