private ConnectorFactory determineConnectorFactory(ConnectorType connectorType) { if (connectorType == null) { return null; } return determineConnectorFactory(connectorType.getFramework()); }
/** * Get contect informations * * @param connectorType * @return * @throws ObjectNotFoundException */ private ConnectorInfo getConnectorInfo(ConnectorType connectorType) throws ObjectNotFoundException { if (!SchemaConstants.ICF_FRAMEWORK_URI.equals(connectorType.getFramework())) { throw new ObjectNotFoundException("Requested connector for framework " + connectorType.getFramework() + " cannot be found in framework " + SchemaConstants.ICF_FRAMEWORK_URI); } ConnectorKey key = getConnectorKey(connectorType); if (connectorType.getConnectorHost() == null && connectorType.getConnectorHostRef() == null) { // Local connector return getLocalConnectorInfoManager().findConnectorInfo(key); } ConnectorHostType host = connectorType.getConnectorHost(); if (host == null) { throw new ObjectNotFoundException( "Attempt to use remote connector without ConnectorHostType resolved (there is only ConnectorHostRef"); } return getRemoteConnectorInfoManager(host).findConnectorInfo(key); }
private boolean compareConnectors(PrismObject<ConnectorType> prismA, PrismObject<ConnectorType> prismB) { ConnectorType a = prismA.asObjectable(); ConnectorType b = prismB.asObjectable(); if (!a.getFramework().equals(b.getFramework())) { return false; } if (!a.getConnectorType().equals(b.getConnectorType())) { return false; } if (!compareConnectorHost(a, b)) { return false; } if (a.getConnectorVersion() == null && b.getConnectorVersion() == null) { // Both connectors without version. This is OK. return true; } if (a.getConnectorVersion() != null && b.getConnectorVersion() != null) { // Both connectors with version. This is OK. return a.getConnectorVersion().equals(b.getConnectorVersion()); } // One connector has version and other does not. This is inconsistency LOGGER.error("Inconsistent representation of ConnectorType, one has connectorVersion and other does not. OIDs: " + a.getOid() + " and " + b.getOid()); // Obviously they don't match return false; }
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())); }
@Test public void testSearchConnectorAnd() throws SchemaException{ TestUtil.displayTestTitle("testSearchConnectorAnd"); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + ".testSearchConnector"); ObjectQuery query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(SchemaConstants.ICF_FRAMEWORK_URI) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(IntegrationTestTools.LDAP_CONNECTOR_TYPE) .build(); System.out.println("Query:\n"+query.debugDump()); List<PrismObject<ConnectorType>> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); assertEquals("Unexpected number of results", 1, connectors.size()); PrismObject<ConnectorType> ldapConnector = connectors.get(0); assertEquals("Type does not match", IntegrationTestTools.LDAP_CONNECTOR_TYPE, ldapConnector.asObjectable().getConnectorType()); assertEquals("Framework does not match", SchemaConstants.ICF_FRAMEWORK_URI, ldapConnector.asObjectable().getFramework()); } }
public static void copyFromJAXB(ConnectorType jaxb, RConnector repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException { copyAssignmentHolderInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult); repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName())); repo.setConnectorBundle(jaxb.getConnectorBundle()); repo.setConnectorType(jaxb.getConnectorType()); repo.setConnectorVersion(jaxb.getConnectorVersion()); repo.setFramework(jaxb.getFramework()); repo.setConnectorHostRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getConnectorHostRef(), repositoryContext.relationRegistry)); if (jaxb.getConnectorHost() != null) { LOGGER.warn("Connector host from connector type won't be saved. It should be " + "translated to connector host reference."); } try { repo.setTargetSystemType(RUtil.listToSet(jaxb.getTargetSystemType())); } catch (Exception ex) { throw new DtoTranslationException(ex.getMessage(), ex); } } }
if (hostType == null) { query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(connectorType.getFramework()) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(connectorType.getConnectorType()) .and().item(ConnectorType.F_CONNECTOR_HOST_REF).isNull() } else { query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(connectorType.getFramework()) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(connectorType.getConnectorType()) .and().item(ConnectorType.F_CONNECTOR_HOST_REF).ref(hostType.getOid(), ConnectorHostType.COMPLEX_TYPE) if (foundOid != null) { result.recordPartialError("Found more than one connector that matches " + connectorType.getFramework() + " : " + connectorType.getConnectorType() + " : " + connectorType.getVersion() + ". OIDs " + foundConnector.getOid() + " and " + foundOid + ". Inconsistent database state."); LOGGER.error("Found more than one connector that matches " + connectorType.getFramework() + " : " + connectorType.getConnectorType() + " : " + connectorType.getVersion() + ". OIDs " + foundConnector.getOid() + " and " + foundOid + ". Inconsistent database state.");
LOGGER.warn("Provisioning framework {} supplied OID for connector {}", foundConnector.getFramework(), foundConnector); foundConnector.setOid(null);
.item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(connectorType.getFramework()) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(connectorType.getConnectorType()) .build();