1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.social.model.impl;
16  
17  import com.liferay.portal.theme.ThemeDisplay;
18  import com.liferay.portlet.social.model.SocialRequest;
19  import com.liferay.portlet.social.model.SocialRequestFeedEntry;
20  import com.liferay.portlet.social.model.SocialRequestInterpreter;
21  
22  import java.util.HashSet;
23  import java.util.Set;
24  
25  /**
26   * <a href="SocialRequestInterpreterImpl.java.html"><b><i>View Source</i></b>
27   * </a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class SocialRequestInterpreterImpl
32      implements SocialRequestInterpreter {
33  
34      public SocialRequestInterpreterImpl(
35          String portletId, SocialRequestInterpreter requestInterpreter) {
36  
37          _portletId = portletId;
38          _requestInterpreter = requestInterpreter;
39  
40          String[] classNames = _requestInterpreter.getClassNames();
41  
42          for (String className : classNames) {
43              _classNames.add(className);
44          }
45      }
46  
47      public String[] getClassNames() {
48          return _requestInterpreter.getClassNames();
49      }
50  
51      public String getPortletId() {
52          return _portletId;
53      }
54  
55      public boolean hasClassName(String className) {
56          if (_classNames.contains(className)) {
57              return true;
58          }
59          else {
60              return false;
61          }
62      }
63  
64      public SocialRequestFeedEntry interpret(
65          SocialRequest request, ThemeDisplay themeDisplay) {
66  
67          return _requestInterpreter.interpret(
68              request, themeDisplay);
69      }
70  
71      public boolean processConfirmation(
72          SocialRequest request, ThemeDisplay themeDisplay) {
73  
74          return _requestInterpreter.processConfirmation(
75              request, themeDisplay);
76      }
77  
78      public boolean processRejection(
79          SocialRequest request, ThemeDisplay themeDisplay) {
80  
81          return _requestInterpreter.processRejection(request, themeDisplay);
82      }
83  
84      private String _portletId;
85      private SocialRequestInterpreter _requestInterpreter;
86      private Set<String> _classNames = new HashSet<String>();
87  
88  }