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.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.service.ServiceContext;
020    import com.liferay.portlet.social.model.SocialActivity;
021    import com.liferay.portlet.social.model.SocialActivityFeedEntry;
022    import com.liferay.portlet.social.model.SocialActivityInterpreter;
023    import com.liferay.portlet.social.model.SocialActivitySet;
024    
025    import java.util.HashSet;
026    import java.util.Set;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public class SocialActivityInterpreterImpl
032            implements SocialActivityInterpreter {
033    
034            public SocialActivityInterpreterImpl(
035                    String portletId, SocialActivityInterpreter activityInterpreter) {
036    
037                    _portletId = portletId;
038                    _activityInterpreter = activityInterpreter;
039    
040                    String[] classNames = _activityInterpreter.getClassNames();
041    
042                    for (String className : classNames) {
043                            _classNames.add(className);
044                    }
045            }
046    
047            public String[] getClassNames() {
048                    return _activityInterpreter.getClassNames();
049            }
050    
051            public String getPortletId() {
052                    return _portletId;
053            }
054    
055            public String getSelector() {
056                    return _activityInterpreter.getSelector();
057            }
058    
059            public boolean hasClassName(String className) {
060                    if (_classNames.contains(className)) {
061                            return true;
062                    }
063                    else {
064                            return false;
065                    }
066            }
067    
068            public SocialActivityFeedEntry interpret(
069                    SocialActivity activity, ServiceContext serviceContext) {
070    
071                    return _activityInterpreter.interpret(activity, serviceContext);
072            }
073    
074            public SocialActivityFeedEntry interpret(
075                    SocialActivitySet activitySet, ServiceContext serviceContext) {
076    
077                    return _activityInterpreter.interpret(activitySet, serviceContext);
078            }
079    
080            public void updateActivitySet(long activityId)
081                    throws PortalException, SystemException {
082    
083                    _activityInterpreter.updateActivitySet(activityId);
084            }
085    
086            private SocialActivityInterpreter _activityInterpreter;
087            private Set<String> _classNames = new HashSet<String>();
088            private String _portletId;
089    
090    }