if ( producerId == null ) {
// if the producer can't be found, we simply return
this.getLogger().error("Producer not configured in wsrp coplet " + copletData.getId());
return;
}
final Producer producer = consumerEnvironment.getProducerRegistry().getProducer(producerId);
if ( producer == null ) {
// if the producer can't be found, we simply return
this.getLogger().error("Producer with id " + producerId + " not found.");
return;
}
// get the wsrp user and store it as an attribute on the instance
final String currentUserID = this.service.getComponentManager().getProfileManager().getUser().getUserName();
User user = this.consumerEnvironment.getUserRegistry().getUser(currentUserID);
if ( user == null ) {
// create a new user
user = new UserImpl(currentUserID);
user.setUserContext(this.userContextProvider.createUserContext(currentUserID));
this.consumerEnvironment.getUserRegistry().addUser(user);
}
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_USER, user);
// get the portlet handle
final String portletHandle = (String) copletData.getAttribute("portlet-handle");
if ( portletHandle == null ) {
// if the portlet handle can't be found, we simply return
this.getLogger().error("Portlet handle not configured in wsrp coplet " + copletData.getId());
return;
}
// get the wsrp portlet
final PortletKey portletKey = new PortletKeyImpl(portletHandle, producerId);
WSRPPortlet wsrpportlet = this.consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
if ( wsrpportlet == null ) {
wsrpportlet = new WSRPPortletImpl(portletKey);
final PortletContext portletContext = new PortletContext(null, portletKey.getPortletHandle(), null);
wsrpportlet.setPortletContext(portletContext);
try {
consumerEnvironment.getPortletRegistry().addPortlet(wsrpportlet);
} catch (WSRPException we) {
this.getLogger().error("Exception adding wsrp portlet.", we);
return;
}
}
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY, portletKey);
final Session session = ObjectModelHelper.getRequest(this.service.getObjectModel()).getSession();
final String portletInstanceKey = this.getPortletInstanceKey(portletKey, coplet, session.getId());
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY, portletInstanceKey);
// create consumer parameters
final Map addParams = new HashMap();
addParams.put(Constants.PORTLET_INSTANCE_KEY, portletInstanceKey);
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_CONSUMER_MAP, addParams);
// get the window-state and -mode
SimplePortletWindowSession windowSession;
wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
try {
// this call includes the getServiceDescription()-Invocation
// additionally register() initCookie() and so on will be handled
// (within ProducerImpl and PortletDriverImpl)
windowSession = getSimplePortletWindowSession(wsrpportlet,
portletInstanceKey,
user);
final PortletDescription desc = producer.getPortletDescription(portletHandle);
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_TITLE,
desc.getTitle());
final MarkupType markupType = desc.getMarkupTypes(0);
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_MODES, markupType.getModes());
coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_WINDOWSTATES, markupType.getWindowStates());