Skip to content

Commit

Permalink
Merge branch 'snapshot' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Mar 9, 2022
2 parents ee2a4d6 + a1be8bf commit b8fda01
Show file tree
Hide file tree
Showing 36 changed files with 1,110 additions and 165 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
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.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType;

import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
* Created by Viliam Repan (lazyman).
Expand Down Expand Up @@ -66,4 +68,6 @@ OperationResult testResourceConnection(String oid)
List<String> getSourceProfiles() throws IOException;

List<ScriptObject> getSourceProfileScripts(String profile) throws IOException;

Map<SchemaFileType, String> getExtensionSchemas() throws IOException, SchemaException, AuthenticationException, ClientException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ServiceFactory {
DOMUtilSettings.setAddTransformerFactorySystemProperty(false);
// todo create web client just to obtain extension schemas!

PrismContextFactory factory = new MidPointPrismContextFactory();
MidPointPrismContextFactory factory = new MidPointPrismContextFactory();
PrismContext prismContext = factory.createPrismContext();
prismContext.initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteScriptResponseType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.BuildInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.query_3.QueryType;
import com.fasterxml.jackson.databind.ObjectMapper;
import okhttp3.*;
Expand Down Expand Up @@ -530,4 +527,33 @@ public List<ScriptObject> getSourceProfileScripts(String profile) throws IOExcep
return sos.getScripts();
}
}

@Override
public Map<SchemaFileType, String> getExtensionSchemas() throws IOException, SchemaException, AuthenticationException, ClientException {
SchemaFilesType files = getSchemaFiles();
if (files == null || files.getSchema().isEmpty()) {
return Collections.emptyMap();
}

Map<SchemaFileType, String> result = new HashMap<>();
for (SchemaFileType file : files.getSchema()) {
Request.Builder builder = context.build("/ws/schema", "/" + file.getFileName(), null).get();
Request req = builder.build();

String xsd = executeRequest(req, String.class);
result.put(file, xsd);
}

return result;
}

private SchemaFilesType getSchemaFiles() throws IOException, SchemaException, AuthenticationException, ClientException {
Request.Builder builder = context.build("/ws/schema", "", null)
.get();

Request req = builder.build();

return executeRequest(req, SchemaFilesType.class);
}

}
10 changes: 10 additions & 0 deletions studio-idea-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# MidPoint Studio

## 4.4.2
### Changed
- Changed format of local/remote diff (internal XML file representation)

### Fixed
- MID-7658 fix for task upgrade, when task had 528 archetype and no/wrong handler uri - delete task was created incorrectly
- MID-7658 invalid handler task test (generates no change)
- MID-7695 namespace variants missing fix
- MID-7691 console logs didn't correspond with task being executed (upload/test resource)

## 4.4.1
### Added
- Model authorizations were added to list of possibilities when completion dialog is shown
Expand Down
16 changes: 12 additions & 4 deletions studio-idea-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.5.31"
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.2.0"
id("org.jetbrains.intellij") version "1.4.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.0"
id("org.jetbrains.changelog") version "1.3.1"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.17.1"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
Expand All @@ -31,9 +31,13 @@ val pluginImplementation by configurations.creating {
extendsFrom(configurations.implementation.get())
}

val resolvableCompileOnly by configurations.creating {
extendsFrom(configurations.compileOnly.get())
}

sourceSets {
main {
compileClasspath = pluginImplementation + configurations.compileOnly
compileClasspath = pluginImplementation + resolvableCompileOnly
}
}

Expand Down Expand Up @@ -225,6 +229,10 @@ tasks {
useJUnitPlatform()
}

runIde {
jvmArgs("--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED")
}

runIdeForUiTests {
systemProperty("robot-server.port", "8082") // default port 8580
}
Expand Down
6 changes: 3 additions & 3 deletions studio-idea-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = com.evolveum.midpoint.studio
pluginName = intellij-midpoint-studio
pluginVersion = 4.4.1
pluginVersion = 4.4.2

# 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.
Expand All @@ -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, IC-2022.1
pluginVerifierIdeVersions = IC-2020.3.4, IC-2021.1.3, IC-2021.2.2, IC-2021.3.2, IC-2022.1

platformType = IC
platformVersion = 2021.3
platformVersion = 2021.3.2
platformDownloadSources = true
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.evolveum.midpoint.studio.action;

import com.evolveum.midpoint.studio.MidPointConstants;
import com.evolveum.midpoint.studio.impl.EnvironmentService;
import com.evolveum.midpoint.studio.impl.MidPointClient;
import com.evolveum.midpoint.studio.ui.resource.ResourceWizard;
import com.evolveum.midpoint.studio.util.RunnableUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.actionSystem.AnAction;
Expand All @@ -11,6 +15,8 @@
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

/**
* Created by Viliam Repan (lazyman).
*/
Expand Down Expand Up @@ -52,9 +58,18 @@ public void actionPerformed(@NotNull AnActionEvent evt) {
return;
}

Project project = evt.getProject();
// Project project = evt.getProject();
//
// ResourceWizard wizard = ResourceWizard.createWizard(project);
// wizard.showAndGet();

