本文整理汇总了Java中info.magnolia.jcr.util.NodeTypes类的典型用法代码示例。如果您正苦于以下问题:Java NodeTypes类的具体用法?Java NodeTypes怎么用?Java NodeTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeTypes类属于info.magnolia.jcr.util包,在下文中一共展示了NodeTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCell
import info.magnolia.jcr.util.NodeTypes; //导入依赖的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.NodeTypes; //导入依赖的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: generateCellWithoutBlogNode
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void generateCellWithoutBlogNode() throws Exception {
Object itemId = "1";
JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
Node mockNode = mock(Node.class);
doReturn(mockItem).when(mockTable).getItem(itemId);
doReturn(mockNode).when(mockItem).getJcrItem();
doReturn(true).when(mockItem).isNode();
doReturn(true).when(mockNode).isNode();
doReturnIsNodeType(mockNode, NodeTypes.Page.NAME);
Object result = formatter.generateCell(mockTable, itemId, null);
assertEquals(StringUtils.EMPTY, result);
}
示例4: testGenerateCellWithoutBlogOrFolderNode
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void testGenerateCellWithoutBlogOrFolderNode() throws Exception {
Object itemId = "1";
JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
Node mockNode = mock(Node.class);
doReturn(mockItem).when(mockTable).getItem(itemId);
doReturn(mockNode).when(mockItem).getJcrItem();
doReturn(true).when(mockItem).isNode();
doReturn(true).when(mockNode).isNode();
doReturnIsNodeType(mockNode, NodeTypes.Page.NAME);
Object result = formatter.generateCell(mockTable, itemId, null);
Assert.assertEquals(StringUtils.EMPTY, result);
}
示例5: testGenerateCellWithFolderNode
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Test
public void testGenerateCellWithFolderNode() throws Exception {
Object itemId = "1";
String folderName = "folder1";
JcrItemAdapter mockItem = mock(JcrItemAdapter.class);
Node mockNode = mock(Node.class);
doReturn(mockItem).when(mockTable).getItem(itemId);
doReturn(mockNode).when(mockItem).getJcrItem();
doReturn(true).when(mockItem).isNode();
doReturn(true).when(mockNode).isNode();
doReturnIsNodeType(mockNode, NodeTypes.Folder.NAME);
doReturn(folderName).when(mockNode).getName();
Object result = formatter.generateCell(mockTable, itemId, null);
Assert.assertEquals(folderName, result);
}
示例6: execute
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
super.execute();
try {
Node node = (Node) ((JcrItemAdapter) item).getJcrItem();
// 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, "It would seem you decided to change type of the component! In case you realize that being bad idea, you can always change it back.");
} catch (RepositoryException e) {
log.error("It would seem we were not able to obtain id of parent item of node {}", ((JcrItemAdapter) item).getJcrItem());
}
}
示例7: getExtraInstallTasks
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
protected List<Task> getExtraInstallTasks(InstallContext installContext) {
List<Task> tasks = new ArrayList<Task>(super.getExtraInstallTasks(installContext));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/neatconfiguration", null,
new CreateNodeTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps", "neatconfiguration", NodeTypes.ContentNode.NAME)));
tasks.add(new MoveNodeTask("", "/modules/ui-admincentral/config/appLauncherLayout/groups/manage/apps/configuration", "/modules/ui-admincentral/config/appLauncherLayout/groups/tools/apps/configuration", false));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkSiteApp/subApps",
new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkSiteApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkThemesApp/subApps",
new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkThemesApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkChannelsApp/subApps",
new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkChannelsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkDialogsApp/subApps",
new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkDialogsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
tasks.add(new NodeExistsDelegateTask("", "/modules/ui-admincentral/apps/stkTemplateDefsApp/subApps",
new SetPropertyTask("config", "/modules/ui-admincentral/apps/stkTemplateDefsApp/subApps", "extends", "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps")));
tasks.add(new IsModuleInstalledOrRegistered("STK JPG Image generator", "standard-templating-kit",
new BootstrapSingleResource("", "", "/mgnl-bootstrap/standard-templating-kit/config.modules.imaging.config.generators.stk-jpg.xml")));
return tasks;
}
示例8: execute
import info.magnolia.jcr.util.NodeTypes; //导入依赖的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());
}
}
示例9: execute
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
super.execute();
// First Validate
validator.showValidation(true);
if (validator.isValid()) {
try {
Node node = (Node) item.getJcrItem();
// 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, "In case you didn't manage to set component type right, you can always try again ... and again");
} catch (RepositoryException e) {
log.error("It would seem we were not able to obtain id of parent item of node {}", item.getJcrItem());
}
} else {
log.debug("Validation error(s) occurred. No save performed.");
}
}
示例10: generateCellHelper
import info.magnolia.jcr.util.NodeTypes; //导入依赖的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;
}
示例11: generateCellHelper
import info.magnolia.jcr.util.NodeTypes; //导入依赖的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;
}
示例12: getExtraInstallTasks
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
protected List<Task> getExtraInstallTasks(InstallContext installContext) {
List<Task> tasks = new ArrayList<Task>(super.getExtraInstallTasks(installContext));
if (!LicenseFileExtractor.getInstance().get(LicenseFileExtractor.VERSION_NUMBER).startsWith("5.4")) {
tasks.add(new InstallTextResourceTask("/ui-admincentral/neat_theme.css"));
} else {
tasks.add(new CreateNodePathTask("admincentral", "/", NodeTypes.Folder.NAME));
}
return tasks;
}
示例13: execute
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
public void execute() throws ActionExecutionException {
// First Validate
validator.showValidation(true);
if (validator.isValid()) {
try {
final Node node = item.applyChanges();
// Set the Node name.
setNodeName(node, item);
// WTF was whomever at JR dev team thinking?
for (Property prop : in((Iterator<Property>) node.getProperties())) {
if (prop.getType() == PropertyType.STRING && StringUtils.isEmpty(prop.getValue().getString())) {
prop.remove();
}
}
Node actions = node.addNode("actions", NodeTypes.ContentNode.NAME);
setAction(node, actions, "commit", "info.magnolia.ui.form.action.SaveFormActionDefinition");
setAction(node, actions, "cancel", "info.magnolia.ui.form.action.CancelFormActionDefinition");
Node tabs = node.addNode("form", NodeTypes.ContentNode.NAME).addNode("tabs", NodeTypes.ContentNode.NAME);
for (Node n : in((Iterator<Node>) node.getNodes("tabs*"))) {
if (n.hasProperty("field")) {
String name = n.getProperty("field").getString();
Node tab = tabs.addNode(Path.getUniqueLabel(tabs, Path.getValidatedLabel(name)), NodeTypes.ContentNode.NAME);
tab.setProperty("label", StringUtils.capitalize(name));
tab.addNode("fields", NodeTypes.ContentNode.NAME);
}
n.remove();
}
node.getSession().save();
} catch (final RepositoryException e) {
throw new ActionExecutionException(e);
}
callback.onSuccess(getDefinition().getName());
} else {
log.info("Validation error(s) occurred. No save performed.");
}
}
示例14: setAction
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
private void setAction(final Node node, Node actions, String actionName, String implClass) throws RepositoryException, PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException, ItemExistsException, AccessDeniedException {
String propName = "default" + StringUtils.capitalize(actionName);
if (node.hasProperty(propName)) {
Property defaultAction = node.getProperty(propName);
if (defaultAction.getBoolean()) {
actions.addNode(actionName, NodeTypes.ContentNode.NAME).setProperty("class", implClass);
}
defaultAction.remove();
}
}
示例15: isNotDeleted
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
private boolean isNotDeleted(Node node) {
try {
boolean isDeleted = NodeUtil.hasMixin(node, NodeTypes.Deleted.NAME);
return !isDeleted;
} catch (RepositoryException e) {
log.debug("Failed to check for deleted nodes. with {}", e.getMessage(), e );
}
return false;
}