1 /* 2 * Copyright 2003,2004,2005 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.pluto.portlet.admin.controller; 17 18 import java.io.IOException; 19 20 import javax.portlet.ActionRequest; 21 import javax.portlet.ActionResponse; 22 import javax.portlet.PortletException; 23 import javax.portlet.RenderRequest; 24 import javax.portlet.RenderResponse; 25 26 import org.apache.pluto.portlet.admin.services.PortletRegistryService; 27 28 29 /*** 30 * Portlet concerned with portletentityregistry.xml persistence. 31 * 32 * @author Craig Doremus 33 * 34 */ 35 public class PortletEntityRegistryPortlet extends ControllerPortlet { 36 private PortletRegistryService service; 37 /* (non-Javadoc) 38 * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse) 39 */ 40 protected void doEdit(RenderRequest request, RenderResponse response) 41 throws PortletException, IOException { 42 log("Edit Mode"); 43 super.doEdit(request, response); 44 } 45 /* (non-Javadoc) 46 * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse) 47 */ 48 protected void doView(RenderRequest request, RenderResponse response) 49 throws PortletException, IOException { 50 log("View Mode"); 51 String perPath = getPortletRegistryFilePath(); 52 log("PER file path = " + perPath); 53 //get the new registry list and add to session 54 service.getPortletEntityRegistry(request); 55 super.doView(request, response); 56 } 57 /* (non-Javadoc) 58 * @see javax.portlet.GenericPortlet#init() 59 */ 60 public void init() throws PortletException { 61 super.init(); 62 service = new PortletRegistryService(); 63 } 64 /* (non-Javadoc) 65 * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse) 66 */ 67 protected void doHelp(RenderRequest request, RenderResponse response) 68 throws PortletException, IOException { 69 log("Help Mode"); 70 super.doHelp(request, response); 71 } 72 /* (non-Javadoc) 73 * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse) 74 */ 75 public void processAction(ActionRequest request, ActionResponse response) 76 throws PortletException, IOException { 77 String action = request.getParameter("action"); 78 log("action param == " + action); 79 /*//TODO: Implement editing 80 printParams(request); 81 if (action == null) { 82 ;//so we don't have to do null checks later 83 response.setPortletMode(PortletMode.EDIT); 84 } else if (action.equals("showportlet")) { 85 //Edit link clicked on View page 86 service.getPortletEntityRegistryApp(request); 87 // delegate.getPortletEntityRegistryApp(perPath, request, response); 88 _incEdit = "/PortletEntityRegistryEdit.jsp"; 89 response.setPortletMode(PortletMode.EDIT); 90 } else if (action.equals("addportlet")) { 91 //Add Portlet button on View page clicked 92 // delegate.addPortletEntityRegistryApp(perPath, request, response); 93 _incEdit = "/PortletEntityRegistryEdit.jsp"; 94 response.setPortletMode(PortletMode.EDIT); 95 } else if (action.equals("showprefs")) { 96 //show portlet preferences 97 String appId = request.getParameter("appId"); 98 String portletId = request.getParameter("portletId"); 99 // delegate.getPortletPreferences(perPath, request, response); 100 service.getPortletPreferences(request); 101 _incEdit = "/PERPortletPreferencesEdit.jsp?appId=" + appId + "&portletId=" + portletId; 102 response.setPortletMode(PortletMode.EDIT); 103 } else if (action.equals("addpref")) { 104 //add a portlet preference name/value pair 105 String appId = request.getParameter("appId"); 106 String portletId = request.getParameter("portletId"); 107 // delegate.addPortletPreference(perPath, request, response); 108 _incEdit = "/PERPortletPreferencesEdit.jsp?appId=" + appId + "&portletId=" + portletId; 109 response.setPortletMode(PortletMode.EDIT); 110 } else if (action.equals("addportlettoapp")) { 111 //Add a portlet to App on Edit page 112 //add a portlet preference name/value pair 113 String appId = request.getParameter("appId"); 114 String portletId = request.getParameter("portletId"); 115 // delegate.addPortlet(perPath, request, response); 116 _incEdit = "/PortletEntityRegistryEdit.jsp"; 117 response.setPortletMode(PortletMode.EDIT); 118 } else if (action.equals("savepref")) { 119 //Button clicked on Preference Edit page 120 String submit = request.getParameter("submit"); 121 log("Button clicked: " + submit); 122 //ignore Cancel button 123 if (submit.equalsIgnoreCase("OK")) { 124 //add the pref data to the session 125 // delegate.savePreference(perPath, request, response); 126 } 127 _incEdit = "/PortletEntityRegistryEdit.jsp"; 128 response.setPortletMode(PortletMode.EDIT); 129 } else if (action.equals("saveportlet")) { 130 String submit = request.getParameter("submit"); 131 log("Button clicked: " + submit); 132 //ignore Cancel button 133 //Save button clicked on Edit page 134 if (submit.equalsIgnoreCase("Save")) { 135 //Save the portlet data to portletentityregistry.xml 136 // delegate.savePortlet(perPath, request, response); 137 } 138 _incView = "/PortletEntityRegistryView.jsp"; 139 response.setPortletMode(PortletMode.VIEW); 140 } 141 printParams(request); 142 */ 143 } 144 }