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