Skip to content

Commit

Permalink
Merge branch 'master' into closure
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 8, 2014
2 parents b648b10 + db6faed commit fa2a420
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 153 deletions.
Expand Up @@ -20,7 +20,9 @@
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ConnectorTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -187,6 +189,12 @@ private List<PropertyWrapper> createProperties(PageBase pageBase) {
} else {
definition = containerDefinition;
}
} else if (ResourceType.class.isAssignableFrom(clazz)) {
if (containerDefinition != null){
definition = containerDefinition;
} else{
definition = container.getDefinition();
}
} else {
definition = containerDefinition;
}
Expand Down
Expand Up @@ -357,11 +357,8 @@ private List<ContainerWrapper> createReportContainers(PageBase pageBase) throws
private List<ContainerWrapper> createResourceContainers(PageBase pageBase) throws SchemaException {
List<ContainerWrapper> containers = new ArrayList<ContainerWrapper>();
PrismObject<ConnectorType> connector = loadConnector();

containers.add(createResourceContainerWrapper(SchemaConstants.ICF_CONFIGURATION_PROPERTIES, connector, pageBase));
containers.add(createResourceContainerWrapper(SchemaConstants.ICF_CONNECTOR_POOL_CONFIGURATION, connector, pageBase));
containers.add(createResourceContainerWrapper(SchemaConstants.ICF_TIMEOUTS, connector, pageBase));


containers.addAll(createResourceContainerWrapper(connector, pageBase));
return containers;
}

Expand All @@ -371,30 +368,22 @@ private PrismObject<ConnectorType> loadConnector() {
//todo reimplement
}

private ContainerWrapper createResourceContainerWrapper(QName name, PrismObject<ConnectorType> connector, PageBase pageBase)
private List<ContainerWrapper> createResourceContainerWrapper(PrismObject<ConnectorType> connector, PageBase pageBase)
throws SchemaException {

PrismContainer container = object.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
if (container != null && container.size() == 1 && container.getValue() != null) {
PrismContainerValue value = container.getValue();
container = value.findContainer(name);
}

ConnectorType connectorType = connector.asObjectable();
PrismSchema schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, connector.getPrismContext());
PrismContainerDefinition definition = ConnectorTypeUtil.findConfigurationContainerDefintion(connectorType, schema);

ContainerStatus status = container != null ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
if (container == null) {
ConnectorType connectorType = connector.asObjectable();
PrismSchema schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, connector.getPrismContext());
PrismContainerDefinition definition = ConnectorTypeUtil.findConfigurationContainerDefintion(connectorType, schema);

definition = definition.findContainerDefinition(new ItemPath(name));
container = definition.instantiate();
}

ContainerWrapper wrapper = new ContainerWrapper(this, container, status,
new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, name), pageBase);
addSubresult(wrapper.getResult());

return wrapper;

return createContainerWrapper(container, new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION), pageBase);

}

