@Override
    public void configurationUpdated(ServiceVersionMappingList mappings) {
      configuredMappings.clear();

      for (ServiceVersionMapping mapping : mappings.getVersionMapping()) {
        configuredMappings.put(mapping.getId(), mapping);
      }

      isInitialized = true;
    }
Ejemplo n.º 2
0
  public Destination getHostForVersionMapping(ServiceVersionMapping mapping)
      throws VersionedHostNotFoundException {
    final Destination host = configuredHosts.get(mapping.getPpDestId());

    if (host == null) {
      throw new VersionedHostNotFoundException(
          "Endpoin: " + mapping.getPpDestId() + " is not specified in the system model");
    }

    return host;
  }
Ejemplo n.º 3
0
 public com.rackspace.papi.components.versioning.config.MediaType getMatchingMediaType(
     ServiceVersionMapping serviceVersionMapping, MediaType preferedMediaType) {
   final MediaTypeList configuredMediaTypes = serviceVersionMapping.getMediaTypes();
   if (configuredMediaTypes == null) {
     return null;
   }
   for (com.rackspace.papi.components.versioning.config.MediaType configuredMediaType :
       configuredMediaTypes.getMediaType()) {
     HeaderValue mediaType = new HeaderValueParser(configuredMediaType.getType()).parse();
     if (preferedMediaType.equalsTo(mediaType)) {
       return configuredMediaType;
     }
   }
   return null;
 }