logger.error("Resource " + doc + " not found");
throw new XPathException(this, "Resource " + doc + " not found");
}
final String newName = args[2].itemAt(0).getStringValue();
final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl)
collection.getService("CollectionManagementService", "1.0");
service.moveResource(doc, (XmldbURI) null,
XmldbURI.xmldbUriFor(newName));
} catch (final XMLDBException e) {
logger.error(e.getMessage());
throw new XPathException(this, "XMLDB exception caught: " + e.getMessage(), e);
} catch (final URISyntaxException e) {
logger.error(e.getMessage());
throw new XPathException(this, "URI exception: " + e.getMessage(), e);
}
} else {
try {
final String newName = args[1].itemAt(0).getStringValue();
final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl)
collection.getService("CollectionManagementService", "1.0");
service.move(XmldbURI.xmldbUriFor(collection.getName()), null,
XmldbURI.xmldbUriFor(newName));
} catch (final XMLDBException e) {
logger.error("Cannot rename collection: " + e.getMessage());