Tabnine Logo
org.restlet.ext.platform.internal.conversion
Code IndexAdd Tabnine to your IDE (free)

How to use org.restlet.ext.platform.internal.conversion

Best Java code snippets using org.restlet.ext.platform.internal.conversion (Showing top 20 results out of 315)

origin: org.restlet.osgi/org.restlet.ext.platform

  /**
   * Indicates if the given resource listing and list of API declarations
   * match.
   * 
   * @param resourceListing
   *            The Swagger resource listing.
   * @param apiDeclarations
   *            The list of Swagger API declarations.
   * @throws org.restlet.ext.platform.internal.conversion.TranslationException
   */
  private static void validate(ResourceListing resourceListing,
      Map<String, ApiDeclaration> apiDeclarations)
      throws TranslationException {
    int rlSize = resourceListing.getApis().size();
    int adSize = apiDeclarations.size();
    if (rlSize < adSize) {
      throw new TranslationException("file",
          "Some API declarations are not mapped in your resource listing");
    } else if (rlSize > adSize) {
      throw new TranslationException("file",
          "Some API declarations are missing");
    }
  }
}
origin: org.restlet.jee/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  swagger = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, Swagger.class);
} else {
  File swaggerFile = new File(swaggerUrl);
    swagger = Json.mapper().readValue(swaggerFile, Swagger.class);
  } catch (Exception e) {
    throw new TranslationException("file", e.getMessage());
return Swagger2Reader.translate(swagger);
origin: org.restlet.osgi/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  LOGGER.log(Level.FINE, "Reading file: " + swaggerUrl);
  resourceListing = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, ResourceListing.class);
  for (ResourceListingApi api : resourceListing.getApis()) {
    LOGGER.log(Level.FINE,
        "Reading file: " + swaggerUrl + api.getPath());
    apis.put(
        api.getPath(),
        ImportUtils.getAndDeserialize(swaggerUrl + api.getPath(), userName, password,
            ApiDeclaration.class));
    String basePath = resourceListingFile.getParent();
    LOGGER.log(Level.FINE, "Base path: " + basePath);
    for (ResourceListingApi api : resourceListing.getApis()) {
      LOGGER.log(Level.FINE,
          "Reading file " + basePath + api.getPath());
      apis.put(api.getPath(), om.readValue(new File(basePath
          + api.getPath()), ApiDeclaration.class));
    throw new TranslationException("file", e.getMessage());
return SwaggerReader.translate(resourceListing, apis);
origin: org.restlet.osgi/org.restlet.ext.platform

  Definition definition = new Definition();
  definition.setContract(new Contract());
  Endpoint endpoint = new Endpoint(apiDeclaration.getBasePath());
  definition.getEndpoints().add(endpoint);
  fillEndpointAuthorization(apiDeclaration.getAuthorizations(), endpoint);
  fillContract(contract, apiDeclaration, new ArrayList<String>(), null, null);
  return definition;
} catch (Exception e) {
  throw new TranslationException(
      "compliance",
      "Impossible to read your API definition, check your Swagger specs compliance",
origin: org.restlet.jse/org.restlet.ext.platform

ClientResource cr = createAuthenticatedClientResource(url, userName, password);
representation = cr.get();
  throw new TranslationException("file", "Could not deserialize object at " + url +
      " as " + clazz.getName(), e);
origin: org.restlet.jse/org.restlet.ext.platform

private static void fillRwadefResponses(Operation swaggerOperation,
    org.restlet.ext.platform.internal.model.Operation operation,
    Contract contract, Map<String, Object> parameters) {
  if (swaggerOperation == null) {
    return;
  }
  if (swaggerOperation.getResponses() != null) {
    for (String key : swaggerOperation.getResponses().keySet()) {
      Response swaggerResponse = swaggerOperation.getResponses().get(key);
      org.restlet.ext.platform.internal.model.Response response =
          new org.restlet.ext.platform.internal.model.Response();
      int statusCode;
      try {
        statusCode = Integer.parseInt(key);
        response.setCode(statusCode);
      } catch (Exception e) {
        // TODO: what to do with "Default" responses ?
        LOGGER.warning("Response " + key + " for operation " + swaggerOperation.getOperationId() +
            " could not be retrieved because its key is not a valid status code.");
        continue;
      }
      response.setDescription(swaggerResponse.getDescription());
      response.setName(ConversionUtils.generateResponseName(statusCode));
      fillOutputPayload(swaggerResponse, response, swaggerOperation, contract, parameters);
      operation.getResponses().add(response);
    }
  }
}
origin: org.restlet.jee/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  LOGGER.log(Level.FINE, "Reading file: " + swaggerUrl);
  resourceListing = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, ResourceListing.class);
  for (ResourceListingApi api : resourceListing.getApis()) {
    LOGGER.log(Level.FINE,
        "Reading file: " + swaggerUrl + api.getPath());
    apis.put(
        api.getPath(),
        ImportUtils.getAndDeserialize(swaggerUrl + api.getPath(), userName, password,
            ApiDeclaration.class));
    String basePath = resourceListingFile.getParent();
    LOGGER.log(Level.FINE, "Base path: " + basePath);
    for (ResourceListingApi api : resourceListing.getApis()) {
      LOGGER.log(Level.FINE,
          "Reading file " + basePath + api.getPath());
      apis.put(api.getPath(), om.readValue(new File(basePath
          + api.getPath()), ApiDeclaration.class));
    throw new TranslationException("file", e.getMessage());
return SwaggerReader.translate(resourceListing, apis);
origin: org.restlet.gae/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  swagger = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, Swagger.class);
} else {
  File swaggerFile = new File(swaggerUrl);
    swagger = Json.mapper().readValue(swaggerFile, Swagger.class);
  } catch (Exception e) {
    throw new TranslationException("file", e.getMessage());
return Swagger2Reader.translate(swagger);
origin: org.restlet.gae/org.restlet.ext.platform

ClientResource cr = createAuthenticatedClientResource(url, userName, password);
representation = cr.get();
  throw new TranslationException("file", "Could not deserialize object at " + url +
      " as " + clazz.getName(), e);
origin: org.restlet.jse/org.restlet.ext.platform

  /**
   * Indicates if the given resource listing and list of API declarations
   * match.
   * 
   * @param resourceListing
   *            The Swagger resource listing.
   * @param apiDeclarations
   *            The list of Swagger API declarations.
   * @throws org.restlet.ext.platform.internal.conversion.TranslationException
   */
  private static void validate(ResourceListing resourceListing,
      Map<String, ApiDeclaration> apiDeclarations)
      throws TranslationException {
    int rlSize = resourceListing.getApis().size();
    int adSize = apiDeclarations.size();
    if (rlSize < adSize) {
      throw new TranslationException("file",
          "Some API declarations are not mapped in your resource listing");
    } else if (rlSize > adSize) {
      throw new TranslationException("file",
          "Some API declarations are missing");
    }
  }
}
origin: org.restlet.jee/org.restlet.ext.platform

private static void fillRwadefResponses(Operation swaggerOperation,
    org.restlet.ext.platform.internal.model.Operation operation,
    Contract contract, Map<String, Object> parameters) {
  if (swaggerOperation == null) {
    return;
  }
  if (swaggerOperation.getResponses() != null) {
    for (String key : swaggerOperation.getResponses().keySet()) {
      Response swaggerResponse = swaggerOperation.getResponses().get(key);
      org.restlet.ext.platform.internal.model.Response response =
          new org.restlet.ext.platform.internal.model.Response();
      int statusCode;
      try {
        statusCode = Integer.parseInt(key);
        response.setCode(statusCode);
      } catch (Exception e) {
        // TODO: what to do with "Default" responses ?
        LOGGER.warning("Response " + key + " for operation " + swaggerOperation.getOperationId() +
            " could not be retrieved because its key is not a valid status code.");
        continue;
      }
      response.setDescription(swaggerResponse.getDescription());
      response.setName(ConversionUtils.generateResponseName(statusCode));
      fillOutputPayload(swaggerResponse, response, swaggerOperation, contract, parameters);
      operation.getResponses().add(response);
    }
  }
}
origin: org.restlet.jse/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  LOGGER.log(Level.FINE, "Reading file: " + swaggerUrl);
  resourceListing = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, ResourceListing.class);
  for (ResourceListingApi api : resourceListing.getApis()) {
    LOGGER.log(Level.FINE,
        "Reading file: " + swaggerUrl + api.getPath());
    apis.put(
        api.getPath(),
        ImportUtils.getAndDeserialize(swaggerUrl + api.getPath(), userName, password,
            ApiDeclaration.class));
    String basePath = resourceListingFile.getParent();
    LOGGER.log(Level.FINE, "Base path: " + basePath);
    for (ResourceListingApi api : resourceListing.getApis()) {
      LOGGER.log(Level.FINE,
          "Reading file " + basePath + api.getPath());
      apis.put(api.getPath(), om.readValue(new File(basePath
          + api.getPath()), ApiDeclaration.class));
    throw new TranslationException("file", e.getMessage());
return SwaggerReader.translate(resourceListing, apis);
origin: org.restlet.osgi/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  swagger = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, Swagger.class);
} else {
  File swaggerFile = new File(swaggerUrl);
    swagger = Json.mapper().readValue(swaggerFile, Swagger.class);
  } catch (Exception e) {
    throw new TranslationException("file", e.getMessage());
return Swagger2Reader.translate(swagger);
origin: org.restlet.jee/org.restlet.ext.platform

ClientResource cr = createAuthenticatedClientResource(url, userName, password);
representation = cr.get();
  throw new TranslationException("file", "Could not deserialize object at " + url +
      " as " + clazz.getName(), e);
origin: org.restlet.gae/org.restlet.ext.platform

  /**
   * Indicates if the given resource listing and list of API declarations
   * match.
   * 
   * @param resourceListing
   *            The Swagger resource listing.
   * @param apiDeclarations
   *            The list of Swagger API declarations.
   * @throws org.restlet.ext.platform.internal.conversion.TranslationException
   */
  private static void validate(ResourceListing resourceListing,
      Map<String, ApiDeclaration> apiDeclarations)
      throws TranslationException {
    int rlSize = resourceListing.getApis().size();
    int adSize = apiDeclarations.size();
    if (rlSize < adSize) {
      throw new TranslationException("file",
          "Some API declarations are not mapped in your resource listing");
    } else if (rlSize > adSize) {
      throw new TranslationException("file",
          "Some API declarations are missing");
    }
  }
}
origin: org.restlet.osgi/org.restlet.ext.platform

private static void fillRwadefResponses(Operation swaggerOperation,
    org.restlet.ext.platform.internal.model.Operation operation,
    Contract contract, Map<String, Object> parameters) {
  if (swaggerOperation == null) {
    return;
  }
  if (swaggerOperation.getResponses() != null) {
    for (String key : swaggerOperation.getResponses().keySet()) {
      Response swaggerResponse = swaggerOperation.getResponses().get(key);
      org.restlet.ext.platform.internal.model.Response response =
          new org.restlet.ext.platform.internal.model.Response();
      int statusCode;
      try {
        statusCode = Integer.parseInt(key);
        response.setCode(statusCode);
      } catch (Exception e) {
        // TODO: what to do with "Default" responses ?
        LOGGER.warning("Response " + key + " for operation " + swaggerOperation.getOperationId() +
            " could not be retrieved because its key is not a valid status code.");
        continue;
      }
      response.setDescription(swaggerResponse.getDescription());
      response.setName(ConversionUtils.generateResponseName(statusCode));
      fillOutputPayload(swaggerResponse, response, swaggerOperation, contract, parameters);
      operation.getResponses().add(response);
    }
  }
}
origin: org.restlet.gae/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  LOGGER.log(Level.FINE, "Reading file: " + swaggerUrl);
  resourceListing = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, ResourceListing.class);
  for (ResourceListingApi api : resourceListing.getApis()) {
    LOGGER.log(Level.FINE,
        "Reading file: " + swaggerUrl + api.getPath());
    apis.put(
        api.getPath(),
        ImportUtils.getAndDeserialize(swaggerUrl + api.getPath(), userName, password,
            ApiDeclaration.class));
    String basePath = resourceListingFile.getParent();
    LOGGER.log(Level.FINE, "Base path: " + basePath);
    for (ResourceListingApi api : resourceListing.getApis()) {
      LOGGER.log(Level.FINE,
          "Reading file " + basePath + api.getPath());
      apis.put(api.getPath(), om.readValue(new File(basePath
          + api.getPath()), ApiDeclaration.class));
    throw new TranslationException("file", e.getMessage());
return SwaggerReader.translate(resourceListing, apis);
origin: org.restlet.jse/org.restlet.ext.platform

  throw new TranslationException("url", "You did not provide any URL");
if (ImportUtils.isRemoteUrl(swaggerUrl)) {
  swagger = ImportUtils.getAndDeserialize(swaggerUrl, userName, password, Swagger.class);
} else {
  File swaggerFile = new File(swaggerUrl);
    swagger = Json.mapper().readValue(swaggerFile, Swagger.class);
  } catch (Exception e) {
    throw new TranslationException("file", e.getMessage());
return Swagger2Reader.translate(swagger);
origin: org.restlet.osgi/org.restlet.ext.platform

ClientResource cr = createAuthenticatedClientResource(url, userName, password);
representation = cr.get();
  throw new TranslationException("file", "Could not deserialize object at " + url +
      " as " + clazz.getName(), e);
origin: org.restlet.jee/org.restlet.ext.platform

  /**
   * Indicates if the given resource listing and list of API declarations
   * match.
   * 
   * @param resourceListing
   *            The Swagger resource listing.
   * @param apiDeclarations
   *            The list of Swagger API declarations.
   * @throws org.restlet.ext.platform.internal.conversion.TranslationException
   */
  private static void validate(ResourceListing resourceListing,
      Map<String, ApiDeclaration> apiDeclarations)
      throws TranslationException {
    int rlSize = resourceListing.getApis().size();
    int adSize = apiDeclarations.size();
    if (rlSize < adSize) {
      throw new TranslationException("file",
          "Some API declarations are not mapped in your resource listing");
    } else if (rlSize > adSize) {
      throw new TranslationException("file",
          "Some API declarations are missing");
    }
  }
}
org.restlet.ext.platform.internal.conversion

Most used classes

  • ConversionUtils
  • ImportUtils
  • TranslationException
  • RamlTranslator
    Tools library for converting Restlet Web API Definition to and from RAML documentation.
  • RamlUtils
    Utility class for RAML java beans.
  • SwaggerTypeFormat,
  • SwaggerTypes,
  • SwaggerUtils,
  • SwaggerWriter,
  • ApiDeclaration,
  • ApiInfo,
  • AuthorizationsDeclaration,
  • BasicAuthorizationDeclaration,
  • ItemsDeclaration,
  • ModelDeclaration,
  • OAuth2AuthorizationDeclaration,
  • ResourceDeclaration,
  • ResourceListing,
  • ResourceListingApi
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now