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            @Override
048            public String[] getClassNames() {
049                    return _activityInterpreter.getClassNames();
050            }
051    
052            public String getPortletId() {
053                    return _portletId;
054            }
055    
056            @Override
057            public String getSelector() {
058                    return _activityInterpreter.getSelector();
059            }
060    
061            public boolean hasClassName(String className) {
062                    if (_classNames.contains(className)) {
063                            return true;
064                    }
065                    else {
066                            return false;
067                    }
068            }
069    
070            @Override
071            public SocialActivityFeedEntry interpret(
072                    SocialActivity activity, ServiceContext serviceContext) {
073    
074                    return _activityInterpreter.interpret(activity, serviceContext);
075            }
076    
077            @Override
078            public SocialActivityFeedEntry interpret(
079                    SocialActivitySet activitySet, ServiceContext serviceContext) {
080    
081                    return _activityInterpreter.interpret(activitySet, serviceContext);
082            }
083    
084            @Override
085            public void updateActivitySet(long activityId)
086                    throws PortalException, SystemException {
087    
088                    _activityInterpreter.updateActivitySet(activityId);
089            }
090    
091            private SocialActivityInterpreter _activityInterpreter;
092            private Set<String> _classNames = new HashSet<String>();
093            private String _portletId;
094    
095    }