Esempio n. 1
0
 /** Create a Date object from the given date string. */
 public static Date getDate(String value) {
   /* if something goes wrong with converting the value to a date,
    * try with dateTime and get the date out it, this is because,
    * some service clients send a full date-time string for a date */
   try {
     return new Date(ConverterUtil.convertToDate(value).getTime());
   } catch (Exception e) {
     return new Date(ConverterUtil.convertToDateTime(value).getTimeInMillis());
   }
 }
  /** {@inheritDoc} */
  @Override
  public Subscription[] getJMSSubscriptions(String topicName) throws EventBrokerException {
    try {
      Subscription[] subscriptionsArray = new Subscription[0];

      UserRegistry userRegistry =
          this.registryService.getGovernanceSystemRegistry(
              EventBrokerHolder.getInstance().getTenantId());
      String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
      if (!resourcePath.endsWith("/")) {
        resourcePath = resourcePath + "/";
      }
      resourcePath = resourcePath + EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME;

      // Get subscriptions
      if (userRegistry.resourceExists(resourcePath)) {
        Collection subscriptionCollection = (Collection) userRegistry.get(resourcePath);
        subscriptionsArray = new Subscription[subscriptionCollection.getChildCount()];

        int index = 0;
        for (String subs : subscriptionCollection.getChildren()) {
          Collection subscription = (Collection) userRegistry.get(subs);

          Subscription subscriptionDetails = new Subscription();
          subscriptionDetails.setId(subscription.getProperty("Name"));
          subscriptionDetails.setOwner(subscription.getProperty("Owner"));
          subscriptionDetails.setCreatedTime(
              ConverterUtil.convertToDate(subscription.getProperty("createdTime")));

          subscriptionsArray[index++] = subscriptionDetails;
        }
      }

      return subscriptionsArray;
    } catch (RegistryException e) {
      throw new EventBrokerException("Cannot read the registry resources ", e);
    }
  }