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