From 93aa90f8d24a43a4549bb4d350e4ce9dd5f5e09c Mon Sep 17 00:00:00 2001 From: Daniel Rudolph Date: Thu, 17 Oct 2024 15:55:24 +0200 Subject: [PATCH 1/4] fix: FixElasticSearchDeletedNodes: query never used after elastic migration 7->8 --- .../quartz/FixElasticSearchDeletedNodes.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Backend/services/core/src/main/java/org/edu_sharing/repository/server/jobs/quartz/FixElasticSearchDeletedNodes.java b/Backend/services/core/src/main/java/org/edu_sharing/repository/server/jobs/quartz/FixElasticSearchDeletedNodes.java index 0972d1e68..7a4581c1d 100644 --- a/Backend/services/core/src/main/java/org/edu_sharing/repository/server/jobs/quartz/FixElasticSearchDeletedNodes.java +++ b/Backend/services/core/src/main/java/org/edu_sharing/repository/server/jobs/quartz/FixElasticSearchDeletedNodes.java @@ -2,7 +2,7 @@ import co.elastic.clients.elasticsearch._types.Result; import co.elastic.clients.elasticsearch._types.Time; -import co.elastic.clients.elasticsearch._types.query_dsl.Query; +import co.elastic.clients.elasticsearch._types.query_dsl.*; import co.elastic.clients.elasticsearch.core.*; import co.elastic.clients.elasticsearch.core.search.Hit; import co.elastic.clients.elasticsearch.core.search.HitsMetadata; @@ -14,11 +14,13 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; +import org.apache.commons.text.StringEscapeUtils; import org.apache.log4j.Logger; import org.edu_sharing.alfrescocontext.gate.AlfAppContextGate; import org.edu_sharing.repository.server.jobs.quartz.annotation.JobDescription; import org.edu_sharing.repository.server.jobs.quartz.annotation.JobFieldDescription; import org.edu_sharing.repository.server.tools.ApplicationInfoList; +import org.edu_sharing.service.search.ReadableWrapperQueryBuilder; import org.edu_sharing.service.search.SearchServiceElastic; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -36,7 +38,7 @@ public class FixElasticSearchDeletedNodes extends AbstractJob{ @JobFieldDescription(description = "if false (default) no changes will be done.") boolean execute; - @JobFieldDescription(description = "query that delivers a result of nodes that have to be checked. optional. if not set all nodes will be searched.",sampleValue = "{\"query\":\"{\\\"term\\\":{\\\"type\\\":\\\"ccm:io\\\"}}\"}") + @JobFieldDescription(description = "query that delivers a result of nodes that have to be checked. optional. if not set all nodes will be searched.",sampleValue = "{\"term\":{\"type\":\"ccm:io\"}}") String query; SearchServiceElastic searchServiceElastic = new SearchServiceElastic(ApplicationInfoList.getHomeRepository().getAppId()); @@ -50,21 +52,24 @@ public class FixElasticSearchDeletedNodes extends AbstractJob{ NodeService nodeService = serviceRegistry.getNodeService(); @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { - execute = Boolean.parseBoolean( (String) jobExecutionContext.getJobDetail().getJobDataMap().get("execute")); + execute = (Boolean)jobExecutionContext.getJobDetail().getJobDataMap().get("execute"); query = (String)jobExecutionContext.getJobDetail().getJobDataMap().get("query"); + query = StringEscapeUtils.unescapeJson(query); + logger.info("query:" + query); - AuthenticationUtil.runAsSystem(()->{ - try { - ObjectBuilder queryBuilder = (query == null) ? new Query.Builder().matchAll(x -> x) : new Query.Builder().wrapper(wrapper -> wrapper.query(query)); - search(queryBuilder, new DeletedNodesHandler()); - } catch (IOException e) { - logger.error(e.getMessage(),e); - } - return null; - }); + AuthenticationUtil.runAsSystem(()->{ + try { + Query elQuery = (query == null) ? new Query.Builder().bool(new BoolQuery.Builder().must(q -> q.matchAll(all -> all)).build()).build() : new Query.Builder().wrapper(new ReadableWrapperQueryBuilder(query).build()).build(); + + search(elQuery, new DeletedNodesHandler()); + } catch (IOException e) { + logger.error(e.getMessage(),e); + } + return null; + }); } - private void search(ObjectBuilder queryBuilder, SearchResultHandler searchResultHandler) throws IOException{ + private void search(Query query, SearchResultHandler searchResultHandler) throws IOException{ logger.info("search with handler: "+searchResultHandler.getClass().getName()); Time scroll = Time.of(time->time.time("4h")); @@ -72,7 +77,7 @@ private void search(ObjectBuilder queryBuilder, SearchResultHandler searc int page = 0; do{ if(response == null) { - response = search(SearchServiceElastic.WORKSPACE_INDEX, queryBuilder, scroll); + response = search(SearchServiceElastic.WORKSPACE_INDEX, query, scroll); }else { response = scroll(scroll,response.scrollId()); } @@ -92,12 +97,13 @@ private void search(ObjectBuilder queryBuilder, SearchResultHandler searc - private SearchResponse search(String index, ObjectBuilder queryBuilder, Time scroll) throws IOException { + private SearchResponse search(String index, Query query, Time scroll) throws IOException { return searchServiceElastic.searchNative(SearchRequest.of(req->req .index(index) .size(pageSize) .source(src->src.filter(filter->filter.excludes("preview"))) - .scroll(scroll))); + .scroll(scroll) + .query(query))); } private ScrollResponse scroll(Time scroll, String scrollId) throws IOException { @@ -162,7 +168,7 @@ public void handleSearchHit(Hit searchHit) throws IOException { private void syncNestedCollections(String dbid) throws IOException { ObjectBuilder ioCollectionQuery = new Query.Builder().term(term -> term.field("collections.dbid").value(dbid)); - search(ioCollectionQuery, searchHit -> { + search(ioCollectionQuery.build(), searchHit -> { List> collections = (List>) searchHit.source().get("collections"); /** From e2ba6ffa68015cef91d905916a83261d57961274 Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Fri, 18 Oct 2024 14:09:07 +0200 Subject: [PATCH 2/4] fix:use CET/german timezone as default --- .../java/org/edu_sharing/repository/server/tools/DateTool.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend/services/core/src/main/java/org/edu_sharing/repository/server/tools/DateTool.java b/Backend/services/core/src/main/java/org/edu_sharing/repository/server/tools/DateTool.java index 64f7cf7fc..791b85130 100644 --- a/Backend/services/core/src/main/java/org/edu_sharing/repository/server/tools/DateTool.java +++ b/Backend/services/core/src/main/java/org/edu_sharing/repository/server/tools/DateTool.java @@ -48,7 +48,8 @@ public String formatDate(Long time,Integer dateStyle, Integer timeStyle){ }else{ df = DateFormat.getDateTimeInstance(dateStyle, timeStyle, new Locale(splittedLocale[0],splittedLocale[1])); } - + df.setTimeZone(TimeZone.getTimeZone("CET")); + try { From c4af790179450b6a40e733b5ac0de60c796a5132 Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Fri, 18 Oct 2024 15:10:41 +0200 Subject: [PATCH 3/4] fix:mark bulk mixed values for select --- .../mds-editor-widget-select.component.html | 4 +++- .../mds-editor-widget-select.component.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Frontend/src/app/features/mds/mds-editor/widgets/mds-editor-widget-select/mds-editor-widget-select.component.html b/Frontend/src/app/features/mds/mds-editor/widgets/mds-editor-widget-select/mds-editor-widget-select.component.html index 6935e53c7..f975b8dad 100644 --- a/Frontend/src/app/features/mds/mds-editor/widgets/mds-editor-widget-select/mds-editor-widget-select.component.html +++ b/Frontend/src/app/features/mds/mds-editor/widgets/mds-editor-widget-select/mds-editor-widget-select.component.html @@ -7,7 +7,9 @@ Date: Tue, 22 Oct 2024 11:46:37 +0200 Subject: [PATCH 4/4] fix:catch error if global permissions are missing --- .../authority-search-input/authority-search-input.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/Frontend/src/app/shared/components/authority-search-input/authority-search-input.component.ts b/Frontend/src/app/shared/components/authority-search-input/authority-search-input.component.ts index bd164de0d..2a859f7b4 100644 --- a/Frontend/src/app/shared/components/authority-search-input/authority-search-input.component.ts +++ b/Frontend/src/app/shared/components/authority-search-input/authority-search-input.component.ts @@ -195,6 +195,7 @@ export class AuthoritySearchInputComponent { label: 'WORKSPACE.INVITE_GLOBAL_RESULTS', values: this.convertData(authorities), })), + catchError(() => of({ values: [] } as SuggestionGroup)), ), ); }