Beispiel #1
0
  @Override
  public void handleEvent(Event event) {

    if (!Boolean.TRUE.equals(event.getProperty(BRIDGEMARKER))) {

      // map event from ESH to openHAB
      if (event.getTopic().startsWith(EventConstants.TOPIC_PREFIX)) {
        String topic =
            org.openhab.core.events.EventConstants.TOPIC_PREFIX
                + event.getTopic().substring(EventConstants.TOPIC_PREFIX.length());
        Map<String, Object> properties = constructProperties(event);
        eventAdmin.postEvent(new Event(topic, properties));
      }

      // map event from openHAB to ESH
      if (event.getTopic().startsWith(org.openhab.core.events.EventConstants.TOPIC_PREFIX)) {
        String topic =
            EventConstants.TOPIC_PREFIX
                + event
                    .getTopic()
                    .substring(org.openhab.core.events.EventConstants.TOPIC_PREFIX.length());
        Map<String, Object> properties = constructProperties(event);
        eventAdmin.postEvent(new Event(topic, properties));
      }
    }
  }
  /** {@inheritDoc} */
  public void handleEvent(Event event) {
    synchronized (this.monitor) {
      Bundle bundle = (Bundle) event.getProperty(EventConstants.BUNDLE);

      if (EVENT_WAITING.equals(event.getTopic())) {
        List<ServiceDependency> serviceDependencies = createServiceDependencies(event);
        for (ServiceDependency serviceDependency : serviceDependencies) {
          addServiceDependencyTicker(serviceDependency, bundle);
        }
      } else if (EVENT_GRACE_PERIOD.equals(event.getTopic())) {
        List<ServiceDependency> remainingUnsatisfiedDependencies = createServiceDependencies(event);
        changeInUnsatisfiedDependencies(remainingUnsatisfiedDependencies, bundle);

      } else if (EVENT_FAILURE.equals(event.getTopic())) {
        String[] dependenciesArray = (String[]) event.getProperty("dependencies");
        if (dependenciesArray != null) {
          List<ServiceDependency> serviceDependencies = createServiceDependencies(event);
          serviceDependenciesTimedOut(serviceDependencies, bundle);
        } else {
          containerCreationFailed(bundle);
        }
      } else if (EVENT_CREATED.equals(event.getTopic())) {
        containerCreated(bundle);
      }
    }
  }
  public Collection<SolrInputDocument> getDocuments(
      RepositorySession repositorySession, Event event) {
    String topic = event.getTopic();
    if (topic.endsWith(StoreListener.UPDATED_TOPIC) || topic.endsWith(StoreListener.ADDED_TOPIC)) {
      String path = (String) event.getProperty(FIELD_PATH);

      if (!ignore(path) && !ignoreCache.containsKey(path)) {
        IndexingHandler handler =
            getHandler(repositorySession, path, this.indexers, this.ignoreCache);

        List<SolrInputDocument> outputDocs = Lists.newArrayList();
        Collection<SolrInputDocument> docs = handler.getDocuments(repositorySession, event);
        for (SolrInputDocument doc : docs) {
          // check the fields of the returned docs to make sure they contain atleast 1
          // field that is not a system property. this is not to filter out any system
          // properties but to make sure there are more things to index than just system
          // properties.
          if (!SYSTEM_PROPERTIES.containsAll(doc.getFieldNames())) {
            try {
              addDefaultFields(doc, repositorySession);
              outputDocs.add(doc);
            } catch (StorageClientException e) {
              LOGGER.warn("Failed to index {} cause: {} ", path, e.getMessage());
            }
          }
          return outputDocs;
        }
      } else {
        LOGGER.debug("Ignored action at path:{}  require on {} ", path, event);
      }
    } else {
      LOGGER.debug("No update action require on {} ", event);
    }
    return ImmutableList.of();
  }
 @Override
 public void handleEvent(Event event) {
   if (event.getTopic().equals(com.mendix.core.event.EventConstants.ModelLoadedTopic())) {
     component = mxRuntime.getMainComponent();
     Core.initialize(component, integration);
     component.actionRegistry().registerUserAction(system.actions.VerifyPassword.class);
   }
 }
  @Override
  public void handleEvent(final org.osgi.service.event.Event event) {
    String eventName = event.getTopic();
    if (eventName.equals(IEventTopics.BROADCAST_MESSAGE)) {
      EventListener<Event> listner =
          new EventListener<Event>() {

            @Override
            public void onEvent(Event event) throws Exception {
              BroadCastMsg msg = (BroadCastMsg) event.getData();

              switch (msg.getEventId()) {
                case BroadCastUtil.EVENT_TEST_BROADCAST_MESSAGE:
                  MBroadcastMessage mbMessage =
                      MBroadcastMessage.get(Env.getCtx(), msg.getIntData());
                  String currSession =
                      Integer.toString(Env.getContextAsInt(Env.getCtx(), "AD_Session_ID"));
                  if (currSession.equals(msg.getTarget())) {
                    BroadcastMessageWindow testMessageWindow = new BroadcastMessageWindow(pnlHead);
                    testMessageWindow.appendMessage(mbMessage, true);
                    testMessageWindow = null;
                  }
                  break;
                case BroadCastUtil.EVENT_BROADCAST_MESSAGE:
                  mbMessage = MBroadcastMessage.get(Env.getCtx(), msg.getIntData());
                  if (mbMessage.isValidUserforMessage()) {

                    BroadcastMessageWindow messageWindow = new BroadcastMessageWindow(pnlHead);
                    messageWindow.appendMessage(mbMessage, false);
                  }
                  break;
                case BroadCastUtil.EVENT_SESSION_TIMEOUT:
                  currSession =
                      Integer.toString(Env.getContextAsInt(Env.getCtx(), "AD_Session_ID"));
                  if (currSession.equalsIgnoreCase(msg.getTarget())) {
                    new TimeoutPanel(pnlHead, msg.getIntData());
                  }

                  break;
                case BroadCastUtil.EVENT_SESSION_ONNODE_TIMEOUT:
                  currSession = WebUtil.getServerName();

                  if (currSession.equalsIgnoreCase(msg.getTarget())) {
                    new TimeoutPanel(pnlHead, msg.getIntData());
                  }
              }
            }
          };

      Executions.schedule(
          m_desktop,
          listner,
          new Event("OnBroadcast", null, event.getProperty(IEventManager.EVENT_DATA)));
    }
  }
 public Collection<String> getDeleteQueries(RepositorySession repositorySession, Event event) {
   String topic = event.getTopic();
   if (topic.endsWith(StoreListener.DELETE_TOPIC)) {
     final IndexingHandler indexingHandler = getHandler(repositorySession, event);
     if (indexingHandler != null) {
       return indexingHandler.getDeleteQueries(repositorySession, event);
     }
   } else {
     LOGGER.debug("No delete action require on {} ", event);
   }
   return ImmutableList.of();
 }
 public void handleEvent(org.osgi.service.event.Event event) {
   if (event.getTopic().startsWith(EVENT_TOPIC_ITEMS_NEW)) {
     String pid = (String) event.getProperty("auctionPid");
     AuctionService auction = auctions.get(pid);
     if (auction != null) {
       String itemId = (String) event.getProperty("auctionItemId");
       AuctionItem item = auction.findItem(itemId);
       if (item != null) {
         addAuctionItem(auction, item);
       }
     }
   }
 }
