public String getPath() { try { return item.getPath(); } catch (RepositoryException e) { return ""; } }
public boolean isSame(Item item) throws RepositoryException { return nodePath.equals(item.getPath()); /* The ability to address the same piece of data via more than one path is a common feature of many content storage systems. In JCR this feature is supported through shareable nodes. */ // return this.item.isSame(item); }
/** * Add item * @param item item * @throws RepositoryException */ void addItem(final Item item) throws RepositoryException { this.items.put(item.getPath(), item); }
/** * @see Predicate#evaluate(java.lang.Object) */ public boolean evaluate(Object item) { if ( item instanceof Item ) { try { return regex.matcher(((Item)item).getPath()).matches(); } catch (RepositoryException re) { return false; } } return false; } }
private ZipEntryExportContext(Item exportRoot, OutputStream out, ExportContext context, int pos) { super(exportRoot, out != null, context.getIOListener()); this.out = out; try { String entryPath = (exportRoot.getPath().length() > pos) ? exportRoot.getPath().substring(pos) : ""; entry = new ZipEntry(entryPath); } catch (RepositoryException e) { // should never occur } }
/** {@inheritDoc} */ public String getPath() throws RepositoryException, RemoteException { try { return item.getPath(); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public String getPath() throws JcrDiffException { try { return jcrItem.getPath(); } catch (RepositoryException e) { throw new JcrDiffException("Could not get item path", e); } }
public void registerVisitedItem(Item item) { if (item != null && item.isNode()) { try { synchronized (visitedNodePathSet) { visitedNodePathSet.add(item.getPath()); } } catch (RepositoryException e) { log.warn("Failed to retrieve item path.", e); } } }
RangeIterator listChildren(final String parentPath, final ItemFilter filter) throws RepositoryException { List<Item> children = new ArrayList<Item>(); // build regex pattern for all child paths of parent Pattern pattern = Pattern.compile("^" + Pattern.quote(parentPath) + "/[^/]+$"); // collect child resources for (Item item : this.items.values()) { if (pattern.matcher(item.getPath()).matches() && (filter == null || filter.accept(item))) { children.add(item); } } return new RangeIteratorAdapter(children.iterator(), children.size()); }
public boolean matches(Item itemToMatch) { try { // TODO: missing proper impl return matches(itemToMatch.getPath()); } catch (RepositoryException e) { log.error("Unable to determine match. {}", e.getMessage()); return false; } }
public boolean matches(Item itemToMatch) { try { // TODO: missing proper impl return matches(itemToMatch.getPath()); } catch (RepositoryException e) { log.error("Unable to determine match. {}", e.getMessage()); return false; } }
@Override public void beforeItemSave(Item item) throws RepositoryException { events = changeLog.removeAndGetAffectedEvents(item.getPath()); if (events != null && !events.isEmpty()) { for (EventsListener l : eventsListeners) { l.handleEventsBeforeSave(session, item, events); } } }
public void move(Object src, Object dstParent, String name) throws PersistenceException { try { final Session session = ((Item)src).getSession(); final Item source = ((Item)src); final String targetParentPath = ((Node)dstParent).getPath(); final String targetPath = (targetParentPath.equals("/") ? "" : targetParentPath) + '/' + name; session.move(source.getPath(), targetPath); } catch ( final RepositoryException re) { throw new PersistenceException(re.getMessage(), re); } }
@Override protected void setUp() throws Exception { super.setUp(); removeItem = createRemoveItem(); removePath = removeItem.getPath(); }
Node nodeFor( ResolvedRequest request ) throws RepositoryException { Session session = session(request); Item item = session.getItem(request.getPath()); if (item instanceof Property) { throw new WebdavException(WebdavI18n.errorPropertyPath.text(item.getPath())); } return (Node)item; }
/** * Check whether we can traverse the hierarchy when the item info for a deep item * is retrieved first. * @throws RepositoryException */ public void testGetItemInfosDeepFirst() throws RepositoryException { final String targetPath = "/node2/node21/node211/node2111/node21111/node211111/node2111111"; assertEquals(targetPath, session.getItem(targetPath).getPath()); checkHierarchy(); }
public void testGetItemOrNullExistingProperty() throws RepositoryException { JackrabbitSession js = (JackrabbitSession) superuser; Item item = js.getItemOrNull(PATH_EXISTING_PROPERTY); assertNotNull(item); assertTrue(item instanceof Property); assertEquals(item.getPath(), PATH_EXISTING_PROPERTY); }
public void testGetItemOrNullExistingNode() throws RepositoryException { JackrabbitSession js = (JackrabbitSession) superuser; Item item = js.getItemOrNull(PATH_EXISTING_NODE); assertNotNull(item); assertTrue(item instanceof Node); assertEquals(item.getPath(), PATH_EXISTING_NODE); }
@Test public void getJcrItemWhenWorkbenchPathIsNotRoot() throws RepositoryException { // GIVEN Node node1 = AbstractJcrContainerTest.createNode(rootNode, "node1", NodeTypes.Content.NAME, PROPERTY_1, "name1"); node1.getSession().save(); // WHEN connectorDefinition.setRootPath("/node1"); Item res = container.getJcrItem(JcrItemUtil.getItemId(node1)); // THEN assertNotNull(res); assertEquals("/node1", res.getPath()); }
@Test public void testSetCommonAttributesWithNode() throws Exception { // GIVEN String nodeName = "nodeName"; Node testNode = session.getRootNode().addNode(nodeName); // WHEN DummyJcrAdapter adapter = new DummyJcrAdapter(testNode); // THEN assertTrue(adapter.isNode()); assertEquals(workspaceName, adapter.getWorkspace()); assertEquals(testNode.getIdentifier(), adapter.getItemId().getUuid()); assertEquals(testNode.getPath(), adapter.getJcrItem().getPath()); }