KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > app > portlet > AlfrescoDefaultViewSelector


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.app.portlet;
18
19 import javax.portlet.PortletContext;
20 import javax.portlet.PortletException;
21 import javax.portlet.RenderRequest;
22 import javax.portlet.RenderResponse;
23
24 import org.alfresco.service.cmr.security.PermissionService;
25 import org.alfresco.web.app.servlet.AuthenticationHelper;
26 import org.alfresco.web.bean.repository.User;
27 import org.apache.myfaces.portlet.DefaultViewSelector;
28
29 /**
30  * @author Kevin Roast
31  */

32 public class AlfrescoDefaultViewSelector implements DefaultViewSelector
33 {
34    /**
35     * Select the appropriate view ID
36     */

37    public String JavaDoc selectViewId(RenderRequest request, RenderResponse response) throws PortletException
38    {
39       User user = (User)request.getPortletSession().getAttribute(AuthenticationHelper.AUTHENTICATION_USER);
40       if (user != null && user.getUserName().equals(PermissionService.GUEST_AUTHORITY))
41       {
42          return "/jsp/browse/browse.jsp";
43       }
44       else
45       {
46          return null;
47       }
48    }
49    
50    /**
51     * @see org.apache.myfaces.portlet.DefaultViewSelector#setPortletContext(javax.portlet.PortletContext)
52     */

53    public void setPortletContext(PortletContext portletContext)
54    {
55    }
56 }
57
Popular Tags