Beispiel #8
0
 @Override
 public void handleEvent(Event event) {
   String topic = event.getTopic();
   if (EVENT_TOPIC_DEPLOYING.equals(topic) || EVENT_TOPIC_UNDEPLOYING.equals(topic)) {
     wabStates.put((String) event.getProperty("bundle.symbolicName"), "");
   } else if (EVENT_TOPIC_DEPLOYED.equals(topic)) {
     wabStates.put((String) event.getProperty("bundle.symbolicName"), "DEPLOYED");
   } else if (EVENT_TOPIC_UNDEPLOYED.equals(topic)) {
     wabStates.put((String) event.getProperty("bundle.symbolicName"), "UNDEPLOYED");
   } else if (EVENT_TOPIC_FAILED.equals(topic)) {
     wabStates.put((String) event.getProperty("bundle.symbolicName"), "FAILED");
   }
 }
 public Collection<SolrInputDocument> getDocuments(
     RepositorySession repositorySession, Event event) {
   String topic = event.getTopic();
   if (topic.endsWith(StoreListener.UPDATED_TOPIC) || topic.endsWith(StoreListener.ADDED_TOPIC)) {
     final IndexingHandler indexingHandler = getHandler(repositorySession, event);
     if (indexingHandler != null) {
       LOGGER.debug(
           "Update action at path:{}  require on {} ", event.getProperty(FIELD_PATH), event);
       Collection<SolrInputDocument> docs = indexingHandler.getDocuments(repositorySession, event);
       List<SolrInputDocument> outputDocs = Lists.newArrayList();
       if (docs != null) {
         for (SolrInputDocument doc : docs) {
           boolean docAdded = false;
           for (String name : doc.getFieldNames()) {
             // loop through the fields of the returned docs to make sure they contain
             // atleast 1 field that is not a system property. this is not to filter out
             // any system properties but to make sure there are more things to index than
             // just system properties.
             if (!SYSTEM_PROPERTIES.contains(name)) {
               try {
                 addDefaultFields(doc, repositorySession);
                 outputDocs.add(doc);
                 docAdded = true;
               } catch (StorageClientException e) {
                 LOGGER.warn(
                     "Failed to index {} cause: {} ",
                     event.getProperty(FIELD_PATH),
                     e.getMessage());
               }
               break;
             }
           }
           if (!docAdded) {
             TelemetryCounter.incrementValue(
                 "solr", "SparseIndexingServiceImpl", "docHasOnlySysProps");
           }
         }
       }
       return outputDocs;
     } else {
       LOGGER.debug(
           "Ignored action at path:{}  require on {} ", event.getProperty(FIELD_PATH), event);
     }
   } else {
     LOGGER.debug("No update action require on {} ", event);
   }
   return ImmutableList.of();
 }
