You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2007/05/06 13:18:20 UTC
svn commit: r535599 - in
/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto:
./ services/
Author: cziegeler
Date: Sun May 6 04:18:18 2007
New Revision: 535599
URL: http://svn.apache.org/viewvc?view=rev&rev=535599
Log:
Continue implementation
Added:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java (with props)
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java (with props)
Modified:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortalCallbackServiceImpl.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortalCallbackServiceImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortalCallbackServiceImpl.java?view=diff&rev=535599&r1=535598&r2=535599
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortalCallbackServiceImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortalCallbackServiceImpl.java Sun May 6 04:18:18 2007
@@ -20,6 +20,7 @@
import javax.servlet.http.HttpServletRequest;
+import org.apache.cocoon.portal.util.AbstractBean;
import org.apache.pluto.PortletWindow;
import org.apache.pluto.spi.PortalCallbackService;
import org.apache.pluto.spi.PortletURLProvider;
@@ -28,21 +29,22 @@
/**
* @version $Id$
*/
-public class PortalCallbackServiceImpl implements PortalCallbackService {
+public class PortalCallbackServiceImpl
+ extends AbstractBean
+ implements PortalCallbackService {
/**
* @see org.apache.pluto.spi.PortalCallbackService#addResponseProperty(javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow, java.lang.String, java.lang.String)
*/
public void addResponseProperty(HttpServletRequest request, PortletWindow window, String name, String value) {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
}
/**
* @see org.apache.pluto.spi.PortalCallbackService#getPortletURLProvider(javax.servlet.http.HttpServletRequest, org.apache.pluto.PortletWindow)
*/
public PortletURLProvider getPortletURLProvider(HttpServletRequest request, PortletWindow window) {
- // TODO Auto-generated method stub
- return null;
+ return new PortletURLProviderImpl(this.portalService, window, null);
}
/**
@@ -66,7 +68,7 @@
*/
public void setResponseProperty(HttpServletRequest request, PortletWindow window, String name, String value) {
// TODO Auto-generated method stub
-
+
}
/**
@@ -74,6 +76,6 @@
*/
public void setTitle(HttpServletRequest request, PortletWindow window, String title) {
// TODO Auto-generated method stub
-
+
}
}
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java?view=diff&rev=535599&r1=535598&r2=535599
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java Sun May 6 04:18:18 2007
@@ -36,42 +36,42 @@
*
* @version $Id$
*/
-public class PortletURLProviderImpl
+public class PortletURLProviderImpl
implements PortletURLProvider, CopletInstanceEvent, ConvertableEvent {
-
+
/** The new portlet mode */
protected PortletMode mode;
-
+
/** The new window state */
protected WindowState state;
-
+
/** Is this an action */
protected boolean action;
-
+
/** Secure link? */
protected Boolean secure;
-
+
/** Clear parameters */
protected boolean clearParameters;
-
+
/** Parameters */
protected Map parameters;
-
+
/** The generated url */
protected String generatedURL;
private final LinkService linkService;
/** Tbe coplet instance id. */
- protected final String copletId;
+ protected final String copletInstanceId;
/**
* Constructor
*/
- public PortletURLProviderImpl(PortletWindow portletWindow,
- PortalService service,
- String copletInstanceId) {
+ public PortletURLProviderImpl(PortalService service,
+ PortletWindow portletWindow,
+ String copletInstanceId) {
this.linkService = service.getLinkService();
- this.copletId = copletInstanceId;
+ this.copletInstanceId = copletInstanceId;
}
/**
@@ -83,7 +83,7 @@
String eventData) {
this.linkService = service.getLinkService();
final PortletURLConverter urlConverter = new PortletURLConverter(eventData);
- this.copletId = urlConverter.getCopletId();
+ this.copletInstanceId = urlConverter.getCopletId();
this.mode = urlConverter.getMode();
this.state = urlConverter.getState();
this.action = urlConverter.isAction();
@@ -97,7 +97,7 @@
*/
private PortletURLProviderImpl(PortletURLProviderImpl original) {
this.linkService = original.linkService;
- this.copletId = original.copletId;
+ this.copletInstanceId = original.copletInstanceId;
this.mode = original.mode;
this.state = original.state;
this.action = original.action;
@@ -144,7 +144,7 @@
public void setParameters(Map parameters) {
this.parameters = parameters;
}
-
+
/**
* @see java.lang.Object#toString()
*/
@@ -165,7 +165,7 @@
/**
* @see org.apache.cocoon.portal.event.CopletInstanceEvent#getTarget()
*/
- public CopletInstance getTarget() {
+ public CopletInstance getTarget() {
return null;//((PortletEntityImpl)this.portletWindow.getPortletEntity()).getCopletInstanceData();
}
@@ -175,7 +175,7 @@
*/
public String asString() {
PortletURLConverter urlConverter = new PortletURLConverter();
- urlConverter.setCopletId(this.copletId);
+ urlConverter.setCopletId(this.copletInstanceId);
if (this.mode != null) {
urlConverter.setMode(this.mode);
}
Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java?view=auto&rev=535599
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java (added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java Sun May 6 04:18:18 2007
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.pluto.services;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cocoon.components.thread.RunnableManager;
+import org.apache.cocoon.portal.event.Receiver;
+import org.apache.cocoon.portal.util.AbstractBean;
+import org.apache.pluto.spi.optional.PortletRegistryService;
+
+
+/**
+ *
+ * @version $Id$
+ */
+public class PortletDefinitionRegistryImpl
+ extends AbstractBean
+ implements Receiver, Runnable {
+
+ protected PortletRegistryService portletRegistry;
+
+ /** Wait ten seconds before scanning. */
+ protected static final int STARTUP_DELAY = 10 * 1000;
+
+ private static final String COPLET_XML = "WEB-INF/coplet.xml";
+
+ /** Our context name. */
+ protected String contextName;
+
+ /** Path to the webapp directory containing all web apps. This is used to find already
+ * deployed portlets and to deploy new portlets. */
+ protected String webAppDir;
+
+ protected String localAppDir = "conf/portlets";
+
+ /** Should we scan the webapps directory on startup? */
+ protected boolean scanOnStartup = true;
+
+ /** Create coplets. */
+ protected boolean createCoplets = true;
+
+ /** The name of the coplet base data for portlets. */
+ protected String copletBaseDataName = "Portlet";
+
+ /** The threadpool name to be used for daemon thread. */
+ protected String threadPoolName = "daemon";
+
+ /** The servlet context. */
+ protected ServletContext servletContext;
+
+ protected RunnableManager runnableManager;
+
+ /**
+ * Default constructor.
+ */
+ public PortletDefinitionRegistryImpl() {
+ // nothing to do
+ }
+
+ public void setWebAppDir(String webAppDir) {
+ this.webAppDir = webAppDir;
+ }
+
+ public void setLocalAppDir(String localAppDir) {
+ this.localAppDir = localAppDir;
+ }
+
+ public void setScanOnStartup(boolean scanOnStartup) {
+ this.scanOnStartup = scanOnStartup;
+ }
+
+ public void setCreateCoplets(boolean createCoplets) {
+ this.createCoplets = createCoplets;
+ }
+
+ public void setCopletBaseDataName(String copletBaseDataName) {
+ this.copletBaseDataName = copletBaseDataName;
+ }
+
+ public void setThreadPoolName(String threadPoolName) {
+ this.threadPoolName = threadPoolName;
+ }
+
+ public void setRunnableManager(RunnableManager runnableManager) {
+ this.runnableManager = runnableManager;
+ }
+
+ /**
+ * Initialize.
+ */
+ public void init() throws Exception {
+ if ( this.getLogger().isInfoEnabled() ) {
+ this.getLogger().info("Initializing Portlet Definition Registry.");
+ this.getLogger().info("Local application directory: " + this.localAppDir);
+ if ( this.webAppDir != null ) {
+ this.getLogger().info("Web application directory: " + this.webAppDir);
+ }
+ this.getLogger().info("Scan on startup: " + this.scanOnStartup);
+ }
+ this.servletContext = this.portalService.getProcessInfoProvider().getServletContext();
+
+ // get our context path
+ String baseWMDir = this.servletContext.getRealPath("");
+ if (baseWMDir != null) {
+ // BEGIN PATCH for IBM WebSphere
+ if (baseWMDir.endsWith(File.separator)) {
+ baseWMDir = baseWMDir.substring(0, baseWMDir.length() - 1);
+ }
+ // END PATCH for IBM WebSphere
+ int lastIndex = baseWMDir.lastIndexOf(File.separatorChar);
+ this.contextName = baseWMDir.substring(lastIndex + 1);
+ baseWMDir = baseWMDir.substring(0, lastIndex);
+ if (this.getLogger().isDebugEnabled()) {
+ this.getLogger().debug("servletContext.getRealPath('') =" + this.servletContext.getRealPath(""));
+ this.getLogger().debug("baseWMDir = " + baseWMDir);
+ }
+ }
+ if ( this.webAppDir == null ) {
+ this.webAppDir = baseWMDir;
+ }
+
+ // now check directories
+ File webAppDirFile = new File(this.webAppDir);
+
+ if (webAppDirFile.exists() && webAppDirFile.isDirectory()) {
+ try {
+ this.webAppDir = webAppDirFile.getCanonicalPath();
+ } catch (IOException e) {
+ // ignore
+ }
+ } else {
+ throw new FileNotFoundException("The depoyment directory for portlet applications \""
+ + webAppDirFile.getAbsolutePath() + "\" does not exist.");
+ }
+
+ File localAppDirFile = new File(this.localAppDir);
+ if (!localAppDirFile.exists()) {
+ localAppDirFile.mkdirs();
+ } else if (!localAppDirFile.isDirectory()) {
+ throw new FileNotFoundException("Invalid depoyment directory for local portlet applications: \""
+ + localAppDirFile.getAbsolutePath());
+ }
+ try {
+ this.localAppDir = localAppDirFile.getCanonicalPath();
+ } catch (IOException e) {
+ // ignore
+ }
+
+ // now load existing webapps/portlets
+ if ( this.scanOnStartup ) {
+ this.runnableManager.execute(this.threadPoolName, this, STARTUP_DELAY);
+ }
+ }
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ try {
+ if ( this.webAppDir == null ) {
+ if (this.getLogger().isWarnEnabled()) {
+ this.getLogger().warn("Only local portlets are supported when deployed as a war "
+ + "and 'webapp-directory' is not configured.");
+ }
+ this.contextName = "local";
+ //this.loadLocal();
+ } else {
+ //this.scanWebapps();
+ }
+ } catch (Exception ignore) {
+ this.getLogger().error("Exception during scanning of portlet applications.", ignore);
+ }
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletDefinitionRegistryImpl.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java?view=auto&rev=535599
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java (added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java Sun May 6 04:18:18 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.pluto.services;
+
+import org.apache.cocoon.portal.util.AbstractBean;
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.spi.optional.PortletInfoService;
+
+/**
+ *
+ * @version $Id$
+ */
+public class PortletInfoServiceImpl
+ extends AbstractBean
+ implements PortletInfoService {
+
+ public String getKeywords(PortletWindow arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getShortTitle(PortletWindow arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTitle(PortletWindow arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-newimpl/src/main/java/org/apache/cocoon/portal/pluto/services/PortletInfoServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Id