private List<ContainerWrapper> createContainerWrapper(PrismContainer parent, ItemPath path, PageBase pageBase) {
Expand Down Expand Up @@ -432,7 +421,7 @@ private List<ContainerWrapper> createContainerWrapper(PrismContainer parent, Ite
}

ItemPath newPath = createPropertyPath(parentPath, containerDef.getName());
PrismContainer prismContainer = object.findContainer(def.getName());
PrismContainer prismContainer = parent.findContainer(def.getName());
ContainerWrapper container;
if (prismContainer != null) {
container = new ContainerWrapper(this, prismContainer, ContainerStatus.MODIFYING, newPath, pageBase);
Expand Down
Expand Up @@ -78,7 +78,10 @@ public void revive(PrismContext prismContext) throws SchemaException {
}

protected PrismPropertyDefinition getItemDefinition() {
PrismPropertyDefinition propDef = container.getContainerDefinition().findPropertyDefinition(property.getDefinition().getName());
PrismPropertyDefinition propDef = null;
if (container.getContainerDefinition() != null){
propDef = container.getContainerDefinition().findPropertyDefinition(property.getDefinition().getName());
}
if (propDef == null) {
propDef = property.getDefinition();
}
Expand Down
Expand Up @@ -20,11 +20,13 @@

<div class="row">
<div class="col-xs-5 col-sm-4 col-sm-offset-1 col-md-6 col-md-offset-1 col-lg-offset-1 col-lg-6">
<form wicket:id="main">
<div wicket:id="configuration" />

</form>
<div class="main-button-bar">
<a class="btn btn-info" wicket:id="testConnection"/>
</div>

</div>
<div class="col-md-6">
<!-- todo split configuration into two columns... -->
Expand Down
Expand Up @@ -88,8 +88,12 @@ protected ObjectWrapper load() {
}

private void initLayout() {
com.evolveum.midpoint.web.component.form.Form form = new com.evolveum.midpoint.web.component.form.Form<>("main", true);
form.setOutputMarkupId(true);
add(form);

final PrismObjectPanel configuration = new PrismObjectPanel(ID_CONFIGURATION, configurationProperties, null, null);
add(configuration);
form.add(configuration);

AjaxSubmitButton testConnection = new AjaxSubmitButton(ID_TEST_CONNECTION,
createStringResource("ConfigurationStep.button.testConnection")) {
Expand Down
Expand Up @@ -204,6 +204,13 @@ private XSSchemaSet parseSchema(Element schema) throws SchemaException {
} catch (TransformerException e) {
throw new SchemaException("XML transformer error during XSD schema parsing: "
+ e.getMessage() + "(locator: "+e.getLocator()+", embedded exception:"+ e.getException()+") in "+shortDescription, e);
} catch (RuntimeException e) {
// This sometimes happens, e.g. NPEs in Saxon
if (LOGGER.isErrorEnabled()) {
LOGGER.error("Unexpected error {} during parsing of schema:\n{}",e.getMessage(),DOMUtil.serializeDOMToString(schema));
}
throw new SchemaException("XML error during XSD schema parsing: "
+ e.getMessage() + " in "+shortDescription, e);
}

return xss;
Expand Down
Expand Up @@ -131,115 +131,6 @@ public void initSystem(Task initTask, OperationResult initResult)
InternalMonitor.setTraceShadowFetchOperation(true);
InternalMonitor.setTraceResourceSchemaOperations(true);
}

@Test
public void test040GetResource() throws Exception {
TestUtil.displayTestTile(this, "test040GetResource");

// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test040GetResource");
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);

// WHEN
PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result);

// THEN
assertResource(resource);

result.computeStatus();
TestUtil.assertSuccess("getObject result", result);

assertSteadyResources();
}

@Test
public void test041SearchResources() throws Exception {
final String TEST_NAME = "test041SearchResources";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);

// WHEN
List<PrismObject<ResourceType>> resources = modelService.searchObjects(ResourceType.class, null, null, task, result);

// THEN
assertNotNull("null search return", resources);
assertFalse("Empty search return", resources.isEmpty());
assertEquals("Unexpected number of resources found", 8, resources.size());

result.computeStatus();
TestUtil.assertSuccess("searchObjects result", result);

for (PrismObject<ResourceType> resource: resources) {
assertResource(resource);
}

assertSteadyResources();
}

@Test
public void test042SearchResourcesIterative() throws Exception {
final String TEST_NAME = "test042SearchResourcesIterative";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);

final List<PrismObject<ResourceType>> resources = new ArrayList<PrismObject<ResourceType>>();

ResultHandler<ResourceType> handler = new ResultHandler<ResourceType>() {
@Override
public boolean handle(PrismObject<ResourceType> resource, OperationResult parentResult) {
try {
assertResource(resource);
} catch (JAXBException e) {
throw new RuntimeException(e.getMessage(),e);
}
resources.add(resource);
return true;
}
};

// WHEN
modelService.searchObjectsIterative(ResourceType.class, null, handler, null, task, result);

// THEN
result.computeStatus();
TestUtil.assertSuccess("searchObjects result", result);

assertFalse("Empty search return", resources.isEmpty());
assertEquals("Unexpected number of resources found", 8, resources.size());

assertSteadyResources();
}

private void assertResource(PrismObject<ResourceType> resource) throws JAXBException {
display("Resource", resource);
display("Resource def", resource.getDefinition());
PrismContainer<ConnectorConfigurationType> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No Resource connector configuration def", configurationContainer);
PrismContainerDefinition<ConnectorConfigurationType> configurationContainerDefinition = configurationContainer.getDefinition();
display("Resource connector configuration def", configurationContainerDefinition);
display("Resource connector configuration def complex type def", configurationContainerDefinition.getComplexTypeDefinition());
assertNotNull("Empty Resource connector configuration def", configurationContainer.isEmpty());
assertEquals("Wrong compile-time class in Resource connector configuration in "+resource, ConnectorConfigurationType.class,
configurationContainer.getCompileTimeClass());
assertEquals("configurationContainer maxOccurs", 1, configurationContainerDefinition.getMaxOccurs());

resource.checkConsistence(true, true);

// Try to marshal using pure JAXB as a rough test that it is OK JAXB-wise
// skipped because of parsing changes [pm]
// Element resourceDomElement = prismContext.getPrismJaxbProcessor().marshalJaxbObjectToDom(resource.asObjectable(), new QName(SchemaConstants.NS_C, "resource"),
// DOMUtil.getDocument());
// display("Resouce DOM element after JAXB marshall", resourceDomElement);
}

@Test
public void test050GetUserJack() throws Exception {
Expand Down

0 comments on commit fa2a420

Please sign in to comment.