class HMSManagementRestService {

    @GET
    @Path( "/hmslogs" )
    @Produces( MediaType.APPLICATION_OCTET_STREAM )
    public Response getHmsLogs()
        throws HMSRestException
    {
        // String tempDir = FileUtil.getTemporaryFolderPath();
        String tempDir = HmsConfigHolder.getHMSConfigProperty( HmsConfigHolder.HMS_TEMPORARY_LOG_DIR );
        File tempDirHandle = new File( tempDir );

        if ( !tempDirHandle.exists() && !tempDirHandle.isDirectory() )
        {
            if ( !FileUtil.createDirectory( tempDir ) )
            {
                logger.error( "Unable to create directory for creating temporary OOB logs" );
                ResponseBuilder response = Response.status( Status.INTERNAL_SERVER_ERROR );
                return response.build();
            }
        }

        String tempZipFileName = System.currentTimeMillis() + "-hmsLog.zip";

        // Create a random zip file name
        String outputZipFile = tempDir + tempZipFileName;

        String hmslogPath = HmsConfigHolder.getHMSConfigProperty( HmsConfigHolder.HMS_LOG_FILE_PATH );
        String hmslog1Path = HmsConfigHolder.getHMSConfigProperty( HmsConfigHolder.HMS_LOG_1_FILE_PATH );

        // Put some validations here such as invalid file name or missing file name
        if ( hmslogPath == null || hmslogPath.isEmpty() )
        {
            ResponseBuilder response = Response.status( Status.NOT_FOUND );
            return response.build();
        }

        logger.debug( "Hms Log file path:" + hmslogPath );
        logger.debug( "Hms Log 1 file path:" + hmslog1Path );

        boolean zipForLogCreated = ZipUtil.zipFiles( outputZipFile, hmslogPath, hmslog1Path );

        if ( zipForLogCreated )
        {
            // Prepare a file object with file to return
            File hmsLog = new File( outputZipFile );

            ResponseBuilder response = Response.ok( hmsLog );
            response.header( "Content-Disposition", "attachment; filename=\"" + "hmslog.zip" + "\"" );

            return response.build();
        }
        else
        {
            ResponseBuilder response = Response.status( Status.INTERNAL_SERVER_ERROR );
            return response.build();
        }
    }

}