// construct the new customization state
WSRP wsrp = new WSRP();
String portletId = portletContext.getId();
wsrp.setPortletId(portletId);
if (portletContext instanceof StatefulPortletContext) {
StatefulPortletContext context = (StatefulPortletContext) portletContext;
if (PortletStateType.OPAQUE.equals(context.getType())) {
wsrp.setState((byte[]) context.getState());
} else {
throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
}
}
// destroy existing customization as otherwise re-customizing will fail
Customization<?> customization = window.getCustomization();