String encodedForPath = ChromatticPersister.PortletNameFormatter.encode(portletId);
PortletStateContextMapping pscm = session.findByPath(PortletStateContextMapping.class, PATH + encodedForPath);
if (pscm == null)
{
PortletStateContextsMapping portletStateContexts = getContexts(session);
pscm = portletStateContexts.createPortletStateContext(portletId);
portletStateContexts.getPortletStateContexts().add(pscm);
}
PortletStateMapping psm = pscm.getState();
psm.setPortletID(pscm.getPortletId());
psm.setProperties(propertyMap);