1 16 package org.apache.juddi.function; 17 18 import java.util.Vector ; 19 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 import org.apache.juddi.datastore.DataStore; 23 import org.apache.juddi.datastore.DataStoreFactory; 24 import org.apache.juddi.datatype.RegistryObject; 25 import org.apache.juddi.datatype.publisher.Publisher; 26 import org.apache.juddi.datatype.request.AuthInfo; 27 import org.apache.juddi.datatype.request.SetPublisherAssertions; 28 import org.apache.juddi.datatype.response.PublisherAssertions; 29 import org.apache.juddi.error.RegistryException; 30 import org.apache.juddi.registry.RegistryEngine; 31 import org.apache.juddi.util.Config; 32 33 36 public class SetPublisherAssertionsFunction extends AbstractFunction 37 { 38 private static Log log = LogFactory.getLog(SetPublisherAssertionsFunction.class); 40 41 44 public SetPublisherAssertionsFunction(RegistryEngine registry) 45 { 46 super(registry); 47 } 48 49 52 public RegistryObject execute(RegistryObject regObject) 53 throws RegistryException 54 { 55 SetPublisherAssertions request = (SetPublisherAssertions)regObject; 56 String generic = request.getGeneric(); 57 AuthInfo authInfo = request.getAuthInfo(); 58 Vector assertionVector = request.getPublisherAssertionVector(); 59 60 DataStore dataStore = DataStoreFactory.getDataStore(); 62 63 try 64 { 65 dataStore.beginTrans(); 66 67 Publisher publisher = getPublisher(authInfo,dataStore); 69 String publisherID = publisher.getPublisherID(); 70 71 74 Vector savedAssertionsVector = dataStore.setAssertions(publisherID,assertionVector); 76 77 dataStore.commit(); 78 79 PublisherAssertions assertions = new PublisherAssertions(); 80 assertions.setGeneric(generic); 81 assertions.setOperator(Config.getOperator()); 82 assertions.setPublisherAssertionVector(savedAssertionsVector); 83 return assertions; 84 } 85 catch(RegistryException regex) 86 { 87 try { dataStore.rollback(); } catch(Exception e) { } 88 log.error(regex); 89 throw (RegistryException)regex; 90 } 91 catch(Exception ex) 92 { 93 try { dataStore.rollback(); } catch(Exception e) { } 94 log.error(ex); 95 throw new RegistryException(ex); 96 } 97 finally 98 { 99 if (dataStore != null) 100 dataStore.release(); 101 } 102 } 103 104 105 106 107 108 109 110 public static void main(String [] args) 111 { 112 RegistryEngine reg = new RegistryEngine(); 114 reg.init(); 115 116 try 117 { 118 } 119 catch (Exception ex) 120 { 121 ex.printStackTrace(); 123 } 124 finally 125 { 126 reg.dispose(); 128 } 129 } 130 } 131 132 | Popular Tags |