Thierry,

Here the sample code which reproduce the bug. I am going to test again with
the svn version.
Sorry for the lag.

Thanks.
Rémi

On Thu, Jul 3, 2008 at 10:00 AM, Thierry Boileau <[EMAIL PROTECTED]>
wrote:

> Hi Rémi,
>
> thanks for your report, it helps fixing a bug in the FileClientHelper. The
> fix is now available in the svn repositories (Restlet 1.0 and 1.1).
> Could you try again and tell us if it solves your problem?
>
> best regards,
> Thierry Boileau
>
>
>  Yes I have the TunnelService on but off for extensions. The
>> FileClientHelper search for a file with file starting with the same baseName
>> and having the same set of extensions : no surprise it finds test2.xml.
>> I'll be off for the end of the week. I will test it as soon as possible
>> and investigate a bit more on this.
>> Thanks for the fast feedback !
>> RÃ(c)mi
>>
>>
>> On Wed, Jul 2, 2008 at 6:09 PM, Thierry Boileau <[EMAIL PROTECTED]<mailto:
>> [EMAIL PROTECTED]>> wrote:
>>
>>    Hello RÃ(c)mi,
>>
>>
>>    I'm not able to reproduce your problem with Restlet 1.1M4. I send
>>    you my sample code.
>>    It contains a directory and 2 restlet, one that creates/updates
>>    the "test.xml" file, the other the "test2.xml" file.
>>    Just hot http://localhost:8182/restletPut1 and
>>    http://localhost:8182/restletPut2 to "invoke" them.
>>
>>    Are you using some filter? such as TunnelFilter?
>>
>>    best regards,
>>    Thierry Boileau
>>
>>        Hello,
>>        I have an issue with the implementation of PUT on files.
>>        Let say I have files in a directory :
>>        test.xml
>>        test2.xml
>>        If I make a PUT on test.xml it will modify test2.xml which is
>>        not exactilly what I would expect.
>>        I don't really catch what I don't understand reading from line
>>        187 to line 219 in FileClientHelper.
>>        If it is not a bug what should I do ?
>>
>>        I am using this line of code :
>>        Response resp =
>>
>>  
>> Application.getCurrent().getContext().getClientDispatcher().put(resourceUri,new
>>        DomRepresentation(MediaType.TEXT_XML,doc));
>>
>>        I am using Restlet 1.1M4.
>>
>>        Thanks a lot,
>>        RÃ(c)mi
>>
>>
>>
package testPut;

import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.DomRepresentation;
import org.restlet.resource.Representation;
import org.restlet.resource.StringRepresentation;

public class TestApplication extends Application {
    public static void main(String[] args) {
        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);
        component.getClients().add(Protocol.FILE);
        component.getDefaultHost().attachDefault(new TestApplication(component.getContext()));
        try {
            component.start();
        } catch (Exception e) {
        }
    }

    public TestApplication(Context parentContext) {
        super(parentContext);
    }

    @Override
    public Restlet createRoot() {
        Router router = new Router(getContext());

        // Restlet that puts a representation to file "test.xml"
        Restlet restletPut1 = new Restlet(getContext()) {
            @Override
            public void handle(Request request, Response response) {
                Representation xmlRep = new StringRepresentation("<a>b</a>", MediaType.TEXT_XML);
                DomRepresentation domRepresentation = new DomRepresentation(xmlRep);

                Response resp = getContext().getClientDispatcher().put("file:///tmp/test.xml", domRepresentation);
                response.setEntity(resp.getEntity());
                response.setStatus(resp.getStatus());
            }
        };

        // Restlet that puts a representation to file "test2.xml"
        Restlet restletPut2 = new Restlet(getContext()) {
            @Override
            public void handle(Request request, Response response) {
                Representation xmlRep = new StringRepresentation("<c>d</c>", MediaType.TEXT_XML);
                DomRepresentation domRepresentation = new DomRepresentation(xmlRep);
                Response resp = getContext().getClientDispatcher().put("file:///tmp/test2.xml", domRepresentation);
                response.setEntity(resp.getEntity());
                response.setStatus(resp.getStatus());
            }
        };
        router.attach("/restletPut1", restletPut1);
        router.attach("/restletPut2", restletPut2);
        return router;
    }

}

Reply via email to