use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.
the class ConnectorITCase method update.
@Test
public void update() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
// set connector instance key
connectorTO.setKey("fcf9f2b0-f7d6-42c9-84a6-61b28255a42b");
// set connector version
connectorTO.setVersion(connIdSoapVersion);
// set connector name
connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
// set bundle name
connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
connectorTO.setConnRequestTimeout(20);
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<>();
ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
endpointSchema.setName("endpoint");
endpointSchema.setType(String.class.getName());
endpointSchema.setRequired(true);
ConnConfProperty endpoint = new ConnConfProperty();
endpoint.setSchema(endpointSchema);
endpoint.getValues().add("http://localhost:8888/syncope-fit-build-tools/cxf/soap");
conf.add(endpoint);
ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
servicenameSchema.setName("servicename");
servicenameSchema.setType(String.class.getName());
servicenameSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(servicenameSchema);
servicename.getValues().add("Provisioning");
conf.add(servicename);
// set connector configuration
connectorTO.getConf().addAll(conf);
connectorService.update(connectorTO);
ConnInstanceTO actual = connectorService.read(connectorTO.getKey(), Locale.ENGLISH.getLanguage());
assertNotNull(actual);
actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
assertNotNull(actual);
assertEquals(actual.getBundleName(), connectorTO.getBundleName());
assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
assertEquals(actual.getVersion(), connectorTO.getVersion());
assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
}
use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.
the class ConnInstanceDataBinderImpl method getConnInstanceTO.
@Override
public ConnInstanceTO getConnInstanceTO(final ConnInstance connInstance) {
ConnInstanceTO connInstanceTO = new ConnInstanceTO();
Pair<URI, ConnectorInfo> info = connIdBundleManager.getConnectorInfo(connInstance);
BeanUtils.copyProperties(connInstance, connInstanceTO, IGNORE_PROPERTIES);
connInstanceTO.setAdminRealm(connInstance.getAdminRealm().getFullPath());
connInstanceTO.setLocation(info.getLeft().toASCIIString());
connInstanceTO.getConf().addAll(connInstance.getConf());
// refresh stored properties in the given connInstance with direct information from underlying connector
ConfigurationProperties properties = connIdBundleManager.getConfigurationProperties(info.getRight());
properties.getPropertyNames().forEach(propName -> {
ConnConfPropSchema schema = build(properties.getProperty(propName));
Optional<ConnConfProperty> property = connInstanceTO.getConf(propName);
if (!property.isPresent()) {
property = Optional.of(new ConnConfProperty());
connInstanceTO.getConf().add(property.get());
}
property.get().setSchema(schema);
});
Collections.sort(connInstanceTO.getConf());
// pool configuration
if (connInstance.getPoolConf() != null && (connInstance.getPoolConf().getMaxIdle() != null || connInstance.getPoolConf().getMaxObjects() != null || connInstance.getPoolConf().getMaxWait() != null || connInstance.getPoolConf().getMinEvictableIdleTimeMillis() != null || connInstance.getPoolConf().getMinIdle() != null)) {
ConnPoolConfTO poolConf = new ConnPoolConfTO();
BeanUtils.copyProperties(connInstance.getPoolConf(), poolConf);
connInstanceTO.setPoolConf(poolConf);
}
return connInstanceTO;
}
use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.
the class ConnInstanceTest method save.
@Test
public void save() throws ClassNotFoundException {
ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class);
connInstance.setLocation(new File(System.getProperty("java.io.tmpdir")).toURI().toString());
// set connector version
connInstance.setVersion("1.0");
// set connector name
connInstance.setConnectorName("WebService");
// set bundle name
connInstance.setBundleName("org.apache.syncope.core.persistence.test.util");
connInstance.setDisplayName("New");
connInstance.setConnRequestTimeout(60);
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<>();
ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
endpointSchema.setName("endpoint");
endpointSchema.setType(String.class.getName());
endpointSchema.setRequired(true);
ConnConfProperty endpoint = new ConnConfProperty();
endpoint.setSchema(endpointSchema);
endpoint.getValues().add("http://host.domain");
ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
servicenameSchema.setName("servicename");
servicenameSchema.setType(String.class.getName());
servicenameSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(servicenameSchema);
endpoint.getValues().add("Provisioning");
conf.add(endpoint);
conf.add(servicename);
// set connector configuration
connInstance.setConf(conf);
assertFalse(connInstance.getConf().isEmpty());
// perform save operation
ConnInstance actual = connInstanceDAO.save(connInstance);
assertNotNull("save did not work", actual.getKey());
assertEquals("WebService", actual.getConnectorName());
assertEquals("org.apache.syncope.core.persistence.test.util", actual.getBundleName());
assertEquals("1.0", connInstance.getVersion());
assertEquals("New", actual.getDisplayName());
assertEquals(60, actual.getConnRequestTimeout().intValue());
conf = connInstance.getConf();
assertFalse(conf.isEmpty());
assertNotNull(conf);
assertTrue(conf.size() == 2);
}
use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.
the class ResourceITCase method createOverridingProps.
@Test
public void createOverridingProps() {
String resourceKey = "overriding-conn-conf-target-resource-create";
ResourceTO resourceTO = new ResourceTO();
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
resourceTO.getProvisions().add(provisionTO);
MappingTO mapping = new MappingTO();
provisionTO.setMapping(mapping);
ItemTO item = new ItemTO();
item.setExtAttrName("uid");
item.setIntAttrName("userId");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
item = new ItemTO();
item.setExtAttrName("username");
item.setIntAttrName("key");
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
item = new ItemTO();
item.setExtAttrName("fullname");
item.setIntAttrName("cn");
item.setConnObjectKey(false);
item.setPurpose(MappingPurpose.PROPAGATION);
mapping.add(item);
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
ConnConfProperty prop = new ConnConfProperty();
ConnConfPropSchema schema = new ConnConfPropSchema();
schema.setType("java.lang.String");
schema.setName("endpoint");
schema.setRequired(true);
prop.setSchema(schema);
prop.getValues().add("http://invalidurl/");
Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<>(Arrays.asList(prop));
resourceTO.getConfOverride().addAll(connectorConfigurationProperties);
Response response = resourceService.create(resourceTO);
ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
assertNotNull(actual);
// check the existence
actual = resourceService.read(resourceKey);
assertNotNull(actual);
assertNull(actual.getPropagationPriority());
}
use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.
the class ConnInstanceDataBinderImpl method build.
@Override
public ConnConfPropSchema build(final ConfigurationProperty property) {
ConnConfPropSchema connConfPropSchema = new ConnConfPropSchema();
connConfPropSchema.setName(property.getName());
connConfPropSchema.setDisplayName(property.getDisplayName(property.getName()));
connConfPropSchema.setHelpMessage(property.getHelpMessage(property.getName()));
connConfPropSchema.setRequired(property.isRequired());
connConfPropSchema.setType(property.getType().getName());
connConfPropSchema.setOrder(((ConfigurationPropertyImpl) property).getOrder());
connConfPropSchema.setConfidential(property.isConfidential());
if (property.getValue() != null) {
if (property.getValue().getClass().isArray()) {
connConfPropSchema.getDefaultValues().addAll(Arrays.asList((Object[]) property.getValue()));
} else if (property.getValue() instanceof Collection<?>) {
connConfPropSchema.getDefaultValues().addAll((Collection<?>) property.getValue());
} else {
connConfPropSchema.getDefaultValues().add(property.getValue());
}
}
return connConfPropSchema;
}
Aggregations