Search in sources :

Example 1 with SearchEntryJson

use of org.eclipse.openvsx.json.SearchEntryJson in project openvsx by eclipse.

the class LocalRegistryService method toSearchEntry.

private SearchEntryJson toSearchEntry(SearchHit<ExtensionSearch> searchHit, String serverUrl, ISearchService.Options options) {
    var searchItem = searchHit.getContent();
    var extension = entityManager.find(Extension.class, searchItem.id);
    if (extension == null || !extension.isActive()) {
        extension = new Extension();
        extension.setId(searchItem.id);
        search.removeSearchEntry(extension);
        return null;
    }
    var extVer = extension.getLatest();
    var entry = extVer.toSearchEntryJson();
    entry.url = createApiUrl(serverUrl, "api", entry.namespace, entry.name);
    entry.files = Maps.newLinkedHashMapWithExpectedSize(2);
    storageUtil.addFileUrls(extVer, serverUrl, entry.files, DOWNLOAD, ICON);
    if (options.includeAllVersions) {
        var allVersions = Lists.newArrayList(repositories.findActiveVersions(extension));
        Collections.sort(allVersions, ExtensionVersion.SORT_COMPARATOR);
        entry.allVersions = CollectionUtil.map(allVersions, ev -> toVersionReference(ev, entry, serverUrl));
    }
    return entry;
}
Also used : Extension(org.eclipse.openvsx.entities.Extension) Autowired(org.springframework.beans.factory.annotation.Autowired) QueryParamJson(org.eclipse.openvsx.json.QueryParamJson) CacheControl(org.springframework.http.CacheControl) ExtensionSearch(org.eclipse.openvsx.search.ExtensionSearch) ISearchService(org.eclipse.openvsx.search.ISearchService) FileResource(org.eclipse.openvsx.entities.FileResource) Namespace(org.eclipse.openvsx.entities.Namespace) ReviewJson(org.eclipse.openvsx.json.ReviewJson) ExtensionJson(org.eclipse.openvsx.json.ExtensionJson) SearchUtilService(org.eclipse.openvsx.search.SearchUtilService) ResponseStatusException(org.springframework.web.server.ResponseStatusException) Transactional(javax.transaction.Transactional) PageRequest(org.springframework.data.domain.PageRequest) ExtensionReview(org.eclipse.openvsx.entities.ExtensionReview) Collectors(java.util.stream.Collectors) Stream(java.util.stream.Stream) Maps(org.apache.jena.ext.com.google.common.collect.Maps) org.eclipse.openvsx.dto(org.eclipse.openvsx.dto) CollectionUtil(org.eclipse.openvsx.util.CollectionUtil) QueryResultJson(org.eclipse.openvsx.json.QueryResultJson) NamespaceMembership(org.eclipse.openvsx.entities.NamespaceMembership) java.util(java.util) Iterables(com.google.common.collect.Iterables) ExtensionVersion(org.eclipse.openvsx.entities.ExtensionVersion) ReviewListJson(org.eclipse.openvsx.json.ReviewListJson) ErrorResultException(org.eclipse.openvsx.util.ErrorResultException) UrlUtil(org.eclipse.openvsx.util.UrlUtil) TimeUtil(org.eclipse.openvsx.util.TimeUtil) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) NamespaceJson(org.eclipse.openvsx.json.NamespaceJson) NotFoundException(org.eclipse.openvsx.util.NotFoundException) SearchHit(org.springframework.data.elasticsearch.core.SearchHit) UrlUtil.createApiUrl(org.eclipse.openvsx.util.UrlUtil.createApiUrl) Extension(org.eclipse.openvsx.entities.Extension) SearchHits(org.springframework.data.elasticsearch.core.SearchHits) SemanticVersion(org.eclipse.openvsx.util.SemanticVersion) EntityManager(javax.persistence.EntityManager) ResultJson(org.eclipse.openvsx.json.ResultJson) TimeUnit(java.util.concurrent.TimeUnit) SearchResultJson(org.eclipse.openvsx.json.SearchResultJson) RepositoryService(org.eclipse.openvsx.repositories.RepositoryService) HttpStatus(org.springframework.http.HttpStatus) Component(org.springframework.stereotype.Component) SearchEntryJson(org.eclipse.openvsx.json.SearchEntryJson) ResponseEntity(org.springframework.http.ResponseEntity) EclipseService(org.eclipse.openvsx.eclipse.EclipseService) InputStream(java.io.InputStream) StorageUtilService(org.eclipse.openvsx.storage.StorageUtilService)

Aggregations

Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 InputStream (java.io.InputStream)1 java.util (java.util)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 EntityManager (javax.persistence.EntityManager)1 Transactional (javax.transaction.Transactional)1 Maps (org.apache.jena.ext.com.google.common.collect.Maps)1 org.eclipse.openvsx.dto (org.eclipse.openvsx.dto)1 EclipseService (org.eclipse.openvsx.eclipse.EclipseService)1 Extension (org.eclipse.openvsx.entities.Extension)1 ExtensionReview (org.eclipse.openvsx.entities.ExtensionReview)1 ExtensionVersion (org.eclipse.openvsx.entities.ExtensionVersion)1 FileResource (org.eclipse.openvsx.entities.FileResource)1 Namespace (org.eclipse.openvsx.entities.Namespace)1 NamespaceMembership (org.eclipse.openvsx.entities.NamespaceMembership)1 ExtensionJson (org.eclipse.openvsx.json.ExtensionJson)1