Search in sources :

Example 1 with SchemaFilesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType in project midpoint by Evolveum.

the class TestSchemaRestService method test010listSchemas.

@Test
public void test010listSchemas() {
    WebClient client = prepareClient();
    when();
    Response response = client.get();
    then();
    assertStatus(response, 200);
    SchemaFilesType schemas = response.readEntity(SchemaFilesType.class);
    assertNotNull("Error response must contain list of schemas", schemas);
    logger.info("Returned result: {}", schemas);
    assertAndGetPiracySchemaFile(schemas);
}
Also used : Response(javax.ws.rs.core.Response) SchemaFilesType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 2 with SchemaFilesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType 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;
}
Also used : SchemaFileType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType)

Example 3 with SchemaFilesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType 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);
}
Also used : Response(javax.ws.rs.core.Response) SchemaFilesType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType) SchemaFileType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType) WebClient(org.apache.cxf.jaxrs.client.WebClient) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with SchemaFilesType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType 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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SchemaDescription(com.evolveum.midpoint.prism.schema.SchemaDescription) SchemaFilesType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType) SchemaFileType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

SchemaFileType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFileType)3 SchemaFilesType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaFilesType)3 Response (javax.ws.rs.core.Response)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 Test (org.testng.annotations.Test)2 SchemaDescription (com.evolveum.midpoint.prism.schema.SchemaDescription)1 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 File (java.io.File)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1