}
private CollectionImpl mkcol(final XmldbURI collPath, final Date created) throws XMLDBException, URISyntaxException {
final XmldbURI[] allSegments = collPath.getPathSegments();
final XmldbURI[] segments = Arrays.copyOfRange(allSegments, 1, allSegments.length); //drop the first 'db' segment
final XmldbURI dbUri;
if(!dbBaseUri.endsWith(XmldbURI.ROOT_COLLECTION)) {
dbUri = XmldbURI.xmldbUriFor(dbBaseUri + XmldbURI.ROOT_COLLECTION);
} else {
dbUri = XmldbURI.xmldbUriFor(dbBaseUri);
}
CollectionImpl current = (CollectionImpl)DatabaseManager.getCollection(dbUri.toString(), dbUsername, dbPassword);
XmldbURI p = XmldbURI.ROOT_COLLECTION_URI;
for(final XmldbURI segment : segments) {
p = p.append(segment);
final XmldbURI xmldbURI = dbUri.resolveCollectionPath(p);
CollectionImpl c = (CollectionImpl)DatabaseManager.getCollection(xmldbURI.toString(), dbUsername, dbPassword);
if(c == null) {
current.setTriggersEnabled(false);
final CollectionManagementServiceImpl mgtService = (CollectionManagementServiceImpl)current.getService("CollectionManagementService", "1.0");
c = (CollectionImpl)mgtService.createCollection(segment, created);
current.setTriggersEnabled(true);