Search in sources :

Example 1 with MidPointClient

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");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) IOException(java.io.IOException) Project(com.intellij.openapi.project.Project) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) ShowResultNotificationAction(com.evolveum.midpoint.studio.impl.ShowResultNotificationAction) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment)

Example 2 with MidPointClient

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;
}
Also used : MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment)

Example 3 with MidPointClient

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);
}
Also used : SearchResultList(com.evolveum.midpoint.schema.SearchResultList) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) ComboObjectTypes(com.evolveum.midpoint.studio.action.browse.ComboObjectTypes) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException)

Example 4 with MidPointClient

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());
    }
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ComboObjectTypes(com.evolveum.midpoint.studio.action.browse.ComboObjectTypes) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException) RunnableUtils(com.evolveum.midpoint.studio.util.RunnableUtils) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) ComboQueryType(com.evolveum.midpoint.studio.action.browse.ComboQueryType) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) ComboQueryType(com.evolveum.midpoint.studio.action.browse.ComboQueryType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 5 with MidPointClient

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");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) SchemaFileType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)12 Environment (com.evolveum.midpoint.studio.impl.Environment)7 IOException (java.io.IOException)5 EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)2 ComboObjectTypes (com.evolveum.midpoint.studio.action.browse.ComboObjectTypes)2 TestConnectionResult (com.evolveum.midpoint.studio.client.TestConnectionResult)2 MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)2 SchemaFileType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ObjectValidator (com.evolveum.midpoint.schema.validator.ObjectValidator)1 ValidationItem (com.evolveum.midpoint.schema.validator.ValidationItem)1 ValidationResult (com.evolveum.midpoint.schema.validator.ValidationResult)1 ComboQueryType (com.evolveum.midpoint.studio.action.browse.ComboQueryType)1