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.datatype.CategoryBag; 23 import org.apache.juddi.datatype.IdentifierBag; 24 import org.apache.juddi.datatype.KeyedReference; 25 import org.apache.juddi.datatype.RegistryObject; 26 import org.apache.juddi.datatype.binding.BindingTemplate; 27 import org.apache.juddi.datatype.binding.BindingTemplates; 28 import org.apache.juddi.datatype.business.BusinessEntity; 29 import org.apache.juddi.datatype.request.ValidateValues; 30 import org.apache.juddi.datatype.response.DispositionReport; 31 import org.apache.juddi.datatype.response.Result; 32 import org.apache.juddi.datatype.service.BusinessService; 33 import org.apache.juddi.datatype.service.BusinessServices; 34 import org.apache.juddi.datatype.tmodel.TModel; 35 import org.apache.juddi.error.RegistryException; 36 import org.apache.juddi.registry.RegistryEngine; 37 import org.apache.juddi.util.Config; 38 39 42 public class ValidateValuesFunction extends AbstractFunction 43 { 44 private static Log log = LogFactory.getLog(SetPublisherAssertionsFunction.class); 46 47 50 public ValidateValuesFunction(RegistryEngine registry) 51 { 52 super(registry); 53 } 54 55 61 public RegistryObject execute(RegistryObject obj) 62 throws RegistryException 63 { 64 ValidateValues request = (ValidateValues)obj; 65 String generic = request.getGeneric(); 66 67 Vector businessVector = request.getBusinessEntityVector(); 68 if ((businessVector != null) && (businessVector.size() > 0)) 69 validateBusinessVector(businessVector); 70 71 Vector serviceVector = request.getBusinessServiceVector(); 72 if ((serviceVector != null) && (serviceVector.size() > 0)) 73 validateServiceVector(serviceVector); 74 75 Vector tModelVector = request.getTModelVector(); 76 if ((tModelVector != null) && (tModelVector.size() > 0)) 77 validateTModelVector(tModelVector); 78 79 83 Result result = new Result(Result.E_SUCCESS); 87 result.setErrCode(Result.lookupErrCode(Result.E_SUCCESS)); 88 DispositionReport dispRpt = new DispositionReport(); 89 dispRpt.setGeneric(generic); 90 dispRpt.setOperator(Config.getOperator()); 91 dispRpt.addResult(result); 92 93 return dispRpt; 94 } 95 96 99 private RegistryObject validateBusinessVector(Vector businessVector) 100 { 101 if (businessVector == null) 102 return null; 103 104 for (int i=0; i<businessVector.size(); i++) 105 { 106 BusinessEntity business = (BusinessEntity)businessVector.elementAt(i); 107 108 CategoryBag catBag = business.getCategoryBag(); 109 if (catBag != null) 110 { 111 Vector refs = catBag.getKeyedReferenceVector(); 112 if ((refs != null) && (refs.size() > 0)) 113 validate(refs); 114 } 115 116 IdentifierBag idBag = business.getIdentifierBag(); 117 if (idBag != null) 118 { 119 Vector refs = idBag.getKeyedReferenceVector(); 120 if ((refs != null) && (refs.size() > 0)) 121 validate(refs); 122 } 123 124 BusinessServices services = business.getBusinessServices(); 125 if (services != null) 126 { 127 Vector serviceVector = services.getBusinessServiceVector(); 128 if (serviceVector != null) 129 validateServiceVector(serviceVector); 130 } 131 } 132 133 return null; 134 } 135 136 139 private RegistryObject validateServiceVector(Vector serviceVector) 140 { 141 if (serviceVector == null) 142 return null; 143 144 for (int i=0; i<serviceVector.size(); i++) 145 { 146 BusinessService service = (BusinessService)serviceVector.elementAt(i); 147 148 CategoryBag catBag = service.getCategoryBag(); 149 if (catBag != null) 150 { 151 Vector refs = catBag.getKeyedReferenceVector(); 152 if ((refs != null) && (refs.size() > 0)) 153 validate(refs); 154 } 155 156 BindingTemplates templates = service.getBindingTemplates(); 157 if (templates != null) 158 { 159 Vector bindings = templates.getBindingTemplateVector(); 160 if (bindings != null) 161 validateBindingVector(bindings); 162 } 163 } 164 165 return null; 166 } 167 168 171 private RegistryObject validateBindingVector(Vector bindingVector) 172 { 173 if (bindingVector == null) 174 return null; 175 176 for (int i=0; i<bindingVector.size(); i++) 177 { 178 BindingTemplate binding = (BindingTemplate)bindingVector.elementAt(i); 179 180 CategoryBag catBag = binding.getCategoryBag(); 181 if (catBag != null) 182 { 183 Vector refs = catBag.getKeyedReferenceVector(); 184 if ((refs != null) && (refs.size() > 0)) 185 validate(refs); 186 } 187 } 188 189 return null; 190 } 191 192 195 private RegistryObject validateTModelVector(Vector tModelVector) 196 { 197 if (tModelVector == null) 198 return null; 199 200 for (int i=0; i<tModelVector.size(); i++) 201 { 202 TModel tModel = (TModel)tModelVector.elementAt(i); 203 204 CategoryBag catBag = tModel.getCategoryBag(); 205 if (catBag != null) 206 { 207 Vector refs = catBag.getKeyedReferenceVector(); 208 if ((refs != null) && (refs.size() > 0)) 209 validate(refs); 210 } 211 212 IdentifierBag idBag = tModel.getIdentifierBag(); 213 if (idBag != null) 214 { 215 Vector refs = idBag.getKeyedReferenceVector(); 216 if ((refs != null) && (refs.size() > 0)) 217 validate(refs); 218 } 219 } 220 221 return null; 222 } 223 224 228 private RegistryObject validate(Vector refs) 229 { 230 if (refs == null) 231 return null; 232 233 for (int i=0; i<refs.size(); i++) 234 { 235 KeyedReference ref = (KeyedReference)refs.elementAt(i); 236 237 } 239 240 return null; 241 } 242 243 244 245 246 247 248 public static void main(String [] args) 249 { 250 RegistryEngine reg = new RegistryEngine(); 252 reg.init(); 253 254 try 255 { 256 } 257 catch (Exception ex) 258 { 259 ex.printStackTrace(); 261 } 262 finally 263 { 264 reg.dispose(); 266 } 267 } 268 } | Popular Tags |