docs: protected IPortletEntity getPortletEntity(
              HttpServletRequest request,
              PortletEntityCache<IPortletEntity> portletEntityCache,
              IPortletEntityId portletEntityId,
              String layoutNodeId,
              int userId) {
  
          IPortletEntity portletEntity;
  
          // First look in the request map
          if (portletEntityId != null) {
              portletEntity = portletEntityCache.getEntity(portletEntityId);
          } else {
              portletEntity = portletEntityCache.getEntity(layoutNodeId, userId);
          }
  
          if (portletEntity != null) {
              logger.trace(
                      "Found IPortletEntity {} in request cache", portletEntity.getPortletEntityId());
              return portletEntity;
          }
  
          // Didn't find it, next look in the session map
          final PortletEntityCache<PortletEntityData> portletEntityDataMap =
                  this.getPortletEntityDataMap(request);
          final PortletEntityData portletEntityData;
          if (portletEntityId != null) {
              portletEntityData = portletEntityDataMap.getEntity(portletEntityId);
          } else {
              portletEntityData = portletEntityDataMap.getEntity(layoutNodeId, userId);
          }
  
          if (portletEntityData != null) {
  
              // Stick the entity wrapper in the request map (if it wasn't already added by another
              // thread)
              portletEntity =
                      portletEntityCache.storeIfAbsentEntity(
                              portletEntityData.getPortletEntityId(),
                              new Function<IPortletEntityId, IPortletEntity>() {
                                  @Override
                                  public IPortletEntity apply(IPortletEntityId input) {
                                      // Found a session stored entity, wrap it to make it a real
                                      // IPortletEntity
                                      logger.trace(
                                              "Found PortletEntityData {} in session cache, caching wrapper in the request",
                                              portletEntityData.getPortletEntityId());
  
                                      return wrapPortletEntityData(portletEntityData);
                                  }
                              });
  
              return portletEntity;
          }
  
          // Still didn't find it, look in the persistent store
          if (portletEntityId != null) {
              if (portletEntityId instanceof PortletEntityIdImpl) {
                  final PortletEntityIdImpl consistentPortletEntityId =
                          (PortletEntityIdImpl) portletEntityId;
                  final String localLayoutNodeId = consistentPortletEntityId.getLayoutNodeId();
                  final int localUserId = consistentPortletEntityId.getUserId();
  
                  portletEntity =
                          this.portletEntityDao.getPortletEntity(localLayoutNodeId, localUserId);
              } else {
                  portletEntity = this.portletEntityDao.getPortletEntity(portletEntityId);
              }
          } else {
              portletEntity = this.portletEntityDao.getPortletEntity(layoutNodeId, userId);
          }
  
          // Found a persistent entity, wrap it to make the id consistent between the persistent and
          // session stored entities
          if (portletEntity != null) {
              final IPortletEntityId consistentPortletEntityId =
                      this.createConsistentPortletEntityId(portletEntity);
  
              final IPortletEntity anonPortletEntity = portletEntity;
  
              // Stick the entity wrapper in the request map (if it wasn't already added by another
              // thread)
              portletEntity =
                      portletEntityCache.storeIfAbsentEntity(
                              consistentPortletEntityId,
                              new Function<IPortletEntityId, IPortletEntity>() {
                                  @Override
                                  public IPortletEntity apply(IPortletEntityId input) {
                                      logger.trace(
                                              "Found persistent IPortletEntity {}, mapped id to {}, caching the wrapper in the request",
                                              anonPortletEntity.getPortletEntityId(),
                                              consistentPortletEntityId);
                                      return new PersistentPortletEntityWrapper(
                                              anonPortletEntity, consistentPortletEntityId);
                                  }
                              });
  
              return portletEntity;
          }
  
          // Didn't find an entity, just return null
          return null;
      }