UDDI TestEntityDeleter.java
TestEntityDeleter-java
package com.ibm.uddi.promoter.sample; /* * IBM WebSphere UDDI Registry Sample Program * * "This sample program may be freely used, executed, copied and modified by customer * (a) for its own instruction and study, (b) in order to develop applications which run with * IBM WebSphere products, either for customer's own internal use or for redistribution with * customer's own products." * * Product 5630-A36, (C) COPYRIGHT International Business Machines Corp., 2003 * All Rights Reserved * Licensed Materials - Property of IBM * */ import java.util.ArrayList; import com.ibm.uddi.promoter.PromoterAPI; import com.ibm.uddi.promoter.PromoterConstants; import com.ibm.uddi.promoter.PromoterLogger; import com.ibm.uddi.promoter.UddiEntityKeys; import com.ibm.uddi.promoter.config.Configuration; import com.ibm.uddi.promoter.exception.PromoterConfigurationException; import com.ibm.uddi.promoter.exception.PromoterException; import com.ibm.uddi.promoter.exception.PromoterIOException; import com.ibm.uddi.promoter.exception.PromoterTransportException; import com.ibm.uddi.promoter.exception.PromoterUDDI4JException; import com.ibm.uddi.promoter.publish.EntityDeleter; /** * Sample to show typical use of the EntityDeleter * to delete selected entities from a target registry. * * Exception handling is minimal. * * @author IBM */ public class TestEntityDeleter { /** * Start this class with first argument value of: * * > 'deleterDirect' - shows how to use EntityDeleter directly to perform delete * > 'deleterAPI' - shows how to use PromoterAPI to perform delete function * * * @param args */ public static void main(String[] args) { if (args.length != 1 || (args.length == 1 && !"deleterDirect".equals(args[0]) && !"deleterAPI".equals(args[0]))) { System.out.println("must use either 'deleterDirect' or 'deleterAPI' as arg"); } else if ("deleterDirect".equals(args[0])) { testDeleterDirect(); } else if ("deleterAPI".equals(args[0])) { testDeleterViaPromoterAPI(); } } /** * Instantiates PromoterAPI and invokes the deleteEntities * method. * * The entity keys to be deleted can be set up in one of three ways: * * 1. read the keys from a keys file. * 2. create and populate an UddiEntityKeys object * 3. specify an entity type and an entity key * * * All three methods are shown. */ public static void testDeleterViaPromoterAPI() { System.out.println("starting testDeleteViaPromoterAPI"); // used to choose method of setting keys //String keySetMethod = "keys file"; //String keySetMethod = "keys object"; String keySetMethod = "single entity key"; try { // use a predefined config file Configuration config = new Configuration("c:/promoter/UDDIUtilityTools.properties"); // write messages to console config.setMessageStream(System.out); // start trace and message logging PromoterLogger.getLogger().initialise(config.getLoggerConfiguration()); // create a PromoterAPI to contain the keys PromoterAPI api = new PromoterAPI(config); // read the keys from a file if (keySetMethod.equals("keys file")) { api.setUddiEntities("c:/promoter/deletekeys.txt"); // set up keys in UddiEntityKeys object } else if (keySetMethod.equals("keys object")) { // set up key values String businessKey1 = "BEB2B1BE-F0E6-4619-95F6-00616400F66D"; String serviceKey1 = "1F5F411F-D33B-4BF1-B5AB-5FC7555FABD2"; // create lists for each type of entity ArrayList businessKeys = new ArrayList(); ArrayList serviceKeys = new ArrayList(); // add the keys to the lists for each type businessKeys.add(businessKey1); serviceKeys.add(serviceKey1); // create a container for all types of keys UddiEntityKeys entityKeys = new UddiEntityKeys(); // add the business and service keys entityKeys.setBusinesses(businessKeys); entityKeys.setServices(serviceKeys); // set the keys in the PromoterAPI object api.setUddiEntities(entityKeys); // set up a single key for a specified entity type } else if (keySetMethod.equals("single entity key")) { // entity type - business, service, binding or tModel String entityType = PromoterConstants.ENTITY_BUSINESS; // key value String entityKey = "1F5F411F-D33B-4BF1-B5AB-5FC7555FABA3"; api.setUddiEntity(entityType, entityKey); } // now perform delete using the keys set api.deleteEntities(); System.out.println("finished deleting using PromoterAPI"); } catch (PromoterConfigurationException e) { System.out.println(e); } catch (PromoterIOException e) { System.out.println(e); } catch (PromoterException e) { System.out.println(e); } } /** * Instantiates EntityDeleter and performs delete for specified keys. * * Shows how to set up UddiEntityKeys, configure the EntityDeleter, * and invoke the deleteEntities method. * */ public static void testDeleterDirect() { System.out.println("starting testDeleterDirect"); try { // set up key values String businessKey1 = "BEB2B1BE-F0E6-4619-95F6-00616400F66D"; String serviceKey1 = "1F5F411F-D33B-4BF1-B5AB-5FC7555FABD2"; // create lists for each type of entity ArrayList businessKeys = new ArrayList(); ArrayList serviceKeys = new ArrayList(); // add the keys to the lists for each type businessKeys.add(businessKey1); serviceKeys.add(serviceKey1); // create a container for all types of keys UddiEntityKeys entityKeys = new UddiEntityKeys(); // add the business and service keys entityKeys.setBusinesses(businessKeys); entityKeys.setServices(serviceKeys); // use a predefined config file Configuration config = new Configuration("c:/promoter/UDDIUtilityTools.properties"); // write messages to console config.setMessageStream(System.out); // start trace and message logging PromoterLogger.getLogger().initialise(config.getLoggerConfiguration()); // create EntityDeleter EntityDeleter deleter = new EntityDeleter(entityKeys); // set up deleter configuration deleter.setDeleteConfig(config); // perform the delete deleter.deleteEntities(); System.out.println("finished deleting using EntityDeleter"); } catch (PromoterConfigurationException e) { System.out.println("pce: " + e); } catch (PromoterUDDI4JException e) { System.out.println("ue: " + e); } catch (PromoterTransportException e) { System.out.println("te: " + e); } catch (PromoterException e) { System.out.println("pe: " + e); } } }
Enabling Universal Description, Discovery and Integration (UDDI)
UDDI TestEntityExporter.java
UDDI TestEntityImporter.java
UDDI TestEntityPromoter.java
UDDI TestEntityFinder.java
UDDI TestEntityPromoter.java
UDDI TestUddiDeserializer.java
UDDI TestStubManager.java
UDDI TestCreateMinimalEntity.java