javax.jcr.nodetype.NodeType Java Examples
The following examples show how to use
javax.jcr.nodetype.NodeType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractExporter.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
private void writeNodeType(NodeType nt, CNDWriter w, Set<String> written) throws IOException, RepositoryException { if (nt != null && !written.contains(nt.getName())) { written.add(nt.getName()); w.write(nt); for (NodeType s: nt.getSupertypes()) { writeNodeType(s, w, written); } for (NodeDefinition n: nt.getChildNodeDefinitions()) { writeNodeType(n.getDefaultPrimaryType(), w, written); if (n.getRequiredPrimaryTypes() != null) { for (NodeType r: n.getRequiredPrimaryTypes()) { writeNodeType(r, w, written); } } } } }
Example #2
Source File: TreeSync.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
private void writeNtFile(SyncResult res, Entry e) throws RepositoryException, IOException { Node ntFile = e.node; Node content; String action = "A"; if (ntFile == null) { e.node = ntFile = e.parentNode.addNode(e.jcrName, NodeType.NT_FILE); content = ntFile.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE); } else { content = ntFile.getNode(Node.JCR_CONTENT); action = "U"; } Calendar cal = Calendar.getInstance(); if (preserveFileDate) { cal.setTimeInMillis(e.file.lastModified()); } InputStream in = FileUtils.openInputStream(e.file); Binary bin = content.getSession().getValueFactory().createBinary(in); content.setProperty(Property.JCR_DATA, bin); content.setProperty(Property.JCR_LAST_MODIFIED, cal); content.setProperty(Property.JCR_MIMETYPE, MimeTypes.getMimeType(e.file.getName(), MimeTypes.APPLICATION_OCTET_STREAM)); syncLog.log("%s jcr://%s", action, ntFile.getPath()); res.addEntry(e.getJcrPath(), e.getFsPath(), SyncResult.Operation.UPDATE_JCR); }
Example #3
Source File: TestAtomicCounter.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Tests if installing a package with a mix:atomicCounter works (update) */ @Test public void updateAtomicCounter() throws RepositoryException, IOException, PackageException { Assume.assumeTrue(isOak()); Node tmp = JcrUtils.getOrAddNode(admin.getRootNode(), "tmp", NodeType.NT_UNSTRUCTURED); Node testroot = JcrUtils.getOrAddNode(tmp, "testroot", NodeType.NT_UNSTRUCTURED); testroot.addMixin("mix:atomicCounter"); testroot.setProperty("oak:increment", 5); admin.save(); assertEquals(5L, testroot.getProperty("oak:counter").getLong()); JcrPackage pack = packMgr.upload(getStream("/test-packages/atomic-counter-test.zip"), false); assertNotNull(pack); ImportOptions opts = getDefaultOptions(); pack.install(opts); assertProperty("/tmp/testroot/oak:counter", "42"); }
Example #4
Source File: TestEmptyPackage.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Installs a package that contains /tmp/test/content/foo/foo.jsp and then creates a new node * /tmp/test/content/bar/bar.jsp. Tests if after reinstall the new node was deleted. */ @Test public void installEmptyFolder() throws RepositoryException, IOException, PackageException { JcrPackage pack = packMgr.upload(getStream("/test-packages/tmp_test_folders.zip"), false); assertNotNull(pack); pack.install(getDefaultOptions()); assertNodeExists("/tmp/test/content/foo/foo.jsp"); // create new node Node content = admin.getNode("/tmp/test/content"); Node bar = content.addNode("bar", NodeType.NT_FOLDER); InputStream is = new ByteArrayInputStream("hello, world.".getBytes()); JcrUtils.putFile(bar, "bar.jsp", "text/plain", is); admin.save(); // now re-install package pack.install(getDefaultOptions()); assertNodeMissing("/tmp/test/content/bar"); assertNodeMissing("/tmp/test/content/bar/bar.jsp"); }
Example #5
Source File: DocViewSaxFormatterTest.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Tests minimal serialization */ @Test public void testMinimalSerialization() throws Exception { JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin); admin.save(); DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter(); filter.add(new PathFilterSet("/testroot")); RepositoryAddress addr = new RepositoryAddress("/" + admin.getWorkspace().getName() + "/"); VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, null, admin); Aggregate a = jcrfs.getAggregateManager().getRoot().getAggregate("testroot"); DocViewSerializer s = new DocViewSerializer(a); ByteArrayOutputStream out = new ByteArrayOutputStream(); s.writeContent(out); assertEquals("valid xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" + " jcr:primaryType=\"nt:unstructured\"/>\n", out.toString("utf-8")); }
Example #6
Source File: RCPTest.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
@Test public void testAddMixin() throws IOException, RepositoryException, ConfigurationException { Node a = JcrUtils.getOrCreateByPath(SRC_TEST_NODE_PATH, NodeType.NT_FOLDER, NodeType.NT_FOLDER, admin, true); RepositoryCopier rcp = new RepositoryCopier(); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertNodeExists(DST_TEST_NODE_PATH); assertPropertyMissing(DST_TEST_NODE_PATH + "/jcr:title"); a.addMixin(NodeType.MIX_TITLE); a.setProperty("jcr:title", "Hello"); admin.save(); assertProperty(SRC_TEST_NODE_PATH + "/jcr:title", "Hello"); rcp = new RepositoryCopier(); rcp.setOnlyNewer(false); rcp.setUpdate(true); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertProperty(DST_TEST_NODE_PATH + "/jcr:title", "Hello"); assertProperty(DST_TEST_NODE_PATH + "/jcr:mixinTypes", new String[]{"mix:title"}); }
Example #7
Source File: DocViewSaxFormatterTest.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Tests export of mixed case named properties serialization */ @Test public void testMixedCaseSerialization() throws Exception { Node node = JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin); node.setProperty("testproperty", "lowercase"); node.setProperty("TestProperty", "MixedCase"); admin.save(); DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter(); filter.add(new PathFilterSet("/testroot")); RepositoryAddress addr = new RepositoryAddress("/" + admin.getWorkspace().getName() + "/"); VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, null, admin); Aggregate a = jcrfs.getAggregateManager().getRoot().getAggregate("testroot"); DocViewSerializer s = new DocViewSerializer(a); ByteArrayOutputStream out = new ByteArrayOutputStream(); s.writeContent(out); assertEquals("valid xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" + " jcr:primaryType=\"nt:unstructured\"\n" + " TestProperty=\"MixedCase\"\n" + " testproperty=\"lowercase\"/>\n", out.toString("utf-8")); }
Example #8
Source File: RCPTest.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
@Test public void testSimple() throws IOException, RepositoryException, ConfigurationException { Node a = JcrUtils.getOrCreateByPath(SRC_TEST_NODE_PATH, NodeType.NT_UNSTRUCTURED, NodeType.NT_UNSTRUCTURED, admin, true); a.setProperty("p0", "0"); a.setProperty("p1", "1"); a.setProperty("m0", new String[]{"0", "1", "2"}, PropertyType.STRING); admin.save(); assertNodeExists(SRC_TEST_NODE_PATH); RepositoryCopier rcp = new RepositoryCopier(); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertProperty(DST_TEST_NODE_PATH + "/p0", "0"); assertProperty(DST_TEST_NODE_PATH + "/p1", "1"); assertProperty(DST_TEST_NODE_PATH + "/m0", new String[]{"0", "1", "2"}); }
Example #9
Source File: FileArtifactHandler.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * Checks if the given node is a nt_resource like structure that was modified. this is to test if a single * file artifact needs to recreate existing content of a sub-typed jcr:content node. see JCRVLT-177 * * @param content the content node * @return {@code true} if modified * @throws RepositoryException if an error occurrs */ private boolean isModifiedNtResource(Node content) throws RepositoryException { if (content.getMixinNodeTypes().length > 0) { return true; } if (content.isNodeType(NodeType.NT_RESOURCE)) { return false; } // allow nt:unstructured with no child nodes return content.hasNodes(); }
Example #10
Source File: PageServiceImpl.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private static Node convertPageToNode(Node node, Page page, String createdUser) { try { node.addMixin(NodeType.MIX_VERSIONABLE); node.setProperty("wiki:subject", page.getSubject()); node.setProperty("wiki:content", page.getContent()); node.setProperty("wiki:status", page.getStatus()); node.setProperty("wiki:category", page.getCategory()); node.setProperty("wiki:isLock", page.isLock()); node.setProperty("wiki:createdUser", createdUser); return node; } catch (Exception e) { throw new MyCollabException(e); } }
Example #11
Source File: JcrPackageRegistry.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * Returns the primary package root. If the root does not exist yet and {@code autoCreate} is {@code true} it will * be created. * * @param autoCreate if {@code true} the roots are created if missing. * @return the the package root or {@code null} * @throws RepositoryException if an error occurs. */ @Nullable public Node getPrimaryPackageRoot(boolean autoCreate) throws RepositoryException { if (packRoots[0] == null) { if (session.nodeExists(packRootPaths[0])) { packRoots[0] = session.getNode(packRootPaths[0]); } else if (autoCreate) { if (session.hasPendingChanges()) { throw new RepositoryException("Unwilling to create package root folder while session has transient changes."); } packRoots[0] = JcrUtils.getOrCreateByPath(packRootPaths[0], NodeType.NT_FOLDER, NodeType.NT_FOLDER, session, true); } } return packRoots[0]; }
Example #12
Source File: DocViewSaxFormatterTest.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * Tests if an 'empty' node serialization includes the jcr namespace. see JCRVLT-266 */ @Test public void testFormatterIncludesJcrNamespace() throws Exception { // rep:itemNames restrictions are only supported in oak. Assume.assumeTrue(isOak()); JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin); admin.save(); // setup access control AccessControlManager acMgr = admin.getAccessControlManager(); JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/testroot"); Privilege[] privs = new Privilege[]{acMgr.privilegeFromName(Privilege.JCR_READ)}; Map<String, Value[]> rest = new HashMap<>(); rest.put("rep:itemNames", new Value[]{ admin.getValueFactory().createValue("jcr:mixinTypes", PropertyType.NAME), admin.getValueFactory().createValue("jcr:primaryType", PropertyType.NAME) }); acl.addEntry(EveryonePrincipal.getInstance(), privs, false, null, rest); acMgr.setPolicy("/testroot", acl); admin.save(); Session guest = repository.login(new GuestCredentials()); DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter(); filter.add(new PathFilterSet("/testroot")); RepositoryAddress addr = new RepositoryAddress("/" + admin.getWorkspace().getName() + "/"); VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, null, guest); Aggregate a = jcrfs.getAggregateManager().getRoot().getAggregate("testroot"); DocViewSerializer s = new DocViewSerializer(a); ByteArrayOutputStream out = new ByteArrayOutputStream(); s.writeContent(out); assertEquals("valid xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"/>\n", out.toString("utf-8")); }
Example #13
Source File: RCPTest.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
@Test public void testMixin() throws IOException, RepositoryException, ConfigurationException { Node a = JcrUtils.getOrCreateByPath(SRC_TEST_NODE_PATH, NodeType.NT_FOLDER, NodeType.NT_FOLDER, admin, true); RepositoryCopier rcp = new RepositoryCopier(); a.addMixin(NodeType.MIX_TITLE); a.setProperty("jcr:title", "Hello"); admin.save(); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertProperty(DST_TEST_NODE_PATH + "/jcr:title", "Hello"); assertProperty(DST_TEST_NODE_PATH + "/jcr:mixinTypes", new String[]{"mix:title"}); }
Example #14
Source File: RCPTest.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
@Test public void testRemoveMixin() throws IOException, RepositoryException, ConfigurationException { Node a = JcrUtils.getOrCreateByPath(SRC_TEST_NODE_PATH, NodeType.NT_FOLDER, NodeType.NT_FOLDER, admin, true); RepositoryCopier rcp = new RepositoryCopier(); a.addMixin(NodeType.MIX_TITLE); a.setProperty("jcr:title", "Hello"); admin.save(); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertProperty(DST_TEST_NODE_PATH + "/jcr:title", "Hello"); assertProperty(DST_TEST_NODE_PATH + "/jcr:mixinTypes", new String[]{"mix:title"}); a.removeMixin(NodeType.MIX_TITLE); admin.save(); // removing a mixing should remove the undeclared properties assertPropertyMissing(SRC_TEST_NODE_PATH + "/jcr:title"); assertPropertyMissingOrEmpty(SRC_TEST_NODE_PATH + "/jcr:mixinTypes"); rcp = new RepositoryCopier(); rcp.setOnlyNewer(false); rcp.setUpdate(true); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertNodeExists(DST_TEST_NODE_PATH); assertPropertyMissing(DST_TEST_NODE_PATH + "/jcr:title"); assertPropertyMissingOrEmpty(DST_TEST_NODE_PATH + "/jcr:mixinTypes"); }
Example #15
Source File: TestSerialization.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
@Test public void exportJcrXmlTest() throws RepositoryException, IOException, PackageException { Node testRoot = admin.getRootNode().addNode("testroot", NodeType.NT_UNSTRUCTURED); Node nodeA = testRoot.addNode("a", NodeType.NT_UNSTRUCTURED); Node xmlText = nodeA.addNode("jcr:xmltext", NodeType.NT_UNSTRUCTURED); xmlText.setProperty("jcr:xmlcharacters", "Hello, World."); admin.save(); ExportOptions opts = new ExportOptions(); DefaultMetaInf inf = new DefaultMetaInf(); DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter(); filter.add(new PathFilterSet("/testroot/a")); inf.setFilter(filter); Properties props = new Properties(); props.setProperty(VaultPackage.NAME_GROUP, "jackrabbit/test"); props.setProperty(VaultPackage.NAME_NAME, "test-package"); inf.setProperties(props); opts.setMetaInf(inf); File tmpFile = File.createTempFile("vaulttest", "zip"); VaultPackage pkg = packMgr.assemble(admin, opts, tmpFile); // check if entries are present Archive.Entry e = pkg.getArchive().getEntry("/jcr_root/testroot/.content.xml"); assertNotNull("entry should exist", e); String src = IOUtils.toString(pkg.getArchive().getInputSource(e).getByteStream(), "utf-8"); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" + " jcr:primaryType=\"nt:unstructured\">\n" + " <a jcr:primaryType=\"nt:unstructured\">\n" + " <jcr:xmltext\n" + " jcr:primaryType=\"nt:unstructured\"\n" + " jcr:xmlcharacters=\"Hello, World.\"/>\n" + " </a>\n" + "</jcr:root>\n"; assertEquals("content.xml must be correct", expected, src); pkg.close(); tmpFile.delete(); }
Example #16
Source File: CmdMixins.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception { String jcrPath = (String) cl.getValue(argJcrPath); List added = cl.getValues(optAdd); List rems = cl.getValues(optRemove); ConsoleFile wo = ctx.getFile(jcrPath, true); if (wo instanceof RepositoryCFile) { Node node = (Node) wo.unwrap(); try { for (Iterator it = added.iterator(); it.hasNext();) { node.addMixin((String) it.next()); } for (Iterator it = rems.iterator(); it.hasNext();) { node.removeMixin((String) it.next()); } String delim = "Mixins: "; for (NodeType nt: node.getMixinNodeTypes()) { System.out.print(delim); System.out.print(nt.getName()); delim = ", "; } System.out.println(); } catch (RepositoryException e) { throw new ExecutionException("Error while downloading file: " + e); } } else { throw new ExecutionException("'mixins' only possible in repcontext"); } }
Example #17
Source File: ContentSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private NodeTypeTemplate createMyCollabFolderType(NodeTypeManager manager) throws RepositoryException { // Create content node type NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate(); contentTypeTemplate.setAbstract(false); contentTypeTemplate.setMixin(false); contentTypeTemplate.setName("mycollab:folder"); contentTypeTemplate.setPrimaryItemName("folder"); contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER}); contentTypeTemplate.setQueryable(true); contentTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdPropertyTemplate = manager .createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("mycollab:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); PropertyDefinitionTemplate descPropertyTemplate = manager .createPropertyDefinitionTemplate(); descPropertyTemplate.setMultiple(false); descPropertyTemplate.setName("jcr:description"); descPropertyTemplate.setMandatory(false); descPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate); return contentTypeTemplate; }
Example #18
Source File: PageSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private NodeTypeTemplate createWikiFolderType(NodeTypeManager manager) throws RepositoryException { // Create content node type NodeTypeTemplate folderTypeTemplate = manager.createNodeTypeTemplate(); folderTypeTemplate.setAbstract(false); folderTypeTemplate.setMixin(false); folderTypeTemplate.setName("wiki:folder"); folderTypeTemplate.setPrimaryItemName("folder"); folderTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_FOLDER}); folderTypeTemplate.setQueryable(true); folderTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("wiki:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); PropertyDefinitionTemplate namePropertyTemplate = manager.createPropertyDefinitionTemplate(); namePropertyTemplate.setMultiple(false); namePropertyTemplate.setName("wiki:name"); namePropertyTemplate.setMandatory(true); namePropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(namePropertyTemplate); PropertyDefinitionTemplate descPropertyTemplate = manager.createPropertyDefinitionTemplate(); descPropertyTemplate.setMultiple(false); descPropertyTemplate.setName("wiki:description"); descPropertyTemplate.setMandatory(true); descPropertyTemplate.setRequiredType(PropertyType.STRING); folderTypeTemplate.getPropertyDefinitionTemplates().add(descPropertyTemplate); return folderTypeTemplate; }
Example #19
Source File: RepositoryServiceImpl.java From urule with Apache License 2.0 | 5 votes |
@Override public void lockPath(String path,User user) throws Exception{ path = processPath(path); int pos=path.indexOf(":"); if(pos!=-1){ path=path.substring(0,pos); } Node rootNode=getRootNode(); if (!rootNode.hasNode(path)) { throw new RuleException("File [" + path + "] not exist."); } Node fileNode = rootNode.getNode(path); String topAbsPath=fileNode.getPath(); if(lockManager.isLocked(topAbsPath)){ String owner=lockManager.getLock(topAbsPath).getLockOwner(); throw new NodeLockException("【"+path+"】已被"+owner+"锁定,您不能进行再次锁定!"); } List<Node> nodeList=new ArrayList<Node>(); unlockAllChildNodes(fileNode, user, nodeList, path); for(Node node:nodeList){ if(!lockManager.isLocked(node.getPath())){ continue; } Lock lock=lockManager.getLock(node.getPath()); lockManager.unlock(lock.getNode().getPath()); } if(!fileNode.isNodeType(NodeType.MIX_LOCKABLE)){ if (!fileNode.isCheckedOut()) { versionManager.checkout(fileNode.getPath()); } fileNode.addMixin("mix:lockable"); session.save(); } lockManager.lock(topAbsPath, true, true, Long.MAX_VALUE, user.getUsername()); }
Example #20
Source File: TreeSync.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
private Type getJcrType(Node node) throws RepositoryException { if (node == null) { return Type.MISSING; } else if (node.isNodeType(NodeType.NT_FILE)) { if (node.getMixinNodeTypes().length == 0) { // only ok, if pure nt:file Node content = node.getNode(Node.JCR_CONTENT); if (content.isNodeType(NodeType.NT_RESOURCE) && content.getMixinNodeTypes().length == 0) { return Type.FILE; } } return Type.UNSUPPORTED; } for (String nt: FULL_COVERAGE_NTS) { try { if (node.isNodeType(nt)) { return Type.FULL_COVERAGE; } } catch (RepositoryException e) { // ignore } } if (node.isNodeType(NodeType.NT_HIERARCHY_NODE)) { return Type.DIRECTORY; } else { return Type.UNSUPPORTED; } }
Example #21
Source File: AggregateManagerImpl.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * Add the primary and mixin node types of that node to the internal set * of used node types. * @param node the node * @throws RepositoryException if an error occurs */ public void addNodeTypes(Node node) throws RepositoryException { internalAddNodeType(node.getPrimaryNodeType()); for (NodeType nt: node.getMixinNodeTypes()) { internalAddNodeType(nt); } }
Example #22
Source File: RCPTest.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
@Test public void testOnlyNewer() throws IOException, RepositoryException, ConfigurationException { Calendar now = Calendar.getInstance(); Calendar then = Calendar.getInstance(); then.setTimeInMillis(now.getTimeInMillis() + 1); // create /testroot/src/a/jcr:content with 'now' as last modified Node a = JcrUtils.getOrCreateByPath(SRC_TEST_NODE_PATH, NodeType.NT_FOLDER, NodeType.NT_FILE, admin, false); Node content = a.addNode(Node.JCR_CONTENT, NodeType.NT_UNSTRUCTURED); content.setProperty(Property.JCR_LAST_MODIFIED, now); content.setProperty("p0", "0"); admin.save(); assertProperty(SRC_TEST_NODE_PATH + "/jcr:content/p0", "0"); RepositoryCopier rcp = new RepositoryCopier(); rcp.setOnlyNewer(false); rcp.setUpdate(true); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); assertProperty(DST_TEST_NODE_PATH + "/jcr:content/p0", "0"); // modify property but don't update last modified content.setProperty("p0", "1"); admin.save(); rcp = new RepositoryCopier(); rcp.setOnlyNewer(true); rcp.setUpdate(true); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); // property should still be the old value, since src is not "newer" assertProperty(DST_TEST_NODE_PATH + "/jcr:content/p0", "0"); // now update last modified content.setProperty(Property.JCR_LAST_MODIFIED, then); admin.save(); rcp = new RepositoryCopier(); rcp.setOnlyNewer(true); rcp.setUpdate(true); rcp.copy(admin, SRC_PATH, admin, DST_PATH, true); // property should now be the new value, since src is now "newer" assertProperty(DST_TEST_NODE_PATH + "/jcr:content/p0", "1"); }
Example #23
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeType getPrimaryNodeType() throws RepositoryException { return this.delegate.getPrimaryNodeType(); }
Example #24
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeType[] getMixinNodeTypes() throws RepositoryException { return this.delegate.getMixinNodeTypes(); }
Example #25
Source File: PageSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 4 votes |
private NodeTypeTemplate createWikiPageType(NodeTypeManager manager) throws RepositoryException { LOG.info("Register MyCollab content type"); NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE); // Create content node type NodeTypeTemplate pageTypeTemplate = manager.createNodeTypeTemplate(hierachyNode); pageTypeTemplate.setAbstract(false); pageTypeTemplate.setMixin(false); pageTypeTemplate.setName("wiki:page"); pageTypeTemplate.setPrimaryItemName("page"); pageTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE}); pageTypeTemplate.setQueryable(true); pageTypeTemplate.setOrderableChildNodes(false); LOG.debug("PROPERTY {} {}", pageTypeTemplate.getDeclaredPropertyDefinitions().length, pageTypeTemplate.getDeclaredChildNodeDefinitions().length); PropertyDefinitionTemplate subjectPropertyTemplate = manager.createPropertyDefinitionTemplate(); subjectPropertyTemplate.setMultiple(false); subjectPropertyTemplate.setName("wiki:subject"); subjectPropertyTemplate.setMandatory(true); subjectPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(subjectPropertyTemplate); PropertyDefinitionTemplate contentPropertyTemplate = manager.createPropertyDefinitionTemplate(); contentPropertyTemplate.setMultiple(false); contentPropertyTemplate.setName("wiki:content"); contentPropertyTemplate.setMandatory(true); contentPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(contentPropertyTemplate); PropertyDefinitionTemplate lockPropertyTemplate = manager.createPropertyDefinitionTemplate(); lockPropertyTemplate.setMultiple(false); lockPropertyTemplate.setName("wiki:isLock"); lockPropertyTemplate.setMandatory(false); lockPropertyTemplate.setRequiredType(PropertyType.BOOLEAN); pageTypeTemplate.getPropertyDefinitionTemplates().add(lockPropertyTemplate); PropertyDefinitionTemplate statusPropertyTemplate = manager.createPropertyDefinitionTemplate(); statusPropertyTemplate.setMultiple(false); statusPropertyTemplate.setName("wiki:status"); statusPropertyTemplate.setMandatory(true); statusPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(statusPropertyTemplate); PropertyDefinitionTemplate categoryPropertyTemplate = manager.createPropertyDefinitionTemplate(); categoryPropertyTemplate.setMultiple(false); categoryPropertyTemplate.setName("wiki:category"); categoryPropertyTemplate.setMandatory(false); categoryPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(categoryPropertyTemplate); PropertyDefinitionTemplate createdPropertyTemplate = manager.createPropertyDefinitionTemplate(); createdPropertyTemplate.setMultiple(false); createdPropertyTemplate.setName("wiki:createdUser"); createdPropertyTemplate.setMandatory(true); createdPropertyTemplate.setRequiredType(PropertyType.STRING); pageTypeTemplate.getPropertyDefinitionTemplates().add(createdPropertyTemplate); return pageTypeTemplate; }
Example #26
Source File: NodeTypeManagerWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException { return nodeTypeManager.getNodeType(nodeTypeName); }
Example #27
Source File: ContentSessionFactory.java From mycollab with GNU Affero General Public License v3.0 | 4 votes |
private NodeTypeTemplate createMyCollabContentType(NodeTypeManager manager) throws RepositoryException { LOG.info("Register mycollab content type"); NodeType hierachyNode = manager.getNodeType(NodeType.NT_HIERARCHY_NODE); // Create content node type NodeTypeTemplate contentTypeTemplate = manager.createNodeTypeTemplate(hierachyNode); contentTypeTemplate.setAbstract(false); contentTypeTemplate.setMixin(false); contentTypeTemplate.setName("mycollab:content"); contentTypeTemplate.setPrimaryItemName("content"); contentTypeTemplate.setDeclaredSuperTypeNames(new String[]{NodeType.NT_HIERARCHY_NODE}); contentTypeTemplate.setQueryable(true); contentTypeTemplate.setOrderableChildNodes(false); PropertyDefinitionTemplate createdUserPropertyTemplate = manager .createPropertyDefinitionTemplate(); createdUserPropertyTemplate.setMultiple(false); createdUserPropertyTemplate.setName("mycollab:createdUser"); createdUserPropertyTemplate.setMandatory(true); createdUserPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(createdUserPropertyTemplate); PropertyDefinitionTemplate contentPathPropertyTemplate = manager.createPropertyDefinitionTemplate(); contentPathPropertyTemplate.setMultiple(false); contentPathPropertyTemplate.setName("mycollab:contentPath"); contentPathPropertyTemplate.setMandatory(false); contentPathPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(contentPathPropertyTemplate); PropertyDefinitionTemplate thumbnailPathPropertyTemplate = manager.createPropertyDefinitionTemplate(); thumbnailPathPropertyTemplate.setMultiple(false); thumbnailPathPropertyTemplate.setName("mycollab:thumbnailPath"); thumbnailPathPropertyTemplate.setMandatory(false); thumbnailPathPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(thumbnailPathPropertyTemplate); PropertyDefinitionTemplate lastModifiedUserPropertyTemplate = manager.createPropertyDefinitionTemplate(); lastModifiedUserPropertyTemplate.setMultiple(false); lastModifiedUserPropertyTemplate.setName("mycollab:lastModifiedUser"); lastModifiedUserPropertyTemplate.setMandatory(true); lastModifiedUserPropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(lastModifiedUserPropertyTemplate); PropertyDefinitionTemplate mimeTypePropertyTemplate = manager .createPropertyDefinitionTemplate(); mimeTypePropertyTemplate.setMultiple(false); mimeTypePropertyTemplate.setName("mycollab:mimeType"); mimeTypePropertyTemplate.setMandatory(false); mimeTypePropertyTemplate.setRequiredType(PropertyType.STRING); contentTypeTemplate.getPropertyDefinitionTemplates().add(mimeTypePropertyTemplate); PropertyDefinitionTemplate sizePropertyTemplate = manager.createPropertyDefinitionTemplate(); sizePropertyTemplate.setMultiple(false); sizePropertyTemplate.setName("mycollab:size"); sizePropertyTemplate.setMandatory(true); sizePropertyTemplate.setRequiredType(PropertyType.LONG); contentTypeTemplate.getPropertyDefinitionTemplates().add(sizePropertyTemplate); return contentTypeTemplate; }
Example #28
Source File: NodeTypeManagerWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException { return nodeTypeManager.registerNodeType(ntd, allowUpdate); }
Example #29
Source File: NodeTypeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public NodeType[] getSupertypes() { return new NodeType[0]; }
Example #30
Source File: NodeTypeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public NodeType[] getDeclaredSupertypes() { return new NodeType[0]; }