Package org.wso2.carbon.registry.core.session

Examples of org.wso2.carbon.registry.core.session.UserRegistry


    }

    public void unSubscribe(String subscriptionID) throws EventBrokerException {
        try {
            UserRegistry userRegistry =
                    this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
            String fullPath = this.indexStoragePath;
            if (userRegistry.resourceExists(fullPath)) {
                Resource topicIndexResource = userRegistry.get(fullPath);

                String topicName = topicIndexResource.getProperty(subscriptionID);
                // delete the subscriptions resource
                // if the registry is read only there can be situations where the the subscriptions
                // is not saved to registry and hence the topic name
                if (topicName != null){
                    userRegistry.delete(getResourcePath(subscriptionID, topicName));
                }

                topicIndexResource.removeProperty(subscriptionID);

                userRegistry.put(fullPath, topicIndexResource);
            }

        } catch (RegistryException e) {
            throw new EventBrokerException("Can not access the registry ", e);
        }
View Full Code Here


        topicResourcePath += EventBrokerConstants.EB_CONF_WS_SUBSCRIPTION_COLLECTION_NAME;
        List<Subscription> matchingSubscriptions = new ArrayList();

        try {
            UserRegistry userRegistry =
                    this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
            String subscriptionID = null;
            if (userRegistry.resourceExists(topicResourcePath)) {
                Collection subscriptions = (Collection) userRegistry.get(topicResourcePath);
                String[] subscriptionPaths = (String[]) subscriptions.getContent();
                for (String subscriptionPath : subscriptionPaths) {
                    Resource resource = userRegistry.get(subscriptionPath);
                    Subscription subscription = JavaUtil.getSubscription(resource);
                    subscriptionID = subscriptionPath.substring(subscriptionPath.lastIndexOf("/") + 1);
                    subscription.setId(subscriptionID);
                    subscription.setTopicName(topicName);
View Full Code Here

        */
    public static void createQueue(String queueName, String owner)
            throws RegistryClientException {
        try {
            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Set queue properties
            Collection queue = null;
            String queueID = CommonsUtil.getQueueID(queueName);

            if (!registry.resourceExists(queueID)) { // Create queue
                queue = registry.newCollection();

                queue.setProperty(OWNER, owner);
                queue.setProperty(NAME, queueName);
                queue.setProperty(CREATED_TIME, ConverterUtil.convertToString(
                        Calendar.getInstance()));
                queue.setProperty(UPDATED_TIME, ConverterUtil.convertToString(
                        Calendar.getInstance()));
                queue.setProperty(CREATED_FROM, CREATED_FROM_AMQP);
                queue.setProperty(USER_COUNT, "1");
            } else { // Share queue
                queue = (Collection)registry.get(queueID);

                queue.setProperty(UPDATED_TIME, ConverterUtil.convertToString(
                        Calendar.getInstance()));

                String userCount = queue.getProperty(USER_COUNT);
                if (null != userCount) {
                    int count = Integer.parseInt(userCount);
                    queue.setProperty(USER_COUNT, Integer.toString(++count));
                }
            }

            registry.put(queueID, queue);
        } catch (RegistryException e) {
            throw new RegistryClientException(e);
        }
    }
View Full Code Here

        */
    public static void deleteQueue(String queueName)
            throws RegistryClientException {
        try {
            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Delete queue
            String queueID = CommonsUtil.getQueueID(queueName);

            if (registry.resourceExists(queueID)) {
                String createdFrom = registry.get(queueID).getProperty(CREATED_FROM);

                if ((null != createdFrom) && (CREATED_FROM_AMQP.equals(createdFrom))) {
                    Collection queue = (Collection)registry.get(queueID);

                    String userCount = queue.getProperty(USER_COUNT);
                    if (null != userCount) {
                        int count = Integer.parseInt(userCount);

                        if (count > 1) {
                            queue.setProperty(USER_COUNT, Integer.toString(--count));
                            registry.put(queueID, queue);
                        } else {
                            registry.delete(queueID);
                        }
                    }
                }
            }
        } catch (RegistryException e) {
View Full Code Here

            throws RegistryClientException {
        try {
            QueueDetails[] queueDetailsArray = new QueueDetails[0];

            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Get queues
            String queuesID = CommonsUtil.getQueuesID();
            if (registry.resourceExists(queuesID)) {
                Collection queueCollection = (Collection)registry.get(queuesID);
                queueDetailsArray = new QueueDetails[queueCollection.getChildCount()];

                int index = 0;
                for (String queueId : queueCollection.getChildren()) {
                    Collection queue = (Collection)registry.get(queueId);

                    QueueDetails queueDetails = new QueueDetails();
                    queueDetails.setName(queue.getProperty(NAME));
                    queueDetails.setOwner(queue.getProperty(OWNER));
                    queueDetails.setCreatedTime(queue.getProperty(CREATED_TIME));
View Full Code Here

    public static void createSubscription(
            String topic, String subscriptionName, String owner)
            throws RegistryClientException {
        try {
            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Add new subscription and set properties
            Collection subscription = null;
            String subscriptionID = CommonsUtil.getSubscriptionID(topic, subscriptionName);

            if (!registry.resourceExists(subscriptionID)) {
                subscription = registry.newCollection();
            } else {
                subscription = (Collection)registry.get(subscriptionID);
            }

            subscription.setProperty(OWNER, owner);
            subscription.setProperty(NAME, subscriptionName);
            subscription.setProperty(CREATED_TIME, CommonsUtil.getCurrentTime());

            registry.put(subscriptionID, subscription);
        } catch (RegistryException e) {
            throw new RegistryClientException(e);
        }
    }
View Full Code Here

    public static void deleteSubscription(
            String topic, String subscriptionName)
            throws RegistryClientException {
        try {
            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Delete subscription
            String subscriptionID = CommonsUtil.getSubscriptionID(topic, subscriptionName);
            if (registry.resourceExists(subscriptionID)) {
                registry.delete(subscriptionID);
            }
        } catch (RegistryException e) {
            throw new RegistryClientException(e);
        }
    }
View Full Code Here

            throws RegistryClientException {
        try {
            SubscriptionDetails[] subscriptionDetailsArray = new SubscriptionDetails[0];

            RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
            UserRegistry registry = registryService.getGovernanceSystemRegistry();

            // Get subscriptions
            String subscriptionsID = CommonsUtil.getSubscriptonsID(topic);
            if (registry.resourceExists(subscriptionsID)) {
                Collection subscriptionCollection = (Collection)registry.get(subscriptionsID);
                subscriptionDetailsArray =
                        new SubscriptionDetails[subscriptionCollection.getChildCount()];

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

                    SubscriptionDetails subscriptionDetails = new SubscriptionDetails();
                    subscriptionDetails.setName(subscription.getProperty(NAME));
                    subscriptionDetails.setOwner(subscription.getProperty(OWNER));
                    subscriptionDetails.setCreatedTime(subscription.getProperty(CREATED_TIME));
View Full Code Here

  }


  public SearchResultsBean getContentSearchResults(String searchQuery) throws AxisFault{
        try {
      UserRegistry registry = (UserRegistry) getRootRegistry();
            return searchContent(searchQuery, registry);
    } catch (Exception e) {
      log.error("Error " + e.getMessage() + "at the content search back end component.", e );
    }
        return new SearchResultsBean();
View Full Code Here

        if ("".equals(mediaType)) mediaType = null;
        this.mediaType = mediaType;
    }

    private boolean queryExists(Registry configSystemRegistry, String queryPath) throws RegistryException {
        UserRegistry registry = (UserRegistry) configSystemRegistry;
        return registry.resourceExists(queryPath);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.session.UserRegistry

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.