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.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    }