abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: Problem with PUT and DELETE
Date Wed, 20 Feb 2008 19:43:27 GMT


Chiradip Narayan Mandal wrote:
> Hello James and David,
> 
> Thanks for your replies. But James! I think PUT & DELETE is not going to
> work with blogger using Abdera, even after overriding.
> 

I've tested it before with the current version of blogger and it's worked.

> I have another problem - it is regarding POST with roller. I use the latest
> version of roller and the code snippet below. Problem is with the line
> containign 'Service service = service_doc.getRoot();'. I am getting a
> ClassCastException saying FOMFeed can not be casted to Service. Any help?
> 

You must be trying to GET the collection feed and not the service 
document or, roller is serving the feed incorrectly when a service 
document is requested.

- James

> Chiradip
> 
> Document<Service> service_doc = client.get(start).getDocument();
> 
> Service service = service_doc.getRoot();
> 
> Collection collection = service.getWorkspaces
> ().get(0).getCollections().get(0);
> 
> String uri = collection.getHref().toString();
> 
> 
> On Wed, Feb 20, 2008 at 11:17 PM, James M Snell <jasnell@gmail.com> wrote:
> 
>> They may be blocking PUT and DELETE. Try using POST but add the
>> X-HTTP-Method-Override header to the request.
>>
>> e.g.
>>
>>   POST /foo HTTP/1.1
>>   X-HTTP-Method-Override: PUT
>>
>> More info:
>>   http://code.google.com/apis/gdata/basics.html#Updating-an-entry
>>
>> In the Abdera client, the post override can be set using the
>> RequestOptions
>>
>>   Abdera abdera = new Abdera();
>>   AbderaClient client = new AbderaClient(abdera);
>>   RequestOptions options = client.getDefaultRequestOptions();
>>   options.setUsePostOverride(true);
>>   ClientResponse resp = client.put("...", ..., options);
>>
>>
>> - James
>>
>> Chiradip Narayan Mandal wrote:
>>> * Hello,
>>  >
>>> Can anybody please help me about the below code? It is mainly taken from
>> the
>>> example written by James. With the same condition POST is going
>> perfectly
>>> well. But I am not able to perform PUT and DELETE operations. I
>> understand
>>> the success status codes for PUT and DELETE are different from POST. I
>> am
>>> getting 400 as the status code and 'Bad request' as the satus code text.
>> I
>>> want to know how PUT and DELETE can be performed.
>>>
>>> Chiradip
>>>
>>> public* *static* *void* putToBlogger() *throws* Exception {
>>>
>>> Abdera abdera = *new* Abdera();
>>>
>>> URL url = *new* URL("http://atomsandbox.blogspot.com/feeds/posts/default"
>> );
>>> Parser parser = Abdera.*getNewParser*();
>>>
>>> Document<Feed> doc = parser.parse( url.openStream() );
>>>
>>> Feed feed = doc.getRoot();
>>>
>>> Entry entry = feed.getEntry( "tag:blogger.com,1999:
>>> blog-8038874006622135494.post-6147415018903117917" );
>>>
>>> *out*.println( "entry.getTitle() : " + entry.getTitle() );
>>>
>>> entry.setUpdated( *new* java.util.Date() );
>>>
>>> AbderaClient client = *new* AbderaClient( abdera );
>>>
>>> String auth = GoogleLogin.*getAuth*( client, "blogger",
>>> "your_real_user_name", "your_password" );
>>>
>>> RequestOptions options = client.getDefaultRequestOptions();
>>>
>>> options.setAuthorization( "GoogleLogin " + auth );
>>>
>>> BaseRequestEntity bre = *new* BaseRequestEntity( entry, *false* );
>>>
>>> Response response = client.put( "
>>> http://atomsandbox.blogspot.com/feeds/posts/default", bre, options );
>>>
>>> *out*.println("response.getStatusText() : " + response.getStatus() + " "
>> +
>>> response.getStatusText() );
>>>
>>> *if* ( response.getStatus() == 201 )
>>>
>>> *out*.println( "Success!" );
>>>
>>> *else
>>> *
>>>
>>> *out*.println( "Failed!" );
>>>
>>> }
>>>
> 

Mime
View raw message