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.taglib.util;
016    
017    import com.liferay.portal.kernel.util.ListUtil;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portlet.expando.model.ExpandoBridge;
020    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
021    
022    import java.util.Collections;
023    import java.util.List;
024    
025    /**
026     * @author Eudaldo Alonso
027     */
028    public class CustomAttributesUtil {
029    
030            public static boolean hasCustomAttributes(
031                            long companyId, String className, long classPK,
032                            String ignoreAttributeNames)
033                    throws Exception {
034    
035                    ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(
036                            companyId, className, classPK);
037    
038                    List<String> attributeNames = ListUtil.remove(
039                            Collections.list(expandoBridge.getAttributeNames()),
040                            ListUtil.fromString(ignoreAttributeNames, StringPool.COMMA));
041    
042                    if (ListUtil.isEmpty(attributeNames)) {
043                            return false;
044                    }
045    
046                    return true;
047            }
048    
049    }