001    /**
002     * Copyright (c) 2000-present 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.trash.test;
016    
017    import com.liferay.portal.model.ClassedModel;
018    import com.liferay.portlet.asset.model.AssetEntry;
019    import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
020    
021    /**
022     * @author Cristina Gonz??lez
023     */
024    public class DefaultWhenIsAssetable implements WhenIsAssetable {
025    
026            @Override
027            public AssetEntry fetchAssetEntry(ClassedModel classedModel)
028                    throws Exception {
029    
030                    Class<?> modelClass = classedModel.getModelClass();
031    
032                    return AssetEntryLocalServiceUtil.fetchEntry(
033                            modelClass.getName(), (Long)classedModel.getPrimaryKeyObj());
034            }
035    
036            @Override
037            public boolean isAssetEntryVisible(ClassedModel classedModel, long classPK)
038                    throws Exception {
039    
040                    AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(
041                            classedModel.getModelClassName(), classPK);
042    
043                    return assetEntry.isVisible();
044            }
045    
046    }