javax.jcr.Node Java Examples

The following examples show how to use javax.jcr.Node. 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: RepositoryCFile.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
public ConsoleFile[] listFiles() throws IOException {
    try {
        if (item.isNode()) {
            Node node = (Node) item;
            ArrayList<RepositoryCFile> ret = new ArrayList<RepositoryCFile>();
            PropertyIterator piter = node.getProperties();
            while (piter.hasNext()) {
                ret.add(new RepositoryCFile(piter.nextProperty()));
            }
            NodeIterator niter = node.getNodes();
            while (niter.hasNext()) {
                ret.add(new RepositoryCFile(niter.nextNode()));
            }
            return ret.toArray(new RepositoryCFile[ret.size()]);
        } else {
            return ConsoleFile.EMPTY_ARRAY;
        }
    } catch (RepositoryException e) {
        throw new IOException(e.toString());
    }
}
 
Example #2
Source File: ImportTests.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * Imports an empty package with a filter "/testnode" relative to "/testnode". Since this is a relative import,
 * the "/testnode" would map to "/testnode/testnode". So the import should not remove "/testnode".
 */
@Test
public void testRelativeEmptyImport() throws IOException, RepositoryException, ConfigurationException {
    ZipArchive archive = new ZipArchive(getTempFile("/test-packages/empty_testnode.zip"));

    admin.getRootNode().addNode(TEST_ROOT.substring(1, TEST_ROOT.length()));
    admin.save();

    archive.open(true);
    Node rootNode = admin.getNode(TEST_ROOT);
    ImportOptions opts = getDefaultOptions();
    Importer importer = new Importer(opts);
    importer.run(archive, rootNode);

    assertNodeExists(TEST_ROOT);
}
 
Example #3
Source File: DocViewSAXFormatter.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onWalkBegin(Node root) throws RepositoryException {
    // init ignored protected properties
    ignored.clear();
    ignored.add(JcrConstants.JCR_CREATED);
    ignored.add(JcrConstants.JCR_CREATED_BY);
    ignored.add(JcrConstants.JCR_BASEVERSION);
    ignored.add(JcrConstants.JCR_VERSIONHISTORY);
    ignored.add(JcrConstants.JCR_PREDECESSORS);

    try {
        writer.writeStartDocument();
    } catch (XMLStreamException e) {
        throw new RepositoryException(e);
    }
}
 
Example #4
Source File: FileAggregator.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean includes(Node root, Node node, String path) throws RepositoryException {
    if (path == null) {
        path = node.getPath();
    }
    int depth = PathUtil.getDepth(path) - root.getDepth();
    boolean isFile = root.isNodeType(JcrConstants.NT_FILE);
    if (depth == 0) {
        // should not happen, but ok.
        return true;
    } else if (depth == 1) {
        // on root level, we only allow "jcr:content" if it's a file
        if (isFile && node.getName().equals(JcrConstants.JCR_CONTENT)) {
            return true;
        }
    } else {
        // no sub nodes.
    }
    // only respect content filter if not empty
    return !contentFilter.isEmpty() && contentFilter.contains(node, path, depth);
}
 
Example #5
Source File: StorageUpdate15.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private void updateTemplateNodes() throws RepositoryException {
	
	// add shortcutType node to all report templates nodes
   	String statement = 
			"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) + 
			"//*[@className='ro.nextreports.server.domain.Report']/templates";
	  
	QueryResult queryResult = getTemplate().query(statement);
	NodeIterator nodes = queryResult.getNodes();
	
	LOG.info("Add shortcutType node to all report templates nodes : Found " + nodes.getSize() + " report nodes");
	while (nodes.hasNext()) {			
		Node node = nodes.nextNode();
		NodeIterator templatesForReport = node.getNodes();
		while (templatesForReport.hasNext()) {
			Node template = templatesForReport.nextNode();
			Node shortcutTypeNode = template.addNode("shortcutType");
			shortcutTypeNode.setProperty("type", 0);
			shortcutTypeNode.setProperty("timeType", 0);
			shortcutTypeNode.setProperty("timeUnits", 0);
		}
	}					

   	getTemplate().save();
	
}
 
