@Override
  protected boolean isProcessPortletRequest(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (permissionChecker.isCompanyAdmin()) {
      return true;
    }

    Group group = themeDisplay.getScopeGroup();

    if (group.isSite() && permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) {

      return true;
    }

    return false;
  }
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    HashMap<Date, ArrayList<HashMap<String, Object>>> resultado =
        new HashMap<Date, ArrayList<HashMap<String, Object>>>();
    List<TimeLinePopUp> listaPopUps = new ArrayList<TimeLinePopUp>();

    PortletPreferences prefs = renderRequest.getPreferences();
    String showInMain = prefs.getValue("showInMain", "true");
    String showItems = prefs.getValue("showItems", "true");
    String showAlerts = prefs.getValue("showAlerts", "true");

    // *********************
    // 1) Sites de LIFERAY
    // *********************
    List<Group> offices = new ArrayList<Group>();

    // Si el portlet se muestra en la pagina ppal, recorremos todas las oficianas a partir de un
    // sitio padre leido desde properties
    if (showInMain.equals("true")) {
      String mainSiteGroupId = com.liferay.util.portlet.PortletProps.get("lfvo.main.site.group.id");
      if (mainSiteGroupId != null && !"".equals(mainSiteGroupId)) {
        try {
          offices =
              GroupLocalServiceUtil.getGroups(
                  themeDisplay.getCompanyId(), Long.parseLong(mainSiteGroupId), true);

        } catch (NumberFormatException e) {
          e.printStackTrace();
          offices = GroupLocalServiceUtil.getGroups(themeDisplay.getCompanyId(), 0, true);
        }
      } else {
        offices = GroupLocalServiceUtil.getGroups(themeDisplay.getCompanyId(), 0, true);
      }
      // Si el portlet no se muestra en la pagina ppal, cogemos la oficina del sitio
    } else {
      offices.add(themeDisplay.getScopeGroup());
    }

    // *********************
    // 2) Sites de FIREBASE
    // *********************
    HashMap<String, Object> officesMap = new HashMap<String, Object>();
    try {
      DatabaseReference ref = FirebaseDatabase.getInstance().getReference("/offices/");
      Firebase firebase = new Firebase(ref.toString());
      FirebaseResponse response = firebase.get();
      officesMap = (HashMap<String, Object>) response.getBody();

    } catch (FirebaseException e2) {
      e2.printStackTrace();
    }

    if (officesMap != null) {
      for (Group office : offices) {

        HashMap<String, Object> officeBD =
            (HashMap<String, Object>)
                officesMap.get(
                    String.valueOf(office.getGroupId())); // Site Firebase <> Site Liferay
        if (officeBD != null) {

          try {
            List<Item> items = ItemLocalServiceUtil.getItems(office.getGroupId(), -1, -1);
            for (Item item : items) {

              // Si s�lo mostramos ITEMS y no ALERTS...
              if (showItems.equals("true") & showAlerts.equals("false")) {
                if (!"".equals(item.getType())
                    & !item.getType()
                        .equals("office")) { // Si tiene tipo, pero no es 'office' descartamos
                  continue;
                }
              }

              // Si s�lo mostramos ALERTS y no ITEMS...
              if (showItems.equals("false") & showAlerts.equals("true")) {
                if ("".equals(item.getType())
                    || item.getType()
                        .equals("office")) { // Si es vacio o es 'office' descartamos							
                  continue;
                }
              }

              // Si no mostramos nada...
              if (showItems.equals("false") & showAlerts.equals("false")) {
                continue;
              }

              HashMap<String, Object> miItem = new HashMap<String, Object>();

              // Creamos una fecha con formato simple
              Date createDate = item.getCreateDate();
              String fechaFormat = "";
              String fechaFormatEus = "";
              SimpleDateFormat dt1 = new SimpleDateFormat("dd/MM/yyyy");
              SimpleDateFormat dt2 = new SimpleDateFormat("yyyy/MM/dd");
              if (createDate != null) {
                fechaFormat = dt1.format(item.getCreateDate());
                fechaFormatEus = dt2.format(item.getCreateDate());
              } else {
                fechaFormat = dt1.format(item.getModifiedDate());
                fechaFormatEus = dt2.format(item.getModifiedDate());
              }

              // Quitamos la hora y minutos de la fecha original
              SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
              Date b = new Date();
              try {
                b = formatter.parse(fechaFormat);
              } catch (ParseException e) {

              }

              // PopUp - Mapa Street
              TimeLinePopUp miPopUp = new TimeLinePopUp();
              miPopUp.setDate_es(fechaFormat);
              miPopUp.setDate_eu(fechaFormatEus);
              miPopUp.setName(item.getName());
              miPopUp.setImage(this.obtenerImagenItem(item.getItemId()));
              miPopUp.setLat(String.valueOf(item.getLat()));
              miPopUp.setLng(String.valueOf(item.getLng()));

              listaPopUps.add(miPopUp);

              // HashMaps - Timeline
              miItem.put("image", this.obtenerImagenItem(item.getItemId()));
              miItem.put("name", item.getName());
              miItem.put("desc", item.getDescription());
              miItem.put("lat", item.getLat());
              miItem.put("lng", item.getLng());
              miItem.put("type", item.getType());

              if (resultado.get(b) == null) {
                resultado.put(b, new ArrayList<HashMap<String, Object>>());
              }
              resultado.get(b).add(miItem);
            }
          } catch (PortalException e) {
            e.printStackTrace();
          }
        }
      }
    }

    // Lista de PopUps
    Type listType = new TypeToken<List<TimeLinePopUp>>() {}.getType();
    Gson gson = new Gson();
    String json = gson.toJson(listaPopUps, listType);

    renderRequest.setAttribute("popUps", json);

    // En vez de ordenar el hashmap, ordenamos las keys
    ArrayList<Date> miArray = new ArrayList<Date>();
    for (Date date : resultado.keySet()) {
      miArray.add(date);
    }
    Collections.sort(miArray);

    renderRequest.setAttribute("resultado", resultado);
    renderRequest.setAttribute("orderedKeys", miArray);

    super.doView(renderRequest, renderResponse);
  }