Package org.codehaus.enunciate.contract.jaxrs

Examples of org.codehaus.enunciate.contract.jaxrs.ResourceMethod


   * </ol>
   *
   * @return An example resource method, or if no good examples were found.
   */
  public ResourceMethod findExampleResourceMethod() {
    ResourceMethod example = null;
    List<RootResource> resources = getRootResources();
    for (RootResource root : resources) {
      List<ResourceMethod> methods = root.getResourceMethods(true);
      for (ResourceMethod method : methods) {
        if (method.getAnnotation(DocumentationExample.class) != null && !method.getAnnotation(DocumentationExample.class).exclude()) {
View Full Code Here


   * @param resource The resource to read.
   * @return The string form of the resource.
   */
  protected String readResource(String resource) throws IOException, EnunciateException {
    HashMap<String, Object> model = new HashMap<String, Object>();
    ResourceMethod exampleResource = getModelInternal().findExampleResourceMethod();
    String label = getLabel() == null ? getEnunciate().getConfig() == null ? "enunciate" : getEnunciate().getConfig().getLabel() : getLabel();
    model.put("label", label);
    NameForTypeDefinitionMethod nameForTypeDefinition = new NameForTypeDefinitionMethod(getTypeDefinitionNamePattern(), label, getModelInternal().getNamespacesToPrefixes(), this.packageIdentifiers);

    if (exampleResource != null) {
      if (exampleResource.getEntityParameter() != null && exampleResource.getEntityParameter().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getEntityParameter().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
        }

        if (typeDefinition != null) {
          model.put("input_element_name", nameForTypeDefinition.calculateName(typeDefinition));
        }
      }

      if (exampleResource.getRepresentationMetadata() != null && exampleResource.getRepresentationMetadata().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getRepresentationMetadata().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
        }

        if (typeDefinition != null) {
          model.put("output_element_name", nameForTypeDefinition.calculateName(typeDefinition));
        }
      }

      model.put("resource_url", exampleResource.getFullpath());
      model.put("resource_method", exampleResource.getHttpMethods().isEmpty() ? "GET" : exampleResource.getHttpMethods().iterator().next());
    }

    URL res = ObjCDeploymentModule.class.getResource(resource);
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(bytes);
View Full Code Here

   * @param resource The resource to read.
   * @return The string form of the resource.
   */
  protected String readResource(String resource) throws IOException, EnunciateException {
    HashMap<String, Object> model = new HashMap<String, Object>();
    ResourceMethod exampleResource = getModelInternal().findExampleResourceMethod();
    model.put("filename", getSourceFileName());
    String label = getLabel() == null ? getEnunciate().getConfig() == null ? "enunciate" : getEnunciate().getConfig().getLabel() : getLabel();
    NameForTypeDefinitionMethod nameForTypeDefinition = new NameForTypeDefinitionMethod(getTypeDefinitionNamePattern(), label, getModelInternal().getNamespacesToPrefixes());

    if (exampleResource != null) {
      if (exampleResource.getEntityParameter() != null && exampleResource.getEntityParameter().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getEntityParameter().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
        }

        if (typeDefinition != null) {
          model.put("input_element_name", nameForTypeDefinition.calculateName(typeDefinition));
        }
      }

      if (exampleResource.getRepresentationMetadata() != null && exampleResource.getRepresentationMetadata().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getRepresentationMetadata().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.jaxrs.ResourceMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.