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"); /** 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 { 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 @@ of({ values: [] } as SuggestionGroup)), ), ); }