本文整理汇总了Java中info.magnolia.jcr.util.NodeUtil类的典型用法代码示例。如果您正苦于以下问题:Java NodeUtil类的具体用法?Java NodeUtil怎么用?Java NodeUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeUtil类属于info.magnolia.jcr.util包,在下文中一共展示了NodeUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCell
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
final Item jcrItem = getJcrItem(source, itemId);
if (jcrItem != null && jcrItem.isNode()) {
final Node node = (Node) jcrItem;
try {
if (NodeUtil.isNodeType(node, NodeTypes.ContentNode.NAME)) {
// Get identifier from the items name propertyName: eg. sitePageMap
final String pageId = PropertyUtil.getString(node, definition.getPropertyName(), StringUtils.EMPTY);
// Find page in website and return page path
if (StringUtils.isNotEmpty(pageId)) {
final Node page = NodeUtil.getNodeByIdentifier(RepositoryConstants.WEBSITE, pageId);
final String pagePath = page.getPath();
final StringBuilder nameBuilder = new StringBuilder();
nameBuilder.append(pagePath);
return nameBuilder.toString().trim();
}
}
} catch (RepositoryException e) {
log.warn("Unable to get name of contact for column", e);
}
}
return StringUtils.EMPTY;
}
示例2: isLastOnPage
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
* Check if current component is the last component with same template definition on the page.
* @return true if last component based on mgnl:template
*/
public Boolean isLastOnPage() {
int counter = 0;
int currentPos = 0;
try {
Node page = templatingFunctions.page(content);
String currentNodeTemplate = PropertyUtil.getString(content, "mgnl:template");
Iterable<Node> pageComponents = NodeUtil.collectAllChildren(page, new NodeTypePredicate(NodeTypes.Component.NAME, true));
for (Node component : pageComponents) {
if (StringUtils.equalsIgnoreCase(PropertyUtil.getString(component, "mgnl:template"), currentNodeTemplate)) {
counter++;
if (currentPos > 0 && counter > currentPos) {
return false;
}
if (StringUtils.equalsIgnoreCase(content.getIdentifier(), component.getIdentifier())) {
currentPos = counter;
}
}
}
} catch (RepositoryException e) {
log.warn("Repository error thrown during fetch page child components", e);
}
return true;
}
示例3: getTemplateDefinition
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
* Returns the TemplateDefinition for the supplied content. Never returns null.
*/
private TemplateDefinition getTemplateDefinition(Node content) throws ServletException {
TemplateDefinition templateDefinition;
try {
templateDefinition = templateDefinitionAssignment.getAssignedTemplateDefinition(content);
} catch (RegistrationException e) {
throw new ServletException("No template set or template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
}
if (templateDefinition == null) {
throw new ServletException("Template not available for node with identifier: " + NodeUtil.getNodeIdentifierIfPossible(content));
}
return templateDefinition;
}
示例4: onPostExecute
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void onPostExecute() throws Exception {
super.onPostExecute();
Node node = (Node) getCurrentItem().getJcrItem();
boolean restoreMultiple = getItems().size() > 1 || NodeUtil.getNodes(node, BlogsNodeTypes.Blog.NAME).iterator().hasNext();
if (!restoreMultiple) {
locationController.goTo(new DetailLocation(
"tricode-blogs",
"detail",
DetailView.ViewType.EDIT,
node.getPath(),
"")
);
}
}
示例5: execute
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
super.execute();
try {
Node node = (Node) item.getJcrItem();
NodeUtil.orderAfter((Node) JcrItemUtil.getJcrItem(changedId), node.getName());
// need to mark page as modified manually? Why? I'd love to know too.
NodeTypes.LastModified.update(node);
node.getSession().save();
JcrItemId itemIdOfChangedItem = JcrItemUtil.getItemId(templatingFunctions.page(node));
eventBus.fireEvent(new ContentChangedEvent(itemIdOfChangedItem));
uiContext.openNotification(MessageStyleTypeEnum.INFO, true, "The item your grace requested have been duplicated! How may I serve my lord further?");
} catch (RepositoryException e) {
log.error("It would seem we were not able to obtain id of parent item of node {}", item.getJcrItem());
}
}
示例6: getOptions
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public List<SelectFieldOptionDefinition> getOptions() {
final List<SelectFieldOptionDefinition> options = new ArrayList<>();
final List<Node> nodes = getNodes();
if (nodes.isEmpty()) {
LOGGER.debug("No site nodes found.");
options.add(createOptionDefinition(DEF_SITE, true));
} else {
LOGGER.debug("{} site nodes found.", nodes.size());
for (Node node : nodes) {
options.add(createOptionDefinition(NodeUtil.getName(node), options.isEmpty()));
}
}
return options;
}
示例7: setNodeName
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void setNodeName(final Node node, final JcrNodeAdapter item) throws RepositoryException {
try {
if (item.isNew() || NewsWorkspaceUtil.hasNameChanged(node, getDefinition().getPropertyName())) {
final String newNodeName = NewsWorkspaceUtil.generateUniqueNodeName(node, getDefinition().getPropertyName());
item.setNodeName(newNodeName);
NodeUtil.renameNode(node, newNodeName);
}
} catch (PathNotFoundException e) {
LOGGER.error("Trying to fetch value of a non-existant propertyName", e);
}
}
示例8: generateCellHelper
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
static Object generateCellHelper(final Item jcrItem, final String nodeTypeName, final String propertyTitle) {
if (jcrItem != null && jcrItem.isNode()) {
Node node = (Node) jcrItem;
try {
if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) {
return node.getName();
}
if (NodeUtil.isNodeType(node, NodeTypes.Deleted.NAME)) {
return node.getName();
}
if (NodeUtil.isNodeType(node, nodeTypeName)) {
Object result = PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
if (result != null) {
return result;
} else {
return PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
}
}
} catch (RepositoryException e) {
LOGGER.info("Unable to get '" + propertyTitle + "' of news for column", e);
}
}
return StringUtils.EMPTY;
}
示例9: onPostExecute
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void onPostExecute() throws Exception {
super.onPostExecute();
Node node = (Node) getCurrentItem().getJcrItem();
boolean restoreMultiple = getItems().size() > 1 || NodeUtil.getNodes(node, NewsNodeTypes.News.NAME).iterator().hasNext();
if (!restoreMultiple) {
DetailLocation location = new DetailLocation("tricode-news", "detail", DetailView.ViewType.EDIT, node.getPath(), "");
locationController.goTo(location);
}
}
示例10: setNodeName
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
JcrNodeAdapter itemChanged = item;
// Set the Node Composite Name
if (itemChanged instanceof JcrNewNodeAdapter || !node.getName().startsWith(defineNodeName(node))) {
final String newNodeName = generateUniqueNodeNameForTag(node);
itemChanged.setNodeName(newNodeName);
NodeUtil.renameNode(node, newNodeName);
}
}
示例11: getTotalCount
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
/**
* Get total results count of all child components results count
*
* @return Total result count
* @throws RepositoryException
*/
public int getTotalCount() throws RepositoryException {
int grandTotal = 0;
for (Node node : NodeUtil.getNodes(content,"mgnl:component")) {
grandTotal += getComponentTotal(node);
}
return grandTotal;
}
示例12: setNodeName
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
try {
if (item.isNew() || BlogWorkspaceUtil.hasNameChanged(node, getDefinition().getPropertyName())) {
final String newNodeName = BlogWorkspaceUtil.generateUniqueNodeName(node, getDefinition().getPropertyName());
item.setNodeName(newNodeName);
NodeUtil.renameNode(node, newNodeName);
}
} catch (PathNotFoundException e) {
LOGGER.error("Trying to fetch value of a non-existent propertyName", e);
}
}
示例13: generateCellHelper
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
static Object generateCellHelper(Item jcrItem, String nodeTypeName, String propertyTitle) {
if (jcrItem != null && jcrItem.isNode()) {
Node node = (Node) jcrItem;
try {
if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) {
return node.getName();
}
if (NodeUtil.isNodeType(node, NodeTypes.Deleted.NAME)) {
return node.getName();
}
if (NodeUtil.isNodeType(node, nodeTypeName)) {
Object result = PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
if (result != null) {
return result;
} else {
return PropertyUtil.getString(node, propertyTitle, StringUtils.EMPTY);
}
}
} catch (RepositoryException e) {
LOGGER.info("Unable to get '" + propertyTitle + "' of blog for column", e);
}
}
return StringUtils.EMPTY;
}
示例14: generateCell
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
final Item jcrItem = getJcrItem(source, itemId);
if (jcrItem != null && jcrItem.isNode()) {
final Node node = (Node) jcrItem;
try {
if (NodeUtil.isNodeType(node, BlogsNodeTypes.Blog.NAME)) {
// Get identifier from author
final String authorId = PropertyUtil.getString(node, BlogsNodeTypes.Blog.PROPERTY_AUTHOR, StringUtils.EMPTY);
// Find author in contacts and return first name and last name
if (StringUtils.isNotEmpty(authorId)) {
final Optional<Node> authorOptional = readAuthorDetails(authorId);
if (authorOptional.isPresent()) {
final Node author = authorOptional.get();
final StringBuilder nameBuilder = new StringBuilder();
nameBuilder.append(PropertyUtil.getString(author, ContactsNodeTypes.Contact.PROPERTY_FIRST_NAME, StringUtils.EMPTY));
nameBuilder.append(" ");
nameBuilder.append(PropertyUtil.getString(author, ContactsNodeTypes.Contact.PROPERTY_LAST_NAME, StringUtils.EMPTY));
return nameBuilder.toString().trim();
}
}
}
} catch (RepositoryException e) {
LOGGER.warn("Unable to determine node type", e);
}
}
return StringUtils.EMPTY;
}
示例15: readAuthorDetails
import info.magnolia.jcr.util.NodeUtil; //导入依赖的package包/类
private static Optional<Node> readAuthorDetails(final String authorId) {
try {
return Optional.of(NodeUtil.getNodeByIdentifier(BlogRepositoryConstants.CONTACTS, authorId));
} catch (RepositoryException e) {
LOGGER.warn("Referenced authorId not found: {}", authorId);
return Optional.empty();
}
}