private ConnectorStruct getConnectorStruct(ConnectorType connectorType) throws ObjectNotFoundException { if (connectorMap == null) { discoverConnectors(); } String type = connectorType.getConnectorType(); ConnectorStruct struct = connectorMap.get(type); if (struct == null) { throw new ObjectNotFoundException("No built-in connector type "+type); } return struct; }
private ConnectorKey getConnectorKey(ConnectorType connectorType) { return new ConnectorKey(connectorType.getConnectorBundle(), connectorType.getConnectorVersion(), connectorType.getConnectorType()); }
@Override public ConnectorInstance createConnectorInstance(ConnectorType connectorType, String namespace, String instanceName, String desc) throws ObjectNotFoundException, SchemaException { String type = connectorType.getConnectorType(); ConnectorStruct struct = connectorMap.get(type); Class<? extends ConnectorInstance> connectorClass = struct.connectorClass; ConnectorInstance connectorInstance; try { connectorInstance = connectorClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new ObjectNotFoundException("Cannot create instance of connector "+connectorClass+": "+e.getMessage(), e); } if (connectorInstance instanceof AbstractManagedConnectorInstance) { setupAbstractConnectorInstance((AbstractManagedConnectorInstance)connectorInstance, connectorType, namespace, desc, struct); } if (connectorInstance instanceof RepositoryAware) { ((RepositoryAware)connectorInstance).setRepositoryService(repositoryService); } if (connectorInstance instanceof CaseManagerAware) { ((CaseManagerAware)connectorInstance).setCaseManager(caseManager); } if (connectorInstance instanceof TaskManagerAware) { ((TaskManagerAware)connectorInstance).setTaskManager(taskManager); } return connectorInstance; }
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; }
@Test public void testSearchConnectorSimple() throws SchemaException{ final String TEST_NAME = "testSearchConnectorSimple"; displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); PrismObject<ConnectorType> ldapConnector = findConnectorByType(IntegrationTestTools.LDAP_CONNECTOR_TYPE, result); assertEquals("Type does not match", IntegrationTestTools.LDAP_CONNECTOR_TYPE, ldapConnector.asObjectable().getConnectorType()); }
@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()); }
@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); } } }
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() .build(); 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) .build(); + " : " + 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.");
.and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(connectorType.getConnectorType()) .build(); List<PrismObject<ConnectorType>> foundConnectors; foundConnectors = modelService.searchObjects(ConnectorType.class, query, null, null, result); } catch (SchemaException|ConfigurationException|ObjectNotFoundException|CommunicationException|SecurityViolationException|ExpressionEvaluationException e) { throw new ScriptExecutionException("Couldn't get connectors of type: " + connectorType.getConnectorType() + ": " + e.getMessage(), e);
private ConnectorInstance createConnectorInstance(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { ConnectorType connectorType = getConnectorTypeReadOnly(connectorSpec, result); ConnectorFactory connectorFactory = determineConnectorFactory(connectorType); ConnectorInstance connector = null; try { InternalMonitor.recordCount(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT); connector = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(connectorSpec.getResource()), connectorSpec.getResource().getName().toString(), connectorSpec.toString()); } catch (ObjectNotFoundException e) { result.recordFatalError(e.getMessage(), e); throw new ObjectNotFoundException(e.getMessage(), e); } // This log message should be INFO level. It happens only occasionally. // If it happens often, it may be an // indication of a problem. Therefore it is good for admin to see it. LOGGER.info("Created new connector instance for {}: {} v{}", connectorSpec, connectorType.getConnectorType(), connectorType.getConnectorVersion()); return connector; }
display("Connector", connector); ConnectorType connectorType = connector.asObjectable(); if (CONNECTOR_DUMMY_TYPE.equals(connectorType.getConnectorType())) { String connectorVersion = connectorType.getConnectorVersion(); if (connectorVersion.contains("fake")) {
LOGGER.trace("Connector host object: {}", ObjectTypeUtil.dump(connectorType.getConnectorHost())); throw new ObjectNotFoundException("The classes (JAR) of " + ObjectTypeUtil.toShortString(connectorType) + " were not found by the ICF framework; bundle="+connectorType.getConnectorBundle()+" connector type=" + connectorType.getConnectorType() + ", version="+connectorType.getConnectorVersion());
assertEquals("org.identityconnectors.databasetable.DatabaseTableConnector", connector.getConnectorType());