[prev in list] [next in list] [prev in thread] [next in thread]
List: juddi-cvs
Subject: svn commit: r1170951 - in /juddi/trunk/juddi-core/src/main:
From: kstam () apache ! org
Date: 2011-09-15 4:17:47
Message-ID: 20110915041747.714DD23888E4 () eris ! apache ! org
[Download RAW message or body]
Author: kstam
Date: Thu Sep 15 04:17:46 2011
New Revision: 1170951
URL: http://svn.apache.org/viewvc?rev=1170951&view=rev
Log:
JUDDI-258 hooking up checking for max constraints for a publisher
Added:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/error/MaxEntitiesExceededException.java
Modified:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidatePublish.java
juddi/trunk/juddi-core/src/main/resources/messages.properties
Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java?rev=1170951&r1=1170950&r2=1170951&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java \
(original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java \
Thu Sep 15 04:17:46 2011 @@ -518,7 +518,8 @@ public class UDDIPublicationImpl extends
UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());
- new ValidatePublish(publisher).validateSaveBinding(em, body, null);
+ ValidatePublish validator = new ValidatePublish(publisher);
+ validator.validateSaveBinding(em, body, null);
BindingDetail result = new BindingDetail();
@@ -536,6 +537,8 @@ public class UDDIPublicationImpl extends
em.persist(modelBindingTemplate);
result.getBindingTemplate().add(apiBindingTemplate);
+
+ validator.validateSaveBindingMax(em, \
modelBindingTemplate.getBusinessService().getEntityKey()); }
tx.commit();
@@ -569,7 +572,8 @@ public class UDDIPublicationImpl extends
UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());
- new ValidatePublish(publisher).validateSaveBusiness(em, body, null);
+ ValidatePublish validator = new ValidatePublish(publisher);
+ validator.validateSaveBusiness(em, body, null);
BusinessDetail result = new BusinessDetail();
@@ -586,6 +590,9 @@ public class UDDIPublicationImpl extends
result.getBusinessEntity().add(apiBusinessEntity);
}
+
+ //check how many business this publisher owns.
+ validator.validateSaveBusinessMax(em);
tx.commit();
long procTime = System.nanoTime() - startTime;
@@ -618,7 +625,8 @@ public class UDDIPublicationImpl extends
UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());
- new ValidatePublish(publisher).validateSaveService(em, body, null);
+ ValidatePublish validator = new ValidatePublish(publisher);
+ validator.validateSaveService(em, body, null);
ServiceDetail result = new ServiceDetail();
@@ -636,8 +644,11 @@ public class UDDIPublicationImpl extends
em.persist(modelBusinessService);
result.getBusinessService().add(apiBusinessService);
+
+ validator.validateSaveServiceMax(em, \
modelBusinessService.getBusinessEntity().getEntityKey()); }
-
+
+
tx.commit();
long procTime = System.nanoTime() - startTime;
serviceCounter.update(PublicationQuery.SAVE_SERVICE,
Added: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/error/MaxEntitiesExceededException.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/error/MaxEntitiesExceededException.java?rev=1170951&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/error/MaxEntitiesExceededException.java \
(added)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/v3/error/MaxEntitiesExceededException.java \
Thu Sep 15 04:17:46 2011 @@ -0,0 +1,37 @@
+/*
+ * Copyright 2001-2008 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.v3.error;
+
+import org.apache.juddi.v3.error.ErrorMessage;
+import org.apache.juddi.v3.error.RegistryException;
+import org.apache.juddi.v3.error.UDDIErrorHelper;
+
+/**
+ * E_valueNotAllowed: (20210) Signifies that a value did not pass validation \
because of contextual issues. The value may be valid in some contexts, but + * \
not in the context used. The error text MAY contain information about the contextual \
problem. + *
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class MaxEntitiesExceededException extends RegistryException {
+
+ private static final long serialVersionUID = -4003033708851434957L;
+
+ public MaxEntitiesExceededException(ErrorMessage message) {
+ super(message, UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_VALUE_NOT_ALLOWED));
+ }
+}
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=1170951&r1=1170950&r2=1170951&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 \
Thu Sep 15 04:17:46 2011 @@ -37,12 +37,15 @@ import org.apache.juddi.keygen.KeyGenera
import org.apache.juddi.model.Publisher;
import org.apache.juddi.model.UddiEntity;
import org.apache.juddi.model.UddiEntityPublisher;
+import org.apache.juddi.query.FindBusinessByPublisherQuery;
+import org.apache.juddi.query.FindTModelByPublisherQuery;
import org.apache.juddi.v3.error.AssertionNotFoundException;
import org.apache.juddi.v3.error.ErrorMessage;
import org.apache.juddi.v3.error.FatalErrorException;
import org.apache.juddi.v3.error.InvalidKeyPassedException;
import org.apache.juddi.v3.error.InvalidProjectionException;
import org.apache.juddi.v3.error.KeyUnavailableException;
+import org.apache.juddi.v3.error.MaxEntitiesExceededException;
import org.apache.juddi.v3.error.UserMismatchException;
import org.apache.juddi.v3.error.ValueNotAllowedException;
import org.uddi.api_v3.AddPublisherAssertions;
@@ -270,6 +273,32 @@ public class ValidatePublish extends Val
}
}
+ public void validateSaveBusinessMax(EntityManager em) throws \
DispositionReportFaultMessage { +
+ //Obtain the maxSettings for this publisher or get the defaults
+ Publisher publisher = em.find(Publisher.class, \
getPublisher().getAuthorizedName()); + Integer maxBusinesses = \
publisher.getMaxBusinesses(); + try {
+ if (maxBusinesses==null) {
+ if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER)) \
{ + maxBusinesses = \
AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER, \
-1); + } else {
+ maxBusinesses = -1;
+ }
+ }
+ } catch (ConfigurationException e) {
+ log.error(e.getMessage(), e);
+ }
+ //if we have the maxBusinesses set for this publisher then we need to make sure we \
did not exceed it. + if (maxBusinesses > 0) {
+ //get the businesses owned by this publisher
+ List<?> businessKeysFound = FindBusinessByPublisherQuery.select(em, null, \
publisher, null); + if (businessKeysFound!=null && businessKeysFound.size() > \
maxBusinesses) + throw new MaxEntitiesExceededException(new \
ErrorMessage("errors.save.maxBusinessesExceeded")); + }
+
+ }
+
public void validateSaveService(EntityManager em, SaveService body, Configuration \
config) throws DispositionReportFaultMessage {
if (config==null) {
@@ -294,6 +323,31 @@ public class ValidatePublish extends Val
}
}
+ public void validateSaveServiceMax(EntityManager em, String businessKey) throws \
DispositionReportFaultMessage { +
+ //Obtain the maxSettings for this publisher or get the defaults
+ Publisher publisher = em.find(Publisher.class, \
getPublisher().getAuthorizedName()); + Integer maxServices = \
publisher.getMaxBusinesses(); + try {
+ if (maxServices==null) {
+ if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_SERVICES_PER_BUSINESS)) \
{ + maxServices = \
AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_SERVICES_PER_BUSINESS, \
-1); + } else {
+ maxServices = -1;
+ }
+ }
+ } catch (ConfigurationException e) {
+ log.error(e.getMessage(), e);
+ }
+ //if we have the maxServices set for a business then we need to make sure we did \
not exceed it. + if (maxServices > 0) {
+ //get the businesses owned by this publisher
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity = \
em.find(org.apache.juddi.model.BusinessEntity.class, businessKey); + if \
(modelBusinessEntity.getBusinessServices()!=null && \
modelBusinessEntity.getBusinessServices().size() > maxServices) + throw new \
MaxEntitiesExceededException(new ErrorMessage("errors.save.maxServicesExceeded")); \
+ } + }
+
public void validateSaveBinding(EntityManager em, SaveBinding body, Configuration \
config) throws DispositionReportFaultMessage {
if (config==null) {
@@ -316,6 +370,31 @@ public class ValidatePublish extends Val
validateBindingTemplate(em, entity, null, config);
}
}
+
+ public void validateSaveBindingMax(EntityManager em, String serviceKey) throws \
DispositionReportFaultMessage { +
+ //Obtain the maxSettings for this publisher or get the defaults
+ Publisher publisher = em.find(Publisher.class, \
getPublisher().getAuthorizedName()); + Integer maxBindings = \
publisher.getMaxBindingsPerService(); + try {
+ if (maxBindings==null) {
+ if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_BINDINGS_PER_SERVICE)) \
{ + maxBindings = \
AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_BINDINGS_PER_SERVICE, -1); \
+ } else { + maxBindings = -1;
+ }
+ }
+ } catch (ConfigurationException e) {
+ log.error(e.getMessage(), e);
+ }
+ //if we have the maxBindings set for a service then we need to make sure we did \
not exceed it. + if (maxBindings > 0) {
+ //get the bindings owned by this service
+ org.apache.juddi.model.BusinessService modelBusinessService = \
em.find(org.apache.juddi.model.BusinessService.class, serviceKey); + if \
(modelBusinessService.getBindingTemplates()!=null && \
modelBusinessService.getBindingTemplates().size() > maxBindings) + throw new \
MaxEntitiesExceededException(new ErrorMessage("errors.save.maxBindingsExceeded")); \
+ } + }
public void validateSaveTModel(EntityManager em, SaveTModel body, Configuration \
config) throws DispositionReportFaultMessage {
@@ -339,6 +418,31 @@ public class ValidatePublish extends Val
validateTModel(em, entity, config);
}
}
+
+ public void validateSaveTModelMax(EntityManager em) throws \
DispositionReportFaultMessage { +
+ //Obtain the maxSettings for this publisher or get the defaults
+ Publisher publisher = em.find(Publisher.class, \
getPublisher().getAuthorizedName()); + Integer maxTModels = \
publisher.getMaxTmodels(); + try {
+ if (maxTModels==null) {
+ if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER)) \
{ + maxTModels = \
AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER, \
-1); + } else {
+ maxTModels = -1;
+ }
+ }
+ } catch (ConfigurationException e) {
+ log.error(e.getMessage(), e);
+ }
+ //if we have the TModels set for a publisher then we need to make sure we did not \
exceed it. + if (maxTModels > 0) {
+ //get the tmodels owned by this publisher
+ List<?> tmodelKeysFound = FindTModelByPublisherQuery.select(em, null, publisher, \
null); + if (tmodelKeysFound!=null && tmodelKeysFound.size() > maxTModels)
+ throw new MaxEntitiesExceededException(new \
ErrorMessage("errors.save.maxTModelsExceeded")); + }
+ }
public void validateAddPublisherAssertions(EntityManager em, AddPublisherAssertions \
body) throws DispositionReportFaultMessage {
Modified: juddi/trunk/juddi-core/src/main/resources/messages.properties
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/resources/messages.properties?rev=1170951&r1=1170950&r2=1170951&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/resources/messages.properties (original)
+++ juddi/trunk/juddi-core/src/main/resources/messages.properties Thu Sep 15 04:17:46 \
2011 @@ -179,6 +179,10 @@ errors.getregisteredinfo.NoInfoSelection
errors.AdminReqd=An account must have administrative privileges to perform this \
function errors.savepublisher.NoInput=At least one Publisher must be provided
errors.savepublisher.AdminReqd=An account must have administrative privileges to \
save publishers +errors.save.maxBusinessesExceeded=The maximum allowed number of \
businesses are exceed for this publisher +errors.save.maxServicesExceeded=The maximum \
allowed number of services are exceed for this business \
+errors.save.maxBindingsExceeded=The maximum allowed number of bindings are exceed \
for this service +errors.save.maxTModelsExceeded=The maximum allowed number of \
tmodels are exceed for this publisher errors.deletepublisher.AdminReqd=An account \
must have administrative privileges to delete publishers \
errors.publisher.NullInput=The Publisher structure cannot be blank \
errors.publisher.NoAuthorizedName=A valid publisher authorized name was not specified
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic