public String getHumanReadableName() { return connectorType.toString() + ": " + description; }
public static PrismSchema getConnectorSchema(ConnectorType connectorType, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchema = connectorType.getSchema(); if (xmlSchema == null) { return null; } Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchema); if (xsdElement == null) { return null; } MutablePrismSchema connectorSchema = prismContext.schemaFactory().createPrismSchema(); connectorSchema.parseThis(xsdElement, true, connectorType.toString(), prismContext); return connectorSchema; }
@Override public void initialize(ResourceSchema resourceSchema, Collection<Object> capabilities, boolean caseIgnoreAttributeNames, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException { OperationResult result = parentResult.createSubresult(ConnectorInstance.OPERATION_INITIALIZE); result.addContext("connector", getConnectorObject().toString()); result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, this.getClass()); setResourceSchema(resourceSchema); setCapabilities(capabilities); connect(result); result.recordSuccessIfUnknown(); }
@Override public void test(OperationResult parentResult) { OperationResult connectionResult = parentResult .createSubresult(ConnectorTestOperation.CONNECTOR_CONNECTION.getOperation()); connectionResult.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ManualConnectorInstance.class); connectionResult.addContext("connector", getConnectorObject().toString()); if (repositoryService == null) { connectionResult.recordFatalError("No repository service"); return; } if (!connected && InternalsConfig.isSanityChecks()) { throw new IllegalStateException("Attempt to test non-connected connector instance "+this); } connectionResult.recordSuccess(); }
@Test public void testListConnectors() throws Exception{ TestUtil.displayTestTitle("testListConnectors"); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + ".listConnectorsTest"); List<PrismObject<ConnectorType>> connectors = provisioningService.searchObjects(ConnectorType.class, null, null, null, result); assertNotNull(connectors); for (PrismObject<ConnectorType> connector : connectors){ ConnectorType conn = connector.asObjectable(); System.out.println(conn.toString()); System.out.println("connector name: "+ conn.getName()); System.out.println("connector type: "+ conn.getConnectorType()); System.out.println("-----\n"); } assertEquals("Unexpected number of connectors found", 8, connectors.size()); }
public static void assertConnectorSchemaSanity(ConnectorType conn, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchemaType = conn.getSchema(); assertNotNull("xmlSchemaType is null",xmlSchemaType); Element connectorXsdSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(conn); assertNotNull("No schema", connectorXsdSchemaElement); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaType); assertNotNull("No xsd:schema element in xmlSchemaType",xsdElement); display("XSD schema of "+conn, DOMUtil.serializeDOMToString(xsdElement)); // Try to parse the schema PrismSchema schema = null; try { schema = PrismSchemaImpl.parse(xsdElement, true, "schema of "+conn, prismContext); } catch (SchemaException e) { throw new SchemaException("Error parsing schema of "+conn+": "+e.getMessage(),e); } assertConnectorSchemaSanity(schema, conn.toString(), SchemaConstants.ICF_FRAMEWORK_URI.equals(conn.getFramework())); }
@Override public void test(OperationResult parentResult) { OperationResult connectionResult = parentResult .createSubresult(ConnectorTestOperation.CONNECTOR_CONNECTION.getOperation()); connectionResult.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ManualConnectorInstance.class); connectionResult.addContext("connector", getConnectorObject().toString()); try { DummyItsm itsm = DummyItsm.getInstance(); itsm.test(); } catch (Exception e) { LOGGER.info("TEST: "+e); connectionResult.recordFatalError(e); } if (!connected) { throw new IllegalStateException("Attempt to test non-connected connector instance "+this); } LOGGER.info("TEST: OK"); connectionResult.recordSuccess(); }