001    /**
002     * Copyright (c) 2000-2012 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.MBMessageConstants;
020    import com.liferay.portlet.messageboards.model.MBThread;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     * @author Mika Koivisto
025     */
026    public class MBThreadImpl extends MBThreadBaseImpl {
027    
028            public MBThreadImpl() {
029            }
030    
031            public String getAttachmentsDir() {
032                    return MBMessageConstants.BASE_ATTACHMENTS_DIR + getThreadId();
033            }
034    
035            public Lock getLock() {
036                    try {
037                            return LockLocalServiceUtil.getLock(
038                                    MBThread.class.getName(), getThreadId());
039                    }
040                    catch (Exception e) {
041                    }
042    
043                    return null;
044            }
045    
046            public boolean hasLock(long userId) {
047                    try {
048                            return LockLocalServiceUtil.hasLock(
049                                    userId, MBThread.class.getName(), getThreadId());
050                    }
051                    catch (Exception e) {
052                    }
053    
054                    return false;
055            }
056    
057            public boolean isLocked() {
058                    try {
059                            return LockLocalServiceUtil.isLocked(
060                                    MBThread.class.getName(), getThreadId());
061                    }
062                    catch (Exception e) {
063                    }
064    
065                    return false;
066            }
067    
068    }