Retrieves the event id for a SIP Response event.

@param eventLookupFacility
@param response
@return
10064
public FireableEventType getEventId(EventLookupFacility eventLookupFacility,
			Response response) {

		String statusCodeName = null;
		final int responseStatus = response.getStatusCode();
		if (responseStatus == 100) {
			statusCodeName = "TRYING";
		} else if (100 < responseStatus && responseStatus < 200) {
			statusCodeName = "PROVISIONAL";
		} else if (responseStatus < 300) {
			statusCodeName = "SUCCESS";
		} else if (responseStatus < 400) {
			statusCodeName = "REDIRECT";
		} else if (responseStatus < 500) {
			statusCodeName = "CLIENT_ERROR";
		} else if (responseStatus < 600) {
			statusCodeName = "SERVER_ERROR";
		} else {
			statusCodeName = "GLOBAL_FAILURE";
		}

		// in dialog responses use the 1.1 event id prefix
		return getEventId(eventLookupFacility, new StringBuilder(RESPONSE_EVENT_PREFIX).append(statusCodeName).toString());
	}
1076413
@SuppressWarnings({"unused", "WeakerAccess"})
    public int getCount(String event) {
        EventDetail eventDetail = getLocalDataStore().getEventDetail(event);
        if (eventDetail != null) return eventDetail.getCount();

        return -1;
    }
767749
private EventTypeEnum getEventType(Message message) {
        boolean isRequestor = MessageUtils.isRequestor(message);
        boolean isFault = MessageUtils.isFault(message);
        boolean isOutbound = MessageUtils.isOutbound(message);

        //Needed because if it is rest request and method does not exists had better to return Fault
        if(!isFault && isRestMessage(message)) {
            isFault = (message.getExchange().get("org.apache.cxf.resource.operation.name") == null);
            if (!isFault) {
                Integer responseCode = (Integer) message.get(Message.RESPONSE_CODE);
                if (null != responseCode) {
                    isFault = (responseCode >= 400);
                }
            }
        }
        if (isOutbound) {
            if (isFault) {
                return EventTypeEnum.FAULT_OUT;
            } else {
                return isRequestor ? EventTypeEnum.REQ_OUT : EventTypeEnum.RESP_OUT;
            }
        } else {
            if (isFault) {
                return EventTypeEnum.FAULT_IN;
            } else {
                return isRequestor ? EventTypeEnum.RESP_IN : EventTypeEnum.REQ_IN;
            }
        }
    }
957358
public String getEventDescriptor(Class controlInterface)
    {
        //
        // NOTE: The input controlInterface is currently unused, but included to
        // enable downstream optimization of serialization representation.  See the
        // OPTIMIZE comment below for more details.  If implemented, the interface
        // is needed to reverse the transformation from a hash back to a method or
        // descriptor.
        //
        if (_descriptor == null)
            _descriptor = computeEventDescriptor(_method);

        return _descriptor;
    }
435879
public FireableEventType getEventId(EventLookupFacility eventLookupFacility,
			Request request, boolean inDialogActivity) {

		final String requestMethod = request.getMethod();
		
		// Cancel is always the same.
		if (requestMethod.equals(Request.CANCEL))
			inDialogActivity = false;

		FireableEventType eventID = null;
		if (inDialogActivity) {
			eventID = getEventId(eventLookupFacility,
					new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString());
			if (eventID == null) {
				eventID = getEventId(eventLookupFacility,
						new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString());
			}
		} else {
			eventID = getEventId(eventLookupFacility,
					new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString());
			if (eventID == null) {
				eventID = getEventId(eventLookupFacility,
						new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString());
			}
		}
		return eventID;
	}
855659
protected EventIdentificationType setEventIdentification(
            RFC3881EventOutcomeCodes outcome,
            RFC3881EventActionCodes action,
            CodedValueType id, CodedValueType[] type,
            List<CodedValueType> purposesOfUse) {
        EventIdentificationType eventBlock = new EventIdentificationType();

        eventBlock.setEventID(id);
        eventBlock.setEventDateTime(TimestampUtils.getRFC3881Timestamp(eventDateTime));
        if (!EventUtils.isEmptyOrNull(action)) {
            eventBlock.setEventActionCode(action.getCode());
        }
        if (!EventUtils.isEmptyOrNull(outcome)) {
            eventBlock.setEventOutcomeIndicator(outcome.getCode());
        }
        if (!EventUtils.isEmptyOrNull(type, true)) {
            eventBlock.getEventTypeCode().addAll(Arrays.asList(type));
        }
        eventBlock.setPurposesOfUse(purposesOfUse);

        getAuditMessage().setEventIdentification(eventBlock);

        return eventBlock;
    }
