Package org.gatein.wsrp.consumer.registry.mapping

Examples of org.gatein.wsrp.consumer.registry.mapping.ProducerInfosMapping


         ChromatticSession session = persister.getSession();

         final long now = SupportsLastModified.now();

         // since we're creating a new ProducerInfo, we need to modify the parent as well
         ProducerInfosMapping pims = getProducerInfosMapping(session);
         pims.setLastModified(now);

         // use ProducerInfosMapping to create a child ProducerInfo node and initialize it
         ProducerInfoMapping pim = pims.createProducerInfo(info.getId());
         // we first need to persist the ProducerInfoMapping as a child of the ProducerInfosMapping element, using its id as path
         String key = session.persist(pims, pim, info.getId());
         info.setKey(key);
         info.setLastModified(now);
         pim.initFrom(info);
View Full Code Here


         pim.initFrom(producerInfo);

         idUnchanged = oldId.equals(newId);

         // if the ProducerInfo's last modified date is posterior to the set it's contained in, modify that one too
         ProducerInfosMapping pims = getProducerInfosMapping(session);
         final long pimsLastModified = pims.getLastModified();
         final long lastModified = producerInfo.getLastModified();
         if (lastModified > pimsLastModified)
         {
            pims.setLastModified(lastModified);
         }

         if (!idUnchanged)
         {
            // the consumer was renamed, we need to update its parent
            Map<String, ProducerInfoMapping> nameToProducerInfoMap = pims.getNameToProducerInfoMap();
            nameToProducerInfoMap.put(pim.getId(), pim);
         }

         persister.save();
View Full Code Here

    * @param session the ChromatticSession used to access the JCR store
    * @return the ProducerInfosMapping element representing the collection of ProducerInfos
    */
   private ProducerInfosMapping getProducerInfosMapping(ChromatticSession session)
   {
      ProducerInfosMapping producerInfosMapping = session.findByPath(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);

      if (producerInfosMapping == null)
      {
         // we don't currently have any persisted data in JCR so first create the JCR node
         producerInfosMapping = session.insert(ProducerInfosMapping.class, ProducerInfosMapping.NODE_NAME);

         if (loadFromXMLIfNeeded)
         {
            // loading initial data is requested so do it
            XMLConsumerRegistry fromXML = new XMLConsumerRegistry(configurationIS);
            fromXML.reloadConsumers();

            // Save to JCR
            List<ProducerInfoMapping> infos = producerInfosMapping.getProducerInfos();
            List<WSRPConsumer> xmlConsumers = fromXML.getConfiguredConsumers();
            for (WSRPConsumer consumer : xmlConsumers)
            {
               ProducerInfo info = consumer.getProducerInfo();

               // create the ProducerInfoMapping children node
               ProducerInfoMapping pim = producerInfosMapping.createProducerInfo(info.getId());

               // need to add to parent first to attach newly created ProducerInfoMapping
               infos.add(pim);

               // init it from ProducerInfo
               pim.initFrom(info);

               // update ProducerInfo with the persistence key
               info.setKey(pim.getKey());

               // populate the cache with the newly created consumer
               consumerCache.putConsumer(info.getId(), consumer);
            }

            producerInfosMapping.setLastModified(SupportsLastModified.now());
            session.save();
         }
      }

      return producerInfosMapping;
View Full Code Here

      return getPathFor(needsComputedPath);
   }

   public LastModified lastModifiedToUpdateOnDelete(ChromatticSession session)
   {
      final ProducerInfosMapping pims = session.findByPath(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);
      if (pims != null)
      {
         // GTNWSRP-239
         return pims.getLastModifiedMixin();
      }
      else
      {
         return null;
      }
View Full Code Here

TOP

Related Classes of org.gatein.wsrp.consumer.registry.mapping.ProducerInfosMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.