private DistributedUserLayout _getUserLayout ( IPerson person , IUserProfile profile ) { final String userName = ( String ) person . getAttribute ( "username" ) ; final FragmentDefinition ownedFragment = this . fragmentUtils . getFragmentDefinitionByOwner ( person ) ; final boolean isLayoutOwnerDefault = this . isLayoutOwnerDefault ( person ) ; final Set < String > fragmentNames = new LinkedHashSet <> ( ) ; final Document ILF ; final Document PLF = this . getPLF ( person , profile ) ; // If this user is an owner then ownedFragment will be non null. For // fragment owners and owners of any default layout from which a // fragment owners layout is copied there should not be any imported // distributed layouts. Instead, load their PLF, mark as an owned // if a fragment owner, and return. if ( ownedFragment != null || isLayoutOwnerDefault ) { ILF = ( Document ) PLF . cloneNode ( true ) ; final Element layoutNode = ILF . getDocumentElement ( ) ; final Element ownerDocument = layoutNode . getOwnerDocument ( ) . getDocumentElement ( ) ; final NodeList channelNodes = ownerDocument . getElementsByTagName ( "channel" ) ; for ( int i = 0 ; i < channelNodes . getLength ( ) ; i ++ ) { Element channelNode = ( Element ) channelNodes . item ( i ) ; final Node chanIdNode = channelNode . getAttributeNode ( "chanID" ) ; if ( chanIdNode == null || MissingPortletDefinition . CHANNEL_ID . equals ( chanIdNode . getNodeValue ( ) ) ) { channelNode . getParentNode ( ) . removeChild ( channelNode ) ; } } if ( ownedFragment != null ) { fragmentNames . add ( ownedFragment . getName ( ) ) ; layoutNode . setAttributeNS ( Constants . NS_URI , Constants . ATT_FRAGMENT_NAME , ownedFragment . getName ( ) ) ; logger . debug ( "User '{}' is owner of '{}' fragment." , userName , ownedFragment . getName ( ) ) ; } else if ( isLayoutOwnerDefault ) { layoutNode . setAttributeNS ( Constants . NS_URI , Constants . ATT_TEMPLATE_LOGIN_ID , ( String ) person . getAttribute ( "username" ) ) ; } } else { final Locale locale = profile . getLocaleManager ( ) . getLocales ( ) . get ( 0 ) ; final List < FragmentDefinition > applicableFragmentDefinitions = this . fragmentUtils . getFragmentDefinitionsApplicableToPerson ( person ) ; final List < Document > applicableLayouts = this . fragmentUtils . getFragmentDefinitionUserViewLayouts ( applicableFragmentDefinitions , locale ) ; final IntegrationResult integrationResult = new IntegrationResult ( ) ; ILF = this . createCompositeILF ( person , PLF , applicableLayouts , integrationResult ) ; // push optimizations made during merge back into db. if ( integrationResult . isChangedPLF ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Saving PLF for {} due to changes during merge." , person . getAttribute ( IPerson . USERNAME ) ) ; } super . setUserLayout ( person , profile , PLF , false ) ; } fragmentNames . addAll ( this . fragmentUtils . getFragmentNames ( applicableFragmentDefinitions ) ) ; } return this . createDistributedUserLayout ( person , profile , ILF , fragmentNames ) ; }
Returns the layout for a user . This method overrides the same method in the superclass to return a composite layout for non fragment owners and a regular layout for layout owners . A composite layout is made up of layout pieces from potentially multiple incorporated layouts . If no layouts are defined then the composite layout will be the same as the user s personal layout fragment or PLF the one holding only those UI elements that they own or incorporated elements that they have been allowed to changed .