* @param event The event triggering the action
* @param basket The basket
*/
protected void processShowItemEvent(ShowItemEvent event, Basket basket) {
if ( event.getItem() instanceof ContentItem ) {
PortalService service = null;
try {
service = (PortalService) this.manager.lookup(PortalService.ROLE);
ContentItem ci = (ContentItem)event.getItem();
CopletLayout layout = (CopletLayout) event.getLayout();
CopletInstanceData cid = null;
if ( ci.isContent() ) {
CopletData copletData = service.getComponentManager().getProfileManager().getCopletData(event.getCopletDataId());
cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
cid.setAttribute("item-content", ci.getContent());
} else {
if ( ci.getURL() != null ) {
SourceResolver resolver = null;
Source source = null;
String url = null;
try {
resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
url = ci.getURL();
source = resolver.resolveURI(url);
CopletData copletData = service.getComponentManager().getProfileManager().getCopletData(event.getCopletDataId());
cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
cid.setAttribute("item-content", IOUtil.toByteArray(source.getInputStream()));
} catch (IOException se) {
this.getLogger().warn("Unable to get content for " + url, se);
} catch (ServiceException se) {
this.getLogger().warn("Unable to get source resolver.", se);
} finally {
if ( source != null ) {
resolver.release(source);
}
this.manager.release(resolver);
}
} else {
CopletData copletData = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId()).getCopletData();
cid = service.getComponentManager().getCopletFactory().newInstance(copletData);
Map attributes = (Map) ci.getAttribute("coplet-attributes");
Iterator i = attributes.entrySet().iterator();
while ( i.hasNext() ) {
Map.Entry entry = (Map.Entry)i.next();
cid.setAttribute(entry.getKey().toString(), entry.getValue());