コード例 #1
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.sakaiproject.nakamura.api.message.LiteMessageTransport#send(org.sakaiproject.nakamura.api.message.MessageRoutes,
   *     org.osgi.service.event.Event, org.sakaiproject.nakamura.api.lite.content.Content)
   */
  public void send(MessageRoutes routes, Event event, Content message) {
    LOGGER.debug("Started handling an email message");

    // delay list instantiation to save object creation when not needed.
    List<String> recipients = null;
    for (MessageRoute route : routes) {
      if (TYPE.equals(route.getTransport())) {
        if (recipients == null) {
          recipients = new ArrayList<String>();
        }
        recipients.add(route.getRcpt());
      }
    }

    if (recipients != null) {
      Properties props = new Properties();
      if (event != null) {
        for (String propName : event.getPropertyNames()) {
          Object propValue = event.getProperty(propName);
          props.put(propName, propValue);
        }
      }
      // make the message deliver to one listener, that means the desination must be a queue.
      props.put(EventDeliveryConstants.DELIVERY_MODE, EventDeliveryMode.P2P);
      // make the message persistent to survive restarts.
      props.put(EventDeliveryConstants.MESSAGE_MODE, EventMessageMode.PERSISTENT);
      props.put(LiteOutgoingEmailMessageListener.RECIPIENTS, recipients);
      props.put(LiteOutgoingEmailMessageListener.CONTENT_PATH_PROPERTY, message.getPath());
      Event emailEvent = new Event(LiteOutgoingEmailMessageListener.QUEUE_NAME, (Map) props);

      LOGGER.debug("Sending event [" + emailEvent + "]");
      eventAdmin.postEvent(emailEvent);
    }
  }
コード例 #2
0
ファイル: EventBridge.java プロジェクト: ingomauser/openhab2
  @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));
      }
    }
  }
コード例 #3
0
        @Override
        public void handleEvent(Event event) {
          Object element = event.getProperty(UIEvents.EventTags.ELEMENT);
          if (!(element instanceof MPartStack)) {
            return;
          }

          Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
          Object oldValue = event.getProperty(UIEvents.EventTags.OLD_VALUE);

          boolean minimizedTagAdded =
              UIEvents.isADD(event) && IPresentationEngine.MINIMIZED.equals(newValue);
          boolean minimizedTagRemoved =
              UIEvents.isREMOVE(event) && IPresentationEngine.MINIMIZED.equals(oldValue);

          if (!(minimizedTagAdded || minimizedTagRemoved)) {
            return;
          }

          MPart part = toPart(((MPartStack) element).getSelectedElement());
          if (part != null && minimizedTagAdded) {
            firePartHidden(part);
          } else if (part != null) {
            firePartVisible(part);
          }
        }
コード例 #4
0
  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();
  }
コード例 #5
0
        public void handleEvent(Event event) {
          if (psTB.isDisposed()) {
            return;
          }

          MUIElement changedElement = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);

          if (psME == null || !(changedElement instanceof MPerspective)) return;

          String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
          Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);

          MWindow perspWin = modelService.getTopLevelWindowFor(changedElement);
          MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
          if (perspWin != switcherWin) return;

          MPerspective perspective = (MPerspective) changedElement;
          if (!perspective.isToBeRendered()) return;

          for (ToolItem ti : psTB.getItems()) {
            if (ti.getData() == perspective) {
              updateToolItem(ti, attName, newValue);
            }
          }

          // update the size
          fixSize();
        }
コード例 #6
0
 public void handleEvent(Event event) {
   // Ensure that this event is for a MMenuItem
   if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBar)) return;
   MToolBar toolbarModel = (MToolBar) event.getProperty(UIEvents.EventTags.ELEMENT);
   if (UIEvents.isADD(event)) {
     Object obj = toolbarModel;
     processContents((MElementContainer<MUIElement>) obj);
   }
 }
コード例 #7
0
ファイル: EventBridge.java プロジェクト: ingomauser/openhab2
 private Map<String, Object> constructProperties(Event event) {
   String[] propertyNames = event.getPropertyNames();
   Map<String, Object> properties = new HashMap<>();
   for (String propertyName : propertyNames) {
     properties.put(propertyName, event.getProperty(propertyName));
   }
   properties.put(BRIDGEMARKER, true);
   return properties;
 }
