Search in sources :

Example 61 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class ObjectPolicyPanel method createObjectTemplateList.

protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
    return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {

        @Override
        public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
            List<PrismObject<ObjectTemplateType>> templateList = null;
            List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
            OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            try {
                templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
                result.recomputeStatus();
            } catch (Exception e) {
                result.recordFatalError("Could not get list of object templates", e);
                LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
            // TODO - show this error in GUI
            }
            if (templateList != null) {
                ObjectTemplateType template;
                for (PrismObject<ObjectTemplateType> obj : templateList) {
                    template = obj.asObjectable();
                    list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
                }
            }
            return list;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 62 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class PageDebugList method loadResources.

private List<ObjectViewDto> loadResources() {
    List<ObjectViewDto> objects = new ArrayList<>();
    try {
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        List<PrismObject<ResourceType>> list = WebModelServiceUtils.searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result, this, null);
        for (PrismObject obj : list) {
            ObjectViewDto dto = new ObjectViewDto(obj.getOid(), WebComponentUtil.getName(obj));
            objects.add(dto);
        }
    } catch (Exception ex) {
    // todo implement error handling
    }
    Collections.sort(objects, (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()));
    return objects;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 63 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class TestRefinedSchema method assertAccountShadow.

private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<ResourceType> resource, PrismContext prismContext) throws SchemaException, JAXBException {
    ResourceType resourceType = resource.asObjectable();
    QName objectClassQName = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass");
    PrismAsserts.assertPropertyValue(accObject, ShadowType.F_NAME, createPolyString("jack"));
    PrismAsserts.assertPropertyValue(accObject, ShadowType.F_OBJECT_CLASS, objectClassQName);
    PrismAsserts.assertPropertyValue(accObject, ShadowType.F_INTENT, SchemaConstants.INTENT_DEFAULT);
    PrismContainer<?> attributes = accObject.findOrCreateContainer(SchemaConstants.C_ATTRIBUTES);
    assertEquals("Wrong type of <attributes> definition in account", ResourceAttributeContainerDefinitionImpl.class, attributes.getDefinition().getClass());
    ResourceAttributeContainerDefinition attrDef = (ResourceAttributeContainerDefinition) attributes.getDefinition();
    assertAttributeDefs(attrDef, resourceType, null, LayerType.MODEL);
    PrismAsserts.assertPropertyValue(attributes, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
    PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "cn"), "Jack Sparrow");
    PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "givenName"), "Jack");
    PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "sn"), "Sparrow");
    PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "uid"), "jack");
    assertEquals("JAXB class name doesn't match (1)", ShadowType.class, accObject.getCompileTimeClass());
    accObject.checkConsistence();
    ShadowType accObjectType = accObject.asObjectable();
    assertEquals("Wrong JAXB name", createPolyStringType("jack"), accObjectType.getName());
    assertEquals("Wrong JAXB objectClass", objectClassQName, accObjectType.getObjectClass());
    ShadowAttributesType attributesType = accObjectType.getAttributes();
    assertNotNull("null ResourceObjectShadowAttributesType (JAXB)", attributesType);
    List<Object> attributeElements = attributesType.getAny();
    TestUtil.assertElement(attributeElements, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
    TestUtil.assertElement(attributeElements, getAttrQName(resource, "cn"), "Jack Sparrow");
    TestUtil.assertElement(attributeElements, getAttrQName(resource, "givenName"), "Jack");
    TestUtil.assertElement(attributeElements, getAttrQName(resource, "sn"), "Sparrow");
    TestUtil.assertElement(attributeElements, getAttrQName(resource, "uid"), "jack");
    String accString = PrismTestUtil.serializeObjectToString(accObjectType.asPrismObject());
    System.out.println("Result of JAXB marshalling:\n" + accString);
    accObject.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH);
}
Also used : QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 64 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class BasicValidatorTest method handlerTest.

@Test
public void handlerTest() throws Exception {
    System.out.println("\n===[ handlerTest ]=====");
    OperationResult result = new OperationResult(this.getClass().getName() + ".handlerTest");
    final List<String> postMarshallHandledOids = new ArrayList<String>();
    final List<String> preMarshallHandledOids = new ArrayList<String>();
    EventHandler handler = new EventHandler() {

        @Override
        public EventResult preMarshall(Element objectElement, Node postValidationTree, OperationResult objectResult) {
            preMarshallHandledOids.add(objectElement.getAttribute("oid"));
            return EventResult.cont();
        }

        @Override
        public <T extends Objectable> EventResult postMarshall(PrismObject<T> object, Element objectElement, OperationResult objectResult) {
            System.out.println("Handler processing " + object + ", result:");
            System.out.println(objectResult.debugDump());
            postMarshallHandledOids.add(object.getOid());
            return EventResult.cont();
        }

        @Override
        public void handleGlobalError(OperationResult currentResult) {
            System.out.println("Handler got global error:");
            System.out.println(currentResult.debugDump());
        }
    };
    validateFile("three-objects.xml", handler, result);
    System.out.println(result.debugDump());
    AssertJUnit.assertTrue("Result is not success", result.isSuccess());
    AssertJUnit.assertTrue(postMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111111"));
    AssertJUnit.assertTrue(preMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111111"));
    AssertJUnit.assertTrue(postMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111112"));
    AssertJUnit.assertTrue(preMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111112"));
    AssertJUnit.assertTrue(postMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111113"));
    AssertJUnit.assertTrue(preMarshallHandledOids.contains("c0c010c0-d34d-b33f-f00d-111111111113"));
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Objectable(com.evolveum.midpoint.prism.Objectable) ArrayList(java.util.ArrayList) EventHandler(com.evolveum.midpoint.common.validator.EventHandler) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 65 with PrismObject

use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.

the class InternalMonitor method afterObjectClone.

@Override
public synchronized <O extends Objectable> void afterObjectClone(PrismObject<O> orig, PrismObject<O> clone) {
    prismObjectCloneCount++;
    Object cloneStartObject = orig.getUserData(CLONE_START_TIMESTAMP_KEY);
    if (cloneStartObject != null && cloneStartObject instanceof Long) {
        long cloneDurationMillis = System.currentTimeMillis() - (Long) cloneStartObject;
        prismObjectCloneDurationMillis += cloneDurationMillis;
        LOGGER.debug("MONITOR prism object clone end: {} (duration {} ms)", orig, cloneDurationMillis);
    } else {
        LOGGER.debug("MONITOR prism object clone end: {}", orig);
    }
    if (tracePrismObjectClone) {
        traceOperation("prism object clone", null, prismObjectCloneCount, false);
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)488 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)358 Test (org.testng.annotations.Test)227 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)219 Task (com.evolveum.midpoint.task.api.Task)205 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)97 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)95 ArrayList (java.util.ArrayList)81 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)79 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)64 QName (javax.xml.namespace.QName)59 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)50 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)40 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)37 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)37 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)37 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)37 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)37 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)35 SystemException (com.evolveum.midpoint.util.exception.SystemException)34