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