1/*2 * Copyright 2001-2008 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.apache.juddi.examples.vsv.valuesetvalidator;
1718import org.apache.commons.configuration.ConfigurationException;
19import org.apache.juddi.api.impl.UDDIValueSetValidationImpl;
20import org.apache.juddi.v3.client.UDDIConstants;
21import org.apache.juddi.v3.client.config.UDDIClerk;
22import org.apache.juddi.v3.client.config.UDDIClient;
23import org.uddi.api_v3.CategoryBag;
24import org.uddi.api_v3.KeyedReference;
25import org.uddi.api_v3.Name;
26import org.uddi.api_v3.TModel;
2728/**29 * Hello world!30 *31 */32publicclassApp {
3334publicstaticvoid main(String[] args) throws ConfigurationException {
35 System.out.println("Notice! before running this, build this project and copy the jar file into juddi-tomcat/target/tomcat/apache-tomcat.../juddiv3.war/WEB-INF/lib and restart!");
3637 System.out.println(UDDIValueSetValidationImpl.convertKeyToClass("uddi:www.bob.com:verified-tmodel"));
383940414243//register joe publisher key generator44//register tmodel that's validated45 UDDIClient client = new UDDIClient("META-INF/uddi.xml");
46 UDDIClerk clerk = client.getClerk("default");
47 TModel keygen = UDDIClerk.createKeyGenator("www.bob.com", "Bob's Key Generator", "This key generator is used for the jUDDI example Value Set Validator example");
4849 keygen = clerk.register(keygen).getTModel().get(0);
5051 TModel verifiedTmodel = new TModel();
52 verifiedTmodel.setTModelKey(keygen.getTModelKey().replace("keygenerator", "verified-tmodel"));
53 verifiedTmodel.setCategoryBag(new CategoryBag());
5455 verifiedTmodel.getCategoryBag().getKeyedReference().add(new KeyedReference(UDDIConstants.IS_VALIDATED_BY, UDDIConstants.IS_VALIDATED_BY_KEY_NAME, "uddi:juddi.apache.org:servicebindings-valueset-cp"));
56 verifiedTmodel.setName(new Name("Bob's tModel with validation", "en"));
57 verifiedTmodel = clerk.register(verifiedTmodel).getTModel().get(0);
5859//now try to use it with a valid value6061//try to use it when an invalid value6263 }
64 }