You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by dl...@apache.org on 2006/11/22 13:40:43 UTC
svn commit: r478151 - in /portals/wsrp4j/trunk/consumer-proxyportlet/src:
java/org/apache/wsrp4j/consumer/configportlet/controller/
java/org/apache/wsrp4j/consumer/configportlet/model/delegate/
java/org/apache/wsrp4j/consumer/configportlet/model/delega...
Author: dlouzan
Date: Wed Nov 22 04:40:42 2006
New Revision: 478151
URL: http://svn.apache.org/viewvc?view=rev&rev=478151
Log:
ConfigPortlet: added support for editing portlets
Added a link on each of the jsp's to the root page
Added:
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditPortlet.jsp
Modified:
portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java
portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/DeployPortletDelegate.java
portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java
portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/services/DeployPortletService.java
portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/util/Constants.java
portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddPortlet.jsp
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddProducer.jsp
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditProducer.jsp
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showPortlet.jsp
portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showProducer.jsp
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java Wed Nov 22 04:40:42 2006
@@ -94,6 +94,9 @@
} else if (action.equals(Constants.ACTION_SHOW_ADD_PORTLET)) {
service.showAddPortlet(request);
delegateToJSP(request, response, "/jsp/configportlet/showAddPortlet.jsp");
+ } else if (action.equals(Constants.ACTION_SHOW_EDIT_PORTLET)) {
+ service.showUpdatePortlet(request);
+ delegateToJSP(request, response, "/jsp/configportlet/showEditPortlet.jsp");
}
} catch (ConfigPortletException e) {
@@ -121,6 +124,8 @@
service.processAddPortlet(request, response);
} else if (action.equals(Constants.ACTION_DELETE_PORTLET)) {
service.processDeletePortlet(request, response);
+ } else if (action.equals(Constants.ACTION_UPDATE_PORTLET)) {
+ service.processUpdatePortlet(request, response);
}
} catch (ConfigPortletException e) {
throw new PortletException(e);
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/DeployPortletDelegate.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/DeployPortletDelegate.java?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/DeployPortletDelegate.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/DeployPortletDelegate.java Wed Nov 22 04:40:42 2006
@@ -45,4 +45,7 @@
public void deletePortlet(String id)
throws PortletNotFoundException, ConfigPortletException;
+ public void updatePortlet(PortletTO portletTO)
+ throws PortletNotFoundException, ConfigPortletException;
+
}
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java Wed Nov 22 04:40:42 2006
@@ -202,6 +202,26 @@
}
/**
+ * Updates a portlet contents. As the XML modification is difficult,
+ * we follow the delete - add strategy
+ */
+ public void updatePortlet(PortletTO portletTO)
+ throws PortletNotFoundException, ConfigPortletException {
+
+ if (!existsPortlet(portletTO.getId())) {
+ throw new PortletNotFoundException(portletTO.getId());
+ }
+
+ try {
+ deletePortlet(portletTO.getId());
+ addPortlet(portletTO);
+ } catch (DuplicatePortletException e) {
+ throw new ConfigPortletException(e);
+ }
+
+ }
+
+ /**
* Populates the PortletTO map searching on the DOM document. We could use
* a solution similar to Pluto's using castor to map the portlet.xml
* file to Java objects, but for now and as a test we do it like this
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/services/DeployPortletService.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/services/DeployPortletService.java?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/services/DeployPortletService.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/services/DeployPortletService.java Wed Nov 22 04:40:42 2006
@@ -106,6 +106,44 @@
}
+ public void showUpdatePortlet(RenderRequest request)
+ throws ConfigPortletException {
+
+ String isError = request.getParameter(Constants.PARAM_IS_ERROR);
+
+ if (isError == null) {
+ String portletId = request.getParameter(Constants.PARAM_PORTLET_ID);
+
+ try {
+ PortletTO portlet =
+ (PortletTO) delegate.findPortlet(portletId);
+
+ form = new PortletForm();
+ form.setId(portlet.getId());
+ form.setDescription(portlet.getDescription());
+ form.setDisplayName(portlet.getDisplayName());
+ form.setTitle(portlet.getTitle());
+ form.setShortTitle(portlet.getShortTitle());
+ form.setKeywords(portlet.getKeywordsAsString());
+ form.setPortletHandle(portlet.getPortletHandle());
+ form.setProducerId(portlet.getProducerId());
+
+ } catch (PortletNotFoundException e) {
+ form = null;
+ errors = new Hashtable();
+ errors.put(Constants.PARAM_PORTLET_ID,
+ Constants.ERROR_PORTLET_NOT_FOUND);
+ request.setAttribute(Constants.PARAM_PORTLET_ID,
+ Constants.ERROR_PORTLET_NOT_FOUND);
+ }
+ } else {
+ request.setAttribute(Constants.ATTR_ERRORS, errors);
+ }
+
+ request.setAttribute(Constants.ATTR_PORTLET_FORM, form);
+
+ }
+
public void processAddPortlet(ActionRequest request,
ActionResponse response)
throws ConfigPortletException {
@@ -158,6 +196,36 @@
response.setRenderParameter(Constants.PARAM_ACTION,
Constants.ACTION_SHOW_ALL_DEPLOYED_PORTLETS);
+ }
+
+ public void processUpdatePortlet(ActionRequest request,
+ ActionResponse response)
+ throws ConfigPortletException {
+
+ form = new PortletForm();
+ Map parameters = request.getParameterMap();
+ formPopulator.populate(form, parameters);
+
+ errors = form.validate();
+ if (!errors.isEmpty()) {
+ response.setRenderParameter(Constants.PARAM_ACTION,
+ Constants.ACTION_SHOW_EDIT_PORTLET);
+ response.setRenderParameter(Constants.PARAM_IS_ERROR,
+ Constants.TRUE);
+ } else {
+ try {
+ PortletTO portletTO = createPortletTO(form);
+ delegate.updatePortlet(portletTO);
+ } catch (PortletNotFoundException e) {
+ errors = new Hashtable();
+ errors.put(Constants.PARAM_PORTLET_ID,
+ Constants.ERROR_PORTLET_NOT_FOUND);
+ response.setRenderParameter(Constants.PARAM_ACTION,
+ Constants.ACTION_SHOW_EDIT_PORTLET);
+ response.setRenderParameter(Constants.PARAM_IS_ERROR,
+ Constants.TRUE);
+ }
+ }
}
private PortletTO createPortletTO(PortletForm form) {
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/util/Constants.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/util/Constants.java?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/util/Constants.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/util/Constants.java Wed Nov 22 04:40:42 2006
@@ -63,6 +63,8 @@
public static final String ACTION_SHOW_ALL_DEPLOYED_PORTLETS = "showAllDeployedPortlets";
public static final String ACTION_SHOW_PORTLET = "showPortlet";
public static final String ACTION_SHOW_ADD_PORTLET = "showAddPortlet";
+ public static final String ACTION_SHOW_EDIT_PORTLET = "showEditPortlet";
+ public static final String ACTION_UPDATE_PORTLET = "updatePortlet";
public static final String ACTION_ADD_PORTLET = "addPortlet";
public static final String ACTION_DELETE_PORTLET = "deletePortlet";
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties Wed Nov 22 04:40:42 2006
@@ -25,6 +25,7 @@
Form.addPortlet=Add Portlet
Form.createProducer=Create Producer
Form.false=False
+Form.modifyPortlet=Modify Portlet
Form.modifyProducer=Modify Producer
Form.true=True
@@ -34,6 +35,8 @@
Link.deleteProducer=Delete Producer
Link.editPortlet=Edit Portlet
Link.editProducer=Edit Producer
+Link.viewAllPortlets=View Portlets
+Link.viewAllProducers=View Producers
Portlet.id=ID
Portlet.description=Description
@@ -55,6 +58,7 @@
Title.addPortlet=Add Portlet
Title.addProducer=Add Producer
+Title.editPortlet=Edit Portlet
Title.editProducer=Edit Producer
Title.viewAllDeployedPortlets=Deployed Portlets
Title.viewAllProducers=ProxyPortlet Producers
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddPortlet.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddPortlet.jsp?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddPortlet.jsp (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddPortlet.jsp Wed Nov 22 04:40:42 2006
@@ -149,4 +149,10 @@
value="<fmt:message key='Form.addPortlet'/>"
class="portlet-form-button"/>
-</form>
\ No newline at end of file
+</form>
+
+<p class="portlet-font">
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllPortlets"/>
+ </a>
+</p>
\ No newline at end of file
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddProducer.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddProducer.jsp?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddProducer.jsp (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showAddProducer.jsp Wed Nov 22 04:40:42 2006
@@ -161,4 +161,10 @@
value="<fmt:message key='Form.createProducer'/>"
class="portlet-form-button"/>
-</form>
\ No newline at end of file
+</form>
+
+<p class="portlet-font">
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllProducers"/>
+ </a>
+</p>
\ No newline at end of file
Added: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditPortlet.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditPortlet.jsp?view=auto&rev=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditPortlet.jsp (added)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditPortlet.jsp Wed Nov 22 04:40:42 2006
@@ -0,0 +1,171 @@
+<%--
+Copyright 2003-2006 The Apache Software Foundation
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
+
+<portlet:defineObjects/>
+
+<p class="portlet-section-header">
+ <fmt:message key="Title.editPortlet"/>
+</p>
+
+<c:choose>
+
+<c:when test="${not empty portletForm}">
+
+<form action="<portlet:actionURL/>" method="post">
+
+ <input type="hidden" name="action" value="updatePortlet"/>
+
+ <table>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.id"/>
+ </td>
+ <td>
+ <c:out value="${portletForm.id}"/>
+ <input type="hidden" name="id"
+ value="<c:out value='${portletForm.id}'/>"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['id']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.description"/>
+ </td>
+ <td>
+ <input type="text" name="description"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.description}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['description']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.displayName"/>
+ </td>
+ <td>
+ <input type="text" name="displayName"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.displayName}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['displayName']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.title"/>
+ </td>
+ <td>
+ <input type="text" name="title"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.title}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['title']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.shortTitle"/>
+ </td>
+ <td>
+ <input type="text" name="shortTitle"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.shortTitle}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['shortTitle']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.keywords"/>
+ </td>
+ <td>
+ <input type="text" name="keywords"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.keywords}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['keywords']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.remoteProducer"/>
+ </td>
+ <td>
+ <input type="text" name="producerId"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.producerId}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['producerId']}"/>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td class="portlet-font">
+ <fmt:message key="Portlet.remoteHandle"/>
+ </td>
+ <td>
+ <input type="text" name="portletHandle"
+ class="portlet-form-input-field"
+ value="<c:out value='${portletForm.portletHandle}'/>"
+ size="30"/>
+ <span class="portlet-msg-error">
+ <c:out value="${errors['portletHandle']}"/>
+ </span>
+ </td>
+ </tr>
+
+ </table>
+
+ <input type="submit"
+ value="<fmt:message key='Form.modifyPortlet'/>"
+ class="portlet-form-button"/>
+
+</form>
+
+</c:when>
+
+<c:otherwise>
+ <p class="portlet-msg-error">
+ <fmt:message key="Error.portletNotFound"/>
+ </p>
+</c:otherwise>
+
+</c:choose>
+
+<p class="portlet-font">
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllPortlets"/>
+ </a>
+</p>
\ No newline at end of file
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditProducer.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditProducer.jsp?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditProducer.jsp (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showEditProducer.jsp Wed Nov 22 04:40:42 2006
@@ -177,4 +177,10 @@
</p>
</c:otherwise>
-</c:choose>
\ No newline at end of file
+</c:choose>
+
+<p class="portlet-font">
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllProducers"/>
+ </a>
+</p>
\ No newline at end of file
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showPortlet.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showPortlet.jsp?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showPortlet.jsp (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showPortlet.jsp Wed Nov 22 04:40:42 2006
@@ -121,7 +121,10 @@
<a href="<c:out value='${deletePortletURL}'/>" escapeXml="false"
onclick="return <portlet:namespace/>checkDeletePortlet()">
<fmt:message key="Link.deletePortlet"/>
- </a>
+ </a>
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllPortlets"/>
+ </a>
</p>
<c:if test="${!empty errors}">
Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showProducer.jsp
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showProducer.jsp?view=diff&rev=478151&r1=478150&r2=478151
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showProducer.jsp (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/webapp/jsp/configportlet/showProducer.jsp Wed Nov 22 04:40:42 2006
@@ -122,7 +122,10 @@
<a href="<c:out value='${deleteProducerURL}'/>" escapeXml="false"
onclick="return <portlet:namespace/>checkDeleteProducer()">
<fmt:message key="Link.deleteProducer"/>
- </a>
+ </a>
+ <a href="<portlet:renderURL/>" escapeXml="false">
+ <fmt:message key="Link.viewAllProducers"/>
+ </a>
</p>
<c:if test="${!empty errors}">