/** {@inheritDoc} */
  @Override
  public Collection<CacheEntity> getCaches(final UriInfo info) {
    LOG.debug(
        String.format("Invoking CachesResourceServiceImpl.getCaches: %s", info.getRequestUri()));

    validator.validateSafe(info);

    String cacheManagerNames =
        info.getPathSegments().get(1).getMatrixParameters().getFirst("names");
    Set<String> cmNames =
        cacheManagerNames == null
            ? null
            : new HashSet<String>(Arrays.asList(cacheManagerNames.split(",")));

    String cacheNames = info.getPathSegments().get(2).getMatrixParameters().getFirst("names");
    Set<String> cNames =
        cacheNames == null ? null : new HashSet<String>(Arrays.asList(cacheNames.split(",")));

    MultivaluedMap<String, String> qParams = info.getQueryParameters();
    List<String> attrs = qParams.get(ATTR_QUERY_KEY);
    Set<String> cAttrs = attrs == null || attrs.isEmpty() ? null : new HashSet<String>(attrs);

    try {
      return entityResourceFactory.createCacheEntities(cmNames, cNames, cAttrs);
    } catch (ServiceExecutionException e) {
      throw new ResourceRuntimeException(
          "Failed to get caches", e, Response.Status.BAD_REQUEST.getStatusCode());
    }
  }
  /** {@inheritDoc} */
  public Collection<CacheManagerEntity> getCacheManagers(UriInfo info) {
    LOG.info(String.format("Invoking getCacheManagers: %s", info.getRequestUri()));

    validator.validateSafe(info);

    String names = info.getPathSegments().get(1).getMatrixParameters().getFirst("names");
    Set<String> cmNames =
        names == null ? null : new HashSet<String>(Arrays.asList(names.split(",")));

    MultivaluedMap<String, String> qParams = info.getQueryParameters();
    List<String> attrs = qParams.get(ATTR_QUERY_KEY);
    Set<String> cmAttrs = attrs == null || attrs.isEmpty() ? null : new HashSet<String>(attrs);

    try {
      return entityResourceFactory.createCacheManagerEntities(cmNames, cmAttrs);
    } catch (ServiceExecutionException e) {
      LOG.error("Failed to get cache managers.", e.getCause());
      throw new WebApplicationException(
          Response.status(Response.Status.BAD_REQUEST).entity(e.getCause().getMessage()).build());
    }
  }
Esempio n. 3
0
  @Override
  public Collection<CacheManagerConfigEntity> getCacheManagerConfigs(UriInfo info) {
    LOG.debug(
        String.format(
            "Invoking CacheManagerConfigsResourceServiceImpl.getXMLCacheManagerConfigs: %s",
            info.getRequestUri()));

    validator.validateSafe(info);

    String names = info.getPathSegments().get(1).getMatrixParameters().getFirst("names");
    Set<String> cmNames =
        names == null ? null : new HashSet<String>(Arrays.asList(names.split(",")));

    try {
      return entityResourceFactory.createCacheManagerConfigEntities(cmNames);
    } catch (ServiceExecutionException e) {
      throw new ResourceRuntimeException(
          "Failed to get xml cache manager configs",
          e,
          Response.Status.BAD_REQUEST.getStatusCode());
    }
  }