You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by jf...@apache.org on 2008/09/18 22:11:03 UTC
svn commit: r696786 - in /webservices/juddi/branches/v3_trunk: ./
juddi-core/src/main/java/org/apache/juddi/config/
juddi-core/src/main/java/org/apache/juddi/error/
juddi-core/src/main/java/org/apache/juddi/mapping/
juddi-core/src/main/java/org/apache/...
Author: jfaath
Date: Thu Sep 18 13:11:02 2008
New Revision: 696786
URL: http://svn.apache.org/viewvc?rev=696786&view=rev
Log:
JUDDI-131: Started creating the layer to map api to model. Also added some basic infrastructure for config, error-handling, and the persistence framework. This is all likely to change, but was necessary to test my work.
Added:
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java (with props)
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java (with props)
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java (with props)
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java (with props)
webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/
webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml (with props)
webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties (with props)
Modified:
webservices/juddi/branches/v3_trunk/.classpath
webservices/juddi/branches/v3_trunk/pom.xml
webservices/juddi/branches/v3_trunk/uddi-ws/src/main/java/org/apache/juddi/ws/impl/UDDIPublicationImpl.java
Modified: webservices/juddi/branches/v3_trunk/.classpath
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/.classpath?rev=696786&r1=696785&r2=696786&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/.classpath (original)
+++ webservices/juddi/branches/v3_trunk/.classpath Thu Sep 18 13:11:02 2008
@@ -1,8 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="uddi-ws/src/main/java"/>
- <classpathentry kind="src" path="juddi-core/src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target-eclipse/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="uddi-ws/src/main/java"/>
+ <classpathentry kind="src" path="uddi-ws/src/main/resources"/>
+ <classpathentry kind="src" path="juddi-core/src/main/resources"/>
+ <classpathentry kind="src" path="juddi-core/src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
+</classpath>
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java Thu Sep 18 13:11:02 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.config;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class Configuration {
+ public static final String GLOBAL_MESSAGES_FILE = "messages";
+
+ private static final ResourceBundle globalMessages;
+
+ static {
+ try {
+ globalMessages = ResourceBundle.getBundle(GLOBAL_MESSAGES_FILE, Locale.getDefault());
+ }
+ catch (Throwable t) {
+ System.err.println("Initial configuration failed:" + t);
+ throw new ExceptionInInitializerError(t);
+ }
+ }
+
+ public static String getGlobalMessage(String key) {
+ String msg = null;
+ if (globalMessages != null) {
+ if (key != null && key.length() > 0)
+ msg = globalMessages.getString(key);
+ }
+ if (msg != null && msg.length() > 0)
+ return msg;
+
+ return key;
+ }
+}
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Configuration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java Thu Sep 18 13:11:02 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.error;
+
+import org.apache.juddi.config.Configuration;
+import org.uddi.api_v3.DispositionReport;
+import org.uddi.api_v3.Result;
+import org.uddi.api_v3.ErrInfo;
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class UDDIErrorHelper {
+
+ public static final int E_ASSERTION_NOT_FOUND = 30000;
+ public static final int E_AUTH_TOKEN_EXPIRED = 10110;
+ public static final int E_AUTH_TOKEN_REQUIRED = 10120;
+ public static final int E_ACCOUNT_LIMIT_EXCEEDED = 10160;
+ public static final int E_BUSY = 10400;
+ public static final int E_CATEGORIZATION_NOT_ALLOWED = 20100;
+ public static final int E_FATAL_ERROR = 10500;
+ public static final int E_INVALID_KEY_PASSED = 10210;
+ public static final int E_INVALID_PROJECTION = 20230;
+ public static final int E_INVALID_CATEGORY = 20000;
+ public static final int E_INVALID_COMPLETION_STATUS = 30100;
+ public static final int E_INVALID_URL_PASSED = 10220;
+ public static final int E_INVALID_VALUE = 20200;
+ public static final int E_KEY_RETIRED = 10310;
+ public static final int E_LANGUAGE_ERROR = 10060;
+ public static final int E_MESSAGE_TOO_LARGE = 30110;
+ public static final int E_NAME_TOO_LONG = 10020;
+ public static final int E_OPERATOR_MISMATCH = 10130;
+ public static final int E_PUBLISHER_CANCELLED = 30220;
+ public static final int E_REQUEST_DENIED = 30210;
+ public static final int E_SECRET_UNKNOWN = 30230;
+ public static final int E_SUCCESS = 0;
+ public static final int E_TOO_MANY_OPTIONS = 10030;
+ public static final int E_TRANSFER_ABORTED = 30200;
+ public static final int E_UNRECOGNIZED_VERSION = 10040;
+ public static final int E_UNKNOWN_USER = 10150;
+ public static final int E_UNSUPPORTED = 10050;
+ public static final int E_USER_MISMATCH = 10140;
+ public static final int E_VALUE_NOT_ALLOWED = 20210;
+ public static final int E_UNVALIDATABLE = 20220;
+ public static final int E_REQUEST_TIMEOUT = 20240;
+ public static final int E_INVALID_TIME = 40030;
+ public static final int E_RESULT_SET_TOO_LARGE = 40300;
+
+ public static final String lookupErrCode(int errno) {
+ switch (errno) {
+ case E_ACCOUNT_LIMIT_EXCEEDED : return "E_accountLimitExceeded";
+ case E_ASSERTION_NOT_FOUND : return "E_assertionNotFound";
+ case E_AUTH_TOKEN_EXPIRED : return "E_authTokenExpired";
+ case E_AUTH_TOKEN_REQUIRED : return "E_authTokenRequired";
+ case E_BUSY : return "E_busy";
+ case E_CATEGORIZATION_NOT_ALLOWED : return "E_categorizationNotAllowed";
+ case E_FATAL_ERROR : return "E_fatalError";
+ case E_INVALID_CATEGORY : return "E_invalidCategory";
+ case E_INVALID_COMPLETION_STATUS : return "E_invalidCompletionStatus";
+ case E_INVALID_KEY_PASSED : return "E_invalidKeyPassed";
+ case E_INVALID_PROJECTION : return "E_invalidProjection";
+ case E_INVALID_TIME : return "E_invalidTime";
+ case E_INVALID_URL_PASSED : return "E_invalidURLPassed";
+ case E_INVALID_VALUE : return "E_invalidValue";
+ case E_KEY_RETIRED : return "E_keyRetired";
+ case E_LANGUAGE_ERROR : return "E_languageError";
+ case E_MESSAGE_TOO_LARGE : return "E_messageTooLarge";
+ case E_NAME_TOO_LONG : return "E_nameTooLong";
+ case E_OPERATOR_MISMATCH : return "E_operatorMismatch";
+ case E_PUBLISHER_CANCELLED : return "E_publisherCancelled";
+ case E_REQUEST_DENIED : return "E_requestDenied";
+ case E_REQUEST_TIMEOUT : return "E_requestTimeout";
+ case E_RESULT_SET_TOO_LARGE : return "E_resultSetTooLarge";
+ case E_SECRET_UNKNOWN : return "E_secretUnknown";
+ case E_SUCCESS : return "E_success";
+ case E_TOO_MANY_OPTIONS : return "E_tooManyOptions";
+ case E_TRANSFER_ABORTED : return "E_transferAborted";
+ case E_UNKNOWN_USER : return "E_unknownUser";
+ case E_UNRECOGNIZED_VERSION : return "E_unrecognizedVersion";
+ case E_UNSUPPORTED : return "E_unsupported";
+ case E_UNVALIDATABLE : return "E_unvalidatable";
+ case E_USER_MISMATCH : return "E_userMismatch";
+ case E_VALUE_NOT_ALLOWED : return "E_valueNotAllowed";
+ default : return null;
+ }
+ }
+
+ public static final String lookupErrText(int errno) {
+ String errCode = lookupErrCode(errno);
+ if (errCode == null)
+ return null;
+ return Configuration.getGlobalMessage(errCode);
+ }
+
+ public static final DispositionReport buildDispositionReport(int errNo) {
+ DispositionReport dr = new DispositionReport();
+ Result res = new Result();
+ res.setErrno(errNo);
+
+ ErrInfo ei = new ErrInfo();
+ ei.setErrCode(lookupErrCode(errNo));
+ ei.setValue(lookupErrText(errNo));
+
+ res.setErrInfo(ei);
+
+ dr.getResult().add(res);
+
+ return dr;
+ }
+}
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/error/UDDIErrorHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java Thu Sep 18 13:11:02 2008
@@ -0,0 +1,604 @@
+/*
+ * 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.mapping;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Date;
+
+import javax.xml.bind.JAXBElement;
+
+import org.uddi.v3_service.DispositionReportFaultMessage;
+
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class MappingApiToModel {
+
+ public static void mapBusinessEntity(org.uddi.api_v3.BusinessEntity apiBusinessEntity,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+
+ modelBusinessEntity.setBusinessKey(apiBusinessEntity.getBusinessKey());
+ modelBusinessEntity.setLastUpdate(new Date());
+ // TODO: Theses fields no longer exist in UDDIv3. Are they here for backwards compatibility or can we get rid of them?
+ modelBusinessEntity.setAuthorizedName("authorizedName");
+ modelBusinessEntity.setOperator("operator");
+
+ mapBusinessNames(apiBusinessEntity.getName(), modelBusinessEntity.getBusinessNames(), modelBusinessEntity);
+ mapBusinessDescriptions(apiBusinessEntity.getDescription(), modelBusinessEntity.getBusinessDescrs(), modelBusinessEntity);
+ mapDiscoveryUrls(apiBusinessEntity.getDiscoveryURLs(), modelBusinessEntity.getDiscoveryUrls(), modelBusinessEntity);
+ mapContacts(apiBusinessEntity.getContacts(), modelBusinessEntity.getContacts(), modelBusinessEntity);
+ mapBusinessIdentifiers(apiBusinessEntity.getIdentifierBag(), modelBusinessEntity.getBusinessIdentifiers(), modelBusinessEntity);
+ mapBusinessCategories(apiBusinessEntity.getCategoryBag(), modelBusinessEntity.getBusinessCategories(), modelBusinessEntity);
+
+ mapBusinessServices(apiBusinessEntity.getBusinessServices(), modelBusinessEntity.getBusinessServices(), modelBusinessEntity);
+ }
+
+
+ public static void mapBusinessNames(List<org.uddi.api_v3.Name> apiNameList,
+ Set<org.apache.juddi.model.BusinessName> modelNameList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelNameList.clear();
+
+ Iterator<org.uddi.api_v3.Name> apiNameListItr = apiNameList.iterator();
+ int id = 0;
+ while (apiNameListItr.hasNext()) {
+ org.uddi.api_v3.Name apiName = apiNameListItr.next();
+
+ org.apache.juddi.model.BusinessNameId businessNameId = new org.apache.juddi.model.BusinessNameId(modelBusinessEntity.getBusinessKey(), id++);
+ modelNameList.add(new org.apache.juddi.model.BusinessName(businessNameId, modelBusinessEntity, apiName.getLang(), apiName.getValue()));
+ }
+ }
+
+ public static void mapBusinessDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.BusinessDescr> modelDescList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.BusinessDescrId businessDescId = new org.apache.juddi.model.BusinessDescrId(modelBusinessEntity.getBusinessKey(), id++);
+ modelDescList.add(new org.apache.juddi.model.BusinessDescr(businessDescId, modelBusinessEntity, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapDiscoveryUrls(org.uddi.api_v3.DiscoveryURLs apiDiscUrls,
+ Set<org.apache.juddi.model.DiscoveryUrl> modelDiscUrlList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelDiscUrlList.clear();
+
+ if (apiDiscUrls != null) {
+ List<org.uddi.api_v3.DiscoveryURL> apiDiscUrlList = apiDiscUrls.getDiscoveryURL();
+ Iterator<org.uddi.api_v3.DiscoveryURL> apiDiscUrlListItr = apiDiscUrlList.iterator();
+ int id = 0;
+ while (apiDiscUrlListItr.hasNext()) {
+ org.uddi.api_v3.DiscoveryURL apiDiscUrl = apiDiscUrlListItr.next();
+
+ org.apache.juddi.model.DiscoveryUrlId discUrlId = new org.apache.juddi.model.DiscoveryUrlId(modelBusinessEntity.getBusinessKey(), id++);
+ modelDiscUrlList.add(new org.apache.juddi.model.DiscoveryUrl(discUrlId, modelBusinessEntity, apiDiscUrl.getUseType(), apiDiscUrl.getValue()));
+ }
+ }
+ }
+
+ public static void mapContacts(org.uddi.api_v3.Contacts apiContacts,
+ Set<org.apache.juddi.model.Contact> modelContactList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelContactList.clear();
+
+ if (apiContacts != null) {
+ List<org.uddi.api_v3.Contact> apiContactList = apiContacts.getContact();
+ Iterator<org.uddi.api_v3.Contact> apiContactListItr = apiContactList.iterator();
+ int id = 0;
+ while (apiContactListItr.hasNext()) {
+ org.uddi.api_v3.Contact apiContact = apiContactListItr.next();
+
+ // The model only supports one personName per contact and it is just a string value (no language code).
+ List<org.uddi.api_v3.PersonName> apiNameList = apiContact.getPersonName();
+ String personName = null;
+ if (apiNameList != null && apiNameList.size() > 0)
+ personName = ((org.uddi.api_v3.PersonName)apiNameList.get(0)).getValue();
+
+ org.apache.juddi.model.ContactId contactId = new org.apache.juddi.model.ContactId(modelBusinessEntity.getBusinessKey(), id++);
+ org.apache.juddi.model.Contact modelContact = new org.apache.juddi.model.Contact(contactId, modelBusinessEntity, personName);
+ modelContact.setUseType(apiContact.getUseType());
+
+ mapContactDescriptions(apiContact.getDescription(), modelContact.getContactDescrs(), modelContact, modelBusinessEntity.getBusinessKey());
+ mapContactEmails(apiContact.getEmail(), modelContact.getEmails(), modelContact, modelBusinessEntity.getBusinessKey());
+ mapContactPhones(apiContact.getPhone(), modelContact.getPhones(), modelContact, modelBusinessEntity.getBusinessKey());
+ mapContactAddresses(apiContact.getAddress(), modelContact.getAddresses(), modelContact, modelBusinessEntity.getBusinessKey());
+
+ modelContactList.add(modelContact);
+ }
+ }
+ }
+
+ public static void mapContactDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.ContactDescr> modelDescList,
+ org.apache.juddi.model.Contact modelContact,
+ String businessKey)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.ContactDescrId contactDescId = new org.apache.juddi.model.ContactDescrId(businessKey, modelContact.getId().getContactId(), id++);
+ modelDescList.add(new org.apache.juddi.model.ContactDescr(contactDescId, modelContact, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapContactEmails(List<org.uddi.api_v3.Email> apiEmailList,
+ Set<org.apache.juddi.model.Email> modelEmailList,
+ org.apache.juddi.model.Contact modelContact,
+ String businessKey)
+ throws DispositionReportFaultMessage {
+ modelEmailList.clear();
+
+ Iterator<org.uddi.api_v3.Email> apiEmailListItr = apiEmailList.iterator();
+ int id = 0;
+ while (apiEmailListItr.hasNext()) {
+ org.uddi.api_v3.Email apiEmail = apiEmailListItr.next();
+
+ org.apache.juddi.model.EmailId emailId = new org.apache.juddi.model.EmailId(businessKey, modelContact.getId().getContactId(), id++);
+ modelEmailList.add(new org.apache.juddi.model.Email(emailId, modelContact, apiEmail.getUseType(), apiEmail.getValue()));
+ }
+ }
+
+ public static void mapContactPhones(List<org.uddi.api_v3.Phone> apiPhoneList,
+ Set<org.apache.juddi.model.Phone> modelPhoneList,
+ org.apache.juddi.model.Contact modelContact,
+ String businessKey)
+ throws DispositionReportFaultMessage {
+ modelPhoneList.clear();
+
+ Iterator<org.uddi.api_v3.Phone> apiPhoneListItr = apiPhoneList.iterator();
+ int id = 0;
+ while (apiPhoneListItr.hasNext()) {
+ org.uddi.api_v3.Phone apiPhone = apiPhoneListItr.next();
+
+ org.apache.juddi.model.PhoneId phoneId = new org.apache.juddi.model.PhoneId(businessKey, modelContact.getId().getContactId(), id++);
+ modelPhoneList.add(new org.apache.juddi.model.Phone(phoneId, modelContact, apiPhone.getUseType(), apiPhone.getValue()));
+ }
+ }
+
+ public static void mapContactAddresses(List<org.uddi.api_v3.Address> apiAddressList,
+ Set<org.apache.juddi.model.Address> modelAddressList,
+ org.apache.juddi.model.Contact modelContact,
+ String businessKey)
+ throws DispositionReportFaultMessage {
+ modelAddressList.clear();
+
+ Iterator<org.uddi.api_v3.Address> apiAddressListItr = apiAddressList.iterator();
+ int id = 0;
+ while (apiAddressListItr.hasNext()) {
+ org.uddi.api_v3.Address apiAddress = apiAddressListItr.next();
+
+ org.apache.juddi.model.AddressId addressId = new org.apache.juddi.model.AddressId(businessKey, modelContact.getId().getContactId(), id++);
+ org.apache.juddi.model.Address modelAddress = new org.apache.juddi.model.Address(addressId, modelContact);
+ modelAddress.setSortCode(apiAddress.getSortCode());
+ modelAddress.setTmodelKey(apiAddress.getTModelKey());
+ modelAddress.setUseType(apiAddress.getUseType());
+
+ mapAddressLines(apiAddress.getAddressLine(), modelAddress.getAddressLines(), modelAddress, businessKey, modelContact.getId().getContactId());
+
+ modelAddressList.add(modelAddress);
+ }
+ }
+
+ public static void mapAddressLines(List<org.uddi.api_v3.AddressLine> apiAddressLineList,
+ Set<org.apache.juddi.model.AddressLine> modelAddressLineList,
+ org.apache.juddi.model.Address modelAddress,
+ String businessKey,
+ int contactId)
+ throws DispositionReportFaultMessage {
+ modelAddressLineList.clear();
+
+ Iterator<org.uddi.api_v3.AddressLine> apiAddressLineListItr = apiAddressLineList.iterator();
+ int id = 0;
+ while (apiAddressLineListItr.hasNext()) {
+ org.uddi.api_v3.AddressLine apiAddressLine = apiAddressLineListItr.next();
+
+ org.apache.juddi.model.AddressLineId addressLineId = new org.apache.juddi.model.AddressLineId(businessKey, contactId, modelAddress.getId().getAddressId(), id++);
+ modelAddressLineList.add(new org.apache.juddi.model.AddressLine(addressLineId, modelAddress, apiAddressLine.getValue(), apiAddressLine.getKeyName(), apiAddressLine.getKeyValue()));
+ }
+ }
+
+
+ public static void mapBusinessIdentifiers(org.uddi.api_v3.IdentifierBag apiIdentifierBag,
+ Set<org.apache.juddi.model.BusinessIdentifier> modelIdentifierList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelIdentifierList.clear();
+
+ if (apiIdentifierBag != null) {
+ List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
+ Iterator<org.uddi.api_v3.KeyedReference> apiKeyedRefListItr = apiKeyedRefList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = apiKeyedRefListItr.next();
+
+ org.apache.juddi.model.BusinessIdentifierId identifierId = new org.apache.juddi.model.BusinessIdentifierId(modelBusinessEntity.getBusinessKey(), id++);
+ modelIdentifierList.add(new org.apache.juddi.model.BusinessIdentifier(identifierId, modelBusinessEntity, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+
+ public static void mapBusinessCategories(org.uddi.api_v3.CategoryBag apiCategoryBag,
+ Set<org.apache.juddi.model.BusinessCategory> modelCategoryList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelCategoryList.clear();
+
+ if (apiCategoryBag != null) {
+ List<JAXBElement<?>> apiCategoryList = apiCategoryBag.getContent();
+ Iterator<JAXBElement<?>> apiKeyedRefListItr = apiCategoryList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ JAXBElement<?> elem = apiKeyedRefListItr.next();
+
+ // TODO: Currently, the model doesn't allow for the persistence of keyedReference groups. This must be incorporated into the model. For now
+ // the KeyedReferenceGroups are ignored.
+ if (elem.getValue() instanceof org.uddi.api_v3.KeyedReference) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = (org.uddi.api_v3.KeyedReference)elem.getValue();
+
+ org.apache.juddi.model.BusinessCategoryId categoryId = new org.apache.juddi.model.BusinessCategoryId(modelBusinessEntity.getBusinessKey(), id++);
+ modelCategoryList.add(new org.apache.juddi.model.BusinessCategory(categoryId, modelBusinessEntity, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+ }
+
+ public static void mapBusinessServices(org.uddi.api_v3.BusinessServices apiBusinessServices,
+ Set<org.apache.juddi.model.BusinessService> modelBusinessServiceList,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+ modelBusinessServiceList.clear();
+
+ if (apiBusinessServices != null) {
+ List<org.uddi.api_v3.BusinessService> apiBusinessServiceList = apiBusinessServices.getBusinessService();
+ Iterator<org.uddi.api_v3.BusinessService> apiBusinessServiceListItr = apiBusinessServiceList.iterator();
+ while (apiBusinessServiceListItr.hasNext()) {
+ org.uddi.api_v3.BusinessService apiBusinessService = apiBusinessServiceListItr.next();
+ org.apache.juddi.model.BusinessService modelBusinessService = new org.apache.juddi.model.BusinessService();
+
+ mapBusinessService(apiBusinessService, modelBusinessService, modelBusinessEntity);
+
+ modelBusinessServiceList.add(modelBusinessService);
+ }
+ }
+ }
+
+ public static void mapBusinessService(org.uddi.api_v3.BusinessService apiBusinessService,
+ org.apache.juddi.model.BusinessService modelBusinessService,
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity)
+ throws DispositionReportFaultMessage {
+
+ modelBusinessService.setBusinessEntity(modelBusinessEntity);
+ modelBusinessService.setServiceKey(apiBusinessService.getServiceKey());
+ modelBusinessService.setLastUpdate(new Date());
+
+ mapServiceNames(apiBusinessService.getName(), modelBusinessService.getServiceNames(), modelBusinessService);
+ mapServiceDescriptions(apiBusinessService.getDescription(), modelBusinessService.getServiceDescrs(), modelBusinessService);
+
+ mapServiceCategories(apiBusinessService.getCategoryBag(), modelBusinessService.getServiceCategories(), modelBusinessService);
+
+ }
+
+ public static void mapServiceNames(List<org.uddi.api_v3.Name> apiNameList,
+ Set<org.apache.juddi.model.ServiceName> modelNameList,
+ org.apache.juddi.model.BusinessService modelBusinessService)
+ throws DispositionReportFaultMessage {
+ modelNameList.clear();
+
+ Iterator<org.uddi.api_v3.Name> apiNameListItr = apiNameList.iterator();
+ int id = 0;
+ while (apiNameListItr.hasNext()) {
+ org.uddi.api_v3.Name apiName = apiNameListItr.next();
+
+ org.apache.juddi.model.ServiceNameId serviceNameId = new org.apache.juddi.model.ServiceNameId(modelBusinessService.getServiceKey(), id++);
+ modelNameList.add(new org.apache.juddi.model.ServiceName(serviceNameId, modelBusinessService, apiName.getLang(), apiName.getValue()));
+ }
+ }
+
+ public static void mapServiceDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.ServiceDescr> modelDescList,
+ org.apache.juddi.model.BusinessService modelBusinessService)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.ServiceDescrId serviceDescId = new org.apache.juddi.model.ServiceDescrId(modelBusinessService.getServiceKey(), id++);
+ modelDescList.add(new org.apache.juddi.model.ServiceDescr(serviceDescId, modelBusinessService, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapServiceCategories(org.uddi.api_v3.CategoryBag apiCategoryBag,
+ Set<org.apache.juddi.model.ServiceCategory> modelCategoryList,
+ org.apache.juddi.model.BusinessService modelBusinessService)
+ throws DispositionReportFaultMessage {
+ modelCategoryList.clear();
+
+ if (apiCategoryBag != null) {
+ List<JAXBElement<?>> apiCategoryList = apiCategoryBag.getContent();
+ Iterator<JAXBElement<?>> apiKeyedRefListItr = apiCategoryList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ JAXBElement<?> elem = apiKeyedRefListItr.next();
+
+ // TODO: Currently, the model doesn't allow for the persistence of keyedReference groups. This must be incorporated into the model. For now
+ // the KeyedReferenceGroups are ignored.
+ if (elem.getValue() instanceof org.uddi.api_v3.KeyedReference) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = (org.uddi.api_v3.KeyedReference)elem.getValue();
+
+ org.apache.juddi.model.ServiceCategoryId categoryId = new org.apache.juddi.model.ServiceCategoryId(modelBusinessService.getServiceKey(), id++);
+ modelCategoryList.add(new org.apache.juddi.model.ServiceCategory(categoryId, modelBusinessService, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+ }
+
+ public static void mapBindingTemplate(org.uddi.api_v3.BindingTemplate apiBindingTemplate,
+ org.apache.juddi.model.BindingTemplate modelBindingTemplate,
+ org.apache.juddi.model.BusinessService modelBusinessService)
+ throws DispositionReportFaultMessage {
+
+ modelBindingTemplate.setBusinessService(modelBusinessService);
+ modelBindingTemplate.setBindingKey(apiBindingTemplate.getBindingKey());
+ modelBindingTemplate.setLastUpdate(new Date());
+ modelBindingTemplate.setAccessPointType(apiBindingTemplate.getAccessPoint().getUseType());
+ modelBindingTemplate.setAccessPointUrl(apiBindingTemplate.getAccessPoint().getValue());
+ modelBindingTemplate.setHostingRedirector(apiBindingTemplate.getHostingRedirector().getBindingKey());
+
+ mapBindingDescriptions(apiBindingTemplate.getDescription(), modelBindingTemplate.getBindingDescrs(), modelBindingTemplate);
+ mapBindingCategories(apiBindingTemplate.getCategoryBag(), modelBindingTemplate.getBindingCategories(), modelBindingTemplate);
+ mapTModelInstanceDetails(apiBindingTemplate.getTModelInstanceDetails(), modelBindingTemplate.getTmodelInstanceInfos(), modelBindingTemplate);
+ }
+
+ public static void mapBindingDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.BindingDescr> modelDescList,
+ org.apache.juddi.model.BindingTemplate modelBindingTemplate)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.BindingDescrId bindingDescId = new org.apache.juddi.model.BindingDescrId(modelBindingTemplate.getBindingKey(), id++);
+ modelDescList.add(new org.apache.juddi.model.BindingDescr(bindingDescId, modelBindingTemplate, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapBindingCategories(org.uddi.api_v3.CategoryBag apiCategoryBag,
+ Set<org.apache.juddi.model.BindingCategory> modelCategoryList,
+ org.apache.juddi.model.BindingTemplate modelBindingTemplate)
+ throws DispositionReportFaultMessage {
+ modelCategoryList.clear();
+
+ if (apiCategoryBag != null) {
+ List<JAXBElement<?>> apiCategoryList = apiCategoryBag.getContent();
+ Iterator<JAXBElement<?>> apiKeyedRefListItr = apiCategoryList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ JAXBElement<?> elem = apiKeyedRefListItr.next();
+
+ // TODO: Currently, the model doesn't allow for the persistence of keyedReference groups. This must be incorporated into the model. For now
+ // the KeyedReferenceGroups are ignored.
+ if (elem.getValue() instanceof org.uddi.api_v3.KeyedReference) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = (org.uddi.api_v3.KeyedReference)elem.getValue();
+
+ org.apache.juddi.model.BindingCategoryId categoryId = new org.apache.juddi.model.BindingCategoryId(modelBindingTemplate.getBindingKey(), id++);
+ modelCategoryList.add(new org.apache.juddi.model.BindingCategory(categoryId, modelBindingTemplate, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+ }
+
+ public static void mapTModelInstanceDetails(org.uddi.api_v3.TModelInstanceDetails apiTModelInstDetails,
+ Set<org.apache.juddi.model.TmodelInstanceInfo> modelTModelInstInfoList,
+ org.apache.juddi.model.BindingTemplate modelBindingTemplate)
+ throws DispositionReportFaultMessage {
+ modelTModelInstInfoList.clear();
+
+ if (apiTModelInstDetails != null) {
+ List<org.uddi.api_v3.TModelInstanceInfo> apiTModelInstInfoList = apiTModelInstDetails.getTModelInstanceInfo();
+ Iterator<org.uddi.api_v3.TModelInstanceInfo> apiTModelInstInfoListItr = apiTModelInstInfoList.iterator();
+ int id = 0;
+ while (apiTModelInstInfoListItr.hasNext()) {
+ org.uddi.api_v3.TModelInstanceInfo apiTModelInstInfo = apiTModelInstInfoListItr.next();
+
+ org.apache.juddi.model.TmodelInstanceInfoId tmodelInstInfoId = new org.apache.juddi.model.TmodelInstanceInfoId(modelBindingTemplate.getBindingKey(), id++);
+ org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo = new org.apache.juddi.model.TmodelInstanceInfo(tmodelInstInfoId, modelBindingTemplate, apiTModelInstInfo.getTModelKey());
+
+ mapTModelInstanceInfoDescriptions(apiTModelInstInfo.getDescription(), modelTModelInstInfo.getTmodelInstanceInfoDescrs(), modelTModelInstInfo, modelBindingTemplate.getBindingKey());
+ mapInstanceDetails(apiTModelInstInfo.getInstanceDetails(), modelTModelInstInfo, modelBindingTemplate.getBindingKey());
+
+ modelTModelInstInfoList.add(modelTModelInstInfo);
+ }
+ }
+ }
+
+ public static void mapTModelInstanceInfoDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.TmodelInstanceInfoDescr> modelDescList,
+ org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo,
+ String bindingKey)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.TmodelInstanceInfoDescrId tmodelInstInfoDescId = new org.apache.juddi.model.TmodelInstanceInfoDescrId(bindingKey, modelTModelInstInfo.getId().getTmodelInstanceInfoId(), id++);
+ modelDescList.add(new org.apache.juddi.model.TmodelInstanceInfoDescr(tmodelInstInfoDescId, modelTModelInstInfo, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapInstanceDetails(org.uddi.api_v3.InstanceDetails apiInstanceDetails,
+ org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo,
+ String bindingKey)
+ throws DispositionReportFaultMessage {
+ modelTModelInstInfo.getInstanceDetailsDescrs().clear();
+
+ if (apiInstanceDetails != null) {
+ List<JAXBElement<?>> apiInstanceDetailsContent = apiInstanceDetails.getContent();
+ Iterator<JAXBElement<?>> aapiInstanceDetailsContentItr = apiInstanceDetailsContent.iterator();
+ int docId = 0;
+ int descId = 0;
+ while (aapiInstanceDetailsContentItr.hasNext()) {
+ JAXBElement<?> elem = aapiInstanceDetailsContentItr.next();
+
+ if (elem.getValue() instanceof org.uddi.api_v3.OverviewDoc) {
+ org.uddi.api_v3.OverviewDoc apiOverviewDoc = (org.uddi.api_v3.OverviewDoc)elem.getValue();
+ // TODO: OverviewDoc is not mapped properly in the model.
+ }
+ else if (elem.getValue() instanceof org.uddi.api_v3.Description) {
+ org.uddi.api_v3.Description apiDesc = (org.uddi.api_v3.Description)elem.getValue();
+
+ org.apache.juddi.model.InstanceDetailsDescrId instanceDetailsDescId = new org.apache.juddi.model.InstanceDetailsDescrId(bindingKey, modelTModelInstInfo.getId().getTmodelInstanceInfoId(), descId++);
+ modelTModelInstInfo.getInstanceDetailsDescrs().add(new org.apache.juddi.model.InstanceDetailsDescr(instanceDetailsDescId, modelTModelInstInfo, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ else if (elem.getValue() instanceof String) {
+ modelTModelInstInfo.setInstanceParms((String)elem.getValue());
+ }
+ }
+ }
+ }
+
+ public static void mapTModel(org.uddi.api_v3.TModel apiTModel,
+ org.apache.juddi.model.Tmodel modelTModel)
+ throws DispositionReportFaultMessage {
+
+ modelTModel.setTmodelKey(apiTModel.getTModelKey());
+ modelTModel.setLastUpdate(new Date());
+ modelTModel.setName(apiTModel.getName().getValue());
+ modelTModel.setDeleted(apiTModel.isDeleted());
+ // TODO: Theses fields no longer exist in UDDIv3. Are they here for backwards compatibility or can we get rid of them?
+ modelTModel.setAuthorizedName("authorizedName");
+ modelTModel.setOperator("operator");
+
+ mapTModelDescriptions(apiTModel.getDescription(), modelTModel.getTmodelDescrs(), modelTModel);
+ mapTModelIdentifiers(apiTModel.getIdentifierBag(), modelTModel.getTmodelIdentifiers(), modelTModel);
+ mapTModelCategories(apiTModel.getCategoryBag(), modelTModel.getTmodelCategories(), modelTModel);
+ //TODO: OverviewDoc - requires handling the JAXBElement catch-all issue, also, model doesn't have logical mapping
+
+ }
+
+ public static void mapTModelDescriptions(List<org.uddi.api_v3.Description> apiDescList,
+ Set<org.apache.juddi.model.TmodelDescr> modelDescList,
+ org.apache.juddi.model.Tmodel modelTModel)
+ throws DispositionReportFaultMessage {
+ modelDescList.clear();
+
+ Iterator<org.uddi.api_v3.Description> apiDescListItr = apiDescList.iterator();
+ int id = 0;
+ while (apiDescListItr.hasNext()) {
+ org.uddi.api_v3.Description apiDesc = apiDescListItr.next();
+
+ org.apache.juddi.model.TmodelDescrId tmodelDescId = new org.apache.juddi.model.TmodelDescrId(modelTModel.getTmodelKey(), id++);
+ modelDescList.add(new org.apache.juddi.model.TmodelDescr(tmodelDescId, modelTModel, apiDesc.getLang(), apiDesc.getValue()));
+ }
+ }
+
+ public static void mapTModelIdentifiers(org.uddi.api_v3.IdentifierBag apiIdentifierBag,
+ Set<org.apache.juddi.model.TmodelIdentifier> modelIdentifierList,
+ org.apache.juddi.model.Tmodel modelTModel)
+ throws DispositionReportFaultMessage {
+ modelIdentifierList.clear();
+
+ if (apiIdentifierBag != null) {
+ List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
+ Iterator<org.uddi.api_v3.KeyedReference> apiKeyedRefListItr = apiKeyedRefList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = apiKeyedRefListItr.next();
+
+ org.apache.juddi.model.TmodelIdentifierId identifierId = new org.apache.juddi.model.TmodelIdentifierId(modelTModel.getTmodelKey(), id++);
+ modelIdentifierList.add(new org.apache.juddi.model.TmodelIdentifier(identifierId, modelTModel, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+
+ public static void mapTModelCategories(org.uddi.api_v3.CategoryBag apiCategoryBag,
+ Set<org.apache.juddi.model.TmodelCategory> modelCategoryList,
+ org.apache.juddi.model.Tmodel modelTModel)
+ throws DispositionReportFaultMessage {
+ modelCategoryList.clear();
+
+ if (apiCategoryBag != null) {
+ List<JAXBElement<?>> apiCategoryList = apiCategoryBag.getContent();
+ Iterator<JAXBElement<?>> apiKeyedRefListItr = apiCategoryList.iterator();
+ int id = 0;
+ while (apiKeyedRefListItr.hasNext()) {
+ JAXBElement<?> elem = apiKeyedRefListItr.next();
+
+ // TODO: Currently, the model doesn't allow for the persistence of keyedReference groups. This must be incorporated into the model. For now
+ // the KeyedReferenceGroups are ignored.
+ if (elem.getValue() instanceof org.uddi.api_v3.KeyedReference) {
+ org.uddi.api_v3.KeyedReference apiKeyedRef = (org.uddi.api_v3.KeyedReference)elem.getValue();
+
+ org.apache.juddi.model.TmodelCategoryId categoryId = new org.apache.juddi.model.TmodelCategoryId(modelTModel.getTmodelKey(), id++);
+ modelCategoryList.add(new org.apache.juddi.model.TmodelCategory(categoryId, modelTModel, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
+ }
+ }
+ }
+ }
+
+ public static void mapPublisherAssertion(org.uddi.api_v3.PublisherAssertion apiPubAssertion,
+ org.apache.juddi.model.PublisherAssertion modelPubAssertion)
+ throws DispositionReportFaultMessage {
+
+ modelPubAssertion.setId(new org.apache.juddi.model.PublisherAssertionId(apiPubAssertion.getFromKey(), apiPubAssertion.getToKey()));
+
+ org.apache.juddi.model.BusinessEntity beFrom = new org.apache.juddi.model.BusinessEntity();
+ beFrom.setBusinessKey(apiPubAssertion.getFromKey());
+ modelPubAssertion.setBusinessEntityByFromKey(beFrom);
+
+ org.apache.juddi.model.BusinessEntity beTo = new org.apache.juddi.model.BusinessEntity();
+ beFrom.setBusinessKey(apiPubAssertion.getToKey());
+ modelPubAssertion.setBusinessEntityByToKey(beTo);
+
+ org.uddi.api_v3.KeyedReference apiKeyedRef = apiPubAssertion.getKeyedReference();
+ if (apiKeyedRef != null) {
+ modelPubAssertion.setTmodelKey(apiKeyedRef.getTModelKey());
+ modelPubAssertion.setKeyName(apiKeyedRef.getKeyName());
+ modelPubAssertion.setKeyValue(apiKeyedRef.getKeyName());
+ }
+ }
+
+
+}
+
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java Thu Sep 18 13:11:02 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.util;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+import javax.persistence.EntityManager;
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class JPAUtil {
+ public static final String PERSISTENCE_UNIT_NAME = "juddiDatabase";
+
+ private static final EntityManagerFactory emf;
+
+ static {
+ try {
+ emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+ }
+ catch (Throwable t) {
+ System.err.println("Initial entityManagerFactory creation failed:" + t);
+ throw new ExceptionInInitializerError(t);
+ }
+ }
+
+ public static EntityManager getEntityManager() {
+ return emf.createEntityManager();
+ }
+
+ public static void persistEntity(Object uddiEntity, Object entityKey) {
+ EntityManager em = getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+
+ Object existingUddiEntity = em.find(uddiEntity.getClass(), entityKey);
+ if (existingUddiEntity != null)
+ em.remove(existingUddiEntity);
+
+ em.persist(uddiEntity);
+
+ tx.commit();
+ em.close();
+ }
+
+ public static Object getEntity(Class<?> entityClass, Object entityKey) {
+ EntityManager em = getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+
+ Object obj = em.find(entityClass, entityKey);
+
+ tx.commit();
+ em.close();
+
+ return obj;
+ }
+
+ public static void deleteEntity(Class<?> entityClass, Object entityKey) {
+ EntityManager em = getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+
+ Object obj = em.find(entityClass, entityKey);
+ em.remove(obj);
+
+ tx.commit();
+ em.close();
+ }
+
+}
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/util/JPAUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml Thu Sep 18 13:11:02 2008
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="juddiDatabase" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
+ <!-- When not using Hibernate autodetection, persistent classes must be listed here
+ <class>org.apache.juddi.model.AuthToken</class>
+ -->
+
+ <properties>
+ <property name="hibernate.archive.autodetection" value="class"/>
+ <property name="hibernate.hbm2ddl.auto" value="update"/>
+ <property name="hibernate.show_sql" value="true"/>
+
+ <!-- connection properties -->
+ <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
+ <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/juddi?autoReconnect=true"/>
+ <property name="hibernate.connection.username" value="juddi"/>
+ <property name="hibernate.connection.password" value="juddi"/>
+
+ <!-- connection pool properties -->
+ <property name="hibernate.dbcp.maxActive" value="100"/>
+ <property name="hibernate.dbcp.maxIdle" value="30"/>
+ <property name="hibernate.dbcp.maxWait" value="10000"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties?rev=696786&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties (added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties Thu Sep 18 13:11:02 2008
@@ -0,0 +1,58 @@
+#/*
+# * 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.
+# *
+# */
+
+# Global messages file for English locale.
+
+#-- UDDI-specific messages
+E_accountLimitExceeded=
+E_assertionNotFound=
+E_authTokenExpired=
+E_authTokenRequired=
+E_busy=
+E_categorizationNotAllowed=
+E_fatalError=
+E_invalidCategory=
+E_invalidCompletionStatus=
+E_invalidKeyPassed=An invalid key has been passed
+E_invalidProjection=
+E_invalidTime=
+E_invalidURLPassed=
+E_invalidValue=
+E_keyRetired=
+E_languageError=
+E_messageTooLarge=
+E_nameTooLong=
+E_operatorMismatch=
+E_publisherCancelled=
+E_requestDenied=
+E_requestTimeout=
+E_resultSetTooLarge=
+E_secretUnknown=
+E_success=
+E_tooManyOptions=
+E_transferAborted=
+E_unknownUser=
+E_unrecognizedVersion=
+E_unsupported=
+E_unvalidatable=
+E_userMismatch=
+E_valueNotAllowed=
+
+#-- General error messages
+errors.Unspecified=An unspecified error occured
+errors.invalidkey.BusinessNotFound=The business entity was not found for the given key
+errors.invalidkey.ServiceNotFound=The business service was not found for the given key
Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: webservices/juddi/branches/v3_trunk/pom.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/pom.xml?rev=696786&r1=696785&r2=696786&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/pom.xml (original)
+++ webservices/juddi/branches/v3_trunk/pom.xml Thu Sep 18 13:11:02 2008
@@ -133,16 +133,41 @@
<artifactId>jaxb-impl</artifactId>
<version>2.1.7</version>
</dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.1</version>
+ <version>4.5</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>3.2.5.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>3.3.1.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ <version>2.1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: webservices/juddi/branches/v3_trunk/uddi-ws/src/main/java/org/apache/juddi/ws/impl/UDDIPublicationImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/uddi-ws/src/main/java/org/apache/juddi/ws/impl/UDDIPublicationImpl.java?rev=696786&r1=696785&r2=696786&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/uddi-ws/src/main/java/org/apache/juddi/ws/impl/UDDIPublicationImpl.java (original)
+++ webservices/juddi/branches/v3_trunk/uddi-ws/src/main/java/org/apache/juddi/ws/impl/UDDIPublicationImpl.java Thu Sep 18 13:11:02 2008
@@ -18,6 +18,7 @@
package org.apache.juddi.ws.impl;
import java.util.List;
+import java.util.Iterator;
import javax.jws.WebService;
import javax.xml.ws.Holder;
@@ -44,6 +45,14 @@
import org.uddi.v3_service.DispositionReportFaultMessage;
import org.uddi.v3_service.UDDIPublicationPortType;
+import org.apache.juddi.mapping.MappingApiToModel;
+import org.apache.juddi.util.JPAUtil;
+import org.apache.juddi.error.UDDIErrorHelper;
+import org.apache.juddi.config.Configuration;
+
+/**
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
@WebService(serviceName="UDDIPublicationService",
endpointInterface="org.uddi.v3_service.UDDIPublicationPortType")
public class UDDIPublicationImpl implements UDDIPublicationPortType {
@@ -51,42 +60,100 @@
public void addPublisherAssertions(AddPublisherAssertions body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
-
+
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.PublisherAssertion> apiPubAssertionList = body.getPublisherAssertion();
+ Iterator<org.uddi.api_v3.PublisherAssertion> apiPubAssertionListItr = apiPubAssertionList.iterator();
+ while (apiPubAssertionListItr.hasNext()) {
+ org.uddi.api_v3.PublisherAssertion apiPubAssertion = apiPubAssertionListItr.next();
+
+ //TODO: Validate the input here
+
+ org.apache.juddi.model.PublisherAssertion modelPubAssertion = new org.apache.juddi.model.PublisherAssertion();
+
+ MappingApiToModel.mapPublisherAssertion(apiPubAssertion, modelPubAssertion);
+
+ JPAUtil.persistEntity(modelPubAssertion, modelPubAssertion.getId());
+ }
}
public void deleteBinding(DeleteBinding body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<String> entityKeyList = body.getBindingKey();
+ Iterator<String> entityKeyListListItr = entityKeyList.iterator();
+ while (entityKeyListListItr.hasNext()) {
+ String entityKey = entityKeyListListItr.next();
+
+ JPAUtil.deleteEntity(org.apache.juddi.model.BindingTemplate.class, entityKey);
+ }
}
-
public void deleteBusiness(DeleteBusiness body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<String> entityKeyList = body.getBusinessKey();
+ Iterator<String> entityKeyListListItr = entityKeyList.iterator();
+ while (entityKeyListListItr.hasNext()) {
+ String entityKey = entityKeyListListItr.next();
+
+ JPAUtil.deleteEntity(org.apache.juddi.model.BusinessEntity.class, entityKey);
+ }
}
-
public void deletePublisherAssertions(DeletePublisherAssertions body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
- }
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.PublisherAssertion> apiPubAssertionList = body.getPublisherAssertion();
+ Iterator<org.uddi.api_v3.PublisherAssertion> apiPubAssertionListItr = apiPubAssertionList.iterator();
+ while (apiPubAssertionListItr.hasNext()) {
+ org.uddi.api_v3.PublisherAssertion apiPubAssertion = apiPubAssertionListItr.next();
+ org.apache.juddi.model.PublisherAssertionId pubAssertionId = new org.apache.juddi.model.PublisherAssertionId(apiPubAssertion.getFromKey(), apiPubAssertion.getToKey());
+ JPAUtil.deleteEntity(org.apache.juddi.model.PublisherAssertion.class, pubAssertionId);
+ }
+ }
public void deleteService(DeleteService body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<String> entityKeyList = body.getServiceKey();
+ Iterator<String> entityKeyListListItr = entityKeyList.iterator();
+ while (entityKeyListListItr.hasNext()) {
+ String entityKey = entityKeyListListItr.next();
+
+ JPAUtil.deleteEntity(org.apache.juddi.model.BusinessService.class, entityKey);
+ }
}
public void deleteTModel(DeleteTModel body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<String> entityKeyList = body.getTModelKey();
+ Iterator<String> entityKeyListListItr = entityKeyList.iterator();
+ while (entityKeyListListItr.hasNext()) {
+ String entityKey = entityKeyListListItr.next();
+
+ JPAUtil.deleteEntity(org.apache.juddi.model.Tmodel.class, entityKey);
+ }
}
@@ -114,29 +181,129 @@
public BindingDetail saveBinding(SaveBinding body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
- return null;
+
+ org.uddi.api_v3.BindingDetail result = new org.uddi.api_v3.BindingDetail();
+
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.BindingTemplate> apiBindingTemplateList = body.getBindingTemplate();
+ Iterator<org.uddi.api_v3.BindingTemplate> apiBindingTemplateListItr = apiBindingTemplateList.iterator();
+ while (apiBindingTemplateListItr.hasNext()) {
+ org.uddi.api_v3.BindingTemplate apiBindingTemplate = apiBindingTemplateListItr.next();
+
+ //TODO: Validate the input here
+ if (JPAUtil.getEntity(org.apache.juddi.model.BusinessService.class, apiBindingTemplate.getServiceKey()) == null) {
+ throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.ServiceNotFound") + ": " + apiBindingTemplate.getServiceKey(),
+ UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
+ }
+ //TODO: Test if key is null, and if so, apply key-generation strategy
+ String bindingKey = apiBindingTemplate.getBindingKey();
+
+ org.apache.juddi.model.BindingTemplate modelBindingTemplate = new org.apache.juddi.model.BindingTemplate();
+ org.apache.juddi.model.BusinessService modelBusinessService = new org.apache.juddi.model.BusinessService();
+ modelBusinessService.setServiceKey(apiBindingTemplate.getServiceKey());
+
+ MappingApiToModel.mapBindingTemplate(apiBindingTemplate, modelBindingTemplate, modelBusinessService);
+
+ JPAUtil.persistEntity(modelBindingTemplate, modelBindingTemplate.getBindingKey());
+
+ result.getBindingTemplate().add(apiBindingTemplate);
+ }
+ return result;
}
public BusinessDetail saveBusiness(SaveBusiness body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
- return null;
+
+ org.uddi.api_v3.BusinessDetail result = new org.uddi.api_v3.BusinessDetail();
+
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.BusinessEntity> apiBusinessEntityList = body.getBusinessEntity();
+ Iterator<org.uddi.api_v3.BusinessEntity> apiBusinessEntityListItr = apiBusinessEntityList.iterator();
+ while (apiBusinessEntityListItr.hasNext()) {
+ org.uddi.api_v3.BusinessEntity apiBusinessEntity = apiBusinessEntityListItr.next();
+
+ //TODO: Validate the input here
+ //TODO: Test if key is null, and if so, apply key-generation strategy
+ String businessKey = apiBusinessEntity.getBusinessKey();
+
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity = new org.apache.juddi.model.BusinessEntity();
+
+ MappingApiToModel.mapBusinessEntity(apiBusinessEntity, modelBusinessEntity);
+
+ JPAUtil.persistEntity(modelBusinessEntity, modelBusinessEntity.getBusinessKey());
+
+ result.getBusinessEntity().add(apiBusinessEntity);
+ }
+ return result;
}
public ServiceDetail saveService(SaveService body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
- return null;
+
+ org.uddi.api_v3.ServiceDetail result = new org.uddi.api_v3.ServiceDetail();
+
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.BusinessService> apiBusinessServiceList = body.getBusinessService();
+ Iterator<org.uddi.api_v3.BusinessService> apiBusinessServiceListItr = apiBusinessServiceList.iterator();
+ while (apiBusinessServiceListItr.hasNext()) {
+ org.uddi.api_v3.BusinessService apiBusinessService = apiBusinessServiceListItr.next();
+
+ //TODO: Validate the input here
+ if (JPAUtil.getEntity(org.apache.juddi.model.BusinessEntity.class, apiBusinessService.getBusinessKey()) == null) {
+ throw new DispositionReportFaultMessage(Configuration.getGlobalMessage("errors.invalidkey.BusinessNotFound") + ": " + apiBusinessService.getBusinessKey(),
+ UDDIErrorHelper.buildDispositionReport(UDDIErrorHelper.E_INVALID_KEY_PASSED));
+ }
+ //TODO: Test if key is null, and if so, apply key-generation strategy
+ String serviceKey = apiBusinessService.getServiceKey();
+
+ org.apache.juddi.model.BusinessService modelBusinessService = new org.apache.juddi.model.BusinessService();
+ org.apache.juddi.model.BusinessEntity modelBusinessEntity = new org.apache.juddi.model.BusinessEntity();
+ modelBusinessEntity.setBusinessKey(apiBusinessService.getBusinessKey());
+
+ MappingApiToModel.mapBusinessService(apiBusinessService, modelBusinessService, modelBusinessEntity);
+
+ JPAUtil.persistEntity(modelBusinessService, modelBusinessService.getServiceKey());
+
+ result.getBusinessService().add(apiBusinessService);
+ }
+ return result;
}
public TModelDetail saveTModel(SaveTModel body)
throws DispositionReportFaultMessage {
- // TODO Auto-generated method stub
- return null;
+
+ org.uddi.api_v3.TModelDetail result = new org.uddi.api_v3.TModelDetail();
+
+ // TODO: Perform necessary authentication logic
+ String authInfo = body.getAuthInfo();
+
+ List<org.uddi.api_v3.TModel> apiTModelList = body.getTModel();
+ Iterator<org.uddi.api_v3.TModel> apiTModelListItr = apiTModelList.iterator();
+ while (apiTModelListItr.hasNext()) {
+ org.uddi.api_v3.TModel apiTModel = apiTModelListItr.next();
+
+ //TODO: Validate the input here
+ //TODO: Test if key is null, and if so, apply key-generation strategy
+ String tmodelKey = apiTModel.getTModelKey();
+
+ org.apache.juddi.model.Tmodel modelTModel = new org.apache.juddi.model.Tmodel();
+
+ MappingApiToModel.mapTModel(apiTModel, modelTModel);
+
+ JPAUtil.persistEntity(modelTModel, modelTModel.getTmodelKey());
+
+ result.getTModel().add(apiTModel);
+ }
+ return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org