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 we...@apache.org on 2004/06/10 22:19:26 UTC
cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity JetspeedPowerTool.java
weaver 2004/06/10 13:19:26
Modified: portal/src/java/org/apache/jetspeed/velocity
JetspeedPowerTool.java
Log:
- Added more exception handling
- Add auto generation of non-existent portlet entities
Revision Changes Path
1.16 +68 -15 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
Index: JetspeedPowerTool.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- JetspeedPowerTool.java 25 May 2004 01:37:12 -0000 1.15
+++ JetspeedPowerTool.java 10 Jun 2004 20:19:26 -0000 1.16
@@ -42,6 +42,8 @@
import org.apache.jetspeed.capabilities.CapabilityMap;
import org.apache.jetspeed.components.ComponentManager;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
+import org.apache.jetspeed.components.portletentity.PortletEntityNotGeneratedException;
+import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
import org.apache.jetspeed.container.session.NavigationalState;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
import org.apache.jetspeed.locator.LocatorDescriptor;
@@ -52,7 +54,6 @@
import org.apache.jetspeed.om.page.Page;
import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.services.information.PortletURLProviderImpl;
-import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.pluto.Constants;
import org.apache.pluto.om.entity.PortletEntity;
import org.apache.velocity.context.Context;
@@ -92,6 +93,18 @@
*/
public class JetspeedPowerTool implements ViewTool
{
+
+ private static final int ACTION_MINIMIZE = 0;
+ private static final int ACTION_MAXIMIZE = 1;
+ private static final int ACTION_NORMAL = 2;
+ private static final int ACTION_VIEW = 3;
+ private static final int ACTION_EDIT = 4;
+ private static final int ACTION_HELP = 5;
+ private static final String ACTION_STRINGS[] =
+ {
+ "minimize", "maximize", "restore", "view", "edit", "help"
+ };
+
protected static final String PORTLET_CONFIG_ATTR = "portletConfig";
protected static final String RENDER_RESPONSE_ATTR = "renderResponse";
protected static final String RENDER_REQUEST_ATTR = "renderRequest";
@@ -315,7 +328,15 @@
*/
public PortletEntity getCurrentPortletEntity()
{
- return windowAccess.getPortletWindow(getCurrentFragment()).getPortletEntity();
+ try
+ {
+ return windowAccess.getPortletWindow(getCurrentFragment()).getPortletEntity();
+ }
+ catch (Exception e)
+ {
+ handleError(e, "JetspeedPowerTool failed to retreive the current PortletEntity. "+e.toString() );
+ return null;
+ }
}
/**
@@ -323,12 +344,32 @@
* @param f Fragment whose <code>PortletEntity</code> we want to retreive.
* @return The PortletEntity represented by the current fragment.
*/
- public PortletEntity getPortletEntity(Fragment f)
+ public PortletEntity getPortletEntity(Fragment f)
{
- PortletEntity portletEntity = entityAccess.getPortletEntity(JetspeedObjectID.createFromString(f.getId()));
+ PortletEntity portletEntity = entityAccess.getPortletEntityForFragment(f);
+ if(portletEntity == null)
+ {
+ try
+ {
+ portletEntity = entityAccess.generateEntityFromFragment(f);
+ entityAccess.storePortletEntity(portletEntity);
+ }
+ catch (PortletEntityNotGeneratedException e)
+ {
+ String msg = "JetspeedPowerTool failed to retreive a PortletEntity for Fragment "+f.getId()+". "+e.toString();
+ handleError(e, msg);
+ }
+ catch (PortletEntityNotStoredException e)
+ {
+ String msg = "JetspeedPowerTool failed to store a PortletEntity for Fragment "+f.getId()+". "+e.toString();
+ handleError(e, msg);
+ }
+ }
return portletEntity;
}
+
+
/**
* This method is synonymous with the following code:
* <p>
@@ -605,18 +646,30 @@
throw e;
}
}
+
+ /**
+ * <p>
+ * handleError
+ * </p>
+ *
+ * @param e
+ * @param msg
+ */
+ protected void handleError( Exception e, String msg )
+ {
+ log.error(msg, e);
+ try
+ {
+ renderResponse.getWriter().write(e.toString());
+ }
+ catch (IOException e1)
+ {
+ log.error("Failed writing to RenderResponse. "+e1.toString());
+ }
+ }
- private static final int ACTION_MINIMIZE = 0;
- private static final int ACTION_MAXIMIZE = 1;
- private static final int ACTION_NORMAL = 2;
- private static final int ACTION_VIEW = 3;
- private static final int ACTION_EDIT = 4;
- private static final int ACTION_HELP = 5;
- private static final String ACTION_STRINGS[] =
- {
- "minimize", "maximize", "restore", "view", "edit", "help"
- };
+
public List getDecoratorActions()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org