} else { final String portletDefinitionId = PortletEntityIdStringUtils.parsePortletDefinitionId(portletWindowIdString); final String layoutNodeId = PortletEntityIdStringUtils.parseLayoutNodeId(portletWindowIdString); final String portletEntityId = PortletEntityIdStringUtils.format( portletDefinitionId, layoutNodeId, userIdAndOtherParts.userId); return createPartsArray(
private static UserIdAndOtherParts parseUserIdAndOtherParts( final String portletWindowIdString) { final UserIdAndOtherParts result = new UserIdAndOtherParts(); final String userId = PortletEntityIdStringUtils.parseUserIdAsString(portletWindowIdString); final String[] parts = ID_PART_SEPARATOR_PATTERN.split(userId); if (parts.length > 0) { result.userId = parts[0]; if (parts.length > 1) { result.portletWindowInstanceId = parts[1]; if (parts.length > 2) { result.extraParts = ArrayUtils.subarray(parts, 2, parts.length); } } } return result; }
@Override public boolean shouldBePersisted(IPortletEntity portletEntity) { // Delegate entities should NEVER be persisted final String layoutNodeId = portletEntity.getLayoutNodeId(); if (PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { return false; } // Only non delegate entities with preferences or a non-null window state should be // persisted final List<IPortletPreference> preferences = portletEntity.getPortletPreferences(); return !CollectionUtils.isEmpty(preferences) || !portletEntity.getWindowStates().isEmpty(); }
if (!PortletEntityIdStringUtils.hasCorrectNumberOfParts(consistentEntityIdString)) { throw new IllegalArgumentException( "consistentEntityIdString does not have 3 parts and is invalid: " PortletEntityIdStringUtils.parsePortletDefinitionId(consistentEntityIdString); final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionIdString); PortletEntityIdStringUtils.parseLayoutNodeId(consistentEntityIdString); if (!PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { final IUserLayoutNodeDescription node = userLayoutManager.getNode(layoutNodeId); if (node == null || node.getType() != LayoutNodeType.PORTLET) { PortletEntityIdStringUtils.parseUserIdAsString(consistentEntityIdString); try { userId = Integer.parseInt(userIdAsString);
@Test public void hasCorrectNumberOfPartsTest() { boolean result = PortletEntityIdStringUtils.hasCorrectNumberOfParts("88_n149_52"); assertTrue(result); }
@Test public void parseLayoutNodeId() { String layoutNodeId = PortletEntityIdStringUtils.parseLayoutNodeId("88_n149_52"); assertEquals(layoutNodeId, "n149"); }
@Test public void parsePortletDefinitionId() { String portletDefinitionId = PortletEntityIdStringUtils.parsePortletDefinitionId("88_n149_52"); assertEquals(portletDefinitionId, "88"); }
public PortletEntityIdImpl( IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) { this.portletDefinitionId = portletDefinitionId; this.layoutNodeId = layoutNodeId; this.userId = userId; this.compositeIdString = PortletEntityIdStringUtils.format( portletDefinitionId.getStringId(), layoutNodeId, userId); }
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; }
if (!PortletEntityIdStringUtils.hasCorrectNumberOfParts(consistentEntityIdString)) { throw new IllegalArgumentException( "consistentEntityIdString does not have 3 parts and is invalid: " PortletEntityIdStringUtils.parsePortletDefinitionId(consistentEntityIdString); final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionIdString); PortletEntityIdStringUtils.parseLayoutNodeId(consistentEntityIdString); if (!PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { final IUserLayoutNodeDescription node = userLayoutManager.getNode(layoutNodeId); if (node == null || node.getType() != LayoutNodeType.PORTLET) { PortletEntityIdStringUtils.parseUserIdAsString(consistentEntityIdString); try { userId = Integer.parseInt(userIdAsString);
@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()); }
@Test public void parseUserIdAsString() { String layoutNodeId = PortletEntityIdStringUtils.parseUserIdAsString("88_n149_52"); assertEquals(layoutNodeId, "52"); } }
@Override public boolean shouldBePersisted(IPortletEntity portletEntity) { // Delegate entities should NEVER be persisted final String layoutNodeId = portletEntity.getLayoutNodeId(); if (PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { return false; } // Only non delegate entities with preferences or a non-null window state should be // persisted final List<IPortletPreference> preferences = portletEntity.getPortletPreferences(); return !CollectionUtils.isEmpty(preferences) || !portletEntity.getWindowStates().isEmpty(); }
@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()); }
@Test public void isDelegateLayoutNode() { boolean result = PortletEntityIdStringUtils.isDelegateLayoutNode("dlg-5-ctf1-18_18"); assertTrue(result); result = PortletEntityIdStringUtils.isDelegateLayoutNode("88_n149_52"); assertFalse(result); }