Search in sources :

Example 11 with MidPointClient

use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.

the class VerifyAction method processFiles.

private void processFiles(AnActionEvent evt, MidPointService mm, Environment env, List<VirtualFile> files) {
    ObjectValidator validator = new ObjectValidator(MidPointUtils.DEFAULT_PRISM_CONTEXT);
    validator.setAllWarnings();
    MidPointClient client = new MidPointClient(evt.getProject(), env);
    for (VirtualFile file : files) {
        RunnableUtils.runReadAction(() -> {
            try {
                List<MidPointObject> objects = MidPointUtils.parseProjectFile(evt.getProject(), file, NOTIFICATION_KEY);
                for (MidPointObject obj : objects) {
                    try {
                        PrismObject object = client.parseObject(obj.getContent());
                        ValidationResult validationResult = validator.validate(object);
                        for (ValidationItem validationItem : validationResult.getItems()) {
                            String msg = buildValidationItem(object, validationItem);
                            mm.printToConsole(env, VerifyAction.class, msg);
                        }
                    } catch (Exception ex) {
                        mm.printToConsole(env, VerifyAction.class, "Couldn't parse object '" + obj.getName() + "'(" + obj.getType() + ") from file '" + file.getPath() + "', reason: " + ex.getMessage());
                    }
                }
            } catch (Exception ex) {
                mm.printToConsole(env, VerifyAction.class, "Couldn't parse objects from file '" + file.getPath() + "', reason: " + ex.getMessage());
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PrismObject(com.evolveum.midpoint.prism.PrismObject) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) ValidationItem(com.evolveum.midpoint.schema.validator.ValidationItem) ObjectValidator(com.evolveum.midpoint.schema.validator.ObjectValidator) ValidationResult(com.evolveum.midpoint.schema.validator.ValidationResult) IOException(java.io.IOException)

Example 12 with MidPointClient

use of com.evolveum.midpoint.studio.impl.MidPointClient in project midpoint-studio by Evolveum.

the class ClientBackgroundableTask method setupMidpointClient.

private MidPointClient setupMidpointClient() {
    LOG.debug("Setting up MidPoint client");
    Environment env = getEnvironment();
    midPointService.printToConsole(env, getClass(), "Setting up midPoint client");
    MidPointClient client = new MidPointClient(getProject(), env);
    LOG.debug("MidPoint client setup done");
    return client;
}
Also used : MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment)

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