Example #6
Source File: CmdRefresh.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
        throws Exception {
    String jcrPath = (String) cl.getValue(argJcrPath);
    if (jcrPath == null) {
        jcrPath = "/";
    }
    ConsoleFile wo = ctx.getFile(jcrPath, true);
    if (wo instanceof RepositoryCFile) {
        Node node = (Node) wo.unwrap();
        try {
            node.getSession().refresh(cl.hasOption(optKeepChanges));
            System.out.println("Modifications refreshed.");
        } catch (RepositoryException e) {
            throw new ExecutionException("Error while refreshing: " + e);
        }
    } else {
        throw new ExecutionException("'refresh' only possible in repcontext");
    }
}
 
Example #7
Source File: JcrExporter.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
private void scan(Node dir) throws RepositoryException {
    NodeIterator iter = dir.getNodes();
    while (iter.hasNext()) {
        Node child = iter.nextNode();
        String name = child.getName();
        if (".svn".equals(name) || ".vlt".equals(name)) {
            continue;
        }
        if (child.isNodeType(JcrConstants.NT_FOLDER)) {
            exportInfo.update(ExportInfo.Type.RMDIR, child.getPath());
            scan(child);
        } else if (child.isNodeType(JcrConstants.NT_FILE)) {
            exportInfo.update(ExportInfo.Type.DELETE, child.getPath());
        }
    }
}
 
Example #8
Source File: CommentServiceImpl.java    From publick-sling-blog with Apache License 2.0 6 votes vote down vote up
/**
 * Edit comment and mark it as author edited.
 *
 * @param request The current request to get session and Resource Resolver
 * @param id The comment UUID
 * @param text The comment text
 * @return true if the operation was successful
 */
public boolean editComment(final SlingHttpServletRequest request, final String id, String text) {
    boolean result = false;

    try {
        Session session = request.getResourceResolver().adaptTo(Session.class);
        Node node = session.getNodeByIdentifier(id);

        if (node != null) {
            JcrResourceUtil.setProperty(node, PublickConstants.COMMENT_PROPERTY_COMMENT, text);
            JcrResourceUtil.setProperty(node, PublickConstants.COMMENT_PROPERTY_EDITED, true);
            session.save();
            result = true;
        }
    } catch (RepositoryException e) {
        LOGGER.error("Could not update comment from JCR", e);
    }

    return result;
}
 
Example #9
Source File: Purge.java    From APM with Apache License 2.0 6 votes vote down vote up
private void purge(final Context context, final ActionResult actionResult)
    throws RepositoryException, ActionExecutionException {
  NodeIterator iterator = getPermissions(context);
  String normalizedPath = normalizePath(path);
  while (iterator != null && iterator.hasNext()) {
    Node node = iterator.nextNode();
    if (node.hasProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)) {
      String parentPath = node.getProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)
          .getString();
      String normalizedParentPath = normalizePath(parentPath);
      boolean isUsersPermission = parentPath.startsWith(context.getCurrentAuthorizable().getPath());
      if (StringUtils.startsWith(normalizedParentPath, normalizedPath) && !isUsersPermission) {
        RemoveAll removeAll = new RemoveAll(parentPath);
        ActionResult removeAllResult = removeAll.execute(context);
        if (Status.ERROR.equals(removeAllResult.getStatus())) {
          copyErrorMessages(removeAllResult, actionResult);
        }
      }
    }
  }
}
 
Example #10
Source File: JcrPackageManagerImplTest.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPackageRootNoRootAccess() throws Exception {
    Node packageRoot = packMgr.getPackageRoot();

    // TODO: maybe rather change the setup of the test-base to not assume that everyone has full read-access
    AccessControlManager acMgr = admin.getAccessControlManager();
    JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
    acMgr.removePolicy(acl.getPath(), acl);

    AccessControlUtils.getAccessControlList(acMgr, "/etc/packages");
    AccessControlUtils.allow(packageRoot, org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal.NAME, javax.jcr.security.Privilege.JCR_READ);

    admin.save();

    Session anonymous = repository.login(new GuestCredentials());
    try {
        assertFalse(anonymous.nodeExists("/"));
        assertFalse(anonymous.nodeExists("/etc"));
        assertTrue(anonymous.nodeExists("/etc/packages"));

        JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(anonymous, new String[0]);
        jcrPackageManager.getPackageRoot(false);
    } finally {
        anonymous.logout();
    }
}
 
Example #11
Source File: FileFolderNodeFilter.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Returns {@code true} if the item is a node of type nt:hierarchyNode
 * that has or defines a 'jcr:content' child node.
 */
