http://git-wip-us.apache.org/repos/asf/juddi/blob/e78753f1/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgidentifierisreplacedby.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgidentifierisreplacedby.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgidentifierisreplacedby.java new file mode 100644 index 0000000..0c97efe --- /dev/null +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgidentifierisreplacedby.java @@ -0,0 +1,318 @@ +/* + * Copyright 2014 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.validation.vsv; + +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; +import org.uddi.v3_service.DispositionReportFaultMessage; + +/** + * UDDI provides a mechanism that may be used by publishers to tag their + * businessEntities and tModels with information that identifies them according + * to any number of identification systems. This tModel represents an identifier + * system that may be used to identify the tModel or businessEntity that + * logically replaces the tModel or businessEntity in which it is used. This + * version of the isReplacedBy identifier system replaces the prior version of + * this identifier system by providing a means for referring to replacement + * entities that have version 3 format keys. + * + * It is often desirable to gracefully retire a tModel in favor of a + * replacement. For example, when a Web service definition is replaced by an + * incompatible version, the publisher of the specification may wish to leave + * the tModel for the existing definition in place so that existing uses will + * not be disturbed, while at the same time making it clear that there is a + * replacement available. The UDDI isReplacedBy identifier system, coupled with + * the behavior of UDDI with respect to obsolete tModels, fills this need by + * allowing the obsolete tModel to point to its replacement. See Section 5.2.11 + * delete_tModel. + * + * The isReplacedBy identifier system exists in prior versions of UDDI. + * keyedReferences that refer to this original isReplacedBy identifier system + * contain entity keys in the version 1 and 2 formats (as UUIDs with the uuid or + * no scheme prefix). When accessed using a prior version API in a multi-version + * registry, the older isReplacedBy identifier system yields valid references to + * businessEntity or tModel keys that are in the format of the prior version, + * and thus remain valid. When viewed using the version 3 UDDI API these same + * references to the earlier isReplacedBy identifier system contain invalid + * version 3 format keys. A new version of this identifier system is required to + * be able to reference the set of values defined by version 3 format keys. + * +* <p class="MsoBodyText">The keyValues in keyedReferences that refer to this + * tModel must be tModelKeys or businessKeys. Such a keyValue specifies the + * entity that is the replacement for the entity in which the keyedReference + * appears. The above and further validation requirements are as follows:</p> + * + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in">a.<span + * style="font:7.0pt "Times New + * Roman""> </span>In the case where a + * reference is made from an obsolete business entity the following validation + * rules apply:</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">1.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to a new + * business entity; this is a valid operation</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">2.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to self; + * this is invalid</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">3.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to a + * service, binding or tModel; this is an invalid operation given that the + * entity being pointed to must be a business</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">4.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to another + * publisherâs business; this is a valid operation; no ownership check is + * made</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">5.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to another + * publisherâs service, binding or tModel; this is an invalid operation because + * of a.3 above</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">6.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to invalid + * keys; this is an invalid operation; a key must be valid.</p> + * + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in">b.<span + * style="font:7.0pt "Times New Roman""> + * </span>In the case where a reference is made from an obsolete tModel the + * following validation rules apply:</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">1.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to a new + * tModel; this is a valid operation</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">2.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to self; + * this is invalid</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">3.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to a + * service, binding or business; this is an invalid operation given that the + * entity being pointed to must be a tModel</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">4.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to another + * publisherâs tModel; this is a valid operation; no ownership check is made</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">5.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to another + * publisherâs service, binding or business; this is an invalid operation + * because of b.3 above</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">6.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to invalid + * keys; this is an invalid operation; a key must be valid.</p> + * + * <p class="MsoBodyText" style="margin-left:1.25in;text-indent:-.25in">7.<span + * style="font:7.0pt "Times New + * Roman""> </span>reference to a + * hidden tModel; this is a valid operation</p> + * + * <p class="MsoBodyText" style="margin-left:1.0in;text-indent:-.25in">c.<span + * style="font:7.0pt "Times New + * Roman""> </span>Adding isReplacedBy + * to a serviceâs or bindingâs category bag: this is a semantically wrong + * operation and will be rejected. </p> + * + * <p class="MsoBodyText">When returning an error encountered in the above, + * E_invalidValue will be returned to indicate that a value that was passed in a + * keyValue attribute did not pass validation.</p> + * + * <p class="MsoBodyText">While this validation is intended at save time, + * references to replacing business entities may become invalid if (A) the + * business is deleted and (B) in V3 the business is deleted and then the key is + * re-used for a different entity. As such, in a replicating registry, nodes + * processing changeRecords related to business entities or tModels that refer + * to (now) invalid or missing business or tModels entity keys respectively, + * MUST NOT raise replication errors.</p> + * + * @author Alex O'Ree + */ +public class Uddiuddiorgidentifierisreplacedby implements ValueSetValidator { + + public static final String key = "uddi:uddi.org:identifier:isreplacedby"; + + @Override + public void validateValuesBindingTemplate(List<BindingTemplate> items, String xpath) throws DispositionReportFaultMessage { + 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 { + 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 { + 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 { + if (items == null) { + return; + } + for (int i = 0; i < items.size(); i++) { + AbstractSimpleValidator.validateKeyNotPresentKeyRef(items.get(i).getKeyedReference(), key, "publisherAssertion"); + } + } + + 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)); + } + } + + @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 { + 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())) { + //TODO look up value + Tmodel find = em.find(org.apache.juddi.model.Tmodel.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")); + } + } + } + } + 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/e78753f1/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgrelationships.java ---------------------------------------------------------------------- diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgrelationships.java b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgrelationships.java new file mode 100644 index 0000000..2748bba --- /dev/null +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/Uddiuddiorgrelationships.java @@ -0,0 +1,55 @@ +/* + * Copyright 2014 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.validation.vsv; + +import java.util.ArrayList; +import java.util.List; + +/** + * UDDI provides a mechanism that may be used by publishers to assert + * relationships between businessEntity structures they publish and other + * businessEntity structures according to any number of relationship type + * schemes. See Appendix A Relationships and Publisher Assertions for more + * information. This section defines a tModel representing a relationship type + * system for use in describing the way businessEntity structures relate to one + * another. + * <Br><Br> + * While UDDI provides for any number of relationship type system to be used in + * relating businessEntity structures to one another, it is useful to define a + * "starter set" of relationship types that publishers may use without needing + * to define their own. The uddi-org:relationships relationship type system is + * such a starter set that covers a number of basic relationships. All three + * attributes are significant in keyedReferences that describe relationship + * types. The keyValue attributes should contain well known but somewhat broad + * versions of the relationship type, like those described in this relationship + * type set. The keyName attributes should be used to more explicitly type the + * relationship. + * + * @author Alex O'Ree + */ +public class Uddiuddiorgrelationships extends AbstractSimpleValidator{ + + @Override + public List<String> getValidValues() { + List<String> ret = new ArrayList<String>(); + ret.add("parent-child"); + ret.add("identity"); + ret.add("peer-peer"); + return ret; + } + + +} http://git-wip-us.apache.org/repos/asf/juddi/blob/e78753f1/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 new file mode 100644 index 0000000..f9f2977 --- /dev/null +++ b/juddi-core/src/main/java/org/apache/juddi/validation/vsv/ValueSetValidator.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.juddi.validation.vsv; + +import java.util.List; +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; + +/** + * + * @author Alex O'Ree + */ +public interface ValueSetValidator { + + public void validateTmodelInstanceDetails(List<TModelInstanceInfo> tModelInstanceInfo, String xpath) throws DispositionReportFaultMessage; + + public void validateValuesBindingTemplate(List<BindingTemplate> items, String xpath) throws DispositionReportFaultMessage; + + public void validateValuesBusinessEntity(List<BusinessEntity> items) throws DispositionReportFaultMessage; + + public void validateValuesBusinessService(List<BusinessService> items, String xpath) throws DispositionReportFaultMessage; + + public void validateValuesPublisherAssertion(List<PublisherAssertion> items) throws DispositionReportFaultMessage; + + public void validateValuesTModel(List<TModel> items) throws DispositionReportFaultMessage; + + public List<String> getValidValues(); +} http://git-wip-us.apache.org/repos/asf/juddi/blob/e78753f1/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 50f524e..2119c21 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 @@ -155,6 +155,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:uncacheable" keyValue="uncacheable" tModelKey="uddi:uddi.org:categorization:types" /> + <keyedReference keyName="" keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" tModelKey="uddi:uddi.org:identifier:validatedby"/> </categoryBag> </tModel> @@ -228,8 +229,8 @@ <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:uncacheable" keyValue="uncacheable" tModelKey="uddi:uddi.org:categorization:types" /> - <keyedReference keyName="entityKeyValues" keyValue="businessKey" tModelKey="uddi:uddi.org:categorization:entitykeyvalues" /> + <keyedReference keyName="" keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" tModelKey="uddi:uddi.org:identifier:validatedby"/> </categoryBag> </tModel> <tModel tModelKey="uddi:uddi.org:identifier:isreplacedby"> @@ -248,10 +249,9 @@ <keyedReference keyName="uddi-org:types:identifier" keyValue="identifier" 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:uncacheable" keyValue="uncacheable" tModelKey="uddi:uddi.org:categorization:types" /> - <keyedReference keyName="entityKeyValues" keyValue="businessKey" tModelKey="uddi:uddi.org:categorization:entitykeyvalues" /> - <keyedReference keyName="entityKeyValues" keyValue="tModelKey" tModelKey="uddi:uddi.org:categorization:entitykeyvalues" /> + <keyedReference keyName="" keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" tModelKey="uddi:uddi.org:identifier:validatedby"/> </categoryBag> </tModel> @@ -296,6 +296,7 @@ <keyedReference keyName="uddi-org:types:checked" keyValue="checked" tModelKey="uddi:uddi.org:categorization:types" /> <keyedReference keyName="uddi-org:types:uncacheable" keyValue="uncacheable" tModelKey="uddi:uddi.org:categorization:types" /> <keyedReference keyName="entityKeyValues" keyValue="bindingKey" tModelKey="uddi:uddi.org:categorization:entitykeyvalues" /> + <keyedReference keyName="" keyValue="uddi:juddi.apache.org:servicebindings-valueset-cp" tModelKey="uddi:uddi.org:identifier:validatedby"/> </categoryBag> </tModel> <tModel tModelKey="uddi:uddi.org:categorization:derivedfrom"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
