Search in sources :

Example 1 with SearchResult

use of com.evolveum.midpoint.studio.client.SearchResult 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");
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) SearchResult(com.evolveum.midpoint.studio.client.SearchResult) ControlFlowException(com.intellij.openapi.diagnostic.ControlFlowException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 2 with SearchResult

use of com.evolveum.midpoint.studio.client.SearchResult in project midpoint-studio by Evolveum.

the class DownloadTask method downloadByQuery.

private void downloadByQuery() {
    List<VirtualFile> files = new ArrayList<>();
    try {
        SearchResult result = client.search(type.getClassDefinition(), query, raw);
        if (result == null || result.getObjects() == null) {
            return;
        }
        LOG.debug("Storing file");
        RunnableUtils.runWriteActionAndWait(() -> {
            for (MidPointObject obj : result.getObjects()) {
                VirtualFile file = saveFile(obj);
                if (file != null) {
                    files.add(file);
                }
            }
        });
        LOG.debug("Files saved");
    } catch (Exception ex) {
        MidPointUtils.publishExceptionNotification(getProject(), getEnvironment(), DownloadTask.class, NOTIFICATION_KEY, "Exception occurred when searching for " + type.getValue(), ex);
    }
    if (!files.isEmpty() && openAfterDownload) {
        ApplicationManager.getApplication().invokeAndWait(() -> MidPointUtils.openFile(getProject(), files.get(0)));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) ArrayList(java.util.ArrayList) SearchResult(com.evolveum.midpoint.studio.client.SearchResult) IOException(java.io.IOException)

Aggregations

MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)2 SearchResult (com.evolveum.midpoint.studio.client.SearchResult)2 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)1 ControlFlowException (com.intellij.openapi.diagnostic.ControlFlowException)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1