1/*2 * Copyright 2001-2008 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 */1718package org.apache.juddi.validation;
192021import java.util.logging.Level;
22import java.util.logging.Logger;
23import javax.persistence.EntityManager;
24import org.apache.commons.configuration.ConfigurationException;
25import org.apache.juddi.config.AppConfig;
26import org.apache.juddi.config.Property;
2728import org.apache.juddi.model.Subscription;
29import org.apache.juddi.model.UddiEntity;
30import org.apache.juddi.model.UddiEntityPublisher;
31import org.apache.juddi.v3.error.ErrorMessage;
32import org.apache.juddi.v3.error.UnsupportedException;
33import org.uddi.v3_service.DispositionReportFaultMessage;
3435/**36 * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>37 */38publicabstractclassValidateUDDIApi {
3940protectedUddiEntityPublisher publisher;
41protected String nodeID=null;
4243/**44 * This is used only during the install process to prevent infinite loops45 * @param publisher46 * @param nodeid 47 */48publicValidateUDDIApi(UddiEntityPublisher publisher, String nodeid) {
49this.publisher = publisher;
50this.nodeID = nodeid;
51 }
5253publicValidateUDDIApi(UddiEntityPublisher publisher) {
54this.publisher = publisher;
55try {
56this.nodeID = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
57 } catch (ConfigurationException ex) {
58 Logger.getLogger(ValidateUDDIApi.class.getName()).log(Level.SEVERE, "unable to get the current node id, this may cause access control problems"59 + " and must be fixed. set " + Property.JUDDI_NODE_ID + " in juddiv3.xml", ex);
60 }
61 }
6263publicUddiEntityPublisher getPublisher() {
64return publisher;
65 }
6667publicvoid setPublisher(UddiEntityPublisher publisher) {
68this.publisher = publisher;
69 }
7071publicstaticvoid unsupportedAPICall() throws DispositionReportFaultMessage {
72thrownewUnsupportedException(newErrorMessage("errors.Unsupported"));
73 }
7475publicstaticboolean isUniqueKey(EntityManager em, String entityKey) {
76 Object obj = em.find(UddiEntity.class, entityKey);
77if (obj != null)
78return false;
7980 obj = em.find(Subscription.class, entityKey);
81if (obj != null)
82return false;
8384returntrue;
85 }
86 }