use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class OperationResultDialog method saveResult.
private void saveResult(final Project project, ProgressIndicator indicator, final VirtualFileWrapper fileWrapper, OperationResult result) {
MidPointService mm = MidPointService.getInstance(project);
EnvironmentService em = EnvironmentService.getInstance(project);
Environment environment = em.getSelected();
RunnableUtils.runWriteActionAndWait(() -> {
File file = fileWrapper.getFile();
try {
if (file.exists()) {
file.delete();
}
file.createNewFile();
} catch (IOException ex) {
mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
}
VirtualFile vFile = fileWrapper.getVirtualFile();
try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(vFile.getOutputStream(this), vFile.getCharset()))) {
MidPointClient client = new MidPointClient(project, environment);
PrismContext ctx = client.getPrismContext();
PrismSerializer<String> serializer = ctx.serializerFor(PrismContext.LANG_XML);
String xml = serializer.serializeAnyData(result.createOperationResultType(), SchemaConstantsGenerated.C_OPERATION_RESULT);
IOUtils.write(xml, out);
} catch (IOException | SchemaException ex) {
mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
}
});
}
use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class DocumentationAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent evt) {
MidPointService mm = MidPointService.getInstance(evt.getProject());
MidPointSettings settings = mm.getSettings();
DocGeneratorOptions opts = settings.getDocGeneratorOptions();
if (opts == null) {
opts = DocGeneratorOptions.createDefaultOptions(evt.getProject());
}
DocumentationDialog dialog = new DocumentationDialog(evt.getProject(), opts);
if (!dialog.showAndGet()) {
return;
}
opts = dialog.getOptions();
settings.setDocGeneratorOptions(opts);
mm.settingsUpdated();
GenerateOptions options = DocGeneratorOptions.buildGenerateOptions(opts);
File exportOutput = opts.getExportOutput();
File adocOutput = new File(exportOutput.getParent(), exportOutput.getName() + ".adoc");
options.setAdocOutput(adocOutput);
this.options = options;
super.actionPerformed(evt);
}
use of com.evolveum.midpoint.studio.impl.MidPointService 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");
}
use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class FileUtils method createScratchFile.
public static VirtualFile createScratchFile(Project project, Environment env, String fileNamePrefix) throws IOException {
Map<String, String> params = new HashMap<>();
// environment short name
params.put("s", env.getShortName());
// environment name
params.put("e", env.getName());
MidPointService mm = MidPointService.getInstance(project);
MidPointSettings settings = mm.getSettings();
return createFile(project, params, null, null, null, settings.getGeneratedFilePattern(), fileNamePrefix, false);
}
Aggregations