/**
   * Method that search the PlatformComponentProfiles tha mach with the parameters
   *
   * @param platformComponentType
   * @param networkServiceType
   * @param communicationCloudClientIdentity
   * @return List<PlatformComponentProfile>
   */
  private List<PlatformComponentProfile> searchProfileByCommunicationCloudClientIdentity(
      PlatformComponentType platformComponentType,
      NetworkServiceType networkServiceType,
      String communicationCloudClientIdentity) {

    /*
     * Prepare the list
     */
    List<PlatformComponentProfile> temporalList = null;
    List<PlatformComponentProfile> finalFilteredList = new ArrayList<>();

    /*
     * Switch between platform component type
     */
    switch (platformComponentType) {
      case COMMUNICATION_CLOUD_SERVER:
        temporalList =
            new ArrayList<>(
                wsCommunicationCloudServer.getRegisteredCommunicationsCloudServerCache().values());
        break;

      case COMMUNICATION_CLOUD_CLIENT:
        temporalList =
            new ArrayList<>(
                wsCommunicationCloudServer.getRegisteredCommunicationsCloudClientCache().values());
        break;

      case NETWORK_SERVICE:
        temporalList =
            new ArrayList<>(
                wsCommunicationCloudServer
                    .getRegisteredNetworkServicesCache()
                    .get(networkServiceType));
        break;

        // Others
      default:
        temporalList =
            wsCommunicationCloudServer
                .getRegisteredOtherPlatformComponentProfileCache()
                .get(platformComponentType);
        break;
    }

    /*
     * Find the component that match with the CommunicationCloudClientIdentity
     */
    for (PlatformComponentProfile platformComponentProfile : temporalList) {

      if (platformComponentProfile
          .getCommunicationCloudClientIdentity()
          .equals(communicationCloudClientIdentity)) {
        finalFilteredList.add(platformComponentProfile);
      }
    }

    return finalFilteredList;
  }
  /**
   * Return the primary list from the cache filtered by the platformComponentType or
   * networkServiceType
   *
   * @param platformComponentType
   * @param networkServiceType
   * @return List<PlatformComponentProfile>
   */
  public List<PlatformComponentProfile> getPrimaryFilteredListFromCache(
      PlatformComponentType platformComponentType,
      NetworkServiceType networkServiceType,
      String clientIdentityPublicKey) {

    /*
     * Get the list
     */
    List<PlatformComponentProfile> list = new ArrayList<>();

    /*
     * Switch between platform component type
     */
    switch (platformComponentType) {
      case COMMUNICATION_CLOUD_SERVER:
        if (!wsCommunicationCloudServer.getRegisteredCommunicationsCloudServerCache().isEmpty()) {
          list =
              (List<PlatformComponentProfile>)
                  new ArrayList<>(
                          wsCommunicationCloudServer
                              .getRegisteredCommunicationsCloudServerCache()
                              .values())
                      .clone();
        }
        break;

      case COMMUNICATION_CLOUD_CLIENT:
        if (!wsCommunicationCloudServer.getRegisteredCommunicationsCloudClientCache().isEmpty()) {
          list =
              (List<PlatformComponentProfile>)
                  new ArrayList<>(
                          wsCommunicationCloudServer
                              .getRegisteredCommunicationsCloudClientCache()
                              .values())
                      .clone();
        }
        break;

      case NETWORK_SERVICE:
        if (wsCommunicationCloudServer
                .getRegisteredNetworkServicesCache()
                .containsKey(networkServiceType)
            && !wsCommunicationCloudServer
                .getRegisteredNetworkServicesCache()
                .get(networkServiceType)
                .isEmpty()) {
          list =
              (List<PlatformComponentProfile>)
                  new ArrayList<>(
                          wsCommunicationCloudServer
                              .getRegisteredNetworkServicesCache()
                              .get(networkServiceType))
                      .clone();
        }
        break;

        // Others
      default:
        if (wsCommunicationCloudServer
                .getRegisteredOtherPlatformComponentProfileCache()
                .containsKey(platformComponentType)
            && !wsCommunicationCloudServer
                .getRegisteredOtherPlatformComponentProfileCache()
                .get(platformComponentType)
                .isEmpty()) {
          list =
              (List<PlatformComponentProfile>)
                  new ArrayList<>(
                          wsCommunicationCloudServer
                              .getRegisteredOtherPlatformComponentProfileCache()
                              .get(platformComponentType))
                      .clone();
        }
        break;
    }

    /*
     * Remove the requester from the list
     */
    Iterator<PlatformComponentProfile> iterator = list.iterator();
    while (iterator.hasNext()) {

      PlatformComponentProfile platformComponentProfileRegistered = iterator.next();
      if (platformComponentProfileRegistered
          .getCommunicationCloudClientIdentity()
          .equals(clientIdentityPublicKey)) {
        System.out.println(
            "ComponentRegisteredListWebService - removing ="
                + platformComponentProfileRegistered.getName());
        iterator.remove();
      }
    }

    return list;
  }