コード例 #8
0
        public void handleEvent(Event event) {
          // Ensure that this event is for a MMenuItem
          if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MMenuItem)) return;

          MMenuItem itemModel = (MMenuItem) event.getProperty(UIEvents.EventTags.ELEMENT);
          IContributionItem ici = getContribution(itemModel);
          if (ici != null) {
            ici.update();
          }
        }
コード例 #9
0
  @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)));
    }
  }
コード例 #10
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.sakaiproject.nakamura.api.solr.IndexingHandler#getDeleteQueries(org.sakaiproject.nakamura.api.solr.RepositorySession,
  *     org.osgi.service.event.Event)
  */
 @Override
 public Collection<String> getDeleteQueries(RepositorySession repoSession, Event event) {
   List<String> retval = Collections.emptyList();
   LOGGER.debug("getDeleteQueries for {}", event);
   String path = (String) event.getProperty(IndexingHandler.FIELD_PATH);
   String resourceType = (String) event.getProperty("resourceType");
   if (CONTENT_TYPES.contains(resourceType)) {
     retval = ImmutableList.of("id:" + ClientUtils.escapeQueryChars(path));
   }
   return retval;
 }
コード例 #11
0
ファイル: LogAppender.java プロジェクト: CMoH/karaf-decanter
 @Override
 public void handleEvent(Event event) {
   StringBuilder builder = new StringBuilder();
   for (String innerKey : event.getPropertyNames()) {
     builder
         .append(innerKey)
         .append(":")
         .append(event.getProperty(innerKey).toString())
         .append(" | ");
   }
   LOGGER.info(builder.toString());
 }
コード例 #12
0
        public void handleEvent(Event event) {
          // Ensure that this event is for a MMenuItem
          if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) return;

          MToolBarElement itemModel =
              (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT);
          String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
          if (UIEvents.UIElement.TOBERENDERED.equals(attName)) {
            Object obj = itemModel.getParent();
            if (!(obj instanceof MToolBar)) {
              return;
            }
            ToolBarManager parent = getManager((MToolBar) obj);
            if (itemModel.isToBeRendered()) {
              if (parent != null) {
                modelProcessSwitch(parent, itemModel);
                parent.update(true);
                ToolBar tb = parent.getControl();
                if (tb != null && !tb.isDisposed()) {
                  tb.pack(true);
                  tb.getShell().layout(new Control[] {tb}, SWT.DEFER);
                }
              }
            } else {
              IContributionItem ici = modelToContribution.remove(itemModel);
              if (ici != null && parent != null) {
                parent.remove(ici);
              }
              if (ici != null) {
                ici.dispose();
              }
            }
          } else if (UIEvents.UIElement.VISIBLE.equals(attName)) {
            IContributionItem ici = getContribution(itemModel);
            if (ici == null) {
              return;
            }
            ici.setVisible(itemModel.isVisible());
            ToolBarManager parent = (ToolBarManager) ((ContributionItem) ici).getParent();
            if (parent != null) {
              parent.markDirty();
              parent.update(true);
              // MUIElement tbModel = itemModel.getParent();
              // disposeToolbarIfNecessary((MToolBar) tbModel);
              ToolBar tb = parent.getControl();
              if (tb != null && !tb.isDisposed()) {
                tb.pack(true);
                tb.getShell().layout(new Control[] {tb}, SWT.DEFER);
              }
            }
          }
        }
