You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2010/12/15 22:50:21 UTC
svn commit: r1049724 - in /juddi/trunk:
juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/
juddi-core/src/main/java/org/apache/juddi/validation/
uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/
uddi-tck-base/src/main/resources/uddi_data/jo...
Author: kstam
Date: Wed Dec 15 21:50:21 2010
New Revision: 1049724
URL: http://svn.apache.org/viewvc?rev=1049724&view=rev
Log:
JUDDI-435, removing the TODO and allowing moving of services if both businesses are owned by the same publisher.
Added:
juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/moveBusinessService1to3.xml
Modified:
juddi/trunk/juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java
juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java
juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/businessEntity3.xml
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_040_BusinessServiceIntegrationTest.java
Modified: juddi/trunk/juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java?rev=1049724&r1=1049723&r2=1049724&view=diff
==============================================================================
--- juddi/trunk/juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java (original)
+++ juddi/trunk/juddi-core-openjpa/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java Wed Dec 15 21:50:21 2010
@@ -111,6 +111,44 @@ public class API_040_BusinessServiceTest
tckTModel.deleteJoePublisherTmodel(authInfoJoe);
}
}
+ /**
+ * 5.2.16.3 paragraph 4
+ * Data contained within businessEntity structures can be rearranged with
+ * this API call. This can be done by redefining parent container relationships
+ * for other registered information. For instance, if a new businessEntity
+ * is saved with information about a businessService that is registered
+ * already as part of a different businessEntity, this results in the
+ * businessService being moved from its current container to the new businessEntity.
+ * This condition occurs when the businessKey of the businessService being
+ * saved matches the businessKey of the businessEntity being saved.
+ * An attempt to delete or move a businessService in this manner by
+ * a party who is not the publisher of the businessService MUST be
+ * rejected with an error E_userMismatch.
+ */
+ @Test
+ public void joepublisherMoveBusinessService() {
+ try {
+ tckTModel.saveJoePublisherTmodel(authInfoJoe);
+ tckBusiness.saveJoePublisherBusiness(authInfoJoe);
+ tckBusinessService.saveJoePublisherService(authInfoJoe);
+ tckBusiness.checkServicesBusinessOne(1);
+ tckBusiness.saveJoePublisherBusiness3(authInfoJoe);
+ //check that this business has no services
+ tckBusiness.checkServicesBusinessThree(0);
+ //Now move the service from one to three
+ tckBusiness.saveJoePublisherBusiness1to3(authInfoJoe);
+ tckBusiness.checkServicesBusinessOne(0);
+ tckBusiness.checkServicesBusinessThree(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ } finally {
+ tckBusinessService.deleteJoePublisherService(authInfoJoe);
+ tckBusiness.deleteJoePublisherBusiness3(authInfoJoe);
+ tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
+ tckTModel.deleteJoePublisherTmodel(authInfoJoe);
+ }
+ }
@Test
public void samsyndicator() {
Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java?rev=1049724&r1=1049723&r2=1049724&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java Wed Dec 15 21:50:21 2010
@@ -522,15 +522,21 @@ public class ValidatePublish extends Val
businessService.setBusinessKey(parentKey);
}
- // If existing service trying to be saved has a different parent key, then we have a problem
- // TODO: moving services is allowed according to spec?
- if (!parentKey.equalsIgnoreCase(bs.getBusinessEntity().getEntityKey()))
- throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.businessservice.ParentMismatch", parentKey + ", " + bs.getBusinessEntity().getEntityKey()));
-
// Make sure publisher owns this entity.
if (!publisher.isOwner((UddiEntity)obj))
throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));
+ // If existing service trying to be saved has a different parent key, then we have a problem
+ if (!parentKey.equalsIgnoreCase(bs.getBusinessEntity().getEntityKey())) {
+ // if both businesses are owned by this publisher then we allow it.
+ // we already check the current business is owned, lets see if the old one is too
+ if (!publisher.isOwner(bs.getBusinessEntity())) {
+ throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.businessservice.ParentMismatch", parentKey + ", " + bs.getBusinessEntity().getEntityKey()));
+ } else {
+ if (log.isDebugEnabled()) log.debug("Services moved from business " + bs.getBusinessEntity() + " to " + businessService.getBusinessKey());
+ }
+ }
+
}
else {
// Inside this block, we have a key proposed by the publisher on a new entity
Modified: juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java?rev=1049724&r1=1049723&r2=1049724&view=diff
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java (original)
+++ juddi/trunk/uddi-tck-base/src/main/java/org/apache/juddi/v3/tck/TckBusiness.java Wed Dec 15 21:50:21 2010
@@ -17,6 +17,7 @@ package org.apache.juddi.v3.tck;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
+import java.rmi.RemoteException;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -39,6 +40,9 @@ public class TckBusiness
{
final static String JOE_BUSINESS_XML = "uddi_data/joepublisher/businessEntity.xml";
final static String JOE_BUSINESS_KEY = "uddi:uddi.joepublisher.com:businessone";
+ final static String JOE_BUSINESS3_XML = "uddi_data/joepublisher/businessEntity3.xml";
+ final static String JOE_BUSINESS3_KEY = "uddi:uddi.joepublisher.com:businessthree.com";
+ final static String JOE_BUSINESS_MOVE_XML = "uddi_data/joepublisher/moveBusinessService1to3.xml";
final static String MARY_BUSINESS_XML = "uddi_data/marypublisher/businessEntity.xml";
final static String MARY_BUSINESS_KEY = "uddi:uddi.marypublisher.com:marybusinessone";
final static String SAM_BUSINESS_XML = "uddi_data/samsyndicator/businessEntity.xml";
@@ -80,6 +84,14 @@ public class TckBusiness
saveBusiness(authInfoJoe, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
}
+ public void saveJoePublisherBusiness3(String authInfoJoe) {
+ saveBusiness(authInfoJoe, JOE_BUSINESS3_XML, JOE_BUSINESS3_KEY);
+ }
+
+ public void saveJoePublisherBusiness1to3(String authInfoJoe) {
+ saveBusiness(authInfoJoe, JOE_BUSINESS_MOVE_XML, JOE_BUSINESS3_KEY);
+ }
+
public void saveMaryPublisherBusiness(String authInfoMary) {
saveBusiness(authInfoMary, MARY_BUSINESS_XML, MARY_BUSINESS_KEY);
}
@@ -96,6 +108,10 @@ public class TckBusiness
deleteBusiness(authInfoJoe, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
}
+ public void deleteJoePublisherBusiness3(String authInfoJoe) {
+ deleteBusiness(authInfoJoe, JOE_BUSINESS3_XML, JOE_BUSINESS3_KEY);
+ }
+
public void deleteMaryPublisherBusiness(String authInfoMary) {
deleteBusiness(authInfoMary, MARY_BUSINESS_XML, MARY_BUSINESS_KEY);
}
@@ -103,6 +119,14 @@ public class TckBusiness
public void deleteJoePublisherBusinesses(String authInfoJoe, int numberOfCopies) {
deleteBusinesses(authInfoJoe, JOE_BUSINESS_XML, JOE_BUSINESS_KEY, numberOfCopies);
}
+
+ public void checkServicesBusinessOne(int expectedNumberOfServices) {
+ checkNumberOfServices(JOE_BUSINESS_KEY,expectedNumberOfServices);
+ }
+
+ public void checkServicesBusinessThree(int expectedNumberOfServices) {
+ checkNumberOfServices(JOE_BUSINESS3_KEY,expectedNumberOfServices);
+ }
public void saveBusinesses(String authInfo, String businessXML, String businessKey, int numberOfCopies) {
try {
@@ -123,6 +147,26 @@ public class TckBusiness
Assert.fail("No exception should be thrown");
}
}
+
+ public void checkNumberOfServices(String businessKey, int expectedServices) {
+
+ try {
+ GetBusinessDetail gb = new GetBusinessDetail();
+ gb.getBusinessKey().add(businessKey);
+ BusinessDetail bd;
+ bd = inquiry.getBusinessDetail(gb);
+ List<BusinessEntity> beOutList = bd.getBusinessEntity();
+ BusinessEntity beOut = beOutList.get(0);
+ if (expectedServices > 0) {
+ assertEquals(expectedServices, beOut.getBusinessServices().getBusinessService().size());
+ } else {
+ Assert.assertNull(beOut.getBusinessServices());
+ }
+ } catch (RemoteException e) {
+ logger.error(e.getMessage(),e);
+ Assert.fail("No exception should be thrown");
+ }
+ }
public void saveBusiness(String authInfo, String businessXML, String businessKey) {
try {
Modified: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/businessEntity3.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/businessEntity3.xml?rev=1049724&r1=1049723&r2=1049724&view=diff
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/businessEntity3.xml (original)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/businessEntity3.xml Wed Dec 15 21:50:21 2010
@@ -15,7 +15,7 @@
* limitations under the License.
*
*/ -->
-<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:businessthree.com">
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.joepublisher.com:businessthree.com">
<discoveryURLs>
<discoveryURL useType="home">http://www.businessthree.com</discoveryURL>
<discoveryURL useType="serviceList">http://www.businessthree.com/services</discoveryURL>
@@ -37,18 +37,4 @@
</address>
</contact>
</contacts>
- <businessServices>
- </businessServices>
- <categoryBag>
- <keyedReference tModelKey="uddi:tmodelkey:categories:fruit" keyName="category" keyValue="apples" />
- <keyedReference tModelKey="uddi:tmodelkey:categories:music" keyName="category" keyValue="jazz" />
- <keyedReference tModelKey="uddi:tmodelkey:categories:music" keyName="category" keyValue="blues" />
- <keyedReference tModelKey="uddi:tmodelkey:categories:music" keyName="category" keyValue="blues-rock" />
- <keyedReferenceGroup tModelKey="uddi:tmodelkey:group">
- <keyedReference tModelKey="uddi:tmodelkey:blank" keyName="blank" keyValue="blank" />
- </keyedReferenceGroup>
- </categoryBag>
- <identifierBag>
- <keyedReference tModelKey="uddi:tmodelkey:identifier" keyName="identify" keyValue="identity" />
- </identifierBag>
</businessEntity>
\ No newline at end of file
Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/moveBusinessService1to3.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/moveBusinessService1to3.xml?rev=1049724&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/moveBusinessService1to3.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/joepublisher/moveBusinessService1to3.xml Wed Dec 15 21:50:21 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 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.
+ *
+ */ -->
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.joepublisher.com:businessthree.com">
+ <name>businessThree</name>
+ <businessServices>
+ <!-- Move the service businessone to businessthree-->
+ <businessService serviceKey="uddi:uddi.joepublisher.com:serviceone" businessKey="uddi:uddi.joepublisher.com:businessthree.com">
+ <name>moved service</name>
+ </businessService>
+ </businessServices>
+</businessEntity>
\ No newline at end of file
Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_040_BusinessServiceIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_040_BusinessServiceIntegrationTest.java?rev=1049724&r1=1049723&r2=1049724&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_040_BusinessServiceIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_040_BusinessServiceIntegrationTest.java Wed Dec 15 21:50:21 2010
@@ -113,6 +113,45 @@ public class UDDI_040_BusinessServiceInt
}
}
+ /**
+ * 5.2.16.3 paragraph 4
+ * Data contained within businessEntity structures can be rearranged with
+ * this API call. This can be done by redefining parent container relationships
+ * for other registered information. For instance, if a new businessEntity
+ * is saved with information about a businessService that is registered
+ * already as part of a different businessEntity, this results in the
+ * businessService being moved from its current container to the new businessEntity.
+ * This condition occurs when the businessKey of the businessService being
+ * saved matches the businessKey of the businessEntity being saved.
+ * An attempt to delete or move a businessService in this manner by
+ * a party who is not the publisher of the businessService MUST be
+ * rejected with an error E_userMismatch.
+ */
+ @Test
+ public void joepublisherMoveBusinessService() {
+ try {
+ tckTModel.saveJoePublisherTmodel(authInfoJoe);
+ tckBusiness.saveJoePublisherBusiness(authInfoJoe);
+ tckBusinessService.saveJoePublisherService(authInfoJoe);
+ tckBusiness.checkServicesBusinessOne(1);
+ tckBusiness.saveJoePublisherBusiness3(authInfoJoe);
+ //check that this business has no services
+ tckBusiness.checkServicesBusinessThree(0);
+ //Now move the service from one to three
+ tckBusiness.saveJoePublisherBusiness1to3(authInfoJoe);
+ tckBusiness.checkServicesBusinessOne(0);
+ tckBusiness.checkServicesBusinessThree(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ } finally {
+ tckBusinessService.deleteJoePublisherService(authInfoJoe);
+ tckBusiness.deleteJoePublisherBusiness3(authInfoJoe);
+ tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
+ tckTModel.deleteJoePublisherTmodel(authInfoJoe);
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org