You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juddi.apache.org by "Viens, Stephen" <St...@LibertyMutual.com> on 2005/03/14 22:42:39 UTC

RE: Jaxr Problem 3 final: problem solved

Ming,

[Moved thread to the juddi-dev list ... more appropriate for this
subject]

Thanks for doing the legwork to fix this.  I've taken a look at your
solution and I may have an alternate solution that will eliminate this
problem which actually exists in a dozen or more situations - we just
haven't run into it yet.

The fix is to update the unmarshal() methods in DescriptionHandler and
NameHandler classes so that they ignore description and name elements
which do not contain a text node (the problem you've encountered).  For
instance. The updated DescriptionHandler.unmarshal() method would look
like this:

  public RegistryObject unmarshal(Element element)
  {   
    // Attributes
    String langCode = element.getAttribute("xml:lang");

    // Text Node Value
    String descValue = XMLUtils.getText(element);

    // Child Elements
    // {none}

    // Only create Description instance if descValue not null and not
zero-length
    Description obj = null;
    if ((descValue != null) && (descValue.trim().length() > 0)) 
      obj = new Description(descValue,langCode);
    
    return obj;
  }

The new unmarshal method in NameHandler will look (almost) identical.
Unfortunately all dependent handlers will need to be updated as well to
potentially expect to receive a null value from this method.  It's an
easy change but must be made to about 19 other Handler classes.  I'll
post the fix to CVS tonight.

Steve

-----Original Message-----
From: Wang, Ming-Fang [mailto:Ming-Fang.Wang@fnf.com] 
Sent: Monday, March 14, 2005 10:25 AM
To: juddi-user@ws.apache.org
Subject: RE: Jaxr Problem 3 final: problem solved


Steve,

I found that for Oracle JDBC driver, if a value is empty string, a null
is actually inserted into database table. So, if I use Oracle database
and give an empty string in the description, in the
BindingDescTable.insert method, a null value will be inserted into the
table. Since the descr column of the table is not null-able, a sql
exception will be generated. My suggestion is to add an if statement
there to check value first. So, the code looks like:

        String str=desc.getValue();			// Added Line
        if (str!=null && str.length()>0) {	// Added Line
            
            statement.setInt(2, descID);
            statement.setString(3, desc.getLanguageCode());
            statement.setString(4, desc.getValue());
    
            log.debug(
              "insert into BINDING_DESCR table:\n\n\t"
                + insertSQL
                + "\n\t BINDING_KEY="
                + bindingKey.toString()
                + "\n\t BINDING_DESCR_ID="
                + descID
                + "\n\t LANG_CODE="
                + desc.getLanguageCode()
                + "\n\t DESCR="
                + desc.getValue()
                + "\n");
    
            statement.executeUpdate();
        }							// Added
Line

In this way, no empty string will be written to database. 

For those database drivers that do write something to database even for
empty strings, this arrangement will prevent inserting anything to db,
which I think should be acceptable.

-Ming

-----Original Message-----
From: Steve Viens [mailto:steve@viens.net] 
Sent: Friday, March 11, 2005 4:53 AM
To: juddi-user@ws.apache.org
Subject: RE: Jaxr Problem 3 final: problem solved

Ming, 

jUDDI should be more careful than to just try to insert the description
value without checking for null first. 

When Juddi tries to insert the comment, a sql exception is thrown,
complaining null value instead into a null value disallowed column.

Could you post this to jUDDI's issue tracker?

  http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10401

If jUDDI isn't checking BindingTemplate descriptions then it's probably
not checking Description values for the other major objects
(BusinessEntity, BusinessService, etc).

Steve
-----Original Message-----
From: Wang, Ming-Fang [mailto:Ming-Fang.Wang@fnf.com] 
Sent: Thursday, March 10, 2005 2:34 PM
To: juddi-user@ws.apache.org
Subject: Jaxr Problem 3 final: problem solved


Hi,

I have just found one more bug from the Sun Micro implementation of
Jaxr. It generates an empty description element on a bindingTemplate
element. According to uddi.xsd, empty description element under a
bindingTemplate element is a violation.

The jaxr code looks like this:

                ServiceBinding bnd =
m_buzLfCyclMgr.createServiceBinding();
                bnd.setValidateURI(false);
//                InternationalString
is=m_buzLfCyclMgr.createInternationalString(Locale.US,
//                    "Just another access point");
//                bnd.setDescription(is);
 
bnd.setAccessURI("http://localhost:8080/axis/services/urn:xmltoday-delay
ed-quotes");
                svc.addServiceBinding(bnd);

With these three lines commented out, the section of uddi XML looks
like:

                <bindingTemplate bindingKey=""
serviceKey="A2B392F0-90DD-11D9-BF4F-FAA2D4FA8F92">
                    <description xml:lang="en-US"/>
                    <accessPoint URLType="http">
 
http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes
                    </accessPoint>
                    <tModelInstanceDetails/>
                </bindingTemplate>

According to UDDI schema, this <description> element can be missing but
cannot be empty. When Juddi tries to insert the comment, a sql exception
is thrown, complaining null value instead into a null value disallowed
column.

Solution, do not comment these lines.

If you have followed jaxr problem 3, I hope you did not regret too much
on reading the e-mails. This will be the last e-mail in this problem 3
issue. Only if I find another issue, but that will be jaxr problem 4
e-mail chain.

Thanks

-Ming