コード例 #13
0
 public void handleEvent(Event event) {
   Object element = event.getProperty(UIEvents.EventTags.ELEMENT);
   String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
   if (element instanceof MMenuItem) {
     MMenuItem itemModel = (MMenuItem) element;
     if (UIEvents.UIElement.TOBERENDERED.equals(attName)) {
       Object obj = itemModel.getParent();
       if (!(obj instanceof MMenu)) {
         return;
       }
       MenuManager parent = getManager((MMenu) obj);
       if (itemModel.isToBeRendered()) {
         if (parent != null) {
           modelProcessSwitch(parent, itemModel);
         }
       } else {
         IContributionItem ici = getContribution(itemModel);
         clearModelToContribution(itemModel, ici);
         if (ici != null && parent != null) {
           parent.remove(ici);
         }
         if (ici != null) {
           ici.dispose();
         }
       }
     }
   }
   if (UIEvents.UIElement.VISIBLE.equals(attName)) {
     if (element instanceof MMenu) {
       MMenu menuModel = (MMenu) element;
       MenuManager manager = getManager(menuModel);
       if (manager == null) {
         return;
       }
       manager.setVisible(menuModel.isVisible());
       if (manager.getParent() != null) {
         manager.getParent().markDirty();
       }
     } else if (element instanceof MMenuElement) {
       MMenuElement itemModel = (MMenuElement) element;
       Object obj = getContribution(itemModel);
       if (!(obj instanceof ContributionItem)) {
         return;
       }
       ContributionItem item = (ContributionItem) obj;
       item.setVisible(itemModel.isVisible());
       if (item.getParent() != null) {
         item.getParent().markDirty();
       }
     }
   }
 }
コード例 #14
0
ファイル: WARDeployer.java プロジェクト: eclipse/virgo.web
 @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");
   }
 }
コード例 #15
0
 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);
       }
     }
   }
 }
  private List<ServiceDependency> createServiceDependencies(Event event) {
    String[] filters = (String[]) event.getProperty("dependencies");
    String[] beanNames = (String[]) event.getProperty("bean.name");

    List<ServiceDependency> serviceDependencies = new ArrayList<ServiceDependency>();

    if (filters != null) {
      for (int i = 0; i < filters.length; i++) {
        serviceDependencies.add(new ServiceDependency(filters[i], beanNames[i]));
      }
    }

    return serviceDependencies;
  }
コード例 #17
0
 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();
 }
コード例 #18
0
 @Override
 public void handleEvent(Event event) {
   Object data = event.getProperty(EventUtils.DATA);
   if (data instanceof Media) {
     insertMedia((Media) data);
   }
 }
コード例 #19
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.sakaiproject.nakamura.api.solr.IndexingHandler#getDocuments(org.sakaiproject.nakamura.api.solr.RepositorySession,
   *     org.osgi.service.event.Event)
   */
  @Override
  public Collection<SolrInputDocument> getDocuments(RepositorySession repoSession, Event event) {
    LOGGER.debug("getDocuments for {}", event);
    String path = (String) event.getProperty(IndexingHandler.FIELD_PATH);

    List<SolrInputDocument> documents = Lists.newArrayList();
    if (!StringUtils.isBlank(path)) {
      Session session = repoSession.adaptTo(Session.class);
      try {
        ContentManager cm = session.getContentManager();
        Content content = cm.get(path);
        SolrInputDocument doc = new SolrInputDocument();
        for (Entry<String, String> prop : PROPERTIES.entrySet()) {
          String key = prop.getKey();
          Object value = content.getProperty(key);
          if (value != null) {
            doc.addField(PROPERTIES.get(key), value);
          }
        }
        doc.setField(_DOC_SOURCE_OBJECT, content);
        documents.add(doc);
      } catch (StorageClientException e) {
        LOGGER.error(e.getMessage(), e);
      } catch (AccessDeniedException e) {
        LOGGER.error(e.getMessage(), e);
      }
    }
    return documents;
  }
コード例 #20
0
ファイル: Events.java プロジェクト: nokia/RED
 public static <T> T get(final Event event, final String key, final Class<T> expectedDataClass) {
   final Object data = event.getProperty(key);
   if (data != null && expectedDataClass.isAssignableFrom(data.getClass())) {
     return expectedDataClass.cast(data);
   }
   return null;
 }
