You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2019/07/21 10:24:39 UTC
[syncope] branch master updated (c880152 -> ccf3091)
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git.
from c880152 Restoring Camel scripting features for Groovy
new fc974e1 Upgrading Jackson, Highlight.js and JUnit
new ccf3091 Elasticsearch: remove usage of deprecated methods + adjust with dynamic domain management
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../client/ElasticsearchIndexManager.java | 85 ++++++++++++++--
.../elasticsearch/client/ElasticsearchUtils.java | 5 +-
.../core/persistence/jpa/DomainIndexLoader.java | 40 +++++---
.../jpa/dao/ElasticsearchAnySearchDAO.java | 3 +-
.../java/job/ElasticsearchReindex.java | 107 +++++----------------
.../syncope/core/logic/init/ElasticsearchInit.java | 21 ++--
.../apache/syncope/fit/core/KeymasterITCase.java | 9 ++
.../org/apache/syncope/fit/core/SearchITCase.java | 8 ++
pom.xml | 8 +-
src/site/xdoc/release-process.xml | 8 +-
10 files changed, 165 insertions(+), 129 deletions(-)
copy core/idrepo/logic/src/main/java/org/apache/syncope/core/logic/init/IdRepoEntitlementLoader.java => ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/DomainIndexLoader.java (51%)
[syncope] 02/02: Elasticsearch: remove usage of deprecated methods
+ adjust with dynamic domain management
Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit ccf3091eff236d5a2ce5ba063e794ab196256246
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Sun Jul 21 12:24:21 2019 +0200
Elasticsearch: remove usage of deprecated methods + adjust with dynamic domain management
---
.../client/ElasticsearchIndexManager.java | 85 ++++++++++++++--
.../elasticsearch/client/ElasticsearchUtils.java | 5 +-
.../core/persistence/jpa/DomainIndexLoader.java | 60 ++++++++++++
.../jpa/dao/ElasticsearchAnySearchDAO.java | 3 +-
.../java/job/ElasticsearchReindex.java | 107 +++++----------------
.../syncope/core/logic/init/ElasticsearchInit.java | 21 ++--
.../apache/syncope/fit/core/KeymasterITCase.java | 9 ++
.../org/apache/syncope/fit/core/SearchITCase.java | 8 ++
8 files changed, 193 insertions(+), 105 deletions(-)
diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchIndexManager.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchIndexManager.java
index 914e951..a854a318 100644
--- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchIndexManager.java
+++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchIndexManager.java
@@ -19,19 +19,29 @@
package org.apache.syncope.ext.elasticsearch.client;
import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.provisioning.api.event.AnyCreatedUpdatedEvent;
import org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -50,19 +60,77 @@ public class ElasticsearchIndexManager {
@Autowired
private ElasticsearchUtils elasticsearchUtils;
+ public boolean existsIndex(final String domain, final AnyTypeKind kind) throws IOException {
+ return client.indices().exists(
+ new GetIndexRequest(elasticsearchUtils.getContextDomainName(domain, kind)), RequestOptions.DEFAULT);
+ }
+
+ public void createIndex(final String domain, final AnyTypeKind kind)
+ throws InterruptedException, ExecutionException, IOException {
+
+ XContentBuilder settings = XContentFactory.jsonBuilder().
+ startObject().
+ startObject("analysis").
+ startObject("analyzer").
+ startObject("string_lowercase").
+ field("type", "custom").
+ field("tokenizer", "standard").
+ field("filter").
+ startArray().
+ value("lowercase").
+ endArray().
+ endObject().
+ endObject().
+ endObject().
+ startObject("index").
+ field("number_of_shards", elasticsearchUtils.getNumberOfShards()).
+ field("number_of_replicas", elasticsearchUtils.getNumberOfReplicas()).
+ endObject().
+ endObject();
+
+ XContentBuilder mapping = XContentFactory.jsonBuilder().
+ startObject().
+ startArray("dynamic_templates").
+ startObject().
+ startObject("strings").
+ field("match_mapping_type", "string").
+ startObject("mapping").
+ field("type", "keyword").
+ field("analyzer", "string_lowercase").
+ endObject().
+ endObject().
+ endObject().
+ endArray().
+ endObject();
+
+ CreateIndexResponse response = client.indices().create(
+ new CreateIndexRequest(elasticsearchUtils.getContextDomainName(domain, kind)).
+ settings(settings).
+ mapping(mapping), RequestOptions.DEFAULT);
+ LOG.debug("Successfully created {} for {}: {}",
+ elasticsearchUtils.getContextDomainName(domain, kind), kind.name(), response);
+ }
+
+ public void removeIndex(final String domain, final AnyTypeKind kind) throws IOException {
+ AcknowledgedResponse acknowledgedResponse = client.indices().delete(
+ new DeleteIndexRequest(elasticsearchUtils.getContextDomainName(domain, kind)), RequestOptions.DEFAULT);
+ LOG.debug("Successfully removed {}: {}",
+ elasticsearchUtils.getContextDomainName(domain, kind), acknowledgedResponse);
+ }
+
@TransactionalEventListener
public void after(final AnyCreatedUpdatedEvent<Any<?>> event) throws IOException {
GetRequest getRequest = new GetRequest(
- elasticsearchUtils.getContextDomainName(event.getAny().getType().getKind()),
- event.getAny().getType().getKind().name(),
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), event.getAny().getType().getKind()),
event.getAny().getKey());
GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);
if (getResponse.isExists()) {
LOG.debug("About to update index for {}", event.getAny());
UpdateRequest request = new UpdateRequest(
- elasticsearchUtils.getContextDomainName(event.getAny().getType().getKind()),
- event.getAny().getType().getKind().name(),
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), event.getAny().getType().getKind()),
event.getAny().getKey()).
retryOnConflict(elasticsearchUtils.getRetryOnConflict()).
doc(elasticsearchUtils.builder(event.getAny()));
@@ -72,9 +140,9 @@ public class ElasticsearchIndexManager {
LOG.debug("About to create index for {}", event.getAny());
IndexRequest request = new IndexRequest(
- elasticsearchUtils.getContextDomainName(event.getAny().getType().getKind()),
- event.getAny().getType().getKind().name(),
- event.getAny().getKey()).
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), event.getAny().getType().getKind())).
+ id(event.getAny().getKey()).
source(elasticsearchUtils.builder(event.getAny()));
IndexResponse response = client.index(request, RequestOptions.DEFAULT);
LOG.debug("Index successfully created for {}: {}", event.getAny(), response);
@@ -86,8 +154,7 @@ public class ElasticsearchIndexManager {
LOG.debug("About to delete index for {}[{}]", event.getAnyTypeKind(), event.getAnyKey());
DeleteRequest request = new DeleteRequest(
- elasticsearchUtils.getContextDomainName(event.getAnyTypeKind()),
- event.getAnyTypeKind().name(),
+ elasticsearchUtils.getContextDomainName(AuthContextUtils.getDomain(), event.getAnyTypeKind()),
event.getAnyKey());
DeleteResponse response = client.delete(request, RequestOptions.DEFAULT);
LOG.debug("Index successfully deleted for {}[{}]: {}",
diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
index 2f64eb7..73f6436 100644
--- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
+++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
@@ -34,7 +34,6 @@ import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -209,7 +208,7 @@ public class ElasticsearchUtils {
return builder.endObject();
}
- public String getContextDomainName(final AnyTypeKind kind) {
- return AuthContextUtils.getDomain().toLowerCase() + "_" + kind.name().toLowerCase();
+ public String getContextDomainName(final String domain, final AnyTypeKind kind) {
+ return domain.toLowerCase() + "_" + kind.name().toLowerCase();
}
}
diff --git a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/DomainIndexLoader.java b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/DomainIndexLoader.java
new file mode 100644
index 0000000..1697683
--- /dev/null
+++ b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/DomainIndexLoader.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa;
+
+import javax.sql.DataSource;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.core.persistence.api.SyncopeCoreLoader;
+import org.apache.syncope.ext.elasticsearch.client.ElasticsearchIndexManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.Ordered;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DomainIndexLoader implements SyncopeCoreLoader {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DomainIndexLoader.class);
+
+ @Autowired
+ private ElasticsearchIndexManager indexManager;
+
+ @Override
+ public int getOrder() {
+ return Ordered.LOWEST_PRECEDENCE;
+ }
+
+ @Override
+ public void load(final String domain, final DataSource datasource) {
+ try {
+ if (!indexManager.existsIndex(domain, AnyTypeKind.USER)) {
+ indexManager.createIndex(domain, AnyTypeKind.USER);
+ }
+ if (!indexManager.existsIndex(domain, AnyTypeKind.GROUP)) {
+ indexManager.createIndex(domain, AnyTypeKind.GROUP);
+ }
+ if (!indexManager.existsIndex(domain, AnyTypeKind.ANY_OBJECT)) {
+ indexManager.createIndex(domain, AnyTypeKind.ANY_OBJECT);
+ }
+ } catch (Exception e) {
+ LOG.error("While creating index for domain {}", domain, e);
+ }
+ }
+}
diff --git a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
index f6dccee..63a7688 100644
--- a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
+++ b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
@@ -56,6 +56,7 @@ import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Realm;
import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.apache.syncope.ext.elasticsearch.client.ElasticsearchUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchType;
@@ -139,7 +140,7 @@ public class ElasticsearchAnySearchDAO extends AbstractAnySearchDAO {
size(size);
sortBuilders.forEach(sort -> sourceBuilder.sort(sort));
- return new SearchRequest(elasticsearchUtils.getContextDomainName(kind)).
+ return new SearchRequest(elasticsearchUtils.getContextDomainName(AuthContextUtils.getDomain(), kind)).
searchType(SearchType.QUERY_THEN_FETCH).
source(sourceBuilder);
}
diff --git a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
index eea2a8f..8b8c3f4 100644
--- a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
+++ b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
@@ -18,8 +18,6 @@
*/
package org.apache.syncope.core.provisioning.java.job;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.core.persistence.api.dao.AnyDAO;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
@@ -30,18 +28,12 @@ import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.spring.security.AuthContextUtils;
+import org.apache.syncope.ext.elasticsearch.client.ElasticsearchIndexManager;
import org.apache.syncope.ext.elasticsearch.client.ElasticsearchUtils;
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
-import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.common.xcontent.XContentFactory;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +46,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate {
private RestHighLevelClient client;
@Autowired
+ private ElasticsearchIndexManager indexManager;
+
+ @Autowired
private ElasticsearchUtils elasticsearchUtils;
@Autowired
@@ -71,22 +66,29 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate {
LOG.debug("Start rebuilding indexes");
try {
- removeIndexIfExists(AnyTypeKind.USER);
- removeIndexIfExists(AnyTypeKind.GROUP);
- removeIndexIfExists(AnyTypeKind.ANY_OBJECT);
+ if (indexManager.existsIndex(AuthContextUtils.getDomain(), AnyTypeKind.USER)) {
+ indexManager.removeIndex(AuthContextUtils.getDomain(), AnyTypeKind.USER);
+ }
+ indexManager.createIndex(AuthContextUtils.getDomain(), AnyTypeKind.USER);
- createIndex(AnyTypeKind.USER);
- createIndex(AnyTypeKind.GROUP);
- createIndex(AnyTypeKind.ANY_OBJECT);
+ if (indexManager.existsIndex(AuthContextUtils.getDomain(), AnyTypeKind.GROUP)) {
+ indexManager.removeIndex(AuthContextUtils.getDomain(), AnyTypeKind.GROUP);
+ }
+ indexManager.createIndex(AuthContextUtils.getDomain(), AnyTypeKind.GROUP);
+
+ if (indexManager.existsIndex(AuthContextUtils.getDomain(), AnyTypeKind.ANY_OBJECT)) {
+ indexManager.removeIndex(AuthContextUtils.getDomain(), AnyTypeKind.ANY_OBJECT);
+ }
+ indexManager.createIndex(AuthContextUtils.getDomain(), AnyTypeKind.ANY_OBJECT);
LOG.debug("Indexing users...");
for (int page = 1; page <= (userDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
for (User user : userDAO.findAll(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
IndexRequest request = new IndexRequest(
- elasticsearchUtils.getContextDomainName(AnyTypeKind.USER),
- AnyTypeKind.USER.name(),
- user.getKey()).
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), AnyTypeKind.USER)).
+ id(user.getKey()).
source(elasticsearchUtils.builder(user));
IndexResponse response = client.index(request, RequestOptions.DEFAULT);
LOG.debug("Index successfully created for {}: {}", user, response);
@@ -97,9 +99,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate {
for (int page = 1; page <= (groupDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
for (Group group : groupDAO.findAll(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
IndexRequest request = new IndexRequest(
- elasticsearchUtils.getContextDomainName(AnyTypeKind.GROUP),
- AnyTypeKind.GROUP.name(),
- group.getKey()).
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), AnyTypeKind.GROUP)).
+ id(group.getKey()).
source(elasticsearchUtils.builder(group));
IndexResponse response = client.index(request, RequestOptions.DEFAULT);
LOG.debug("Index successfully created for {}: {}", group, response);
@@ -110,9 +112,9 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate {
for (int page = 1; page <= (anyObjectDAO.count() / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
for (AnyObject anyObject : anyObjectDAO.findAll(page, AnyDAO.DEFAULT_PAGE_SIZE)) {
IndexRequest request = new IndexRequest(
- elasticsearchUtils.getContextDomainName(AnyTypeKind.ANY_OBJECT),
- AnyTypeKind.ANY_OBJECT.name(),
- anyObject.getKey()).
+ elasticsearchUtils.getContextDomainName(
+ AuthContextUtils.getDomain(), AnyTypeKind.ANY_OBJECT)).
+ id(anyObject.getKey()).
source(elasticsearchUtils.builder(anyObject));
IndexResponse response = client.index(request, RequestOptions.DEFAULT);
LOG.debug("Index successfully created for {}: {}", anyObject, response);
@@ -128,63 +130,6 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate {
return "SUCCESS";
}
- private void removeIndexIfExists(final AnyTypeKind kind) throws IOException {
- if (client.indices().exists(
- new GetIndexRequest().indices(elasticsearchUtils.getContextDomainName(kind)), RequestOptions.DEFAULT)) {
-
- AcknowledgedResponse acknowledgedResponse = client.indices().delete(
- new DeleteIndexRequest(elasticsearchUtils.getContextDomainName(kind)), RequestOptions.DEFAULT);
- LOG.debug("Successfully removed {}: {}",
- elasticsearchUtils.getContextDomainName(kind), acknowledgedResponse);
- }
- }
-
- private void createIndex(final AnyTypeKind kind)
- throws InterruptedException, ExecutionException, IOException {
-
- XContentBuilder settings = XContentFactory.jsonBuilder().
- startObject().
- startObject("analysis").
- startObject("analyzer").
- startObject("string_lowercase").
- field("type", "custom").
- field("tokenizer", "standard").
- field("filter").
- startArray().
- value("lowercase").
- endArray().
- endObject().
- endObject().
- endObject().
- startObject("index").
- field("number_of_shards", elasticsearchUtils.getNumberOfShards()).
- field("number_of_replicas", elasticsearchUtils.getNumberOfReplicas()).
- endObject().
- endObject();
-
- XContentBuilder mapping = XContentFactory.jsonBuilder().
- startObject().
- startArray("dynamic_templates").
- startObject().
- startObject("strings").
- field("match_mapping_type", "string").
- startObject("mapping").
- field("type", "keyword").
- field("analyzer", "string_lowercase").
- endObject().
- endObject().
- endObject().
- endArray().
- endObject();
-
- CreateIndexResponse response = client.indices().create(
- new CreateIndexRequest(elasticsearchUtils.getContextDomainName(kind)).
- settings(settings).
- mapping(kind.name(), mapping), RequestOptions.DEFAULT);
- LOG.debug("Successfully created {} for {}: {}",
- elasticsearchUtils.getContextDomainName(kind), kind.name(), response);
- }
-
@Override
protected boolean hasToBeRegistered(final TaskExec execution) {
return true;
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/core/logic/init/ElasticsearchInit.java b/fit/core-reference/src/main/java/org/apache/syncope/core/logic/init/ElasticsearchInit.java
index 4a9f0d4..f652f72 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/core/logic/init/ElasticsearchInit.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/core/logic/init/ElasticsearchInit.java
@@ -48,17 +48,16 @@ public class ElasticsearchInit {
public void init() {
Implementation reindex = implementationDAO.findByType(IdRepoImplementationType.TASKJOB_DELEGATE).
stream().
- filter(impl -> impl.getEngine() == ImplementationEngine.JAVA
- && ES_REINDEX.equals(impl.getBody())).
- findAny().orElse(null);
- if (reindex == null) {
- reindex = entityFactory.newEntity(Implementation.class);
- reindex.setKey(ES_REINDEX);
- reindex.setEngine(ImplementationEngine.JAVA);
- reindex.setType(IdRepoImplementationType.TASKJOB_DELEGATE);
- reindex.setBody(ES_REINDEX);
- reindex = implementationDAO.save(reindex);
- }
+ filter(impl -> impl.getEngine() == ImplementationEngine.JAVA && ES_REINDEX.equals(impl.getBody())).
+ findAny().
+ orElseGet(() -> {
+ Implementation impl = entityFactory.newEntity(Implementation.class);
+ impl.setKey(ES_REINDEX);
+ impl.setEngine(ImplementationEngine.JAVA);
+ impl.setType(IdRepoImplementationType.TASKJOB_DELEGATE);
+ impl.setBody(ES_REINDEX);
+ return implementationDAO.save(impl);
+ });
SchedTaskTO task = new SchedTaskTO();
task.setJobDelegate(reindex.getKey());
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/KeymasterITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/KeymasterITCase.java
index a07760e..02935dd 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/KeymasterITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/KeymasterITCase.java
@@ -52,6 +52,7 @@ import org.apache.syncope.common.rest.api.beans.AnyQuery;
import org.apache.syncope.common.rest.api.service.UserService;
import org.apache.syncope.core.spring.security.Encryptor;
import org.apache.syncope.fit.AbstractITCase;
+import org.apache.syncope.fit.ElasticsearchDetector;
import org.junit.jupiter.api.Test;
public class KeymasterITCase extends AbstractITCase {
@@ -273,6 +274,14 @@ public class KeymasterITCase extends AbstractITCase {
assertNotNull(user);
assertEquals("monteverdi", user.getUsername());
+ if (ElasticsearchDetector.isElasticSearchEnabled(syncopeService)) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ex) {
+ // ignore
+ }
+ }
+
users = userService.search(
new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).page(1).size(1).build());
assertNotNull(users);
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
index 0e1d261..ad0505b 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
@@ -541,6 +541,14 @@ public class SearchITCase extends AbstractITCase {
req.getPlainAttrs().add(new AttrPatch.Builder(attr("ctype", "ou=sample,o=isp")).build());
userService.update(req);
+ if (ElasticsearchDetector.isElasticSearchEnabled(syncopeService)) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ex) {
+ // ignore
+ }
+ }
+
try {
PagedResult<UserTO> users = userService.search(new AnyQuery.Builder().fiql(
SyncopeClient.getUserSearchConditionBuilder().is("ctype").equalTo("ou=sample%252Co=isp").query()).
[syncope] 01/02: Upgrading Jackson, Highlight.js and JUnit
Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit fc974e15fdc7752d5751ae7af349c4d1b1a52b74
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Sun Jul 21 07:52:28 2019 +0200
Upgrading Jackson, Highlight.js and JUnit
---
pom.xml | 8 ++++----
src/site/xdoc/release-process.xml | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/pom.xml b/pom.xml
index ddf0e08..7b0cacc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -391,7 +391,7 @@ under the License.
<cxf.version>3.3.2</cxf.version>
- <jackson.version>2.9.9</jackson.version>
+ <jackson.version>2.10.0.pr1</jackson.version>
<spring.version>5.1.8.RELEASE</spring.version>
<spring-security.version>5.1.5.RELEASE</spring-security.version>
@@ -436,7 +436,7 @@ under the License.
<h2.version>1.4.199</h2.version>
- <junit.version>5.5.0</junit.version>
+ <junit.version>5.5.1</junit.version>
<conf.directory>${project.build.directory}/test-classes</conf.directory>
<bundles.directory>${project.build.directory}/bundles</bundles.directory>
@@ -459,7 +459,7 @@ under the License.
<font-awesome.version>4.7.0</font-awesome.version>
<font-awesome.filename>font-awesome.min.css</font-awesome.filename>
<ionicons.version>2.0.1</ionicons.version>
- <highlightjs.version>9.8.0</highlightjs.version>
+ <highlightjs.version>9.15.8</highlightjs.version>
<codemirror.version>5.45.0</codemirror.version>
<googlediffmatchpath.version>895a9512bb</googlediffmatchpath.version>
<jsplumb.version>2.0.7</jsplumb.version>
@@ -910,7 +910,7 @@ under the License.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>${jackson.version}.1</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
diff --git a/src/site/xdoc/release-process.xml b/src/site/xdoc/release-process.xml
index d6f32dc..120207e 100644
--- a/src/site/xdoc/release-process.xml
+++ b/src/site/xdoc/release-process.xml
@@ -322,13 +322,13 @@ sed -i 's/\/syncope\/webjars\/jquery-ui-themes\/1.12.1\/smoothness\/jquery-ui.mi
# if releasing from 2_0_X
curl -o /tmp/schema_1_syncope2.html http://localhost:9080/syncope/schema_1_syncope2.html
-sed -i 's/\/syncope\/webjars\/highlightjs\/9.8.0\/styles\/default.min.css/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.8.0\/styles\/default.min.css/' /tmp/schema_1_syncope2.html
-sed -i 's/\/syncope\/webjars\/highlightjs\/9.8.0\/highlight.min.js/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.8.0\/highlight.min.js/' /tmp/schema_1_syncope2.html
+sed -i 's/\/syncope\/webjars\/highlightjs\/9.15.8\/styles\/default.min.css/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.15.8\/styles\/default.min.css/' /tmp/schema_1_syncope2.html
+sed -i 's/\/syncope\/webjars\/highlightjs\/9.15.8\/highlight.min.js/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.15.8\/highlight.min.js/' /tmp/schema_1_syncope2.html
# else if releasing from 2_1_X
curl -o /tmp/schema_1_syncope21.html http://localhost:9080/syncope/schema_1_syncope21.html
-sed -i 's/\/syncope\/webjars\/highlightjs\/9.8.0\/styles\/default.min.css/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.8.0\/styles\/default.min.css/' /tmp/schema_1_syncope21.html
-sed -i 's/\/syncope\/webjars\/highlightjs\/9.8.0\/highlight.min.js/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.8.0\/highlight.min.js/' /tmp/schema_1_syncope21.html
+sed -i 's/\/syncope\/webjars\/highlightjs\/9.15.8\/styles\/default.min.css/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.15.8\/styles\/default.min.css/' /tmp/schema_1_syncope21.html
+sed -i 's/\/syncope\/webjars\/highlightjs\/9.15.8\/highlight.min.js/http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.15.8\/highlight.min.js/' /tmp/schema_1_syncope21.html
./bin/shutdown.sh && cd -