Search in sources :

Example 26 with Environment

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

the class MatchEnvironmentPanel method createUIComponents.

private void createUIComponents() {
    environments = new ComboBox();
    environments.setRenderer(SimpleListCellRenderer.<Environment>create("All Environments", e -> e != null ? e.getName() : null));
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) java.awt(java.awt) List(java.util.List) SimpleListCellRenderer(com.intellij.ui.SimpleListCellRenderer) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) ListComboBoxModel(org.jdesktop.swingx.combobox.ListComboBoxModel) Environment(com.evolveum.midpoint.studio.impl.Environment) javax.swing(javax.swing) ArrayList(java.util.ArrayList) ComboBox(com.intellij.openapi.ui.ComboBox)

Example 27 with Environment

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

the class DownloadTask method showOnly.

public void showOnly(ProgressIndicator indicator) {
    indicator.setIndeterminate(true);
    Project project = getProject();
    Environment environment = getEnvironment();
    RunnableUtils.runWriteActionAndWait(() -> {
        BufferedWriter out = null;
        VirtualFile file = null;
        try {
            indicator.setFraction(0d);
            file = FileUtils.createScratchFile(project, environment);
            out = new BufferedWriter(new OutputStreamWriter(file.getOutputStream(this), StandardCharsets.UTF_8));
            if (oids.size() > 1) {
                out.write(ClientUtils.OBJECTS_XML_PREFIX);
            }
            if (oids != null) {
                showByOid(out);
            } else {
                showByQuery(out);
            }
            if (oids.size() > 1) {
                out.write(ClientUtils.OBJECTS_XML_SUFFIX);
            }
            MidPointUtils.openFile(project, file);
        } catch (Exception ex) {
            MidPointUtils.publishExceptionNotification(project, environment, DownloadTask.class, NOTIFICATION_KEY, "Exception occurred when preparing show only file " + (file != null ? file.getName() : null), ex);
        } finally {
            IOUtils.closeQuietly(out);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Environment(com.evolveum.midpoint.studio.impl.Environment) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 28 with Environment

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

the class TestConnectionAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    Project project = e.getProject();
    if (project == null) {
        e.getPresentation().setEnabled(false);
        return;
    }
    boolean hasFacet = MidPointUtils.hasMidPointFacet(e.getProject());
    if (!hasFacet) {
        e.getPresentation().setEnabled(false);
        return;
    }
    EnvironmentService em = EnvironmentService.getInstance(project);
    Environment selected = em.getSelected();
    e.getPresentation().setEnabled(selected != null);
}
Also used : Project(com.intellij.openapi.project.Project) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService)

Example 29 with Environment

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

the class VerifyAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile[] selectedFiles = ApplicationManager.getApplication().runReadAction((Computable<VirtualFile[]>) () -> e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY));
    if (selectedFiles == null || selectedFiles.length == 0) {
        MidPointUtils.publishNotification(project, NOTIFICATION_KEY, ACTION_NAME, "No files selected for cleanup", NotificationType.WARNING);
        return;
    }
    List<VirtualFile> toProcess = MidPointUtils.filterXmlFiles(selectedFiles);
    if (toProcess.isEmpty()) {
        MidPointUtils.publishNotification(project, NOTIFICATION_KEY, ACTION_NAME, "No files matched for verification (xml)", NotificationType.WARNING);
        return;
    }
    MidPointService mm = MidPointService.getInstance(project);
    EnvironmentService em = EnvironmentService.getInstance(project);
    Environment env = em.getSelected();
    mm.focusConsole();
    mm.printToConsole(env, VerifyAction.class, "Starting verification using midpoint schema bundled in MidPoint Studio.");
    processFiles(e, mm, env, toProcess);
    mm.printToConsole(env, VerifyAction.class, "Verification finished");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService)

Example 30 with Environment

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

the class SetLoggerTask method doRun.

