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