コード例 #21
0
ファイル: RuleEngine.java プロジェクト: cvanorman/openhab
  /** {@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);
    }
  }
コード例 #22
0
        public void handleEvent(Event event) {
          if (psTB.isDisposed()) {
            return;
          }

          Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);

          if (psME == null || !(changedObj instanceof MPerspectiveStack)) return;

          MWindow perspWin = modelService.getTopLevelWindowFor((MUIElement) changedObj);
          MWindow switcherWin = modelService.getTopLevelWindowFor(psME);
          if (perspWin != switcherWin) return;

          if (UIEvents.isADD(event)) {
            for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
              MPerspective added = (MPerspective) o;
              // Adding invisible elements is a NO-OP
              if (!added.isToBeRendered()) continue;

              addPerspectiveItem(added);
            }
          } else if (UIEvents.isREMOVE(event)) {
            for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.OLD_VALUE)) {
              MPerspective removed = (MPerspective) o;
              // Removing invisible elements is a NO-OP
              if (!removed.isToBeRendered()) continue;

              removePerspectiveItem(removed);
            }
          }
        }
コード例 #23
0
        public void handleEvent(Event event) {
          Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
          if (!(changedObj instanceof MTrimmedWindow)) return;

          MTrimmedWindow window = (MTrimmedWindow) changedObj;
          if (window.getWidget() == null) return;

          String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
          if (UIEvents.EventTypes.ADD.equals(eventType)) {
            MUIElement added = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
            if (added.isToBeRendered()) createGui(added, window.getWidget(), window.getContext());
          } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
            MUIElement removed = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
            if (removed.getRenderer() != null) removeGui(removed);
          }
        }
コード例 #24
0
 @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);
   }
 }
コード例 #25
0
        @Override
        public void handleEvent(Event event) {
          Object changedObj = event.getProperty(EventTags.ELEMENT);

          if (!(changedObj instanceof MPerspectiveStack)) {
            return;
          }

          final MPerspectiveStack changedElement = (MPerspectiveStack) changedObj;

          String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
          String tag = (String) event.getProperty(UIEvents.EventTags.NEW_VALUE);
          String oldVal = (String) event.getProperty(UIEvents.EventTags.OLD_VALUE);

          if (UIEvents.EventTypes.ADD.equals(eventType) && Tags.ICONS_ONLY.equals(tag)) {
            for (Map.Entry<MPerspective, TwoStateToolbarButton> entry :
                perspective_button.entrySet()) {
              MPerspective perspective = entry.getKey();
              TwoStateToolbarButton button = entry.getValue();

              button.setLabelAndIcon(null, Commons.trim(perspective.getIconURI()));

              ContextMenu menu = button2ContextMenu.get(button);
              //					menu.removeItem(showTextItem);
              //					showTextItem = menu.addItem("Show Text");
              //					showTextItem.addStyleName("close-perspective-item"); //bugfixing style for ie9
              // (context menu addon has bug for ie9)
            }
          } else if (UIEvents.EventTypes.REMOVE.equals(eventType)
              && Tags.ICONS_ONLY.equals(oldVal)) {
            for (Map.Entry<MPerspective, TwoStateToolbarButton> entry :
                perspective_button.entrySet()) {
              MPerspective perspective = entry.getKey();
              TwoStateToolbarButton button = entry.getValue();
              button.setLabelAndIcon(
                  Commons.trim(perspective.getLabel()), Commons.trim(perspective.getIconURI()));

              ContextMenu menu = button2ContextMenu.get(button);
              //					menu.removeItem(showTextItem);
              //					showTextItem = menu.addItem("Hide Text");
              //					showTextItem.addStyleName("close-perspective-item"); //bugfixing style for ie9
              // (context menu addon has bug for ie9)
            }
          }
        }
コード例 #26
0
        public void handleEvent(Event event) {
          // Ensure that this event is for a MMenuItem
          if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MMenuItem)) return;

          MMenuItem itemModel = (MMenuItem) event.getProperty(UIEvents.EventTags.ELEMENT);

          IContributionItem ici = getContribution(itemModel);
          if (ici == null) {
            return;
          }

          String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
          if (UIEvents.UILabel.LABEL.equals(attName)) {
            ici.update();
          } else if (UIEvents.UILabel.ICONURI.equals(attName)) {
            ici.update();
          }
        }
コード例 #27
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.sakaiproject.nakamura.api.solr.IndexingHandler#getDeleteQueries(org.sakaiproject.nakamura.api.solr.RepositorySession,
  *     org.osgi.service.event.Event)
  */
 public Collection<String> getDeleteQueries(RepositorySession repositorySession, Event event) {
   LOGGER.debug("GetDelete for {} ", event);
   String path = (String) event.getProperty("path");
   boolean ignore = ignorePath(path);
   if (ignore) {
     return Collections.emptyList();
   } else {
     return ImmutableList.of(FIELD_ID + ":" + ClientUtils.escapeQueryChars(path));
   }
 }
