You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2004/06/02 20:06:26 UTC

cvs commit: ws-axis/java/src/org/apache/axis/utils JavaUtils.java

dims        2004/06/02 11:06:26

  Modified:    java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/src/org/apache/axis/utils JavaUtils.java
  Log:
  Fix for AXIS-1368 - Java2WSDL generates elements with the same QName if more than one service-specific fault is present
  from Andrei Iltchenko (andrei.iltchenko@nl.compuware.com)
  
  Revision  Changes    Path
  1.122     +17 -0     ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- Emitter.java	17 May 2004 12:37:01 -0000	1.121
  +++ Emitter.java	2 Jun 2004 18:06:25 -0000	1.122
  @@ -178,6 +178,9 @@
       /** Field exceptionMsg */
       private Map exceptionMsg = null;
   
  +    /** Global element names already in use */
  +    private Map usedElementNames;
  +
       /** Field encodingList */
       private ArrayList encodingList;
   
  @@ -224,6 +227,7 @@
   
           namespaces = new Namespaces();
           exceptionMsg = new HashMap();
  +        usedElementNames = new HashMap();
       }
   
       /**
  @@ -1840,6 +1844,19 @@
   
                   param.setQName(qname);
               }
  +
  +            // Make sure qname's value is unique.
  +            ArrayList   names = (ArrayList)
  +                    usedElementNames.get(qname.getNamespaceURI());
  +            if (names == null) {
  +                names = new ArrayList(1);
  +                usedElementNames.put(qname.getNamespaceURI(), names);
  +            }
  +            else if (names.contains(qname.getLocalPart())) {
  +                qname = new QName(qname.getNamespaceURI(),
  +                    JavaUtils.getUniqueValue(names, qname.getLocalPart()));
  +            }
  +            names.add(qname.getLocalPart());
   
               types.writeElementDecl(qname, param.getJavaType(),
                       param.getTypeQName(), false, false);
  
  
  
  1.110     +56 -0     ws-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- JavaUtils.java	14 May 2004 12:56:13 -0000	1.109
  +++ JavaUtils.java	2 Jun 2004 18:06:26 -0000	1.110
  @@ -1191,4 +1191,60 @@
   
           return attachmentSupportEnabled;
       } // isAttachmentSupported
  +
  +    /**
  +     * Makes the value passed in <code>initValue</code> unique among the
  +     * {@link String} values contained in <code>values</code> by suffixing
  +     * it with a decimal digit suffix.
  +     */
  +    public static String  getUniqueValue(Collection values, String initValue) {
  +
  +        if (!values.contains(initValue))  {
  +            return  initValue;
  +        }
  +        else  {
  +
  +            StringBuffer   unqVal = new StringBuffer(initValue);
  +            int   beg = unqVal.length(),  cur,  end;
  +            while (Character.isDigit(unqVal.charAt(beg - 1)))  {
  +                beg--;
  +            }
  +            if (beg == unqVal.length())  {
  +                unqVal.append('1');
  +            }
  +            cur = end = unqVal.length() - 1;
  +
  +            while (values.contains(unqVal.toString()))  {
  +
  +                if (unqVal.charAt(cur) < '9')  {
  +                    unqVal.setCharAt(cur, (char) (unqVal.charAt(cur) + 1));
  +                }
  +
  +                else  {
  +
  +                    while (cur-- > beg)  {
  +                        if (unqVal.charAt(cur) < '9')  {
  +                            unqVal.setCharAt(cur,
  +                                (char) (unqVal.charAt(cur) + 1));
  +                            break;
  +                        }
  +                    }
  +
  +                    // See if there's a need to insert a new digit.
  +                    if (cur < beg)  {
  +                        unqVal.insert(++cur, '1');     end++;
  +                    }
  +                    while (cur < end)  {
  +                        unqVal.setCharAt(++cur, '0');
  +                    }
  +
  +                }
  +
  +            }
  +
  +            return  unqVal.toString();
  +
  +        }  /*  For  else  clause  of  selection-statement   If(!values ...   */
  +
  +    }  /*  For  class  method   JavaUtils.getUniqueValue   */
   }