Normal
0
false
false
false
EN-US
X-NONE
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
The following code helps in writing a standalone java program to test an ICF based connector. The sample code in this example takes into account an ICF based flatfile connector. It is possible to test various operations like create, update, delete, search etc... It is also possible to set values to the connector configuration parameters, add/remove attributes and their values.
public class FlatFile
{
private static final java.lang.String BUNDLE_NAME = "<PACKAGE_NAME>";
//Ex:
org.info.icf.flatfile
private static final java.lang.String BUNDLE_VERSION = "1.0.0";
private static final java.lang.String CONNECTOR_NAME = "org.info.icf.flatfile.FlatFileConnector";
//
Name of connector class i.e. the class implemting the connector SPI
operations
public ConnectorFacade
getFacade() throws IOException {
ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory
.getInstance();
File bundleDirectory = new File("<BUNDLE_LOCATION>");
//Ex:
/usr/oracle/connector_bundles/
URL url = IOUtil.makeURL(bundleDirectory,
"org.info.icf.flatfile-1.0.0.jar");
ConnectorInfoManager manager = fact.getLocalManager(url);
ConnectorKey key = new ConnectorKey(BUNDLE_NAME, BUNDLE_VERSION,
CONNECTOR_NAME);
ConnectorInfo info = manager.findConnectorInfo(key);
//
From the ConnectorInfo object, create the default APIConfiguration.
APIConfiguration apiConfig =
info.createDefaultAPIConfiguration();
//
From the default APIConfiguration, retrieve the
//
ConfigurationProperties.
ConfigurationProperties properties = apiConfig
.getConfigurationProperties();
//
Print out what the properties are (not necessary)
List propertyNames = properties.getPropertyNames();
for (String propName :
propertyNames) {
ConfigurationProperty prop =
properties.getProperty(propName);
System.out.println("Property
Name: " + prop.getName()
+ "\tProperty
Type: " + prop.getType());
}
properties
.setPropertyValue("fileLocation",
"/usr/oracle/accounts.csv");
//
Set all of the ConfigurationProperties needed by the connector.
//
properties.setPropertyValue("host", FOOBAR_HOST);
//
properties.setPropertyValue("adminName", FOOBAR_ADMIN);
//
properties.setPropertyValue("adminPassword", FOOBAR_PASSWORD);
//
properties.setPropertyValue("useSSL", false);
// Use the ConnectorFacadeFactory's
newInstance() method to get a new
//
connector.
ConnectorFacade connFacade = ConnectorFacadeFactory.getInstance()
.newInstance(apiConfig);
//
Make sure we have set up the Configuration properly
connFacade.validate();
return connFacade;
}
public static void main(String[] args) throws IOException {
FlatFile file = new FlatFile();
ConnectorFacade cfac = file.getFacade();
Set attrSet = new HashSet();
attrSet.add(AttributeBuilder.build(Name.NAME, "Test01"));
attrSet.add(AttributeBuilder.build("FIRST_NAME", "Test_First"));
attrSet.add(AttributeBuilder.build("LAST_NAME", "Test_Last"));
//Create
Uid uid = cfac.create(ObjectClass.ACCOUNT, attrSet, null);
//Delete
Uid uidP = new Uid("Test01");
cfac.delete(ObjectClass.ACCOUNT, uidP, null);
}
}