Jaspersoft / jrs-rest-java-client

Java Rest Client for JasperReports Server
GNU Lesser General Public License v3.0
100 stars 101 forks source link

Update jrxml file #268

Closed salk31 closed 7 years ago

salk31 commented 7 years ago

Hello,

I'm probably missing something obvious but I can't see how to update an already uploaded file (using uploadFile method).

I tried delete/uploadFile but some of the jrxml is locked by being used for a report.

Many thanks

Sam

gt78 commented 7 years ago

Is this a single resource or a resource part of a report unit?

salk31 commented 7 years ago

I was just trying to do single resources but if I could update any part of a report unit I could switch to that.

salk31 commented 7 years ago

FWIW I cobbled something together something using patch but it is quite verbose.

gt78 commented 7 years ago

What do you mean with patch? The point is that you should not recreate the resource, but just modify the existing resource providing the new data.

salk31 commented 7 years ago
            PatchDescriptor patchDescriptor = new PatchDescriptor();
            patchDescriptor.setVersion(version.intValue());
            patchDescriptor.field("content", encodedString);

            OperationResult<ClientFile> result = client
                    .authenticate("XXX", "XXX").resourcesService()
                    .resource(getFinalPath())
                    .patchResource(ClientFile.class, patchDescriptor);

So works but a bit of a pain as I also need to fetch the version?

gt78 commented 7 years ago

Yes, this is the correct way of doing it.

salk31 commented 7 years ago

Ah OK. Is the uploadFile just a convenience method? Cleaner to use the other repository methods?

I got confused because the API docs seem to suggest updateFile could/should exist http://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v621/working-file-resources#Updating_File_Resources

Anyway, thanks for your time.

gt78 commented 7 years ago

It is not about uploading a generic file but a specific type of resource (FileResource)

salk31 commented 7 years ago

OK. Many thanks.