private boolean ContainsKey(List<TModel> items, String keyValue) { for (int i = 0; i < items.size(); i++) { if (items.get(i).getTModelKey().equalsIgnoreCase(keyValue)) { return true; } } return false; }
private boolean ContainsKey(List<TModel> items, String keyValue) { for (int i = 0; i < items.size(); i++) { if (items.get(i).getTModelKey().equalsIgnoreCase(keyValue)) { return true; } } return false; }
private void validateSignaturesTModel(TModel tModel, Configuration config) throws FatalErrorException { boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false); initDigSig(config); if (shouldcheck && !tModel.getSignature().isEmpty() && ds != null) { AtomicReference<String> outmsg = new AtomicReference<String>(); boolean ok = ds.verifySignedUddiEntity(tModel, outmsg); if (!ok) { throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", tModel.getTModelKey() + " " + outmsg.get())); } } }
private void validateSignaturesTModel(TModel tModel, Configuration config) throws FatalErrorException { boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false); initDigSig(config); if (shouldcheck && !tModel.getSignature().isEmpty() && ds != null) { AtomicReference<String> outmsg = new AtomicReference<String>(); boolean ok = ds.verifySignedUddiEntity(tModel, outmsg); if (!ok) { throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", tModel.getTModelKey() + " " + outmsg.get())); } } }
void validateNotSigned(org.uddi.api_v3.TModel item) throws ValueNotAllowedException { if (item == null) { return; } if (item.getTModelKey() == null && !item.getSignature().isEmpty()) { throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "tModelKey")); } }
void validateNotSigned(org.uddi.api_v3.TModel item) throws ValueNotAllowedException { if (item == null) { return; } if (item.getTModelKey() == null && !item.getSignature().isEmpty()) { throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "tModelKey")); } }
protected static String getRootPartition(TModel rootTModelKeyGen) throws JAXBException, IOException, DispositionReportFaultMessage { String result = rootTModelKeyGen.getTModelKey().substring(0, rootTModelKeyGen.getTModelKey().lastIndexOf(KeyGenerator.PARTITION_SEPARATOR)); if (result == null || result.length() == 0) { throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result)); } // Must validate the root partition. The first component should be a domain key and the any following // tokens should be a valid KSS. result = result.trim(); if (result.endsWith(KeyGenerator.PARTITION_SEPARATOR) || result.startsWith(KeyGenerator.PARTITION_SEPARATOR)) { throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result)); } StringTokenizer tokenizer = new StringTokenizer(result.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR); for (int count = 0; tokenizer.hasMoreTokens(); count++) { String nextToken = tokenizer.nextToken(); if (count == 0) { if (!ValidateUDDIKey.isValidDomainKey(nextToken)) { throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result)); } } else { if (!ValidateUDDIKey.isValidKSS(nextToken)) { throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result)); } } } return result; }
private static void installTModels(EntityManager em, List<org.uddi.api_v3.TModel> apiTModelList, UddiEntityPublisher publisher, String nodeId) throws DispositionReportFaultMessage { if (apiTModelList != null) { for (org.uddi.api_v3.TModel apiTModel : apiTModelList) { String tModelKey = apiTModel.getTModelKey(); if (tModelKey.toUpperCase().endsWith(KeyGenerator.KEYGENERATOR_SUFFIX.toUpperCase())) { installPublisherKeyGen(em, apiTModel, publisher, nodeId); } else { org.apache.juddi.model.Tmodel modelTModel = new org.apache.juddi.model.Tmodel(); apiTModel.setTModelKey(apiTModel.getTModelKey().toLowerCase()); MappingApiToModel.mapTModel(apiTModel, modelTModel); modelTModel.setAuthorizedName(publisher.getAuthorizedName()); Date now = new Date(); modelTModel.setCreated(now); modelTModel.setModified(now); modelTModel.setModifiedIncludingChildren(now); modelTModel.setNodeId(nodeId); em.persist(modelTModel); SaveTModel stm = new SaveTModel(); stm.getTModel().add(apiTModel); ReplicationNotifier.enqueue(UDDIPublicationImpl.getChangeRecord(modelTModel, apiTModel, nodeId)); } } } }
private static void installTModels(EntityManager em, List<org.uddi.api_v3.TModel> apiTModelList, UddiEntityPublisher publisher, String nodeId) throws DispositionReportFaultMessage { if (apiTModelList != null) { for (org.uddi.api_v3.TModel apiTModel : apiTModelList) { String tModelKey = apiTModel.getTModelKey(); if (tModelKey.toUpperCase().endsWith(KeyGenerator.KEYGENERATOR_SUFFIX.toUpperCase())) { installPublisherKeyGen(em, apiTModel, publisher, nodeId); } else { org.apache.juddi.model.Tmodel modelTModel = new org.apache.juddi.model.Tmodel(); apiTModel.setTModelKey(apiTModel.getTModelKey().toLowerCase()); MappingApiToModel.mapTModel(apiTModel, modelTModel); modelTModel.setAuthorizedName(publisher.getAuthorizedName()); Date now = new Date(); modelTModel.setCreated(now); modelTModel.setModified(now); modelTModel.setModifiedIncludingChildren(now); modelTModel.setNodeId(nodeId); em.persist(modelTModel); SaveTModel stm = new SaveTModel(); stm.getTModel().add(apiTModel); ReplicationNotifier.enqueue(UDDIPublicationImpl.getChangeRecord(modelTModel, apiTModel, nodeId)); } } } }
public static void validateUDDIv3KeyGeneratorTModel(org.uddi.api_v3.TModel tModel) throws DispositionReportFaultMessage { if (tModel == null) throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NullInput")); validateUDDIv3KeyGeneratorKey(tModel.getTModelKey()); // A key generator key should have exactly one category and it's key value should be 'keyGenerator' org.uddi.api_v3.CategoryBag categories = tModel.getCategoryBag(); if (categories != null) { List<org.uddi.api_v3.KeyedReference> elems = categories.getKeyedReference(); if (elems != null && elems.size() == 1) { org.uddi.api_v3.KeyedReference elem = elems.get(0); if (elem != null) { if (elem instanceof org.uddi.api_v3.KeyedReference) { String keyedValue = elem.getKeyValue(); if (keyedValue != null) { if (keyedValue.equalsIgnoreCase(KeyGenerator.KEYGENERATOR_SUFFIX)) return; } } } } } throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.keygenerator.BadCategory")); }
public static void validateUDDIv3KeyGeneratorTModel(org.uddi.api_v3.TModel tModel) throws DispositionReportFaultMessage { if (tModel == null) throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NullInput")); validateUDDIv3KeyGeneratorKey(tModel.getTModelKey()); // A key generator key should have exactly one category and it's key value should be 'keyGenerator' org.uddi.api_v3.CategoryBag categories = tModel.getCategoryBag(); if (categories != null) { List<org.uddi.api_v3.KeyedReference> elems = categories.getKeyedReference(); if (elems != null && elems.size() == 1) { org.uddi.api_v3.KeyedReference elem = elems.get(0); if (elem != null) { if (elem instanceof org.uddi.api_v3.KeyedReference) { String keyedValue = elem.getKeyValue(); if (keyedValue != null) { if (keyedValue.equalsIgnoreCase(KeyGenerator.KEYGENERATOR_SUFFIX)) return; } } } } } throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.keygenerator.BadCategory")); }
public void findTModel(String findQualifier) { try { FindTModel body = (FindTModel)EntityCreator.buildFromDoc(FIND_TMODEL_XML, "org.uddi.api_v3"); if (findQualifier!=null) body.getFindQualifiers().getFindQualifier().add(findQualifier); TModelList result = inquiry.findTModel(body); if (result == null) Assert.fail("Null result from find tModel operation"); TModelInfos tInfos = result.getTModelInfos(); if (tInfos == null) Assert.fail("No result from find tModel operation"); List<TModelInfo> tiList = tInfos.getTModelInfo(); if (tiList == null || tiList.size() == 0) Assert.fail("No result from find tModel operation"); TModelInfo tiOut = tiList.get(0); TModel tmIn = (TModel)EntityCreator.buildFromDoc(TckTModel.JOE_PUBLISHER_TMODEL_XML, "org.uddi.api_v3"); assertEquals(tmIn.getTModelKey(), tiOut.getTModelKey()); assertEquals(tmIn.getName().getLang(), tiOut.getName().getLang()); assertEquals(tmIn.getName().getValue(), tiOut.getName().getValue()); TckValidator.checkDescriptions(tmIn.getDescription(), tiOut.getDescription()); } catch(Exception e) { logger.error(e.getMessage(), e); Assert.fail("No exception should be thrown."); } } }
public static ChangeRecord getChangeRecord(Tmodel modelBusinessEntity, org.uddi.api_v3.TModel apiBusinessEntity, String node) throws DispositionReportFaultMessage { ChangeRecord cr = new ChangeRecord(); if (!apiBusinessEntity.getTModelKey().equals(modelBusinessEntity.getEntityKey())) { throw new FatalErrorException(new ErrorMessage("E_fatalError", "the model and api keys do not match when saving a tmodel!")); } cr.setEntityKey(modelBusinessEntity.getEntityKey()); cr.setNodeID(node); cr.setRecordType(ChangeRecord.RecordType.ChangeRecordNewData); org.uddi.repl_v3.ChangeRecord crapi = new org.uddi.repl_v3.ChangeRecord(); crapi.setChangeID(new ChangeRecordIDType(node, -1L)); crapi.setChangeRecordNewData(new ChangeRecordNewData()); crapi.getChangeRecordNewData().setTModel(apiBusinessEntity); crapi.getChangeRecordNewData().getTModel().setTModelKey(modelBusinessEntity.getEntityKey()); crapi.getChangeRecordNewData().setOperationalInfo(new OperationalInfo()); MappingModelToApi.mapOperationalInfo(modelBusinessEntity, crapi.getChangeRecordNewData().getOperationalInfo()); StringWriter sw = new StringWriter(); JAXB.marshal(crapi, sw); try { cr.setContents(sw.toString().getBytes("UTF8")); } catch (UnsupportedEncodingException ex) { logger.error(ex); } return cr; }
public static ChangeRecord getChangeRecord(Tmodel modelBusinessEntity, org.uddi.api_v3.TModel apiBusinessEntity, String node) throws DispositionReportFaultMessage { ChangeRecord cr = new ChangeRecord(); if (!apiBusinessEntity.getTModelKey().equals(modelBusinessEntity.getEntityKey())) { throw new FatalErrorException(new ErrorMessage("E_fatalError", "the model and api keys do not match when saving a tmodel!")); } cr.setEntityKey(modelBusinessEntity.getEntityKey()); cr.setNodeID(node); cr.setRecordType(ChangeRecord.RecordType.ChangeRecordNewData); org.uddi.repl_v3.ChangeRecord crapi = new org.uddi.repl_v3.ChangeRecord(); crapi.setChangeID(new ChangeRecordIDType(node, -1L)); crapi.setChangeRecordNewData(new ChangeRecordNewData()); crapi.getChangeRecordNewData().setTModel(apiBusinessEntity); crapi.getChangeRecordNewData().getTModel().setTModelKey(modelBusinessEntity.getEntityKey()); crapi.getChangeRecordNewData().setOperationalInfo(new OperationalInfo()); MappingModelToApi.mapOperationalInfo(modelBusinessEntity, crapi.getChangeRecordNewData().getOperationalInfo()); StringWriter sw = new StringWriter(); JAXB.marshal(crapi, sw); try { cr.setContents(sw.toString().getBytes("UTF8")); } catch (UnsupportedEncodingException ex) { logger.error(ex); } return cr; }
public static org.uddi.api_v2.TModel MapTModel(org.uddi.api_v3.TModel be) { if (be == null) { return null; } TModel item = new org.uddi.api_v2.TModel(); item.setTModelKey(be.getTModelKey()); item.setName(new Name(be.getName().getValue(), be.getName().getLang())); item.setCategoryBag(MapCategoryBag(be.getCategoryBag())); item.getDescription().addAll(MapDescription(be.getDescription())); item.setIdentifierBag(MapIdentBag(be.getIdentifierBag())); item.setOverviewDoc(MapOverviewDoc(be.getOverviewDoc())); return item; }
private static ChangeRecord getChangeRecordConditional(Tmodel modelTModel, TModel apiTModel, String node) throws DispositionReportFaultMessage { ChangeRecord cr = new ChangeRecord(); if (!apiTModel.getTModelKey().equals(modelTModel.getEntityKey())) { throw new FatalErrorException(new ErrorMessage("E_fatalError", "the model and api keys do not match when saving a tmodel!")); } cr.setEntityKey(modelTModel.getEntityKey()); cr.setNodeID(node); cr.setRecordType(ChangeRecord.RecordType.ChangeRecordNewDataConditional); org.uddi.repl_v3.ChangeRecord crapi = new org.uddi.repl_v3.ChangeRecord(); crapi.setChangeID(new ChangeRecordIDType(node, -1L)); crapi.setChangeRecordNewDataConditional(new ChangeRecordNewDataConditional()); crapi.getChangeRecordNewDataConditional().setChangeRecordNewData(new ChangeRecordNewData()); crapi.getChangeRecordNewDataConditional().getChangeRecordNewData().setTModel(apiTModel); crapi.getChangeRecordNewDataConditional().getChangeRecordNewData().getTModel().setTModelKey(modelTModel.getEntityKey()); crapi.getChangeRecordNewDataConditional().getChangeRecordNewData().setOperationalInfo(new OperationalInfo()); MappingModelToApi.mapOperationalInfo(modelTModel, crapi.getChangeRecordNewDataConditional().getChangeRecordNewData().getOperationalInfo()); StringWriter sw = new StringWriter(); JAXB.marshal(crapi, sw); try { cr.setContents(sw.toString().getBytes("UTF8")); } catch (UnsupportedEncodingException ex) { logger.error(ex); } return cr; }
public static Concept getConcept(TModel tmodel, LifeCycleManager lifeCycleManager) throws JAXRException { Concept concept = new ConceptImpl(lifeCycleManager); concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey())); concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()), tmodel.getName().getValue())); Description desc = getDescription(tmodel); if (desc != null) { concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue())); } concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager)); concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager)); return concept; }
public static Concept getConcept(TModelDetail tModelDetail, LifeCycleManager lifeCycleManager) throws JAXRException { Concept concept = new ConceptImpl(lifeCycleManager); List<TModel> tmodelList = tModelDetail.getTModel(); for (TModel tmodel : tmodelList) { concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey())); concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()), tmodel.getName().getValue())); Description desc = getDescription(tmodel); if( desc != null ) { concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue())); } concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager)); concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager)); } return concept; }
/** * * @param apiTModel * @param modelTModel * @throws DispositionReportFaultMessage */ public static void mapTModel(org.uddi.api_v3.TModel apiTModel, org.apache.juddi.model.Tmodel modelTModel) throws DispositionReportFaultMessage { modelTModel.setEntityKey(apiTModel.getTModelKey()); modelTModel.setName(apiTModel.getName().getValue()); modelTModel.setLangCode(apiTModel.getName().getLang()); modelTModel.setDeleted(apiTModel.isDeleted()); mapTModelDescriptions(apiTModel.getDescription(), modelTModel.getTmodelDescrs(), modelTModel); mapTModelIdentifiers(apiTModel.getIdentifierBag(), modelTModel.getTmodelIdentifiers(), modelTModel); if (apiTModel.getCategoryBag() != null) { modelTModel.setCategoryBag(new org.apache.juddi.model.TmodelCategoryBag(modelTModel)); mapCategoryBag(apiTModel.getCategoryBag(), modelTModel.getCategoryBag()); } mapTModelOverviewDocs(apiTModel.getOverviewDoc(), modelTModel.getOverviewDocs(), modelTModel); mapTmodelSignatures(apiTModel.getSignature(), modelTModel); }
/** * * @param apiTModel * @param modelTModel * @throws DispositionReportFaultMessage */ public static void mapTModel(org.uddi.api_v3.TModel apiTModel, org.apache.juddi.model.Tmodel modelTModel) throws DispositionReportFaultMessage { modelTModel.setEntityKey(apiTModel.getTModelKey()); modelTModel.setName(apiTModel.getName().getValue()); modelTModel.setLangCode(apiTModel.getName().getLang()); modelTModel.setDeleted(apiTModel.isDeleted()); mapTModelDescriptions(apiTModel.getDescription(), modelTModel.getTmodelDescrs(), modelTModel); mapTModelIdentifiers(apiTModel.getIdentifierBag(), modelTModel.getTmodelIdentifiers(), modelTModel); if (apiTModel.getCategoryBag() != null) { modelTModel.setCategoryBag(new org.apache.juddi.model.TmodelCategoryBag(modelTModel)); mapCategoryBag(apiTModel.getCategoryBag(), modelTModel.getCategoryBag()); } mapTModelOverviewDocs(apiTModel.getOverviewDoc(), modelTModel.getOverviewDocs(), modelTModel); mapTmodelSignatures(apiTModel.getSignature(), modelTModel); }