RunnableUtils.executeWithPluginClassloader(() -> {

ResourceWizard wizard = ResourceWizard.createWizard(project);
wizard.showAndGet();
EnvironmentService es = EnvironmentService.getInstance(evt.getProject());
MidPointClient client = new MidPointClient(evt.getProject(), es.getSelected(), true, true);
Map<SchemaFileType, String> result = client.getExtensionSchemas();
System.out.println(result);
return result;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private MidPointClient setupMidpointClient() {

Environment env = getEnvironment();

midPointService.printToConsole(env, getClass(), "Initializing '" + getTitle() + "' action");
midPointService.printToConsole(env, getClass(), "Setting up midPoint client");

MidPointClient client = new MidPointClient(getProject(), env);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.evolveum.midpoint.studio.action.task;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.studio.client.ClientUtils;
import com.evolveum.midpoint.studio.client.MidPointObject;
import com.evolveum.midpoint.studio.util.FileUtils;
import com.evolveum.midpoint.studio.impl.xml.LocationType;
import com.evolveum.midpoint.studio.util.MidPointUtils;
import com.evolveum.midpoint.studio.util.RunnableUtils;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaObjectType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
Expand All @@ -18,15 +14,14 @@
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;

import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

/**
* Created by Viliam Repan (lazyman).
*/
public class DiffLocalTask extends SimpleBackgroundableTask {
public class DiffLocalTask extends DiffTask {

private static final Logger LOG = Logger.getInstance(DiffLocalTask.class);

Expand All @@ -35,9 +30,7 @@ public class DiffLocalTask extends SimpleBackgroundableTask {
public static String NOTIFICATION_KEY = TITLE;

public DiffLocalTask(@NotNull AnActionEvent event) {
super(event.getProject(), TITLE, NOTIFICATION_KEY);

setEvent(event);
super(event, TITLE, NOTIFICATION_KEY);
}

@Override
Expand Down Expand Up @@ -83,35 +76,10 @@ protected void doRun(ProgressIndicator indicator) {
MidPointObject first = firstSet.get(i);
MidPointObject second = secondSet.get(i);

// todo expand local content before its used for comparing
PrismObject firstObject = client.parseObject(first.getContent());
PrismObject secondObject = client.parseObject(second.getContent());

ObjectDeltaObjectType odo = new ObjectDeltaObjectType();
odo.setOldObject((ObjectType) firstObject.asObjectable());
odo.setNewObject((ObjectType) secondObject.asObjectable());

String xml = client.serialize(odo);
deltas.add(xml);
}

vf = FileUtils.createScratchFile(getProject(), getEnvironment(), "diff");

writer = new OutputStreamWriter(vf.getOutputStream(this), vf.getCharset());

if (deltas.size() > 1) {
writer.write(ClientUtils.DELTAS_XML_PREFIX);
writer.write('\n');
deltas.add(createDiffXml(first, firstFile, LocationType.LOCAL, second, secondFile, LocationType.LOCAL));
}

for (String obj : deltas) {
writer.write(obj);
}

if (deltas.size() > 1) {
writer.write(ClientUtils.DELTAS_XML_SUFFIX);
writer.write('\n');
}
vf = createScratchAndWriteDiff(deltas);
} catch (Exception ex) {
// failed.incrementAndGet();
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.evolveum.midpoint.studio.action.task;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.studio.client.ClientUtils;
import com.evolveum.midpoint.studio.client.MidPointObject;
import com.evolveum.midpoint.studio.impl.Environment;
import com.evolveum.midpoint.studio.impl.EnvironmentService;
import com.evolveum.midpoint.studio.impl.SearchOptions;
import com.evolveum.midpoint.studio.util.FileUtils;
import com.evolveum.midpoint.studio.impl.xml.LocationType;
import com.evolveum.midpoint.studio.util.MidPointUtils;
import com.evolveum.midpoint.studio.util.RunnableUtils;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaObjectType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectType;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
Expand All @@ -22,7 +18,6 @@
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;

import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -33,7 +28,7 @@
/**
* Created by Viliam Repan (lazyman).
*/
public class DiffRemoteTask extends SimpleBackgroundableTask {
public class DiffRemoteTask extends DiffTask {

private static final Logger LOG = Logger.getInstance(DiffRemoteTask.class);

Expand All @@ -42,9 +37,7 @@ public class DiffRemoteTask extends SimpleBackgroundableTask {
public static String NOTIFICATION_KEY = TITLE;

public DiffRemoteTask(@NotNull AnActionEvent event) {
super(event.getProject(), TITLE, NOTIFICATION_KEY);

setEvent(event);
super(event, TITLE, NOTIFICATION_KEY);
}

@Override
Expand All @@ -54,7 +47,6 @@ protected void doRun(ProgressIndicator indicator) {
indicator.setIndeterminate(false);

EnvironmentService em = EnvironmentService.getInstance(getProject());
Environment env = em.getSelected();

VirtualFile[] selectedFiles = UIUtil.invokeAndWaitIfNeeded(() -> event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY));

Expand Down Expand Up @@ -141,35 +133,10 @@ private void processFiles(ProgressIndicator indicator, List<VirtualFile> files)
continue;
}

// todo expand local content before its used for comparing
PrismObject localObject = client.parseObject(local.getContent());
PrismObject remoteObject = client.parseObject(remote.getContent());

ObjectDeltaObjectType odo = new ObjectDeltaObjectType();
odo.setOldObject((ObjectType) localObject.asObjectable());
odo.setNewObject((ObjectType) remoteObject.asObjectable());

String xml = client.serialize(odo);
deltas.add(xml);
}

vf = FileUtils.createScratchFile(getProject(), env, "diff");

writer = new OutputStreamWriter(vf.getOutputStream(this), vf.getCharset());

if (deltas.size() > 1) {
writer.write(ClientUtils.DELTAS_XML_PREFIX);
writer.write('\n');
deltas.add(createDiffXml(local, file, LocationType.LOCAL, remote, null, LocationType.REMOTE));
}

for (String obj : deltas) {
writer.write(obj);
}

if (deltas.size() > 1) {
writer.write(ClientUtils.DELTAS_XML_SUFFIX);
writer.write('\n');
}
vf = createScratchAndWriteDiff(deltas);
} catch (Exception ex) {
failed.incrementAndGet();

Expand Down
Loading

0 comments on commit b8fda01

Please sign in to comment.