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