use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class OperationResultDialog method saveResult.
private void saveResult(final Project project, ProgressIndicator indicator, final VirtualFileWrapper fileWrapper, OperationResult result) {
MidPointService mm = MidPointService.getInstance(project);
EnvironmentService em = EnvironmentService.getInstance(project);
Environment environment = em.getSelected();
RunnableUtils.runWriteActionAndWait(() -> {
File file = fileWrapper.getFile();
try {
if (file.exists()) {
file.delete();
}
file.createNewFile();
} catch (IOException ex) {
mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
}
VirtualFile vFile = fileWrapper.getVirtualFile();
try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(vFile.getOutputStream(this), vFile.getCharset()))) {
MidPointClient client = new MidPointClient(project, environment);
PrismContext ctx = client.getPrismContext();
PrismSerializer<String> serializer = ctx.serializerFor(PrismContext.LANG_XML);
String xml = serializer.serializeAnyData(result.createOperationResultType(), SchemaConstantsGenerated.C_OPERATION_RESULT);
IOUtils.write(xml, out);
} catch (IOException | SchemaException ex) {
mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
}
});
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class EnvironmentEditorDialog method executeTestConnection.
private void executeTestConnection(Project project, JLabel testConnection) {
Environment env = new Environment();
populateEnvironment(env);
try {
MidPointClient client = new MidPointClient(project, env, settings);
TestConnectionResult result = client.testConnection();
if (result.success()) {
updateInAwtThread(ConsoleViewContentType.NORMAL_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), "Version: " + result.version() + ", revision: " + result.revision());
} else {
String msg = result.exception() != null ? result.exception().getMessage() : null;
updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), msg);
}
} catch (Exception ex) {
LOG.error("Couldn't test connection", ex);
updateInAwtThread(ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY.getDefaultAttributes().getForegroundColor(), ex.getMessage());
}
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class ConnectorXmlSchemaCacheService method refresh.
private void refresh(Environment env) {
LOG.info("Invoking refresh");
RunnableUtils.submitNonBlockingReadAction(() -> {
LOG.info("Refreshing");
cache.clear();
if (env == null) {
LOG.info("Refresh skipped, no environment selected");
return;
}
MidPointClient client = new MidPointClient(project, env, true, true);
SearchResult result = client.search(ConnectorType.class, null, true);
for (MidPointObject object : result.getObjects()) {
try {
PrismObject<?> prismObject = client.parseObject(object.getContent());
ConnectorType connectorType = (ConnectorType) prismObject.asObjectable();
cache.put(connectorType, new CacheValue(connectorType, buildIcfSchema(object), buildConnectorSchema(object)));
} catch (Exception ex) {
if (ex instanceof ProcessCanceledException) {
throw (ProcessCanceledException) ex;
}
LOG.error("Couldn't parse connector object", ex);
}
}
LOG.info("Refresh finished, " + cache.size() + " objects in cache");
}, AppExecutorUtil.getAppExecutorService());
LOG.info("Invoke done");
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class TestAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent evt) {
if (evt.getProject() == null) {
return;
}
// Project project = evt.getProject();
//
// ResourceWizard wizard = ResourceWizard.createWizard(project);
// wizard.showAndGet();
RunnableUtils.executeWithPluginClassloader(() -> {
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;
});
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class TestConnectionAction method testConnection.
private void testConnection(Project project, Environment environment) {
try {
MidPointClient client = new MidPointClient(project, environment);
TestConnectionResult result = client.testConnection();
String status = result.success() ? "was successful" : "failed";
NotificationType type = result.success() ? NotificationType.INFORMATION : NotificationType.ERROR;
String versionInfo = "";
if (result.success()) {
versionInfo = " Version: " + result.version() + ", build: " + result.revision() + ".";
}
NotificationAction action = null;
if (result.exception() != null) {
action = new ShowExceptionNotificationAction("Connection test exception for '" + environment.getName() + "'", result.exception(), TestConnectionAction.class, environment);
}
MidPointUtils.publishNotification(project, NOTIFICATION_KEY, "Test connection", "Connection test for '" + environment.getName() + "' " + status + "." + versionInfo, type, action);
} catch (Exception ex) {
MidPointUtils.publishExceptionNotification(project, environment, TestConnectionAction.class, NOTIFICATION_KEY, "Connection test for '" + environment.getName() + "' failed with exception", ex);
}
}
Aggregations