basho/yokozuna — pull request #323 by rzezeski (2014-02-25 22:00:12+00:00)
Title: Verify schema version

This patch verifies that the schema version is set to `1.5` and is the
second part of enhancements for issues #321. There was also
supplemental work done around error messages so that they would
display in a more user friendly manner.

Result of uploading schema with wrong version:

```
# curl -i -X PUT -H 'content-type: application/xml' 'http://localhost:10018/search/schema/bad_version' --data-binary @/root/bad-version-schema.xml
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Server: MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)
Date: Tue, 25 Feb 2014 21:08:06 GMT
Content-Type: text/plain
Content-Length: 61

Error storing schema: schema 'version' attribute must be 1.5
```

Attempting to store schema with missing fields (yes, the x-path is
ugly but this is still an improvement from raw erlang terms):

```
# curl -i -X PUT -H 'content-type: application/xml' 'http://localhost:10018/search/schema/bad_version' --data-binary @/root/missing-fields-schema.xml
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Server: MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)
Date: Tue, 25 Feb 2014 21:08:59 GMT
Content-Type: text/plain
Content-Length: 205

Error storing schema: missing field /schema/fields/field[@name="_yz_fpn" and @type="_yz_str" and @indexed="true"]
missing field /schema/fields/field[@name="_yz_pn" and @type="_yz_str" and @indexed="true"]
```

Attempting to store a truncated schema:

```
# curl -i -X PUT -H 'content-type: application/xml' 'http://localhost:10018/search/schema/bad_version' --data-binary @/root/truncated-schema.xml
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Server: MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)
Date: Tue, 25 Feb 2014 21:10:52 GMT
Content-Type: text/plain
Content-Length: 203

Error storing schema: failed to parse {fatal,
{unexpected_end,
{file,file_name_unknown},
{line,161},
{col,1}}}
```