本文整理汇总了Java中info.magnolia.jcr.util.NodeTypes类的典型用法代码示例。如果您正苦于以下问题:Java NodeTypes类的具体用法?Java NodeTypes怎么用?Java NodeTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeTypes类属于info.magnolia.jcr.util包,在下文中一共展示了NodeTypes类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:26,代码来源:PagePathColumnFormatter.java
示例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;
}
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:29,代码来源:BaseComponentRenderableDefinition.java
示例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);
}
开发者ID:tricode,项目名称:magnolia-blog,代码行数:17,代码来源:AuthorNameColumnFormatterTest.java
示例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);
}
开发者ID:tricode,项目名称:magnolia-blog,代码行数:17,代码来源:BlogNameColumnFormatterTest.java
示例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);
}
开发者ID:tricode,项目名称:magnolia-blog,代码行数:19,代码来源:BlogNameColumnFormatterTest.java
示例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());
}
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:17,代码来源:SaveAndRefreshGenericCommitDialogAction.java
示例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;
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:21,代码来源:NeatTweaks4DevelopersVersionHandler.java
示例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());
}
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:18,代码来源:DuplicatePageComponentAction.java
示例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.");
}
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:24,代码来源:SaveAndRefreshPageAction.java
示例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;
}
开发者ID:tricode,项目名称:magnolia-news,代码行数:28,代码来源:GenericColumnFormatter.java
示例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;
}
开发者ID:tricode,项目名称:magnolia-blog,代码行数:29,代码来源:BlogColumnFormatterUtil.java
示例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;
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:DefaultNeatVersionHandler.java
示例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.");
}
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:40,代码来源:SaveDialogFormAction.java
示例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();
}
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:11,代码来源:SaveDialogFormAction.java
示例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;
}
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:10,代码来源:JsonBuilder.java
示例16: setUp
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
super.setUp();
session = MgnlContext.getInstance().getJCRSession("website");
// register node type
NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
NodeTypeTemplate type = NodeTypeTemplateUtil.createSimpleNodeType(nodeTypeManager, "mgnl:apex",
Arrays.asList(NodeType.NT_HIERARCHY_NODE, NodeType.MIX_REFERENCEABLE, NodeTypes.Created.NAME, NodeTypes.Activatable.NAME, NodeTypes.LastModified.NAME, NodeTypes.Renderable.NAME));
nodeTypeManager.registerNodeType(type, true);
session.save();
new PropertiesImportExport().createNodes(session.getRootNode(), IOUtils.toInputStream(rootTree));
session.save();
// silly but can't use : in name in util
session.move("/home/mgnl_apex", "/home/mgnl:apex");
session.move("/home/section/mgnl_apex", "/home/section/mgnl:apex");
session.move("/home/section2/mgnl_apex", "/home/section2/mgnl:apex");
session.move("/home/section/article/mgnl_apex", "/home/section/article/mgnl:apex");
session.move("/home/section2/article/mgnl_apex", "/home/section2/article/mgnl:apex");
session.save();
Components.getSingleton(RepositoryManager.class).createWorkspace("magnolia", "category");
Session catSession = MgnlContext.getInstance().getJCRSession("category");
// register node type
NodeTypeManager catNodeTypeManager = catSession.getWorkspace().getNodeTypeManager();
type = NodeTypeTemplateUtil.createSimpleNodeType(nodeTypeManager, "category", Arrays.asList(NodeType.NT_HIERARCHY_NODE, NodeType.MIX_REFERENCEABLE, NodeTypes.Created.NAME, NodeTypes.Activatable.NAME, NodeTypes.LastModified.NAME, NodeTypes.Renderable.NAME));
nodeTypeManager.registerNodeType(type, true);
catNode = catSession.getRootNode().addNode("foo", "category");
catNode.addNode("foobar", "mgnl:content");
catNode.setProperty("name", "myCategory");
catSession.save();
MgnlContext.setLocale(null);
ComponentsTestUtil.setInstance(I18nContentSupport.class, new DefaultI18nContentSupport());
}
开发者ID:rah003,项目名称:neat-jsonfn,代码行数:39,代码来源:JsonBuilderTest.java
示例17: getBasicInstallTasks
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
@Override
protected List<Task> getBasicInstallTasks(InstallContext installContext) {
List<Task> tasks = new ArrayList<Task>();
tasks.add(new CreateNodeTask("", "", "scripts", "/", "selectFields", NodeTypes.Folder.NAME));
tasks.addAll(super.getBasicInstallTasks(installContext));
return tasks;
}
开发者ID:rah003,项目名称:scripted-select,代码行数:8,代码来源:NeatScriptedSelectVersionHandler.java
示例18: getAreaHierarchy
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
private Map<String, TemplateDefinition> getAreaHierarchy(Node parentArea) throws RepositoryException, RegistrationException {
Map<String, TemplateDefinition> areaHierarchy = new LinkedHashMap<String, TemplateDefinition>();
List<String> areaNamesHierarchy = new ArrayList<String> ();
Node parentParentArea = parentArea;
while (parentParentArea != null) {
String areaName = parentParentArea.getName();
areaNamesHierarchy.add(areaName);
parentParentArea = NodeUtil.getNearestAncestorOfType(parentParentArea, NodeTypes.Area.NAME);
}
Node parentPage = NodeUtil.getNearestAncestorOfType(parentArea, NodeTypes.Page.NAME);
templateId = parentPage.getProperty(NodeTypes.Renderable.TEMPLATE).getString();
TemplateDefinition templateDef = registry.getTemplateDefinition(templateId);
templateDef = mergeDefinition(templateDef);
ListIterator<String> iter = areaNamesHierarchy.listIterator(areaNamesHierarchy.size());
Node componentOrArea = parentPage;
while (iter.hasPrevious()) {
String name = iter.previous();
// subnode component is typically indication of having area type single
if (!componentOrArea.hasNode(name) && (componentOrArea.hasNode("component") || (templateDef instanceof AreaDefinition && "single".equals(((AreaDefinition) templateDef).getType())))) {
componentOrArea = componentOrArea.getNode("component/" + name);
// so we know component is single, and we neeed to look if it has any sub areas
String id = componentOrArea.getParent().getProperty(NodeTypes.Renderable.TEMPLATE).getString();
TemplateDefinition componentDef = registry.getTemplateDefinition(id);
if (componentDef != null) {
templateDef = componentDef;
}
} else {
componentOrArea = componentOrArea.getNode(name);
}
// do we really need to merge here already?
AreaDefinition area = templateDef.getAreas().get(name);
if (area != null) {
AreaDefinition areaDef = (AreaDefinition) mergeDefinition(area);
templateDef = areaDef;
} else {
AreaDefinition maybeHit = templateDef.getAreas().get(name);
if (maybeHit != null) {
areaHierarchy.put(name, maybeHit);
templateDef = maybeHit;
} else {
// get subareas of the area? what the hack was i thinking when writing this? How does it work anyway?
for (Entry<String, AreaDefinition> tempAreaEntry : templateDef.getAreas().entrySet()) {
AreaDefinition tempArea = tempAreaEntry.getValue();
maybeHit = tempArea.getAreas().get(name);
if (maybeHit != null) {
areaHierarchy.put(tempAreaEntry.getKey(), tempAreaEntry.getValue());
templateDef = maybeHit;
}
}
}
// noComponent area ... how do i read those?
}
areaHierarchy.put(name, templateDef);
}
return areaHierarchy;
}
开发者ID:rah003,项目名称:neat-tweaks,代码行数:61,代码来源:ComponentTemplateSelectFieldFactory.java
示例19: getTreeRoot
import info.magnolia.jcr.util.NodeTypes; //导入依赖的package包/类
/**
* Returns the tree's root {@link Node} of the passed @param content {@link Node}
*
* @param node
* @return Node of tree root
* @throws RepositoryException
*/
public Node getTreeRoot(Node node) throws RepositoryException {
Node rootNode = root(page(node), NodeTypes.Page.NAME);
return (rootNode == null) ? page(node) : rootNode;
}
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:12,代码来源:FoundationTemplatingFunctions.java
注:本文中的info.magnolia.jcr.util.NodeTypes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论