use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class SessionImpl method getImportContentHandler.
/**
* {@inheritDoc}
*/
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
// check sanity of this session
sanityCheck();
NodeImpl parent;
try {
Path p = getQPath(parentAbsPath).getNormalizedPath();
if (!p.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + parentAbsPath);
}
parent = getItemManager().getNode(p);
} catch (NameException e) {
String msg = parentAbsPath + ": invalid path";
log.debug(msg);
throw new RepositoryException(msg, e);
} catch (AccessDeniedException ade) {
throw new PathNotFoundException(parentAbsPath);
}
// verify that parent node is checked-out, not locked and not protected
// by either node type constraints nor by some retention or hold.
int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
context.getItemValidator().checkModify(parent, options, Permission.NONE);
SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, context.getWorkspace().getConfig().getImportConfig());
return new ImportHandler(importer, this);
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class QueryImpl method storeAsNode.
/**
* {@inheritDoc}
*/
public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
checkInitialized();
try {
Path p = sessionContext.getQPath(absPath).getNormalizedPath();
if (!p.isAbsolute()) {
throw new RepositoryException(absPath + " is not an absolute path");
}
String relPath = sessionContext.getJCRPath(p).substring(1);
Node queryNode = sessionContext.getSessionImpl().getRootNode().addNode(relPath, sessionContext.getJCRName(NT_QUERY));
// set properties
queryNode.setProperty(sessionContext.getJCRName(JCR_LANGUAGE), language);
queryNode.setProperty(sessionContext.getJCRName(JCR_STATEMENT), statement);
node = queryNode;
return node;
} catch (NameException e) {
throw new RepositoryException(e.getMessage(), e);
}
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class VersionHistoryImpl method removeVersion.
/**
* @see javax.jcr.version.VersionHistory#removeVersion(String)
*/
public void removeVersion(String versionName) throws UnsupportedRepositoryOperationException, VersionException, RepositoryException {
try {
// check permissions
checkVersionManagementPermission();
sessionContext.getSessionImpl().getInternalVersionManager().removeVersion(getSession(), getInternalVersionHistory(), sessionContext.getQName(versionName));
} catch (NameException e) {
throw new RepositoryException(e);
}
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class WorkspaceImpl method internalClone.
/**
* Handles a clone inside the same workspace, which is supported with
* shareable nodes.
*
* @see {@link #clone()}
*
* @param srcAbsPath source path
* @param destAbsPath destination path
* @return the path of the node at its new position
* @throws ConstraintViolationException
* @throws AccessDeniedException
* @throws VersionException
* @throws PathNotFoundException
* @throws ItemExistsException
* @throws LockException
* @throws RepositoryException
*/
private String internalClone(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
Path srcPath;
try {
srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + srcAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!srcPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + srcAbsPath);
}
Path destPath;
try {
destPath = context.getQPath(destAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + destAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!destPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + destAbsPath);
}
BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
try {
ops.edit();
} catch (IllegalStateException e) {
String msg = "unable to start edit operation";
log.debug(msg);
throw new RepositoryException(msg, e);
}
boolean succeeded = false;
try {
ItemId id = ops.clone(srcPath, destPath);
ops.update();
succeeded = true;
return context.getJCRPath(hierMgr.getPath(id));
} finally {
if (!succeeded) {
// update operation failed, cancel all modifications
ops.cancel();
}
}
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class WorkspaceImpl method move.
/**
* {@inheritDoc}
*/
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
// check state of this instance
sanityCheck();
// intra-workspace move...
Path srcPath;
try {
srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + srcAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!srcPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + srcAbsPath);
}
Path destPath;
try {
destPath = context.getQPath(destAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + destAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!destPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + destAbsPath);
}
BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
try {
ops.edit();
} catch (IllegalStateException e) {
String msg = "unable to start edit operation";
log.debug(msg);
throw new RepositoryException(msg, e);
}
boolean succeeded = false;
try {
ops.move(srcPath, destPath);
ops.update();
succeeded = true;
} finally {
if (!succeeded) {
// update operation failed, cancel all modifications
ops.cancel();
}
}
}
Aggregations