/** * Creates a response that is a copy of another response * * @param response The response to copy */ public Response(Response response) { this._nIdResponse = response.getIdResponse(); this._strToStringValueResponse = response.getToStringValueResponse(); this._entry = response.getEntry(); this._field = response.getField(); this._strResponseValue = response.getResponseValue(); this._nStatus = response.getStatus(); File file = response.getFile(); if (file != null) { _file = new File(); _file.setExtension(file.getExtension()); _file.setIdFile(file.getIdFile()); _file.setMimeType(file.getMimeType()); _file.setSize(file.getSize()); _file.setTitle(file.getTitle()); PhysicalFile physicalFile = file.getPhysicalFile(); if (physicalFile != null) { PhysicalFile pfDuplicated = new PhysicalFile(); pfDuplicated.setIdPhysicalFile(pfDuplicated.getIdPhysicalFile()); pfDuplicated.setValue(pfDuplicated.getValue()); _file.setPhysicalFile(pfDuplicated); } } }
/** * Initiate a download of a XSL file * * @param request The request * @param response The response * @throws IOException Throw an exception if the outputstream has error. */ public void doDownloadXslExport(HttpServletRequest request, HttpServletResponse response) throws IOException { String strXslExportId = request.getParameter(PARAMETER_ID_XSL_EXPORT); if (strXslExportId != null) { int nXslExportId = Integer.parseInt(strXslExportId); XslExport xslExport = XslExportHome.findByPrimaryKey(nXslExportId); String strMimetype = xslExport.getFile().getMimeType(); response.setContentType((strMimetype != null) ? strMimetype : "application/octet-stream"); response.setHeader( "Content-Disposition", "attachement; filename=\"" + xslExport.getFile().getTitle() + "\""); OutputStream out = response.getOutputStream(); PhysicalFile physicalFile = PhysicalFileHome.findByPrimaryKey( xslExport.getFile().getPhysicalFile().getIdPhysicalFile()); out.write(physicalFile.getValue()); out.flush(); out.close(); } }