@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()); }
public PortletWindowIdImpl(IPortletEntityId portletEntityId, String windowInstanceId) { Validate.notNull(portletEntityId, "portletEntityId can not be null"); this.portletEntityId = portletEntityId; this.windowInstanceId = windowInstanceId; this.compositeIdString = PortletWindowIdStringUtils.format(portletEntityId.getStringId(), windowInstanceId); }
public static String convertToDelegateLayoutNodeId(final String portletWindowIdString) { final String portletEntityIdString = parsePortletEntityId(portletWindowIdString); final String portletWindowInstanceIdString = parsePortletWindowInstanceId(portletWindowIdString); final String converted = PortletEntityIdStringUtils.convertToDelegateLayoutNodeId(portletEntityIdString); return (portletWindowInstanceIdString == null) ? converted : converted + ID_PART_SEPARATOR + portletWindowInstanceIdString; }
@Test public void parsePortletEntityIdTest() { String portletEntityId = PortletWindowIdStringUtils.parsePortletEntityId("71_u54_12.2"); assertNotNull(portletEntityId); assertEquals(portletEntityId, "71_u54_12"); }
@Test public void parsePortletWindowInstanceIdTest() { String portletWindowInstanceId = PortletWindowIdStringUtils.parsePortletWindowInstanceId("88_n149_52.tw"); assertNotNull(portletWindowInstanceId); assertEquals(portletWindowInstanceId, "tw"); }
@Test public void hasCorrectNumberOfPartsTest() { Boolean result = PortletWindowIdStringUtils.hasCorrectNumberOfParts("88_n149_52.tw"); assertTrue(result); } }
@Override public IPortletEntity getOrCreateDelegatePortletEntity( HttpServletRequest request, IPortletWindowId parentPortletWindowId, IPortletDefinitionId delegatePortletDefinitionId) { // Create a special synthetic layout node ID for the delegate entity final String layoutNodeId = PortletWindowIdStringUtils.convertToDelegateLayoutNodeId( parentPortletWindowId.toString()); // Grab the current user final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request); final IPerson person = userInstance.getPerson(); final int userId = person.getID(); // Use the general API, the only thing special is the layout node id return getOrCreatePortletEntity(request, delegatePortletDefinitionId, layoutNodeId, userId); }
parseUserIdAndOtherParts(portletWindowIdString); if (userIdAndOtherParts.portletWindowInstanceId == null) { return new String[] {portletWindowIdString}; PortletEntityIdStringUtils.format( portletDefinitionId, layoutNodeId, userIdAndOtherParts.userId); return createPartsArray( portletEntityId, userIdAndOtherParts.portletWindowInstanceId,
@Override public IPortletEntity getOrCreateDelegatePortletEntity( HttpServletRequest request, IPortletWindowId parentPortletWindowId, IPortletDefinitionId delegatePortletDefinitionId) { // Create a special synthetic layout node ID for the delegate entity final String layoutNodeId = PortletWindowIdStringUtils.convertToDelegateLayoutNodeId( parentPortletWindowId.toString()); // Grab the current user final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request); final IPerson person = userInstance.getPerson(); final int userId = person.getID(); // Use the general API, the only thing special is the layout node id return getOrCreatePortletEntity(request, delegatePortletDefinitionId, layoutNodeId, userId); }
@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()); }