Beispiel #10
0
  /** {@inheritDoc} */
  public void handleEvent(Event event) {
    String itemName = (String) event.getProperty("item");

    String topic = event.getTopic();
    String[] topicParts = topic.split(TOPIC_SEPERATOR);

    if (!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
      return; // we have received an event with an invalid topic
    }
    String operation = topicParts[1];

    if (operation.equals(EventType.COMMAND.toString())) {
      Command command = (Command) event.getProperty("command");
      if (command != null) receiveCommand(itemName, command);
    }
  }
Beispiel #11
0
  @Override
  public void handleEvent(Event event) throws IllegalArgumentException {
    LOGGER.debug("Received activity on topic {}", event.getTopic());

    String id = (String) event.getProperty(ActivityEvent.ID_KEY);
    String session = (String) event.getProperty(ActivityEvent.SESSION_ID_KEY);
    String status = (String) event.getProperty(ActivityEvent.STATUS_KEY);
    if (status.equals(ActivityEvent.ActivityStatus.RUNNING.toString())) {
      return;
    }
    String title = (String) event.getProperty(ActivityEvent.TITLE_KEY);
    String message = (String) event.getProperty(ActivityEvent.MESSAGE_KEY);
    String timestamp = (String) event.getProperty(ActivityEvent.TIMESTAMP_KEY);
    Map<String, String> operations =
        (Map<String, String>) event.getProperty(ActivityEvent.OPERATIONS_KEY);
    String progress = event.getProperty(ActivityEvent.PROGRESS_KEY).toString();
    String user = (String) event.getProperty(ActivityEvent.USER_ID_KEY);
    String category = (String) event.getProperty(ActivityEvent.CATEGORY_KEY);
    Long bytes = (Long) event.getProperty(ActivityEvent.BYTES_READ_KEY);
    String downloadId = (String) event.getProperty(ActivityEvent.DOWNLOAD_ID_KEY);

    PersistentItem activityToStore = new PersistentItem();
    activityToStore.addIdProperty(id);
    activityToStore.addProperty(ActivityEvent.SESSION_ID_KEY, session);
    activityToStore.addProperty(ActivityEvent.STATUS_KEY, status);
    activityToStore.addProperty(ActivityEvent.TITLE_KEY, title);
    activityToStore.addProperty(ActivityEvent.MESSAGE_KEY, message);
    activityToStore.addProperty(ActivityEvent.TIMESTAMP_KEY, timestamp);
    for (Map.Entry<String, String> entry : operations.entrySet()) {
      activityToStore.addProperty(
          ActivityEvent.OPERATIONS_KEY + "_" + entry.getKey(), entry.getValue());
    }
    activityToStore.addProperty(ActivityEvent.PROGRESS_KEY, progress);
    activityToStore.addProperty(ActivityEvent.USER_ID_KEY, user);
    activityToStore.addProperty(ActivityEvent.CATEGORY_KEY, category);
    activityToStore.addProperty(ActivityEvent.BYTES_READ_KEY, bytes);
    activityToStore.addProperty(ActivityEvent.DOWNLOAD_ID_KEY, downloadId);
    try {
      persistentStore.add(PersistentStore.ACTIVITY_TYPE, activityToStore);
    } catch (PersistenceException e) {
      LOGGER.info("Caught PersistenceException {}", e.getMessage());
    }
  }
  public Collection<String> getDeleteQueries(RepositorySession repositorySession, Event event) {
    String topic = event.getTopic();
    if (topic.endsWith(StoreListener.DELETE_TOPIC)) {
      String path = (String) event.getProperty(FIELD_PATH);
      if (!ignore(path) && !ignoreCache.containsKey(path)) {
        String resourceType = (String) event.getProperty("resourceType");

        IndexingHandler handler = null;
        if (resourceType != null) {
          handler = getHandler(resourceType, this.indexers);
        } else {
          handler = getHandler(repositorySession, path, this.indexers, this.ignoreCache);
        }
        return handler.getDeleteQueries(repositorySession, event);
      }
    } else {
      LOGGER.debug("No delete action require on {} ", event);
    }
    return ImmutableList.of();
  }
  @Override
  public void handleEvent(Event event) {
    if (event.getTopic().equals(ProviderMessage.INIT_PROVIDER_LIST_RESPOND)) {

      ProviderMessage respondMessage = new ProviderMessage();
      respondMessage.setType(ProviderMessage.PROVIDER_MESSAGE);
      respondMessage.processType = ProviderMessage.INIT_PROVIDER_LIST_RESPOND;

      if (event.getProperty("providerType").equals("storage")) {
        respondMessage.providerType = "storage";
      } else if (event.getProperty("providerType").equals("mail")) {
        respondMessage.providerType = "mail";
      } else if (event.getProperty("providerType").equals("hoster")) {
        respondMessage.providerType = "hoster";
      } else return;
      respondMessage.convertToProviderVO((ArrayList<Object>) event.getProperty("provider"));
      try {
        Bridge.getInstance().sendMessage(respondMessage);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
 public void handleEvent(Event event) {
   if ("org/eclipse/virgo/kernel/userregion/systemartifacts/DEPLOYED".equals(event.getTopic())) {
     latch.countDown();
   }
 }
 public void handleEvent(final Event event) {
   logger.debug(
       "Resource event: {} at: {}",
       event.getTopic(),
       event.getProperty(SlingConstants.PROPERTY_PATH));
 }