001    /**
002     * Copyright (c) 2000-2013 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 MBThreadBaseImpl {
026    
027            public MBThreadImpl() {
028            }
029    
030            @Override
031            public String getAttachmentsDir() {
032                    return "messageboards/" + getThreadId();
033            }
034    
035            @Override
036            public Lock getLock() {
037                    try {
038                            return LockLocalServiceUtil.getLock(
039                                    MBThread.class.getName(), getThreadId());
040                    }
041                    catch (Exception e) {
042                    }
043    
044                    return null;
045            }
046    
047            @Override
048            public boolean hasLock(long userId) {
049                    try {
050                            return LockLocalServiceUtil.hasLock(
051                                    userId, MBThread.class.getName(), getThreadId());
052                    }
053                    catch (Exception e) {
054                    }
055    
056                    return false;
057            }
058    
059            @Override
060            public boolean isLocked() {
061                    try {
062                            return LockLocalServiceUtil.isLocked(
063                                    MBThread.class.getName(), getThreadId());
064                    }
065                    catch (Exception e) {
066                    }
067    
068                    return false;
069            }
070    
071    }