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;
}
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();
}
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);
}
}
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);
}
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;
}
Aggregations