try {
resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
url = ci.getURL();
if ( url == null ) {
// copy coplet attributes
PortalService service = null;
try {
service = (PortalService) this.manager.lookup(PortalService.ROLE);
CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId());
url = "coplet://" + ci.getCopletId();
Map attributes = new HashMap();
Iterator i = cid.getAttributes().entrySet().iterator();
while ( i.hasNext() ) {
Map.Entry entry = (Map.Entry)i.next();
attributes.put(entry.getKey(), entry.getValue());
}
i = cid.getCopletData().getAttributes().entrySet().iterator();
while ( i.hasNext() ) {
Map.Entry entry = (Map.Entry)i.next();
attributes.put(entry.getKey(), entry.getValue());
}
ci.setAttribute("coplet-attributes", attributes);
} catch (ServiceException se) {
this.getLogger().warn("Unable to lookup portal service.", se);
} finally {
this.manager.release(service);
}
}
source = resolver.resolveURI(url);
ci.setContent(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 if ( ci.getURL() == null ) {
// copy coplet attributes
PortalService service = null;
try {
service = (PortalService) this.manager.lookup(PortalService.ROLE);
CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(ci.getCopletId());
Map attributes = new HashMap();
Iterator i = cid.getAttributes().entrySet().iterator();
while ( i.hasNext() ) {
Map.Entry entry = (Map.Entry)i.next();
attributes.put(entry.getKey(), entry.getValue());