Author: sergeyb
Date: Thu Aug 23 10:25:36 2012
New Revision: 1376425

URL: http://svn.apache.org/viewvc?rev=1376425&view=rev
Log:
Merged revisions 1376138 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1376138 | sergeyb | 2012-08-22 17:59:36 +0100 (Wed, 22 Aug 2012) | 21 lines
  
  Merged revisions 1375100,1375535,1375672,1376072 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1375100 | sergeyb | 2012-08-20 17:50:26 +0100 (Mon, 20 Aug 2012) | 1 line
    
    [CXF-4477] Fixing regression to do with defaulting primitive parameter 
types to String, adding the option to customize the type mapping
  ........
    r1375535 | sergeyb | 2012-08-21 14:26:28 +0100 (Tue, 21 Aug 2012) | 1 line
    
    [CXF-4477] Avoiding using the schemaTypesMap for both primitive schema type 
to java type mappings and complex Java to Java type mappings (as in case of W3C 
EPR), support for autoboxing of all optional params, support for mapping 
representations with no element references to Java types
  ........
    r1375672 | sergeyb | 2012-08-21 18:23:43 +0100 (Tue, 21 Aug 2012) | 1 line
    
    [CXF-4477] One more update
  ........
    r1376072 | sergeyb | 2012-08-22 15:35:01 +0100 (Wed, 22 Aug 2012) | 1 line
    
    [CXF-4477] Restoring schemaTypeMap, adding notypes option
  ........
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    
cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
    
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 23 10:25:36 2012
@@ -0,0 +1,2 @@
+/cxf/branches/2.6.x-fixes:1376138
+/cxf/trunk:1375100,1375535,1375672,1376072

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
 Thu Aug 23 10:25:36 2012
@@ -75,6 +75,7 @@ import org.apache.cxf.catalog.OASISCatal
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.ReflectionInvokationHandler;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
@@ -91,9 +92,6 @@ import org.apache.cxf.service.model.Sche
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.ws.commons.schema.XmlSchema;
 
