docs: @Override
      public IPortletEntity getOrCreatePortletEntity(
              HttpServletRequest request,
              IPortletDefinitionId portletDefinitionId,
              String layoutNodeId,
              int userId) {
          final PortletEntityCache<IPortletEntity> portletEntityCache = getPortletEntityMap(request);
  
          // Try just getting an existing entity first
          IPortletEntity portletEntity =
                  this.getPortletEntity(request, portletEntityCache, null, layoutNodeId, userId);
  
          // Found an existing entity!
          if (portletEntity != null) {
              // Verify the definition IDs match, this is a MUST in the case where the subscribed
              // portlet changes
              final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
              if (portletDefinitionId.equals(portletDefinition.getPortletDefinitionId())) {
                  return portletEntity;
              }
  
              // Remove the entity if the definition IDs don't match
              this.logger.warn(
                      "Found portlet entity '{}' is not the correct entity for portlet definition id: {}. The entity will be deleted and a new one created.",
                      portletEntity,
                      portletDefinitionId);
              this.deletePortletEntity(request, portletEntity, false);
          }
  
          // Create the entity data object and store it in the session map (if not already there)
          final PortletEntityCache<PortletEntityData> portletEntityDataMap =
                  this.getPortletEntityDataMap(request);
  
          final IPortletEntityId portletEntityId =
                  this.createConsistentPortletEntityId(portletDefinitionId, layoutNodeId, userId);
          PortletEntityData portletEntityData =
                  new PortletEntityData(portletEntityId, portletDefinitionId, layoutNodeId, userId);
          portletEntityData = portletEntityDataMap.storeIfAbsentEntity(portletEntityData);
  
          portletEntity = wrapPortletEntityData(portletEntityData);
  
          // Stick the wrapper in the request map
          portletEntity = portletEntityCache.storeIfAbsentEntity(portletEntity);
  
          return portletEntity;
      }