return new MappingToProducerInfoIterator(mappings.iterator());
}
private ProducerInfosMapping getProducerInfosMapping(ChromatticSession session)
{
ProducerInfosMapping producerInfosMapping = session.findByPath(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);
// if we don't have info from JCR, load from XML and populate JCR
if (producerInfosMapping == null)
{
producerInfosMapping = session.insert(ProducerInfosMapping.class, ProducerInfosMapping.NODE_NAME);
List<ProducerInfoMapping> infos = producerInfosMapping.getProducerInfos();
// Load from XML
XMLConsumerRegistry fromXML = new XMLConsumerRegistry();
fromXML.reloadConsumers();
// Save to JCR
List<WSRPConsumer> consumers = fromXML.getConfiguredConsumers();
for (WSRPConsumer consumer : consumers)
{
ProducerInfo info = consumer.getProducerInfo();
ProducerInfoMapping pim = producerInfosMapping.createProducerInfo(info.getId());
// need to add to parent first to attach newly created ProducerInfoMapping
infos.add(pim);
// init it from ProducerInfo