From 9e6c439821b732c4ef8cfc136a555c3adcd028c9 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 11 Sep 2018 16:46:46 +0200 Subject: [PATCH] Allow unparseable enums in COMPAT mode This issue made midPoint unavailable if such an enum was present in system configuration object. --- .../midpoint/prism/marshaller/BeanUnmarshaller.java | 3 ++- .../midpoint/prism/marshaller/PrismUnmarshaller.java | 7 +++++-- .../midpoint/repo/sql/SqlRepositoryServiceImpl.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/BeanUnmarshaller.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/BeanUnmarshaller.java index 2250cc92281..18106a50b76 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/BeanUnmarshaller.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/BeanUnmarshaller.java @@ -1233,7 +1233,8 @@ private T unmarshalEnumFromPrimitive(PrimitiveXNode prim, Class beanClass } } if (javaEnumString == null) { - throw new SchemaException("Cannot find enum value for string '"+primValue+"' in "+beanClass); + pc.warnOrThrow(LOGGER, "Cannot find enum value for string '"+primValue+"' in "+beanClass); + return null; } @SuppressWarnings("unchecked") diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java index 188fc3583f3..60e56aa27a8 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/marshaller/PrismUnmarshaller.java @@ -379,8 +379,11 @@ private PrismPropertyValue parsePropertyValue(@NotNull XNode node, if (expression != null) { PrismPropertyValue ppv = new PrismPropertyValue<>(null, prismContext, null, null, expression); return ppv; - - } + } else { + // There's no point in returning PPV(null) as it would soon fail on internal PP check. + // We are probably recovering from an error in COMPAT mode here, so let's just skip this value. + return null; + } } PrismPropertyValue ppv = new PrismPropertyValue<>(realValue); ppv.setPrismContext(prismContext); diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java index a9b1515fbcb..6b504d63f54 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java @@ -1130,7 +1130,7 @@ public FullTextSearchConfigurationType getFullTextSearchConfiguration() { @Override public void postInit(OperationResult result) throws SchemaException { - LOGGER.info("Executing repository postInit method"); + LOGGER.debug("Executing repository postInit method"); SystemConfigurationType systemConfiguration; try {