public PortletContext importPortlet(PortletStateType stateType, PortletContext originalPortletContext)
throws PortletInvokerException, IllegalArgumentException
{
// The original portletcontext is the non cloned version and should be one the PC available from the getPortlets operation
RegistrationSPI registration = getRegistrationAsSPI();
if (registration != null)
{
checkOperationIsAllowed(originalPortletContext, registration, "importPortlet");
PortletContext newPortletContext = super.importPortlet(stateType, originalPortletContext);
if (!newPortletContext.getId().equals(originalPortletContext.getId()))
{
try
{
registration.addPortletContext(newPortletContext);
}
catch (RegistrationException e)
{
throw new PortletInvokerException("Couldn't add portlet context '" + newPortletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
}
}
return newPortletContext;
}