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.documentlibrary.model.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
020    import com.liferay.portlet.documentlibrary.model.DLFileVersion;
021    import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
022    import com.liferay.portlet.documentlibrary.util.DLUtil;
023    import com.liferay.portlet.expando.model.ExpandoBridge;
024    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
025    
026    /**
027     * @author Jorge Ferrer
028     */
029    public class DLFileVersionImpl
030            extends DLFileVersionModelImpl implements DLFileVersion {
031    
032            public DLFileVersionImpl() {
033            }
034    
035            public ExpandoBridge getExpandoBridge() {
036                    if (_expandoBridge == null) {
037                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(
038                                    getCompanyId(), DLFileEntry.class.getName(), getPrimaryKey());
039                    }
040    
041                    return _expandoBridge;
042            }
043    
044            public DLFileEntry getFileEntry() throws PortalException, SystemException {
045                    return DLFileEntryLocalServiceUtil.getFileEntry(
046                            getGroupId(), getFolderId(), getName());
047            }
048    
049            public String getIcon() {
050                    return DLUtil.getFileIcon(getExtension());
051            }
052    
053            private ExpandoBridge _expandoBridge;
054    
055    }