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