コード例 #28
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.sakaiproject.nakamura.api.solr.IndexingHandler#getDocuments(org.sakaiproject.nakamura.api.solr.RepositorySession,
   *     org.osgi.service.event.Event)
   */
  public Collection<SolrInputDocument> getDocuments(
      RepositorySession repositorySession, Event event) {
    String path = (String) event.getProperty(FIELD_PATH);

    logger.info("Indexing connections at path {}", path);
    List<SolrInputDocument> documents = Lists.newArrayList();
    if (!StringUtils.isBlank(path)) {
      try {
        Session session = repositorySession.adaptTo(Session.class);
        ContentManager cm = session.getContentManager();
        Content content = cm.get(path);

        int lastSlash = path.lastIndexOf('/');
        String contactName = path.substring(lastSlash + 1);
        AuthorizableManager am = session.getAuthorizableManager();
        Authorizable contactAuth = am.findAuthorizable(contactName);

        if (content != null && contactAuth != null) {
          SolrInputDocument doc = new SolrInputDocument();
          for (Entry<String, String> prop : WHITELISTED_PROPS.entrySet()) {
            String key = prop.getKey();
            Object value = content.getProperty(key);
            if (value != null) {
              doc.addField(WHITELISTED_PROPS.get(key), value);
            }
          }

          // flatten out the contact so we can search it
          Map<String, Object> contactProps = contactAuth.getSafeProperties();
          if (contactAuth != null) {
            for (String prop : FLATTENED_PROPS) {
              Object value = contactProps.get(prop);
              if (value != null) {
                doc.addField(prop, value);
              }
            }
          }

          doc.addField(_DOC_SOURCE_OBJECT, content);
          documents.add(doc);
        } else {
          logger.warn(
              "Did not index {}: Content == {}; Contact Auth == {}",
              new Object[] {path, content, contactAuth});
        }
      } catch (StorageClientException e) {
        logger.error(e.getMessage(), e);
      } catch (AccessDeniedException e) {
        logger.error(e.getMessage(), e);
      }
    }
    logger.debug("Got documents {} ", documents);
    return documents;
  }
コード例 #29
0
 public void handleEvent(Event event) {
   log.debug("SSE listener running on event {}", event);
   Object pathProperty = event.getProperty("replication.package.paths");
   Object agentNameProperty = event.getProperty("replication.agent.name");
   log.debug("cached events {}", cachedEvents.size());
   if (pathProperty != null && agentNameProperty != null) {
     String agentName = String.valueOf(agentNameProperty);
     String[] paths = (String[]) pathProperty;
     synchronized (cachedEvents) {
       log.debug("queue event for agent {} on paths {}", agentName, Arrays.toString(paths));
       Collection<String> eventsForAgent = cachedEvents.get(agentName);
       if (eventsForAgent == null) {
         eventsForAgent = new LinkedList<String>();
       }
       eventsForAgent.add(Arrays.toString(paths));
       cachedEvents.put(agentName, eventsForAgent);
       cachedEvents.notifyAll();
     }
   }
 }
コード例 #30
0
 @Override
 public boolean post(String topic, Object data) {
   Event event = constructEvent(topic, data);
   Activator activator = Activator.getDefault();
   if (activator == null) {
     if (logger != null) {
       logger.error(NLS.bind(ServiceMessages.NO_EVENT_ADMIN, event.toString()));
     }
     return false;
   }
   EventAdmin eventAdmin = activator.getEventAdmin();
   if (eventAdmin == null) {
     if (logger != null) {
       logger.error(NLS.bind(ServiceMessages.NO_EVENT_ADMIN, event.toString()));
     }
     return false;
   }
   eventAdmin.postEvent(event);
   return true;
 }