use of org.apache.jackrabbit.core.xml.ImportHandler 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.core.xml.ImportHandler in project jackrabbit by apache.
the class UserImporterTest method doImport.
private void doImport(NodeImpl target, String xml, int uuidBehavior, int importBehavior) throws IOException, SAXException, RepositoryException {
InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8"));
SessionImporter importer = new SessionImporter(target, sImpl, uuidBehavior, new PseudoConfig(importBehavior));
ImportHandler ih = new ImportHandler(importer, sImpl);
new ParsingContentHandler(ih).parse(in);
}
use of org.apache.jackrabbit.core.xml.ImportHandler in project jackrabbit by apache.
the class UserImporterTest method doImport.
// --------------------------------------------------------------------------
private void doImport(NodeImpl target, String xml) throws IOException, SAXException, RepositoryException {
InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8"));
SessionImporter importer = new SessionImporter(target, sImpl, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW, new PseudoConfig());
ImportHandler ih = new ImportHandler(importer, sImpl);
new ParsingContentHandler(ih).parse(in);
}
use of org.apache.jackrabbit.core.xml.ImportHandler in project jackrabbit by apache.
the class WorkspaceImpl method getImportContentHandler.
/**
* {@inheritDoc}
*/
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
// check state of this instance
sanityCheck();
Path parentPath;
try {
parentPath = context.getQPath(parentAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + parentAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!parentPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + parentAbsPath);
}
Importer importer = new WorkspaceImporter(parentPath, this, context, uuidBehavior, wspConfig.getImportConfig());
return new ImportHandler(importer, getSession());
}
Aggregations