Ejemplo n.º 1
0
  /**
   * Method for getting the list of componentType.
   *
   * @return res ResponseObject. {@literal Body should be HashMap<ComponentType,
   *     list[ComponentManager.property]>}.
   */
  private Response getComponentTypes() {
    ComponentTypesHash componentTypesHash = new ComponentTypesHash();

    for (String compMgrId : componentMgrsSet) {
      Response resp = getComponentTypes(compMgrId);
      if (resp.isError("GET")) {
        log.warn("invalid GET:" + resp.statusCode);
        return resp;
      }
      try {
        ComponentTypesHash types = resp.getBody(ComponentTypesHash.class);
        for (String type : types.keySet()) {
          if (componentTypesHash.containsKey(type)) {
            ComponentType compType = componentTypesHash.get(type);
            compType.addCmId(compMgrId);
          } else {
            ComponentType compType = types.get(type).clone();
            compType.addCmId(compMgrId);
            componentTypesHash.put(type, compType);
          }
        }
      } catch (ParseBodyException e) {
        return new Response(Response.INTERNAL_SERVER_ERROR, "Failed GET component_types.");
      }
    }
    return new Response(Response.OK, componentTypesHash);
  }
Ejemplo n.º 2
0
 /**
  * Method for getting the CompoentManager's componentTypes.
  *
  * @return res ResponseObject. {@literal Body should be HashMap<String, ComponentType>}.
  */
 private Response getComponentTypes(String compmgrId) {
   try {
     Response resp = request(compmgrId, Method.GET, "component_types", null);
     if (resp.isError("GET")) {
       log.warn("invalid GET:" + resp.statusCode);
       return resp;
     }
     ComponentTypesHash types = resp.getBody(ComponentTypesHash.class);
     return new Response(Response.OK, types);
   } catch (Exception ex) {
     log.error("Recieved Message Exception.", ex);
     return new Response(Response.INTERNAL_SERVER_ERROR, "Failed GET component_types.");
   }
 }