public boolean matches(Item item) throws RepositoryException {
    if (item.isNode()) {
        Node node = (Node) item;
        if (node.isNodeType(JcrConstants.NT_HIERARCHYNODE)) {
            if (node.hasNode(JcrConstants.JCR_CONTENT)) {
                return true;
            } else {
                for (NodeDefinition pd: node.getPrimaryNodeType().getChildNodeDefinitions()) {
                    if (pd.getName().equals(JcrConstants.JCR_CONTENT)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example #12
Source File: FolderArtifactHandler.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
private Node modifyPrimaryType(Node node, ImportInfoImpl info) throws RepositoryException {
    String name = node.getName();
    Node parent = node.getParent();

    // check versionable
    ensureCheckedOut(node, info);

    ChildNodeStash recovery = new ChildNodeStash(node.getSession());
    recovery.stashChildren(node);
    node.remove();
    
    // now create the new node
    Node newNode = parent.addNode(name, nodeType);
    info.onReplaced(newNode.getPath());
    // move the children back
    recovery.recoverChildren(newNode, info);
    return newNode;
}
 
Example #13
Source File: RepositoryServiceImpl.java    From urule with Apache License 2.0 6 votes vote down vote up
private void unlockAllChildNodes(Node node,User user,List<Node> nodeList,String rootPath) throws Exception{
	NodeIterator iter=node.getNodes();
	while(iter.hasNext()){
		Node nextNode=iter.nextNode();
		String absPath=nextNode.getPath();
		if(!lockManager.isLocked(absPath)){
			continue;
		}
		Lock lock=lockManager.getLock(absPath);
		String owner=lock.getLockOwner();
		if(!user.getUsername().equals(owner)){
			throw new NodeLockException("当前目录下有子目录被其它人锁定,您不能执行锁定"+rootPath+"目录");
		}
		nodeList.add(nextNode);
		unlockAllChildNodes(nextNode, user, nodeList, rootPath);
	}
}
 
Example #14
Source File: JcrPackageRegistry.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new jcr vault package.
 *
 * @param parent the parent node
 * @param pid the package id of the new package.
 * @param bin the binary containing the zip
 * @param archive the archive with the meta data
 * @return the created jcr vault package.
 * @throws RepositoryException if an repository error occurs
 * @throws IOException if an I/O error occurs
 *
 * @since 3.1
 */
@NotNull
private JcrPackage createNew(@NotNull Node parent, @NotNull PackageId pid, @NotNull Binary bin, @NotNull MemoryArchive archive)
        throws RepositoryException, IOException {
    Node node = parent.addNode(Text.getName(getInstallationPath(pid) + ".zip"), JcrConstants.NT_FILE);
    Node content = node.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
    content.addMixin(JcrPackage.NT_VLT_PACKAGE);
    Node defNode = content.addNode(JcrPackage.NN_VLT_DEFINITION);
    JcrPackageDefinitionImpl def = new JcrPackageDefinitionImpl(defNode);
    def.set(JcrPackageDefinition.PN_NAME, pid.getName(), false);
    def.set(JcrPackageDefinition.PN_GROUP, pid.getGroup(), false);
    def.set(JcrPackageDefinition.PN_VERSION, pid.getVersionString(), false);
    def.touch(null, false);
    content.setProperty(JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance());
    content.setProperty(JcrConstants.JCR_MIMETYPE, JcrPackage.MIME_TYPE);
    content.setProperty(JcrConstants.JCR_DATA, bin);
    def.unwrap(archive, false);
    dispatch(PackageEvent.Type.CREATE, pid, null);
    return new JcrPackageImpl(this, node);
}
 
Example #15
Source File: JcrMetadataRepository.java    From archiva with Apache License 2.0 5 votes vote down vote up
private void updateNamespace(Session jcrSession, String repositoryId, String namespace) throws MetadataRepositoryException {
    try {
        Node node = getOrAddNamespaceNode(jcrSession, repositoryId, namespace);
        node.setProperty("id", namespace);
        node.setProperty("namespace", namespace);
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException(e.getMessage(), e);
    }
}
 
Example #16
Source File: NodeTypeAggregator.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * If no match filter is defined, add the nt:nodeType as node type filter.
 */
public boolean matches(Node node, String path) throws RepositoryException {
    if (getMatchFilter().isEmpty()) {
        getMatchFilter().addInclude(
                new NodeTypeItemFilter(JcrConstants.NT_NODETYPE, true)
        );
    }
    return super.matches(node, path);
}
 
Example #17
Source File: JcrPackageRegistry.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@Nullable
private Node getPackageNode(@NotNull PackageId id) throws RepositoryException {
    String relPath = getRelativeInstallationPath(id);
    for (String pfx: packRootPaths) {
        String path = pfx + relPath;
        String[] exts = new String[]{"", ".zip", ".jar"};
        for (String ext: exts) {
            if (session.nodeExists(path + ext)) {
                return session.getNode(path + ext);
            }
        }
    }
    return null;
}
 
Example #18
Source File: RCPTest.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@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 #19
Source File: MockedResourceResolver.java    From sling-samples with Apache License 2.0 5 votes vote down vote up
public void delete(Resource resource) throws PersistenceException {
    if (resources.contains(resource)) {
        resources.remove(resource);
        Node node = resource.adaptTo(Node.class);
        try {
            node.remove();
        } catch (RepositoryException e) {
            throw new PersistenceException("RepositoryException: "+e, e);
        }
    } else {
        throw new UnsupportedOperationException("Not implemented");
    }
}
 
Example #20
Source File: TestSpecialDoubleProperties.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@Test
public void importDoubles() throws RepositoryException, IOException, PackageException {
    JcrPackage pack = packMgr.upload(getStream("/test-packages/double_properties.zip"), false);
    assertNotNull(pack);
    pack.install(getDefaultOptions());

    Node tmp = admin.getNode("/tmp/jcr:content");
    assertEquals(Double.NaN, tmp.getProperty("double_nan").getDouble(), 0.0);
    assertEquals(Double.POSITIVE_INFINITY, tmp.getProperty("double_pos_inf").getDouble(), 0.0);
    assertEquals(Double.NEGATIVE_INFINITY, tmp.getProperty("double_neg_inf").getDouble(), 0.0);
}
 
Example #21
Source File: CmdMixins.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: ThumbnailGenerator.java    From sling-samples with Apache License 2.0 5 votes vote down vote up
private void processNewNode(Node addedNode) throws Exception {
    final String mimeType = getMimeType(addedNode);
	if (mimeType == null) {
		return;
	}
	final String suffix = supportedMimeTypes.get(mimeType);

	// Scale to a temp file for simplicity
	log.info("Creating thumbnails for node {}", addedNode.getPath());
	final int [] widths = { 50, 100, 250 };
	for(int width : widths) {
	    createThumbnail(addedNode, width, mimeType, suffix);
	}
}
 
Example #23
Source File: AggregateImpl.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
private void include(Node node, String nodePath) throws RepositoryException {
    if (nodePath == null) {
        nodePath = node.getPath();
    }

    String relPath = nodePath.substring(path.length());
    if (includes == null || !includes.contains(relPath)) {
        if (log.isDebugEnabled()) {
            log.trace("including {} -> {}", path, nodePath);
        }
        if (includes == null) {
            includes = new HashSet<String>();
        }
        includes.add(mgr.cacheString(relPath));
        if (!node.isSame(getNode())) {
            // ensure that parent nodes are included
            include(node.getParent(), null);
        }
    }
}
 
Example #24
Source File: TestFolderArtifactHandler.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@Test
public void testNotModifyingContainedNodeNtFolderPrimaryType() throws RepositoryException, IOException, PackageException {
    // create node "/testroot/foo" with node type "nt:unstructured"
    Node rootNode = admin.getRootNode();
    Node testNode = rootNode.addNode("testroot", "nt:unstructured");
    Node fooNode = testNode.addNode("foo", "nt:folder");
    String oldId = fooNode.getIdentifier();
    admin.save();
    try (VaultPackage vltPackage = extractVaultPackageStrict("/test-packages/folder-without-docview-element.zip")) {
        assertNodeHasPrimaryType("/testroot/foo", "nt:folder");
        assertPropertyMissing("/testroot/value");
        assertEquals(oldId, admin.getNode("/testroot/foo").getIdentifier());
    }
}
 
Example #25
Source File: RepositoryServiceImpl.java    From urule with Apache License 2.0 5 votes vote down vote up
private List<String> getFiles(Node rootNode,String path) throws Exception{
	String project=getProject(path);
	List<String> list=new ArrayList<String>();
	Node projectNode=rootNode.getNode(project);		
	buildPath(list, projectNode);
	return list;
}
 
Example #26
Source File: TestFolderArtifactHandler.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatingIntermediateNodesWithFallbackType() throws RepositoryException, IOException, PackageException {
    // create node "/var/foo" with node type "nt:unstructured"
    Node rootNode = admin.getRootNode();
    Node testNode = rootNode.addNode("var", "nt:folder");
    admin.save();
    assertNodeHasPrimaryType("/var", "nt:folder");
    try (VaultPackage vltPackage = extractVaultPackage("/test-packages/folder-without-docview-element.zip")) {
        assertNodeHasPrimaryType("/var", "nt:folder");
        assertNodeHasPrimaryType("/var/foo", "nt:folder");
    }
}
 
Example #27
Source File: JcrPackageManagerImpl.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<JcrPackage> listPackages(String group, boolean built) throws RepositoryException {
    List<JcrPackage> packages = new LinkedList<JcrPackage>();
    for (Node root: registry.getPackageRoots()) {
        listPackages(root, packages, group, built);
    }
    Collections.sort(packages);
    return packages;
}
 
Example #28
Source File: WebdavProviderTestCase.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/** Recursively outputs the contents of the given node. */
private static void dump(final Node node) throws RepositoryException {
    // First output the node path
    message(node.getPath());
    // Skip the virtual (and large!) jcr:system subtree
    if (node.getName().equals("jcr:system")) {
        return;
    }

    if (node.getName().equals("jcr:content")) {
        return;
    }

    // Then output the properties
    final PropertyIterator properties = node.getProperties();
    while (properties.hasNext()) {
        final Property property = properties.nextProperty();
        if (property.getDefinition().isMultiple()) {
            // A multi-valued property, print all values
            final Value[] values = property.getValues();
            for (final Value value : values) {
                message(property.getPath() + " = " + value.getString());
            }
        } else {
            // A single-valued property
            message(property.getPath() + " = " + property.getString());
        }
    }

    // Finally output all the child nodes recursively
    final NodeIterator nodes = node.getNodes();
    while (nodes.hasNext()) {
        dump(nodes.nextNode());
    }
}
 
Example #29
Source File: CNDImporter.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
private int doPropertyType(Node pdi) throws ParseException, RepositoryException {
    if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
        return PropertyType.UNDEFINED;
    }
    nextToken();
    int type = PropertyType.UNDEFINED;
    if (currentTokenEquals(Lexer.STRING)) {
        type = PropertyType.STRING;
    } else if (currentTokenEquals(Lexer.BINARY)) {
        type = PropertyType.BINARY;
    } else if (currentTokenEquals(Lexer.LONG)) {
        type = PropertyType.LONG;
    } else if (currentTokenEquals(Lexer.DOUBLE)) {
        type = PropertyType.DOUBLE;
    } else if (currentTokenEquals(Lexer.BOOLEAN)) {
        type = PropertyType.BOOLEAN;
    } else if (currentTokenEquals(Lexer.DATE)) {
        type = PropertyType.DATE;
    } else if (currentTokenEquals(Lexer.NAME)) {
        type = PropertyType.NAME;
    } else if (currentTokenEquals(Lexer.PATH)) {
        type = PropertyType.PATH;
    } else if (currentTokenEquals(Lexer.REFERENCE)) {
        type = PropertyType.REFERENCE;
    } else if (currentTokenEquals(Lexer.UNDEFINED)) {
        type = PropertyType.UNDEFINED;
    } else {
        lexer.fail("Unknown property type '" + currentToken + "' specified");
    }
    pdi.setProperty(JcrConstants.JCR_REQUIREDTYPE, PropertyType.nameFromValue(type).toUpperCase());
    nextToken();
    if (!currentTokenEquals(Lexer.END_TYPE)) {
        lexer.fail("Missing '" + Lexer.END_TYPE + "' delimiter for end of property type");
    }
    nextToken();
    return type;
}
 
Example #30
Source File: JcrPackageRegistry.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
public JcrPackageRegistry(@NotNull Session session, @Nullable AbstractPackageRegistry.SecurityConfig securityConfig, @Nullable String... roots) {
    super(securityConfig);
    this.session = session;
    if (roots == null || roots.length == 0) {
        packRootPaths = new String[]{DEFAULT_PACKAGE_ROOT_PATH};
    } else {
        packRootPaths = roots;
    }
    packRoots = new Node[packRootPaths.length];
    initNodeTypes();
}