Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 @Override
 public Resource filter(ApiRequest request, Object original, Resource converted) {
   if (original instanceof AuditLogRecord) {
     AuditLogRecord auditLogRecord = (AuditLogRecord) original;
     if (auditLogRecord.getResourceId() != null) {
       converted
           .getLinks()
           .put(
               "resource",
               ApiContext.getUrlBuilder()
                   .resourceReferenceLink(
                       auditLogRecord.getResourceType(),
                       String.valueOf(auditLogRecord.getResourceId())));
     }
     if (StringUtils.isNotBlank(auditLogRecord.getAuthenticatedAsIdentityId())) {
       converted
           .getLinks()
           .put(
               "authenticatedAsIdentity",
               ApiContext.getUrlBuilder()
                   .resourceReferenceLink(
                       Identity.class,
                       String.valueOf(auditLogRecord.getAuthenticatedAsIdentityId())));
     }
     Map<String, Object> data =
         (Map<String, Object>) ((AuditLogRecord) original).getData().get("fields");
     makeMap(data, "requestObject", converted);
     makeMap(data, "responseObject", converted);
   }
   return converted;
 }
Ejemplo n.º 2
0
  @Override
  public Resource filter(ApiRequest request, Object original, Resource converted) {
    boolean add = false;
    boolean hostStats = false;
    boolean containerStats = false;
    boolean project = false;

    if (original instanceof Host
        && DockerHostConstants.KIND_DOCKER.equals(((Host) original).getKind())) {
      add = true;
      hostStats = true;
      containerStats = true;
    } else if (original instanceof Instance
        && InstanceConstants.CONTAINER_LIKE.contains(((Instance) original).getKind())) {
      containerStats = true;
      add = true;
    } else if (original instanceof Account
        && AccountConstants.PROJECT_KIND.equals(((Account) original).getKind())) {
      project = true;
    } else if (original instanceof Service) {
      containerStats = true;
    }

    if (add) {
      converted
          .getLinks()
          .put(
              StatsConstants.LINK_STATS,
              ApiContext.getUrlBuilder().resourceLink(converted, StatsConstants.LINK_STATS));
    }
    if (hostStats) {
      converted
          .getLinks()
          .put(
              StatsConstants.HOST_STATS,
              ApiContext.getUrlBuilder().resourceLink(converted, StatsConstants.HOST_STATS));
    }
    if (containerStats) {
      converted
          .getLinks()
          .put(
              StatsConstants.CONTAINER_STATS,
              ApiContext.getUrlBuilder().resourceLink(converted, StatsConstants.CONTAINER_STATS));
    }
    if (project) {
      converted
          .getLinks()
          .put(
              StatsConstants.HOST_STATS,
              ApiContext.getUrlBuilder()
                  .resourceLink(
                      converted,
                      "projects/" + converted.getId() + "/" + StatsConstants.HOST_STATS));
    }

    return converted;
  }
Ejemplo n.º 3
0
 protected String getLink(ProcessDefinition def) {
   return ApiContext.getUrlBuilder()
       .resourceReferenceLink(ProcessDefinitionApi.class, def.getName())
       .toExternalForm();
 }