Search in sources :

Example 21 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class ChildNodeEntriesImpl method reload.

/**
     * @see ChildNodeEntries#reload()
     */
public synchronized void reload() throws ItemNotFoundException, RepositoryException {
    if (isComplete()) {
        // nothing to do
        return;
    }
    NodeId id = parent.getWorkspaceId();
    Iterator<ChildInfo> childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id);
    update(childNodeInfos);
}
Also used : NodeId(org.apache.jackrabbit.spi.NodeId) ChildInfo(org.apache.jackrabbit.spi.ChildInfo)

Example 22 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class RepositoryServiceImpl method retrieveLockInfo.

private LockInfo retrieveLockInfo(LockDiscovery lockDiscovery, SessionInfo sessionInfo, NodeId nodeId, NodeId parentId) throws RepositoryException {
    checkSessionInfo(sessionInfo);
    List<ActiveLock> activeLocks = lockDiscovery.getValue();
    ActiveLock activeLock = null;
    for (ActiveLock l : activeLocks) {
        Scope sc = l.getScope();
        if (l.getType() == Type.WRITE && (Scope.EXCLUSIVE.equals(sc) || sc == ItemResourceConstants.EXCLUSIVE_SESSION)) {
            if (activeLock != null) {
                throw new RepositoryException("Node " + saveGetIdString(nodeId, sessionInfo) + " contains multiple exclusive write locks.");
            } else {
                activeLock = l;
            }
        }
    }
    if (activeLock == null) {
        log.debug("No lock present on node " + saveGetIdString(nodeId, sessionInfo));
        return null;
    }
    NodeId holder = null;
    String lockroot = activeLock.getLockroot();
    if (activeLock.getLockroot() != null) {
        holder = uriResolver.getNodeId(lockroot, sessionInfo);
    }
    if (activeLock.isDeep() && holder == null && parentId != null) {
        // deep lock, parent known, but holder is not
        LockInfo pLockInfo = getLockInfo(sessionInfo, parentId);
        if (pLockInfo != null) {
            return pLockInfo;
        }
    }
    return new LockInfoImpl(activeLock, holder == null ? nodeId : holder, ((SessionInfoImpl) sessionInfo).getAllLockTokens());
}
Also used : ActiveLock(org.apache.jackrabbit.webdav.lock.ActiveLock) Scope(org.apache.jackrabbit.webdav.lock.Scope) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException) LockInfo(org.apache.jackrabbit.spi.LockInfo)

Example 23 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class RepositoryServiceImpl method restore.

@Override
public void restore(SessionInfo sessionInfo, NodeId nodeId, NodeId versionId, boolean removeExisting) throws RepositoryException {
    String uri = getItemUri(nodeId, sessionInfo);
    String vUri = getItemUri(versionId, sessionInfo);
    Path relPath = null;
    if (!exists(sessionInfo, uri)) {
        // restore with rel-Path part
        Path path = nodeId.getPath();
        if (nodeId.getUniqueID() != null) {
            uri = getItemUri(idFactory.createNodeId(nodeId.getUniqueID(), null), sessionInfo);
            relPath = (path.isAbsolute()) ? getPathFactory().getRootPath().computeRelativePath(path) : path;
        } else {
            int degree = 0;
            while (degree < path.getLength()) {
                Path ancestorPath = path.getAncestor(degree);
                NodeId parentId = idFactory.createNodeId(nodeId.getUniqueID(), ancestorPath);
                if (exists(sessionInfo, getItemUri(parentId, sessionInfo))) {
                    uri = getItemUri(parentId, sessionInfo);
                    relPath = ancestorPath.computeRelativePath(path);
                    break;
                }
                degree++;
            }
        }
    }
    update(uri, relPath, new String[] { vUri }, UpdateInfo.UPDATE_BY_VERSION, removeExisting, sessionInfo);
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeId(org.apache.jackrabbit.spi.NodeId)

Example 24 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class RepositoryServiceImpl method checkpoint.

@Override
public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
    // TODO review again.
    NodeId vID = checkin(sessionInfo, nodeId);
    checkout(sessionInfo, nodeId);
    return vID;
}
Also used : NodeId(org.apache.jackrabbit.spi.NodeId)

Example 25 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class RepositoryServiceImpl method merge.

@Override
public Iterator<NodeId> merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName, boolean bestEffort, boolean isShallow) throws RepositoryException {
    HttpMerge request = null;
    try {
        Document doc = DomUtil.createDocument();
        String wspHref = obtainAbsolutePathFromUri(uriResolver.getWorkspaceUri(srcWorkspaceName));
        Element mElem = MergeInfo.createMergeElement(new String[] { wspHref }, !bestEffort, false, doc);
        if (isShallow) {
            mElem.appendChild(DomUtil.depthToXml(false, doc));
        }
        MergeInfo mInfo = new MergeInfo(mElem);
        String uri = getItemUri(nodeId, sessionInfo);
        request = new HttpMerge(uri, mInfo);
        initMethod(request, sessionInfo, !isUnLockMethod(request));
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
        MultiStatusResponse[] resps = request.getResponseBodyAsMultiStatus(response).getResponses();
        List<NodeId> failedIds = new ArrayList<NodeId>(resps.length);
        for (MultiStatusResponse resp : resps) {
            String href = resolve(uri, resp.getHref());
            failedIds.add(uriResolver.getNodeId(href, sessionInfo));
        }
        return failedIds.iterator();
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (ParserConfigurationException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : MergeInfo(org.apache.jackrabbit.webdav.version.MergeInfo) DavException(org.apache.jackrabbit.webdav.DavException) Element(org.w3c.dom.Element) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) Document(org.w3c.dom.Document) HttpMerge(org.apache.jackrabbit.webdav.client.methods.HttpMerge) NodeId(org.apache.jackrabbit.spi.NodeId) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

NodeId (org.apache.jackrabbit.spi.NodeId)80 Batch (org.apache.jackrabbit.spi.Batch)35 Name (org.apache.jackrabbit.spi.Name)32 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)23 RepositoryException (javax.jcr.RepositoryException)21 QValue (org.apache.jackrabbit.spi.QValue)21 PropertyId (org.apache.jackrabbit.spi.PropertyId)13 Path (org.apache.jackrabbit.spi.Path)11 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)10 ArrayList (java.util.ArrayList)9 ItemNotFoundException (javax.jcr.ItemNotFoundException)9 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)9 IOException (java.io.IOException)6 Node (javax.jcr.Node)5 HttpResponse (org.apache.http.HttpResponse)5 ItemId (org.apache.jackrabbit.spi.ItemId)5 DavException (org.apache.jackrabbit.webdav.DavException)5 InputStream (java.io.InputStream)4 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)4 PathNotFoundException (javax.jcr.PathNotFoundException)3