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", IOUtils.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 {
final CopletInstanceData original = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId());
final CopletData copletData = original.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();