本文整理了Java中org.hippoecm.repository.util.JcrUtils.getNodeIfExists()
方法的一些代码示例,展示了JcrUtils.getNodeIfExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JcrUtils.getNodeIfExists()
方法的具体详情如下:
包路径:org.hippoecm.repository.util.JcrUtils
类名称:JcrUtils
方法名:getNodeIfExists
JcrUtils.getNodeIfExists介绍
[英]Gets the node at absPath
or null
if no such node exists.
[中]获取位于absPath
或null
的节点(如果不存在此类节点)。
代码示例
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
private Node getJobNode(final String jobName, final String groupName) throws RepositoryException {
synchronized (session) {
final Node moduleCOnfig= session.getNode(moduleConfigPath);
final Node groupNode = JcrUtils.getNodeIfExists(moduleConfig, getGroupName(groupName));
if (groupNode != null) {
return JcrUtils.getNodeIfExists(groupNode, jobName);
}
}
return null;
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
public void save(Node node) throws RepositoryException {
long start = 0;
final Node derivatesFolder = JcrUtils.getNodeIfExists(DERIVATIVES_PATH, session);
if (derivatesFolder == null) {
return;
}
if (log.isDebugEnabled()) {
start = System.currentTimeMillis();
log.debug("Derived engine active");
}
try {
final Collection nodesToCompute = findNodesToCompute(node);
if (log.isDebugEnabled()) {
log.debug("Derived engine found " + nodesToCompute.size() + " nodes to be evaluated in " +
(System.currentTimeMillis() - start) + " ms");
}
for (Node modified : nodesToCompute) {
compute(derivatesFolder, modified);
}
} catch (NamespaceException | ConstraintViolationException ex) {
log.error(ex.getClass().getName() + ": " + ex.getMessage(), ex);
} finally {
if (log.isDebugEnabled()) {
log.debug("Derived engine done in " + (System.currentTimeMillis() - start) + " ms");
}
}
}
代码示例来源:origin: org.onehippo.cms7.hst/hst-content-beans
try {
nodePath = node.getPath();
final Node relNode = JcrUtils.getNodeIfExists(node, relPath);
if (relNode == null) {
log.info("Cannot get object for node '{}' with relPath '{}'", nodePath , relPath);
final Node document = JcrUtils.getNodeIfExists(relNode, relNode.getName());
if (document == null) {
log.info("Cannot get object for node '{}' with relPath '{}'", nodePath, relPath);
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
private void buildRegistry() {
Map> updatedUpdaters = new HashMap<>();
try {
final Node registry = JcrUtils.getNodeIfExists(UPDATE_REGISTRY_PATH, session);
if (registry != null) {
for (final Node node : new NodeIterable(registry.getNodes())) {
final String updaterName = node.getName();
try {
final UpdaterInfo updaterInfo = new UpdaterInfo(node);
if (updaterInfo.getNodeType() != null) {
List list = updatedUpdaters.get(updaterInfo.getNodeType());
if (list == null) {
list = new ArrayList<>();
updatedUpdaters.put(updaterInfo.getNodeType(), list);
}
list.add(updaterInfo);
}
} catch (Exception e) {
log.error("Failed to register updater '{}': {}", updaterName, e.toString());
}
}
}
} catch (RepositoryException e) {
log.error("Failed to build updater registry", e);
}
updaters = updatedUpdaters;
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
public static int getNodeIndex(final Session session, final String nodePath) throws RepositoryException {
final Node node = JcrUtils.getNodeIfExists(nodePath, session);
if (node != null && node.getParent().getPrimaryNodeType().hasOrderableChildNodes()) {
final NodeIterator nodes = node.getParent().getNodes();
int index = 0;
while (nodes.hasNext()) {
if (nodes.nextNode().isSame(node)) {
return index;
}
index++;
}
}
return -1;
}
代码示例来源:origin: org.onehippo.cms7.hst.components/hst-core
try {
session = repository.login(credentials);
final Node templateComposerNode = JcrUtils.getNodeIfExists(jcrPathTemplateComposer, session);
if (templateComposerNode == null) {
log.warn("Missing jcr node at '{}' to read required configured admin privileges from: Return empty SecurityModel.",
代码示例来源:origin: org.onehippo.cms7/hippo-repository-api
@Override
public void onEvent(final EventIterator events) {
boolean recOnfigure= false;
while (events.hasNext()) {
try {
if (isReconfigureEvent(events.nextEvent())) {
recOnfigure= true;
break;
}
} catch (RepositoryException e) {
log.error("Failed to determine if event is a reconfigure event", e);
}
}
if (reconfigure) {
try {
final Node moduleCOnfig= JcrUtils.getNodeIfExists(moduleConfigPath, session);
if (moduleConfig != null) {
onConfigurationChange(moduleConfig);
} else {
log.warn("Configuration for module {} not found", moduleName);
}
} catch (RepositoryException e) {
log.error("Failed to reconfigure module {}", moduleName, e);
}
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
log.debug("Looking for workflow in category {} for node {}", category, item.getPath());
Node cOnfiguration= JcrUtils.getNodeIfExists(workflowSession.getNodeByIdentifier(configurationId), category);
if (configuration != null) {
for (Node workflowNode : new NodeIterable(configuration.getNodes())) {
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
itemNode = JcrUtils.getNodeIfExists(initializationFolder, tempItemNode.getName());
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
private void registerModules() throws RepositoryException {
for (DaemonModule module : new Modules<>(Modules.getModules(), DaemonModule.class)) {
registerModule(module);
}
final Node modules = JcrUtils.getNodeIfExists(MODULES_PATH, session);
if (modules != null) {
for (Node node : new NodeIterable(modules.getNodes())) {
registerModule(node);
}
}
registry.checkDependencyGraph(true);
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
if (module instanceof ConfigurableDaemonModule) {
final String moduleCOnfigPath= MODULES_PATH + "/" + moduleName + "/" + HIPPO_MODULECONFIG;
final Node moduleCOnfig= JcrUtils.getNodeIfExists(moduleConfigPath, moduleSession);
if (moduleConfig != null) {
ConfigurableDaemonModule cOnfigurable= (ConfigurableDaemonModule) module;
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
try {
final Node jobNode = session.getNodeByIdentifier(jobIdentifier);
final Node triggersNode = JcrUtils.getNodeIfExists(jobNode, HIPPOSCHED_TRIGGERS);
if (triggersNode != null) {
final List triggers = new ArrayList<>();
代码示例来源:origin: org.onehippo.cms7/hippo-cms-console-frontend
@Override
public void onOk() {
if (Strings.isEmpty(name)) {
return;
}
final Node sourceNode = getOriginalModel().getObject();
if (sourceNode == null) {
return;
}
try {
final Node parentNode = getParentDestNode();
if (parentNode == null) {
return;
}
JcrUtils.copy(sourceNode, name, parentNode);
Node targetNode = JcrUtils.getNodeIfExists(parentNode, name);
if (targetNode != null) {
if (generate) {
targetNode.accept(new GenerateNewTranslationIdsVisitor());
}
modelReference.setModel(new JcrNodeModel(targetNode));
}
} catch (RepositoryException | IllegalArgumentException ex) {
log.error(ex.getMessage());
error(ex.getMessage());
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-console-frontend
@Override
public void onOk() {
Node sourceNode = getOriginalModel().getObject();
Node parentNode = getParentDestNode();
if (Strings.isEmpty(name) || parentNode == null || sourceNode == null) {
return;
}
try {
String targetPath = parentNode.getPath();
if (!targetPath.endsWith("/")) {
targetPath += "/";
}
targetPath += name;
// The actual move
Session jcrSession = UserSession.get().getJcrSession();
jcrSession.move(sourceNode.getPath(), targetPath);
Node targetNode = JcrUtils.getNodeIfExists(targetPath, jcrSession);
if (targetNode != null) {
modelReference.setModel(new JcrNodeModel(targetNode));
}
} catch (RepositoryException ex) {
error(ex.getMessage());
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-editor-frontend
final Node node;
try {
node = JcrUtils.getNodeIfExists(path, session);
} catch (RepositoryException ex) {
log.error(ex.getMessage());
代码示例来源:origin: org.onehippo.cms7.hst.components/hst-core
Node jcrNode = JcrUtils.getNodeIfExists(getValueProvider().getPath(), session);
if (jcrNode == null) {
if (parent != null) {