// instance context
ExoPortletInstanceContext instanceContext;
// TODO: we should not be having these wsrp specific conditions through the code like
// this, it should either work the same was as normal portlets or abstracted out to another class.
if (ApplicationType.WSRP_PORTLET.equals(state.getApplicationType())) {
WSRP wsrp = (WSRP) preferencesPortletContext.getState();
AccessMode accessMode = AccessMode.CLONE_BEFORE_WRITE;
if (wsrp.getState() != null) {
StatefulPortletContext statefulPortletContext = StatefulPortletContext.create(
preferencesPortletContext.getId(), PortletStateType.OPAQUE, wsrp.getState());
invocation.setTarget(statefulPortletContext);
} else {
PortletContext portletContext = PortletContext.createPortletContext(preferencesPortletContext.getId());
invocation.setTarget(portletContext);
}
// if the portlet is a cloned one already, we can modify it directly instead of requesting a clone
if (wsrp.isCloned()) {
accessMode = AccessMode.READ_WRITE;
}
instanceContext = new ExoPortletInstanceContext(preferencesPortletContext.getId(), accessMode);
} else {
instanceContext = new ExoPortletInstanceContext(preferencesPortletContext.getId());