-/**
- * TODO: This will need to be moved into a separate module
- */
 public class SourceGenerator {
     public static final String CODE_TYPE_GRAMMAR = "grammar";
     public static final String CODE_TYPE_PROXY = "proxy";
@@ -110,6 +108,11 @@ public class SourceGenerator {
     private static final List<String> HTTP_OK_STATUSES =
         Arrays.asList(new String[] {"200", "201", "202", "203", "204"});
     
+    private static final Set<Class<?>> OPTIONAL_PARAMS = 
+        new HashSet<Class<?>>(Arrays.<Class<?>>asList(QueryParam.class, 
+                                                      HeaderParam.class,
+                                                      MatrixParam.class,
+                                                      FormParam.class));
     private static final Map<String, Class<?>> HTTP_METHOD_ANNOTATIONS;
     private static final Map<String, Class<?>> PARAM_ANNOTATIONS;
     private static final Set<String> RESOURCE_LEVEL_PARAMS;
@@ -146,8 +149,22 @@ public class SourceGenerator {
         
         XSD_SPECIFIC_TYPE_MAP = new HashMap<String, String>();
         XSD_SPECIFIC_TYPE_MAP.put("string", "String");
-        XSD_SPECIFIC_TYPE_MAP.put("decimal", "java.math.BigInteger");
         XSD_SPECIFIC_TYPE_MAP.put("integer", "long");
+        XSD_SPECIFIC_TYPE_MAP.put("int", "int");
+        XSD_SPECIFIC_TYPE_MAP.put("long", "long");
+        XSD_SPECIFIC_TYPE_MAP.put("byte", "byte");
+        XSD_SPECIFIC_TYPE_MAP.put("boolean", "boolean");
+        XSD_SPECIFIC_TYPE_MAP.put("unsignedInt", "long");
+        XSD_SPECIFIC_TYPE_MAP.put("unsignedShort", "int");
+        XSD_SPECIFIC_TYPE_MAP.put("unsignedByte", "short");
+        XSD_SPECIFIC_TYPE_MAP.put("unsignedLong", "java.math.BigInteger");
+        XSD_SPECIFIC_TYPE_MAP.put("decimal", "java.math.BigInteger");
+        XSD_SPECIFIC_TYPE_MAP.put("positiveInteger", "java.math.BigInteger");
+        XSD_SPECIFIC_TYPE_MAP.put("QName", "javax.xml.namespace.QName");
+        XSD_SPECIFIC_TYPE_MAP.put("duration", "javax.xml.datatype.Duration");
+        XSD_SPECIFIC_TYPE_MAP.put("date", "java.util.Date");
+        XSD_SPECIFIC_TYPE_MAP.put("dateTime", "java.util.Date");
+        XSD_SPECIFIC_TYPE_MAP.put("time", "java.util.Date");
     }
 
     private Comparator<String> importsComparator;
@@ -158,6 +175,7 @@ public class SourceGenerator {
     private String wadlPath;
     private String wadlNamespace = WadlGenerator.WADL_NS;
     private boolean generateEnums;
+    private boolean skipSchemaGeneration;
     
     private Map<String, String> properties; 
     
@@ -167,10 +185,12 @@ public class SourceGenerator {
     private List<InputSource> schemaPackageFiles = Collections.emptyList();
     private List<String> compilerArgs = new ArrayList<String>();
     private Map<String, String> schemaPackageMap = Collections.emptyMap();
-    private Map<String, String> schemaTypesMap = Collections.emptyMap();
+    private Map<String, String> javaTypeMap = Collections.emptyMap();
+    private Map<String, String> schemaTypeMap = Collections.emptyMap();
+    private Map<String, String> mediaTypesMap = Collections.emptyMap();
     private Bus bus;
     private boolean supportMultipleXmlReps;
-
+    
     private SchemaCollection schemaCollection = new SchemaCollection();
     
     public SourceGenerator() {
@@ -197,6 +217,10 @@ public class SourceGenerator {
         this.generateEnums = generate;
     }
     
+    public void setSkipSchemaGeneration(boolean skip) {
+        this.skipSchemaGeneration = skip;
+    }
+    
     private String getClassPackageName(String wadlPackageName) {
         if (resourcePackageName != null) {
             return resourcePackageName;
@@ -229,8 +253,9 @@ public class SourceGenerator {
     
     private GrammarInfo generateSchemaCodeAndInfo(Application app, Set<String> 
typeClassNames, 
                                                   File srcDir) {
+        
         List<SchemaInfo> schemaElements = getSchemaElements(app);
-        if (schemaElements != null && !schemaElements.isEmpty()) {
+        if (!skipSchemaGeneration && schemaElements != null && 
!schemaElements.isEmpty()) {
             // generate classes from schema
             JCodeModel codeModel = createCodeModel(schemaElements, 
typeClassNames);
             if (codeModel != null) {
@@ -613,6 +638,7 @@ public class SourceGenerator {
             if (id.length() == 0) {
                 id = methodNameLowerCase;
             }
+            
             String suffixName = "";
             if (!jaxpSourceRequired && inXmlRep != null && 
xmlRequestReps.size() > 1) {
                 String value = inXmlRep.getAttribute("element");
@@ -648,9 +674,10 @@ public class SourceGenerator {
                 responseTypeAvailable = writeResponseType(responseEls, sbCode, 
imports, info);
                 String genMethodName = id + suffixName;
                 if (methodNameLowerCase.equals(genMethodName)) {
-                    genMethodName += 
firstCharToUpperCase(currentPath.replaceAll("/", ""));
+                    genMethodName += firstCharToUpperCase(
+                        currentPath.replaceAll("/", "").replaceAll("\\{", 
"").replaceAll("\\}", ""));
                 }
-                sbCode.append(genMethodName); 
+                sbCode.append(genMethodName);
             } else {
                 boolean expandedQName = id.startsWith("{");
                 QName qname = convertToQName(id, expandedQName);
@@ -762,7 +789,7 @@ public class SourceGenerator {
                 return el;
             }
         }
-        return null;
+        return repElements.isEmpty() ? null : repElements.get(0);
     }
     
     private boolean writeResponseType(List<Element> responseEls,
@@ -865,7 +892,7 @@ public class SourceGenerator {
             boolean isRepeating = 
Boolean.valueOf(paramEl.getAttribute("repeating"));
             String type = enumCreated ? getTypicalClassName(name)
                 : getPrimitiveType(paramEl, info, imports);
-            if (paramAnn == QueryParam.class
+            if (OPTIONAL_PARAMS.contains(paramAnn)
                 && (isRepeating || 
!Boolean.valueOf(paramEl.getAttribute("required")))    
                 && AUTOBOXED_PRIMITIVES_MAP.containsKey(type)) {
                 type = AUTOBOXED_PRIMITIVES_MAP.get(type);
@@ -889,6 +916,10 @@ public class SourceGenerator {
             if (!jaxpRequired) {    
                 elementParamType = getElementRefName(repElement, info, 
imports);
                 if (elementParamType != null) {
+                    int lastIndex = elementParamType.lastIndexOf('.');
+                    if (lastIndex != -1) {
+                        elementParamType = 
elementParamType.substring(lastIndex + 1);
+                    }
                     elementParamName = elementParamType.toLowerCase();
                 }
             } else {
@@ -1006,21 +1037,29 @@ public class SourceGenerator {
     }
     
     private String getPrimitiveType(Element paramEl, ContextInfo info, 
Set<String> imports) {
+        final String defaultValue = "String";
         String type = paramEl.getAttribute("type");
         if (type.length() == 0) {
-            return "String";
+            return defaultValue;
         }
+        
         String[] pair = type.split(":");
-        String value = pair.length == 2 ? pair[1] : type;
-        if (XSD_SPECIFIC_TYPE_MAP.containsKey(value)) {
-            return XSD_SPECIFIC_TYPE_MAP.get(value);
-        } else {
-            String actualValue = value.replaceAll("[\\-\\_]", "");
-            if (pair.length > 1) {
-                actualValue = convertRefToClassName(pair[0], actualValue, 
"String", info, imports);
+        if (pair.length == 2) {
+            if (XSD_SPECIFIC_TYPE_MAP.containsKey(pair[1])) {
+                String expandedName = "{" + 
XmlSchemaConstants.XSD_NAMESPACE_URI + "}" + pair[1];
+                if (schemaTypeMap.containsKey(expandedName)) {
+                    return schemaTypeMap.get(expandedName);
+                }
+                
+                return XSD_SPECIFIC_TYPE_MAP.get(pair[1]);
             }
-            return actualValue;
+            
+            String value = pair[1].replaceAll("[\\-\\_]", "");
+            return convertRefToClassName(pair[0], value, defaultValue, info, 
imports);
+        } else {
+            return type;
         }
+        
     }
     
     private String convertRefToClassName(String prefix,
@@ -1032,12 +1071,18 @@ public class SourceGenerator {
         if (gInfo != null) {
             String namespace = gInfo.getNsMap().get(prefix);
             if (namespace != null) {
+                                
                 String packageName = getPackageFromNamespace(namespace);
                 String clsName = getSchemaClassName(packageName, gInfo, 
actualValue, 
                                                     info.getTypeClassNames());
+                
+                if (clsName == null) {
+                    clsName = schemaTypeMap.get("{" + namespace + "}" + 
actualValue);
+                }
                 if (clsName != null) {
                     addImport(imports, clsName);
                     int index = clsName.lastIndexOf(".");
+                    
                     if (index != -1) {
                         clsName = clsName.substring(index + 1);
                     } 
@@ -1062,6 +1107,12 @@ public class SourceGenerator {
                 return convertRefToClassName(pair[0], pair[1], null, info, 
imports);
             }
         } else {
+            // try mediaTypesMap first
+            String mediaType = repElement.getAttribute("mediaType");
+            if (!StringUtils.isEmpty(mediaType) && 
mediaTypesMap.containsKey(mediaType)) {
+                return mediaTypesMap.get(mediaType);
+            }
+            
             Element param = DOMUtils.getFirstChildWithName(repElement, 
getWadlNamespace(), "param");
             if (param != null) {
                 return getPrimitiveType(param, info, imports);
@@ -1080,8 +1131,8 @@ public class SourceGenerator {
                 clsName = matchClassName(typeClassNames, packageName, 
elementTypeName.replaceAll("_", ""));
             }
         }
-        if (clsName == null && schemaTypesMap != null) {
-            clsName = schemaTypesMap.get(packageName + "." + localName);
+        if (clsName == null && javaTypeMap != null) {
+            clsName = javaTypeMap.get(packageName + "." + localName);
         }
         return clsName;
     }
@@ -1226,12 +1277,11 @@ public class SourceGenerator {
         return lastSep != -1 ? docPath.substring(0, lastSep + 1) : docPath;
     }
     
-    private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) { 
+    private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) {
         SchemaInfo info = new 
SchemaInfo(schemaEl.getAttribute("targetNamespace"));
-
+        
         info.setElement(schemaEl);
         info.setSystemId(systemId);
-
         // Lets try to read the schema to deal with the possible
         // eviction of the DOM element from the memory 
         try {
@@ -1241,7 +1291,7 @@ public class SourceGenerator {
             // may be due to unsupported resolvers for protocols like
             // classpath: or not the valid schema definition, may not be 
critical
             // for the purpose of the schema compilation.
-        } 
+        }
 
         return info;
     }
@@ -1320,7 +1370,7 @@ public class SourceGenerator {
                 // when addressing the issue of retrieving WADLs with included 
schemas  
                 if (key.startsWith("classpath:")) {
                     String resource = key.substring(10);
-                    URL url = ResourceUtils.getClasspathResourceURL(resource,
+                    URL url = ResourceUtils.getClasspathResourceURL(resource, 
                                                                     
SourceGenerator.class,
                                                                     bus);
                     if (url != null) {
@@ -1387,8 +1437,16 @@ public class SourceGenerator {
         this.schemaPackageMap = map;
     }
     
-    public void setSchemaTypesMap(Map<String, String> map) {
-        this.schemaTypesMap = map;
+    public void setJavaTypeMap(Map<String, String> map) {
+        this.javaTypeMap = map;
+    }
+    
+    public void setSchemaTypeMap(Map<String, String> map) {
+        this.schemaTypeMap = map;
+    }
+    
+    public void setMediaTypeMap(Map<String, String> map) {
+        this.mediaTypesMap = map;
     }
     
     public void setBus(Bus bus) {

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
 Thu Aug 23 10:25:36 2012
@@ -37,11 +37,14 @@ public final class WadlToolConstants {
     public static final String CFG_SCHEMA_PACKAGENAME = "schemaPackagename";
     public static final String CFG_RESOURCENAME = "resourcename";
     
+    public static final String CFG_SCHEMA_TYPE_MAP = "schemaTypeMap";
+    public static final String CFG_MEDIA_TYPE_MAP = "mediaTypeMap";
     public static final String CFG_MULTIPLE_XML_REPS = 
"supportMultipleXmlReps";
     
     public static final String CFG_CATALOG = ToolConstants.CFG_CATALOG;
     public static final String CFG_BINDING = ToolConstants.CFG_BINDING;
     
+    public static final String CFG_NO_TYPES = ToolConstants.CFG_NO_TYPES;
     public static final String CFG_NO_ADDRESS_BINDING = 
ToolConstants.CFG_NO_ADDRESS_BINDING;
     
     public static final String CFG_WADL_NAMESPACE = "wadlNamespace";

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
 Thu Aug 23 10:25:36 2012
@@ -25,6 +25,7 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URL;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -44,12 +45,12 @@ import org.apache.cxf.tools.wadlto.WadlT
 import org.apache.cxf.tools.wadlto.jaxb.CustomizationParser;
 
 public class JAXRSContainer extends AbstractCXFToolContainer {
-    private static final Map<String, String> DEFAULT_TYPES_MAP;
+    private static final Map<String, String> DEFAULT_JAVA_TYPE_MAP;
     private static final String TOOL_NAME = "wadl2java";
+    private static final String EPR_TYPE_KEY = 
"org.w3._2005._08.addressing.EndpointReference";
     
     static {
-        // Should we have a common code which checks W3C EPR bindings in 
tools-common ?
-        DEFAULT_TYPES_MAP = 
Collections.singletonMap("org.w3._2005._08.addressing.EndpointReference", 
+        DEFAULT_JAVA_TYPE_MAP = Collections.singletonMap(EPR_TYPE_KEY, 
                 "javax.xml.ws.wsaddressing.W3CEndpointReference");
     }
     
@@ -98,7 +99,12 @@ public class JAXRSContainer extends Abst
     }
 
     public Set<String> getArrayKeys() {
-        return new HashSet<String>();
+        Set<String> set = new HashSet<String>();
+        set.add(WadlToolConstants.CFG_BINDING);
+        set.add(WadlToolConstants.CFG_SCHEMA_PACKAGENAME);
+        set.add(WadlToolConstants.CFG_SCHEMA_TYPE_MAP);
+        set.add(WadlToolConstants.CFG_MEDIA_TYPE_MAP);
+        return set;
     }
     
     private void processWadl() {
@@ -138,15 +144,15 @@ public class JAXRSContainer extends Abst
         List<InputSource> schemaPackageFiles = parser.getSchemaPackageFiles();
         sg.setSchemaPackageFiles(schemaPackageFiles);
         sg.setSchemaPackageMap(context.getNamespacePackageMap());
-        // 
sg.setSchemaPackageName((String)context.get(WadlToolConstants.CFG_TOOLS_PACKAGENAME)));
         
-        // TODO: consider introducing an option too for users be able to
-        //       supply custom type mappings
-        sg.setSchemaTypesMap(DEFAULT_TYPES_MAP);
+        sg.setJavaTypeMap(DEFAULT_JAVA_TYPE_MAP);
+        sg.setSchemaTypeMap(getSchemaTypeMap());
+        sg.setMediaTypeMap(getMediaTypeMap());
 
         if (context.optionSet(WadlToolConstants.CFG_GENERATE_ENUMS)) {
             sg.setGenerateEnums(true);
         }
+        
sg.setSkipSchemaGeneration(context.optionSet(WadlToolConstants.CFG_NO_TYPES));
         
         // generate
         String codeType = context.optionSet(WadlToolConstants.CFG_TYPES)
@@ -219,5 +225,32 @@ public class JAXRSContainer extends Abst
             }
         }
         
-    }    
+    }
+    
+    private Map<String, String> getSchemaTypeMap() {
+        return getMap(WadlToolConstants.CFG_SCHEMA_TYPE_MAP);
+    }
+    
+    private Map<String, String> getMediaTypeMap() {
+        return getMap(WadlToolConstants.CFG_MEDIA_TYPE_MAP);
+    }
+    
+    private Map<String, String> getMap(String parameterName) {
+        String[] typeToClasses = new String[]{};
+        Object value = context.get(parameterName);
+        if (value != null) {
+            typeToClasses = value instanceof String ? new 
String[]{(String)value}
+                                                   : (String[])value;
+        }
+        Map<String, String> typeMap = new HashMap<String, String>();
+        for (int i = 0; i < typeToClasses.length; i++) {
+            int pos = typeToClasses[i].indexOf("=");
+            if (pos != -1) {
+                String type = typeToClasses[i].substring(0, pos);
+                String clsName = typeToClasses[i].substring(pos + 1);
+                typeMap.put(type, clsName);
+            }
+        }
+        return typeMap;
+    }
 }

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
 Thu Aug 23 10:25:36 2012
@@ -66,6 +66,30 @@ Examples:
                     <annotation>[schema-namespace =]package-name</annotation>
                 </associatedArgument>
             </option>
+            
+            <option id="schemaTypeMap" maxOccurs="unbounded">
+                <annotation>
+                    Specifies the optional mapping between WADL parameter 
+                    or representation schema type and custom Java type.
+                </annotation>
+                <switch>tMap</switch>
+                <associatedArgument placement="afterSpace">
+                    <valuetype>NamingSpacePackageString</valuetype>
+                    <annotation>schema-type=java-type</annotation>
+                </associatedArgument>
+            </option>
+            
+            <option id="mediaTypeMap" maxOccurs="unbounded">
+                <annotation>
+                    Specifies the optional mapping between a WADL 
representation
+                    with no wadl:element attribute and Java class.
+                </annotation>
+                <switch>repMap</switch>
+                <associatedArgument placement="afterSpace">
+                    <valuetype>NamingSpacePackageString</valuetype>
+                    <annotation>media-type=class-name</annotation>
+                </associatedArgument>
+            </option>
 
             <option id="resourcename">
                 <annotation>
@@ -146,6 +170,11 @@ Examples:
                 <switch>generateEnums</switch>
             </option>
             
+            <option id="notypes" maxOccurs="1">
+                <annotation>Turns off generating types</annotation>
+                <switch>noTypes</switch>
+            </option>
+            
             <option id="noAddressBinding" maxOccurs="1">
                 <annotation>
                     Specifies that the generator should not use the address 
jaxb binding file to map wsa:EndpointReferenceType 

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
 Thu Aug 23 10:25:36 2012
@@ -40,6 +40,10 @@ public class JAXRSContainerTest extends 
             ToolContext context = new ToolContext();
             context.put(WadlToolConstants.CFG_OUTPUTDIR, 
output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, 
getLocation("/wadl/bookstore.xml"));
+            context.put(WadlToolConstants.CFG_MEDIA_TYPE_MAP, 
+                        "application/xml=javax.xml.transform.Source");
+            context.put(WadlToolConstants.CFG_MEDIA_TYPE_MAP, 
+                        
"multipart/form-data=org.apache.cxf.jaxrs.ext.multipart.MultipartBody");
             context.put(WadlToolConstants.CFG_COMPILE, "true");
             
             container.setContext(context);
@@ -177,6 +181,8 @@ public class JAXRSContainerTest extends 
             ToolContext context = new ToolContext();
             context.put(WadlToolConstants.CFG_OUTPUTDIR, 
output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, 
getLocation("/wadl/resourceWithEPR.xml"));
+            context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP, 
+                        
"{http://www.w3.org/2001/XMLSchema}date=javax.xml.datatype.XMLGregorianCalendar";);
             context.put(WadlToolConstants.CFG_COMPILE, "true");
 
             container.setContext(context);
@@ -196,6 +202,36 @@ public class JAXRSContainerTest extends 
         }
     }
     
+    @Test
+    public void testResourceWithEPRNoSchemaGen() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, 
output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, 
getLocation("/wadl/resourceWithEPR.xml"));
+            context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP, 
+                "{http://www.w3.org/2005/08/addressing}EndpointReferenceType="; 
+                + "javax.xml.ws.wsaddressing.W3CEndpointReference");
+            context.put(WadlToolConstants.CFG_NO_ADDRESS_BINDING, "true");
+            context.put(WadlToolConstants.CFG_NO_TYPES, "true");
+            
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + 
"class" + "$");
+            assertEquals(1, files.size());
+            assertTrue(checkContains(files, "application" + 
".BookstoreResource.class"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
     @Test    
     public void testCodeGenWithImportedSchemaAndResourceSet() {
         try {

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
 Thu Aug 23 10:25:36 2012
@@ -72,7 +72,7 @@
         <param name="a" style="query" type="xs:int"/>
         <param name="c.a" style="query" type="xs:int"/>
         <param name="c.b" style="query" type="xs:int"/>
-        <param name="c.d.a" style="query" type="xs:int"/>
+        <param name="c.d.a" style="query" type="xs:dateTime"/>
         <param name="option"  default="A" style="query"
 required="true">
      <option value="A"/>
@@ -140,6 +140,15 @@ required="true">
       </response>
      </method>
 
+     <method name="POST" id="addBookXmlDefault">
+      <request>
+       <representation mediaType="application/xml"/>
+      </request>
+      <response>
+       <representation mediaType="multipart/form-data"/>
+      </response>
+     </method>
+
      <method name="POST" id="addBookOrBook2">
       <request>
        <representation mediaType="application/xml" element="prefix1:thebook"/>

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceWithEPR.xml
 Thu Aug 23 10:25:36 2012
@@ -41,7 +41,9 @@
  <resources base="http://localhost:8080/baz";>
    <resource path="/bookstore">
      <method name="GET">
-      <request/>
+      <request>
+         <param name="date" style="query" type="xs:date"/>
+      </request>
       <response>
        <representation mediaType="application/xml" 
element="wsa:EndpointReference"/>
       </response>

Modified: 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml?rev=1376425&r1=1376424&r2=1376425&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml
 (original)
+++ 
cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml
 Thu Aug 23 10:25:36 2012
@@ -3,7 +3,8 @@
  
   <resources base="http://localhost:8080/baz";>
        <resource path="/TestRs">
-          <resource path="/helloWorld">
+          <param name="id" style="template" type="xs:int"/>
+          <resource path="/helloWorld/{id}">
            <method name="GET">
            <response>
              <representation mediaType="application/octet-stream">
@@ -20,6 +21,15 @@
             </response>
            </method>
           </resource>
+          <resource path="/helloWorld3">
+           <method name="GET" id="get">
+            <response>
+              <representation mediaType="application/octet-stream">
+                <param name="result" style="plain" type="xs:string"/>
+              </representation>
+            </response>
+           </method>
+          </resource>
         </resource>
   </resources>
 </application>
\ No newline at end of file


Reply via email to