Search in sources :

Example 6 with ResourceObjectTypeDefinitionType

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

the class PageAccounts method createIntentChoices.

private IModel<List<String>> createIntentChoices() {
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> intentList = new ArrayList<>();
            ResourceItemDto dto = resourceModel.getObject();
            PrismObject<ResourceType> resourcePrism;
            if (dto == null) {
                return intentList;
            }
            String oid = dto.getOid();
            OperationResult result = new OperationResult(OPERATION_GET_INTENTS);
            try {
                resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
                ResourceType resource = resourcePrism.asObjectable();
                SchemaHandlingType schemaHandling = resource.getSchemaHandling();
                for (ResourceObjectTypeDefinitionType r : schemaHandling.getObjectType()) {
                    intentList.add(r.getIntent());
                }
            } catch (Exception e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
                error("Couldn't load intents from resource.");
                return null;
            }
            return intentList;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 7 with ResourceObjectTypeDefinitionType

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

the class TestParseResource method assertResourceJaxb.

private void assertResourceJaxb(ResourceType resourceType, boolean isSimple) throws SchemaException {
    assertEquals("Wrong oid (JAXB)", TestConstants.RESOURCE_OID, resourceType.getOid());
    assertEquals("Wrong name (JAXB)", PrismTestUtil.createPolyStringType("Embedded Test OpenDJ"), resourceType.getName());
    String expectedNamespace = TestConstants.RESOURCE_NAMESPACE;
    if (isSimple) {
        expectedNamespace = MidPointConstants.NS_RI;
    }
    assertEquals("Wrong namespace (JAXB)", expectedNamespace, ResourceTypeUtil.getResourceNamespace(resourceType));
    ObjectReferenceType connectorRef = resourceType.getConnectorRef();
    assertNotNull("No connectorRef (JAXB)", connectorRef);
    assertEquals("Wrong type in connectorRef (JAXB)", ConnectorType.COMPLEX_TYPE, connectorRef.getType());
    SearchFilterType filter = connectorRef.getFilter();
    assertNotNull("No filter in connectorRef (JAXB)", filter);
    MapXNode filterElement = filter.getFilterClauseXNode();
    assertNotNull("No filter element in connectorRef (JAXB)", filterElement);
    EvaluationTimeType resolutionTime = connectorRef.getResolutionTime();
    if (isSimple) {
        assertEquals("Wrong resolution time in connectorRef (JAXB)", EvaluationTimeType.RUN, resolutionTime);
    } else {
        assertEquals("Wrong resolution time in connectorRef (JAXB)", EvaluationTimeType.IMPORT, resolutionTime);
    }
    XmlSchemaType xmlSchemaType = resourceType.getSchema();
    SchemaHandlingType schemaHandling = resourceType.getSchemaHandling();
    if (isSimple) {
        assertNull("Schema sneaked in", xmlSchemaType);
        assertNull("SchemaHandling sneaked in", schemaHandling);
    } else {
        assertNotNull("No schema element (JAXB)", xmlSchemaType);
        SchemaDefinitionType definition = xmlSchemaType.getDefinition();
        assertNotNull("No definition element in schema (JAXB)", definition);
        List<Element> anyElements = definition.getAny();
        assertNotNull("Null element list in definition element in schema (JAXB)", anyElements);
        assertFalse("Empty element list in definition element in schema (JAXB)", anyElements.isEmpty());
        assertNotNull("No schema handling (JAXB)", schemaHandling);
        for (ResourceObjectTypeDefinitionType accountType : schemaHandling.getObjectType()) {
            String name = accountType.getIntent();
            assertNotNull("Account type without a name", name);
            assertNotNull("Account type " + name + " does not have an objectClass", accountType.getObjectClass());
            boolean foundDescription = false;
            boolean foundDepartmentNumber = false;
            for (ResourceAttributeDefinitionType attributeDefinitionType : accountType.getAttribute()) {
                if ("description".equals(ItemPathUtil.getOnlySegmentQName(attributeDefinitionType.getRef()).getLocalPart())) {
                    foundDescription = true;
                    MappingType outbound = attributeDefinitionType.getOutbound();
                    JAXBElement<?> valueEvaluator = outbound.getExpression().getExpressionEvaluator().get(0);
                    System.out.println("value evaluator for description = " + valueEvaluator);
                    assertNotNull("no expression evaluator for description", valueEvaluator);
                    assertEquals("wrong expression evaluator element name for description", SchemaConstantsGenerated.C_VALUE, valueEvaluator.getName());
                    assertEquals("wrong expression evaluator actual type for description", RawType.class, valueEvaluator.getValue().getClass());
                } else if ("departmentNumber".equals(ItemPathUtil.getOnlySegmentQName(attributeDefinitionType.getRef()).getLocalPart())) {
                    foundDepartmentNumber = true;
                    MappingType outbound = attributeDefinitionType.getOutbound();
                    VariableBindingDefinitionType source = outbound.getSource().get(0);
                    System.out.println("source for departmentNumber = " + source);
                    assertNotNull("no source for outbound mapping for departmentNumber", source);
                    //<path xmlns:z="http://z/">$user/extension/z:dept</path>
                    ItemPath expected = new ItemPath(new NameItemPathSegment(new QName("user"), true), new NameItemPathSegment(new QName("extension")), namespaces ? new NameItemPathSegment(new QName("http://z/", "dept")) : new NameItemPathSegment(new QName("dept")));
                    PrismAsserts.assertPathEqualsExceptForPrefixes("source for departmentNubmer", expected, source.getPath().getItemPath());
                }
            }
            assertTrue("ri:description attribute was not found", foundDescription);
            assertTrue("ri:departmentNumber attribute was not found", foundDepartmentNumber);
        }
        // checking <class> element in fetch result
        OperationResultType fetchResult = resourceType.getFetchResult();
        assertNotNull("No fetchResult (JAXB)", fetchResult);
        JAXBElement<?> value = fetchResult.getParams().getEntry().get(0).getEntryValue();
        assertNotNull("No fetchResult param value (JAXB)", value);
        assertEquals("Wrong value class", UnknownJavaObjectType.class, value.getValue().getClass());
        UnknownJavaObjectType unknownJavaObjectType = (UnknownJavaObjectType) value.getValue();
        assertEquals("Wrong value class", "my.class", unknownJavaObjectType.getClazz());
        assertEquals("Wrong value toString value", "my.value", unknownJavaObjectType.getToString());
    }
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 8 with ResourceObjectTypeDefinitionType

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

the class ProjectionValuesProcessor method formatIterationToken.

private <F extends ObjectType> String formatIterationToken(LensContext<F> context, LensProjectionContext accountContext, int iteration, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    ResourceObjectTypeDefinitionType accDef = accountContext.getResourceObjectTypeDefinitionType();
    if (accDef == null) {
        return LensUtil.formatIterationTokenDefault(iteration);
    }
    IterationSpecificationType iterationType = accDef.getIteration();
    ExpressionVariables variables = createExpressionVariables(context, accountContext);
    return LensUtil.formatIterationToken(context, accountContext, iterationType, iteration, expressionFactory, variables, task, result);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) IterationSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.IterationSpecificationType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)

Example 9 with ResourceObjectTypeDefinitionType

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

the class ResourceCarefulAntUtil method createNewSchemaHandling.

private static SchemaHandlingType createNewSchemaHandling(File resourceFile, int iteration, PrismContext prismContext) throws SchemaException {
    PrismObject<ResourceType> resource = parseResource(resourceFile, prismContext);
    SchemaHandlingType schemaHandling = resource.asObjectable().getSchemaHandling();
    ResourceObjectTypeDefinitionType accountType = schemaHandling.getObjectType().iterator().next();
    List<ResourceAttributeDefinitionType> attrDefs = accountType.getAttribute();
    ResourceAttributeDefinitionType attributeDefinitionType = attrDefs.get(rnd.nextInt(attrDefs.size()));
    attributeDefinitionType.setDescription(Integer.toString(iteration));
    return schemaHandling;
}
Also used : SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ResourceAttributeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Example 10 with ResourceObjectTypeDefinitionType

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

the class TestSanity method checkOpenDjSchemaHandling.

private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
    SchemaHandlingType schemaHandling = resource.getSchemaHandling();
    for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
        if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
            assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
        if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
            String name = resObjectTypeDef.getIntent();
            assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
            assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
        }
    }
}
Also used : SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)

Aggregations

ResourceObjectTypeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType)15 ResourceActivationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType)4 SchemaHandlingType (com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType)4 IterationSpecificationType (com.evolveum.midpoint.xml.ns._public.common.common_3.IterationSpecificationType)3 ResourceBidirectionalMappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType)3 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)2 SynchronizationIntent (com.evolveum.midpoint.model.impl.lens.SynchronizationIntent)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ResourceAttributeDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)2 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)2 ActivationValidityCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType)2 ArrayList (java.util.ArrayList)2 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1