1303708
@Override
    public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        final PipelineEventReader<XMLEventReader, XMLEvent> pipelineEventReader =
                this.wrappedComponent.getEventReader(request, response);

        final Transformer transformer = this.transformerSource.getTransformer(request, response);

        // Setup a URIResolver based on the current resource loader
        transformer.setURIResolver(this.uriResolver);

        // Configure the Transformer via injected class
        if (this.xsltParameterSource != null) {
            final Map<String, Object> transformerParameters =
                    this.xsltParameterSource.getParameters(request, response);
            if (transformerParameters != null) {
                this.logger.debug(
                        "{} - Setting Transformer Parameters: ",
                        this.beanName,
                        transformerParameters);
                for (final Map.Entry<String, Object> transformerParametersEntry :
                        transformerParameters.entrySet()) {
                    final String name = transformerParametersEntry.getKey();
                    final Object value = transformerParametersEntry.getValue();
                    if (value != null) {
                        transformer.setParameter(name, value);
                    }
                }
            }

            final Properties outputProperties =
                    this.xsltParameterSource.getOutputProperties(request, response);
            if (outputProperties != null) {
                this.logger.debug(
                        "{} - Setting Transformer Output Properties: ",
                        this.beanName,
                        outputProperties);
                transformer.setOutputProperties(outputProperties);
            }
        }

        // The event reader from the previous component in the pipeline
        final XMLEventReader eventReader = pipelineEventReader.getEventReader();

        // Wrap the event reader in a stream reader to avoid a JDK bug
        final XMLStreamReader streamReader;
        try {
            streamReader = new FixedXMLEventStreamReader(eventReader);
        } catch (XMLStreamException e) {
            throw new RuntimeException("Failed to create XMLStreamReader from XMLEventReader", e);
        }
        final Source xmlReaderSource = new StAXSource(streamReader);

        // Setup logging for the transform
        transformer.setErrorListener(this.errorListener);

        // Transform to a SAX ContentHandler to avoid JDK bug:
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6775588
        final XMLEventBufferWriter eventWriterBuffer = new XMLEventBufferWriter();
        final ContentHandler contentHandler = StaxUtils.createContentHandler(eventWriterBuffer);
        contentHandler.setDocumentLocator(new LocatorImpl());

        final SAXResult outputTarget = new SAXResult(contentHandler);
        try {
            this.logger.debug("{} - Begining XML Transformation", this.beanName);
            transformer.transform(xmlReaderSource, outputTarget);
            this.logger.debug("{} - XML Transformation complete", this.beanName);
        } catch (TransformerException e) {
            throw new RuntimeException("Failed to transform document", e);
        }

        final String mediaType = transformer.getOutputProperty(OutputKeys.MEDIA_TYPE);

        final List<XMLEvent> eventBuffer = eventWriterBuffer.getEventBuffer();
        final XMLEventReader outputEventReader =
                new XMLEventBufferReader(eventBuffer.listIterator());

        final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
        final PipelineEventReaderImpl<XMLEventReader, XMLEvent> pipelineEventReaderImpl =
                new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(
                        outputEventReader, outputProperties);
        pipelineEventReaderImpl.setOutputProperty(OutputKeys.MEDIA_TYPE, mediaType);
        return pipelineEventReaderImpl;
    }
1210319
@SuppressWarnings("unchecked")
    @Override
    public final PipelineEventReader<R, E> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        if (Included.PLAIN == this.resourcesElementsProvider.getDefaultIncludedType()) {
            this.logger.trace(
                    "{} - Resoure Aggregation Disabled, ignoring event cache and returning parent event reader directly",
                    this.beanName);
            return this.wrappedComponent.getEventReader(request, response);
        }

        // Get the key for this request from the target component and see if there is a cache entry
        final CacheKey cacheKey = this.wrappedComponent.getCacheKey(request, response);
        Element element = this.cache.get(cacheKey);
        CachedEventReader<E> cachedEventReader = null;
        if (element != null) {
            cachedEventReader = (CachedEventReader<E>) element.getObjectValue();
        }

        // If there was a cached reader return it immediately
        if (cachedEventReader == null) {
            // No cached data for key, call target component to get events and an updated cache key
            logger.debug(
                    "{} - No cached events found for key {}, calling parent",
                    this.beanName,
                    cacheKey);
            final PipelineEventReader<R, E> pipelineEventReader =
                    this.wrappedComponent.getEventReader(request, response);

            // Copy the events from the reader into a buffer to be cached
            final List<E> eventCache = new LinkedList<E>();
            for (final E event : pipelineEventReader) {
                // TODO add de-duplication logic here
                eventCache.add(event);
            }

            final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
            cachedEventReader =
                    new CachedEventReader<E>(
                            eventCache, new LinkedHashMap<String, String>(outputProperties));

            // Cache the buffer
            element = new Element(cacheKey, cachedEventReader);
            this.cache.put(element);
            logger.debug(
                    "{} - Cached {} events for key {}", this.beanName, eventCache.size(), cacheKey);
        } else {
            logger.debug("{} - Found cached events for key {}", this.beanName, cacheKey);
        }

        final List<E> eventCache = cachedEventReader.getEventCache();
        final Map<String, String> outputProperties = cachedEventReader.getOutputProperties();

        final R eventReader = this.createEventReader(eventCache.listIterator());
        return new PipelineEventReaderImpl<R, E>(eventReader, outputProperties);
    }
