javax.jcr.observation.Event.getUserData()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中javax.jcr.observation.Event.getUserData()方法的一些代码示例,展示了Event.getUserData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getUserData()方法的具体详情如下:
包路径:javax.jcr.observation.Event
类名称:Event
方法名:getUserData

Event.getUserData介绍

[英]Returns the user data set through ObservationManager#setUserDataon the ObservationManager bound to the Session that caused the event.
[中]通过导致事件的Session绑定的ObservationManager上的ObservationManager#setUserDataon返回用户数据集。

代码示例

代码示例来源:origin: apache/jackrabbit

/** {@inheritDoc} */
public String getUserData() throws RepositoryException, RemoteException {
  return event.getUserData();
}

代码示例来源:origin: apache/jackrabbit

@Override
public String getUserData() throws RepositoryException {
  userInfoAccessed();
  return event.getUserData();
}

代码示例来源:origin: org.fcrepo/fcrepo-kernel

/**
 * @return the user data of the underlying JCR {@link Event}s
 */
public String getUserData() {
  try {
    return e.getUserData();
  } catch (RepositoryException e1) {
    throw new RepositoryRuntimeException("Error getting event userData!", e1);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public String getUserData() throws RepositoryException {
  userInfoAccessed();
  return event.getUserData();
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

@Override
public String getUserData() throws RepositoryException {
  userInfoAccessed();
  return event.getUserData();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

/**
 * checks a generated JCR event was not created by a JCR session having set the 'userData' to {@link #DO_NOT_DISTRIBUTE}.
 *
 * @param jcrEvent an {@link javax.jcr.observation.Event}
 * @return <code>false</code> if the event was generated by a {@link javax.jcr.Session} having its
 * {@link javax.jcr.observation.ObservationManager#setUserData(String)} set to {@link #DO_NOT_DISTRIBUTE}
 * @throws javax.jcr.RepositoryException if retrieving 'userData' fails
 */
public static boolean isSafe(@NotNull Event jcrEvent) throws RepositoryException {
  boolean safe = false;
  if (jcrEvent instanceof JackrabbitEvent && !((JackrabbitEvent) jcrEvent).isExternal()) {
    String userData = jcrEvent.getUserData();
    if (!DO_NOT_DISTRIBUTE.equals(userData)) {
      safe = true;
    }
  }
  return safe;
}

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

final Map<String, String> info = new HashMap<>(event.getInfo());
final String userdata = event.getUserData();
try {
  if (userdata != null && !userdata.isEmpty()) {

代码示例来源:origin: org.onehippo.cms7.hst.components/hst-core

private void addEvent(final Event jcrEvent, final Map<String, Set<Integer>> movedNodeDetectionMap) throws RepositoryException {
  if (HippoNodeType.HIPPO_IGNORABLE.equals(jcrEvent.getUserData())) {
    log.debug("Ignore event '{}' because marked {}", jcrEvent.getPath(), HippoNodeType.HIPPO_IGNORABLE);
    return;
  }
  if (ignore(jcrEvent)) {
    log.debug("Ignore event '{}' because not an event below /hst:hst.", jcrEvent.getPath());
    return;
  }
  final String path = jcrEvent.getPath();
  final HstEvent event;
  if (isPropertyEvent(jcrEvent)) {
    event = new HstEvent(StringUtils.substringBeforeLast(path, "/"), true);
  } else {
    final int type = jcrEvent.getType();
    if (type == Event.NODE_REMOVED || type == Event.NODE_ADDED) {
      if (!movedNodeDetectionMap.containsKey(path)) {
        movedNodeDetectionMap.put(path, new HashSet<Integer>());
      }
      movedNodeDetectionMap.get(path).add(type);
    }
    event = new HstEvent(path, false);
  }
  hstEvents.add(event);
  log.debug("Collected event {}", event);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

createdNode.setProperty("date", event.getDate());
createdNode.setProperty("type", event.getType());
createdNode.setProperty("userData", event.getUserData());
createdNode.setProperty("userID", event.getUserID());

代码示例来源:origin: apache/jackrabbit

public void testUserData() throws RepositoryException {
  testRootNode.addNode(nodeName1);
  String data = createRandomString(5);
  obsMgr.setUserData(data);
  journal = obsMgr.getEventJournal();
  skipToNow();
  superuser.save();
  assertTrue("no more events", journal.hasNext());
  assertEquals("Wrong user data", data, journal.nextEvent().getUserData());
}

代码示例来源:origin: apache/jackrabbit

protected void runWithUserData(final Callable c, int eventTypes)
    throws RepositoryException {
  final String data = createRandomString(5);
  Event[] events = getEvents(new Callable() {
    public void call() throws RepositoryException {
      obsMgr.setUserData(data);
      c.call();
    }
  }, eventTypes);
  assertTrue("no events returned", events.length > 0);
  for (int i = 0; i < events.length; i++) {
    assertEquals("Wrong user data", data, events[i].getUserData());
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
  public void onEvent(EventIterator events) {
    try {
      assertEquals("magic", events.nextEvent().getUserData());
      listenerTriggered.set(true);
    } catch (RepositoryException e) {
      fail(e.getMessage());
    }
  }
};

代码示例来源:origin: apache/jackrabbit

if (e.getUserData() != null && e.getUserData().length() > 0) {
  writeObsElement(th, E_EVENTUSERDATA, firstEvent.getUserData());

代码示例来源:origin: apache/jackrabbit

DomUtil.addChildElement(eventElem, XML_EVENTUSERDATA, NAMESPACE, event.getUserData());
} catch (RepositoryException e) {
  log.error("Internal error while retrieving event user data. {}", e.getMessage());

代码示例来源:origin: ModeShape/modeshape

@FixFor( "MODE-1370" )
@Test
public void shouldReceiveUserDataWithEventWhenObservationSessionIsSameThatMadeChange() throws Exception {
  // register listener
  SimpleListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
  // add node
  Node addedNode = getRoot().addNode("node1", UNSTRUCTURED);
  // Add user-data to the observation manager ...
  String userData = "my user data";
  getRoot().getSession().getWorkspace().getObservationManager().setUserData(userData);
  save();
  // event handling
  listener.waitForEvents();
  removeListener(listener);
  // tests
  checkResults(listener);
  assertTrue("Path for added node is wrong: actual=" + listener.getEvents().get(0).getPath() + ", expected="
        + addedNode.getPath(),
        containsPath(listener, addedNode.getPath()));
  // Now check the userdata in the events ...
  for (Event event : listener.events) {
    String eventUserData = event.getUserData();
    assertThat(eventUserData, is(userData));
  }
  // Now check the userdata ...
  assertThat(listener.userData.size(), is(not(0)));
  for (String receivedUserData : listener.userData) {
    assertThat(receivedUserData, is(userData));
  }
}

代码示例来源:origin: ModeShape/modeshape

String eventUserData = event.getUserData();
assertThat(eventUserData, is(userData));

代码示例来源:origin: apache/jackrabbit

mixinTypes, e.getUserID(), e.getUserData(), e.getDate(), info);

代码示例来源:origin: ModeShape/modeshape

String eventUserData = event.getUserData();
assertThat(eventUserData, is(nullValue()));

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr

mixinTypes, e.getUserID(), e.getUserData(), e.getDate(), info);

相关文章