Ejemplo n.º 1
0
 public void logout() {
   log.debug("explicit logout");
   fireLogoutEvent();
   if (isLoggedIn()) {
     unAuthenticate();
     HttpSession session =
         BeanProvider.getContextualReference(
             HttpSession.class, new AnnotationLiteral<DeltaSpike>() {});
     session.invalidate();
     urlUtil.redirectToInternal(urlUtil.home());
   }
 }
 protected final <T extends Throwable> void handle(
     ExceptionEvent<T> event,
     LogLevel logLevel,
     FacesMessage.Severity severity,
     String messageKey,
     Object... messageArgs) {
   handle(event, logLevel, urlUtil.genericErrorPage(), severity, messageKey, messageArgs);
 }
Ejemplo n.º 3
0
  private void processWebHookDocumentMilestoneEvent(
      DocumentStatisticUpdatedEvent event,
      Collection<ContentState> contentStates,
      String message,
      int percentMilestone) {

    HProjectIteration version = projectIterationDAO.findById(event.getProjectIterationId());
    HProject project = version.getProject();

    if (!project.getWebHooks().isEmpty()) {
      WordStatistic stats =
          translationStateCacheImpl.getDocumentStatistics(
              event.getDocumentId(), event.getLocaleId());

      WordStatistic oldStats = StatisticsUtil.copyWordStatistic(stats);
      if (oldStats != null) {
        oldStats.decrement(event.getNewState(), event.getWordCount());
        oldStats.increment(event.getPreviousState(), event.getWordCount());

        boolean shouldPublish =
            hasContentStateReachedMilestone(oldStats, stats, contentStates, percentMilestone);

        if (shouldPublish) {
          HDocument document = documentDAO.getById(event.getDocumentId());

          String editorUrl =
              urlUtil.fullEditorDocumentUrl(
                  project.getSlug(),
                  version.getSlug(),
                  event.getLocaleId(),
                  LocaleId.EN_US,
                  document.getDocId());

          DocumentMilestoneEvent milestoneEvent =
              new DocumentMilestoneEvent(
                  project.getSlug(),
                  version.getSlug(),
                  document.getDocId(),
                  event.getLocaleId(),
                  message,
                  editorUrl);
          for (WebHook webHook : project.getWebHooks()) {
            publishDocumentMilestoneEvent(webHook, milestoneEvent);
          }
        }
      }
    }
  }
  protected final <T extends Throwable> void handle(
      ExceptionEvent<T> event,
      LogLevel logLevel,
      String redirectUrl,
      FacesMessage.Severity severity,
      String messageKey,
      Object... messageArgs) {
    logException(logLevel, event.getException());

    if (ContextUtils.isContextActive(WindowScoped.class)) {
      messages.clear();
      messages.addFromResourceBundle(severity, messageKey, messageArgs);
      urlUtil.redirectTo(redirectUrl);
      //            TODO urlUtil.forwardTo(redirectPath);

      // required - "stops" the JSF lifecycle
      FacesContext.getCurrentInstance().responseComplete();
    }
    // no other ExceptionHandler should handle this exception...
    event.handled();
  }