Package org.gatein.registration

Examples of org.gatein.registration.Consumer


      }
      group.setStatus(status);

      for (ConsumerMapping cm : getConsumers())
      {
         Consumer consumer = persistenceManager.getConsumerById(cm.getPersistentKey());
         if (consumer == null)
         {
            consumer = cm.toConsumer(persistenceManager);
         }
View Full Code Here


            // if we didn't get a registration to return, just throw the exception
            throw e;
         }
      }*/

      Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);

      // create the actual registration
      RegistrationSPI registration = persistenceManager.addRegistrationFor((ConsumerSPI)consumer, registrationProperties);

      // let the policy decide what the handle should be
View Full Code Here

      // check with policy if we allow the consumer
      policy.validateConsumerName(name, this);

      String identity = policy.getConsumerIdFrom(name, Collections.<QName, Object>emptyMap());

      Consumer consumer = persistenceManager.createConsumer(identity, name);

      // deal with group if needed
      // let the policy decide if there should be a group associated with the Consumer and if yes, with which id
      String groupName = policy.getAutomaticGroupNameFor(name);
      if (groupName != null)
View Full Code Here

      return persistenceManager.createConsumerGroup(groupName);
   }

   public void removeConsumer(String identity) throws RegistrationException, NoSuchRegistrationException
   {
      Consumer consumer = getOrCreateConsumer(identity, false, null);

      ConsumerGroup group = consumer.getGroup();
      if (group != null)
      {
         group.removeConsumer(consumer);
      }

      // cascade delete the registrations
      ArrayList<Registration> registrations = new ArrayList<Registration>(consumer.getRegistrations());
      for (Registration reg : registrations)
      {
         removeRegistration(reg);
      }
View Full Code Here

   public Registration getNonRegisteredRegistration() throws RegistrationException
   {
      //TODO: this might be better to place somewhere else and use the RegistrationHandler.register instead of
      // doing basically the same thing below.
      Consumer unregConsumer = getConsumerByIdentity(NON_REGISTERED_CONSUMER);
      if (unregConsumer == null)
      {
         Registration registration = addRegistrationTo(NON_REGISTERED_CONSUMER, new HashMap<QName, Object>(), null, true);
         registration.setStatus(RegistrationStatus.VALID);
         getPersistenceManager().saveChangesTo(registration);
         return registration;
      }
      else
      {
         //The unregistered consumer should only ever have one registration, return that
         final Registration registration = unregConsumer.getRegistrations().iterator().next();

         // but first check that we don't have an improper persisted state due to GTNWSRP-283
         if (registration.getRegistrationHandle() == null || RegistrationStatus.PENDING == registration.getStatus())
         {
            // if we have improper persisted state, correct it
View Full Code Here

   }

   private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded, String consumerName)
      throws RegistrationException
   {
      Consumer consumer = getConsumerByIdentity(identity);
      if (consumer == null)
      {
         if (createConsumerIfNeeded)
         {
            consumer = createConsumer(consumerName);
View Full Code Here

            // pending instead of invalid as technically, the registration is not yet invalid
            reg.setStatus(RegistrationStatus.PENDING);

            // make changes persistent
            Consumer consumer = reg.getConsumer();
            try
            {
               persistenceManager.saveChangesTo(consumer);
            }
            catch (RegistrationException e)
            {
               if (log.isDebugEnabled())
               {
                  log.debug("Couldn't persist changes to Consumer '" + consumer.getId() + "'", e);
               }
            }
         }
      }
      catch (RegistrationException e)
View Full Code Here

            throw new InvalidConsumerDataException(messageString);
         }
      }

      // check that this is not a duplicate registration if the status is not pending
      Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
      if (consumer != null && !RegistrationStatus.PENDING.equals(consumer.getStatus()))
      {
         // allow the new registration only if the registration properties are different that existing registrations
         // for this consumer...
         for (Registration registration : consumer.getRegistrations())
         {
            if (registration.hasEqualProperties(registrationProperties))
            {
               throw new DuplicateRegistrationException("Consumer named '" + consumer.getName()
                  + "' has already been registered with the same set of registration properties. Registration rejected!", null, registration);
            }
         }
      }
   }
View Full Code Here

      try
      {
         for (ConsumerMapping cm : getConsumers())
         {
            Consumer consumer = persistenceManager.getConsumerById(cm.getPersistentKey());
            if (consumer == null)
            {
               consumer = cm.toModel((ConsumerSPI)consumer, persistenceManager);
            }
View Full Code Here

            throw new InvalidConsumerDataException(messageString);
         }
      }

      // check that this is not a duplicate registration if the status is not pending
      Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
      if (consumer != null && !RegistrationStatus.PENDING.equals(consumer.getStatus()))
      {
         // allow the new registration only if the registration properties are different that existing registrations
         // for this consumer...
         for (Registration registration : consumer.getRegistrations())
         {
            if (registration.hasEqualProperties(registrationProperties))
            {
               throw new DuplicateRegistrationException("Consumer named '" + consumer.getName()
                  + "' has already been registered with the same set of registration properties. Registration rejected!", null, registration);
            }
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.gatein.registration.Consumer

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.