Search in sources :

Example 21 with Item

use of javax.jcr.Item in project magnolia-vanity-url by aperto.

the class LinkColumnFormatter method generateCell.

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    String link = "";
    final Item jcrItem = getJcrItem(source, itemId);
    if (jcrItem != null && jcrItem.isNode()) {
        link = _vanityUrlService.createPublicUrl((Node) jcrItem);
    }
    return link;
}
Also used : Item(javax.jcr.Item) Node(javax.jcr.Node)

Example 22 with Item

use of javax.jcr.Item in project vorto by eclipse.

the class DefaultModelBackupService method removeAll.

private void removeAll() throws Exception {
    Set<String> rootNodes = new HashSet<>();
    for (ModelInfo resource : this.modelRepository.search("*")) {
        int namespaceIdx = resource.getId().getNamespace().indexOf(".");
        if (namespaceIdx != -1) {
            final String org = resource.getId().getNamespace().substring(0, namespaceIdx);
            rootNodes.add(org);
        } else {
            rootNodes.add(resource.getId().getNamespace());
        }
    }
    for (String rootNode : rootNodes) {
        try {
            Item item = session.getItem("/" + rootNode);
            item.remove();
        } catch (PathNotFoundException ex) {
        }
    }
    this.session.save();
}
Also used : Item(javax.jcr.Item) ModelInfo(org.eclipse.vorto.repository.api.ModelInfo) PathNotFoundException(javax.jcr.PathNotFoundException) HashSet(java.util.HashSet)

Example 23 with Item

use of javax.jcr.Item in project jackrabbit-oak by apache.

the class ReadWithMembershipTest method setupACEs.

private void setupACEs(Principal principal) throws RepositoryException {
    int size = allPaths.size();
    for (int i = 0; i < numberOfAces; i++) {
        int index = (int) Math.floor(size * Math.random());
        Item item = adminSession.getItem(allPaths.get(index));
        Node n = (item.isNode()) ? (Node) item : item.getParent();
        String path = getAccessControllablePath(n);
        AccessControlUtils.addAccessControlEntry(adminSession, path, principal, new String[] { PrivilegeConstants.JCR_READ }, true);
    }
}
Also used : Item(javax.jcr.Item) Node(javax.jcr.Node)

Example 24 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class ChildrenCollectorFilter method collectProperties.

public static PropertyIterator collectProperties(Node node, String[] nameGlobs) throws RepositoryException {
    Collection<Item> properties = Collections.emptySet();
    PropertyIterator pit = node.getProperties();
    while (pit.hasNext()) {
        Property p = pit.nextProperty();
        if (matches(p.getName(), nameGlobs)) {
            properties = addToCollection(properties, p);
        }
    }
    return new PropertyIteratorAdapter(properties);
}
Also used : Item(javax.jcr.Item) PropertyIteratorAdapter(org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter) PropertyIterator(javax.jcr.PropertyIterator) Property(javax.jcr.Property)

Example 25 with Item

use of javax.jcr.Item in project jackrabbit by apache.

the class NtFilePredicate method evaluate.

/**
 * @return <code>true</code> if the item is a nt:file or nt:resource property
 * @see org.apache.jackrabbit.commons.predicate.Predicate#evaluate(java.lang.Object)
 */
public boolean evaluate(Object item) {
    if (item instanceof Item) {
        if (!((Item) item).isNode()) {
            try {
                Property prop = (Property) item;
                String dnt = prop.getDefinition().getDeclaringNodeType().getName();
                // exclude all nt:file props
                if (dnt.equals(NT_FILE) || dnt.equals(NT_HIERARCHYNODE)) {
                    return true;
                }
                if (ignoreEncoding && prop.getName().equals(JCR_ENCODING)) {
                    return false;
                }
                if (ignoreMimeType && prop.getName().equals(JCR_MIMETYPE)) {
                    return false;
                }
                // exclude nt:resource props, if parent is 'jcr:content'
                if (prop.getParent().getName().equals(JCR_CONTENT)) {
                    if (dnt.equals(NT_RESOURCE)) {
                        return true;
                    }
                // exclude primary type if nt:resource
                /*
                        if (prop.getName().equals(JCR_PRIMARY_TYPE)
                                && prop.getValue().getString().equals(NT_RESOURCE)) {
                            return true;
                        }
                        */
                }
            } catch (RepositoryException re) {
                return false;
            }
        }
    }
    return false;
}
Also used : Item(javax.jcr.Item) RepositoryException(javax.jcr.RepositoryException) Property(javax.jcr.Property)

Aggregations

Item (javax.jcr.Item)138 Node (javax.jcr.Node)61 RepositoryException (javax.jcr.RepositoryException)34 Session (javax.jcr.Session)26 Property (javax.jcr.Property)24 PathNotFoundException (javax.jcr.PathNotFoundException)20 ArrayList (java.util.ArrayList)7 JcrCallback (org.springframework.extensions.jcr.JcrCallback)7 PrintWriter (java.io.PrintWriter)6 ItemNotFoundException (javax.jcr.ItemNotFoundException)6 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)5 PropertyIterator (javax.jcr.PropertyIterator)5 ValueFormatException (javax.jcr.ValueFormatException)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)5 MetadataAccessException (com.thinkbiganalytics.metadata.api.MetadataAccessException)4 MetadataExecutionException (com.thinkbiganalytics.metadata.api.MetadataExecutionException)4 JcrPath (com.thinkbiganalytics.metadata.modeshape.support.JcrPath)4