Closed mortias closed 10 years ago
in the singleResourceAdapter the delete works public OperationResult delete() { JerseyRequest request = buildRequest(sessionStorage, Object.class, new String[]{"/resources", resourceUri}); return request.delete(); }
however if i use the batchadapter
public OperationResult delete(){
return getBuilder(Object.class).delete();
}
i get the permission denied error..
Is this correct to delete multiple items? //multiple OperationResult result = client .authenticate("jasperadmin", "jasperadmin") .resourcesService() .resources() .parameter(ResourceSearchParameter.RESOURCE_URI, "/some/resource/uri/1") .parameter(ResourceSearchParameter.RESOURCE_URI, "/some/resource/uri/2") .delete();
if i dig into the code it adds parameters instead of paths, so the targetUri becomes ..... [path to server] jasperserver/rest_v2/resources?resourceUri=integration/reports/testreport instead of [path to server] jasperserver/rest_v2/resources/integration/reports/testreport
as far as i'm aware the get function on resources?resourceUri doesn't exist..
@mortias Yes, deleting multiple resources is done by supplying URI's via resourceUri parameter. Regarding the issue with the client — can't help much, let's wait for the dev
ok i see http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/deleting-resources.. maybe that isn't the issue then.. so why can i delete a resource with the resource("a").delete method but not in batch ..
@mortias One guess would be trying to delete resources (or a folder of resources) that are interdependent. e.g. trying to delete a folder with domain and report based on it could fail if JRS tries to delete the domain first.
i'm just trying to delete a folder with nothing in it which i"ve just created..
So this in batch doesn't work: OperationResult result = session.resourcesService().resources().parameter(ResourceSearchParameter.FOLDER_URI, folder.getUri()).delete();
but this is .. for the same folder OperationResult result = session.resourcesService().resource(folder.getUri()).delete();
same thing with a report, in batch i can't, so i get the forbidden error, with the normal singleresourceadapter it works..
Ok, I see the problem.
@Krasnyanskiy so you can reproduce the error? do you see a solution :) i have the impression he takes it as a server path rather then a request string.. maybe it needs urlencoding.. ? don't know..
@mortias Yes, I can reproduce it.
i don't want to be a pain, but i think you miss some tests to assert all functionalities..
No, I checked it one more time, and it's OK with web service.
ah, ok, let me first say thank you for sorting things out with me. so then there is something fishy with the client ?
----- Oorspronkelijk bericht -----
Van: "Alexander Krasnyanskiy" notifications@github.com Aan: "Jaspersoft/jrs-rest-java-client" jrs-rest-java-client@noreply.github.com Cc: "mortias" mortier@telenet.be Verzonden: Donderdag 18 september 2014 22:00:07 Onderwerp: Re: [jrs-rest-java-client] delete of folder gives me 403.. (#48)
No, I checked one more time. And it's OK with web service.
— Reply to this email directly or view it on GitHub .
Maybe, I need to check it more deeply.
are you sure it is a supported (new/old) feature of the jrs 5.0 ? because if you google on "rest_v2/resources ?resourceUri" i only find one or two references..
----- Oorspronkelijk bericht -----
Van: "Alexander Krasnyanskiy" notifications@github.com Aan: "Jaspersoft/jrs-rest-java-client" jrs-rest-java-client@noreply.github.com Cc: "mortias" mortier@telenet.be Verzonden: Donderdag 18 september 2014 22:07:59 Onderwerp: Re: [jrs-rest-java-client] delete of folder gives me 403.. (#48)
Maybe, I need to check it more deeply.
— Reply to this email directly or view it on GitHub .
@mortias I think you were right when you said "maybe it needs urlencoding". In debugging mode I see that the request goes to URL http://localhost:8080/jasperserver-pro/rest_v2/resources?resourceURI=/some/resource/uri/1&resourceURI=/some/resource/uri/2
, whereas slashes must be urlencoded for the endpoint to consume it correctly.
As a temp workaround try urlencoding them before feeding to the client (IIRC %2F is slash)
With regard to JRS version — in fact RESTv2 Repository service was introduced in 5.5, if I'm not mistaken; it's absent in 5.0 totally, so neither way to delete a resource would work for you in that case.
I checked it on 5.6.0.
well i'm at home so i wasn't sure of the versions but if you checked it that is something we can exclude :) i have the impression that it tells me i don't have the permission on that path which is correct because this path doesn't exist, however it doesn't interprete the string as a urlencoded one, i need to test this tomorrow if you are not first..
or maybe you see something in the logs of the server?
I tried to delete folders via pure Jersey
Client client = ClientBuilder
.newClient()
.register(HttpAuthenticationFeature.basic("superuser", "superuser"))
.register(JacksonFeature.class);
WebTarget target = client.target("http://54.196.19.224:8080/jasperserver-pro/");
Response resp = target
.path("/rest_v2/resources/?resourceURI=/public/Samples/NewFolder1&resourceURI=/public/Samples/NewFolder2")
.request()
.delete();
But result is the same. Even if I change slash
with %2F
in URIs.
OK, I got it.
The parameter's name is wrong. It must be resourceUri
instead of resourceURI
.
(source: internal wiki page. but must be in the public docs too)
isnt it (without the "/" slash after /resources ("/rest_v2/resources?resourceURI=/public/Samples/NewFolder1&resourceURI=/public/Samples/NewFolder2
Oh, but it works with
Response resp = target
.path("/rest_v2/resources")
.queryParam("resourceUri", "/public/Samples/NewFolder1")
.queryParam("resourceUri", "/public/Samples/NewFolder2")
.request()
.delete();
@Krasnyanskiy well I'm testing with Postman, and it worked for me even without urlencoding:
http://localhost:8080/jasperserver-pro/rest_v2/resources?resourceUri=/qa_automation/fld1&resourceUri=/qa_automation/fld2
worked, whereas resourceURI
failed with access denied
ha! so then the resourcesearchparameter enum RESOURCE_URI("resourceURI") should be resourceUri which explains why FOLDER_URI("folderUri") works in the searches ..
OperationResult result = client .authenticate("jasperadmin", "jasperadmin") .resourcesService() .resources() .parameter(ResourceSearchParameter.RESOURCE_URI, "/some/resource/uri/1") .parameter(ResourceSearchParameter.RESOURCE_URI, "/some/resource/uri/2") .delete();
i'll test it tomorrow but i'm quite sure it's this! nice teamwork guys ! (if it works :) )
Fixed (see develop
branch).
confirmed ! i've also send them a request to change their documentation https://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/deleting-resources
Hello,
Any idea how to enable the DELETE rest command on the jasperserver? when i try to delete a created folder via the api i get this response.. or i'm missing something? The user used is the admin so..
InboundJaxrsResponse{ ClientResponse{method=DELETE, uri=http://path_to_server/jasperserver/rest_v2/resources, status=403, reason=Forbidden}}