@Override
    public Response download(String downloadId) throws DownloadNotFoundException {
        DownloadBean download;
        try {
            download = downloadManager.getDownload(downloadId);
            if (download == null) {
                throw new DownloadNotFoundException();
            }
        } catch (StorageException e) {
            throw new DownloadNotFoundException(e);
        }
        String path = download.getPath();
        ApiRegistryInfo info;
        switch (download.getType()) {
            case apiRegistryJson:
                info = parseApiRegistryPath(path);
                return orgs.getApiRegistryJSONInternal(info.organizationId, info.clientId, info.version);
            case apiRegistryXml:
                info = parseApiRegistryPath(path);
                return orgs.getApiRegistryXMLInternal(info.organizationId, info.clientId, info.version);
            case exportJson:
                return system.exportData();
            default:
                throw new DownloadNotFoundException();
        }
    }
@see IDownloadResource#download(java.lang.String)
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DownloadResourceImpl.java