Package org.wso2.carbon.event.core.exception

Examples of org.wso2.carbon.event.core.exception.EventBrokerException


                    }
                }
                topicNode.setChildren(nodes.toArray(new TopicNode[nodes.size()]));
            }
        } catch (RegistryException e) {
            throw new EventBrokerException(e.getMessage(), e);
        }
    }
View Full Code Here


        }
    }

    public void addTopic(String topicName) throws EventBrokerException {
        if (!validateTopicName(topicName)) {
            throw new EventBrokerException("Topic name " + topicName + " is not a valid topic name. " +
                                           "Only alphanumeric characters, hyphens (-), stars(*)," +
                                           " hash(#) ,dot(.),question mark(?)" +
                                           " and underscores (_) are allowed.");
        }

        String loggedInUser = CarbonContext.getCurrentContext().getUsername();

        try {
            UserRegistry userRegistry =
                    this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
            String resourcePath = getResourcePath(topicName);

            //we add the topic only if it does not exits. if the topic exists then
            //we don't do any thing.
            if (!userRegistry.resourceExists(resourcePath)) {
                Collection collection = userRegistry.newCollection();
                userRegistry.put(resourcePath, collection);

                // Grant this user (owner) rights to update permission on newly created topic
                UserRealm userRealm = CarbonContext.getCurrentContext().getUserRealm();

                userRealm.getAuthorizationManager().authorizeUser(
                        loggedInUser, resourcePath, EventBrokerConstants.EB_PERMISSION_CHANGE_PERMISSION);
            }
        } catch (RegistryException e) {
            throw new EventBrokerException("Can not access the config registry");
        } catch (UserStoreException e) {
            throw new EventBrokerException("Error while granting user " + loggedInUser +
                                           ", permission " + EventBrokerConstants.EB_PERMISSION_CHANGE_PERMISSION +
                                           ", on topic " + topicName);
        }
    }
View Full Code Here

                }
            }
            return topicRolePermissions.toArray(
                    new TopicRolePermission[topicRolePermissions.size()]);
        } catch (UserStoreException e) {
            throw new EventBrokerException("Can not access the Userstore manager ", e);
        }
    }
View Full Code Here

        try {
            if (!userRealm.getAuthorizationManager().isUserAuthorized(
                    loggedInUser, topicResourcePath,
                    EventBrokerConstants.EB_PERMISSION_CHANGE_PERMISSION)) {
                if (!JavaUtil.isAdmin(loggedInUser)) {
                    throw new EventBrokerException(" User " + loggedInUser + " can not change" +
                                                   " the permissions of " + topicName);
                }
            }
            for (TopicRolePermission topicRolePermission : topicRolePermissions) {
                role = topicRolePermission.getRoleName();
                if (topicRolePermission.isAllowedToSubscribe()) {
                    if (!userRealm.getAuthorizationManager().isRoleAuthorized(
                            role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_SUBSCRIBE)) {
                        userRealm.getAuthorizationManager().authorizeRole(
                                role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_SUBSCRIBE);
                    }
                } else {
                    if (userRealm.getAuthorizationManager().isRoleAuthorized(
                            role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_SUBSCRIBE)) {
                        userRealm.getAuthorizationManager().denyRole(
                                role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_SUBSCRIBE);
                    }
                }

                if (topicRolePermission.isAllowedToPublish()) {
                    if (!userRealm.getAuthorizationManager().isRoleAuthorized(
                            role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_PUBLISH)) {
                        userRealm.getAuthorizationManager().authorizeRole(
                                role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_PUBLISH);
                    }
                } else {
                    if (userRealm.getAuthorizationManager().isRoleAuthorized(
                            role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_PUBLISH)) {
                        userRealm.getAuthorizationManager().denyRole(
                                role, topicResourcePath, EventBrokerConstants.EB_PERMISSION_PUBLISH);
                    }
                }
            }
        } catch (UserStoreException e) {
            throw new EventBrokerException("Can not access the user store manager", e);
        }
    }
View Full Code Here

                    }
                }
            }

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

            } else {
                return new String[0];
            }

        } catch (UserStoreException e) {
            throw new EventBrokerException("Unable to getRoles from user store", e);
        }
    }
View Full Code Here

                return true;
            } else {
                return false;
            }
        } catch (RegistryException e) {
            throw new EventBrokerException("Can not access the config registry");
        }
    }
View Full Code Here

            // we persists a subscription only if it has a event dispatcher
            // name. the subscriptions with only an event dispatcher is not persisted.
            this.subscriptionManager.addSubscription(subscription);
        } else {
            if (subscription.getEventDispatcher() == null){
                throw new EventBrokerException(" subscription url, event " +
                        "dispatcher name and event dispatcher is null");
            }
        }
        return subscription.getId();
    }
View Full Code Here

            this.topicSubscriber.close();
            this.topicSession.close();
            this.topicConnection.stop();
            this.topicConnection.close();
        } catch (JMSException e) {
            throw new EventBrokerException("Can not close connections ", e);
        }

    }
View Full Code Here

            subscription.getEventDispatcher().notify(message, subscription);
        } else if (subscription.getEventDispatcherName() != null){
            EventDispatcher eventDispatcher =
                    this.eventDispatchMap.get(subscription.getEventDispatcherName());
            if (eventDispatcher == null){
                throw new EventBrokerException("Event dispatcher with name "
                        + subscription.getEventDispatcherName() + " is not exists");
            }
            eventDispatcher.notify(message, subscription);
        } else {
            throw new EventBrokerException("Can not send the notification ");
        }

    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.event.core.exception.EventBrokerException

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.