001    /**
002     * Copyright (c) 2000-2013 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 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    }