use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class PortletCacheControlServiceImplTest method testGetCacheControlDefault.
@Test
public void testGetCacheControlDefault() {
MockHttpServletRequest httpRequest = new MockHttpServletRequest();
MockPortletWindowId portletWindowId = new MockPortletWindowId("123");
MockPortletDefinitionId portletDefinitionId = new MockPortletDefinitionId(789);
when(portletDescriptor.getCacheScope()).thenReturn(null);
final IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
final IPortletWindow portletWindow = mock(IPortletWindow.class);
final IPortletEntity portletEntity = mock(IPortletEntity.class);
when(portletWindowRegistry.getPortletWindow(httpRequest, portletWindowId)).thenReturn(portletWindow);
when(portletWindow.getPortletEntity()).thenReturn(portletEntity);
when(portletWindow.getWindowState()).thenReturn(WindowState.NORMAL);
when(portletWindow.getPortletMode()).thenReturn(PortletMode.VIEW);
when(portletEntity.getPortletDefinitionId()).thenReturn(portletDefinitionId);
when(portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId)).thenReturn(portletDescriptor);
final CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> cacheState = cacheControlService.getPortletRenderState(httpRequest, portletWindowId);
final CacheControl cacheControl = cacheState.getCacheControl();
assertFalse(cacheControl.isPublicScope());
assertNull(cacheControl.getETag());
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class ThreadNamingPortletExecutionInterceptorAdaptor method getFname.
protected String getFname(HttpServletRequest request, IPortletWindowId portletWindowId) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
if (portletWindow == null) {
logger.warn("Failed to resolve IPortletWindow for id: " + portletWindowId + ", the id will be used instead of the fname");
return portletWindowId.toString();
}
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
return portletDefinition.getFName();
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class PortletWindowRegistryImpl method wrapPortletWindowData.
protected IPortletWindow wrapPortletWindowData(HttpServletRequest request, PortletWindowData portletWindowData) {
final IPortletEntityId portletEntityId = portletWindowData.getPortletEntityId();
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
if (portletEntity == null) {
return null;
}
final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinition.getPortletDefinitionId());
if (portletDescriptor == null) {
return null;
}
final IPortletWindow portletWindow = new PortletWindowImpl(portletDescriptor, portletEntity, portletWindowData);
logger.trace("Wrapping PortletWindowData {} as IPortletWindow", portletWindow.getPortletWindowId());
return portletWindow;
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getPortletWindowId.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.registry.IPortletWindowRegistry#getPortletWindowId(java.lang.String)
*/
@Override
public PortletWindowIdImpl getPortletWindowId(HttpServletRequest request, String portletWindowId) {
Validate.notNull(portletWindowId, "portletWindowId can not be null");
final String entityIdStr = PortletWindowIdStringUtils.parsePortletEntityId(portletWindowId);
final String instanceId;
if (!PortletEntityIdStringUtils.hasCorrectNumberOfParts(entityIdStr) || !PortletWindowIdStringUtils.hasCorrectNumberOfParts(portletWindowId)) {
throw new IllegalArgumentException("Provided portlet window ID '" + portletWindowId + "' is not valid");
}
if (PortletWindowIdStringUtils.hasPortletWindowInstanceId(portletWindowId)) {
instanceId = PortletWindowIdStringUtils.parsePortletWindowInstanceId(portletWindowId);
} else {
instanceId = null;
}
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, entityIdStr);
if (portletEntity == null) {
throw new IllegalArgumentException("No parent IPortletEntity found for id '" + entityIdStr + "' from portlet window id: " + portletWindowId);
}
return createPortletWindowId(instanceId, portletEntity.getPortletEntityId());
}
use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getOrCreateDefaultPortletWindow.
@Override
public IPortletWindow getOrCreateDefaultPortletWindow(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
Validate.notNull(request, "HttpServletRequest cannot be null");
Validate.notNull(portletDefinitionId, "portletDefinition cannot be null");
final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreateDefaultPortletEntity(request, portletDefinitionId);
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
return this.getOrCreateDefaultPortletWindow(request, portletEntityId);
}
Aggregations