373453
private static Node checkFollowedIdentifier(
			final HttpServletRequest request,
			final DeleteFollowResponse response) {
		final String followedId = request
				.getParameter(ProtocolConstants.Parameters.Delete.Follow.FOLLOWED_IDENTIFIER);
		if (followedId != null) {
			final Node followed = NeoUtils.getUserByIdentifier(followedId);
			if (followed != null) {
				return followed;
			}
			response.followedIdentifierInvalid(followedId);
		} else {
			response.followedIdentifierMissing();
		}

		return null;
	}
429125
public OvhConferenceParticipants billingAccount_conference_serviceName_participants_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
		String qPath = "/telephony/{billingAccount}/conference/{serviceName}/participants/{id}";
		StringBuilder sb = path(qPath, billingAccount, serviceName, id);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhConferenceParticipants.class);
	}
1309016
@Override
    public void eventFired(EventModel event) {
        if (event.containsDescriptor(SoundIDs.StartRequest.descriptor)) {
            Identification identification = event.getListResourceContainer().provideResource("izou.common.resource.selector").stream()
                    .map(ResourceModel::getResource)
                    .filter(resource -> resource instanceof Identification)
                    .map(resource -> (Identification) resource)
                    .findFirst()
                    .orElseGet(event::getSource);

            AddOnModel addonModel = getMain().getAddOnInformationManager().getAddonModel(identification);

            if (addonModel != null) {
                requestPermanent(addonModel,
                        event.getSource(), event.containsDescriptor(SoundIDs.StartEvent.isUsingNonJava));
            }

        } else if (event.containsDescriptor(SoundIDs.StartEvent.descriptor)) {
            checkAndUpdateIdentification(event.getSource());
        } else {
            Identification identification = event.getListResourceContainer().provideResource("izou.common.resource.selector").stream()
                    .map(ResourceModel::getResource)
                    .filter(resource -> resource instanceof Identification)
                    .map(resource -> (Identification) resource)
                    .findFirst()
                    .orElseGet(event::getSource);
            AddOnModel addonModel = getMain().getAddOnInformationManager().getAddonModel(identification);
            if (addonModel != null) {
                endPermanent(addonModel);
            }
        }
    }
699414
@Override
    public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        final PipelineEventReader<XMLEventReader, XMLEvent> pipelineEventReader =
                this.wrappedComponent.getEventReader(request, response);

        final XMLEventReader eventReader = pipelineEventReader.getEventReader();

        final IStylesheetDescriptor stylesheetDescriptor =
                stylesheetAttributeSource.getStylesheetDescriptor(request);

        final IPortalRequestInfo portalRequestInfo =
                this.urlSyntaxProvider.getPortalRequestInfo(request);

        final XMLEventReader filteredEventReader;
        if (portalRequestInfo.getTargetedPortletWindowId() == null) {
            final IStylesheetParameterDescriptor defaultWindowStateParam =
                    stylesheetDescriptor.getStylesheetParameterDescriptor(
                            "dashboardForcedWindowState");
            if (defaultWindowStateParam != null) {
                // Set all window states to the specified default
                final WindowState windowState =
                        PortletUtils.getWindowState(defaultWindowStateParam.getDefaultValue());
                filteredEventReader =
                        new SinglePortletWindowStateSettingXMLEventReader(
                                request, eventReader, windowState);
            } else {
                // Make sure there aren't any portlets in a "targeted" window state
                filteredEventReader =
                        new NonTargetedPortletWindowStateSettingXMLEventReader(
                                request, eventReader);
            }
        } else {
            // Not mobile, don't bother filtering
            filteredEventReader = eventReader;
        }

        final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
        return new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(
                filteredEventReader, outputProperties);
    }
