use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType in project midpoint by Evolveum.
the class TestSchemaRestService method assertAndGetPiracySchemaFile.
private SchemaFileType assertAndGetPiracySchemaFile(SchemaFilesType schemas) {
assertNotNull("Schema file list must no be null", schemas);
assertEquals(1, schemas.getSchema().size());
SchemaFileType schemaFile = schemas.getSchema().get(0);
assertEquals("piracy.xsd", schemaFile.getFileName());
assertEquals("http://midpoint.evolveum.com/xml/ns/samples/piracy", schemaFile.getNamespace());
assertEquals(null, schemaFile.getUsualPrefix());
return schemaFile;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType 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");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType in project midpoint-studio by Evolveum.
the class TestAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent evt) {
if (evt.getProject() == null) {
return;
}
// Project project = evt.getProject();
//
// ResourceWizard wizard = ResourceWizard.createWizard(project);
// wizard.showAndGet();
RunnableUtils.executeWithPluginClassloader(() -> {
EnvironmentService es = EnvironmentService.getInstance(evt.getProject());
MidPointClient client = new MidPointClient(evt.getProject(), es.getSelected(), true, true);
Map<SchemaFileType, String> result = client.getExtensionSchemas();
System.out.println(result);
return result;
});
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType in project midpoint by Evolveum.
the class ExtensionSchemaRestController method listSchemas.
@GetMapping
public ResponseEntity<?> listSchemas() {
Task task = initRequest();
OperationResult result = createSubresult(task, "listSchemas");
ResponseEntity<?> response;
try {
securityEnforcer.authorize(ModelAuthorizationAction.GET_EXTENSION_SCHEMA.getUrl(), null, AuthorizationParameters.EMPTY, null, task, result);
SchemaRegistry registry = prismContext.getSchemaRegistry();
Collection<SchemaDescription> descriptions = registry.getSchemaDescriptions();
SchemaFilesType files = new SchemaFilesType();
for (SchemaDescription description : descriptions) {
String name = computeName(description);
if (name == null) {
continue;
}
files.schema(new SchemaFileType().namespace(description.getNamespace()).usualPrefix(description.getUsualPrefix()).fileName(name));
}
response = ResponseEntity.ok(files);
} catch (Exception ex) {
result.recordFatalError(ex);
response = handleException(result, ex);
}
finishRequest(task, result);
return response;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType in project midpoint by Evolveum.
the class TestSchemaRestService method test020getSchema.
@Test
public void test020getSchema() throws IOException {
WebClient client = prepareClient();
when();
Response response = client.get();
SchemaFilesType schemas = response.readEntity(SchemaFilesType.class);
SchemaFileType file = assertAndGetPiracySchemaFile(schemas);
client.path("/" + file.getFileName());
client.accept(MediaType.TEXT_PLAIN_TYPE);
response = client.get();
then();
assertStatus(response, 200);
String content = response.readEntity(String.class);
String expected = FileUtils.readFileToString(new File("./src/test/resources/schema/piracy.xsd"), StandardCharsets.UTF_8);
assertEquals("Schemas doesn't match", expected, content);
}
Aggregations