You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2011/04/07 05:02:35 UTC
svn commit: r1089713 - in
/portals/jetspeed-2/applications/j2-admin/trunk/src/main:
java/org/apache/jetspeed/portlets/clone/ webapp/WEB-INF/view/prm/
Author: woonsan
Date: Thu Apr 7 03:02:35 2011
New Revision: 1089713
URL: http://svn.apache.org/viewvc?rev=1089713&view=rev
Log:
JS2-1247: Invoking portlet cloning on registry
Modified:
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java?rev=1089713&r1=1089712&r2=1089713&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/ClonePortletInfo.java Thu Apr 7 03:02:35 2011
@@ -24,6 +24,7 @@ public class ClonePortletInfo implements
{
private static final long serialVersionUID = 1L;
+ private String originalPortletUniqueName;
private String portletName;
private String portletDisplayName;
private String portletTitle;
@@ -31,6 +32,16 @@ public class ClonePortletInfo implements
private String portletKeywords;
private Map<String, List<String>> portletPreferences;
+ public String getOriginalPortletUniqueName()
+ {
+ return originalPortletUniqueName;
+ }
+
+ public void setOriginalPortletUniqueName(String originalPortletUniqueName)
+ {
+ this.originalPortletUniqueName = originalPortletUniqueName;
+ }
+
public String getPortletName()
{
return portletName;
Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java?rev=1089713&r1=1089712&r2=1089713&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java Thu Apr 7 03:02:35 2011
@@ -35,6 +35,7 @@ import javax.portlet.RenderResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.components.portletregistry.FailedToStorePortletDefinitionException;
import org.apache.jetspeed.components.portletregistry.PortletRegistry;
import org.apache.jetspeed.om.portlet.PortletDefinition;
import org.apache.jetspeed.om.portlet.Preference;
@@ -65,21 +66,22 @@ public class PortletCloneManagerPortlet
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
{
RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
- String portletUniqueId = rc.getRequestParameter("portlet");
+ String portletUniqueName = rc.getRequestParameter("portlet");
PortletDefinition def = null;
- if (!StringUtils.isBlank(portletUniqueId))
+ if (!StringUtils.isBlank(portletUniqueName))
{
- def = registry.getPortletDefinitionByUniqueName(portletUniqueId);
+ def = registry.getPortletDefinitionByUniqueName(portletUniqueName);
}
if (def == null)
{
- log.error("Cannot find the portlet or clone: {}", portletUniqueId);
+ log.error("Cannot find the portlet or clone: {}", portletUniqueName);
}
else
{
ClonePortletInfo clonePortletInfo = new ClonePortletInfo();
+ clonePortletInfo.setOriginalPortletUniqueName(portletUniqueName);
clonePortletInfo.setPortletName(def.getPortletName());
clonePortletInfo.setPortletDisplayName(def.getDisplayNameText(Locale.getDefault()));
clonePortletInfo.setPortletTitle(def.getPortletInfo().getTitle());
@@ -109,12 +111,38 @@ public class PortletCloneManagerPortlet
if ("clone".equals(action))
{
ClonePortletInfo clonePortletInfo = readClonePortletInfoFromRequest(request);
+ PortletDefinition def = registry.getPortletDefinitionByUniqueName(clonePortletInfo.getOriginalPortletUniqueName());
+
+ if (def == null)
+ {
+ log.error("Cannot find the portlet or clone: {}", clonePortletInfo.getOriginalPortletUniqueName());
+ }
+ else
+ {
+ if (!StringUtils.isBlank(clonePortletInfo.getPortletName()))
+ {
+ try
+ {
+ PortletDefinition clone = registry.clonePortletDefinition(def, StringUtils.trim(clonePortletInfo.getPortletName()));
+ clone.getPortletInfo().setTitle(StringUtils.defaultString(clonePortletInfo.getPortletTitle()));
+ clone.getPortletInfo().setShortTitle(StringUtils.defaultString(clonePortletInfo.getPortletShortTitle()));
+ clone.getPortletInfo().setKeywords(StringUtils.defaultString(clonePortletInfo.getPortletKeywords()));
+ // TODO displayName, preferences..
+ registry.savePortletDefinition(clone);
+ }
+ catch (FailedToStorePortletDefinitionException e)
+ {
+ log.error("Failed to clone portlet from " + clonePortletInfo.getOriginalPortletUniqueName() + " to " + clonePortletInfo.getPortletName(), e);
+ }
+ }
+ }
}
}
private ClonePortletInfo readClonePortletInfoFromRequest(ActionRequest request)
{
ClonePortletInfo clonePortletInfo = new ClonePortletInfo();
+ clonePortletInfo.setOriginalPortletUniqueName(request.getParameter("originalPortletUniqueName"));
clonePortletInfo.setPortletName(request.getParameter("portlet_name"));
clonePortletInfo.setPortletDisplayName(request.getParameter("portlet_displayName"));
clonePortletInfo.setPortletTitle(request.getParameter("portlet_title"));
Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp?rev=1089713&r1=1089712&r2=1089713&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp Thu Apr 7 03:02:35 2011
@@ -106,6 +106,7 @@ limitations under the License.
<th class="portlet-section-alternate" colspan="2">
<input type="submit" value="<fmt:message key='portlet.clone.label.action.clone'/>" />
<input type="hidden" name="action" value="clone" />
+ <input type="hidden" name="originalPortletUniqueName" value="<c:out value='${clonePortletInfo.originalPortletUniqueName}'/>" />
</th>
</tr>
</tbody>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org