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;
}
};
}
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;
}
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);
}
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"));
}
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);
}
}
Aggregations