1176822
private void consumeNextEvent(
      EventLog<LeadershipEventListener<String>, LeadershipEvent<String>> eventLog,
      String name,
      String id,
      AsyncResponse response) {
    eventLog.nextEvent().whenComplete((event, error) -> {
      if (error == null) {
        if (event.newLeadership().leader() != null && event.newLeadership().leader().id().equals(id)) {
          response.resume(Response.ok(new LeadershipResponse(event.newLeadership())).build());
        } else if (event.newLeadership().candidates().stream().noneMatch(c -> c.equals(id))) {
          getPrimitive(name).thenCompose(election -> election.removeListener(eventLog.listener())).whenComplete((removeResult, removeError) -> {
            response.resume(Response.status(Status.NOT_FOUND).build());
          });
        }
      } else {
        response.resume(Response.status(Status.NOT_FOUND).build());
      }
    });
  }
393431
public static ServerSentEvent withEventId(ByteBuf eventId, ByteBuf data) {
        return new ServerSentEvent(eventId, null, data);
    }
434931
@SuppressWarnings("unchecked")
    @EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING)
    public void handleSearchRequest(EventRequest request, EventResponse response) {
        // UP-3887 Design flaw.  Both the searchLauncher portlet instance and the search portlet
        // instance receive
        // searchRequest and searchResult events because they are in the same portlet code base (to
        // share
        // autosuggest_handler.jsp and because we have to calculate the search portlet url for the
        // ajax call)
        // and share the portlet.xml which defines the event handling behavior.
        // If this instance is the searchLauncher, ignore the searchResult. The search was submitted
        // to the search
        // portlet instance.
        final String searchLaunchFname =
                request.getPreferences().getValue(SEARCH_LAUNCH_FNAME, null);
        if (searchLaunchFname != null) {
            // Noisy in debug mode so commented out log statement
            // logger.debug("SearchLauncher does not participate in SearchRequest events so
            // discarding message");
            return;
        }

        final Event event = request.getEvent();
        final SearchRequest searchQuery = (SearchRequest) event.getValue();

        // Map used to track searches that have been handled, used so that one search doesn't get
        // duplicate results
        ConcurrentMap<String, Boolean> searchHandledCache;
        final PortletSession session = request.getPortletSession();
        synchronized (org.springframework.web.portlet.util.PortletUtils.getSessionMutex(session)) {
            searchHandledCache =
                    (ConcurrentMap<String, Boolean>)
                            session.getAttribute(
                                    SEARCH_HANDLED_CACHE_NAME, PortletSession.APPLICATION_SCOPE);
            if (searchHandledCache == null) {
                searchHandledCache =
                        CacheBuilder.newBuilder()
                                .maximumSize(20)
                                .expireAfterAccess(5, TimeUnit.MINUTES)
                                .<String, Boolean>build()
                                .asMap();
                session.setAttribute(
                        SEARCH_HANDLED_CACHE_NAME,
                        searchHandledCache,
                        PortletSession.APPLICATION_SCOPE);
            }
        }

        final String queryId = searchQuery.getQueryId();
        if (searchHandledCache.putIfAbsent(queryId, Boolean.TRUE) != null) {
            // Already handled this search request
            return;
        }

        // Create the results
        final SearchResults results = new SearchResults();
        results.setQueryId(queryId);
        results.setWindowId(request.getWindowID());
        final List<SearchResult> searchResultList = results.getSearchResult();

        // Run the search for each service appending the results
        for (IPortalSearchService searchService : searchServices) {
            try {
                logger.debug(
                        "For queryId {}, query '{}', searching search service {}",
                        queryId,
                        searchQuery.getSearchTerms(),
                        searchService.getClass().toString());
                final SearchResults serviceResults =
                        searchService.getSearchResults(request, searchQuery);
                logger.debug(
                        "For queryId {}, obtained {} results from search service {}",
                        queryId,
                        serviceResults.getSearchResult().size(),
                        searchService.getClass().toString());
                searchResultList.addAll(serviceResults.getSearchResult());
            } catch (Exception e) {
                logger.warn(
                        searchService.getClass()
                                + " threw an exception when searching, it will be ignored. "
                                + searchQuery,
                        e);
            }
        }

        // Respond with a results event if results were found
        if (!searchResultList.isEmpty()) {
            response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, results);
        }
    }
141215
public boolean isEventStream() {
		boolean isEventStream = false;
		if (!getResponseHeader().isEmpty()) {
			isEventStream = getResponseHeader().hasContentType("text/event-stream");
		} else {
			// response not available
			// is request for event-stream?
			String acceptHeader = getRequestHeader().getHeader("Accept");
			if (acceptHeader != null && acceptHeader.equals("text/event-stream")) {
				// request is for an SSE stream
				isEventStream = true;
			}
		}
		
		return isEventStream;
	}
413636
public static EventType getEventType(Key key)
    {
        Key ek = findAncestor(Repository.EVENTTYPE, key);
        return EventType.values()[(int)ek.getId()-1];
    }