This example uses a portal component which opens a connection to a repository running on MDM Server, retrieves data from the repository, and closes the connection.There are 5 steps we will implement:- Set the connector libraries in the deployment descriptor file portalapp.xml
- Open a connection to a repository
- Get the physical connection via the native interface
- Get data from a repository
- Close the connection
Step 1: configure the potalapp.xml fileThe MDME Connector uses the SAP Connector Framework and MDME4J libraries as a shared library. You need to add these libraries into portalapp.xml. <application> <application-config> <property name="SharingReference" value="com.sap.portal.pcd.glservice, com.sap.portal.ivs.connectorservice, SAPJ2EE::library:MDME4J"/> </application-config> </application>
Step 2 : Open a connection to a repository (using the connector gatway service) The useful EP6 features of system object aliases and single=sign-on user mapping are available only by using the Connector Gatway Services approach.// Get the Connector Gateway Service IConnectorGatewayService cgService = (IConnectorGatewayService) PortalRuntime.getRuntimeResources().getService( IConnectorService.KEY); // Create ConnectionProperties for portal user ConnectionProperties prop = new ConnectionProperties(request.getLocale(), request.getUser()); // Get a connection IConnection connection = cgService.getConnection("MDME_SYSTEM_ALIAS_NAME", prop);
Step 3: Get the physical connection via the native interfaceRetrieve the native interface from the connection, and invoke getNative method. // Retrieve Native inteface INative nativeInterface = connection.retrieveNative(); // Get the CatalogData the physical connection CatalogData catalog = (CatalogData) nativeInterface.getNative(CatalogData.class.getName());
Step 4: Get data from a repositoryAll methods of the CatalogData object are available for retrieving data. The following code uses the GetResultSet method as an example.// Create ResultSetDefinition for products table ResultSetDefinition rsd = new ResultSetDefinition("Products"); rsd.AddField("Name"); // Create Search for products table Search search = new Search("Products"); // Get Data from table A2iResultSet rs = catalog.GetResultSet(search, rsd, "Name", true, 0);
Step 5:Close the connectionconnection.close();