diff --git a/server/src/main/java/org/eclipse/openvsx/ExtensionProcessor.java b/server/src/main/java/org/eclipse/openvsx/ExtensionProcessor.java index 912affd60..e3dcbfe8d 100644 --- a/server/src/main/java/org/eclipse/openvsx/ExtensionProcessor.java +++ b/server/src/main/java/org/eclipse/openvsx/ExtensionProcessor.java @@ -9,6 +9,7 @@ ********************************************************************************/ package org.eclipse.openvsx; +import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.IOException; import java.nio.file.Path; @@ -26,6 +27,7 @@ import com.fasterxml.jackson.databind.node.MissingNode; import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import org.apache.commons.io.FilenameUtils; import org.eclipse.openvsx.entities.ExtensionVersion; import org.eclipse.openvsx.entities.FileResource; import org.eclipse.openvsx.util.ArchiveUtil; @@ -36,6 +38,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.util.Pair; +import org.springframework.http.MediaType; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; /** * Processes uploaded extension files and extracts their metadata. @@ -282,17 +289,22 @@ private List getEngines(JsonNode node) { } public List getFileResources(ExtensionVersion extVersion) { - var resources = new ArrayList(); + readInputStream(); + var contentTypes = loadContentTypes(); var mappers = List.>of( this::getManifest, this::getReadme, this::getChangelog, this::getLicense, this::getIcon ); - mappers.forEach(mapper -> Optional.of(extVersion).map(mapper).ifPresent(resources::add)); - return resources; + return mappers.stream() + .map(mapper -> mapper.apply(extVersion)) + .filter(Objects::nonNull) + .map(resource -> setContentType(resource, contentTypes)) + .collect(Collectors.toList()); } public void processEachResource(ExtensionVersion extVersion, Consumer processor) { readInputStream(); + var contentTypes = loadContentTypes(); zipFile.stream() .filter(zipEntry -> !zipEntry.isDirectory()) .map(zipEntry -> { @@ -311,6 +323,7 @@ public void processEachResource(ExtensionVersion extVersion, Consumer loadContentTypes() { + var bytes = ArchiveUtil.readEntry(zipFile, "[Content_Types].xml"); + var contentTypes = parseContentTypesXml(bytes); + contentTypes.putIfAbsent(".vsix", "application/zip"); + return contentTypes; + } + + private Map parseContentTypesXml(byte[] content) { + var contentTypes = new HashMap(); + try (var input = new ByteArrayInputStream(content)) { + var document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input); + var elements = document.getDocumentElement().getElementsByTagName("Default"); + for(var i = 0; i < elements.getLength(); i++) { + var element = elements.item(i); + var attributes = element.getAttributes(); + var extension = attributes.getNamedItem("Extension").getTextContent(); + if(!extension.startsWith(".")) { + extension = "." + extension; + } + + var contentType = attributes.getNamedItem("ContentType").getTextContent(); + contentTypes.put(extension, contentType); + } + } catch (IOException | ParserConfigurationException | SAXException e) { + logger.error("failed to read content types", e); + contentTypes.clear(); + } + + return contentTypes; + } + + private FileResource setContentType(FileResource resource, Map contentTypes) { + var fileExtension = FilenameUtils.getExtension(resource.getName()); + var contentType = contentTypes.getOrDefault(fileExtension, MediaType.APPLICATION_OCTET_STREAM_VALUE); + resource.setContentType(contentType); + return resource; + } + private void detectLicense(byte[] content, ExtensionVersion extVersion) { if (Strings.isNullOrEmpty(extVersion.getLicense())) { var detection = new LicenseDetection(); @@ -425,9 +474,7 @@ private Pair readFromAlternateNames(String[] names) { var entry = ArchiveUtil.getEntryIgnoreCase(zipFile, name); if (entry != null) { var bytes = ArchiveUtil.readEntry(zipFile, entry); - var lastSegmentIndex = entry.getName().lastIndexOf('/'); - var lastSegment = entry.getName().substring(lastSegmentIndex + 1); - return Pair.of(bytes, lastSegment); + return Pair.of(bytes, FilenameUtils.getName(entry.getName())); } } return null; @@ -442,13 +489,10 @@ protected FileResource getIcon(ExtensionVersion extVersion) { var bytes = ArchiveUtil.readEntry(zipFile, "extension/" + iconPathStr); if (bytes == null) return null; + var icon = new FileResource(); icon.setExtension(extVersion); - var fileNameIndex = iconPathStr.lastIndexOf('/'); - if (fileNameIndex >= 0) - icon.setName(iconPathStr.substring(fileNameIndex + 1)); - else - icon.setName(iconPathStr); + icon.setName(FilenameUtils.getName(iconPathStr)); icon.setType(FileResource.ICON); icon.setContent(bytes); return icon; diff --git a/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java b/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java index c68ccdb96..a0ff54479 100644 --- a/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java +++ b/server/src/main/java/org/eclipse/openvsx/adapter/LocalVSCodeService.java @@ -31,8 +31,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import javax.transaction.Transactional; - import static org.eclipse.openvsx.adapter.ExtensionQueryParam.Criterion.*; import static org.eclipse.openvsx.adapter.ExtensionQueryParam.*; import static org.eclipse.openvsx.adapter.ExtensionQueryResult.Extension.FLAG_PREVIEW; @@ -404,7 +402,7 @@ private ResponseEntity browseFile( String version ) { if (resource.getStorageType().equals(FileResource.STORAGE_DB)) { - var headers = storageUtil.getFileResponseHeaders(resource.getName()); + var headers = storageUtil.getFileResponseHeaders(resource); return new ResponseEntity<>(resource.getContent(), headers, HttpStatus.OK); } else { var namespace = new Namespace(); diff --git a/server/src/main/java/org/eclipse/openvsx/entities/FileResource.java b/server/src/main/java/org/eclipse/openvsx/entities/FileResource.java index 4b87db181..2c077f5aa 100644 --- a/server/src/main/java/org/eclipse/openvsx/entities/FileResource.java +++ b/server/src/main/java/org/eclipse/openvsx/entities/FileResource.java @@ -9,8 +9,6 @@ ********************************************************************************/ package org.eclipse.openvsx.entities; -import org.hibernate.annotations.Fetch; - import javax.persistence.*; @Entity @@ -45,6 +43,8 @@ public class FileResource { @Basic(fetch = FetchType.LAZY) byte[] content; + String contentType; + @Column(length = 32) String storageType; @@ -88,6 +88,14 @@ public void setContent(byte[] content) { this.content = content; } + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + public String getStorageType() { return storageType; } diff --git a/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobRequestHandler.java b/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobRequestHandler.java index da3d0619f..209f08896 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobRequestHandler.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobRequestHandler.java @@ -10,8 +10,8 @@ package org.eclipse.openvsx.migration; import org.eclipse.openvsx.ExtensionProcessor; +import org.eclipse.openvsx.entities.ExtensionVersion; import org.jobrunr.jobs.annotations.Job; -import org.jobrunr.jobs.context.JobRunrDashboardLogger; import org.jobrunr.jobs.lambdas.JobRequestHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,7 +21,7 @@ @Component public class ExtractResourcesJobRequestHandler implements JobRequestHandler { - protected final Logger logger = new JobRunrDashboardLogger(LoggerFactory.getLogger(ExtractResourcesJobRequestHandler.class)); + protected final Logger logger = LoggerFactory.getLogger(ExtractResourcesJobRequestHandler.class); @Autowired ExtractResourcesJobService service; @@ -32,12 +32,12 @@ public class ExtractResourcesJobRequestHandler implements JobRequestHandler { @@ -48,5 +48,6 @@ public void run(MigrationJobRequest jobRequest) throws Exception { } service.deleteWebResources(extVersion); + migrations.deleteFile(extensionFile); } } diff --git a/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobService.java b/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobService.java index 1473c03e7..1a234a6ee 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobService.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/ExtractResourcesJobService.java @@ -12,22 +12,11 @@ import org.eclipse.openvsx.entities.ExtensionVersion; import org.eclipse.openvsx.entities.FileResource; import org.eclipse.openvsx.repositories.RepositoryService; -import org.eclipse.openvsx.storage.AzureBlobStorageService; -import org.eclipse.openvsx.storage.GoogleCloudStorageService; -import org.eclipse.openvsx.storage.IStorageService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpMethod; -import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; import javax.persistence.EntityManager; import javax.transaction.Transactional; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.AbstractMap; -import java.util.Map; @Component public class ExtractResourcesJobService { @@ -35,22 +24,9 @@ public class ExtractResourcesJobService { @Autowired RepositoryService repositories; - @Autowired - RestTemplate restTemplate; - @Autowired EntityManager entityManager; - @Autowired - AzureBlobStorageService azureStorage; - - @Autowired - GoogleCloudStorageService googleStorage; - - public ExtensionVersion getExtension(long entityId) { - return entityManager.find(ExtensionVersion.class, entityId); - } - @Transactional public void deleteResources(ExtensionVersion extVersion) { repositories.deleteFileResources(extVersion, "resource"); @@ -61,13 +37,6 @@ public void deleteWebResources(ExtensionVersion extVersion) { repositories.deleteFileResources(extVersion, "web-resource"); } - @Transactional - public Map.Entry getDownload(ExtensionVersion extVersion) { - var download = repositories.findFileByType(extVersion, FileResource.DOWNLOAD); - var content = download.getStorageType().equals(FileResource.STORAGE_DB) ? download.getContent() : null; - return new AbstractMap.SimpleEntry<>(download, content); - } - @Transactional public void persistResource(FileResource resource) { entityManager.persist(resource); diff --git a/server/src/main/java/org/eclipse/openvsx/migration/MigrationRunner.java b/server/src/main/java/org/eclipse/openvsx/migration/MigrationRunner.java index 3b3128294..0d45d3bf4 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/MigrationRunner.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/MigrationRunner.java @@ -41,6 +41,7 @@ public void runMigrations(ApplicationStartedEvent event) { extractResourcesMigration(); setPreReleaseMigration(); renameDownloadsMigration(); + setContentTypeMigration(); } private void extractResourcesMigration() { @@ -61,6 +62,12 @@ private void renameDownloadsMigration() { repositories.findNotMigratedRenamedDownloads().forEach(item -> enqueueJob(jobName, handler, item)); } + private void setContentTypeMigration() { + var jobName = "SetContentTypeMigration"; + var handler = SetContentTypeJobRequestHandler.class; + repositories.findNotMigratedContentTypes().forEach(item -> enqueueJob(jobName, handler, item)); + } + private void enqueueJob(String jobName, Class> handler, MigrationItem item) { var jobIdText = jobName + "::itemId=" + item.getId(); var jobId = UUID.nameUUIDFromBytes(jobIdText.getBytes(StandardCharsets.UTF_8)); diff --git a/server/src/main/java/org/eclipse/openvsx/migration/MigrationService.java b/server/src/main/java/org/eclipse/openvsx/migration/MigrationService.java index b71e75ebb..4f32bf383 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/MigrationService.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/MigrationService.java @@ -9,7 +9,10 @@ * ****************************************************************************** */ package org.eclipse.openvsx.migration; +import org.apache.commons.io.FilenameUtils; +import org.eclipse.openvsx.entities.ExtensionVersion; import org.eclipse.openvsx.entities.FileResource; +import org.eclipse.openvsx.repositories.RepositoryService; import org.eclipse.openvsx.storage.AzureBlobStorageService; import org.eclipse.openvsx.storage.GoogleCloudStorageService; import org.eclipse.openvsx.storage.IStorageService; @@ -19,14 +22,23 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import javax.persistence.EntityManager; +import javax.transaction.Transactional; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.AbstractMap; import java.util.Map; @Component public class MigrationService { + @Autowired + EntityManager entityManager; + + @Autowired + RepositoryService repositories; + @Autowired RestTemplate restTemplate; @@ -36,20 +48,38 @@ public class MigrationService { @Autowired GoogleCloudStorageService googleStorage; + public T find(MigrationJobRequest jobRequest, Class clazz) { + return entityManager.find(clazz, jobRequest.getEntityId()); + } + + @Transactional + public Map.Entry getDownload(ExtensionVersion extVersion) { + var download = repositories.findFileByType(extVersion, FileResource.DOWNLOAD); + var content = download.getStorageType().equals(FileResource.STORAGE_DB) ? download.getContent() : null; + return new AbstractMap.SimpleEntry<>(download, content); + } + + @Transactional + public byte[] getContent(FileResource download) { + download = entityManager.merge(download); + return download.getStorageType().equals(FileResource.STORAGE_DB) ? download.getContent() : null; + } + @Retryable - public Path getExtensionFile(Map.Entry entry) { + public Path getFile(Map.Entry entry) { Path extensionFile; + var resource = entry.getKey(); try { - extensionFile = Files.createTempFile("extension_", ".vsix"); + var suffix = FilenameUtils.getExtension(resource.getName()); + extensionFile = Files.createTempFile("file_", suffix); } catch (IOException e) { - throw new RuntimeException("Failed to create extension file", e); + throw new RuntimeException("Failed to create file", e); } var content = entry.getValue(); if(content == null) { - var download = entry.getKey(); - var storage = getStorage(download); - var uri = storage.getLocation(download); + var storage = getStorage(resource); + var uri = storage.getLocation(resource); restTemplate.execute(uri, HttpMethod.GET, null, response -> { try(var out = Files.newOutputStream(extensionFile)) { response.getBody().transferTo(out); @@ -61,19 +91,29 @@ public Path getExtensionFile(Map.Entry entry) { try { Files.write(extensionFile, content); } catch (IOException e) { - throw new RuntimeException("Failed to write to extension file", e); + throw new RuntimeException("Failed to write to file", e); } } return extensionFile; } + public void deleteFile(Path filePath) { + try { + Files.delete(filePath); + } catch (IOException e) { + throw new RuntimeException("Failed to delete file"); + } + } + @Retryable + @Transactional public void uploadResource(FileResource resource) { if(resource.getStorageType().equals(FileResource.STORAGE_DB)) { return; } + resource = entityManager.merge(resource); var storage = getStorage(resource); storage.uploadFile(resource); resource.setContent(null); diff --git a/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsJobRequestHandler.java b/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsJobRequestHandler.java index 08a48d142..dd9bcf678 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsJobRequestHandler.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsJobRequestHandler.java @@ -9,6 +9,7 @@ * ****************************************************************************** */ package org.eclipse.openvsx.migration; +import org.eclipse.openvsx.entities.FileResource; import org.jobrunr.jobs.lambdas.JobRequestHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +21,7 @@ @Component public class RenameDownloadsJobRequestHandler implements JobRequestHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(RenameDownloadsJobRequestHandler.class); + protected final Logger logger = LoggerFactory.getLogger(RenameDownloadsJobRequestHandler.class); @Autowired MigrationService migrations; @@ -30,22 +31,23 @@ public class RenameDownloadsJobRequestHandler implements JobRequestHandler(download, content)); + logger.info("Renaming download {}", download.getName()); + var content = migrations.getContent(download); + var extensionFile = migrations.getFile(new AbstractMap.SimpleEntry<>(download, content)); var newDownload = service.cloneResource(download, name); migrations.uploadResource(newDownload, extensionFile); migrations.deleteResource(download); download.setName(name); service.updateResource(download); - LOGGER.info("Updated download name to: {}", name); + migrations.deleteFile(extensionFile); + logger.info("Updated download name to: {}", name); } } diff --git a/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsService.java b/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsService.java index 4ea580051..e9d2fc7ea 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsService.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/RenameDownloadsService.java @@ -36,12 +36,6 @@ public String getNewBinaryName(FileResource resource) { return resourceName; } - @Transactional - public byte[] getContent(FileResource download) { - download = entityManager.merge(download); - return download.getStorageType().equals(FileResource.STORAGE_DB) ? download.getContent() : null; - } - @Transactional public FileResource cloneResource(FileResource resource, String name) { resource = entityManager.merge(resource); @@ -54,10 +48,6 @@ public FileResource cloneResource(FileResource resource, String name) { return clone; } - public FileResource getResource(MigrationJobRequest jobRequest) { - return entityManager.find(FileResource.class, jobRequest.getEntityId()); - } - @Transactional public void updateResource(FileResource resource) { entityManager.merge(resource); diff --git a/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobRequestHandler.java b/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobRequestHandler.java new file mode 100644 index 000000000..abfab7a65 --- /dev/null +++ b/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobRequestHandler.java @@ -0,0 +1,63 @@ +/** ****************************************************************************** + * Copyright (c) 2022 Precies. Software Ltd and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * ****************************************************************************** */ +package org.eclipse.openvsx.migration; + +import org.eclipse.openvsx.ExtensionProcessor; +import org.eclipse.openvsx.entities.ExtensionVersion; +import org.eclipse.openvsx.entities.FileResource; +import org.jobrunr.jobs.annotations.Job; +import org.jobrunr.jobs.lambdas.JobRequestHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.AbstractMap; +import java.util.function.Consumer; + +@Component +public class SetContentTypeJobRequestHandler implements JobRequestHandler { + + protected final Logger logger = LoggerFactory.getLogger(SetContentTypeJobRequestHandler.class); + + @Autowired + MigrationService migrations; + + @Autowired + SetContentTypeJobService service; + + @Override + @Job(name = "Set content type for published file resources", retries = 3) + public void run(MigrationJobRequest jobRequest) throws Exception { + var extVersion = migrations.find(jobRequest, ExtensionVersion.class); + logger.info("Set content type for: {}.{}-{}@{}", extVersion.getExtension().getNamespace().getName(), extVersion.getExtension().getName(), extVersion.getVersion(), extVersion.getTargetPlatform()); + + var entry = migrations.getDownload(extVersion); + var extensionFile = migrations.getFile(entry); + try (var processor = new ExtensionProcessor(extensionFile)) { + Consumer consumer = resource -> { + var existingResource = service.getExistingResource(extVersion, resource); + if(existingResource == null) { + return; + } + + var resourceFile = migrations.getFile(new AbstractMap.SimpleEntry<>(existingResource, resource.getContent())); + migrations.deleteResource(existingResource); + migrations.uploadResource(existingResource, resourceFile); + migrations.deleteFile(resourceFile); + }; + + processor.getFileResources(extVersion).forEach(consumer); + processor.processEachResource(extVersion, consumer); + } + + migrations.deleteFile(extensionFile); + } +} diff --git a/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobService.java b/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobService.java new file mode 100644 index 000000000..f063d2a4b --- /dev/null +++ b/server/src/main/java/org/eclipse/openvsx/migration/SetContentTypeJobService.java @@ -0,0 +1,35 @@ +/** ****************************************************************************** + * Copyright (c) 2022 Precies. Software Ltd and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * ****************************************************************************** */ +package org.eclipse.openvsx.migration; + +import org.eclipse.openvsx.entities.ExtensionVersion; +import org.eclipse.openvsx.entities.FileResource; +import org.eclipse.openvsx.repositories.RepositoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; + +@Component +public class SetContentTypeJobService { + + @Autowired + RepositoryService repositories; + + @Transactional + public FileResource getExistingResource(ExtensionVersion extVersion, FileResource resource) { + var existingResource = repositories.findFileByTypeAndName(extVersion, resource.getType(), resource.getName()); + if(existingResource != null) { + existingResource.setContentType(resource.getContentType()); + } + + return existingResource; + } +} diff --git a/server/src/main/java/org/eclipse/openvsx/migration/SetPreReleaseJobRequestHandler.java b/server/src/main/java/org/eclipse/openvsx/migration/SetPreReleaseJobRequestHandler.java index ac1227808..95ae47317 100644 --- a/server/src/main/java/org/eclipse/openvsx/migration/SetPreReleaseJobRequestHandler.java +++ b/server/src/main/java/org/eclipse/openvsx/migration/SetPreReleaseJobRequestHandler.java @@ -10,7 +10,6 @@ package org.eclipse.openvsx.migration; import org.jobrunr.jobs.annotations.Job; -import org.jobrunr.jobs.context.JobRunrDashboardLogger; import org.jobrunr.jobs.lambdas.JobRequestHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +19,10 @@ @Component public class SetPreReleaseJobRequestHandler implements JobRequestHandler { - protected final Logger logger = new JobRunrDashboardLogger(LoggerFactory.getLogger(ExtractResourcesJobRequestHandler.class)); + protected final Logger logger = LoggerFactory.getLogger(SetPreReleaseJobRequestHandler.class); + + @Autowired + MigrationService migrations; @Autowired SetPreReleaseJobService service; @@ -30,9 +32,10 @@ public class SetPreReleaseJobRequestHandler implements JobRequestHandler getExtensionVersions(MigrationJobRequest jobRequest, Logger logger) { var extension = entityManager.find(Extension.class, jobRequest.getEntityId()); @@ -58,45 +34,6 @@ public List getExtensionVersions(MigrationJobRequest jobReques return extension.getVersions(); } - @Transactional - public Map.Entry getDownload(ExtensionVersion extVersion) { - var download = repositories.findFileByType(extVersion, FileResource.DOWNLOAD); - var content = download.getStorageType().equals(FileResource.STORAGE_DB) ? download.getContent() : null; - return new AbstractMap.SimpleEntry<>(download, content); - } - - @Retryable - public Path getExtensionFile(Map.Entry entry) { - Path extensionFile; - try { - extensionFile = Files.createTempFile("extension_", ".vsix"); - } catch (IOException e) { - throw new RuntimeException("Failed to create extension file", e); - } - - var content = entry.getValue(); - if(content == null) { - var download = entry.getKey(); - var storage = getStorage(download); - var uri = storage.getLocation(download); - restTemplate.execute(uri, HttpMethod.GET, null, response -> { - try(var out = Files.newOutputStream(extensionFile)) { - response.getBody().transferTo(out); - } - - return extensionFile; - }); - } else { - try { - Files.write(extensionFile, content); - } catch (IOException e) { - throw new RuntimeException("Failed to write to extension file", e); - } - } - - return extensionFile; - } - @Transactional public void updatePreviewAndPreRelease(ExtensionVersion extVersion, Path extensionFile) { try(var extProcessor = new ExtensionProcessor(extensionFile)) { @@ -106,13 +43,4 @@ public void updatePreviewAndPreRelease(ExtensionVersion extVersion, Path extensi entityManager.merge(extVersion); } - - private IStorageService getStorage(FileResource resource) { - var storages = Map.of( - FileResource.STORAGE_AZURE, azureStorage, - FileResource.STORAGE_GOOGLE, googleStorage - ); - - return storages.get(resource.getStorageType()); - } } diff --git a/server/src/main/java/org/eclipse/openvsx/repositories/FileResourceJooqRepository.java b/server/src/main/java/org/eclipse/openvsx/repositories/FileResourceJooqRepository.java index 7f7cd7dc6..dcfc42946 100644 --- a/server/src/main/java/org/eclipse/openvsx/repositories/FileResourceJooqRepository.java +++ b/server/src/main/java/org/eclipse/openvsx/repositories/FileResourceJooqRepository.java @@ -28,7 +28,12 @@ public class FileResourceJooqRepository { DSLContext dsl; public List findAll(Collection extensionIds, Collection types) { - return dsl.select(FILE_RESOURCE.ID, FILE_RESOURCE.EXTENSION_ID, FILE_RESOURCE.NAME, FILE_RESOURCE.TYPE) + return dsl.select( + FILE_RESOURCE.ID, + FILE_RESOURCE.EXTENSION_ID, + FILE_RESOURCE.NAME, + FILE_RESOURCE.TYPE + ) .from(FILE_RESOURCE) .where(FILE_RESOURCE.EXTENSION_ID.in(extensionIds)) .and(FILE_RESOURCE.TYPE.in(types)) @@ -37,7 +42,15 @@ public List findAll(Collection extensionIds, Collection findAllResources(long extVersionId, String prefix) { - return dsl.select(FILE_RESOURCE.ID, FILE_RESOURCE.EXTENSION_ID, FILE_RESOURCE.NAME, FILE_RESOURCE.TYPE, FILE_RESOURCE.STORAGE_TYPE, FILE_RESOURCE.CONTENT) + return dsl.select( + FILE_RESOURCE.ID, + FILE_RESOURCE.EXTENSION_ID, + FILE_RESOURCE.NAME, + FILE_RESOURCE.TYPE, + FILE_RESOURCE.STORAGE_TYPE, + FILE_RESOURCE.CONTENT, + FILE_RESOURCE.CONTENT_TYPE + ) .from(FILE_RESOURCE) .where(FILE_RESOURCE.TYPE.eq(FileResource.RESOURCE)) .and(FILE_RESOURCE.EXTENSION_ID.eq(extVersionId)) diff --git a/server/src/main/java/org/eclipse/openvsx/repositories/RepositoryService.java b/server/src/main/java/org/eclipse/openvsx/repositories/RepositoryService.java index ddcc08b76..079a160ed 100644 --- a/server/src/main/java/org/eclipse/openvsx/repositories/RepositoryService.java +++ b/server/src/main/java/org/eclipse/openvsx/repositories/RepositoryService.java @@ -402,6 +402,10 @@ public Streamable findNotMigratedRenamedDownloads() { return findNotMigratedItems("V1_28__MigrationItem.sql"); } + public Streamable findNotMigratedContentTypes() { + return findNotMigratedItems("V1_29__FileResource_ContentType.sql"); + } + private Streamable findNotMigratedItems(String migrationScript) { return migrationItemRepo.findByMigrationScriptAndMigrationScheduledFalseOrderById(migrationScript); } diff --git a/server/src/main/java/org/eclipse/openvsx/storage/AzureBlobStorageService.java b/server/src/main/java/org/eclipse/openvsx/storage/AzureBlobStorageService.java index e69270923..b70a3b1ec 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/AzureBlobStorageService.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/AzureBlobStorageService.java @@ -65,19 +65,21 @@ public void uploadFile(FileResource resource) { + blobName + ": missing Azure blob service endpoint"); } - uploadFile(resource.getContent(), resource.getName(), blobName); + uploadFile(resource, blobName); } - protected void uploadFile(byte[] content, String fileName, String blobName) { + protected void uploadFile(FileResource resource, String blobName) { var blobClient = getContainerClient().getBlobClient(blobName); var headers = new BlobHttpHeaders(); - headers.setContentType(StorageUtil.getFileType(fileName).toString()); - if (fileName.endsWith(".vsix")) { - headers.setContentDisposition("attachment; filename=\"" + fileName + "\""); + headers.setContentType(resource.getContentType()); + if (resource.getName().endsWith(".vsix")) { + headers.setContentDisposition("attachment; filename=\"" + resource.getName() + "\""); } else { - var cacheControl = StorageUtil.getCacheControl(fileName); + var cacheControl = StorageUtil.getCacheControl(resource.getName()); headers.setCacheControl(cacheControl.getHeaderValue()); } + + var content = resource.getContent(); try (var dataStream = new ByteArrayInputStream(content)) { blobClient.upload(dataStream, content.length, true); blobClient.setHttpHeaders(headers); @@ -94,13 +96,13 @@ public void uploadFile(FileResource resource, Path filePath) { + blobName + ": missing Azure blob service endpoint"); } - uploadFile(filePath, resource.getName(), blobName); + uploadFile(filePath, resource.getName(), blobName, resource.getContentType()); } - protected void uploadFile(Path filePath, String fileName, String blobName) { + protected void uploadFile(Path filePath, String fileName, String blobName, String contentType) { var blobClient = getContainerClient().getBlobClient(blobName); var headers = new BlobHttpHeaders(); - headers.setContentType(StorageUtil.getFileType(fileName).toString()); + headers.setContentType(contentType); if (fileName.endsWith(".vsix")) { headers.setContentDisposition("attachment; filename=\"" + fileName + "\""); } else { diff --git a/server/src/main/java/org/eclipse/openvsx/storage/GoogleCloudStorageService.java b/server/src/main/java/org/eclipse/openvsx/storage/GoogleCloudStorageService.java index 48fe33bcd..55bc772ab 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/GoogleCloudStorageService.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/GoogleCloudStorageService.java @@ -68,19 +68,19 @@ public void uploadFile(FileResource resource) { + objectId + ": missing Google bucket id"); } - uploadFile(resource.getContent(), resource.getName(), objectId); + uploadFile(resource, objectId); } - protected void uploadFile(byte[] content, String fileName, String objectId) { + protected void uploadFile(FileResource resource, String objectId) { var blobInfoBuilder = BlobInfo.newBuilder(BlobId.of(bucketId, objectId)) - .setContentType(StorageUtil.getFileType(fileName).toString()); - if (fileName.endsWith(".vsix")) { - blobInfoBuilder.setContentDisposition("attachment; filename=\"" + fileName + "\""); + .setContentType(resource.getContentType()); + if (resource.getName().endsWith(".vsix")) { + blobInfoBuilder.setContentDisposition("attachment; filename=\"" + resource.getName() + "\""); } else { - var cacheControl = StorageUtil.getCacheControl(fileName); + var cacheControl = StorageUtil.getCacheControl(resource.getName()); blobInfoBuilder.setCacheControl(cacheControl.getHeaderValue()); } - getStorage().create(blobInfoBuilder.build(), content); + getStorage().create(blobInfoBuilder.build(), resource.getContent()); } @Override @@ -91,12 +91,12 @@ public void uploadFile(FileResource resource, Path filePath) { + objectId + ": missing Google bucket id"); } - uploadFile(filePath, resource.getName(), objectId); + uploadFile(filePath, resource.getName(), objectId, resource.getContentType()); } - protected void uploadFile(Path filePath, String fileName, String objectId) { + protected void uploadFile(Path filePath, String fileName, String objectId, String contentType) { var blobInfoBuilder = BlobInfo.newBuilder(BlobId.of(bucketId, objectId)) - .setContentType(StorageUtil.getFileType(fileName).toString()); + .setContentType(contentType); if (fileName.endsWith(".vsix")) { blobInfoBuilder.setContentDisposition("attachment; filename=\"" + fileName + "\""); } else { diff --git a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtil.java b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtil.java index 63e897fc4..a5b83c804 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtil.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtil.java @@ -11,26 +11,13 @@ package org.eclipse.openvsx.storage; import org.springframework.http.CacheControl; -import org.springframework.http.MediaType; -import java.net.URLConnection; import java.util.concurrent.TimeUnit; class StorageUtil { private StorageUtil(){} - static MediaType getFileType(String fileName) { - if (fileName.endsWith(".vsix")) - return MediaType.APPLICATION_OCTET_STREAM; - if (fileName.endsWith(".json")) - return MediaType.APPLICATION_JSON; - var contentType = URLConnection.guessContentTypeFromName(fileName); - if (contentType != null) - return MediaType.parseMediaType(contentType); - return MediaType.TEXT_PLAIN; - } - static CacheControl getCacheControl(String fileName) { // Files are requested with a version string in the URL, so their content cannot change return CacheControl.maxAge(30, TimeUnit.DAYS).cachePublic(); diff --git a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java index bb5f5fbd8..d1f075255 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java @@ -10,6 +10,7 @@ package org.eclipse.openvsx.storage; import com.google.common.base.Strings; + import com.google.common.collect.Maps; import org.eclipse.openvsx.cache.CacheService; import org.eclipse.openvsx.entities.Download; @@ -24,6 +25,7 @@ import org.springframework.http.CacheControl; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -215,9 +217,13 @@ public void increaseDownloadCount(FileResource resource) { } } - public HttpHeaders getFileResponseHeaders(String fileName) { + public HttpHeaders getFileResponseHeaders(FileResource resource) { + return getFileResponseHeaders(resource.getName(), resource.getContentType()); + } + + private HttpHeaders getFileResponseHeaders(String fileName, String contentType) { var headers = new HttpHeaders(); - headers.setContentType(StorageUtil.getFileType(fileName)); + headers.setContentType(MediaType.parseMediaType(contentType)); if (fileName.endsWith(".vsix")) { headers.add("Content-Disposition", "attachment; filename=\"" + fileName + "\""); } else { @@ -230,7 +236,7 @@ public HttpHeaders getFileResponseHeaders(String fileName) { public ResponseEntity getFileResponse(FileResource resource) { resource = entityManager.merge(resource); if (resource.getStorageType().equals(FileResource.STORAGE_DB)) { - var headers = getFileResponseHeaders(resource.getName()); + var headers = getFileResponseHeaders(resource); return new ResponseEntity<>(resource.getContent(), headers, HttpStatus.OK); } else { return ResponseEntity.status(HttpStatus.FOUND) diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Indexes.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Indexes.java index a0f80e314..ab4d6926c 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Indexes.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Indexes.java @@ -4,11 +4,14 @@ package org.eclipse.openvsx.jooq; +import org.eclipse.openvsx.jooq.tables.Download; import org.eclipse.openvsx.jooq.tables.Extension; import org.eclipse.openvsx.jooq.tables.ExtensionReview; import org.eclipse.openvsx.jooq.tables.ExtensionVersion; import org.eclipse.openvsx.jooq.tables.FileResource; import org.eclipse.openvsx.jooq.tables.FlywaySchemaHistory; +import org.eclipse.openvsx.jooq.tables.JobrunrBackgroundjobservers; +import org.eclipse.openvsx.jooq.tables.JobrunrJobs; import org.eclipse.openvsx.jooq.tables.NamespaceMembership; import org.eclipse.openvsx.jooq.tables.PersistedLog; import org.eclipse.openvsx.jooq.tables.SpringSession; @@ -28,13 +31,23 @@ public class Indexes { // INDEX definitions // ------------------------------------------------------------------------- + public static final Index DOWNLOAD_TIMESTAMP_BRIN_IDX = Internal.createIndex(DSL.name("download_timestamp_brin_idx"), Download.DOWNLOAD, new OrderField[] { Download.DOWNLOAD.TIMESTAMP }, false); public static final Index EXTENSION__NAMESPACE_ID__IDX = Internal.createIndex(DSL.name("extension__namespace_id__idx"), Extension.EXTENSION, new OrderField[] { Extension.EXTENSION.NAMESPACE_ID }, false); public static final Index EXTENSION_REVIEW__EXTENSION_ID__IDX = Internal.createIndex(DSL.name("extension_review__extension_id__idx"), ExtensionReview.EXTENSION_REVIEW, new OrderField[] { ExtensionReview.EXTENSION_REVIEW.EXTENSION_ID }, false); public static final Index EXTENSION_REVIEW__USER_ID__IDX = Internal.createIndex(DSL.name("extension_review__user_id__idx"), ExtensionReview.EXTENSION_REVIEW, new OrderField[] { ExtensionReview.EXTENSION_REVIEW.USER_ID }, false); public static final Index EXTENSION_VERSION__EXTENSION_ID__IDX = Internal.createIndex(DSL.name("extension_version__extension_id__idx"), ExtensionVersion.EXTENSION_VERSION, new OrderField[] { ExtensionVersion.EXTENSION_VERSION.EXTENSION_ID }, false); public static final Index EXTENSION_VERSION__PUBLISHED_WITH_ID__IDX = Internal.createIndex(DSL.name("extension_version__published_with_id__idx"), ExtensionVersion.EXTENSION_VERSION, new OrderField[] { ExtensionVersion.EXTENSION_VERSION.PUBLISHED_WITH_ID }, false); public static final Index FILE_RESOURCE_EXTENSION_IDX = Internal.createIndex(DSL.name("file_resource_extension_idx"), FileResource.FILE_RESOURCE, new OrderField[] { FileResource.FILE_RESOURCE.EXTENSION_ID }, false); + public static final Index FILE_RESOURCE_TYPE_IDX = Internal.createIndex(DSL.name("file_resource_type_idx"), FileResource.FILE_RESOURCE, new OrderField[] { FileResource.FILE_RESOURCE.TYPE }, false); public static final Index FLYWAY_SCHEMA_HISTORY_S_IDX = Internal.createIndex(DSL.name("flyway_schema_history_s_idx"), FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY, new OrderField[] { FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY.SUCCESS }, false); + public static final Index JOBRUNR_BGJOBSRVRS_FSTHB_IDX = Internal.createIndex(DSL.name("jobrunr_bgjobsrvrs_fsthb_idx"), JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS, new OrderField[] { JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS.FIRSTHEARTBEAT }, false); + public static final Index JOBRUNR_BGJOBSRVRS_LSTHB_IDX = Internal.createIndex(DSL.name("jobrunr_bgjobsrvrs_lsthb_idx"), JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS, new OrderField[] { JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS.LASTHEARTBEAT }, false); + public static final Index JOBRUNR_JOB_CREATED_AT_IDX = Internal.createIndex(DSL.name("jobrunr_job_created_at_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.CREATEDAT }, false); + public static final Index JOBRUNR_JOB_RCI_IDX = Internal.createIndex(DSL.name("jobrunr_job_rci_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.RECURRINGJOBID }, false); + public static final Index JOBRUNR_JOB_SCHEDULED_AT_IDX = Internal.createIndex(DSL.name("jobrunr_job_scheduled_at_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.SCHEDULEDAT }, false); + public static final Index JOBRUNR_JOB_SIGNATURE_IDX = Internal.createIndex(DSL.name("jobrunr_job_signature_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.JOBSIGNATURE }, false); + public static final Index JOBRUNR_JOB_UPDATED_AT_IDX = Internal.createIndex(DSL.name("jobrunr_job_updated_at_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.UPDATEDAT }, false); + public static final Index JOBRUNR_STATE_IDX = Internal.createIndex(DSL.name("jobrunr_state_idx"), JobrunrJobs.JOBRUNR_JOBS, new OrderField[] { JobrunrJobs.JOBRUNR_JOBS.STATE }, false); public static final Index NAMESPACE_MEMBERSHIP__NAMESPACE__IDX = Internal.createIndex(DSL.name("namespace_membership__namespace__idx"), NamespaceMembership.NAMESPACE_MEMBERSHIP, new OrderField[] { NamespaceMembership.NAMESPACE_MEMBERSHIP.NAMESPACE }, false); public static final Index NAMESPACE_MEMBERSHIP__USER_DATA__IDX = Internal.createIndex(DSL.name("namespace_membership__user_data__idx"), NamespaceMembership.NAMESPACE_MEMBERSHIP, new OrderField[] { NamespaceMembership.NAMESPACE_MEMBERSHIP.USER_DATA }, false); public static final Index PERSISTED_LOG__USER_DATA__IDX = Internal.createIndex(DSL.name("persisted_log__user_data__idx"), PersistedLog.PERSISTED_LOG, new OrderField[] { PersistedLog.PERSISTED_LOG.USER_DATA }, false); diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Keys.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Keys.java index cc0544e41..db3faa8de 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Keys.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Keys.java @@ -7,6 +7,10 @@ import org.eclipse.openvsx.jooq.tables.AdminStatistics; import org.eclipse.openvsx.jooq.tables.AdminStatisticsExtensionsByRating; import org.eclipse.openvsx.jooq.tables.AdminStatisticsPublishersByExtensionsPublished; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostActivePublishingUsers; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostDownloadedExtensions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensionVersions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensions; import org.eclipse.openvsx.jooq.tables.AzureDownloadCountProcessedItem; import org.eclipse.openvsx.jooq.tables.Download; import org.eclipse.openvsx.jooq.tables.EntityActiveState; @@ -15,8 +19,15 @@ import org.eclipse.openvsx.jooq.tables.ExtensionVersion; import org.eclipse.openvsx.jooq.tables.FileResource; import org.eclipse.openvsx.jooq.tables.FlywaySchemaHistory; +import org.eclipse.openvsx.jooq.tables.JobrunrBackgroundjobservers; +import org.eclipse.openvsx.jooq.tables.JobrunrJobs; +import org.eclipse.openvsx.jooq.tables.JobrunrMetadata; +import org.eclipse.openvsx.jooq.tables.JobrunrMigrations; +import org.eclipse.openvsx.jooq.tables.JobrunrRecurringJobs; +import org.eclipse.openvsx.jooq.tables.MigrationItem; import org.eclipse.openvsx.jooq.tables.Namespace; import org.eclipse.openvsx.jooq.tables.NamespaceMembership; +import org.eclipse.openvsx.jooq.tables.NamespaceSocialLinks; import org.eclipse.openvsx.jooq.tables.PersistedLog; import org.eclipse.openvsx.jooq.tables.PersonalAccessToken; import org.eclipse.openvsx.jooq.tables.Shedlock; @@ -26,6 +37,10 @@ import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsExtensionsByRatingRecord; import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsPublishersByExtensionsPublishedRecord; import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsRecord; +import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsTopMostActivePublishingUsersRecord; +import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsTopMostDownloadedExtensionsRecord; +import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsTopNamespaceExtensionVersionsRecord; +import org.eclipse.openvsx.jooq.tables.records.AdminStatisticsTopNamespaceExtensionsRecord; import org.eclipse.openvsx.jooq.tables.records.AzureDownloadCountProcessedItemRecord; import org.eclipse.openvsx.jooq.tables.records.DownloadRecord; import org.eclipse.openvsx.jooq.tables.records.EntityActiveStateRecord; @@ -34,8 +49,15 @@ import org.eclipse.openvsx.jooq.tables.records.ExtensionVersionRecord; import org.eclipse.openvsx.jooq.tables.records.FileResourceRecord; import org.eclipse.openvsx.jooq.tables.records.FlywaySchemaHistoryRecord; +import org.eclipse.openvsx.jooq.tables.records.JobrunrBackgroundjobserversRecord; +import org.eclipse.openvsx.jooq.tables.records.JobrunrJobsRecord; +import org.eclipse.openvsx.jooq.tables.records.JobrunrMetadataRecord; +import org.eclipse.openvsx.jooq.tables.records.JobrunrMigrationsRecord; +import org.eclipse.openvsx.jooq.tables.records.JobrunrRecurringJobsRecord; +import org.eclipse.openvsx.jooq.tables.records.MigrationItemRecord; import org.eclipse.openvsx.jooq.tables.records.NamespaceMembershipRecord; import org.eclipse.openvsx.jooq.tables.records.NamespaceRecord; +import org.eclipse.openvsx.jooq.tables.records.NamespaceSocialLinksRecord; import org.eclipse.openvsx.jooq.tables.records.PersistedLogRecord; import org.eclipse.openvsx.jooq.tables.records.PersonalAccessTokenRecord; import org.eclipse.openvsx.jooq.tables.records.ShedlockRecord; @@ -71,6 +93,12 @@ public class Keys { public static final UniqueKey UNIQUE_EXTENSION_VERSION = Internal.createUniqueKey(ExtensionVersion.EXTENSION_VERSION, DSL.name("unique_extension_version"), new TableField[] { ExtensionVersion.EXTENSION_VERSION.EXTENSION_ID, ExtensionVersion.EXTENSION_VERSION.TARGET_PLATFORM, ExtensionVersion.EXTENSION_VERSION.VERSION }, true); public static final UniqueKey FILE_RESOURCE_PKEY = Internal.createUniqueKey(FileResource.FILE_RESOURCE, DSL.name("file_resource_pkey"), new TableField[] { FileResource.FILE_RESOURCE.ID }, true); public static final UniqueKey FLYWAY_SCHEMA_HISTORY_PK = Internal.createUniqueKey(FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY, DSL.name("flyway_schema_history_pk"), new TableField[] { FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY.INSTALLED_RANK }, true); + public static final UniqueKey JOBRUNR_BACKGROUNDJOBSERVERS_PKEY = Internal.createUniqueKey(JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS, DSL.name("jobrunr_backgroundjobservers_pkey"), new TableField[] { JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS.ID }, true); + public static final UniqueKey JOBRUNR_JOBS_PKEY = Internal.createUniqueKey(JobrunrJobs.JOBRUNR_JOBS, DSL.name("jobrunr_jobs_pkey"), new TableField[] { JobrunrJobs.JOBRUNR_JOBS.ID }, true); + public static final UniqueKey JOBRUNR_METADATA_PKEY = Internal.createUniqueKey(JobrunrMetadata.JOBRUNR_METADATA, DSL.name("jobrunr_metadata_pkey"), new TableField[] { JobrunrMetadata.JOBRUNR_METADATA.ID }, true); + public static final UniqueKey JOBRUNR_MIGRATIONS_PKEY = Internal.createUniqueKey(JobrunrMigrations.JOBRUNR_MIGRATIONS, DSL.name("jobrunr_migrations_pkey"), new TableField[] { JobrunrMigrations.JOBRUNR_MIGRATIONS.ID }, true); + public static final UniqueKey JOBRUNR_RECURRING_JOBS_PKEY = Internal.createUniqueKey(JobrunrRecurringJobs.JOBRUNR_RECURRING_JOBS, DSL.name("jobrunr_recurring_jobs_pkey"), new TableField[] { JobrunrRecurringJobs.JOBRUNR_RECURRING_JOBS.ID }, true); + public static final UniqueKey MIGRATION_ITEM_PKEY = Internal.createUniqueKey(MigrationItem.MIGRATION_ITEM, DSL.name("migration_item_pkey"), new TableField[] { MigrationItem.MIGRATION_ITEM.ID }, true); public static final UniqueKey NAMESPACE_PKEY = Internal.createUniqueKey(Namespace.NAMESPACE, DSL.name("namespace_pkey"), new TableField[] { Namespace.NAMESPACE.ID }, true); public static final UniqueKey UNIQUE_NAMESPACE_PUBLIC_ID = Internal.createUniqueKey(Namespace.NAMESPACE, DSL.name("unique_namespace_public_id"), new TableField[] { Namespace.NAMESPACE.PUBLIC_ID }, true); public static final UniqueKey NAMESPACE_MEMBERSHIP_PKEY = Internal.createUniqueKey(NamespaceMembership.NAMESPACE_MEMBERSHIP, DSL.name("namespace_membership_pkey"), new TableField[] { NamespaceMembership.NAMESPACE_MEMBERSHIP.ID }, true); @@ -88,6 +116,10 @@ public class Keys { public static final ForeignKey ADMIN_STATISTICS_EXTENSIONS_BY_RATING__ADMIN_STATISTICS_EXTENSIONS_BY_RATING_FKEY = Internal.createForeignKey(AdminStatisticsExtensionsByRating.ADMIN_STATISTICS_EXTENSIONS_BY_RATING, DSL.name("admin_statistics_extensions_by_rating_fkey"), new TableField[] { AdminStatisticsExtensionsByRating.ADMIN_STATISTICS_EXTENSIONS_BY_RATING.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); public static final ForeignKey ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED__ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED_FKEY = Internal.createForeignKey(AdminStatisticsPublishersByExtensionsPublished.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED, DSL.name("admin_statistics_publishers_by_extensions_published_fkey"), new TableField[] { AdminStatisticsPublishersByExtensionsPublished.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); + public static final ForeignKey ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS__ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS_FKEY = Internal.createForeignKey(AdminStatisticsTopMostActivePublishingUsers.ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS, DSL.name("admin_statistics_top_most_active_publishing_users_fkey"), new TableField[] { AdminStatisticsTopMostActivePublishingUsers.ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); + public static final ForeignKey ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS__ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS_FKEY = Internal.createForeignKey(AdminStatisticsTopMostDownloadedExtensions.ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS, DSL.name("admin_statistics_top_most_downloaded_extensions_fkey"), new TableField[] { AdminStatisticsTopMostDownloadedExtensions.ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); + public static final ForeignKey ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS__ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS_FKEY = Internal.createForeignKey(AdminStatisticsTopNamespaceExtensionVersions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS, DSL.name("admin_statistics_top_namespace_extension_versions_fkey"), new TableField[] { AdminStatisticsTopNamespaceExtensionVersions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); + public static final ForeignKey ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS__ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS_FKEY = Internal.createForeignKey(AdminStatisticsTopNamespaceExtensions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS, DSL.name("admin_statistics_top_namespace_extensions_fkey"), new TableField[] { AdminStatisticsTopNamespaceExtensions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS.ADMIN_STATISTICS_ID }, Keys.ADMIN_STATISTICS_PKEY, new TableField[] { AdminStatistics.ADMIN_STATISTICS.ID }, true); public static final ForeignKey EXTENSION__FK64IMD3NRJ67D50TPKJS94NGMN = Internal.createForeignKey(Extension.EXTENSION, DSL.name("fk64imd3nrj67d50tpkjs94ngmn"), new TableField[] { Extension.EXTENSION.NAMESPACE_ID }, Keys.NAMESPACE_PKEY, new TableField[] { Namespace.NAMESPACE.ID }, true); public static final ForeignKey EXTENSION_REVIEW__FKGD2DQDC23OGBNOBX8AFJFPNKP = Internal.createForeignKey(ExtensionReview.EXTENSION_REVIEW, DSL.name("fkgd2dqdc23ogbnobx8afjfpnkp"), new TableField[] { ExtensionReview.EXTENSION_REVIEW.EXTENSION_ID }, Keys.EXTENSION_PKEY, new TableField[] { Extension.EXTENSION.ID }, true); public static final ForeignKey EXTENSION_REVIEW__FKINJBN9GRK135Y6IK0UT4UJP0W = Internal.createForeignKey(ExtensionReview.EXTENSION_REVIEW, DSL.name("fkinjbn9grk135y6ik0ut4ujp0w"), new TableField[] { ExtensionReview.EXTENSION_REVIEW.USER_ID }, Keys.USER_DATA_PKEY, new TableField[] { UserData.USER_DATA.ID }, true); @@ -96,6 +128,7 @@ public class Keys { public static final ForeignKey FILE_RESOURCE__FILE_RESOURCE_EXTENSION_FKEY = Internal.createForeignKey(FileResource.FILE_RESOURCE, DSL.name("file_resource_extension_fkey"), new TableField[] { FileResource.FILE_RESOURCE.EXTENSION_ID }, Keys.EXTENSION_VERSION_PKEY, new TableField[] { ExtensionVersion.EXTENSION_VERSION.ID }, true); public static final ForeignKey NAMESPACE_MEMBERSHIP__FKGFHWHKNULA6DO2N6WYVQETM3N = Internal.createForeignKey(NamespaceMembership.NAMESPACE_MEMBERSHIP, DSL.name("fkgfhwhknula6do2n6wyvqetm3n"), new TableField[] { NamespaceMembership.NAMESPACE_MEMBERSHIP.NAMESPACE }, Keys.NAMESPACE_PKEY, new TableField[] { Namespace.NAMESPACE.ID }, true); public static final ForeignKey NAMESPACE_MEMBERSHIP__FKNSAMEKUTXYWVSB3S1MJDCJKYP = Internal.createForeignKey(NamespaceMembership.NAMESPACE_MEMBERSHIP, DSL.name("fknsamekutxywvsb3s1mjdcjkyp"), new TableField[] { NamespaceMembership.NAMESPACE_MEMBERSHIP.USER_DATA }, Keys.USER_DATA_PKEY, new TableField[] { UserData.USER_DATA.ID }, true); + public static final ForeignKey NAMESPACE_SOCIAL_LINKS__NAMESPACE_SOCIAL_LINKS_FKEY = Internal.createForeignKey(NamespaceSocialLinks.NAMESPACE_SOCIAL_LINKS, DSL.name("namespace_social_links_fkey"), new TableField[] { NamespaceSocialLinks.NAMESPACE_SOCIAL_LINKS.NAMESPACE_ID }, Keys.NAMESPACE_PKEY, new TableField[] { Namespace.NAMESPACE.ID }, true); public static final ForeignKey PERSISTED_LOG__PERSISTED_LOG_USER_DATA_FKEY = Internal.createForeignKey(PersistedLog.PERSISTED_LOG, DSL.name("persisted_log_user_data_fkey"), new TableField[] { PersistedLog.PERSISTED_LOG.USER_DATA }, Keys.USER_DATA_PKEY, new TableField[] { UserData.USER_DATA.ID }, true); public static final ForeignKey PERSONAL_ACCESS_TOKEN__FKTQJVMHOIG3WTTJ6DL1IBCAJ3L = Internal.createForeignKey(PersonalAccessToken.PERSONAL_ACCESS_TOKEN, DSL.name("fktqjvmhoig3wttj6dl1ibcaj3l"), new TableField[] { PersonalAccessToken.PERSONAL_ACCESS_TOKEN.USER_DATA }, Keys.USER_DATA_PKEY, new TableField[] { UserData.USER_DATA.ID }, true); public static final ForeignKey SPRING_SESSION_ATTRIBUTES__SPRING_SESSION_ATTRIBUTES_FK = Internal.createForeignKey(SpringSessionAttributes.SPRING_SESSION_ATTRIBUTES, DSL.name("spring_session_attributes_fk"), new TableField[] { SpringSessionAttributes.SPRING_SESSION_ATTRIBUTES.SESSION_PRIMARY_ID }, Keys.SPRING_SESSION_PK, new TableField[] { SpringSession.SPRING_SESSION.PRIMARY_ID }, true); diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Public.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Public.java index ed50f6e32..e7c95fcb4 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Public.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Public.java @@ -10,6 +10,10 @@ import org.eclipse.openvsx.jooq.tables.AdminStatistics; import org.eclipse.openvsx.jooq.tables.AdminStatisticsExtensionsByRating; import org.eclipse.openvsx.jooq.tables.AdminStatisticsPublishersByExtensionsPublished; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostActivePublishingUsers; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostDownloadedExtensions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensionVersions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensions; import org.eclipse.openvsx.jooq.tables.AzureDownloadCountProcessedItem; import org.eclipse.openvsx.jooq.tables.Download; import org.eclipse.openvsx.jooq.tables.EntityActiveState; @@ -18,8 +22,16 @@ import org.eclipse.openvsx.jooq.tables.ExtensionVersion; import org.eclipse.openvsx.jooq.tables.FileResource; import org.eclipse.openvsx.jooq.tables.FlywaySchemaHistory; +import org.eclipse.openvsx.jooq.tables.JobrunrBackgroundjobservers; +import org.eclipse.openvsx.jooq.tables.JobrunrJobs; +import org.eclipse.openvsx.jooq.tables.JobrunrJobsStats; +import org.eclipse.openvsx.jooq.tables.JobrunrMetadata; +import org.eclipse.openvsx.jooq.tables.JobrunrMigrations; +import org.eclipse.openvsx.jooq.tables.JobrunrRecurringJobs; +import org.eclipse.openvsx.jooq.tables.MigrationItem; import org.eclipse.openvsx.jooq.tables.Namespace; import org.eclipse.openvsx.jooq.tables.NamespaceMembership; +import org.eclipse.openvsx.jooq.tables.NamespaceSocialLinks; import org.eclipse.openvsx.jooq.tables.PersistedLog; import org.eclipse.openvsx.jooq.tables.PersonalAccessToken; import org.eclipse.openvsx.jooq.tables.Shedlock; @@ -60,6 +72,26 @@ public class Public extends SchemaImpl { */ public final AdminStatisticsPublishersByExtensionsPublished ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED = AdminStatisticsPublishersByExtensionsPublished.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED; + /** + * The table public.admin_statistics_top_most_active_publishing_users. + */ + public final AdminStatisticsTopMostActivePublishingUsers ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS = AdminStatisticsTopMostActivePublishingUsers.ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS; + + /** + * The table public.admin_statistics_top_most_downloaded_extensions. + */ + public final AdminStatisticsTopMostDownloadedExtensions ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS = AdminStatisticsTopMostDownloadedExtensions.ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS; + + /** + * The table public.admin_statistics_top_namespace_extension_versions. + */ + public final AdminStatisticsTopNamespaceExtensionVersions ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS = AdminStatisticsTopNamespaceExtensionVersions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS; + + /** + * The table public.admin_statistics_top_namespace_extensions. + */ + public final AdminStatisticsTopNamespaceExtensions ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS = AdminStatisticsTopNamespaceExtensions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS; + /** * The table public.azure_download_count_processed_item. */ @@ -100,6 +132,41 @@ public class Public extends SchemaImpl { */ public final FlywaySchemaHistory FLYWAY_SCHEMA_HISTORY = FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY; + /** + * The table public.jobrunr_backgroundjobservers. + */ + public final JobrunrBackgroundjobservers JOBRUNR_BACKGROUNDJOBSERVERS = JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS; + + /** + * The table public.jobrunr_jobs. + */ + public final JobrunrJobs JOBRUNR_JOBS = JobrunrJobs.JOBRUNR_JOBS; + + /** + * The table public.jobrunr_jobs_stats. + */ + public final JobrunrJobsStats JOBRUNR_JOBS_STATS = JobrunrJobsStats.JOBRUNR_JOBS_STATS; + + /** + * The table public.jobrunr_metadata. + */ + public final JobrunrMetadata JOBRUNR_METADATA = JobrunrMetadata.JOBRUNR_METADATA; + + /** + * The table public.jobrunr_migrations. + */ + public final JobrunrMigrations JOBRUNR_MIGRATIONS = JobrunrMigrations.JOBRUNR_MIGRATIONS; + + /** + * The table public.jobrunr_recurring_jobs. + */ + public final JobrunrRecurringJobs JOBRUNR_RECURRING_JOBS = JobrunrRecurringJobs.JOBRUNR_RECURRING_JOBS; + + /** + * The table public.migration_item. + */ + public final MigrationItem MIGRATION_ITEM = MigrationItem.MIGRATION_ITEM; + /** * The table public.namespace. */ @@ -110,6 +177,11 @@ public class Public extends SchemaImpl { */ public final NamespaceMembership NAMESPACE_MEMBERSHIP = NamespaceMembership.NAMESPACE_MEMBERSHIP; + /** + * The table public.namespace_social_links. + */ + public final NamespaceSocialLinks NAMESPACE_SOCIAL_LINKS = NamespaceSocialLinks.NAMESPACE_SOCIAL_LINKS; + /** * The table public.persisted_log. */ @@ -168,6 +240,10 @@ public final List> getTables() { AdminStatistics.ADMIN_STATISTICS, AdminStatisticsExtensionsByRating.ADMIN_STATISTICS_EXTENSIONS_BY_RATING, AdminStatisticsPublishersByExtensionsPublished.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED, + AdminStatisticsTopMostActivePublishingUsers.ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS, + AdminStatisticsTopMostDownloadedExtensions.ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS, + AdminStatisticsTopNamespaceExtensionVersions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS, + AdminStatisticsTopNamespaceExtensions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS, AzureDownloadCountProcessedItem.AZURE_DOWNLOAD_COUNT_PROCESSED_ITEM, Download.DOWNLOAD, EntityActiveState.ENTITY_ACTIVE_STATE, @@ -176,8 +252,16 @@ public final List> getTables() { ExtensionVersion.EXTENSION_VERSION, FileResource.FILE_RESOURCE, FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY, + JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS, + JobrunrJobs.JOBRUNR_JOBS, + JobrunrJobsStats.JOBRUNR_JOBS_STATS, + JobrunrMetadata.JOBRUNR_METADATA, + JobrunrMigrations.JOBRUNR_MIGRATIONS, + JobrunrRecurringJobs.JOBRUNR_RECURRING_JOBS, + MigrationItem.MIGRATION_ITEM, Namespace.NAMESPACE, NamespaceMembership.NAMESPACE_MEMBERSHIP, + NamespaceSocialLinks.NAMESPACE_SOCIAL_LINKS, PersistedLog.PERSISTED_LOG, PersonalAccessToken.PERSONAL_ACCESS_TOKEN, Shedlock.SHEDLOCK, diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Tables.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Tables.java index 4334e9223..d17c77f0c 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Tables.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/Tables.java @@ -7,6 +7,10 @@ import org.eclipse.openvsx.jooq.tables.AdminStatistics; import org.eclipse.openvsx.jooq.tables.AdminStatisticsExtensionsByRating; import org.eclipse.openvsx.jooq.tables.AdminStatisticsPublishersByExtensionsPublished; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostActivePublishingUsers; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopMostDownloadedExtensions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensionVersions; +import org.eclipse.openvsx.jooq.tables.AdminStatisticsTopNamespaceExtensions; import org.eclipse.openvsx.jooq.tables.AzureDownloadCountProcessedItem; import org.eclipse.openvsx.jooq.tables.Download; import org.eclipse.openvsx.jooq.tables.EntityActiveState; @@ -15,8 +19,16 @@ import org.eclipse.openvsx.jooq.tables.ExtensionVersion; import org.eclipse.openvsx.jooq.tables.FileResource; import org.eclipse.openvsx.jooq.tables.FlywaySchemaHistory; +import org.eclipse.openvsx.jooq.tables.JobrunrBackgroundjobservers; +import org.eclipse.openvsx.jooq.tables.JobrunrJobs; +import org.eclipse.openvsx.jooq.tables.JobrunrJobsStats; +import org.eclipse.openvsx.jooq.tables.JobrunrMetadata; +import org.eclipse.openvsx.jooq.tables.JobrunrMigrations; +import org.eclipse.openvsx.jooq.tables.JobrunrRecurringJobs; +import org.eclipse.openvsx.jooq.tables.MigrationItem; import org.eclipse.openvsx.jooq.tables.Namespace; import org.eclipse.openvsx.jooq.tables.NamespaceMembership; +import org.eclipse.openvsx.jooq.tables.NamespaceSocialLinks; import org.eclipse.openvsx.jooq.tables.PersistedLog; import org.eclipse.openvsx.jooq.tables.PersonalAccessToken; import org.eclipse.openvsx.jooq.tables.Shedlock; @@ -46,6 +58,26 @@ public class Tables { */ public static final AdminStatisticsPublishersByExtensionsPublished ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED = AdminStatisticsPublishersByExtensionsPublished.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED; + /** + * The table public.admin_statistics_top_most_active_publishing_users. + */ + public static final AdminStatisticsTopMostActivePublishingUsers ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS = AdminStatisticsTopMostActivePublishingUsers.ADMIN_STATISTICS_TOP_MOST_ACTIVE_PUBLISHING_USERS; + + /** + * The table public.admin_statistics_top_most_downloaded_extensions. + */ + public static final AdminStatisticsTopMostDownloadedExtensions ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS = AdminStatisticsTopMostDownloadedExtensions.ADMIN_STATISTICS_TOP_MOST_DOWNLOADED_EXTENSIONS; + + /** + * The table public.admin_statistics_top_namespace_extension_versions. + */ + public static final AdminStatisticsTopNamespaceExtensionVersions ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS = AdminStatisticsTopNamespaceExtensionVersions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSION_VERSIONS; + + /** + * The table public.admin_statistics_top_namespace_extensions. + */ + public static final AdminStatisticsTopNamespaceExtensions ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS = AdminStatisticsTopNamespaceExtensions.ADMIN_STATISTICS_TOP_NAMESPACE_EXTENSIONS; + /** * The table public.azure_download_count_processed_item. */ @@ -86,6 +118,41 @@ public class Tables { */ public static final FlywaySchemaHistory FLYWAY_SCHEMA_HISTORY = FlywaySchemaHistory.FLYWAY_SCHEMA_HISTORY; + /** + * The table public.jobrunr_backgroundjobservers. + */ + public static final JobrunrBackgroundjobservers JOBRUNR_BACKGROUNDJOBSERVERS = JobrunrBackgroundjobservers.JOBRUNR_BACKGROUNDJOBSERVERS; + + /** + * The table public.jobrunr_jobs. + */ + public static final JobrunrJobs JOBRUNR_JOBS = JobrunrJobs.JOBRUNR_JOBS; + + /** + * The table public.jobrunr_jobs_stats. + */ + public static final JobrunrJobsStats JOBRUNR_JOBS_STATS = JobrunrJobsStats.JOBRUNR_JOBS_STATS; + + /** + * The table public.jobrunr_metadata. + */ + public static final JobrunrMetadata JOBRUNR_METADATA = JobrunrMetadata.JOBRUNR_METADATA; + + /** + * The table public.jobrunr_migrations. + */ + public static final JobrunrMigrations JOBRUNR_MIGRATIONS = JobrunrMigrations.JOBRUNR_MIGRATIONS; + + /** + * The table public.jobrunr_recurring_jobs. + */ + public static final JobrunrRecurringJobs JOBRUNR_RECURRING_JOBS = JobrunrRecurringJobs.JOBRUNR_RECURRING_JOBS; + + /** + * The table public.migration_item. + */ + public static final MigrationItem MIGRATION_ITEM = MigrationItem.MIGRATION_ITEM; + /** * The table public.namespace. */ @@ -96,6 +163,11 @@ public class Tables { */ public static final NamespaceMembership NAMESPACE_MEMBERSHIP = NamespaceMembership.NAMESPACE_MEMBERSHIP; + /** + * The table public.namespace_social_links. + */ + public static final NamespaceSocialLinks NAMESPACE_SOCIAL_LINKS = NamespaceSocialLinks.NAMESPACE_SOCIAL_LINKS; + /** * The table public.persisted_log. */ diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsExtensionsByRating.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsExtensionsByRating.java index 04d3cb840..ea408cbea 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsExtensionsByRating.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsExtensionsByRating.java @@ -103,8 +103,13 @@ public Schema getSchema() { return Arrays.>asList(Keys.ADMIN_STATISTICS_EXTENSIONS_BY_RATING__ADMIN_STATISTICS_EXTENSIONS_BY_RATING_FKEY); } + private transient AdminStatistics _adminStatistics; + public AdminStatistics adminStatistics() { - return new AdminStatistics(this, Keys.ADMIN_STATISTICS_EXTENSIONS_BY_RATING__ADMIN_STATISTICS_EXTENSIONS_BY_RATING_FKEY); + if (_adminStatistics == null) + _adminStatistics = new AdminStatistics(this, Keys.ADMIN_STATISTICS_EXTENSIONS_BY_RATING__ADMIN_STATISTICS_EXTENSIONS_BY_RATING_FKEY); + + return _adminStatistics; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsPublishersByExtensionsPublished.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsPublishersByExtensionsPublished.java index 57592196f..46e554e11 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsPublishersByExtensionsPublished.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/AdminStatisticsPublishersByExtensionsPublished.java @@ -103,8 +103,13 @@ public Schema getSchema() { return Arrays.>asList(Keys.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED__ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED_FKEY); } + private transient AdminStatistics _adminStatistics; + public AdminStatistics adminStatistics() { - return new AdminStatistics(this, Keys.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED__ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED_FKEY); + if (_adminStatistics == null) + _adminStatistics = new AdminStatistics(this, Keys.ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED__ADMIN_STATISTICS_PUBLISHERS_BY_EXTENSIONS_PUBLISHED_FKEY); + + return _adminStatistics; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Download.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Download.java index bef8680f3..55b29733e 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Download.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Download.java @@ -8,11 +8,13 @@ import java.util.Arrays; import java.util.List; +import org.eclipse.openvsx.jooq.Indexes; import org.eclipse.openvsx.jooq.Keys; import org.eclipse.openvsx.jooq.Public; import org.eclipse.openvsx.jooq.tables.records.DownloadRecord; import org.jooq.Field; import org.jooq.ForeignKey; +import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; import org.jooq.Row4; @@ -105,6 +107,11 @@ public Schema getSchema() { return Public.PUBLIC; } + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DOWNLOAD_TIMESTAMP_BRIN_IDX); + } + @Override public UniqueKey getPrimaryKey() { return Keys.DOWNLOAD_PKEY; diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Extension.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Extension.java index 8d6f25542..1b1a6b0a5 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Extension.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Extension.java @@ -152,8 +152,13 @@ public List> getKeys() { return Arrays.>asList(Keys.EXTENSION__FK64IMD3NRJ67D50TPKJS94NGMN); } + private transient Namespace _namespace; + public Namespace namespace() { - return new Namespace(this, Keys.EXTENSION__FK64IMD3NRJ67D50TPKJS94NGMN); + if (_namespace == null) + _namespace = new Namespace(this, Keys.EXTENSION__FK64IMD3NRJ67D50TPKJS94NGMN); + + return _namespace; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionReview.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionReview.java index 957d3806d..b2d4304a8 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionReview.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionReview.java @@ -147,12 +147,21 @@ public List> getKeys() { return Arrays.>asList(Keys.EXTENSION_REVIEW__FKGD2DQDC23OGBNOBX8AFJFPNKP, Keys.EXTENSION_REVIEW__FKINJBN9GRK135Y6IK0UT4UJP0W); } + private transient Extension _extension; + private transient UserData _userData; + public Extension extension() { - return new Extension(this, Keys.EXTENSION_REVIEW__FKGD2DQDC23OGBNOBX8AFJFPNKP); + if (_extension == null) + _extension = new Extension(this, Keys.EXTENSION_REVIEW__FKGD2DQDC23OGBNOBX8AFJFPNKP); + + return _extension; } public UserData userData() { - return new UserData(this, Keys.EXTENSION_REVIEW__FKINJBN9GRK135Y6IK0UT4UJP0W); + if (_userData == null) + _userData = new UserData(this, Keys.EXTENSION_REVIEW__FKINJBN9GRK135Y6IK0UT4UJP0W); + + return _userData; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionVersion.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionVersion.java index 274e23d0e..6097e5b61 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionVersion.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/ExtensionVersion.java @@ -173,6 +173,11 @@ public Class getRecordType() { */ public final TableField TARGET_PLATFORM = createField(DSL.name("target_platform"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + /** + * The column public.extension_version.sponsor_link. + */ + public final TableField SPONSOR_LINK = createField(DSL.name("sponsor_link"), SQLDataType.VARCHAR(255), this, ""); + private ExtensionVersion(Name alias, Table aliased) { this(alias, aliased, null); } @@ -231,12 +236,21 @@ public List> getKeys() { return Arrays.>asList(Keys.EXTENSION_VERSION__FKKHS1EC9S9J08FGICQ9PMWU6BT, Keys.EXTENSION_VERSION__FK70KHJ8PM0VACASUIIAQ0W0R80); } + private transient Extension _extension; + private transient PersonalAccessToken _personalAccessToken; + public Extension extension() { - return new Extension(this, Keys.EXTENSION_VERSION__FKKHS1EC9S9J08FGICQ9PMWU6BT); + if (_extension == null) + _extension = new Extension(this, Keys.EXTENSION_VERSION__FKKHS1EC9S9J08FGICQ9PMWU6BT); + + return _extension; } public PersonalAccessToken personalAccessToken() { - return new PersonalAccessToken(this, Keys.EXTENSION_VERSION__FK70KHJ8PM0VACASUIIAQ0W0R80); + if (_personalAccessToken == null) + _personalAccessToken = new PersonalAccessToken(this, Keys.EXTENSION_VERSION__FK70KHJ8PM0VACASUIIAQ0W0R80); + + return _personalAccessToken; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/FileResource.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/FileResource.java index 13ac0947f..44341d510 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/FileResource.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/FileResource.java @@ -16,7 +16,7 @@ import org.jooq.Index; import org.jooq.Name; import org.jooq.Record; -import org.jooq.Row6; +import org.jooq.Row7; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; @@ -78,6 +78,11 @@ public Class getRecordType() { */ public final TableField STORAGE_TYPE = createField(DSL.name("storage_type"), SQLDataType.VARCHAR(32), this, ""); + /** + * The column public.file_resource.content_type. + */ + public final TableField CONTENT_TYPE = createField(DSL.name("content_type"), SQLDataType.VARCHAR(255), this, ""); + private FileResource(Name alias, Table aliased) { this(alias, aliased, null); } @@ -118,7 +123,7 @@ public Schema getSchema() { @Override public List getIndexes() { - return Arrays.asList(Indexes.FILE_RESOURCE_EXTENSION_IDX); + return Arrays.asList(Indexes.FILE_RESOURCE_EXTENSION_IDX, Indexes.FILE_RESOURCE_TYPE_IDX); } @Override @@ -136,8 +141,13 @@ public List> getKeys() { return Arrays.>asList(Keys.FILE_RESOURCE__FILE_RESOURCE_EXTENSION_FKEY); } + private transient ExtensionVersion _extensionVersion; + public ExtensionVersion extensionVersion() { - return new ExtensionVersion(this, Keys.FILE_RESOURCE__FILE_RESOURCE_EXTENSION_FKEY); + if (_extensionVersion == null) + _extensionVersion = new ExtensionVersion(this, Keys.FILE_RESOURCE__FILE_RESOURCE_EXTENSION_FKEY); + + return _extensionVersion; } @Override @@ -167,11 +177,11 @@ public FileResource rename(Name name) { } // ------------------------------------------------------------------------- - // Row6 type methods + // Row7 type methods // ------------------------------------------------------------------------- @Override - public Row6 fieldsRow() { - return (Row6) super.fieldsRow(); + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); } } diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Namespace.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Namespace.java index 8c07e1044..7d3b59cd1 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Namespace.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/Namespace.java @@ -14,7 +14,7 @@ import org.jooq.ForeignKey; import org.jooq.Name; import org.jooq.Record; -import org.jooq.Row3; +import org.jooq.Row10; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; @@ -61,6 +61,41 @@ public Class getRecordType() { */ public final TableField PUBLIC_ID = createField(DSL.name("public_id"), SQLDataType.VARCHAR(128), this, ""); + /** + * The column public.namespace.display_name. + */ + public final TableField DISPLAY_NAME = createField(DSL.name("display_name"), SQLDataType.VARCHAR(32), this, ""); + + /** + * The column public.namespace.description. + */ + public final TableField DESCRIPTION = createField(DSL.name("description"), SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.namespace.company_link. + */ + public final TableField COMPANY_LINK = createField(DSL.name("company_link"), SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.namespace.support_link. + */ + public final TableField SUPPORT_LINK = createField(DSL.name("support_link"), SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.namespace.logo_name. + */ + public final TableField LOGO_NAME = createField(DSL.name("logo_name"), SQLDataType.VARCHAR(255), this, ""); + + /** + * The column public.namespace.logo_bytes. + */ + public final TableField LOGO_BYTES = createField(DSL.name("logo_bytes"), SQLDataType.BLOB, this, ""); + + /** + * The column public.namespace.logo_storage_type. + */ + public final TableField LOGO_STORAGE_TYPE = createField(DSL.name("logo_storage_type"), SQLDataType.VARCHAR(32), this, ""); + private Namespace(Name alias, Table aliased) { this(alias, aliased, null); } @@ -136,11 +171,11 @@ public Namespace rename(Name name) { } // ------------------------------------------------------------------------- - // Row3 type methods + // Row10 type methods // ------------------------------------------------------------------------- @Override - public Row3 fieldsRow() { - return (Row3) super.fieldsRow(); + public Row10 fieldsRow() { + return (Row10) super.fieldsRow(); } } diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/NamespaceMembership.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/NamespaceMembership.java index 6e4b9e00a..af323e774 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/NamespaceMembership.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/NamespaceMembership.java @@ -126,12 +126,21 @@ public List> getKeys() { return Arrays.>asList(Keys.NAMESPACE_MEMBERSHIP__FKGFHWHKNULA6DO2N6WYVQETM3N, Keys.NAMESPACE_MEMBERSHIP__FKNSAMEKUTXYWVSB3S1MJDCJKYP); } + private transient Namespace _namespace; + private transient UserData _userData; + public Namespace namespace() { - return new Namespace(this, Keys.NAMESPACE_MEMBERSHIP__FKGFHWHKNULA6DO2N6WYVQETM3N); + if (_namespace == null) + _namespace = new Namespace(this, Keys.NAMESPACE_MEMBERSHIP__FKGFHWHKNULA6DO2N6WYVQETM3N); + + return _namespace; } public UserData userData() { - return new UserData(this, Keys.NAMESPACE_MEMBERSHIP__FKNSAMEKUTXYWVSB3S1MJDCJKYP); + if (_userData == null) + _userData = new UserData(this, Keys.NAMESPACE_MEMBERSHIP__FKNSAMEKUTXYWVSB3S1MJDCJKYP); + + return _userData; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersistedLog.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersistedLog.java index 40cae9057..015e4f6d5 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersistedLog.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersistedLog.java @@ -127,8 +127,13 @@ public List> getKeys() { return Arrays.>asList(Keys.PERSISTED_LOG__PERSISTED_LOG_USER_DATA_FKEY); } + private transient UserData _userData; + public UserData userData() { - return new UserData(this, Keys.PERSISTED_LOG__PERSISTED_LOG_USER_DATA_FKEY); + if (_userData == null) + _userData = new UserData(this, Keys.PERSISTED_LOG__PERSISTED_LOG_USER_DATA_FKEY); + + return _userData; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersonalAccessToken.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersonalAccessToken.java index de5c8a5aa..5f91c0acc 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersonalAccessToken.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/PersonalAccessToken.java @@ -135,8 +135,13 @@ public List> getKeys() { return Arrays.>asList(Keys.PERSONAL_ACCESS_TOKEN__FKTQJVMHOIG3WTTJ6DL1IBCAJ3L); } + private transient UserData _userData; + public UserData userData() { - return new UserData(this, Keys.PERSONAL_ACCESS_TOKEN__FKTQJVMHOIG3WTTJ6DL1IBCAJ3L); + if (_userData == null) + _userData = new UserData(this, Keys.PERSONAL_ACCESS_TOKEN__FKTQJVMHOIG3WTTJ6DL1IBCAJ3L); + + return _userData; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/SpringSessionAttributes.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/SpringSessionAttributes.java index cdd3a8799..fdae9bd6a 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/SpringSessionAttributes.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/SpringSessionAttributes.java @@ -114,8 +114,13 @@ public List> getKeys() { return Arrays.>asList(Keys.SPRING_SESSION_ATTRIBUTES__SPRING_SESSION_ATTRIBUTES_FK); } + private transient SpringSession _springSession; + public SpringSession springSession() { - return new SpringSession(this, Keys.SPRING_SESSION_ATTRIBUTES__SPRING_SESSION_ATTRIBUTES_FK); + if (_springSession == null) + _springSession = new SpringSession(this, Keys.SPRING_SESSION_ATTRIBUTES__SPRING_SESSION_ATTRIBUTES_FK); + + return _springSession; } @Override diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/ExtensionVersionRecord.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/ExtensionVersionRecord.java index 31570dcab..0e4d18fe8 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/ExtensionVersionRecord.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/ExtensionVersionRecord.java @@ -369,6 +369,20 @@ public String getTargetPlatform() { return (String) get(24); } + /** + * Setter for public.extension_version.sponsor_link. + */ + public void setSponsorLink(String value) { + set(25, value); + } + + /** + * Getter for public.extension_version.sponsor_link. + */ + public String getSponsorLink() { + return (String) get(25); + } + // ------------------------------------------------------------------------- // Primary key information // ------------------------------------------------------------------------- @@ -392,7 +406,7 @@ public ExtensionVersionRecord() { /** * Create a detached, initialised ExtensionVersionRecord */ - public ExtensionVersionRecord(Long id, String bugs, String description, String displayName, String galleryColor, String galleryTheme, String homepage, String license, String markdown, Boolean preview, String qna, String repository, LocalDateTime timestamp, String version, Long extensionId, Long publishedWithId, Boolean active, String dependencies, String bundledExtensions, String engines, String categories, String tags, String extensionKind, Boolean preRelease, String targetPlatform) { + public ExtensionVersionRecord(Long id, String bugs, String description, String displayName, String galleryColor, String galleryTheme, String homepage, String license, String markdown, Boolean preview, String qna, String repository, LocalDateTime timestamp, String version, Long extensionId, Long publishedWithId, Boolean active, String dependencies, String bundledExtensions, String engines, String categories, String tags, String extensionKind, Boolean preRelease, String targetPlatform, String sponsorLink) { super(ExtensionVersion.EXTENSION_VERSION); setId(id); @@ -420,5 +434,6 @@ public ExtensionVersionRecord(Long id, String bugs, String description, String d setExtensionKind(extensionKind); setPreRelease(preRelease); setTargetPlatform(targetPlatform); + setSponsorLink(sponsorLink); } } diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/FileResourceRecord.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/FileResourceRecord.java index 8203f55f1..8fa2ce38c 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/FileResourceRecord.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/FileResourceRecord.java @@ -7,8 +7,8 @@ import org.eclipse.openvsx.jooq.tables.FileResource; import org.jooq.Field; import org.jooq.Record1; -import org.jooq.Record6; -import org.jooq.Row6; +import org.jooq.Record7; +import org.jooq.Row7; import org.jooq.impl.UpdatableRecordImpl; @@ -16,7 +16,7 @@ * This class is generated by jOOQ. */ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class FileResourceRecord extends UpdatableRecordImpl implements Record6 { +public class FileResourceRecord extends UpdatableRecordImpl implements Record7 { private static final long serialVersionUID = 1L; @@ -104,6 +104,20 @@ public String getStorageType() { return (String) get(5); } + /** + * Setter for public.file_resource.content_type. + */ + public void setContentType(String value) { + set(6, value); + } + + /** + * Getter for public.file_resource.content_type. + */ + public String getContentType() { + return (String) get(6); + } + // ------------------------------------------------------------------------- // Primary key information // ------------------------------------------------------------------------- @@ -114,17 +128,17 @@ public Record1 key() { } // ------------------------------------------------------------------------- - // Record6 type implementation + // Record7 type implementation // ------------------------------------------------------------------------- @Override - public Row6 fieldsRow() { - return (Row6) super.fieldsRow(); + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); } @Override - public Row6 valuesRow() { - return (Row6) super.valuesRow(); + public Row7 valuesRow() { + return (Row7) super.valuesRow(); } @Override @@ -157,6 +171,11 @@ public Field field6() { return FileResource.FILE_RESOURCE.STORAGE_TYPE; } + @Override + public Field field7() { + return FileResource.FILE_RESOURCE.CONTENT_TYPE; + } + @Override public Long component1() { return getId(); @@ -187,6 +206,11 @@ public String component6() { return getStorageType(); } + @Override + public String component7() { + return getContentType(); + } + @Override public Long value1() { return getId(); @@ -217,6 +241,11 @@ public String value6() { return getStorageType(); } + @Override + public String value7() { + return getContentType(); + } + @Override public FileResourceRecord value1(Long value) { setId(value); @@ -254,13 +283,20 @@ public FileResourceRecord value6(String value) { } @Override - public FileResourceRecord values(Long value1, String value2, byte[] value3, Long value4, String value5, String value6) { + public FileResourceRecord value7(String value) { + setContentType(value); + return this; + } + + @Override + public FileResourceRecord values(Long value1, String value2, byte[] value3, Long value4, String value5, String value6, String value7) { value1(value1); value2(value2); value3(value3); value4(value4); value5(value5); value6(value6); + value7(value7); return this; } @@ -278,7 +314,7 @@ public FileResourceRecord() { /** * Create a detached, initialised FileResourceRecord */ - public FileResourceRecord(Long id, String type, byte[] content, Long extensionId, String name, String storageType) { + public FileResourceRecord(Long id, String type, byte[] content, Long extensionId, String name, String storageType, String contentType) { super(FileResource.FILE_RESOURCE); setId(id); @@ -287,5 +323,6 @@ public FileResourceRecord(Long id, String type, byte[] content, Long extensionId setExtensionId(extensionId); setName(name); setStorageType(storageType); + setContentType(contentType); } } diff --git a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/NamespaceRecord.java b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/NamespaceRecord.java index 291477855..acbf8f3e1 100644 --- a/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/NamespaceRecord.java +++ b/server/src/main/jooq-gen/org/eclipse/openvsx/jooq/tables/records/NamespaceRecord.java @@ -7,8 +7,8 @@ import org.eclipse.openvsx.jooq.tables.Namespace; import org.jooq.Field; import org.jooq.Record1; -import org.jooq.Record3; -import org.jooq.Row3; +import org.jooq.Record10; +import org.jooq.Row10; import org.jooq.impl.UpdatableRecordImpl; @@ -16,7 +16,7 @@ * This class is generated by jOOQ. */ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class NamespaceRecord extends UpdatableRecordImpl implements Record3 { +public class NamespaceRecord extends UpdatableRecordImpl implements Record10 { private static final long serialVersionUID = 1L; @@ -62,6 +62,104 @@ public String getPublicId() { return (String) get(2); } + /** + * Setter for public.namespace.display_name. + */ + public void setDisplayName(String value) { + set(3, value); + } + + /** + * Getter for public.namespace.display_name. + */ + public String getDisplayName() { + return (String) get(3); + } + + /** + * Setter for public.namespace.description. + */ + public void setDescription(String value) { + set(4, value); + } + + /** + * Getter for public.namespace.description. + */ + public String getDescription() { + return (String) get(4); + } + + /** + * Setter for public.namespace.company_link. + */ + public void setCompanyLink(String value) { + set(5, value); + } + + /** + * Getter for public.namespace.company_link. + */ + public String getCompanyLink() { + return (String) get(5); + } + + /** + * Setter for public.namespace.support_link. + */ + public void setSupportLink(String value) { + set(6, value); + } + + /** + * Getter for public.namespace.support_link. + */ + public String getSupportLink() { + return (String) get(6); + } + + /** + * Setter for public.namespace.logo_name. + */ + public void setLogoName(String value) { + set(7, value); + } + + /** + * Getter for public.namespace.logo_name. + */ + public String getLogoName() { + return (String) get(7); + } + + /** + * Setter for public.namespace.logo_bytes. + */ + public void setLogoBytes(byte[] value) { + set(8, value); + } + + /** + * Getter for public.namespace.logo_bytes. + */ + public byte[] getLogoBytes() { + return (byte[]) get(8); + } + + /** + * Setter for public.namespace.logo_storage_type. + */ + public void setLogoStorageType(String value) { + set(9, value); + } + + /** + * Getter for public.namespace.logo_storage_type. + */ + public String getLogoStorageType() { + return (String) get(9); + } + // ------------------------------------------------------------------------- // Primary key information // ------------------------------------------------------------------------- @@ -72,17 +170,17 @@ public Record1 key() { } // ------------------------------------------------------------------------- - // Record3 type implementation + // Record10 type implementation // ------------------------------------------------------------------------- @Override - public Row3 fieldsRow() { - return (Row3) super.fieldsRow(); + public Row10 fieldsRow() { + return (Row10) super.fieldsRow(); } @Override - public Row3 valuesRow() { - return (Row3) super.valuesRow(); + public Row10 valuesRow() { + return (Row10) super.valuesRow(); } @Override @@ -100,6 +198,41 @@ public Field field3() { return Namespace.NAMESPACE.PUBLIC_ID; } + @Override + public Field field4() { + return Namespace.NAMESPACE.DISPLAY_NAME; + } + + @Override + public Field field5() { + return Namespace.NAMESPACE.DESCRIPTION; + } + + @Override + public Field field6() { + return Namespace.NAMESPACE.COMPANY_LINK; + } + + @Override + public Field field7() { + return Namespace.NAMESPACE.SUPPORT_LINK; + } + + @Override + public Field field8() { + return Namespace.NAMESPACE.LOGO_NAME; + } + + @Override + public Field field9() { + return Namespace.NAMESPACE.LOGO_BYTES; + } + + @Override + public Field field10() { + return Namespace.NAMESPACE.LOGO_STORAGE_TYPE; + } + @Override public Long component1() { return getId(); @@ -115,6 +248,41 @@ public String component3() { return getPublicId(); } + @Override + public String component4() { + return getDisplayName(); + } + + @Override + public String component5() { + return getDescription(); + } + + @Override + public String component6() { + return getCompanyLink(); + } + + @Override + public String component7() { + return getSupportLink(); + } + + @Override + public String component8() { + return getLogoName(); + } + + @Override + public byte[] component9() { + return getLogoBytes(); + } + + @Override + public String component10() { + return getLogoStorageType(); + } + @Override public Long value1() { return getId(); @@ -130,6 +298,41 @@ public String value3() { return getPublicId(); } + @Override + public String value4() { + return getDisplayName(); + } + + @Override + public String value5() { + return getDescription(); + } + + @Override + public String value6() { + return getCompanyLink(); + } + + @Override + public String value7() { + return getSupportLink(); + } + + @Override + public String value8() { + return getLogoName(); + } + + @Override + public byte[] value9() { + return getLogoBytes(); + } + + @Override + public String value10() { + return getLogoStorageType(); + } + @Override public NamespaceRecord value1(Long value) { setId(value); @@ -149,10 +352,59 @@ public NamespaceRecord value3(String value) { } @Override - public NamespaceRecord values(Long value1, String value2, String value3) { + public NamespaceRecord value4(String value) { + setDisplayName(value); + return this; + } + + @Override + public NamespaceRecord value5(String value) { + setDescription(value); + return this; + } + + @Override + public NamespaceRecord value6(String value) { + setCompanyLink(value); + return this; + } + + @Override + public NamespaceRecord value7(String value) { + setSupportLink(value); + return this; + } + + @Override + public NamespaceRecord value8(String value) { + setLogoName(value); + return this; + } + + @Override + public NamespaceRecord value9(byte[] value) { + setLogoBytes(value); + return this; + } + + @Override + public NamespaceRecord value10(String value) { + setLogoStorageType(value); + return this; + } + + @Override + public NamespaceRecord values(Long value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, byte[] value9, String value10) { value1(value1); value2(value2); value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + value10(value10); return this; } @@ -170,11 +422,18 @@ public NamespaceRecord() { /** * Create a detached, initialised NamespaceRecord */ - public NamespaceRecord(Long id, String name, String publicId) { + public NamespaceRecord(Long id, String name, String publicId, String displayName, String description, String companyLink, String supportLink, String logoName, byte[] logoBytes, String logoStorageType) { super(Namespace.NAMESPACE); setId(id); setName(name); setPublicId(publicId); + setDisplayName(displayName); + setDescription(description); + setCompanyLink(companyLink); + setSupportLink(supportLink); + setLogoName(logoName); + setLogoBytes(logoBytes); + setLogoStorageType(logoStorageType); } } diff --git a/server/src/main/resources/db/migration/V1_29__FileResource_ContentType.sql b/server/src/main/resources/db/migration/V1_29__FileResource_ContentType.sql new file mode 100644 index 000000000..99c938250 --- /dev/null +++ b/server/src/main/resources/db/migration/V1_29__FileResource_ContentType.sql @@ -0,0 +1,7 @@ +ALTER TABLE file_resource ADD COLUMN content_type CHARACTER VARYING(255); + +INSERT INTO migration_item(id, migration_script, entity_id, migration_scheduled) +SELECT nextval('hibernate_sequence'), 'V1_29__FileResource_ContentType.sql', ev.id, FALSE +FROM extension_version ev +JOIN extension e ON e.id = ev.extension_id +ORDER BY e.download_count DESC; \ No newline at end of file diff --git a/server/src/test/java/org/eclipse/openvsx/RegistryAPITest.java b/server/src/test/java/org/eclipse/openvsx/RegistryAPITest.java index a007ff656..f2d244291 100644 --- a/server/src/test/java/org/eclipse/openvsx/RegistryAPITest.java +++ b/server/src/test/java/org/eclipse/openvsx/RegistryAPITest.java @@ -1882,6 +1882,7 @@ private FileResource mockReadme(String targetPlatform) { resource.setName("README"); resource.setType(FileResource.README); resource.setContent("Please read me".getBytes()); + resource.setContentType(MediaType.TEXT_PLAIN_VALUE); resource.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(resource)).thenReturn(resource); Mockito.when(repositories.findFileByName(extVersion, "README")) @@ -1896,6 +1897,7 @@ private FileResource mockChangelog() { resource.setName("CHANGELOG"); resource.setType(FileResource.CHANGELOG); resource.setContent("All notable changes is documented here".getBytes()); + resource.setContentType(MediaType.TEXT_PLAIN_VALUE); resource.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(resource)).thenReturn(resource); Mockito.when(repositories.findFileByName(extVersion, "CHANGELOG")) @@ -1910,6 +1912,7 @@ private FileResource mockLicense() { resource.setName("LICENSE"); resource.setType(FileResource.LICENSE); resource.setContent("I never broke the Law! I am the law!".getBytes()); + resource.setContentType(MediaType.TEXT_PLAIN_VALUE); resource.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(resource)).thenReturn(resource); Mockito.when(repositories.findFileByName(extVersion, "LICENSE")) diff --git a/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java b/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java index 6d49d0a4d..8192b40cf 100644 --- a/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java +++ b/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java @@ -17,7 +17,6 @@ import java.io.IOException; import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.*; @@ -55,6 +54,7 @@ import org.springframework.data.elasticsearch.core.SearchHitsImpl; import org.springframework.data.elasticsearch.core.TotalHitsRelation; import org.springframework.data.util.Streamable; +import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; import org.springframework.test.web.servlet.MockMvc; @@ -222,6 +222,7 @@ public void testAsset() throws Exception { mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.Manifest")) .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)) .andExpect(content().string("{\"foo\":\"bar\"}")); } @@ -232,6 +233,7 @@ public void testAssetMacOSX() throws Exception { mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}?targetPlatform={target}", "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.Manifest", target)) .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)) .andExpect(content().string("{\"foo\":\"bar\",\"target\":\"darwin-arm64\"}")); } @@ -245,6 +247,15 @@ public void testAssetNotFound() throws Exception { .andExpect(status().isNotFound()); } + @Test + public void testAssetVsixPackage() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Services.VSIXPackage")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/zip")); + } + @Test public void testGetItem() throws Exception { var extension = mockExtension(); @@ -256,14 +267,65 @@ public void testGetItem() throws Exception { } @Test - public void testWebResourceAsset() throws Exception { + public void testDefaultWebResourceAsset() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/resources/data.bin")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)) + .andExpect(content().string("data.bin")); + } + + @Test + public void testPngWebResourceAsset() throws Exception { mockExtensionVersion(); mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/img/logo.png")) .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)) .andExpect(content().string("logo.png")); } + @Test + public void testCssWebResourceAsset() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/public/static/css/main.css")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, "text/css")) + .andExpect(content().string(".main { margin: 0 auto; }")); + } + + @Test + public void testChunkCssWebResourceAsset() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/public/static/css/main.9cab4879.chunk.css")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, "text/css")) + .andExpect(content().string(".root { margin: 0 auto; }")); + } + + @Test + public void testJsWebResourceAsset() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/public/static/js/main.js")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/javascript")) + .andExpect(content().string("() => { console.log('main'); }")); + } + + @Test + public void testChunkJsWebResourceAsset() throws Exception { + mockExtensionVersion(); + mockMvc.perform(get("/vscode/asset/{namespace}/{extensionName}/{version}/{assetType}", + "redhat", "vscode-yaml", "0.5.2", "Microsoft.VisualStudio.Code.WebResources/extension/public/static/js/main.34d01954.chunk.js")) + .andExpect(status().isOk()) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, "application/javascript")) + .andExpect(content().string("() => { console.log('js'); }")); + } + @Test public void testNotWebResourceAsset() throws Exception { mockExtensionVersion(); @@ -348,12 +410,12 @@ public void testBrowseTopDir() throws Exception { Mockito.when(repositories.findActiveExtensionVersionsByVersion(version, extensionName, namespaceName)) .thenReturn(List.of(extVersion)); - var vsixResource = mockFileResource(15, extVersion, "extension.vsixmanifest", RESOURCE, STORAGE_DB, "".getBytes(StandardCharsets.UTF_8)); - var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, "{\"package\":\"json\"}".getBytes(StandardCharsets.UTF_8)); - var readmeResource = mockFileResource(17, extVersion, "extension/README.md", RESOURCE, STORAGE_DB, "README".getBytes(StandardCharsets.UTF_8)); - var changelogResource = mockFileResource(18, extVersion, "extension/CHANGELOG.md", RESOURCE, STORAGE_DB, "CHANGELOG".getBytes(StandardCharsets.UTF_8)); - var licenseResource = mockFileResource(19, extVersion, "extension/LICENSE.txt", RESOURCE, STORAGE_DB, "LICENSE".getBytes(StandardCharsets.UTF_8)); - var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, "ICON128".getBytes(StandardCharsets.UTF_8)); + var vsixResource = mockFileResource(15, extVersion, "extension.vsixmanifest", RESOURCE, STORAGE_DB, "".getBytes(StandardCharsets.UTF_8), "application/xml"); + var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, "{\"package\":\"json\"}".getBytes(StandardCharsets.UTF_8), "application/json"); + var readmeResource = mockFileResource(17, extVersion, "extension/README.md", RESOURCE, STORAGE_DB, "README".getBytes(StandardCharsets.UTF_8), "text/markdown"); + var changelogResource = mockFileResource(18, extVersion, "extension/CHANGELOG.md", RESOURCE, STORAGE_DB, "CHANGELOG".getBytes(StandardCharsets.UTF_8), "text/markdown"); + var licenseResource = mockFileResource(19, extVersion, "extension/LICENSE.txt", RESOURCE, STORAGE_DB, "LICENSE".getBytes(StandardCharsets.UTF_8), "text/plain"); + var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, "ICON128".getBytes(StandardCharsets.UTF_8), "image/png"); Mockito.when(repositories.findResourceFileResources(1L, "")) .thenReturn(List.of(vsixResource, manifestResource, readmeResource, changelogResource, licenseResource, iconResource)); @@ -385,7 +447,7 @@ public void testBrowseVsixManifest() throws Exception { .thenReturn(List.of(extVersion)); var content = "".getBytes(StandardCharsets.UTF_8); - var vsixResource = mockFileResource(15, extVersion, "extension.vsixmanifest", RESOURCE, STORAGE_DB, content); + var vsixResource = mockFileResource(15, extVersion, "extension.vsixmanifest", RESOURCE, STORAGE_DB, content, "application/xml"); Mockito.when(repositories.findResourceFileResources(1L, "extension.vsixmanifest")) .thenReturn(List.of(vsixResource)); @@ -420,7 +482,7 @@ public void testBrowseVsixManifestUniversal() throws Exception { .thenReturn(extVersions); var content = "".getBytes(StandardCharsets.UTF_8); - var vsixResource = mockFileResource(15, extVersions.get(0), "extension.vsixmanifest", RESOURCE, STORAGE_DB, content); + var vsixResource = mockFileResource(15, extVersions.get(0), "extension.vsixmanifest", RESOURCE, STORAGE_DB, content, "application/xml"); Mockito.when(repositories.findResourceFileResources(1L, "extension.vsixmanifest")) .thenReturn(List.of(vsixResource)); @@ -455,7 +517,7 @@ public void testBrowseVsixManifestWindows() throws Exception { .thenReturn(extVersions); var content = "".getBytes(StandardCharsets.UTF_8); - var vsixResource = mockFileResource(15, extVersions.get(2), "extension.vsixmanifest", RESOURCE, STORAGE_DB, content); + var vsixResource = mockFileResource(15, extVersions.get(2), "extension.vsixmanifest", RESOURCE, STORAGE_DB, content, "application/xml"); Mockito.when(repositories.findResourceFileResources(4L, "extension.vsixmanifest")) .thenReturn(List.of(vsixResource)); @@ -484,11 +546,11 @@ public void testBrowseExtensionDir() throws Exception { Mockito.when(repositories.findActiveExtensionVersionsByVersion(version, extensionName, namespaceName)) .thenReturn(List.of(extVersion)); - var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, "{\"package\":\"json\"}".getBytes(StandardCharsets.UTF_8)); - var readmeResource = mockFileResource(17, extVersion, "extension/README.md", RESOURCE, STORAGE_DB, "README".getBytes(StandardCharsets.UTF_8)); - var changelogResource = mockFileResource(18, extVersion, "extension/CHANGELOG.md", RESOURCE, STORAGE_DB, "CHANGELOG".getBytes(StandardCharsets.UTF_8)); - var licenseResource = mockFileResource(19, extVersion, "extension/LICENSE.txt", RESOURCE, STORAGE_DB, "LICENSE".getBytes(StandardCharsets.UTF_8)); - var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, "ICON128".getBytes(StandardCharsets.UTF_8)); + var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, "{\"package\":\"json\"}".getBytes(StandardCharsets.UTF_8), "application/json"); + var readmeResource = mockFileResource(17, extVersion, "extension/README.md", RESOURCE, STORAGE_DB, "README".getBytes(StandardCharsets.UTF_8), "text/markdown"); + var changelogResource = mockFileResource(18, extVersion, "extension/CHANGELOG.md", RESOURCE, STORAGE_DB, "CHANGELOG".getBytes(StandardCharsets.UTF_8), "text/markdown"); + var licenseResource = mockFileResource(19, extVersion, "extension/LICENSE.txt", RESOURCE, STORAGE_DB, "LICENSE".getBytes(StandardCharsets.UTF_8), "text/plain"); + var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, "ICON128".getBytes(StandardCharsets.UTF_8), "image/png"); Mockito.when(repositories.findResourceFileResources(1L, "extension")) .thenReturn(List.of(manifestResource, readmeResource, changelogResource, licenseResource, iconResource)); @@ -524,7 +586,7 @@ public void testBrowsePackageJson() throws Exception { .thenReturn(List.of(extVersion)); var content = "{\"package\":\"json\"}".getBytes(StandardCharsets.UTF_8); - var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, content); + var manifestResource = mockFileResource(16, extVersion, "extension/package.json", RESOURCE, STORAGE_DB, content, "application/json"); Mockito.when(repositories.findResourceFileResources(1L, "extension/package.json")) .thenReturn(List.of(manifestResource)); @@ -553,7 +615,7 @@ public void testBrowseImagesDir() throws Exception { .thenReturn(List.of(extVersion)); var content = "ICON128".getBytes(StandardCharsets.UTF_8); - var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, content); + var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, content, "image/png"); Mockito.when(repositories.findResourceFileResources(1L, "extension/images")) .thenReturn(List.of(iconResource)); @@ -583,7 +645,7 @@ public void testBrowseIcon() throws Exception { .thenReturn(List.of(extVersion)); var content = "ICON128".getBytes(StandardCharsets.UTF_8); - var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, content); + var iconResource = mockFileResource(20, extVersion, "extension/images/icon128.png", RESOURCE, STORAGE_DB, content, "image/png"); Mockito.when(repositories.findResourceFileResources(1L, "extension/images/icon128.png")) .thenReturn(List.of(iconResource)); @@ -745,10 +807,11 @@ private FileResource mockFileResource(long id, ExtensionVersion extVersion, Stri return resource; } - private FileResource mockFileResource(long id, ExtensionVersion extVersion, String name, String type, String storageType, byte[] content) { + private FileResource mockFileResource(long id, ExtensionVersion extVersion, String name, String type, String storageType, byte[] content, String contentType) { var resource = mockFileResource(id, extVersion, name, type); resource.setStorageType(storageType); resource.setContent(content); + resource.setContentType(contentType); return resource; } @@ -771,6 +834,7 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json extension.setAverageRating(3.0); extension.setNamespace(namespace); var extVersion = new ExtensionVersion(); + extVersion.setExtension(extension); extension.getVersions().add(extVersion); extVersion.setTargetPlatform(targetPlatform); extVersion.setVersion("0.5.2"); @@ -792,13 +856,14 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json Mockito.when(repositories.findVersions(extension)) .thenReturn(Streamable.of(extVersion)); Mockito.when(repositories.countMemberships(namespace, NamespaceMembership.ROLE_OWNER)) - .thenReturn(0l); + .thenReturn(0L); Mockito.when(repositories.countActiveReviews(extension)) - .thenReturn(10l); + .thenReturn(10L); var extensionFile = new FileResource(); extensionFile.setExtension(extVersion); extensionFile.setName("redhat.vscode-yaml-0.5.2.vsix"); extensionFile.setType(FileResource.DOWNLOAD); + extensionFile.setContentType("application/zip"); extensionFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(extensionFile)).thenReturn(extensionFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.DOWNLOAD)) @@ -812,6 +877,7 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json if(!targetPlatform.equals(TargetPlatform.NAME_UNIVERSAL)) manifestContent.put("target", targetPlatform); manifestFile.setContent(new ObjectMapper().writeValueAsBytes(manifestContent)); + manifestFile.setContentType(MediaType.APPLICATION_JSON_VALUE); manifestFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(manifestFile)).thenReturn(manifestFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.MANIFEST)) @@ -820,6 +886,7 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json readmeFile.setExtension(extVersion); readmeFile.setName("README.md"); readmeFile.setType(FileResource.README); + readmeFile.setContentType("text/markdown"); readmeFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(readmeFile)).thenReturn(readmeFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.README)) @@ -828,6 +895,7 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json changelogFile.setExtension(extVersion); changelogFile.setName("CHANGELOG.md"); changelogFile.setType(FileResource.CHANGELOG); + changelogFile.setContentType("text/markdown"); changelogFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(changelogFile)).thenReturn(changelogFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.CHANGELOG)) @@ -836,6 +904,7 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json licenseFile.setExtension(extVersion); licenseFile.setName("LICENSE.txt"); licenseFile.setType(FileResource.LICENSE); + licenseFile.setContentType(MediaType.TEXT_PLAIN_VALUE); licenseFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(licenseFile)).thenReturn(licenseFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.LICENSE)) @@ -844,19 +913,71 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json iconFile.setExtension(extVersion); iconFile.setName("icon128.png"); iconFile.setType(FileResource.ICON); + iconFile.setContentType(MediaType.IMAGE_PNG_VALUE); iconFile.setStorageType(FileResource.STORAGE_DB); Mockito.when(entityManager.merge(iconFile)).thenReturn(iconFile); Mockito.when(repositories.findFileByType(extVersion, FileResource.ICON)) .thenReturn(iconFile); - var webResourceFile = new FileResource(); - webResourceFile.setExtension(extVersion); - webResourceFile.setName("extension/img/logo.png"); - webResourceFile.setType(FileResource.RESOURCE); - webResourceFile.setStorageType(STORAGE_DB); - webResourceFile.setContent("logo.png".getBytes()); - Mockito.when(entityManager.merge(webResourceFile)).thenReturn(webResourceFile); + var binWebResourceFile = new FileResource(); + binWebResourceFile.setExtension(extVersion); + binWebResourceFile.setName("extension/resources/data.bin"); + binWebResourceFile.setType(FileResource.RESOURCE); + binWebResourceFile.setStorageType(STORAGE_DB); + binWebResourceFile.setContent("data.bin".getBytes()); + binWebResourceFile.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + Mockito.when(entityManager.merge(binWebResourceFile)).thenReturn(binWebResourceFile); + Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/resources/data.bin")) + .thenReturn(binWebResourceFile); + var pngWebResourceFile = new FileResource(); + pngWebResourceFile.setExtension(extVersion); + pngWebResourceFile.setName("extension/img/logo.png"); + pngWebResourceFile.setType(FileResource.RESOURCE); + pngWebResourceFile.setStorageType(STORAGE_DB); + pngWebResourceFile.setContent("logo.png".getBytes()); + pngWebResourceFile.setContentType(MediaType.IMAGE_PNG_VALUE); + Mockito.when(entityManager.merge(pngWebResourceFile)).thenReturn(pngWebResourceFile); Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/img/logo.png")) - .thenReturn(webResourceFile); + .thenReturn(pngWebResourceFile); + var jsWebResourceFile = new FileResource(); + jsWebResourceFile.setExtension(extVersion); + jsWebResourceFile.setName("extension/public/static/js/main.js"); + jsWebResourceFile.setType(FileResource.RESOURCE); + jsWebResourceFile.setStorageType(STORAGE_DB); + jsWebResourceFile.setContent("() => { console.log('main'); }".getBytes()); + jsWebResourceFile.setContentType("application/javascript"); + Mockito.when(entityManager.merge(jsWebResourceFile)).thenReturn(jsWebResourceFile); + Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/public/static/js/main.js")) + .thenReturn(jsWebResourceFile); + var jsChunkWebResourceFile = new FileResource(); + jsChunkWebResourceFile.setExtension(extVersion); + jsChunkWebResourceFile.setName("extension/public/static/js/main.34d01954.chunk.js"); + jsChunkWebResourceFile.setType(FileResource.RESOURCE); + jsChunkWebResourceFile.setStorageType(STORAGE_DB); + jsChunkWebResourceFile.setContent("() => { console.log('js'); }".getBytes()); + jsChunkWebResourceFile.setContentType("application/javascript"); + Mockito.when(entityManager.merge(jsChunkWebResourceFile)).thenReturn(jsChunkWebResourceFile); + Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/public/static/js/main.34d01954.chunk.js")) + .thenReturn(jsChunkWebResourceFile); + var cssWebResourceFile = new FileResource(); + cssWebResourceFile.setExtension(extVersion); + cssWebResourceFile.setName("extension/public/static/css/main.css"); + cssWebResourceFile.setType(FileResource.RESOURCE); + cssWebResourceFile.setStorageType(STORAGE_DB); + cssWebResourceFile.setContent(".main { margin: 0 auto; }".getBytes()); + cssWebResourceFile.setContentType("text/css"); + Mockito.when(entityManager.merge(cssWebResourceFile)).thenReturn(cssWebResourceFile); + Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/public/static/css/main.css")) + .thenReturn(cssWebResourceFile); + var cssChunkWebResourceFile = new FileResource(); + cssChunkWebResourceFile.setExtension(extVersion); + cssChunkWebResourceFile.setName("extension/public/static/css/main.9cab4879.chunk.css"); + cssChunkWebResourceFile.setType(FileResource.RESOURCE); + cssChunkWebResourceFile.setStorageType(STORAGE_DB); + cssChunkWebResourceFile.setContent(".root { margin: 0 auto; }".getBytes()); + cssChunkWebResourceFile.setContentType("text/css"); + Mockito.when(entityManager.merge(cssChunkWebResourceFile)).thenReturn(cssChunkWebResourceFile); + Mockito.when(repositories.findFileByTypeAndName(extVersion, FileResource.RESOURCE, "extension/public/static/css/main.9cab4879.chunk.css")) + .thenReturn(cssChunkWebResourceFile); Mockito.when(repositories.findFilesByType(anyCollection(), anyCollection())).thenAnswer(invocation -> { Collection extVersions = invocation.getArgument(0); var types = invocation.getArgument(1); @@ -869,10 +990,8 @@ private ExtensionVersion mockExtensionVersion(String targetPlatform) throws Json return extVersion; } - private String file(String name) throws UnsupportedEncodingException, IOException { - try ( - var stream = getClass().getResourceAsStream(name); - ) { + private String file(String name) throws IOException { + try (var stream = getClass().getResourceAsStream(name)) { return CharStreams.toString(new InputStreamReader(stream, "UTF-8")); } } diff --git a/server/src/test/java/org/eclipse/openvsx/repositories/RepositoryServiceSmokeTest.java b/server/src/test/java/org/eclipse/openvsx/repositories/RepositoryServiceSmokeTest.java index 84c693f2e..82808c2b5 100644 --- a/server/src/test/java/org/eclipse/openvsx/repositories/RepositoryServiceSmokeTest.java +++ b/server/src/test/java/org/eclipse/openvsx/repositories/RepositoryServiceSmokeTest.java @@ -146,6 +146,7 @@ void testExecuteQueries() { () -> repositories.findNotMigratedResources(), () -> repositories.findNotMigratedPreReleases(), () -> repositories.findNotMigratedRenamedDownloads(), + () -> repositories.findNotMigratedContentTypes(), () -> repositories.topMostActivePublishingUsers(NOW, 1), () -> repositories.topNamespaceExtensions(NOW, 1), () -> repositories.topNamespaceExtensionVersions(NOW, 1),