String newName = args.get( 0 );
log.debug( "mkdir. execute: " + newName );
if( !cursor.isFolder() ) {
return result( "current dir not found: " + cursor.getPath() );
} else {
CollectionResource cur = (CollectionResource) cursor.getResource();
Result validationResult = validate( cur, newName );
if( validationResult != null ) {
return validationResult;
}
if( cur instanceof MakeCollectionableResource ) {
MakeCollectionableResource mcr = (MakeCollectionableResource) cur;
CollectionResource newCol;
try {
newCol = doCreate( mcr, newName );
} catch( BadRequestException ex) {
log.debug( "ex", ex );
return result( "BadRequestException exception: " + ex.getMessage() );
} catch( ConflictException ex ) {
log.debug( "ex", ex );
return result( "conflict exception: " + ex.getMessage() );
} catch( NotAuthorizedException ex ) {
log.debug( "ex", ex );
return result( "you are not authorized to create a folder here: " + ex.getMessage() );
}
Path newPath = cursor.getPath().child( newName );
return new Result( cursor.getPath().toString(), "created: <a href='" + newPath + "'>" + newCol.getName() + "</a>" );
} else {
return result( "current dir does not support creating child collections: " + cursor.getPath() );
}
}
}