Check if the caller has permission to publish events to the specified
topic.

@param topic
the topic the event is being published to
777681
void checkTopicPublishPermission(String topic) {
        SecurityManager sm = System.getSecurityManager();
        if (sm == null)
            return;

        sm.checkPermission(new TopicPermission(topic, PUBLISH));
    }
601011
public boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod) {
		boolean allow = false;
		if (subjectid != null && !StringUtils.isBlank(resourcePath) && !StringUtils.isBlank(httpMethod)) {
			// urlDecode resource path
			resourcePath = Utils.urlDecode(resourcePath);

			if (getResourcePermissions().isEmpty()) {
				// Default policy is "deny all". Returning true here would make it "allow all".
				return false;
			}
			if (isDeniedExplicitly(subjectid, resourcePath, httpMethod)) {
				return false;
			}
			if (getResourcePermissions().containsKey(subjectid) &&
					getResourcePermissions().get(subjectid).containsKey(resourcePath)) {
				// subject-specific permissions have precedence over wildcard permissions
				// i.e. only the permissions for that subjectid are checked, other permissions are ignored
				allow = isAllowed(subjectid, resourcePath, httpMethod);
			} else {
				allow = isAllowed(subjectid, resourcePath, httpMethod) ||
						isAllowed(subjectid, ALLOW_ALL, httpMethod) ||
						isAllowed(ALLOW_ALL, resourcePath, httpMethod) ||
						isAllowed(ALLOW_ALL, ALLOW_ALL, httpMethod);
			}
		}
		if (allow) {
			if (isRootApp() && !Config.getConfigBoolean("clients_can_access_root_app", false)) {
				return false;
			}
			if (StringUtils.isBlank(subjectid)) {
				// guest access check
				return isAllowed(ALLOW_ALL, resourcePath, GUEST.toString());
			}
			return true;
		}
		return isAllowedImplicitly(subjectid, resourcePath, httpMethod);
	}
704152
def publish(self, topic, obj, reference_message=None):
        
        logging.debug("Publishing topic (%s): \n%s" % (topic, obj))
        e = Event(
            data=obj,
            type=topic,
        )
        if hasattr(obj, "sender"):
            e.sender = obj.sender

        if reference_message:
            original_incoming_event_hash = None
            if hasattr(reference_message, "original_incoming_event_hash"):
                original_incoming_event_hash = reference_message.original_incoming_event_hash
            elif hasattr(reference_message, "source") and hasattr(reference_message.source, "hash"):
                original_incoming_event_hash = reference_message.source.hash
            elif hasattr(reference_message, "source") and hasattr(reference_message.source, "original_incoming_event_hash"):
                original_incoming_event_hash = reference_message.source.original_incoming_event_hash
            elif hasattr(reference_message, "hash"):
                original_incoming_event_hash = reference_message.hash
            if original_incoming_event_hash:
                e.original_incoming_event_hash = original_incoming_event_hash

        return self.publish_to_backend(
            self._localize_topic(topic),
            self.encrypt(e)
        )
515781
@Async
    public void send(String topic, String content) {
        try {
            if (!StringUtils.isBlank(content)) {
                log.debug("Sending kafka event with data {} to topic {}", content, topic);
                template.send(topic, content);
            }
        } catch (Exception e) {
            log.error("Error send timeline event", e);
            throw e;
        }
    }
796228
public Disruptor createDisruptor(String topic) {
		TreeSet handlers = getHandles(topic);
		if (handlers == null)
			return null;

		Disruptor dw = createDw(topic);
		Disruptor disruptor = addEventMessageHandler(dw, topic, handlers);
		if (disruptor == null)
			return null;
		disruptor.start();
		return disruptor;
	}
745475
public boolean isEnabled(String topicName) {
        if (topicName == null || topicName.length() == 0) {
            throw new JavametricsException("Topic names must not be null or 0 length");
        }
        return getTopic(topicName).isEnabled();
    }
856958
public boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod) {
		if (StringUtils.isBlank(subjectid) || StringUtils.isBlank(resourcePath) || StringUtils.isBlank(httpMethod)) {
			return false;
		}
		resourcePath = Utils.urlEncode(resourcePath);
		String url = Utils.formatMessage("_permissions/{0}/{1}/{2}", subjectid, resourcePath, httpMethod);
		Boolean result = getEntity(invokeGet(url, null), Boolean.class);
		return result != null && result;
	}
559249
def can_subscribe_to_topic(self, topic, user):
        
        # A user can subscribe to topics if they are authenticated and if they have the permission
        # to read the related forum. Of course a user can subscribe only if they have not already
        # subscribed to the considered topic.
        return (
            user.is_authenticated and
            not topic.has_subscriber(user) and
            self._perform_basic_permission_check(topic.forum, user, 'can_read_forum')
        )
380689
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_move_topics(obj, user)
359317
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_update_topics_to_normal_topics(obj, user)
861259
private void publishEvent(WSJobExecution execution, WSJobInstance jobInstance, BatchStatus batchStatus) {

        if (batchStatus == BatchStatus.FAILED) {
            publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_FAILED);
            publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_FAILED);
        } else if (batchStatus == BatchStatus.COMPLETED) {
            publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_COMPLETED);
            publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_COMPLETED);
        } else if (batchStatus == BatchStatus.STOPPED) {
            publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STOPPED);
            publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_STOPPED);
            //smf call to go here, eventually
        } else if (batchStatus == BatchStatus.STOPPING) {
            publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_STOPPING);
            publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STOPPING);
        } else if (batchStatus == BatchStatus.STARTED) {
            publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_DISPATCHED);
            publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STARTED);
        }

    }
949745
def pause_topic(self, topic):
        
        nsq.assert_valid_topic_name(topic)
        return self._request('POST', '/topic/pause', fields={'topic': topic})
1209552
private void publishEndedEvent() {
        BatchEventsPublisher publisher = getBatchEventsPublisher();
        if (publisher != null) {

            publisher.publishSplitFlowEvent(getSplitName(),
                                            getFlowName(),
                                            getTopLevelInstanceId(),
                                            getTopLevelExecutionId(),
                                            BatchEventsPublisher.TOPIC_EXECUTION_SPLIT_FLOW_ENDED,
                                            correlationId);
        }
    }
835528
void sendSubscriptionEvent(String topic, int nb) {
		Collection<Session> sessions = getSessionsForTopic(topic);
		if (!sessions.isEmpty()) {
			MessageToClient messageToClient = new MessageToClient();
			messageToClient.setId(topic);
			messageToClient.setType(MessageType.MESSAGE);
			messageToClient.setResponse(nb);
//			Collection<Session> sessionsClosed = new ArrayList<>(); // throws java.lang.StackOverflowError
			for (Session session : sessions) {
				if (session.isOpen()) {
					session.getAsyncRemote().sendObject(messageToClient);
//				} else {
//					sessionsClosed.add(session);
				}
			}
//			removeSessionsToTopic(sessionsClosed);
		}
	}
667054
public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
        return Build.VERSION.SDK_INT >= 23 && getActivity().shouldShowRequestPermissionRationale(permission);
    }
945533
@Override
    public void publishEvent(FacesContext context,
                             Class<? extends SystemEvent> systemEventClass,
                             Object source) {
        getWrapped().publishEvent(context, systemEventClass, source);
    }
902856
public void removeTopic(String topic)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "removeTopic", topic);

    if (_subscriptionState == null)
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        SibTr.debug(tc, "removeTopic", "Topic not found");
    }
    else
      _subscriptionState.removeTopic(topic);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "removeTopic");
  }