From 4ed9debaaff810b921e7b8ed8a9c0d8ec25e6eff Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Thu, 10 Mar 2022 14:36:43 +0100 Subject: [PATCH 01/23] updating plugin version to 4.5 --- studio-idea-plugin/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio-idea-plugin/gradle.properties b/studio-idea-plugin/gradle.properties index 7131dfc0..f238d9e2 100644 --- a/studio-idea-plugin/gradle.properties +++ b/studio-idea-plugin/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = com.evolveum.midpoint.studio pluginName = intellij-midpoint-studio -pluginVersion = 4.4.2 +pluginVersion = 4.5.0 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions # for insight into build numbers and IntelliJ Platform versions. From 3b0c5011d445ee55c0a60fe97e45a58b0e33628d Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Thu, 10 Mar 2022 14:37:15 +0100 Subject: [PATCH 02/23] updating midpoint dependency to 4.5-M2 --- .../com/evolveum/midpoint/studio/client/ClientUtils.java | 7 +++++-- .../com/evolveum/midpoint/studio/client/ServiceImpl.java | 2 +- settings.gradle.kts | 2 +- .../studio/impl/lang/MidPointExpressionVariables.java | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ClientUtils.java b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ClientUtils.java index 46097aa2..8a4b48a3 100644 --- a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ClientUtils.java +++ b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ClientUtils.java @@ -2,6 +2,7 @@ import com.evolveum.midpoint.common.LocalizationService; import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.result.OperationResult; @@ -55,6 +56,8 @@ public class ClientUtils { public static final String DELTAS_XML_SUFFIX = "\n"; + public static final ItemName O_OBJECT_MODIFICATION = new ItemName("http://midpoint.evolveum.com/xml/ns/public/common/api-types-3", "objectModification"); + public static List filterObjectTypeOnly(List objects) { return filterObjectTypeOnly(objects, true); } @@ -149,8 +152,8 @@ private static MidPointObject parseElement(Element element) { String localName = element.getLocalName(); boolean executable = (namespace == null || SchemaConstantsGenerated.NS_SCRIPTING.equals(namespace)) && SCRIPTING_ACTIONS.contains(localName); - boolean delta = (namespace == null || SchemaConstantsGenerated.O_OBJECT_MODIFICATION.getNamespaceURI().equals(namespace)) - && SchemaConstantsGenerated.O_OBJECT_MODIFICATION.getLocalPart().equals(localName); + boolean delta = (namespace == null || O_OBJECT_MODIFICATION.getNamespaceURI().equals(namespace)) + && O_OBJECT_MODIFICATION.getLocalPart().equals(localName); ObjectTypes type = getObjectType(element); diff --git a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceImpl.java b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceImpl.java index d70185df..f8e038de 100644 --- a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceImpl.java +++ b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceImpl.java @@ -426,7 +426,7 @@ public OperationResult recompute(Class type, String oi ObjectModificationType modification = new ObjectModificationType(); modification.oid(oid); - String xml = context.getSerializer().serialize(new JAXBElement(SchemaConstantsGenerated.O_OBJECT_MODIFICATION, ObjectModificationType.class, modification)); + String xml = context.getSerializer().serialize(new JAXBElement(ClientUtils.O_OBJECT_MODIFICATION, ObjectModificationType.class, modification)); Request.Builder builder = context.build("/" + path + "/" + oid, options) .post(RequestBody.create(xml, ServiceContext.APPLICATION_XML)); diff --git a/settings.gradle.kts b/settings.gradle.kts index c5fd3d60..718624dc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,7 @@ dependencyResolutionManagement { version("jcommander", "1.81") version("jupiter", "5.6.0") version("logback", "1.2.3") - version("midpoint", "4.4.1") + version("midpoint", "4.5-M2") version("midscribe", "4.4-SNAPSHOT") version("okhttp", "4.9.0") version("openkeepass", "0.8.1") diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/MidPointExpressionVariables.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/MidPointExpressionVariables.java index be179cf2..a34302a9 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/MidPointExpressionVariables.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/MidPointExpressionVariables.java @@ -1,12 +1,12 @@ package com.evolveum.midpoint.studio.impl.lang; import com.evolveum.midpoint.common.LocalizationService; -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.model.api.expr.MidpointFunctions; import com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions; import com.evolveum.midpoint.model.common.expression.functions.LogExpressionFunctions; import com.evolveum.midpoint.model.impl.expr.MidpointFunctionsImpl; import com.evolveum.midpoint.notifications.api.events.Event; +import com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** @@ -42,7 +42,7 @@ public enum MidPointExpressionVariables { FOCUS_EXISTS("focusExists", Boolean.class), - R("associationTargetObjectClassDefinition", RefinedObjectClassDefinition.class), + R("associationTargetObjectClassDefinition", ResourceObjectTypeDefinition.class), ENTITLEMENT("entitlement", ShadowType.class), From 51ab7c65ba66f3e50468d88679435b8ed498665c Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Wed, 16 Mar 2022 08:52:49 +0100 Subject: [PATCH 03/23] MID-7735 upload/recompute now recomputes all uploaded objects which are subtypes of AssignmentHolderType --- .../midpoint/studio/action/task/UploadRecomputeTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/UploadRecomputeTask.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/UploadRecomputeTask.java index 7bf2fa40..8abc6037 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/UploadRecomputeTask.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/UploadRecomputeTask.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.studio.util.MidPointUtils; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteScriptResponseType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ActionExpressionType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExpressionPipelineType; @@ -47,7 +48,7 @@ public ProcessObjectResult processObject(MidPointObject obj) throws Exception { return por; } - if (!MidPointUtils.isAssignableFrom(ObjectTypes.FOCUS_TYPE, obj.getType())) { + if (obj.getType() == null || !AssignmentHolderType.class.isAssignableFrom(obj.getType().getClassDefinition())) { return por; } From 795066ac919d3e729d121d88b812e88d575b5f53 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Mon, 21 Mar 2022 15:07:26 +0100 Subject: [PATCH 04/23] updated IDE version to 2021.3.3 --- studio-idea-plugin/gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/studio-idea-plugin/gradle.properties b/studio-idea-plugin/gradle.properties index f238d9e2..de5c4fd3 100644 --- a/studio-idea-plugin/gradle.properties +++ b/studio-idea-plugin/gradle.properties @@ -12,10 +12,10 @@ pluginUntilBuild = 221.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.2, IC-2022.1 +pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.3, IC-2022.1 platformType = IC -platformVersion = 2021.3.2 +platformVersion = 2021.3.3 platformDownloadSources = true # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 From 1f505e82d2dc470eaa5fa3474271f31be7355f7d Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Mon, 21 Mar 2022 15:13:34 +0100 Subject: [PATCH 05/23] MID-7620 partial improvement for autocompletion items for expression evaluators (all items added) --- .../ExpressionEvaluatorTagNameProvider.java | 71 +++++++++++++++++++ .../MidPointCompletionContributor.java | 16 +---- .../midpoint/studio/util/MidPointUtils.java | 17 +++++ .../src/main/resources/META-INF/plugin.xml | 3 + 4 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/ExpressionEvaluatorTagNameProvider.java diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/ExpressionEvaluatorTagNameProvider.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/ExpressionEvaluatorTagNameProvider.java new file mode 100644 index 00000000..be6541df --- /dev/null +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/ExpressionEvaluatorTagNameProvider.java @@ -0,0 +1,71 @@ +package com.evolveum.midpoint.studio.impl.lang.codeInsight; + +import com.evolveum.midpoint.schema.SchemaConstantsGenerated; +import com.evolveum.midpoint.studio.util.MidPointUtils; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.icons.AllIcons; +import com.intellij.patterns.PlatformPatterns; +import com.intellij.psi.xml.XmlTag; +import com.intellij.xml.XmlTagNameProvider; +import org.jetbrains.annotations.NotNull; + +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Created by Viliam Repan (lazyman). + */ +public class ExpressionEvaluatorTagNameProvider implements XmlTagNameProvider { + + private static final List EVALUATORS; + + static { + QName[] evaluators = { + SchemaConstantsGenerated.C_VALUE, + SchemaConstantsGenerated.C_AS_IS, + SchemaConstantsGenerated.C_CONST, + SchemaConstantsGenerated.C_FUNCTION, + SchemaConstantsGenerated.C_PROPORTIONAL, + SchemaConstantsGenerated.C_GENERATE, + SchemaConstantsGenerated.C_SCRIPT, + SchemaConstantsGenerated.C_PATH, + SchemaConstantsGenerated.C_ASSOCIATION_TARGET_SEARCH, + SchemaConstantsGenerated.C_ASSIGNMENT_TARGET_SEARCH, + SchemaConstantsGenerated.C_REFERENCE_SEARCH, + SchemaConstantsGenerated.C_ASSIGNMENT_FROM_ASSOCIATION, + SchemaConstantsGenerated.C_ASSOCIATION_FROM_LINK, + SchemaConstantsGenerated.C_SEQUENTIAL_VALUE + + }; + List names = new ArrayList<>(); + names.addAll(Arrays.asList(evaluators)); + + Collections.sort(names, (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getLocalPart(), o2.getLocalPart())); + + List elements = names.stream().map(q -> + LookupElementBuilder.create(q.getLocalPart()) + .withIcon(AllIcons.Nodes.Tag) + .withTypeText(q.getNamespaceURI()) + .withLookupStrings(Arrays.asList(q.getLocalPart(), q.getNamespaceURI())) + .withCaseSensitivity(true) + ).collect(Collectors.toList()); + + EVALUATORS = Collections.unmodifiableList(elements); + } + + @Override + public void addTagNameVariants(List elements, @NotNull XmlTag tag, String prefix) { + if (!PlatformPatterns.psiElement() + .withParent(MidPointUtils.qualifiedTag(SchemaConstantsGenerated.C_EXPRESSION)) + .accepts(tag)) { + return; + } + + elements.addAll(EVALUATORS); + } +} diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/MidPointCompletionContributor.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/MidPointCompletionContributor.java index 4fa7d016..c2e65a13 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/MidPointCompletionContributor.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/lang/codeInsight/MidPointCompletionContributor.java @@ -4,8 +4,8 @@ import com.intellij.codeInsight.completion.CompletionType; import com.intellij.codeInsight.completion.DefaultCompletionContributor; import com.intellij.patterns.XmlPatterns; -import com.intellij.patterns.XmlTagPattern; +import static com.evolveum.midpoint.studio.util.MidPointUtils.*; import static com.intellij.patterns.PlatformPatterns.psiElement; /** @@ -51,7 +51,7 @@ public MidPointCompletionContributor() { XmlPatterns .xmlText() .withParent( - commonTag("handlerUri").withParent(commonTag("task")) + commonTag("handlerUri").withParent(qualifiedTag(SchemaConstantsGenerated.C_TASK)) )), new TaskHandlerAnnotatorCompletionProvider()); @@ -74,16 +74,4 @@ public MidPointCompletionContributor() { ), new ItemPathCompletionProvider()); } - - private XmlTagPattern.Capture commonTag(String localName) { - return qualifiedTag(localName, SchemaConstantsGenerated.NS_COMMON); - } - - private XmlTagPattern.Capture annotationTag(String localName) { - return qualifiedTag(localName, SchemaConstantsGenerated.NS_ANNOTATION); - } - - private XmlTagPattern.Capture qualifiedTag(String localName, String namespace) { - return XmlPatterns.xmlTag().withLocalName(localName).withNamespace(namespace); - } } diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/util/MidPointUtils.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/util/MidPointUtils.java index d9d4ecb2..437e8ccf 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/util/MidPointUtils.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/util/MidPointUtils.java @@ -51,6 +51,7 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.patterns.XmlPatterns; +import com.intellij.patterns.XmlTagPattern; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; @@ -1022,4 +1023,20 @@ private String dumpAllMessages() { return StringUtils.join(all, "\n"); } } + + public static XmlTagPattern.Capture commonTag(String localName) { + return qualifiedTag(localName, SchemaConstantsGenerated.NS_COMMON); + } + + public static XmlTagPattern.Capture annotationTag(String localName) { + return qualifiedTag(localName, SchemaConstantsGenerated.NS_ANNOTATION); + } + + public static XmlTagPattern.Capture qualifiedTag(QName name) { + return XmlPatterns.xmlTag().withLocalName(name.getLocalPart()).withNamespace(name.getNamespaceURI()); + } + + public static XmlTagPattern.Capture qualifiedTag(String localName, String namespace) { + return XmlPatterns.xmlTag().withLocalName(localName).withNamespace(namespace); + } } diff --git a/studio-idea-plugin/src/main/resources/META-INF/plugin.xml b/studio-idea-plugin/src/main/resources/META-INF/plugin.xml index ccc1480b..585199cc 100644 --- a/studio-idea-plugin/src/main/resources/META-INF/plugin.xml +++ b/studio-idea-plugin/src/main/resources/META-INF/plugin.xml @@ -130,6 +130,9 @@ implementationClass="com.evolveum.midpoint.studio.impl.lang.codeInsight.NonexistentNamespaceUriCompletionProvider" order="before xmlLocation"/> + + From f5e2808dca4492a7043e41daf32231d6ecb9ce33 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Tue, 22 Mar 2022 12:22:13 +0100 Subject: [PATCH 06/23] MID-7756 removed unused namespace definitions --- studio-idea-plugin/src/main/resources/task-transformation.xslt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio-idea-plugin/src/main/resources/task-transformation.xslt b/studio-idea-plugin/src/main/resources/task-transformation.xslt index 1201ebd2..6f30eba0 100644 --- a/studio-idea-plugin/src/main/resources/task-transformation.xslt +++ b/studio-idea-plugin/src/main/resources/task-transformation.xslt @@ -6,7 +6,7 @@ xmlns:scext="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3" xmlns:rext="http://midpoint.evolveum.com/xml/ns/public/report/extension-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" - exclude-result-prefixes="mext scext c"> + exclude-result-prefixes="mext scext c rext"> From 2fe76fdc449f12cf7f5c159cad974c641a2e4b2d Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Tue, 22 Mar 2022 12:22:25 +0100 Subject: [PATCH 07/23] moved mp libs to 4.5-RC1 --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 718624dc..a07212da 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,7 @@ dependencyResolutionManagement { version("jcommander", "1.81") version("jupiter", "5.6.0") version("logback", "1.2.3") - version("midpoint", "4.5-M2") + version("midpoint", "4.5-RC1") version("midscribe", "4.4-SNAPSHOT") version("okhttp", "4.9.0") version("openkeepass", "0.8.1") From 8a31cba9565a37ae9351474dcefaa597af1cd46f Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Mon, 28 Mar 2022 14:46:54 +0200 Subject: [PATCH 08/23] MID-7781 fixed NPE in expander, improved error messages --- .../midpoint/studio/impl/Expander.java | 15 ++-- .../midpoint/studio/ExpanderTest.java | 76 +++++++++++++++++++ .../src/test/testData/expander/insert2.txt | 7 ++ .../system-configuration-expected.xml | 15 ++++ .../expander/system-configuration.xml | 8 ++ 5 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java create mode 100644 studio-idea-plugin/src/test/testData/expander/insert2.txt create mode 100644 studio-idea-plugin/src/test/testData/expander/system-configuration-expected.xml create mode 100644 studio-idea-plugin/src/test/testData/expander/system-configuration.xml diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java index d5e1c4f6..52d5d4cc 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java @@ -178,7 +178,8 @@ private String expandKey(String key, VirtualFile file) { File contentFile = new File(filePath); if (contentFile.isAbsolute()) { VirtualFile content = VfsUtil.findFileByIoFile(contentFile, true); - return loadContent(content); + + return loadContent(content, key, contentFile, null); } else { if (file != null) { if (!file.isDirectory()) { @@ -186,7 +187,7 @@ private String expandKey(String key, VirtualFile file) { } VirtualFile content = file.findFileByRelativePath(contentFile.getPath()); - return loadContent(content); + return loadContent(content, key, contentFile, file); } else { throw new IllegalStateException("Couldn't load file '" + key + "', unknown path '" + key + "'"); } @@ -233,16 +234,20 @@ private String expandKeyFromProperties(String key, boolean throwExceptionIfNotFo return value; } - private String loadContent(VirtualFile file) { + private String loadContent(VirtualFile file, String key, File contentFile, VirtualFile contentParent) { + if (file == null) { + throw new IllegalStateException("Can't load content for key '" + key + "', file '" + contentFile.getPath() + "' is not present in '" + contentParent + "'"); + } + if (file.isDirectory()) { - throw new IllegalStateException("Can't load content, file '" + file.getPath() + "' is directory"); + throw new IllegalStateException("Can't load content for key '" + key + "', file '" + file.getPath() + "' is directory"); } try { byte[] content = file.contentsToByteArray(); return new String(content, file.getCharset()); } catch (IOException ex) { - throw new IllegalStateException("Couldn't load content of file '\" + file.getPath() + \"', reason: " + ex.getMessage()); + throw new IllegalStateException("Couldn't load content for key '" + key + "', file '" + file.getPath() + "', reason: " + ex.getMessage()); } } } diff --git a/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java new file mode 100644 index 00000000..cc4e10ab --- /dev/null +++ b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java @@ -0,0 +1,76 @@ +package com.evolveum.midpoint.studio; + +import com.evolveum.midpoint.studio.impl.EncryptionService; +import com.evolveum.midpoint.studio.impl.Environment; +import com.evolveum.midpoint.studio.impl.EnvironmentService; +import com.evolveum.midpoint.studio.impl.Expander; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.builder.Input; +import org.xmlunit.diff.Diff; + +import java.io.File; + +/** + * Created by Viliam Repan (lazyman). + */ +public class ExpanderTest extends StudioActionTest { + + @Override + protected String getTestFolder() { + return "expander"; + } + + @Test() + public void testExpandFromFileNonexistingChunk() { + IllegalStateException thrown = Assertions.assertThrows(IllegalStateException.class, () -> { + testExpandFile(null, "system-configuration.xml"); + }); + + assertEquals("Can't load content for key '@./insert2.txt', file './insert2.txt' is not present in 'temp:///src'", thrown.getMessage()); + } + + @Test() + public void testExpandFromFileExistingChunk() { + testExpandFile("system-configuration-expected.xml", "system-configuration.xml", "insert2.txt"); + } + + private void testExpandFile(String fileExpected, String fileToExpand, String... expandChunkFiles) { + for (String s : expandChunkFiles) { + myFixture.configureByFile(s); + } + + PsiFile file = myFixture.configureByFile(fileToExpand); + + Editor editor = myFixture.getEditor(); + String text = editor.getDocument().getText(); + + Project project = getProject(); + + Environment environment = new Environment(); + + EnvironmentService es = EnvironmentService.getInstance(project); + es.add(environment); + + EncryptionService cm = project != null ? EncryptionService.getInstance(project) : null; + Expander expander = new Expander(environment, cm, project); + + String result = expander.expand(text, file.getVirtualFile()); + + LOG.info("Expanded result:\n" + result); + + Diff d = DiffBuilder + .compare(Input.fromFile(new File(getTestDataPath(), fileExpected))) + .withTest(Input.fromString(result)) + .build(); + + if (d.hasDifferences()) { + LOG.error(d.fullDescription()); + fail(); + } + } +} diff --git a/studio-idea-plugin/src/test/testData/expander/insert2.txt b/studio-idea-plugin/src/test/testData/expander/insert2.txt new file mode 100644 index 00000000..3cabd4cf --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/insert2.txt @@ -0,0 +1,7 @@ + + + + 127.0.0.1 + + + diff --git a/studio-idea-plugin/src/test/testData/expander/system-configuration-expected.xml b/studio-idea-plugin/src/test/testData/expander/system-configuration-expected.xml new file mode 100644 index 00000000..646f5ee6 --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/system-configuration-expected.xml @@ -0,0 +1,15 @@ + + + System configuration + + + + + 127.0.0.1 + + + + + + diff --git a/studio-idea-plugin/src/test/testData/expander/system-configuration.xml b/studio-idea-plugin/src/test/testData/expander/system-configuration.xml new file mode 100644 index 00000000..0eebe184 --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/system-configuration.xml @@ -0,0 +1,8 @@ + + + System configuration + +$(@./insert2.txt) + + From c2368efc3c5a56dcde1ba20d4aa21ca55e7605e4 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Wed, 30 Mar 2022 10:40:45 +0200 Subject: [PATCH 09/23] MID-7793 task generator fix - query element generated only when there's content for it --- .../impl/browse/BulkActionGenerator.java | 32 +++++++-------- .../studio/impl/browse/TaskGenerator.java | 39 +++++++++++-------- .../midpoint/studio/ui/BrowseToolPanel.java | 2 +- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java index 7a58820b..cc7238f8 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java @@ -203,28 +203,28 @@ private void createSearch(Element extension, GeneratorOptions options, Batch bat Element objectType = DOMUtil.createSubElement(extension, MEXT_OBJECT_TYPE_PREFIXED); objectType.setTextContent(type.getTypeQName().getLocalPart()); - Element objectQuery = DOMUtil.createSubElement(extension, MEXT_OBJECT_QUERY_PREFIXED); - if (options.isBatchByOids()) { - Element filter = DOMUtil.createSubElement(objectQuery, Q_FILTER_PREFIXED); - Element inOid = DOMUtil.createSubElement(filter, Q_IN_OID_PREFIXED); - for (ObjectType o : batch.getObjects()) { - DOMUtil.createSubElement(inOid, Q_VALUE_PREFIXED).setTextContent(o.getOid()); - DOMUtil.createComment(inOid, " " + o.getName() + " "); + if (!batch.getObjects().isEmpty()) { + Element objectQuery = DOMUtil.createSubElement(extension, MEXT_OBJECT_QUERY_PREFIXED); + + Element filter = DOMUtil.createSubElement(objectQuery, Q_FILTER_PREFIXED); + Element inOid = DOMUtil.createSubElement(filter, Q_IN_OID_PREFIXED); + for (ObjectType o : batch.getObjects()) { + DOMUtil.createSubElement(inOid, Q_VALUE_PREFIXED).setTextContent(o.getOid()); + DOMUtil.createComment(inOid, " " + o.getName() + " "); + } } } else { - try { - Element originalQuery = null; - if (StringUtils.isNotEmpty(options.getOriginalQuery())) { - originalQuery = DOMUtil.parseDocument(options.getOriginalQuery()).getDocumentElement(); - } + if (StringUtils.isNotEmpty(options.getOriginalQuery())) { + Element objectQuery = DOMUtil.createSubElement(extension, MEXT_OBJECT_QUERY_PREFIXED); - if (originalQuery != null) { + try { + Element originalQuery = DOMUtil.parseDocument(options.getOriginalQuery()).getDocumentElement(); DOMUtil.listChildElements(originalQuery).forEach(e -> objectQuery.appendChild(objectQuery.getOwnerDocument().adoptNode(e))); + } catch (RuntimeException e) { + MidPointUtils.publishExceptionNotification(project, null, BulkActionGenerator.class, + GeneratorTask.NOTIFICATION_KEY, "Couldn't parse XML query", e); } - } catch (RuntimeException e) { - MidPointUtils.publishExceptionNotification(project, null, BulkActionGenerator.class, - GeneratorTask.NOTIFICATION_KEY, "Couldn't parse XML query", e); } } } diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/TaskGenerator.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/TaskGenerator.java index 359a463f..78a40254 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/TaskGenerator.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/TaskGenerator.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskRecurrenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.intellij.openapi.project.Project; +import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Element; import javax.xml.namespace.QName; @@ -97,26 +98,32 @@ public String generate(Project project, List objects, GeneratorOptio Element extension = DOMUtil.createSubElement(task, TaskType.F_EXTENSION); DOMUtil.createSubElement(extension, new QName(Constants.MEXT_NS, "objectType", "mext")).setTextContent(type.getTypeQName().getLocalPart()); - Element objectQuery = DOMUtil.createSubElement(extension, new QName(Constants.MEXT_NS, "objectQuery", "mext")); + if (options.isBatchByOids()) { - Element filter = DOMUtil.createSubElement(objectQuery, Constants.Q_FILTER_PREFIXED); - Element inOid = DOMUtil.createSubElement(filter, Constants.Q_IN_OID_PREFIXED); - for (ObjectType o : batch.getObjects()) { - DOMUtil.createSubElement(inOid, Constants.Q_VALUE_PREFIXED).setTextContent(o.getOid()); - DOMUtil.createComment(inOid, " " + o.getName() + " "); + if (!batch.getObjects().isEmpty()) { + Element objectQuery = DOMUtil.createSubElement(extension, new QName(Constants.MEXT_NS, "objectQuery", "mext")); + Element filter = DOMUtil.createSubElement(objectQuery, Constants.Q_FILTER_PREFIXED); + Element inOid = DOMUtil.createSubElement(filter, Constants.Q_IN_OID_PREFIXED); + for (ObjectType o : batch.getObjects()) { + DOMUtil.createSubElement(inOid, Constants.Q_VALUE_PREFIXED).setTextContent(o.getOid()); + DOMUtil.createComment(inOid, " " + o.getName() + " "); + } } } else { - try { - Element originalQuery = DOMUtil.parseDocument(options.getOriginalQuery()).getDocumentElement(); - List children = DOMUtil.listChildElements(originalQuery); - for (Element child : children) { - DOMUtil.fixNamespaceDeclarations(child); - objectQuery.appendChild(root.getOwnerDocument().adoptNode(child)); + if (StringUtils.isNotEmpty(options.getOriginalQuery())) { + Element objectQuery = DOMUtil.createSubElement(extension, new QName(Constants.MEXT_NS, "objectQuery", "mext")); + try { + Element originalQuery = DOMUtil.parseDocument(options.getOriginalQuery()).getDocumentElement(); + List children = DOMUtil.listChildElements(originalQuery); + for (Element child : children) { + DOMUtil.fixNamespaceDeclarations(child); + objectQuery.appendChild(root.getOwnerDocument().adoptNode(child)); + } + } catch (RuntimeException e) { + MidPointUtils.publishExceptionNotification(project, null, TaskGenerator.class, + GeneratorTask.NOTIFICATION_KEY, "Couldn't parse XML query", e); + throw e; } - } catch (RuntimeException e) { - MidPointUtils.publishExceptionNotification(project, null, TaskGenerator.class, - GeneratorTask.NOTIFICATION_KEY, "Couldn't parse XML query", e); - throw e; } } diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java index d8098373..7260ba82 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java @@ -401,7 +401,7 @@ public void setSelected(@NotNull AnActionEvent e, boolean state) { processAction = createAnAction("Process", AllIcons.Actions.RealIntentionBulb, e -> processPerformed(e), - e -> e.getPresentation().setEnabled(isResultSelected() || StringUtils.isNotEmpty(query.getText()))); + e -> e.getPresentation().setEnabled(StringUtils.isNotEmpty(query.getText()))); group.add(processAction); From 5abbdd466775d9b7d3ba4b930d73eac8b7fb181f Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Thu, 31 Mar 2022 17:23:44 +0200 Subject: [PATCH 10/23] MID-7756 improved process objects button activity state (always enabled), improved query element for bulk actions --- .../midpoint/studio/impl/browse/BulkActionGenerator.java | 2 +- .../java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java index cc7238f8..32136ecc 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/browse/BulkActionGenerator.java @@ -215,7 +215,7 @@ private void createSearch(Element extension, GeneratorOptions options, Batch bat } } } else { - if (StringUtils.isNotEmpty(options.getOriginalQuery())) { + if (StringUtils.isNotBlank(options.getOriginalQuery())) { Element objectQuery = DOMUtil.createSubElement(extension, MEXT_OBJECT_QUERY_PREFIXED); try { diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java index 7260ba82..b57eb46d 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/BrowseToolPanel.java @@ -399,9 +399,7 @@ public void setSelected(@NotNull AnActionEvent e, boolean state) { group.add(new Separator()); - processAction = createAnAction("Process", AllIcons.Actions.RealIntentionBulb, - e -> processPerformed(e), - e -> e.getPresentation().setEnabled(StringUtils.isNotEmpty(query.getText()))); + processAction = createAnAction("Process", AllIcons.Actions.RealIntentionBulb, e -> processPerformed(e)); group.add(processAction); From ffcd9707f6936ec9ce42c05da7aefd2764efcbba Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 1 Apr 2022 09:44:31 +0200 Subject: [PATCH 11/23] updated gradle plugin to 1.5.2 --- studio-idea-plugin/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio-idea-plugin/build.gradle.kts b/studio-idea-plugin/build.gradle.kts index b59a9866..77133988 100644 --- a/studio-idea-plugin/build.gradle.kts +++ b/studio-idea-plugin/build.gradle.kts @@ -11,7 +11,7 @@ plugins { // Kotlin support id("org.jetbrains.kotlin.jvm") version "1.6.10" // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin - id("org.jetbrains.intellij") version "1.4.0" + id("org.jetbrains.intellij") version "1.5.2" // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin id("org.jetbrains.changelog") version "1.3.1" // detekt linter - read more: https://detekt.github.io/detekt/gradle.html From 665db073ef0369232f5f8a4514ade18b4060bdf8 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 8 Apr 2022 13:37:29 +0200 Subject: [PATCH 12/23] MID-7810 encrypted credentials not expanded in diff --- .../midpoint/studio/action/task/DiffTask.java | 8 ++++--- .../midpoint/studio/impl/Expander.java | 22 ++++++++++++++----- .../midpoint/studio/impl/ExpanderOptions.java | 19 ++++++++++++++++ .../midpoint/studio/impl/MidPointClient.java | 6 ++++- 4 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/ExpanderOptions.java diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/DiffTask.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/DiffTask.java index 5b18ad57..d0575cdc 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/DiffTask.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/action/task/DiffTask.java @@ -2,6 +2,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.studio.client.MidPointObject; +import com.evolveum.midpoint.studio.impl.ExpanderOptions; import com.evolveum.midpoint.studio.impl.xml.DiffObjectType; import com.evolveum.midpoint.studio.impl.xml.DiffType; import com.evolveum.midpoint.studio.impl.xml.LocationType; @@ -37,10 +38,11 @@ public DiffTask(@NotNull AnActionEvent event, String title, String notificationK protected String createDiffXml(MidPointObject first, VirtualFile firstFile, LocationType firstLocation, MidPointObject second, VirtualFile secondFile, LocationType secondLocation) throws SchemaException, IOException { - // todo expand local content before its used for comparing - PrismObject firstObject = client.parseObject(first.getContent()); - PrismObject secondObject = client.parseObject(second.getContent()); + ExpanderOptions opts = new ExpanderOptions().expandEncrypted(false); + + PrismObject firstObject = client.parseObject(first.getContent(), opts); + PrismObject secondObject = client.parseObject(second.getContent(), opts); DiffType objectsDiff = new DiffType(); diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java index 52d5d4cc..fc498864 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java @@ -61,7 +61,11 @@ private void initProjectProperties(Project project) { } public String expand(String object) { - return expand(object, null); + return expand(object, (ExpanderOptions) null); + } + + public String expand(String object, ExpanderOptions opts) { + return expand(object, null, opts); } /** @@ -74,10 +78,18 @@ public String expand(String object) { * @return */ public String expand(String object, VirtualFile file) { + return expand(object, file, null); + } + + public String expand(String object, VirtualFile file, ExpanderOptions opts) { if (object == null) { return null; } + if (opts == null) { + opts = new ExpanderOptions(); + } + Matcher matcher = PATTERN.matcher(object); List missingKeys = new ArrayList<>(); @@ -90,7 +102,7 @@ public String expand(String object, VirtualFile file) { continue; } - String value = expandKey(key, file); + String value = expandKey(key, file, opts.expandEncrypted()); if (value == null) { matcher.appendReplacement(sb, Matcher.quoteReplacement(matcher.group())); missingKeys.add(key); @@ -172,7 +184,7 @@ public Set getKeys() { return set; } - private String expandKey(String key, VirtualFile file) { + private String expandKey(String key, VirtualFile file, boolean expandEncrypted) { if (key != null && key.startsWith("@")) { String filePath = key.replaceFirst("@", ""); File contentFile = new File(filePath); @@ -200,8 +212,8 @@ private String expandKey(String key, VirtualFile file) { return value; } - if (encryptionService == null || !encryptionService.isAvailable()) { - return expandKeyFromProperties(key, true); + if (!expandEncrypted || encryptionService == null || !encryptionService.isAvailable()) { + return expandKeyFromProperties(key, expandEncrypted); } EncryptedProperty property = encryptionService.get(key, EncryptedProperty.class); diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/ExpanderOptions.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/ExpanderOptions.java new file mode 100644 index 00000000..b07332ac --- /dev/null +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/ExpanderOptions.java @@ -0,0 +1,19 @@ +package com.evolveum.midpoint.studio.impl; + +/** + * Created by Viliam Repan (lazyman). + */ +public class ExpanderOptions { + + private boolean expandEncrypted = true; + + public boolean expandEncrypted() { + return expandEncrypted; + } + + public ExpanderOptions expandEncrypted(boolean expand) { + this.expandEncrypted = expand; + + return this; + } +} diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java index f22d619f..6e3c136a 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java @@ -316,10 +316,14 @@ public String serialize(Object obj) throws SchemaException { } public PrismObject parseObject(String xml) throws IOException, SchemaException { + return parseObject(xml, null); + } + + public PrismObject parseObject(String xml, ExpanderOptions opts) throws IOException, SchemaException { EncryptionService cm = project != null ? EncryptionService.getInstance(project) : null; Expander expander = new Expander(environment, cm, project); - String expanded = expander.expand(xml); + String expanded = expander.expand(xml, opts); PrismParser parser = createParser(new ByteArrayInputStream(expanded.getBytes())); return parser.parse(); From 7ac7e15c16d63370247c4508e7cec1c637335227 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 8 Apr 2022 14:50:58 +0200 Subject: [PATCH 13/23] MID-7479 better http2 support --- .../studio/client/ServiceFactory.java | 157 +++++++++++------- settings.gradle.kts | 2 +- .../midpoint/studio/impl/Environment.java | 13 ++ .../midpoint/studio/impl/MidPointClient.java | 1 + .../studio/ui/EnvironmentEditorDialog.form | 34 +++- .../studio/ui/EnvironmentEditorDialog.java | 3 + 6 files changed, 140 insertions(+), 70 deletions(-) diff --git a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceFactory.java b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceFactory.java index f044db6b..9aacc3d3 100644 --- a/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceFactory.java +++ b/midpoint-client/src/main/java/com/evolveum/midpoint/studio/client/ServiceFactory.java @@ -1,12 +1,12 @@ package com.evolveum.midpoint.studio.client; import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismContextFactory; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.util.DOMUtilSettings; import com.evolveum.midpoint.util.MiscUtil; import okhttp3.Credentials; import okhttp3.OkHttpClient; +import okhttp3.Protocol; import okhttp3.Request; import okhttp3.logging.HttpLoggingInterceptor; import org.apache.commons.lang3.StringUtils; @@ -19,6 +19,8 @@ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URI; +import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.TimeUnit; /** @@ -74,6 +76,8 @@ public class ServiceFactory { private int responseTimeout = 60; + private boolean useHttp2 = false; + public ServiceFactory url(final String url) { this.url = url; return this; @@ -129,27 +133,25 @@ public ServiceFactory responseTimeout(final int responseTimeout) { return this; } + public ServiceFactory useHttp2(final boolean useHttp2) { + this.useHttp2 = useHttp2; + return this; + } + public Service create() throws Exception { OkHttpClient.Builder builder = new OkHttpClient.Builder(); builder.followSslRedirects(false); builder.followRedirects(false); + if (useHttp2) { + setupHttp2(builder); + } builder.writeTimeout(responseTimeout, TimeUnit.SECONDS); builder.readTimeout(responseTimeout, TimeUnit.SECONDS); builder.connectTimeout(responseTimeout, TimeUnit.SECONDS); if (username != null || password != null) { - builder.authenticator((route, response) -> { - - if (response.request().header("Authorization") != null) { - return null; // Give up, we've already failed to authenticate. - } - - String credential = Credentials.basic(username, password); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - }); + setupAuthentication(builder); } if (ignoreSSLErrors) { @@ -163,44 +165,7 @@ public Service create() throws Exception { } if (StringUtils.isNotEmpty(proxyServer)) { - URI uri = URI.create(proxyServer); - - if (proxyServerPort == null) { - if (uri.getPort() >= 0 && uri.getPort() <= 0xFFFF) { - proxyServerPort = uri.getPort(); - } else if (proxyServerType.getType() == Proxy.Type.HTTP) { - if ("http".equalsIgnoreCase(uri.getScheme())) { - proxyServerPort = 80; - } else if ("https".equalsIgnoreCase(uri.getScheme())) { - proxyServerPort = 443; - } - } - } - - if (proxyServerType == null) { - throw new IllegalArgumentException("Proxy server type not defined"); - } - - if (StringUtils.isEmpty(uri.getHost())) { - throw new IllegalArgumentException("Proxy host not defined"); - } - - if (proxyServerPort == null) { - throw new IllegalArgumentException("Proxy port undefined"); - } - - Proxy proxy = new Proxy(proxyServerType.getType(), new InetSocketAddress(uri.getHost(), proxyServerPort)); - builder.proxy(proxy); - - if (proxyUsername != null || proxyPassword != null) { - builder.proxyAuthenticator((route, response) -> { - - String credential = Credentials.basic(proxyUsername, proxyPassword); - return response.request().newBuilder() - .header("Proxy-Authorization", credential) - .build(); - }); - } + setupProxy(builder); } builder.addInterceptor(chain -> { @@ -216,19 +181,91 @@ public Service create() throws Exception { return chain.proceed(newRequest); }); - HttpLoggingInterceptor logging = new HttpLoggingInterceptor( - message -> { - if (messageListener == null) { - return; - } - - messageListener.handleMessage(message); - }); - logging.setLevel(HttpLoggingInterceptor.Level.BODY); - builder.addInterceptor(logging); + setupLogging(builder); ServiceContext context = new ServiceContext(url, DEFAULT_PRISM_CONTEXT, builder.build()); return new ServiceImpl(context); } + + private void setupHttp2(OkHttpClient.Builder builder) { + URI uri = URI.create(url); + String scheme = uri.getScheme(); + if (scheme == null) { + return; + } + + scheme = scheme.toLowerCase(); + if ("http".equals(scheme)) { + builder.protocols(Collections.singletonList(Protocol.H2_PRIOR_KNOWLEDGE)); + } else if ("https".equals(scheme)) { + builder.protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)); + } + } + + private void setupAuthentication(OkHttpClient.Builder builder) { + builder.authenticator((route, response) -> { + + if (response.request().header("Authorization") != null) { + return null; // Give up, we've already failed to authenticate. + } + + String credential = Credentials.basic(username, password); + return response.request().newBuilder() + .header("Authorization", credential) + .build(); + }); + } + + private void setupProxy(OkHttpClient.Builder builder) { + URI uri = URI.create(proxyServer); + + if (proxyServerPort == null) { + if (uri.getPort() >= 0 && uri.getPort() <= 0xFFFF) { + proxyServerPort = uri.getPort(); + } else if (proxyServerType.getType() == Proxy.Type.HTTP) { + if ("http".equalsIgnoreCase(uri.getScheme())) { + proxyServerPort = 80; + } else if ("https".equalsIgnoreCase(uri.getScheme())) { + proxyServerPort = 443; + } + } + } + + if (proxyServerType == null) { + throw new IllegalArgumentException("Proxy server type not defined"); + } + + if (StringUtils.isEmpty(uri.getHost())) { + throw new IllegalArgumentException("Proxy host not defined"); + } + + if (proxyServerPort == null) { + throw new IllegalArgumentException("Proxy port undefined"); + } + + Proxy proxy = new Proxy(proxyServerType.getType(), new InetSocketAddress(uri.getHost(), proxyServerPort)); + builder.proxy(proxy); + + if (proxyUsername != null || proxyPassword != null) { + builder.proxyAuthenticator((route, response) -> { + + String credential = Credentials.basic(proxyUsername, proxyPassword); + return response.request().newBuilder() + .header("Proxy-Authorization", credential) + .build(); + }); + } + } + + private void setupLogging(OkHttpClient.Builder builder) { + if (messageListener == null) { + messageListener = message -> { + }; + } + + HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> messageListener.handleMessage(message)); + logging.setLevel(HttpLoggingInterceptor.Level.BODY); + builder.addNetworkInterceptor(logging); + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index a07212da..53e05d76 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,7 +21,7 @@ dependencyResolutionManagement { version("logback", "1.2.3") version("midpoint", "4.5-RC1") version("midscribe", "4.4-SNAPSHOT") - version("okhttp", "4.9.0") + version("okhttp", "4.9.3") version("openkeepass", "0.8.1") version("slf4j", "1.7.26") version("spring", "5.2.8.RELEASE") diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Environment.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Environment.java index b357e7e1..1d842be4 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Environment.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Environment.java @@ -54,6 +54,8 @@ public class Environment implements Serializable, Comparable { private String propertiesFilePath; + private boolean useHttp2; + private List nodeUrls; public Environment() { @@ -80,6 +82,7 @@ public Environment(Environment other) { this.proxyPassword = other.proxyPassword; this.propertiesFilePath = other.propertiesFilePath; this.nodeUrls = other.nodeUrls; + this.useHttp2 = other.useHttp2; } public String getId() { @@ -219,6 +222,14 @@ public void setNodeUrls(List nodeUrls) { this.nodeUrls = nodeUrls; } + public boolean isUseHttp2() { + return useHttp2; + } + + public void setUseHttp2(boolean useHttp2) { + this.useHttp2 = useHttp2; + } + @Override public int compareTo(@NotNull Environment o) { return String.CASE_INSENSITIVE_ORDER.compare(name, o.name); @@ -232,6 +243,7 @@ public boolean equals(Object o) { Environment that = (Environment) o; if (ignoreSslErrors != that.ignoreSslErrors) return false; + if (useHttp2 != that.useHttp2) return false; if (id != null ? !id.equals(that.id) : that.id != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (shortName != null ? !shortName.equals(that.shortName) : that.shortName != null) return false; @@ -269,6 +281,7 @@ public int hashCode() { result = 31 * result + (proxyUsername != null ? proxyUsername.hashCode() : 0); result = 31 * result + (proxyPassword != null ? proxyPassword.hashCode() : 0); result = 31 * result + (propertiesFilePath != null ? propertiesFilePath.hashCode() : 0); + result = 31 * result + (useHttp2 ? 1 : 0); result = 31 * result + (nodeUrls != null ? nodeUrls.hashCode() : 0); return result; } diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java index 6e3c136a..c905563a 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/MidPointClient.java @@ -106,6 +106,7 @@ private void init(MidPointSettings settings) { .proxyUsername(environment.getProxyUsername()) .proxyPassword(environment.getProxyPassword()) .ignoreSSLErrors(environment.isIgnoreSslErrors()) + .useHttp2(environment.isUseHttp2()) .responseTimeout(settings.getRestResponseTimeout()); factory.messageListener((message) -> { diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.form b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.form index aa7151f8..6bb95d33 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.form +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.form @@ -1,6 +1,6 @@
- + @@ -31,7 +31,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -252,7 +252,7 @@ - + @@ -270,7 +270,7 @@ - + @@ -291,10 +291,26 @@ - + + + + + + + + + + + + + + + + +
diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.java index b7d42767..fe2c90d1 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/EnvironmentEditorDialog.java @@ -61,6 +61,7 @@ public class EnvironmentEditorDialog extends DialogWrapper { private JTextField proxyUsername; private JLabel testConnection; private JPanel colorPanel; + private JCheckBox useHttp2; private Project project; @@ -177,6 +178,7 @@ private void populateEnvironment(Environment environment) { environment.setUsername(username.getText()); environment.setPassword(String.copyValueOf(password.getPassword())); environment.setIgnoreSslErrors(ignoreSslErrors.isSelected()); + environment.setUseHttp2(useHttp2.isSelected()); environment.setProxyServerHost(proxyHost.getText()); String port = proxyPort.getToolTipText(); @@ -204,6 +206,7 @@ private void fillInFields() { username.setText(environment.getUsername()); password.setText(environment.getPassword()); ignoreSslErrors.setSelected(environment.isIgnoreSslErrors()); + useHttp2.setSelected(environment.isUseHttp2()); proxyHost.setText(environment.getProxyServerHost()); proxyPort.setText(environment.getProxyServerPort() != null ? environment.getProxyServerPort().toString() : null); From 4e4b4e4d7b12de96eb7e5812ec3149c4bc6d757e Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 8 Apr 2022 15:05:36 +0200 Subject: [PATCH 14/23] updated spring-core version to match midpoint version, midpoint lib updated to 4.5-RC2 --- settings.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 53e05d76..82154376 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,12 +19,12 @@ dependencyResolutionManagement { version("jcommander", "1.81") version("jupiter", "5.6.0") version("logback", "1.2.3") - version("midpoint", "4.5-RC1") + version("midpoint", "4.5-RC2") version("midscribe", "4.4-SNAPSHOT") version("okhttp", "4.9.3") version("openkeepass", "0.8.1") version("slf4j", "1.7.26") - version("spring", "5.2.8.RELEASE") + version("spring", "5.3.8") version("stax", "1.2.0") version("testng", "6.14.3") version("xchart", "3.5.4") From 09d99cb147a0140e45af8aaf654b5d1c4360f126 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Mon, 11 Apr 2022 10:11:41 +0200 Subject: [PATCH 15/23] updated midpoint libs to released 4.5 --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 82154376..70357247 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,7 @@ dependencyResolutionManagement { version("jcommander", "1.81") version("jupiter", "5.6.0") version("logback", "1.2.3") - version("midpoint", "4.5-RC2") + version("midpoint", "4.5") version("midscribe", "4.4-SNAPSHOT") version("okhttp", "4.9.3") version("openkeepass", "0.8.1") From 87b1e92512b5738b1913c002da192a2313b662f3 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Tue, 12 Apr 2022 21:42:17 +0200 Subject: [PATCH 16/23] emergency classspath fix after intellij updated log4j/slf4j logging configuration. plugins fails to load in 2022.1 --- settings.gradle.kts | 2 -- studio-idea-plugin/build.gradle.kts | 1 - studio-idea-plugin/gradle.properties | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 70357247..a1192c79 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,7 +23,6 @@ dependencyResolutionManagement { version("midscribe", "4.4-SNAPSHOT") version("okhttp", "4.9.3") version("openkeepass", "0.8.1") - version("slf4j", "1.7.26") version("spring", "5.3.8") version("stax", "1.2.0") version("testng", "6.14.3") @@ -52,7 +51,6 @@ dependencyResolutionManagement { alias("okhttp3").to("com.squareup.okhttp3", "okhttp").versionRef("okhttp") alias("openkeepass").to("de.slackspace", "openkeepass").versionRef("openkeepass") alias("security-api").to("com.evolveum.midpoint.repo", "security-api").versionRef("midpoint") - alias("slf4j-log4j12").to("org.slf4j", "slf4j-log4j12").versionRef("slf4j") alias("spring-core").to("org.springframework", "spring-core").versionRef("spring") alias("stax").to("stax", "stax").versionRef("stax") alias("xchart").to("org.knowm.xchart", "xchart").versionRef("xchart") diff --git a/studio-idea-plugin/build.gradle.kts b/studio-idea-plugin/build.gradle.kts index 77133988..23d4fd6f 100644 --- a/studio-idea-plugin/build.gradle.kts +++ b/studio-idea-plugin/build.gradle.kts @@ -84,7 +84,6 @@ dependencies { implementation(libs.openkeepass) implementation(libs.commons.lang) // compile(libs.xchart) - implementation(libs.slf4j.log4j12) implementation(libs.okhttp3) implementation(libs.okhttp.logging) diff --git a/studio-idea-plugin/gradle.properties b/studio-idea-plugin/gradle.properties index de5c4fd3..1a6edd94 100644 --- a/studio-idea-plugin/gradle.properties +++ b/studio-idea-plugin/gradle.properties @@ -15,11 +15,11 @@ pluginUntilBuild = 221.* pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.3, IC-2022.1 platformType = IC -platformVersion = 2021.3.3 +platformVersion = 2022.1 platformDownloadSources = true # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = PsiViewer:213-SNAPSHOT, com.jetbrains.hackathon.indices.viewer:1.20, java, Groovy, maven +platformPlugins = PsiViewer:221-SNAPSHOT, com.jetbrains.hackathon.indices.viewer:1.21, java, Groovy, maven # Opt-out flag for bundling Kotlin standard library. # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. From 028916758e542ebf6029c5e056fb11aea9a20779 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 15 Apr 2022 09:36:02 +0200 Subject: [PATCH 17/23] updated random oid icon (dice.svg now) --- .../evolveum/midpoint/studio/MidPointIcons.java | 2 +- .../src/main/resources/META-INF/plugin.xml | 2 +- .../src/main/resources/icons/dice.svg | 1 + .../src/main/resources/icons/random_oid.png | Bin 1377 -> 0 bytes .../src/main/resources/icons/random_oid@2x.png | Bin 2887 -> 0 bytes 5 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 studio-idea-plugin/src/main/resources/icons/dice.svg delete mode 100644 studio-idea-plugin/src/main/resources/icons/random_oid.png delete mode 100644 studio-idea-plugin/src/main/resources/icons/random_oid@2x.png diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/MidPointIcons.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/MidPointIcons.java index 477a38a2..8f9056f8 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/MidPointIcons.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/MidPointIcons.java @@ -11,7 +11,7 @@ */ public class MidPointIcons { - public static final Icon ACTION_RANDOM_OID = IconLoader.findIcon("/icons/random_oid.png"); + public static final @NotNull Icon RandomOid = load("icons/dice.svg"); public static final @NotNull Icon Midpoint = load("icons/midpoint.svg"); diff --git a/studio-idea-plugin/src/main/resources/META-INF/plugin.xml b/studio-idea-plugin/src/main/resources/META-INF/plugin.xml index 585199cc..725cf7ba 100644 --- a/studio-idea-plugin/src/main/resources/META-INF/plugin.xml +++ b/studio-idea-plugin/src/main/resources/META-INF/plugin.xml @@ -166,7 +166,7 @@ diff --git a/studio-idea-plugin/src/main/resources/icons/dice.svg b/studio-idea-plugin/src/main/resources/icons/dice.svg new file mode 100644 index 00000000..73b765cb --- /dev/null +++ b/studio-idea-plugin/src/main/resources/icons/dice.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/studio-idea-plugin/src/main/resources/icons/random_oid.png b/studio-idea-plugin/src/main/resources/icons/random_oid.png deleted file mode 100644 index f828b39ff9f05bb10f4c250692e728bc13d1a480..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1377 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?i-C%- zgD|6$#_S59g43BH5hW46K32*3xq68y`AMmI6}bgK)eHl#hD=EpgRf_NpP;kyKN>wn`Gto0pvg1-vP_QXVNwW%aaf50H@@$nd zN=gc>^!3Zj%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUl_7?}%yCIAPAJe?x5Yj#~W!ySUsdSC(uvPLFxoZ?e74c&*F*$)9B^mK7vgEeV~% z?$o24-Tn9K$HVb^P9?6|wCdL0XOBPa%6O_j@zR5K|J>8A=Tg?}a$2Wx=SghRL!+)2 zOK%0A{^R`kiiBNV6T515Pp_!ZsxJE{B)ZS~ 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 NHkJ Date: Fri, 22 Apr 2022 13:31:32 +0200 Subject: [PATCH 18/23] updated IDEs for verifier --- studio-idea-plugin/gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/studio-idea-plugin/gradle.properties b/studio-idea-plugin/gradle.properties index 1a6edd94..46611545 100644 --- a/studio-idea-plugin/gradle.properties +++ b/studio-idea-plugin/gradle.properties @@ -12,14 +12,14 @@ pluginUntilBuild = 221.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.3, IC-2022.1 +pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.4, IC-2022.1 platformType = IC platformVersion = 2022.1 platformDownloadSources = true # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = PsiViewer:221-SNAPSHOT, com.jetbrains.hackathon.indices.viewer:1.21, java, Groovy, maven +platformPlugins = java, Groovy, maven, PsiViewer:221-SNAPSHOT, com.jetbrains.hackathon.indices.viewer:1.21 # Opt-out flag for bundling Kotlin standard library. # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. From 46d954a2d4468f35c2b4678cf2c52b359be4b880 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 22 Apr 2022 13:38:22 +0200 Subject: [PATCH 19/23] MID-7781 test and fix for expanded, hopefully works on windows too --- .../midpoint/studio/impl/Expander.java | 18 +++++----- .../midpoint/studio/ExpanderTest.java | 35 +++++++++++++++++++ .../testData/expander/mid-7781/expected.xml | 13 +++++++ .../mid-7781/functionalLibraries/lib.xml | 12 +++++++ .../mid-7781/include/email/sample.html | 1 + 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 studio-idea-plugin/src/test/testData/expander/mid-7781/expected.xml create mode 100644 studio-idea-plugin/src/test/testData/expander/mid-7781/functionalLibraries/lib.xml create mode 100644 studio-idea-plugin/src/test/testData/expander/mid-7781/include/email/sample.html diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java index fc498864..32cae67f 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java @@ -9,7 +9,9 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.nio.charset.Charset; +import java.nio.file.Path; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -187,19 +189,19 @@ public Set getKeys() { private String expandKey(String key, VirtualFile file, boolean expandEncrypted) { if (key != null && key.startsWith("@")) { String filePath = key.replaceFirst("@", ""); - File contentFile = new File(filePath); - if (contentFile.isAbsolute()) { - VirtualFile content = VfsUtil.findFileByIoFile(contentFile, true); + URI uri = URI.create(filePath); + if (uri.isAbsolute()) { + VirtualFile content = VfsUtil.findFile(Path.of(filePath), true); - return loadContent(content, key, contentFile, null); + return loadContent(content, key, filePath, null); } else { if (file != null) { if (!file.isDirectory()) { file = file.getParent(); } - VirtualFile content = file.findFileByRelativePath(contentFile.getPath()); + VirtualFile content = file.findFileByRelativePath(filePath); - return loadContent(content, key, contentFile, file); + return loadContent(content, key, filePath, file); } else { throw new IllegalStateException("Couldn't load file '" + key + "', unknown path '" + key + "'"); } @@ -246,9 +248,9 @@ private String expandKeyFromProperties(String key, boolean throwExceptionIfNotFo return value; } - private String loadContent(VirtualFile file, String key, File contentFile, VirtualFile contentParent) { + private String loadContent(VirtualFile file, String key, String contentFilePath, VirtualFile contentParent) { if (file == null) { - throw new IllegalStateException("Can't load content for key '" + key + "', file '" + contentFile.getPath() + "' is not present in '" + contentParent + "'"); + throw new IllegalStateException("Can't load content for key '" + key + "', file '" + contentFilePath + "' is not present in '" + contentParent + "'"); } if (file.isDirectory()) { diff --git a/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java index cc4e10ab..f5ea7733 100644 --- a/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java +++ b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java @@ -6,7 +6,10 @@ import com.evolveum.midpoint.studio.impl.Expander; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; +import org.apache.commons.io.FileSystem; +import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.xmlunit.builder.DiffBuilder; @@ -14,6 +17,8 @@ import org.xmlunit.diff.Diff; import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * Created by Viliam Repan (lazyman). @@ -39,6 +44,36 @@ public void testExpandFromFileExistingChunk() { testExpandFile("system-configuration-expected.xml", "system-configuration.xml", "insert2.txt"); } + @Test + public void testMid7781() { + testExpandFile("mid-7781/expected.xml", "mid-7781/functionalLibraries/lib.xml", "mid-7781/functionalLibraries/lib.xml", "mid-7781/include/email/sample.html"); + } + + @Test + public void testMid7781Variant() throws IOException{ + if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { + testMid7781Variants("$(@..\\include\\email\\sample.html)"); + } else { + testMid7781Variants("$(@../include/email/sample.html)"); + } + } + + private void testMid7781Variants(String keyToExpand) throws IOException { + Project project = getProject(); + EnvironmentService es = EnvironmentService.getInstance(project); + Expander expander = new Expander(es.getSelected(), null, project); + + PsiFile psiFile = myFixture.configureByFile("mid-7781/functionalLibraries/lib.xml"); + VirtualFile file = psiFile.getVirtualFile(); + + myFixture.configureByFile("mid-7781/include/email/sample.html"); + + String expected = FileUtils.readFileToString(new File("./src/test/testData/expander/mid-7781/include/email/sample.html"), StandardCharsets.UTF_8); + + String value = expander.expand(keyToExpand, file); + assertEquals(expected, value); + } + private void testExpandFile(String fileExpected, String fileToExpand, String... expandChunkFiles) { for (String s : expandChunkFiles) { myFixture.configureByFile(s); diff --git a/studio-idea-plugin/src/test/testData/expander/mid-7781/expected.xml b/studio-idea-plugin/src/test/testData/expander/mid-7781/expected.xml new file mode 100644 index 00000000..e07ce98f --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/mid-7781/expected.xml @@ -0,0 +1,13 @@ + + mid-7781 + + + + + + diff --git a/studio-idea-plugin/src/test/testData/expander/mid-7781/functionalLibraries/lib.xml b/studio-idea-plugin/src/test/testData/expander/mid-7781/functionalLibraries/lib.xml new file mode 100644 index 00000000..b570bc4a --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/mid-7781/functionalLibraries/lib.xml @@ -0,0 +1,12 @@ + + mid-7781 + + + + + + diff --git a/studio-idea-plugin/src/test/testData/expander/mid-7781/include/email/sample.html b/studio-idea-plugin/src/test/testData/expander/mid-7781/include/email/sample.html new file mode 100644 index 00000000..d34e0cd7 --- /dev/null +++ b/studio-idea-plugin/src/test/testData/expander/mid-7781/include/email/sample.html @@ -0,0 +1 @@ +

Hi, I'm sample

From 32bb2ca4c51c37aa986cba6cd9dfb1e2409024cc Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 22 Apr 2022 15:02:46 +0200 Subject: [PATCH 20/23] MID-7781 finally should work --- .../java/com/evolveum/midpoint/studio/impl/Expander.java | 8 ++++++-- .../java/com/evolveum/midpoint/studio/ExpanderTest.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java index 32cae67f..35e804ea 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/Expander.java @@ -189,9 +189,13 @@ public Set getKeys() { private String expandKey(String key, VirtualFile file, boolean expandEncrypted) { if (key != null && key.startsWith("@")) { String filePath = key.replaceFirst("@", ""); - URI uri = URI.create(filePath); + + // just windows stuff (mid-7781). Backslash is not correctly handled later in {@link VirtualFile.findFileByRelativePath(path) } + filePath = filePath.replace("\\", "/"); + + Path uri = Path.of(filePath); if (uri.isAbsolute()) { - VirtualFile content = VfsUtil.findFile(Path.of(filePath), true); + VirtualFile content = VfsUtil.findFile(uri, true); return loadContent(content, key, filePath, null); } else { diff --git a/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java index f5ea7733..e884db3e 100644 --- a/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java +++ b/studio-idea-plugin/src/test/java/com/evolveum/midpoint/studio/ExpanderTest.java @@ -53,9 +53,9 @@ public void testMid7781() { public void testMid7781Variant() throws IOException{ if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { testMid7781Variants("$(@..\\include\\email\\sample.html)"); - } else { - testMid7781Variants("$(@../include/email/sample.html)"); } + + testMid7781Variants("$(@../include/email/sample.html)"); } private void testMid7781Variants(String keyToExpand) throws IOException { From 48dfda0df4899b79180ce273b4486ce0e02b37b7 Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 22 Apr 2022 15:05:40 +0200 Subject: [PATCH 21/23] fixed version of IDE for validation --- studio-idea-plugin/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio-idea-plugin/gradle.properties b/studio-idea-plugin/gradle.properties index 46611545..021c9918 100644 --- a/studio-idea-plugin/gradle.properties +++ b/studio-idea-plugin/gradle.properties @@ -12,7 +12,7 @@ pluginUntilBuild = 221.* # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.4, IC-2022.1 +pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.3, IC-2022.1 platformType = IC platformVersion = 2022.1 From 9fc4e4b52e4d6767f2c2cb8a4352f14d999b2afa Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Fri, 22 Apr 2022 16:00:51 +0200 Subject: [PATCH 22/23] MID-7896 not very fancy fix for UI new project wizard --- .../midpoint/studio/ui/ProjectConfigurationPanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/ProjectConfigurationPanel.java b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/ProjectConfigurationPanel.java index ea2714e7..df8bc69e 100644 --- a/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/ProjectConfigurationPanel.java +++ b/studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/ui/ProjectConfigurationPanel.java @@ -2,7 +2,10 @@ import com.evolveum.midpoint.studio.impl.ProjectSettings; import com.evolveum.midpoint.studio.util.MidPointUtils; +import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.util.text.VersionComparatorUtil; +import com.intellij.util.ui.JBUI; import org.apache.commons.lang3.StringUtils; import javax.swing.*; @@ -72,6 +75,11 @@ public ProjectSettings getSettings() { } private void createUIComponents() { + ApplicationInfo ai = ApplicationInfo.getInstance(); + if (VersionComparatorUtil.compare(ai.getFullVersion(), "2022.1") >= 0) { + setBorder(JBUI.Borders.empty(20)); + } + midpointSettingsPanel = new MidPointSettingsPanel(settings.getMidPointSettings()); environmentsPanel = new EnvironmentsPanel(null, settings.getMidPointSettings(), settings.getEnvironmentSettings()); } From a8a5442d3e59e6d8e027abbf6cb22d55ab051bbb Mon Sep 17 00:00:00 2001 From: Viliam Repan Date: Wed, 27 Apr 2022 14:37:13 +0200 Subject: [PATCH 23/23] updated changelog for 4.5.0 release --- studio-idea-plugin/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/studio-idea-plugin/CHANGELOG.md b/studio-idea-plugin/CHANGELOG.md index 09cf8756..3d8794bb 100644 --- a/studio-idea-plugin/CHANGELOG.md +++ b/studio-idea-plugin/CHANGELOG.md @@ -1,5 +1,13 @@ # MidPoint Studio +## 4.5.0 +### Fixed +- MID-7658 task upgrade action fix +- MID-7691 console logging fixes, upload/test resource weren't logged correctly +- MID-7695 namespace variants improvements +- MID-7735 upload/recompute now recomputes all uploaded objects +- MID-7810 encrypted credentials not expanded in diff now + ## 4.4.2 ### Changed - Changed format of local/remote diff (internal XML file representation)