001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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            public String[] getClassNames() {
044                    return _requestInterpreter.getClassNames();
045            }
046    
047            public String getPortletId() {
048                    return _portletId;
049            }
050    
051            public boolean hasClassName(String className) {
052                    if (_classNames.contains(className)) {
053                            return true;
054                    }
055                    else {
056                            return false;
057                    }
058            }
059    
060            public SocialRequestFeedEntry interpret(
061                    SocialRequest request, ThemeDisplay themeDisplay) {
062    
063                    return _requestInterpreter.interpret(request, themeDisplay);
064            }
065    
066            public boolean processConfirmation(
067                    SocialRequest request, ThemeDisplay themeDisplay) {
068    
069                    return _requestInterpreter.processConfirmation(request, themeDisplay);
070            }
071    
072            public boolean processRejection(
073                    SocialRequest request, ThemeDisplay themeDisplay) {
074    
075                    return _requestInterpreter.processRejection(request, themeDisplay);
076            }
077    
078            private Set<String> _classNames = new HashSet<String>();
079            private String _portletId;
080            private SocialRequestInterpreter _requestInterpreter;
081    
082    }