@Override
protected void doRun(ProgressIndicator indicator) {
    super.doRun(indicator);
    indicator.setIndeterminate(false);
    List<ClassLoggerConfigurationType> newLoggers = buildClassLoggers();
    if (newLoggers == null || newLoggers.isEmpty()) {
        noChangeNeeded();
        return;
    }
    Environment env = getEnvironment();
    LOG.debug("Downloading system configuration");
    PrismObject<SystemConfigurationType> configPrism;
    try {
        MidPointObject object = client.get(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), new SearchOptions());
        if (object == null) {
            return;
        }
        configPrism = (PrismObject) client.parseObject(object.getContent());
        indicator.setFraction(0.5);
    } catch (Exception ex) {
        MidPointUtils.publishException(getProject(), env, getClass(), NOTIFICATION_KEY, "Couldn't download and parse system configuration", ex);
        return;
    }
    LOG.debug("Updating logging configuration");
    SystemConfigurationType config = configPrism.asObjectable();
    LoggingConfigurationType logging = config.getLogging();
    if (logging == null) {
        logging = new LoggingConfigurationType();
        config.setLogging(logging);
    }
    List<ClassLoggerConfigurationType> existing = logging.getClassLogger();
    Map<String, ClassLoggerConfigurationType> existingMap = existing.stream().collect(Collectors.toMap(o -> o.getPackage(), o -> o, (a, b) -> a));
    boolean changed = false;
    for (ClassLoggerConfigurationType cl : newLoggers) {
        ClassLoggerConfigurationType existingLogger = existingMap.get(cl.getPackage());
        if (existingLogger == null) {
            LOG.debug("Adding new class logger ", cl.getPackage(), " with level ", cl.getLevel());
            existing.add(cl);
            changed = true;
        } else {
            if (existingLogger.getLevel() != cl.getLevel()) {
                LOG.debug("Updating class logger ", existingLogger.getPackage(), " with level ", cl.getLevel());
                existingLogger.setLevel(cl.getLevel());
                changed = true;
            }
        }
    }
    if (!changed) {
        noChangeNeeded();
        indicator.setFraction(1);
        return;
    }
    LOG.debug("Uploading system configuration");
    try {
        UploadResponse resp = client.upload(configPrism, Arrays.asList(ModelExecuteOptionsType.F_OVERWRITE.getLocalPart()));
        OperationResult result = resp.getResult();
        if (result != null && !result.isSuccess()) {
            String msg = "Upload status of system configuration was " + result.getStatus();
            midPointService.printToConsole(env, getClass(), msg);
            MidPointUtils.publishNotification(getProject(), NOTIFICATION_KEY, "Warning", msg, NotificationType.WARNING, new ShowResultNotificationAction(result));
        } else {
            midPointService.printToConsole(env, getClass(), "System configuration uploaded");
        }
        indicator.setFraction(1);
    } catch (Exception ex) {
        MidPointUtils.publishException(getProject(), env, getClass(), NOTIFICATION_KEY, "Exception occurred during system configuration upload", ex);
    }
}
Also used : Arrays(java.util.Arrays) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SearchOptions(com.evolveum.midpoint.studio.impl.SearchOptions) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collectors(java.util.stream.Collectors) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) Environment(com.evolveum.midpoint.studio.impl.Environment) NotificationType(com.intellij.notification.NotificationType) MidPointUtils(com.evolveum.midpoint.studio.util.MidPointUtils) ShowResultNotificationAction(com.evolveum.midpoint.studio.impl.ShowResultNotificationAction) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) UploadResponse(com.evolveum.midpoint.studio.impl.UploadResponse) Map(java.util.Map) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SearchOptions(com.evolveum.midpoint.studio.impl.SearchOptions) UploadResponse(com.evolveum.midpoint.studio.impl.UploadResponse) MidPointObject(com.evolveum.midpoint.studio.client.MidPointObject) ShowResultNotificationAction(com.evolveum.midpoint.studio.impl.ShowResultNotificationAction) Environment(com.evolveum.midpoint.studio.impl.Environment)

Aggregations

Environment (com.evolveum.midpoint.studio.impl.Environment)32 EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)13 Project (com.intellij.openapi.project.Project)10 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)5 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 NotNull (org.jetbrains.annotations.NotNull)4 ComboObjectTypes (com.evolveum.midpoint.studio.action.browse.ComboObjectTypes)3 MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 BufferedWriter (java.io.BufferedWriter)3 OutputStreamWriter (java.io.OutputStreamWriter)3 Writer (java.io.Writer)3 List (java.util.List)3 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2