001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.messageboards.model.impl;
016    
017    import com.liferay.portal.model.Lock;
018    import com.liferay.portal.service.LockLocalServiceUtil;
019    import com.liferay.portlet.messageboards.model.MBThread;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Mika Koivisto
024     */
025    public class MBThreadImpl extends MBThreadModelImpl implements MBThread {
026    
027            public MBThreadImpl() {
028            }
029    
030            public String getAttachmentsDir() {
031                    return "messageboards/" + getThreadId();
032            }
033    
034            public Lock getLock() {
035                    try {
036                            return LockLocalServiceUtil.getLock(
037                                    MBThread.class.getName(), getThreadId());
038                    }
039                    catch (Exception e) {
040                    }
041    
042                    return null;
043            }
044    
045            public boolean hasLock(long userId) {
046                    try {
047                            return LockLocalServiceUtil.hasLock(
048                                    userId, MBThread.class.getName(), getThreadId());
049                    }
050                    catch (Exception e) {
051                    }
052    
053                    return false;
054            }
055    
056            public boolean isLocked() {
057                    try {
058                            return LockLocalServiceUtil.isLocked(
059                                    MBThread.class.getName(), getThreadId());
060                    }
061                    catch (Exception e) {
062                    }
063    
064                    return false;
065            }
066    
067    }