Alexander Wels has posted comments on this change. Change subject: restApi : RestApi to export volume profile to pdf ......................................................................
Patch Set 4: (4 comments) http://gerrit.ovirt.org/#/c/28340/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterVolumeProfilePdfExportCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterVolumeProfilePdfExportCommand.java: Line 75: setSucceeded(true); Line 76: VdcReturnValueBase returnValue = new VdcReturnValueBase(); Line 77: returnValue.setDescription("Pdf Saved"); Line 78: returnValue.setSucceeded(true); Line 79: setActionReturnValue(byteStream); This should be: setActionReturnValue(byteStream.toByteArray()); Now the byte array will be the action return value. Line 80: } catch (Exception e) { Line 81: setSucceeded(false); Line 82: setActionReturnValue(e.toString()); Line 83: } http://gerrit.ovirt.org/#/c/28340/4/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java File backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/gluster/GlusterVolumeResource.java: Line 110: @Consumes({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML }) Line 111: @Produces("application/pdf") Line 112: @Actionable Line 113: @Path("exportstats") Line 114: public byte[] saveGlusterVolumeProfileAsPdf(Action action); I think this should be: @GET @Produces("application/pdf") @Path("exportstats") public Response saveGlusterVolumeProfileAsPdf(); http://gerrit.ovirt.org/#/c/28340/4/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml File backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml: Line 4384: All-Content: {value: true|false, required: false} Line 4385: - name: /clusters/{cluster:id}/glustervolumes/{glustervolume:id}/exportstats|rel=exportstats Line 4386: description: Export the profile statistics to pdf Line 4387: request: Line 4388: body: please remove extra white space. Line 4389: parameterType: Action Line 4390: signatures: [] Line 4391: urlparams: {} Line 4392: headers: http://gerrit.ovirt.org/#/c/28340/4/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java File backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java: Line 185: throw new WebFaultException(null, localize(Messages.BACKEND_FAILED), Response.Status.INTERNAL_SERVER_ERROR); Line 186: } Line 187: } Line 188: Line 189: public byte[] saveGlusterVolumeProfileAsPdf(Action action) { Try this together with my other changes: public Response saveGlusterVolumeProfileAsPdf() { boolean nfsStats = isNfsStatistics(); VdcQueryReturnValue result = runQuery(VdcQueryType.GetGlusterVolumeProfileInfo, new GlusterVolumeProfileParameters(Guid.createGuidFromString(parent.getParen t().get().getId()), guid, nfsStats)); if (result != null && result.getSucceeded() && result.getReturnValue() != null) { GlusterVolumeProfileInfo profileInfo = (GlusterVolumeProfileInfo) result.getReturnValue(); try { final byte[] data = (byte[]) (doAction(VdcActionType.GlusterVolumeProfilePdfExport, new GlusterVolumeCreatePdfParameters(profileInfo, null, "admin", ExportData.BrickProfile)).getActionReturnValue()); StreamingOutput stream = new StreamingOutput() { public void write(OutputStream output) throws IOException, WebApplicationException { output.write(data); } }; return Response.ok(stream, MediaType.APPLICATION_PDF).header("content-disposition", "attachment; filename=\"stats.pdf\"").build(); } catch (Exception e) { throw new WebFaultException(null, localize(Messages.BACKEND_FAILED), Response.Status.INTERNAL_SERVER_ERROR); } } else { // throw exception throw new WebFaultException(null, localize(Messages.BACKEND_FAILED), Response.Status.INTERNAL_SERVER_ERROR); } } Now in theory when you do a GET on /ovirt-engine/api/path_to_gluster/exportstats it should return a pdf file called stats.pdf. You can easily test this by using something like poster or some other rest tool to make the GET request. Of course I haven't tested this at all, but I believe it should work. Line 190: boolean nfsStats = isNfsStatistics(); Line 191: VdcQueryReturnValue result = Line 192: runQuery(VdcQueryType.GetGlusterVolumeProfileInfo, Line 193: new GlusterVolumeProfileParameters(Guid.createGuidFromString(parent.getParent().get().getId()), -- To view, visit http://gerrit.ovirt.org/28340 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3ff28f5cf18bd7a2bcb53a169873fe6ae3541ed Gerrit-PatchSet: 4 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: anmolbabu <anb...@redhat.com> Gerrit-Reviewer: Alexander Wels <aw...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches