You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by sv...@apache.org on 2004/05/28 06:46:25 UTC
cvs commit: ws-juddi/src/java/org/apache/juddi/datatype/response RegistryInfo.java Property.java
sviens 2004/05/27 21:46:25
Modified: src/java/org/apache/juddi/function FunctionMaker.java
src/java/org/apache/juddi/registry IRegistry.java
AbstractRegistry.java
Added: src/java/org/apache/juddi/handler
GetRegistryInfoHandler.java
RegistryInfoHandler.java PropertyHandler.java
src/java/org/apache/juddi/function
GetRegisteryInfoFunction.java
src/java/org/apache/juddi/datatype/request
GetRegistryInfo.java
src/java/org/apache/juddi/datatype/response
RegistryInfo.java Property.java
Log:
Adding jUDDI-specific API: get_registryInfo function and supporting classes
Revision Changes Path
1.1 ws-juddi/src/java/org/apache/juddi/handler/GetRegistryInfoHandler.java
Index: GetRegistryInfoHandler.java
===================================================================
/*
* Copyright 2001-2004 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.handler;
import java.util.Vector;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.request.GetRegistryInfo;
import org.w3c.dom.Element;
/**
* @author Steve Viens (sviens@apache.org)
*/
public class GetRegistryInfoHandler extends AbstractHandler
{
public static final String TAG_NAME = "get_registryInfo";
private HandlerMaker maker = null;
protected GetRegistryInfoHandler(HandlerMaker maker)
{
this.maker = maker;
}
public RegistryObject unmarshal(Element element)
{
GetRegistryInfo obj = new GetRegistryInfo();
Vector nodeList = null;
AbstractHandler handler = null;
// Attributes
String generic = element.getAttribute("generic");
if ((generic != null && (generic.trim().length() > 0)))
obj.setGeneric(generic);
// Text Node Value
// {none}
// Child Elements
// {none}
return obj;
}
public void marshal(RegistryObject object,Element parent)
{
GetRegistryInfo request = (GetRegistryInfo)object;
Element element = parent.getOwnerDocument().createElement(TAG_NAME);
AbstractHandler handler = null;
String generic = request.getGeneric();
if (generic != null)
element.setAttribute("generic",generic);
parent.appendChild(element);
}
/***************************************************************************/
/***************************** TEST DRIVER *********************************/
/***************************************************************************/
public static void main(String args[])
throws Exception
{
}
}
1.1 ws-juddi/src/java/org/apache/juddi/handler/RegistryInfoHandler.java
Index: RegistryInfoHandler.java
===================================================================
/*
* Copyright 2001-2004 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.handler;
import java.util.Iterator;
import java.util.Properties;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.Vector;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.response.Property;
import org.apache.juddi.datatype.response.RegistryInfo;
import org.apache.juddi.util.xml.XMLUtils;
import org.w3c.dom.Element;
/**
* @author Steve Viens (sviens@apache.org)
*/
public class RegistryInfoHandler extends AbstractHandler
{
public static final String TAG_NAME = "registryInfo";
private HandlerMaker maker = null;
protected RegistryInfoHandler(HandlerMaker maker)
{
this.maker = maker;
}
public RegistryObject unmarshal(Element element)
{
RegistryInfo obj = new RegistryInfo();
Vector nodeList = null;
AbstractHandler handler = null;
// Attributes
// {none}
// Text Node Value
// {none}
// Child Elements
nodeList = XMLUtils.getChildElementsByTagName(element,PropertyHandler.TAG_NAME);
for (int i=0; i<nodeList.size(); i++)
{
handler = maker.lookup(PropertyHandler.TAG_NAME);
obj.addProperty((Property)handler.unmarshal((Element)nodeList.elementAt(i)));
}
return obj;
}
public void marshal(RegistryObject object,Element parent)
{
RegistryInfo info = (RegistryInfo)object;
Element element = parent.getOwnerDocument().createElement(TAG_NAME);
AbstractHandler handler = null;
Properties props = info.getProperties();
if ((props!=null) && (props.size() > 0))
{
handler = maker.lookup(PropertyHandler.TAG_NAME);
SortedSet sortedProps = new TreeSet(props.keySet());
for (Iterator keys = sortedProps.iterator(); keys.hasNext() ; )
{
String name = (String)keys.next();
String value = (String)props.getProperty(name);
handler.marshal(new Property(name,value),element);
}
}
parent.appendChild(element);
}
/***************************************************************************/
/***************************** TEST DRIVER *********************************/
/***************************************************************************/
public static void main(String args[])
throws Exception
{
HandlerMaker maker = HandlerMaker.getInstance();
AbstractHandler handler = maker.lookup(RegistryInfoHandler.TAG_NAME);
Element parent = XMLUtils.newRootElement();
Element child = null;
RegistryInfo regInfo = new RegistryInfo();
regInfo.addProperty(new Property("first_name","Steve"));
regInfo.addProperty(new Property("last_name","Viens"));
regInfo.addProperty(new Property("version","1.0b1"));
System.out.println();
RegistryObject regObject = regInfo;
handler.marshal(regObject,parent);
child = (Element)parent.getFirstChild();
parent.removeChild(child);
XMLUtils.writeXML(child,System.out);
System.out.println();
regObject = handler.unmarshal(child);
handler.marshal(regObject,parent);
child = (Element)parent.getFirstChild();
parent.removeChild(child);
XMLUtils.writeXML(child,System.out);
}
}
1.1 ws-juddi/src/java/org/apache/juddi/handler/PropertyHandler.java
Index: PropertyHandler.java
===================================================================
/*
* Copyright 2001-2004 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.handler;
import org.apache.juddi.datatype.AddressLine;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.response.Property;
import org.w3c.dom.Element;
/**
* Knows about the creation and populating of Property objects.
*
* @author Steve Viens (sviens@apache.org)
*/
public class PropertyHandler extends AbstractHandler
{
public static final String TAG_NAME = "property";
private HandlerMaker maker = null;
protected PropertyHandler(HandlerMaker maker)
{
this.maker = maker;
}
public RegistryObject unmarshal(Element element)
{
Property obj = new Property();
// Attributes
String name = element.getAttribute("name");
if ((name != null) && (name.trim().length() > 0))
obj.setName(name);
String value = element.getAttribute("value");
if ((value != null) && (value.trim().length() > 0))
obj.setValue(value);
// Text Node Value
// {none}
// Child Elements
// {none}
return obj;
}
public void marshal(RegistryObject object,Element parent)
{
Property property = (Property)object;
Element element = parent.getOwnerDocument().createElement(TAG_NAME);
String name = property.getName();
if ((name != null) && (name.trim().length() > 0))
element.setAttribute("name",name);
String value = property.getValue();
if ((value != null) && (value.trim().length() > 0))
element.setAttribute("value",value);
parent.appendChild(element);
}
/***************************************************************************/
/***************************** TEST DRIVER *********************************/
/***************************************************************************/
public static void main(String args[])
throws Exception
{
// create the source object
Property inprop = new Property("nameAttr","valueAttr");
// unmarshal & marshal (object->xml->object)
HandlerMaker maker = HandlerMaker.getInstance();
AbstractHandler handler = maker.lookup(PropertyHandler.TAG_NAME);
Element element = null;
handler.marshal(inprop,element);
AddressLine outprop = (AddressLine)handler.unmarshal(element);
// compare unmarshaled with marshaled obj
if (outprop.equals(inprop))
System.out.println("Input and output are the same.");
else
System.out.println("Input and output are NOT the same!");
}
}
1.5 +4 -0 ws-juddi/src/java/org/apache/juddi/function/FunctionMaker.java
Index: FunctionMaker.java
===================================================================
RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/function/FunctionMaker.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionMaker.java 1 May 2004 14:32:58 -0000 1.4
+++ FunctionMaker.java 28 May 2004 04:46:25 -0000 1.5
@@ -41,6 +41,7 @@
import org.apache.juddi.datatype.request.GetPublisherAssertions;
import org.apache.juddi.datatype.request.GetPublisherDetail;
import org.apache.juddi.datatype.request.GetRegisteredInfo;
+import org.apache.juddi.datatype.request.GetRegistryInfo;
import org.apache.juddi.datatype.request.GetServiceDetail;
import org.apache.juddi.datatype.request.GetTModelDetail;
import org.apache.juddi.datatype.request.SaveBinding;
@@ -142,6 +143,9 @@
function = new GetRegisteredInfoFunction(registry);
functions.put(GetRegisteredInfo.class.getName(),function);
+
+ function = new GetRegisteryInfoFunction(registry);
+ functions.put(GetRegistryInfo.class.getName(),function);
function = new GetServiceDetailFunction(registry);
functions.put(GetServiceDetail.class.getName(),function);
1.1 ws-juddi/src/java/org/apache/juddi/function/GetRegisteryInfoFunction.java
Index: GetRegisteryInfoFunction.java
===================================================================
/*
* Copyright 2001-2004 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.function;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.request.GetRegistryInfo;
import org.apache.juddi.datatype.response.RegistryInfo;
import org.apache.juddi.error.RegistryException;
import org.apache.juddi.registry.RegistryEngine;
import org.apache.juddi.util.Config;
/**
* @author Steve Viens (sviens@apache.org)
*/
public class GetRegisteryInfoFunction extends AbstractFunction
{
// private reference to jUDDI Logger
private static Log log = LogFactory.getLog(GetRegisteryInfoFunction.class);
/**
*
*/
public GetRegisteryInfoFunction(RegistryEngine registry)
{
super(registry);
}
/**
*
*/
public RegistryObject execute(RegistryObject regObject)
throws RegistryException
{
GetRegistryInfo request = (GetRegistryInfo)regObject;
String generic = request.getGeneric();
try
{
// create a new RegisteryInfo instance and
// add Registry name/value properties to it.
RegistryInfo info = new RegistryInfo();
info.setGeneric(generic);
info.setOperator(Config.getOperator());
info.addProperty("registry_contact","admin@viens.net");
info.addProperty("registry_version","1.0b1");
info.addProperty("uddi_version","2.0");
return info;
}
catch(Exception ex)
{
log.error(ex);
throw new RegistryException(ex);
}
}
/***************************************************************************/
/***************************** TEST DRIVER *********************************/
/***************************************************************************/
public static void main(String[] args)
{
// initialize the registry
RegistryEngine reg = new RegistryEngine();
reg.init();
try
{
}
catch (Exception ex)
{
// write execption to the console
ex.printStackTrace();
}
finally
{
// destroy the registry
reg.dispose();
}
}
}
1.1 ws-juddi/src/java/org/apache/juddi/datatype/request/GetRegistryInfo.java
Index: GetRegistryInfo.java
===================================================================
/*
* Copyright 2001-2004 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.datatype.request;
import org.apache.juddi.datatype.RegistryObject;
/**
* "Used to request an abbreviated synopsis of all information currently
* managed by a given individual."
*
* @author Steve Viens (sviens@apache.org)
*/
public class GetRegistryInfo implements RegistryObject,Inquiry
{
String generic;
/**
*
*/
public GetRegistryInfo()
{
}
/**
*
* @param genericValue
*/
public void setGeneric(String genericValue)
{
this.generic = genericValue;
}
/**
*
* @return String UDDI request's generic value.
*/
public String getGeneric()
{
return this.generic;
}
}
1.5 +10 -0 ws-juddi/src/java/org/apache/juddi/registry/IRegistry.java
Index: IRegistry.java
===================================================================
RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/registry/IRegistry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IRegistry.java 1 May 2004 00:51:40 -0000 1.4
+++ IRegistry.java 28 May 2004 04:46:25 -0000 1.5
@@ -36,6 +36,7 @@
import org.apache.juddi.datatype.response.PublisherDetail;
import org.apache.juddi.datatype.response.PublisherList;
import org.apache.juddi.datatype.response.RegisteredInfo;
+import org.apache.juddi.datatype.response.RegistryInfo;
import org.apache.juddi.datatype.response.RelatedBusinessesList;
import org.apache.juddi.datatype.response.ServiceDetail;
import org.apache.juddi.datatype.response.ServiceList;
@@ -282,6 +283,15 @@
* @exception RegistryException;
*/
RegisteredInfo getRegisteredInfo(AuthInfo authInfo)
+ throws RegistryException;
+
+ /**
+ * Used to request public property values from the UDDI registry. This
+ * is a proprietary jUDDI/Viens.net API call.
+ *
+ * @exception RegistryException;
+ */
+ RegistryInfo getRegistryInfo()
throws RegistryException;
/**
1.4 +16 -0 ws-juddi/src/java/org/apache/juddi/registry/AbstractRegistry.java
Index: AbstractRegistry.java
===================================================================
RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/registry/AbstractRegistry.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractRegistry.java 1 May 2004 00:51:40 -0000 1.3
+++ AbstractRegistry.java 28 May 2004 04:46:25 -0000 1.4
@@ -46,6 +46,7 @@
import org.apache.juddi.datatype.request.GetPublisherAssertions;
import org.apache.juddi.datatype.request.GetPublisherDetail;
import org.apache.juddi.datatype.request.GetRegisteredInfo;
+import org.apache.juddi.datatype.request.GetRegistryInfo;
import org.apache.juddi.datatype.request.GetServiceDetail;
import org.apache.juddi.datatype.request.GetTModelDetail;
import org.apache.juddi.datatype.request.SaveBinding;
@@ -66,6 +67,7 @@
import org.apache.juddi.datatype.response.PublisherDetail;
import org.apache.juddi.datatype.response.PublisherList;
import org.apache.juddi.datatype.response.RegisteredInfo;
+import org.apache.juddi.datatype.response.RegistryInfo;
import org.apache.juddi.datatype.response.RelatedBusinessesList;
import org.apache.juddi.datatype.response.ServiceDetail;
import org.apache.juddi.datatype.response.ServiceList;
@@ -469,6 +471,20 @@
request.setAuthInfo(authInfo);
return (RegisteredInfo)execute(request);
+ }
+
+ /**
+ * "Used to request an abbreviated synopsis of all information currently
+ * managed by a given individual."
+ *
+ * @exception RegistryException;
+ */
+ public RegistryInfo getRegistryInfo()
+ throws RegistryException
+ {
+ GetRegistryInfo request = new GetRegistryInfo();
+
+ return (RegistryInfo)execute(request);
}
/**
1.1 ws-juddi/src/java/org/apache/juddi/datatype/response/RegistryInfo.java
Index: RegistryInfo.java
===================================================================
/*
* Copyright 2001-2004 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.datatype.response;
import java.util.Properties;
import org.apache.juddi.datatype.RegistryObject;
/**
* @author Steve Viens (sviens@apache.org)
*/
public class RegistryInfo implements RegistryObject
{
String generic;
String operator;
Properties properties;
/**
* Constructs a new initialized Addressline instance.
*/
public RegistryInfo()
{
properties = new Properties();
}
/**
*
* @param genericValue
*/
public void setGeneric(String genericValue)
{
this.generic = genericValue;
}
/**
*
* @return String UDDI generic value.
*/
public String getGeneric()
{
return this.generic;
}
/**
*
*/
public void setOperator(String operator)
{
this.operator = operator;
}
/**
*
*/
public String getOperator()
{
return this.operator;
}
/**
* @param name The name of the property being added.
* @param value The value of the property.
*/
public void addProperty(String name,String value)
{
properties.put(name,value);
}
/**
* Returns the value of the desired property.
*
* @param name The name of the property being added.
* @return The value of the desired property.
*/
public String getProperty(String name)
{
return (String)properties.get(name);
}
/**
* Adds a property name/value pair to the Property object.
*
* @param prop Property object to add
*/
public void addProperty(Property prop)
{
if (prop == null)
return;
properties.put(prop.getName(),prop.getValue());
}
/**
*
*/
public Properties getProperties()
{
return properties;
}
}
1.1 ws-juddi/src/java/org/apache/juddi/datatype/response/Property.java
Index: Property.java
===================================================================
/*
* Copyright 2001-2004 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.datatype.response;
import org.apache.juddi.datatype.RegistryObject;
/**
* @author Steve Viens (sviens@apache.org)
*/
public class Property implements RegistryObject
{
String name;
String value;
/**
* Constructs a new initialized Addressline instance.
*/
public Property()
{
}
/**
* Constructs a new addressline with the given data.
*
* @param line The data of the addressline.
*/
public Property(String name,String value)
{
this.name = name;
this.value = value;
}
/**
* Sets the name of this property.
*
* @param name The name of this property.
*/
public void setName(String name)
{
this.name = name;
}
/**
* Returns the data of the addressline.
*
* @return The name of the property.
*/
public String getName()
{
return this.name;
}
/**
* Sets the value of this property.
*
* @param value The value of this property
*/
public void setValue(String value)
{
this.value = value;
}
/**
* Returns the value of this property.
*
* @return The value of this property.
*/
public String getValue()
{
return this.value;
}
}