Updating views with the Java API
I'm trying to update the Views in our Couchbase 2.0 server using the Java client library from http://www.couchbase.com/develop/java/next.
Using the normal set-operation with "_design/dev_user" as key returns successfully, but does not change the document in any way.
Using the delete and replace operations the request times out when waiting on the returned OperationFuture.
Is there some special protection for these documents rendering them unchangeable with the API, or am I doing something wrong?
Yes, the design documents need to be updated through the view REST interface. You'll find a simple example for how to do so on the wiki. Also we're going to add some cluster management to the client, including management of design documents.
Hey, this doesn't answer your question directly but thought I'd give you food for thought. I modify some views but found the easiest way was via rest. I do some of this from a coldfusion context which is java underneath...so this might make some really easy psuedocode for you:
http = new http();
http.setTimeOut( 3600 );
pageUrl = 'http://' & serverIp & ':8092/' & bucketName &'/_design/' & designName;
http.setMethod( "put" );
http.addParam( type="header", name="Content-Type", value="application/json" );
http.addParam( type="body", value=data );
http.setUrl( pageUrl );
result = http.send();
Where 'data' is the valid json describing the views, which you can see examples by doing something like:
pageUrl = 'http://' & serverIp & ':8092/' & bucketName &'/_design/' & designName & '?startkey="_design"&endkey="_design0"&includeDocs=true';
...anyhow the point is...you might look at using REST from your code if you find the java client isn't developed enough yet.