Repository: juddi Updated Branches: refs/heads/master 0f8e9eeaf -> 4c7e798b7
JUDDI-197 done JUDDI-198 implementation is done, still needs test cases, documentation updated Project: http://git-wip-us.apache.org/repos/asf/juddi/repo Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/4c7e798b Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/4c7e798b Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/4c7e798b Branch: refs/heads/master Commit: 4c7e798b7b40a7e803551202fe62dc81973d6131 Parents: 0f8e9ee Author: alexoree <[email protected]> Authored: Fri Mar 7 17:22:14 2014 -0500 Committer: alexoree <[email protected]> Committed: Fri Mar 7 17:22:14 2014 -0500 ---------------------------------------------------------------------- .../Guide/en-US/GuideExtendingUDDI.asciidoc | 9 +- .../ValidateValuesFromWebService.java | 4 + .../validation/vsv/AbstractSimpleValidator.java | 5 +- ...Uddiuddiorgcategorizationowningbusiness.java | 136 +++++++++-- .../vsv/Uddiuddiorgcategorizationtype.java | 234 +++++++++++-------- .../juddi/validation/vsv/ValueSetValidator.java | 23 +- .../juddi_install_data/UDDI_tModels.xml | 1 + 7 files changed, 292 insertions(+), 120 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/docs/asciidoc/Guide/en-US/GuideExtendingUDDI.asciidoc ---------------------------------------------------------------------- diff --git a/docs/asciidoc/Guide/en-US/GuideExtendingUDDI.asciidoc b/docs/asciidoc/Guide/en-US/GuideExtendingUDDI.asciidoc index 7d20061..b787fc5 100644 --- a/docs/asciidoc/Guide/en-US/GuideExtendingUDDI.asciidoc +++ b/docs/asciidoc/Guide/en-US/GuideExtendingUDDI.asciidoc @@ -25,7 +25,14 @@ Next, setup a subscription and reference the BindingTemplate key that represents === KeyedReference Value Set Validation Services -Reserved for future discussion for jUDDI v3.3 +Since jUDDI 3.2.1, we now have support for the Value Set Validation Service. This allows you to define a validator that will check when a user saves a UDDI entity that references a given tModel that contains a keyed reference to uddi:uddi.org:identifier:validatedby (which points to the VSV service). + +To defined your own validator, use the following steps +# Create you tModel with a named key +# Implement the org.apache.juddi.validation.vsv.ValueSetValidator interface +# Name your implementation class using the naming schema defined in the ConvertKeyToClass function of UDDIValueSetValidationImpl (first letter is upper, all else is lower. Numbers and letters only. Class must be in the package org.apache.juddi.validation.vsv +# Update your saved tModel and add a keyed reference for uddi:uddi.org:identifier:validatedby using the value of uddi:juddi.apache.org:servicebindings-valueset-cp +# Get your class in the class path of jUDDI and give it a shot === Cryptographic Providers http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateValuesFromWebService.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateValuesFromWebService.java b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateValuesFromWebService.java index bbce12e..f0d1bc2 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateValuesFromWebService.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateValuesFromWebService.java @@ -113,6 +113,7 @@ public class ValidateValuesFromWebService { } catch (Exception ex) { log.warn(ex); ValueNotAllowedException x = new ValueNotAllowedException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", ex.getMessage())); + throw x; } } @@ -126,6 +127,7 @@ public class ValidateValuesFromWebService { } catch (Exception ex) { log.warn(ex); ValueNotAllowedException x = new ValueNotAllowedException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", ex.getMessage())); + throw x; } } @@ -139,6 +141,7 @@ public class ValidateValuesFromWebService { } catch (Exception ex) { log.warn(ex); ValueNotAllowedException x = new ValueNotAllowedException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", ex.getMessage())); + throw x; } } @@ -151,6 +154,7 @@ public class ValidateValuesFromWebService { } catch (Exception ex) { log.warn(ex); ValueNotAllowedException x = new ValueNotAllowedException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", ex.getMessage())); + throw x; } } } http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/AbstractSimpleValidator.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/AbstractSimpleValidator.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/AbstractSimpleValidator.java index 7cb3204..b8a7c29 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/AbstractSimpleValidator.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/AbstractSimpleValidator.java @@ -30,8 +30,11 @@ import org.uddi.api_v3.TModelInstanceInfo; import org.uddi.v3_service.DispositionReportFaultMessage; /** - * + * A simple base class for the validator interface that lets you define a simple set of allowed values. + * All other values will be rejected. Valid values apply to all UDDI elements * @author Alex O'Ree + * @since 3.2.1 + * */ public abstract class AbstractSimpleValidator implements ValueSetValidator { http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationowningbusiness.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationowningbusiness.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationowningbusiness.java index 249eece..4bb5261 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationowningbusiness.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationowningbusiness.java @@ -16,10 +16,18 @@ package org.apache.juddi.validation.vsv; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import org.apache.juddi.config.PersistenceManager; +import org.apache.juddi.model.Tmodel; +import org.apache.juddi.v3.error.ErrorMessage; +import org.apache.juddi.v3.error.InvalidValueException; import org.uddi.api_v3.BindingTemplate; import org.uddi.api_v3.BusinessEntity; import org.uddi.api_v3.BusinessService; +import org.uddi.api_v3.KeyedReference; import org.uddi.api_v3.PublisherAssertion; import org.uddi.api_v3.TModel; import org.uddi.api_v3.TModelInstanceInfo; @@ -47,43 +55,137 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * * @author Alex O'Ree */ -public class Uddiuddiorgcategorizationowningbusiness implements ValueSetValidator{ +public class Uddiuddiorgcategorizationowningbusiness implements ValueSetValidator { - @Override - public List<String> getValidValues() { - List<String> ret = new ArrayList<String>(); - - return ret; - } - - @Override - public void validateTmodelInstanceDetails(List<TModelInstanceInfo> tModelInstanceInfo, String xpath) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + public static final String key = "uddi:uddi.org:categorization:owningbusiness"; @Override public void validateValuesBindingTemplate(List<BindingTemplate> items, String xpath) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (items == null) { + return; + } + + for (int i = 0; i < items.size(); i++) { + if (items.get(i).getCategoryBag() != null) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getCategoryBag().getKeyedReference(), key, "binding"); + AbstractSimpleValidator.validateKeyNotPresentKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), key, "binding"); + } + if (items.get(i).getTModelInstanceDetails() != null) { + for (int k = 0; k < items.get(i).getTModelInstanceDetails().getTModelInstanceInfo().size(); k++) { + if (key.equalsIgnoreCase(items.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getTModelKey())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "not allowed on binding templates")); + } + } + } + } } @Override public void validateValuesBusinessEntity(List<BusinessEntity> items) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (items == null) { + return; + } + for (int i = 0; i < items.size(); i++) { + if (items.get(i).getCategoryBag() != null) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getCategoryBag().getKeyedReference(), key, "business"); + AbstractSimpleValidator.validateKeyNotPresentKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), key, "business"); + } + if (items.get(i).getIdentifierBag() != null) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getCategoryBag().getKeyedReference(), key, "business"); + } + if (items.get(i).getBusinessServices() != null) { + validateValuesBusinessService(items.get(i).getBusinessServices().getBusinessService(), "businessEntity(" + i + ")."); + } + } } @Override public void validateValuesBusinessService(List<BusinessService> items, String xpath) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (items == null) { + return; + } + for (int i = 0; i < items.size(); i++) { + if (items.get(i).getCategoryBag() != null) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getCategoryBag().getKeyedReference(), key, "service"); + AbstractSimpleValidator.validateKeyNotPresentKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), key, "service"); + } + if (items.get(i).getBindingTemplates() != null) { + validateValuesBindingTemplate(items.get(i).getBindingTemplates().getBindingTemplate(), xpath + xpath + "businessService(" + i + ").identifierBag."); + } + } } @Override public void validateValuesPublisherAssertion(List<PublisherAssertion> items) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (items == null) { + return; + } + for (int i = 0; i < items.size(); i++) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getKeyedReference(), key, "publisherAssertion"); + } + } + + @Override + public void validateTmodelInstanceDetails(List<TModelInstanceInfo> tModelInstanceInfo, String xpath) throws DispositionReportFaultMessage { + if (tModelInstanceInfo == null) { + return; + } + for (int k = 0; k < tModelInstanceInfo.size(); k++) { + if (key.equalsIgnoreCase(tModelInstanceInfo.get(k).getTModelKey())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "not allowed on tModel instance info")); + } + } } @Override public void validateValuesTModel(List<TModel> items) throws DispositionReportFaultMessage { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + if (items == null) { + return; + } + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + for (int i = 0; i < items.size(); i++) { + if (items.get(i).getCategoryBag() != null) { + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReference().size(); k++) { + if (key.equalsIgnoreCase(items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey())) { + //The content of keyValue in keyedReferences that refers to this tModel must be a businessKey. + //the referred-to businessEntity must exist, and it must have been published by the same publisher. + org.apache.juddi.model.BusinessEntity find = em.find(org.apache.juddi.model.BusinessEntity.class, items.get(i).getCategoryBag().getKeyedReference().get(k).getKeyValue()); + + if (find == null) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Referenced key " + items.get(i).getCategoryBag().getKeyedReference().get(k).getKeyValue() + " does not exist")); + } else { + if (items.get(i).getTModelKey() != null) { + org.apache.juddi.model.Tmodel tm = em.find(org.apache.juddi.model.Tmodel.class, items.get(i).getTModelKey()); + if (tm == null) { + //this is a project tModel, let access control rules take care of ownership info + } else if (find.getAuthorizedName().equalsIgnoreCase(tm.getAuthorizedName())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Referenced key " + items.get(i).getCategoryBag().getKeyedReference().get(k).getKeyValue() + " exists but is not owned by you.")); + } + } else { + //this is a project tModel, let access control rules take care of ownership info + } + } + } + } + } + if (items.get(i).getIdentifierBag() != null) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getIdentifierBag().getKeyedReference(), key, "tmodel identbag"); + } + } + } catch (DispositionReportFaultMessage d) { + throw d; + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } } + @Override + public List<String> getValidValues() { + return Collections.EMPTY_LIST; + } } http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationtype.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationtype.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationtype.java index a530225..bb91a69 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationtype.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgcategorizationtype.java @@ -16,11 +16,9 @@ package org.apache.juddi.validation.vsv; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityTransaction; -import org.apache.juddi.config.PersistenceManager; -import org.apache.juddi.model.ValueSetValues; +import java.util.Map; import org.apache.juddi.v3.error.ErrorMessage; import org.apache.juddi.v3.error.InvalidValueException; import org.uddi.api_v3.BindingTemplate; @@ -46,19 +44,19 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * * <h4 style="margin-left:0in;text-indent:0in">11.1.1.4 Valid Values</h4> * -<p class="MsoBodyText">Checking of references to this value set consists of + * <p class="MsoBodyText">Checking of references to this value set consists of * ensuring that the keyValues are from the set of categories listed * below. No contextual checks are performed unless otherwise specified * for a given value.</p> * -<p class="MsoBodyText">The following constitute the value set for this + * <p class="MsoBodyText">The following constitute the value set for this * category system. The valid values are those categories marked as being * "allowed". These values are used in the keyValue attributes of keyedReference * elements that are contained in categoryBag elements.</p> * -<p class="MsoBodyText"> </p> + * <p class="MsoBodyText"> </p> * -<table class="specTable" + * <table class="specTable" * style="width:6.0in;margin-left:.5in;border-collapse:collapse;border:none" * border="1" cellpadding="0" cellspacing="0" width="576"> * <thead> @@ -637,9 +635,9 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * </tr> * </tbody></table> * -<p class="MsoBodyText"> </p> + * <p class="MsoBodyText"> </p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>tModel: The UDDI type category system is structured to allow @@ -648,7 +646,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * categorization of tModels within the UDDI registry. Categorization is not * allowed with this key.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>valueSet: A valueSet is the parent branch for the identifier, @@ -657,7 +655,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * value set tModel to indicate redefinition of purpose, derivation, extension * or equivalence.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>identifier: An identifier tModel represents a specific set of @@ -666,7 +664,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * & Bradstreet D-U-N-S® Number uniquely identifies companies globally. The * D-U-N-S® Number system is an identifier system. </p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>namespace: A namespace tModel represents a scoping constraint @@ -676,14 +674,14 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * example, the uddi-org:relationships tModel, which is used to assert * relationships between businessEntity elements, is a namespace tModel.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>categorization: A categorization tModel is used for category * systems within the UDDI registry. NAICS and UNSPSC are examples of * categorization tModels.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>postalAddress: A postalAddress tModel is used to identify @@ -691,21 +689,21 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * tModels may be used with the address element to distinguish different forms * of postal address.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>categorizationGroup: A categorizationGroup tModel is used to * relate one or more category system tModels to one another so that they can be * used in keyedReferenceGroups.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>relationship: A relationship tModel is used for relationship * categorizations within the UDDI registry. relationship tModels are typically * used in connection with publisher relationship assertions.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>specification: A specification tModel is used for tModels that @@ -714,14 +712,14 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * interaction that are prescribed by the Web service. tModels describing XML, * COM, CORBA, or any other Web services are specification tModels.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>xmlSpec: An xmlSpec tModel is a refinement of the specification * tModel type. It is used to indicate that the interaction with the Web service * is via XML. The UDDI API tModels are xmlSpec tModels.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>soapSpec: Further refining the xmlSpec tModel type, a soapSpec @@ -729,24 +727,24 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * The UDDI API tModels are soapSpec tModels, in addition to xmlSpec * tModels.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>wsdlSpec: A tModel for a Web service described using WSDL is * categorized as a wsdlSpec.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>protocol: A tModel describing a protocol of any sort.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>transport: A transport tModel is a specific type of protocol. * HTTP, FTP, and SMTP are types of transport tModels.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>signatureComponent: A signature component is used to for cases @@ -757,7 +755,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * error handling services. Each of these tModels would be of type signature * component, in addition to any others as appropriate.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>unvalidatable: Used to mark a categorization or identifier @@ -766,7 +764,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * disallow its use. See Section <a href="#_Ref8981064 ">6.4</a> * <i>Checked Value Set Validation</i> for more information.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>checked: Marking a tModel with this categorization asserts that @@ -774,14 +772,14 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * keyedReferences, may be checked. Registry, and possibly node policy * determines when and how a checked value set is supported.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>unchecked: Marking a tModel with this categorization asserts * that it represents a value set or category group system whose use, through * keyedReferences, is not checked.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>cacheable: Marking a tModel with this categorization asserts @@ -790,7 +788,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * cacheable checked value set or category group system must rely solely upon * matching references against the cached set of values.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>uncacheable: Marking a tModel with this categorization asserts @@ -800,7 +798,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * the tModel marked with this categorization and may consider contextual * criteria involving the entity associated with the reference.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>keyGenerator: Marking a tModel with this categorization @@ -810,20 +808,20 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * categorization for something other than a key generator tModel will fail with * E_valueNotAllowed returned. </p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>findQualifier: A findQualifier tModel is used as the value of a * findQualifier element to indicate the type of processing to occur for the * inquiry function in which it is included.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>sortOrder: A sort order tModel defines a collation sequence * that can be used during inquiries to control ordering of the results.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>useTypeDesignator: A useTypeDesignator tModel is used to @@ -833,7 +831,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * of common use types as simple strings; tModels of the useTypeDesignator type * are used to describe others.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>bindingTemplate: This key is the root of the branch of the @@ -841,7 +839,7 @@ import org.uddi.v3_service.DispositionReportFaultMessage; * bindingTemplates within the UDDI registry. Categorization is not allowed with * this key.</p> * -<p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in"><span * style="font-family:Symbol">·<span style="font:7.0pt "Times New * Roman""> * </span></span>wsdlDeployment: A bindingTemplate categorized as a @@ -852,19 +850,79 @@ import org.uddi.v3_service.DispositionReportFaultMessage; */ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { + public static final String key = "uddi:uddi.org:categorization:types"; + + private static Map<String, Boolean> NotAllowedOnBindings; + private static Map<String, Boolean> NotAllowedOnTModels; + + static { + NotAllowedOnTModels = new HashMap<String, Boolean>(); + NotAllowedOnTModels.put("wsdlDeployment".toLowerCase(), true); + NotAllowedOnBindings = new HashMap<String, Boolean>(); + NotAllowedOnBindings.put("valueSet".toLowerCase(), true); + NotAllowedOnBindings.put("identifier".toLowerCase(), true); + NotAllowedOnBindings.put("namespace".toLowerCase(), true); + NotAllowedOnBindings.put("categorization".toLowerCase(), true); + NotAllowedOnBindings.put("postalAddress".toLowerCase(), true); + NotAllowedOnBindings.put("categorizationGroup".toLowerCase(), true); + NotAllowedOnBindings.put("relationship".toLowerCase(), true); + NotAllowedOnBindings.put("specification".toLowerCase(), true); + NotAllowedOnBindings.put("xmlSpec".toLowerCase(), true); + NotAllowedOnBindings.put("soapSpec".toLowerCase(), true); + NotAllowedOnBindings.put("wsdlSpec".toLowerCase(), true); + NotAllowedOnBindings.put("protocol".toLowerCase(), true); + NotAllowedOnBindings.put("transport".toLowerCase(), true); + NotAllowedOnBindings.put("signatureComponent".toLowerCase(), true); + NotAllowedOnBindings.put("unvalidatable".toLowerCase(), true); + NotAllowedOnBindings.put("checked".toLowerCase(), true); + NotAllowedOnBindings.put("unchecked".toLowerCase(), true); + NotAllowedOnBindings.put("cacheable".toLowerCase(), true); + NotAllowedOnBindings.put("uncacheable".toLowerCase(), true); + NotAllowedOnBindings.put("keyGenerator".toLowerCase(), true); + NotAllowedOnBindings.put("findQualifier".toLowerCase(), true); + NotAllowedOnBindings.put("sortOrder".toLowerCase(), true); + NotAllowedOnBindings.put("useTypeDesignator".toLowerCase(), true); + } + @Override public void validateValuesBindingTemplate(List<BindingTemplate> items, String xpath) throws DispositionReportFaultMessage { if (items == null) { return; } + //can't use everything else for (int i = 0; i < items.size(); i++) { if (items.get(i).getCategoryBag() != null) { - validatedValuesKeyRef(items.get(i).getCategoryBag().getKeyedReference(), xpath + "bindingTemplate(" + i + ").categoryBag."); - validatedValuesKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), xpath + "bindingTemplate(" + i + ").categoryBag."); + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReference().size(); k++) { + if (items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() != null) { + if (NotAllowedOnBindings.containsKey(items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() + "] not allowed on bindingtemplates for key " + key)); + } + } + + } + + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReferenceGroup().size(); k++) { + if (items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey() != null) { + if (NotAllowedOnBindings.containsKey(items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey() + "] not allowed on bindingtemplates for key " + key)); + } + for (int j = 0; j < items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().size(); j++) { + if (items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey() != null) { + if (NotAllowedOnBindings.containsKey(items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey() + "] not allowed on bindingtemplates for key " + key)); + } + } + } + } + } } if (items.get(i).getTModelInstanceDetails() != null) { - validateTmodelInstanceDetails(items.get(i).getTModelInstanceDetails().getTModelInstanceInfo(), xpath + "bindingTemplate(" + i + ").tModelInstanceDetails."); + for (int k = 0; i < items.get(i).getTModelInstanceDetails().getTModelInstanceInfo().size(); k++) { + if (key.equalsIgnoreCase(items.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getTModelKey())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", key + " is not allowed on tModelInstanceInfos")); + } + } } } } @@ -874,14 +932,11 @@ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { if (items == null) { return; } + + //cant use the following + //wsdlDeployment for (int i = 0; i < items.size(); i++) { - if (items.get(i).getCategoryBag() != null) { - validatedValuesKeyRef(items.get(i).getCategoryBag().getKeyedReference(), "businessEntity(" + i + ").categoryBag."); - validatedValuesKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), "businessEntity(" + i + ").categoryBag."); - } - if (items.get(i).getIdentifierBag() != null) { - validatedValuesKeyRef(items.get(i).getIdentifierBag().getKeyedReference(), "businessEntity(" + i + ").identifierBag."); - } + if (items.get(i).getBusinessServices() != null) { validateValuesBusinessService(items.get(i).getBusinessServices().getBusinessService(), "businessEntity(" + i + ")."); } @@ -895,8 +950,8 @@ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { } for (int i = 0; i < items.size(); i++) { if (items.get(i).getCategoryBag() != null) { - validatedValuesKeyRef(items.get(i).getCategoryBag().getKeyedReference(), xpath + "businessService(" + i + ").categoryBag."); - validatedValuesKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), xpath + "businessService(" + i + ").categoryBag."); + //No specific rules for business services + } if (items.get(i).getBindingTemplates() != null) { validateValuesBindingTemplate(items.get(i).getBindingTemplates().getBindingTemplate(), xpath + xpath + "businessService(" + i + ").identifierBag."); @@ -909,47 +964,7 @@ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { if (items == null) { return; } - for (int i = 0; i < items.size(); i++) { - if (items.get(i).getKeyedReference() != null) { - List<KeyedReference> temp = new ArrayList<KeyedReference>(); - temp.add(items.get(i).getKeyedReference()); - validatedValuesKeyRef(temp, "publisherAssertion(" + i + ")."); - } - } - } - - private void validatedValuesKeyRef(List<KeyedReference> items, String xpath) throws DispositionReportFaultMessage { - if (items == null) { - return; - } - String err = ""; - for (int i = 0; i < items.size(); i++) { - List<String> validValues = getValidValues(); - if (validValues != null) { - //ok we have some work to do - boolean valid = false; - for (int k = 0; k < validValues.size(); k++) { - if (validValues.get(i).equals(items.get(i).getKeyValue())) { - valid = true; - } - } - if (!valid) { - err += xpath + "keyedReference(" + i + ") "; - } - } - } - if (err.length() > 0) { - throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", err)); - } - } - - private void validatedValuesKeyRefGrp(List<KeyedReferenceGroup> items, String xpath) throws DispositionReportFaultMessage { - if (items == null) { - return; - } - for (int i = 0; i < items.size(); i++) { - validatedValuesKeyRef(items.get(i).getKeyedReference(), xpath + "keyReferenceGroup(" + i + ")."); - } + //no rules for PA } @Override @@ -960,13 +975,8 @@ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { @Override public List<String> getValidValues() { List<String> ret = new ArrayList<String>(); - ret.add("checked"); - ret.add("unchecked"); - ret.add("cacheable"); - ret.add("uncacheable"); - ret.add("keygenerator"); - ret.add("findqualifier"); - ret.add("wsdldeployment"); + ret.addAll(NotAllowedOnBindings.keySet()); + ret.addAll(NotAllowedOnTModels.keySet()); return ret; } @@ -977,11 +987,39 @@ public class Uddiuddiorgcategorizationtype implements ValueSetValidator { } for (int i = 0; i < items.size(); i++) { if (items.get(i).getCategoryBag() != null) { - validatedValuesKeyRef(items.get(i).getCategoryBag().getKeyedReference(), "tModel(" + i + ").categoryBag."); - validatedValuesKeyRefGrp(items.get(i).getCategoryBag().getKeyedReferenceGroup(), "tModel(" + i + ").categoryBag."); + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReference().size(); k++) { + if (items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() != null) { + if (NotAllowedOnTModels.containsKey(items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() + "] not allowed on tModels for key " + key)); + } + } + + } + + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReferenceGroup().size(); k++) { + if (items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey() != null) { + if (NotAllowedOnTModels.containsKey(items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getTModelKey() + "] not allowed on tModels for key " + key)); + } + for (int j = 0; j < items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().size(); j++) { + if (items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey() != null) { + if (NotAllowedOnTModels.containsKey(items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReferenceGroup().get(k).getKeyedReference().get(j).getTModelKey() + "] not allowed on tModels for key " + key)); + } + } + } + } + } } if (items.get(i).getIdentifierBag() != null) { - validatedValuesKeyRef(items.get(i).getIdentifierBag().getKeyedReference(), "tModel(" + i + ").identifierBag."); + for (int k = 0; k < items.get(i).getCategoryBag().getKeyedReference().size(); k++) { + if (items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() != null) { + if (NotAllowedOnTModels.containsKey(items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey().toLowerCase())) { + throw new InvalidValueException(new ErrorMessage("errors.valuesetvalidation.invalidcontent", "Value [" + items.get(i).getCategoryBag().getKeyedReference().get(k).getTModelKey() + "] not allowed on tModels for key " + key)); + } + } + + } } } } http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java index f9f2977..fa20db3 100644 --- a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java @@ -17,19 +17,36 @@ package org.apache.juddi.validation.vsv; import java.util.List; +import org.apache.juddi.api.impl.UDDIValueSetCachingImpl; +import org.apache.juddi.api.impl.UDDIValueSetValidationImpl; import org.uddi.api_v3.BindingTemplate; import org.uddi.api_v3.BusinessEntity; import org.uddi.api_v3.BusinessService; -import org.uddi.api_v3.DispositionReport; import org.uddi.api_v3.PublisherAssertion; import org.uddi.api_v3.TModel; import org.uddi.api_v3.TModelInstanceInfo; import org.uddi.v3_service.DispositionReportFaultMessage; -import org.uddi.vs_v3.ValidateValues; /** - * + * This is the value set validator interface. It enables you to define your own validation rules for tModel Keyed References. + * To use this, define a tModel containing the following + * <pre><categoryBag> + * <keyedReference keyName="" + * keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" + * tModelKey="uddi:uddi.org:identifier:validatedby"/> + * </categoryBag> + * </pre>Where uddi:juddi.apache.org:servicebindings-valueset-cp + * is the binding key of the service implementing the VSV API (this service). + * <Br><BR> + * From there, you need to create a class that either implements + * {@link ValueSetValidator} or extends {@link AbstractSimpleValidator}. It must + * be in the package named org.apache.juddi.validation.vsv and must by named + * following the convention outlined in {@link #ConvertKeyToClass(java.lang.String) * @author Alex O'Ree + * @since 3.2.1 + * @see AbstractSimpleValidator + * @see UDDIValueSetValidationImpl + * @see UDDIValueSetCachingImpl */ public interface ValueSetValidator { http://git-wip-us.apache.org/repos/asf/juddi/blob/4c7e798b/juddi-core/src/main/resources/juddi_install_data/UDDI_tModels.xml ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/resources/juddi_install_data/UDDI_tModels.xml b/juddi-core/src/main/resources/juddi_install_data/UDDI_tModels.xml index 2119c21..fb557a7 100644 --- a/juddi-core/src/main/resources/juddi_install_data/UDDI_tModels.xml +++ b/juddi-core/src/main/resources/juddi_install_data/UDDI_tModels.xml @@ -64,6 +64,7 @@ <keyedReference keyName="uddi-org:types:categorization" keyValue="categorization" tModelKey="uddi:uddi.org:categorization:types" /> <keyedReference keyName="uddi-org:types:checked" keyValue="checked" tModelKey="uddi:uddi.org:categorization:types" /> <keyedReference keyName="uddi-org:types:cacheable" keyValue="cacheable" tModelKey="uddi:uddi.org:categorization:types" /> + <keyedReference keyName="" keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" tModelKey="uddi:uddi.org:identifier:validatedby"/> </categoryBag> </tModel> <tModel tModelKey="uddi:uddi.org:categorization:general_keywords"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
