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 2005/08/03 19:26:13 UTC
cvs commit: ws-wsrp4j/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl ConsumerEnvironmentImpl.java ProxyPortlet.java
dlouzan 2005/08/03 10:26:13
Added: sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl
ConsumerEnvironmentImpl.java ProxyPortlet.java
Log:
Initial commit.
Revision Changes Path
1.1 ws-wsrp4j/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ConsumerEnvironmentImpl.java
Index: ConsumerEnvironmentImpl.java
===================================================================
/*
* Copyright 2003-2005 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.
*/
package org.apache.wsrp4j.consumer.portlet.impl;
import oasis.names.tc.wsrp.v1.types.StateChange;
import org.apache.wsrp4j.consumer.ProducerRegistry;
import org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment;
import org.apache.wsrp4j.consumer.driver.PortletDriverRegistryImpl;
import org.apache.wsrp4j.consumer.driver.URLRewriterImpl;
import org.apache.wsrp4j.consumer.util.ConsumerConstants;
import org.apache.wsrp4j.commons.util.Constants;
import org.apache.wsrp4j.commons.util.Modes;
import org.apache.wsrp4j.commons.util.WindowStates;
/**
* Class implements the consumer environment interface for the
* proxy portlet consumer.
*
**/
public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment
{
private static String CONSUMER_AGENT = "WSRP4J proxy portlet consumer v0.1";
private String registryPath = null;
public ConsumerEnvironmentImpl()
{
// set the name of the consumer agent
setConsumerAgent(CONSUMER_AGENT);
// define the locales the consumer supports
String[] supportedLocales = new String[2];
supportedLocales[0] = Constants.LOCALE_EN_US;
supportedLocales[1] = Constants.LOCALE_DE_DE;
setSupportedLocales(supportedLocales);
// define the modes the consumer supports
String[] supportedModes = new String[3];
supportedModes[0] = Modes._view;
supportedModes[1] = Modes._help;
supportedModes[2] = Modes._edit;
setSupportedModes(supportedModes);
// define the window states the consumer supports
String[] supportedWindowStates = new String[3];
supportedWindowStates[0] = WindowStates._normal;
supportedWindowStates[1] = WindowStates._maximized;
supportedWindowStates[2] = WindowStates._minimized;
setSupportedWindowStates(supportedWindowStates);
// define portlet state change behaviour
setPortletStateChange(StateChange.readWrite);
// define the mime types the consumer supports
setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
// define the character sets the consumer supports
setCharacterEncodingSet(new String[] { Constants.UTF_8 });
// set the authentication method the consumer uses
setUserAuthentication(ConsumerConstants.NONE);
// set consumer components
setUserRegistry(UserRegistryImpl.getInstance());
setSessionHandler(SessionHandlerImpl.getInstance(this));
//setProducerRegistry(ProducerRegistryImpl.getInstance());
setPortletRegistry(PortletRegistryImpl.getInstance());
setTemplateComposer(URLTemplateComposerImpl.getInstance());
setURLRewriter(URLRewriterImpl.getInstance());
setPortletDriverRegistry(PortletDriverRegistryImpl.getInstance(this));
}
public void setRegistryPath(String path)
{
this.registryPath = path;
}
public ProducerRegistry getProducerRegistry()
{
if (super.getProducerRegistry() == null)
{
setProducerRegistry(ProducerRegistryImpl.getInstance(registryPath));
}
return super.getProducerRegistry();
}
}
1.1 ws-wsrp4j/sandbox/wsrp4j/consumer/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java
Index: ProxyPortlet.java
===================================================================
/*
* Copyright 2003-2005 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.
*/
package org.apache.wsrp4j.consumer.portlet.impl;
import java.io.IOException;
//import java.security.Principal;
//import java.util.Enumeration;
//import java.util.HashMap;
//import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
//import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
//import oasis.names.tc.wsrp.v1.types.MarkupContext;
//import oasis.names.tc.wsrp.v1.types.MarkupResponse;
//import oasis.names.tc.wsrp.v1.types.PersonName;
//import oasis.names.tc.wsrp.v1.types.PortletDescription;
//import oasis.names.tc.wsrp.v1.types.SessionContext;
//import oasis.names.tc.wsrp.v1.types.UpdateResponse;
//import oasis.names.tc.wsrp.v1.types.UserContext;
//import oasis.names.tc.wsrp.v1.types.UserProfile;
//import org.apache.pluto.core.CoreUtils;
//import org.apache.pluto.om.window.PortletWindow;
import org.apache.wsrp4j.consumer.ConsumerEnvironment;
//import org.apache.wsrp4j.consumer.GroupSession;
//import org.apache.wsrp4j.consumer.InteractionRequest;
//import org.apache.wsrp4j.consumer.MarkupRequest;
//import org.apache.wsrp4j.consumer.PortletDriver;
//import org.apache.wsrp4j.consumer.PortletKey;
//import org.apache.wsrp4j.consumer.PortletWindowSession;
//import org.apache.wsrp4j.consumer.Producer;
//import org.apache.wsrp4j.consumer.URLGenerator;
//import org.apache.wsrp4j.consumer.User;
//import org.apache.wsrp4j.consumer.URLTemplateComposer;
//import org.apache.wsrp4j.consumer.UserSession;
//import org.apache.wsrp4j.consumer.WSRPPortlet;
//import org.apache.wsrp4j.consumer.PortletSession;
//import org.apache.wsrp4j.consumer.driver.PortletKeyImpl;
//import org.apache.wsrp4j.consumer.driver.UserImpl;
//import org.apache.wsrp4j.consumer.driver.WSRPPortletImpl;
//import org.apache.wsrp4j.consumer.portlet.SessionHandler;
//import org.apache.wsrp4j.consumer.util.ConsumerConstants;
import org.apache.wsrp4j.commons.exception.ErrorCodes;
import org.apache.wsrp4j.commons.exception.WSRPException;
import org.apache.wsrp4j.commons.exception.WSRPXHelper;
import org.apache.wsrp4j.commons.log.LogManager;
import org.apache.wsrp4j.commons.log.Logger;
//import org.apache.wsrp4j.commons.util.Modes;
import org.apache.wsrp4j.commons.util.ParameterChecker;
//import org.apache.wsrp4j.commons.util.WindowStates;
/**
* JSR 168 portlet which acts as proxy (consumer) to WSRP portlets.
*
**/
public class ProxyPortlet extends GenericPortlet
{
// stores consumer specific information
private ConsumerEnvironment consumerEnv = null;
// used to validate producer responses
private static ParameterChecker checker = null;
// logger
private static final Logger logger =
LogManager.getLogManager().getLogger(ProxyPortlet.class);
// lock object for thread synchronization while setting the urlgenerator
private static final Object urlGenLock = new Object();
// lock object for thread synchronization while updating session handler
private static final Object sessionHdlrLock = new Object();
// used as key in render params
public static final String NAVIGATIONAL_STATE =
"proxyportlet-updateResponse-navState";
/**
* Called by the container to initialize the portlet. This implementation
* calls init from the super class and instantiates the
* <code>ParameterChecker</code> and a <code>Logger</code>.
*
* @param config a <code>PortletConfig</code> object containing the portlet
* configuration and initialization parameters
**/
public void init(PortletConfig config) throws PortletException
{
final String MN = "init";
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.entry(Logger.TRACE_HIGH, MN);
}
super.init(config);
checker = new ParameterChecker();
try
{
initConsumerEnvironment(config);
} catch (WSRPException e)
{
throw new PortletException(e);
}
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.exit(Logger.TRACE_HIGH, MN);
}
}
/**
* @param config
*/
private void initConsumerEnvironment(PortletConfig config)
throws WSRPException
{
try
{
String className = config.getInitParameter(
ConsumerConstants.CONSUMER_ENV_CLASS);
if (className != null)
{
Class cl = Class.forName(className);
consumerEnv = (ConsumerEnvironment)cl.newInstance();
String path =
config.getPortletContext().getRealPath("/WEB-INF");
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.text(Logger.TRACE_HIGH, "initConsumerEnvironment",
"Path to persistent directory :" + path);
}
((ConsumerEnvironmentImpl)consumerEnv).setRegistryPath(path);
} else
{
throw new IllegalStateException("Consumer Environment class " +
"not found");
}
} catch (Exception e)
{
WSRPXHelper.throwX(
logger,
Logger.ERROR,
"initConsumerEnvironment",
ErrorCodes.INSTANTIATION_OF_CONSUMER_ENV_FAILED,
e);
}
}
/**
* This method is called whenever a <code>performBlockingInteraction</code>
* request is being made on a remote portlet.
*
* The implementation performs the actual wsrp performBlockingInteraction
* call and processes the response from the producer. As result of this
* call the navigational and window state, portlet mode can be changed.
* Optionally the producer can send a redirect which is then passed to the
* portlet container. Changing the state of the remote portlet can lead to
* cloning the portlet at the producer side. As the result of such a
* <i>clone on write</i> behaviour the proxy portlet will be reconfigured
* to serve the clone.
*
* @param request the portlet request
* @param actionResponse the action response
**/
public void processAction(ActionRequest request,
ActionResponse actionResponse) throws PortletException
{
/*
String MN = "processAction";
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.entry(Logger.TRACE_HIGH, MN);
}
try
{
// get the user on which request this call is being done
User user = getUser(request);
String userID = null;
if (user != null)
{
userID = user.getUserID();
}
// get all information and objects which are needed to perform the interaction
Map preferences = getPreferences(request);
PortletKey portletKey = getPortletKey(preferences);
WSRPPortlet portlet = getPortlet(portletKey, preferences);
PortletWindowSession windowSession = getWindowSession(userID, portlet, request);
PortletDriver portletDriver = consumerEnv.getPortletDriverRegistry().getPortletDriver(portlet);
InteractionRequest actionRequest = new WSRPRequestImpl(windowSession, request);
PortletWindow myWindow = CoreUtils.getInternalRequest(request).getInternalPortletWindow();
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.text(
Logger.TRACE_HIGH,
MN,
"proxyportlet("
+ myWindow.getPortletEntity().getId()
+ ") invokes action on portlet "
+ portlet.getPortletKey().getPortletHandle());
}
// do the actual call and check the response from the producer
BlockingInteractionResponse response = null;
try
{
response = portletDriver.performBlockingInteraction(actionRequest, userID);
checker.check(response);
} catch (java.rmi.RemoteException wsrpFault)
{
WSRPXHelper.handleWSRPFault(logger, wsrpFault);
}
// process the reponse
if (response != null)
{
// the producer can either send a update response or a redirect
UpdateResponse updateResponse = response.getUpdateResponse();
String redirectURL = response.getRedirectURL();
if (updateResponse != null)
{
// process the update response
if (windowSession != null)
{
updateSessionContext(updateResponse.getSessionContext(), windowSession.getPortletSession());
windowSession.updateMarkupCache(updateResponse.getMarkupContext());
}
updatePortletContext(request, updateResponse.getPortletContext(), portlet);
// pass navState to next getMarkup by using the render params
String navState = updateResponse.getNavigationalState();
if (navState != null)
{
actionResponse.setRenderParameter(NAVIGATIONAL_STATE, navState);
}
// if the remote portlet requested to change the portlet mode
// we try to solve this request.
String newMode = updateResponse.getNewMode();
if (newMode != null)
{
try
{
if (newMode.equalsIgnoreCase(Modes._view))
{
actionResponse.setPortletMode(PortletMode.VIEW);
} else if (newMode.equalsIgnoreCase(Modes._edit))
{
actionResponse.setPortletMode(PortletMode.EDIT);
} else if (newMode.equalsIgnoreCase(Modes._help))
{
actionResponse.setPortletMode(PortletMode.HELP);
}
} catch (PortletModeException e)
{
// means portlet does not support this mode
// means portlet does not support the window state
if (logger.isLogging(Logger.INFO))
{
logger.text(
Logger.INFO,
MN,
"The portlet='"
+ portlet.getPortletKey().getPortletHandle()
+ "' does not support the mode="
+ e.getMode());
}
}
}
// if the remote portlet requested to change the window state
// we try to solve this request. If the window state
String newWindowState = updateResponse.getNewWindowState();
if (newWindowState != null)
{
try
{
if (newWindowState.equalsIgnoreCase(WindowStates._maximized))
{
actionResponse.setWindowState(WindowState.MAXIMIZED);
} else if (newWindowState.equalsIgnoreCase(WindowStates._minimized))
{
actionResponse.setWindowState(WindowState.MINIMIZED);
} else if (newWindowState.equalsIgnoreCase(WindowStates._normal))
{
actionResponse.setWindowState(WindowState.NORMAL);
}
} catch (WindowStateException e)
{
// means portlet does not support the window state
if (logger.isLogging(Logger.INFO))
{
logger.text(
Logger.INFO,
MN,
"The portlet='"
+ portlet.getPortletKey().getPortletHandle()
+ "' does not support the window state="
+ e.getState());
}
}
}
} else if (redirectURL != null)
{
// if we got a redirect forward this redirect to the container
try
{
actionResponse.sendRedirect(redirectURL);
} catch (IOException ioEx)
{
WSRPXHelper.throwX(logger, Logger.ERROR, "processAction", ErrorCodes.COULD_NOT_FOLLOW_REDIRECT);
}
}
}
} catch (WSRPException e)
{
throw new PortletException(e);
} finally
{
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.exit(Logger.TRACE_HIGH, MN);
}
}
*/
}
/**
* This method is called whenever a <code>GetMarkup</code> or <code>PerformInteraction</code>
* request is being made on the remote portlet.
*
* The implementation performs the actual wsrp getMarkup or performInteraction call
* depending on the value of the request parameter <i>wsrp-urlType</i>. In case of a
* performInteraction a getMarkup call is being done afterwards to fetch the markup.
*
* @param request the portlet request
* @param renderResponse the render response
**/
public void render(RenderRequest request, RenderResponse renderResponse)
throws PortletException, IOException
{
/*
String MN = "render";
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.entry(Logger.TRACE_HIGH, MN);
}
try
{
// set content type in response
renderResponse.setContentType(request.getResponseContentType());
// get the user on which request this call is being done
User user = getUser(request);
String userID = null;
if (user != null)
{
userID = user.getUserID();
}
// get all information and objects which are needed to perform the interaction
Map preferences = getPreferences(request);
PortletKey portletKey = getPortletKey(preferences);
WSRPPortlet portlet = getPortlet(portletKey, preferences);
PortletWindowSession windowSession = getWindowSession(userID, portlet, request);
PortletDriver portletDriver = consumerEnv.getPortletDriverRegistry().getPortletDriver(portlet);
MarkupRequest markupRequest = new WSRPRequestImpl(windowSession, request);
PortletWindow myWindow = CoreUtils.getInternalRequest(request).getInternalPortletWindow();
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.text(
Logger.TRACE_HIGH,
MN,
"proxyportlet("
+ myWindow.getPortletEntity().getId()
+ ") renders portlet "
+ portlet.getPortletKey().getPortletHandle());
}
// feed the url generator with the current response
synchronized (urlGenLock)
{
// update url generator
URLGenerator urlGenerator = URLGeneratorImpl.getInstance(renderResponse, getPortletConfig());
URLTemplateComposer templateComposer = consumerEnv.getTemplateComposer();
if(templateComposer != null) {
templateComposer.setURLGenerator(urlGenerator);
}
consumerEnv.getURLRewriter().setURLGenerator(urlGenerator);
}
// do a getMarkup call and check the response
MarkupResponse response = null;
try
{
response = portletDriver.getMarkup(markupRequest, userID);
checker.check(response);
} catch (java.rmi.RemoteException wsrpFault)
{
WSRPXHelper.handleWSRPFault(logger, wsrpFault);
}
// process the markup response
if (response != null)
{
if (windowSession != null)
{
updateSessionContext(response.getSessionContext(), windowSession.getPortletSession());
}
processMarkupContext(response.getMarkupContext(), renderResponse);
}
// delete any chached markup
if (windowSession != null)
{
windowSession.updateMarkupCache(null);
}
} catch (WSRPException e)
{
throw new PortletException("Error occured while retrieving markup",e);
} finally
{
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.exit(Logger.TRACE_HIGH, MN);
}
}
*/
}
/*
private String processMarkupContext(
MarkupContext markupContext,
RenderResponse renderResponse)
throws WSRPException
{
final String MN = "processMarkupContext";
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.entry(Logger.TRACE_HIGH, MN);
}
String markup = null;
if (markupContext != null && renderResponse != null)
{
// set prefered title if found
String title = markupContext.getPreferredTitle();
if (title != null)
{
renderResponse.setTitle(title);
}
markup = markupContext.getMarkupString();
if (markup != null)
{
try
{
renderResponse.getWriter().write(markup);
} catch (IOException e)
{
WSRPXHelper.throwX(0, e);
}
}
// TODO: need to handle markup binary
}
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.exit(Logger.TRACE_HIGH, MN);
}
return markup;
}
private PortletWindowSession getWindowSession(
String userID,
WSRPPortlet portlet,
PortletRequest request)
throws WSRPException
{
PortletKey portletKey = portlet.getPortletKey();
// to ensure that producer is added to the producer registry
// throws exception which we pass
getProducer(portletKey.getProducerId());
// now we can get our sessions
UserSession userSession = null;
synchronized(sessionHdlrLock)
{
SessionHandler sessionHandler = (SessionHandler)consumerEnv.getSessionHandler();
sessionHandler.setPortletSession(request.getPortletSession());
// get the user session
userSession = sessionHandler.getUserSession(portletKey.getProducerId(), userID);
}
if (userSession != null)
{
// get the group session
String groupID = getPortletDescription(portlet).getGroupID();
groupID = groupID == null ? "default" : groupID;
GroupSession groupSession = userSession.getGroupSession(groupID);
if (groupSession != null)
{
// get the portlet session
PortletWindow portletWindow = CoreUtils.getInternalRequest(request).getInternalPortletWindow();
String handle = portletWindow.getPortletEntity().getId().toString();
PortletSession portletSession = groupSession.getPortletSession(handle);
if (portletSession != null)
{
// get the window session
String windowID = portletWindow.getId().toString();
PortletWindowSession windowSession = portletSession.getPortletWindowSession(windowID);
return windowSession;
} else
{
WSRPXHelper.throwX(ErrorCodes.PORTLET_SESSION_NOT_FOUND);
}
} else
{
WSRPXHelper.throwX(ErrorCodes.GROUP_SESSION_NOT_FOUND);
}
} else
{
WSRPXHelper.throwX(ErrorCodes.USER_SESSION_NOT_FOUND);
}
// we will never reach this
return null;
}
private void updateSessionContext(SessionContext sessionContext, PortletSession portletSession)
{
if (sessionContext != null)
{
if (portletSession != null)
{
portletSession.setSessionContext(sessionContext);
}
}
}
private void updatePortletContext(
PortletRequest request,
oasis.names.tc.wsrp.v1.types.PortletContext portletContext,
WSRPPortlet portlet)
throws WSRPException
{
if (portletContext != null && portlet != null)
{
String newPortletHandle = portletContext.getPortletHandle();
PortletKey portletKey = portlet.getPortletKey();
if (newPortletHandle != null && !newPortletHandle.equals(portletKey.getPortletHandle()))
{
// seems like the producer made a clone
String producerID = portletKey.getProducerId();
PortletKey newPortletKey = new PortletKeyImpl(newPortletHandle, producerID);
portlet = createPortlet(newPortletKey, portlet.getParent());
consumerEnv.getPortletRegistry().addPortlet(portlet);
// set new portlet key in portlet preferences
PortletPreferences preferences = request.getPreferences();
try
{
preferences.setValue(ConsumerConstants.WSRP_PORTLET_HANDLE, newPortletHandle);
preferences.setValue(ConsumerConstants.WSRP_PARENT_HANDLE, portlet.getParent());
preferences.store();
} catch (Exception e)
{
// ups
WSRPXHelper.throwX(0, e);
}
}
portlet.setPortletContext(portletContext);
}
}
private User getUser(PortletRequest request)
{
User user = null;
Principal userPrincipal = request.getUserPrincipal();
if (userPrincipal != null)
{
String userKey = userPrincipal.getName();
user = consumerEnv.getUserRegistry().getUser(userKey);
if (user == null)
{
user = new UserImpl(userKey);
UserContext userContext = new UserContext();
userContext.setProfile(fillUserProfile(request));
userContext.setUserContextKey(userKey);
user.setUserContext(userContext);
consumerEnv.getUserRegistry().addUser(user);
}
}
return user;
}
private UserProfile fillUserProfile(PortletRequest request)
{
UserProfile userProfile = null;
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
if (userInfo != null)
{
userProfile = new UserProfile();
PersonName personName = new PersonName();
personName.setPrefix((String)userInfo.get("user.name.prefix"));
personName.setGiven((String)userInfo.get("user.name.given"));
personName.setFamily((String)userInfo.get("user.name.family"));
personName.setMiddle((String)userInfo.get("user.name.middle"));
personName.setSuffix((String)userInfo.get("user.name.suffix"));
personName.setNickname((String)userInfo.get("user.name.nickName"));
userProfile.setName(personName);
}
return userProfile;
}
private Map getPreferences(PortletRequest request)
{
Map preferences = new HashMap();
Enumeration keys = request.getPreferences().getNames();
while (keys.hasMoreElements())
{
String key = (String)keys.nextElement();
String value = request.getPreferences().getValue(key, null);
preferences.put(key, value);
}
return preferences;
}
protected PortletKey getPortletKey(Map preferences)
{
PortletKey portletKey = null;
String portletHandle = (String)preferences.get(ConsumerConstants.WSRP_PORTLET_HANDLE);
if (portletHandle != null)
{
String producerID = (String)preferences.get(ConsumerConstants.WSRP_PRODUCER_ID);
if (producerID != null)
{
portletKey = new PortletKeyImpl(portletHandle, producerID);
} else
{
// no producer id specified
}
} else
{
// no portlet handle specified for portlet
}
return portletKey;
}
private WSRPPortlet getPortlet(PortletKey portletKey, Map preferences) throws WSRPException
{
WSRPPortlet portlet = null;
if (portletKey != null)
{
portlet = consumerEnv.getPortletRegistry().getPortlet(portletKey);
if (portlet == null)
{
// not yet in registry, create new one
String parentHandle = (String) preferences.get(ConsumerConstants.WSRP_PARENT_HANDLE);
portlet = createPortlet(portletKey, parentHandle);
consumerEnv.getPortletRegistry().addPortlet(portlet);
}
}
return portlet;
}
private WSRPPortlet createPortlet(PortletKey portletKey, String parentHandle)
{
WSRPPortlet portlet = new WSRPPortletImpl(portletKey);
oasis.names.tc.wsrp.v1.types.PortletContext portletContext = new oasis.names.tc.wsrp.v1.types.PortletContext();
portletContext.setPortletHandle(portletKey.getPortletHandle());
portletContext.setPortletState(null);
portletContext.setExtensions(null);
portlet.setPortletContext(portletContext);
if (parentHandle != null)
{
portlet.setParent(parentHandle);
}
else {
// asume a POP -> parentHandle = portletHandle
portlet.setParent(portletKey.getPortletHandle());
}
return portlet;
}
private PortletDescription getPortletDescription(WSRPPortlet portlet) throws WSRPException
{
String producerID = portlet.getPortletKey().getProducerId();
Producer producer = getProducer(producerID);
PortletDescription portletDesc = producer.getPortletDescription(portlet.getParent());
if (portletDesc == null)
{
WSRPXHelper.throwX(ErrorCodes.PORTLET_DESC_NOT_FOUND);
}
return portletDesc;
}
protected Producer getProducer(String producerID) throws WSRPException
{
final String MN = "getProducer";
if (logger.isLogging(Logger.TRACE_HIGH))
{
logger.text(Logger.TRACE_HIGH, MN, "Trying to load producer with ID :" + producerID);
}
Producer producer = consumerEnv.getProducerRegistry().getProducer(producerID);
if (producer == null)
{
WSRPXHelper.throwX(logger, Logger.ERROR, MN, ErrorCodes.PRODUCER_DOES_NOT_EXIST);
}
return producer;
}
protected ConsumerEnvironment getConsumerEnvironment()
{
return consumerEnv;
}
*/
}