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.social.model.impl;
016    
017    import com.liferay.portal.theme.ThemeDisplay;
018    import com.liferay.portlet.social.model.SocialRequest;
019    import com.liferay.portlet.social.model.SocialRequestFeedEntry;
020    import com.liferay.portlet.social.model.SocialRequestInterpreter;
021    
022    import java.util.HashSet;
023    import java.util.Set;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class SocialRequestInterpreterImpl implements SocialRequestInterpreter {
029    
030            public SocialRequestInterpreterImpl(
031                    String portletId, SocialRequestInterpreter requestInterpreter) {
032    
033                    _portletId = portletId;
034                    _requestInterpreter = requestInterpreter;
035    
036                    String[] classNames = _requestInterpreter.getClassNames();
037    
038                    for (String className : classNames) {
039                            _classNames.add(className);
040                    }
041            }
042    
043            @Override
044            public String[] getClassNames() {
045                    return _requestInterpreter.getClassNames();
046            }
047    
048            public String getPortletId() {
049                    return _portletId;
050            }
051    
052            public boolean hasClassName(String className) {
053                    if (_classNames.contains(className)) {
054                            return true;
055                    }
056                    else {
057                            return false;
058                    }
059            }
060    
061            @Override
062            public SocialRequestFeedEntry interpret(
063                    SocialRequest request, ThemeDisplay themeDisplay) {
064    
065                    return _requestInterpreter.interpret(request, themeDisplay);
066            }
067    
068            @Override
069            public boolean processConfirmation(
070                    SocialRequest request, ThemeDisplay themeDisplay) {
071    
072                    return _requestInterpreter.processConfirmation(request, themeDisplay);
073            }
074    
075            @Override
076            public boolean processRejection(
077                    SocialRequest request, ThemeDisplay themeDisplay) {
078    
079                    return _requestInterpreter.processRejection(request, themeDisplay);
080            }
081    
082            private Set<String> _classNames = new HashSet<String>();
083            private String _portletId;
084            private SocialRequestInterpreter _requestInterpreter;
085    
086    }