use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class GeneratorTask method uploadContent.
private void uploadContent(ProgressIndicator indicator, String content) {
Project project = getProject();
Environment env = getEnvironment();
updateIndicator(indicator, "Content created, uploading to " + env.getName());
MidPointService mm = MidPointService.getInstance(project);
MidPointClient client = new MidPointClient(project, env);
List<MidPointObject> objects = MidPointUtils.parseText(project, content, null, NOTIFICATION_KEY);
int fail = 0;
int success = 0;
for (MidPointObject object : objects) {
try {
OperationResult result = UploadExecuteTask.uploadExecute(client, object);
boolean problem = result != null && !result.isSuccess();
if (problem) {
fail++;
String msg = "Upload status of " + object.getName() + " was " + result.getStatus();
mm.printToConsole(env, getClass(), msg);
MidPointUtils.publishNotification(project, NOTIFICATION_KEY, "Warning", msg, NotificationType.WARNING, new ShowResultNotificationAction(result));
} else {
success++;
mm.printToConsole(env, getClass(), "Content uploaded successfuly");
}
} catch (Exception ex) {
fail++;
mm.printToConsole(env, getClass(), "Couldn't upload generated content. Reason: " + ex.getMessage());
MidPointUtils.publishExceptionNotification(project, env, GeneratorTask.class, NOTIFICATION_KEY, "Couldn't upload generated content", ex);
}
}
showNotificationAfterFinish(project, success, fail);
updateIndicator(indicator, "Content uploaded");
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class SimpleBackgroundableTask method setupMidpointClient.
private MidPointClient setupMidpointClient() {
logToConsole("Setting up MidPoint client");
Environment env = getEnvironment();
midPointService.printToConsole(env, getClass(), "Initializing '" + getTitle() + "' action");
MidPointClient client = new MidPointClient(getProject(), env);
logToConsole("MidPoint client setup done");
return client;
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class BrowseToolPanel method searchPerformed.
private void searchPerformed(AnActionEvent evt, ProgressIndicator indicator) {
LOG.debug("Clearing table");
// clear result table
updateTableModel(null);
// load data
EnvironmentService em = EnvironmentService.getInstance(evt.getProject());
Environment env = em.getSelected();
indicator.setText("Searching objects in environment: " + env.getName());
SearchResultList result = null;
try {
LOG.debug("Setting up midpoint client");
MidPointClient client = new MidPointClient(evt.getProject(), env);
ObjectTypes type = objectType.getSelected();
ObjectQuery query = buildQuery(client);
LOG.debug("Starting search");
result = client.list(type.getClassDefinition(), query, rawSearch);
} catch (Exception ex) {
handleGenericException(env, "Couldn't search objects", ex);
}
LOG.debug("Updating table");
// update result table
updateTableModel(result);
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class BrowseToolPanel method processPerformed.
private void processPerformed(AnActionEvent evt) {
String query = this.query.getText();
ComboQueryType.Type queryType = this.queryType.getSelected();
ObjectTypes type = this.objectType.getSelected();
List<ObjectType> selected = getResultsModel().getSelectedObjects(results);
if (ComboQueryType.Type.QUERY_XML != queryType && StringUtils.isNotEmpty(query)) {
// translate query
EnvironmentService em = EnvironmentService.getInstance(evt.getProject());
Environment env = em.getSelected();
try {
LOG.debug("Setting up midpoint client");
MidPointClient client = new MidPointClient(evt.getProject(), env);
LOG.debug("Translating object query");
ObjectQuery objectQuery = buildQuery(client);
ObjectPaging paging = objectQuery.getPaging();
if (paging != null) {
// cleanup ordering, not necessary for bulk processing
paging.setOrdering(new ObjectOrdering[0]);
}
PrismContext ctx = client.getPrismContext();
QueryConverter converter = ctx.getQueryConverter();
QueryType q = converter.createQueryType(objectQuery);
RunnableUtils.PluginClassCallable<String> callable = new RunnableUtils.PluginClassCallable<>() {
@Override
public String callWithPluginClassLoader() throws Exception {
return ctx.serializerFor(PrismContext.LANG_XML).serializeRealValue(q);
}
};
query = callable.call();
} catch (Exception ex) {
handleGenericException(env, "Couldn't serialize query", ex);
}
}
ProcessResultsDialog dialog = new ProcessResultsDialog(processResultsOptions, query, type, selected);
dialog.show();
if (dialog.isOK() || dialog.isGenerate()) {
processResultsOptions = dialog.buildOptions();
performGenerate(evt, selected, processResultsOptions, !dialog.isGenerate());
}
}
use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.
the class ExtensionSchemaCacheService method refresh.
public 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);
Map<SchemaFileType, String> schemas = client.getExtensionSchemas();
cache.clear();
if (schemas != null) {
for (Map.Entry<SchemaFileType, String> entry : schemas.entrySet()) {
SchemaFileType schemaFile = entry.getKey();
VirtualFile file = new LightVirtualFile(schemaFile.getFileName(), entry.getValue());
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
continue;
}
cache.put(schemaFile.getNamespace(), (XmlFile) psiFile);
}
}
LOG.info("Refresh finished, " + cache.size() + " objects in cache");
}, AppExecutorUtil.getAppExecutorService());
LOG.info("Invoke done");
}
Aggregations