idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
34,700
static void adjustPositionSet ( List < NodeInfo > order , Element positionSet , IntegrationResult result ) { Node nodeToMatch = positionSet . getFirstChild ( ) ; Element nodeToInsertBefore = positionSet . getOwnerDocument ( ) . createElement ( "INSERT_POINT" ) ; positionSet . insertBefore ( nodeToInsertBefore , nodeToMatch ) ; for ( Iterator < NodeInfo > iter = order . iterator ( ) ; iter . hasNext ( ) ; ) { NodeInfo ni = iter . next ( ) ; if ( ni . getPositionDirective ( ) != null ) { if ( ni . getPositionDirective ( ) != nodeToMatch ) result . setChangedPLF ( true ) ; ; if ( nodeToMatch != null ) nodeToMatch = nodeToMatch . getNextSibling ( ) ; positionSet . insertBefore ( ni . getPositionDirective ( ) , nodeToInsertBefore ) ; } } int removeFails = 0 ; while ( nodeToInsertBefore . getNextSibling ( ) != null && removeFails < 5 ) { Node toRemove = nodeToInsertBefore . getNextSibling ( ) ; try { toRemove . getParentNode ( ) . removeChild ( toRemove ) ; } catch ( DOMException de ) { LOG . error ( "DOM issue removing next child after insert point: {} -- {}" , toRemove . toString ( ) , de . getLocalizedMessage ( ) ) ; removeFails ++ ; } } if ( nodeToInsertBefore . getParentNode ( ) != null ) { nodeToInsertBefore . getParentNode ( ) . removeChild ( nodeToInsertBefore ) ; } }
This method trims down the position set to the position directives on the node info elements still having a position directive . Any directives that violated restrictions were removed from the node info objects so the position set should be made to match the order of those still having one .
34,701
static boolean hasAffectOnCVP ( List < NodeInfo > order , Element compViewParent ) { if ( order . size ( ) == 0 ) return false ; int idx = 0 ; Element child = ( Element ) compViewParent . getFirstChild ( ) ; NodeInfo ni = order . get ( idx ) ; if ( child == null && ni != null ) return true ; while ( child != null ) { if ( child . getAttribute ( "hidden" ) . equals ( "false" ) && ( ! child . getAttribute ( "chanID" ) . equals ( "" ) || child . getAttribute ( "type" ) . equals ( "regular" ) ) ) { if ( ni . getId ( ) . equals ( child . getAttribute ( Constants . ATT_ID ) ) ) { if ( idx >= order . size ( ) - 1 ) return false ; ni = order . get ( ++ idx ) ; } else return true ; } child = ( Element ) child . getNextSibling ( ) ; } if ( idx < order . size ( ) ) return true ; return false ; }
This method compares the children by id in the order list with the order in the compViewParent s ui visible children and returns true if the ordering differs indicating that the positioning if needed .
34,702
static void applyToNodes ( List < NodeInfo > order , Element compViewParent ) { Node insertPoint = compViewParent . getOwnerDocument ( ) . createElement ( "bogus" ) ; Node first = compViewParent . getFirstChild ( ) ; if ( first != null ) compViewParent . insertBefore ( insertPoint , first ) ; else compViewParent . appendChild ( insertPoint ) ; for ( int i = 0 ; i < order . size ( ) ; i ++ ) compViewParent . insertBefore ( order . get ( i ) . getNode ( ) , insertPoint ) ; compViewParent . removeChild ( insertPoint ) ; }
This method applies the ordering specified in the passed in order list to the child nodes of the compViewParent . Nodes specified in the list but located elsewhere are pulled in .
34,703
static void applyNoHopping ( List < NodeInfo > order ) { if ( isIllegalHoppingSpecified ( order ) == true ) { ArrayList < NodeInfo > cvpNodeInfos = new ArrayList < > ( ) ; for ( int i = order . size ( ) - 1 ; i >= 0 ; i -- ) if ( order . get ( i ) . getIndexInCVP ( ) != - 1 ) cvpNodeInfos . add ( order . remove ( i ) ) ; NodeInfo [ ] nodeInfos = cvpNodeInfos . toArray ( new NodeInfo [ cvpNodeInfos . size ( ) ] ) ; Arrays . sort ( nodeInfos , new NodeInfoComparator ( ) ) ; List < NodeInfo > list = Arrays . asList ( nodeInfos ) ; order . addAll ( 0 , list ) ; } }
This method is responsible for preventing nodes with identical precedence in the same parent from hopping over each other so that a layout fragment can lock two tabs that are next to each other and they can only be separated by tabs with higher precedence .
34,704
static boolean isIllegalHoppingSpecified ( List < NodeInfo > order ) { for ( int i = 0 ; i < order . size ( ) ; i ++ ) { NodeInfo ni = ( NodeInfo ) order . get ( i ) ; if ( ! ni . getNode ( ) . getAttribute ( Constants . ATT_MOVE_ALLOWED ) . equals ( "false" ) ) continue ; for ( int j = 0 ; j < i ; j ++ ) { NodeInfo niSib = ( NodeInfo ) order . get ( j ) ; if ( niSib . getPrecedence ( ) == Precedence . getUserPrecedence ( ) ) continue ; if ( niSib . getPrecedence ( ) . isEqualTo ( ni . getPrecedence ( ) ) && ( niSib . getIndexInCVP ( ) == - 1 || ni . getIndexInCVP ( ) < niSib . getIndexInCVP ( ) ) ) return true ; } for ( int j = i + 1 ; j < order . size ( ) ; j ++ ) { NodeInfo niSib = ( NodeInfo ) order . get ( j ) ; if ( niSib . getIndexInCVP ( ) == - 1 || niSib . getPrecedence ( ) == Precedence . getUserPrecedence ( ) ) continue ; if ( ni . getIndexInCVP ( ) > niSib . getIndexInCVP ( ) && niSib . getPrecedence ( ) . isEqualTo ( ni . getPrecedence ( ) ) ) return true ; } } return false ; }
This method determines if any illegal hopping is being specified . To determine if the positioning is specifying an ordering that will result in hopping I need to determine for each node n in the list if any of the nodes to be positioned to its right currently lie to its left in the CVP and have moveAllowed = false and have the same precedence or if any of the nodes to be positioned to its left currently lie to its right in the CVP and have moveAllowed = false and have the same precedence .
34,705
static void applyOrdering ( List < NodeInfo > order , Element compViewParent , Element positionSet , NodeInfoTracker tracker ) { final Map < String , NodeInfo > available = new LinkedHashMap < String , NodeInfo > ( ) ; Element child = ( Element ) compViewParent . getFirstChild ( ) ; Element next = null ; int indexInCVP = 0 ; while ( child != null ) { next = ( Element ) child . getNextSibling ( ) ; if ( child . getAttribute ( "hidden" ) . equals ( "false" ) && ( ! child . getAttribute ( "chanID" ) . equals ( "" ) || child . getAttribute ( "type" ) . equals ( "regular" ) ) ) { final NodeInfo nodeInfo = new NodeInfo ( child , indexInCVP ++ ) ; tracker . track ( order , compViewParent , positionSet ) ; final NodeInfo prevNode = available . put ( nodeInfo . getId ( ) , nodeInfo ) ; if ( prevNode != null ) { throw new IllegalStateException ( "Infinite loop detected in layout. Triggered by " + nodeInfo . getId ( ) + " with already visited node ids: " + available . keySet ( ) ) ; } } child = next ; } Document CV = compViewParent . getOwnerDocument ( ) ; Element directive = ( Element ) positionSet . getFirstChild ( ) ; while ( directive != null ) { next = ( Element ) directive . getNextSibling ( ) ; String id = directive . getAttribute ( "name" ) ; child = CV . getElementById ( id ) ; if ( child != null ) { final String childId = child . getAttribute ( Constants . ATT_ID ) ; NodeInfo ni = available . remove ( childId ) ; if ( ni == null ) { ni = new NodeInfo ( child ) ; tracker . track ( order , compViewParent , positionSet ) ; } ni . setPositionDirective ( directive ) ; order . add ( ni ) ; } directive = next ; } order . addAll ( available . values ( ) ) ; }
This method assembles in the passed in order object a list of NodeInfo objects ordered first by those specified in the position set and whose nodes still exist in the composite view and then by any remaining children in the compViewParent .
34,706
public static void updatePositionSet ( Element compViewParent , Element plfParent , IPerson person ) throws PortalException { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Updating Position Set" ) ; if ( compViewParent . getChildNodes ( ) . getLength ( ) == 0 ) { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "No Nodes to position" ) ; Element positions = getPositionSet ( plfParent , person , false ) ; if ( positions != null ) plfParent . removeChild ( positions ) ; return ; } Element posSet = ( Element ) getPositionSet ( plfParent , person , true ) ; Element position = ( Element ) posSet . getFirstChild ( ) ; Element viewNode = ( Element ) compViewParent . getFirstChild ( ) ; boolean ilfNodesFound = false ; while ( viewNode != null ) { String ID = viewNode . getAttribute ( Constants . ATT_ID ) ; String channelId = viewNode . getAttribute ( Constants . ATT_CHANNEL_ID ) ; String type = viewNode . getAttribute ( Constants . ATT_TYPE ) ; String hidden = viewNode . getAttribute ( Constants . ATT_HIDDEN ) ; if ( ID . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ) ilfNodesFound = true ; if ( ! channelId . equals ( "" ) || ( type . equals ( "regular" ) && hidden . equals ( "false" ) ) ) { if ( position != null ) position . setAttribute ( Constants . ATT_NAME , ID ) ; else position = createAndAppendPosition ( ID , posSet , person ) ; position = ( Element ) position . getNextSibling ( ) ; } viewNode = ( Element ) viewNode . getNextSibling ( ) ; } if ( ilfNodesFound == false ) plfParent . removeChild ( posSet ) ; else { while ( position != null ) { Element nextPos = ( Element ) position . getNextSibling ( ) ; posSet . removeChild ( position ) ; position = nextPos ; } } }
This method updates the positions recorded in a position set to reflect the ids of the nodes in the composite view of the layout . Any position nodes already in existence are reused to reduce database interaction needed to generate a new ID attribute . If any are left over after updating those position elements are removed . If no position set existed a new one is created for the parent . If no ILF nodes are found in the parent node then the position set as a whole is reclaimed .
34,707
private static Element getPositionSet ( Element plfParent , IPerson person , boolean create ) throws PortalException { Node child = plfParent . getFirstChild ( ) ; while ( child != null ) { if ( child . getNodeName ( ) . equals ( Constants . ELM_POSITION_SET ) ) return ( Element ) child ; child = child . getNextSibling ( ) ; } if ( create == false ) return null ; String ID = null ; try { ID = getDLS ( ) . getNextStructDirectiveId ( person ) ; } catch ( Exception e ) { throw new PortalException ( "Exception encountered while " + "generating new position set node " + "Id for userId=" + person . getID ( ) , e ) ; } Document plf = plfParent . getOwnerDocument ( ) ; Element positions = plf . createElement ( Constants . ELM_POSITION_SET ) ; positions . setAttribute ( Constants . ATT_TYPE , Constants . ELM_POSITION_SET ) ; positions . setAttribute ( Constants . ATT_ID , ID ) ; plfParent . appendChild ( positions ) ; return positions ; }
This method locates the position set element in the child list of the passed in plfParent or if not found it will create one automatically and return it if the passed in create flag is true .
34,708
private static Element createAndAppendPosition ( String elementID , Element positions , IPerson person ) throws PortalException { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Adding Position Set entry " + elementID + "." ) ; String ID = null ; try { ID = getDLS ( ) . getNextStructDirectiveId ( person ) ; } catch ( Exception e ) { throw new PortalException ( "Exception encountered while " + "generating new position node " + "Id for userId=" + person . getID ( ) , e ) ; } Document plf = positions . getOwnerDocument ( ) ; Element position = plf . createElement ( Constants . ELM_POSITION ) ; position . setAttribute ( Constants . ATT_TYPE , Constants . ELM_POSITION ) ; position . setAttribute ( Constants . ATT_ID , ID ) ; position . setAttributeNS ( Constants . NS_URI , Constants . ATT_NAME , elementID ) ; positions . appendChild ( position ) ; return position ; }
Create append to the passed in position set and return a position element that references the passed in elementID .
34,709
private void updateScript ( String target , String databaseQualifier , String outputFile , boolean runIt ) { final ISchemaExport schemaExportBean = this . getSchemaExport ( databaseQualifier ) ; if ( schemaExportBean == null ) { throw new RuntimeException ( target + " could not find schemaExportBean " + databaseQualifier ) ; } try { PortalShell . LOGGER . info ( "" ) ; PortalShell . LOGGER . info ( "" ) ; PortalShell . LOGGER . info ( "Hibernate Update DDL: " + databaseQualifier ) ; outputFile = StringUtils . trimToNull ( outputFile ) ; schemaExportBean . update ( runIt , outputFile , true ) ; } catch ( Exception e ) { throw new RuntimeException ( target + " for " + databaseQualifier + " failed" , e ) ; } }
This runs a database update or just generates the script
34,710
private String formatBody ( URL resetUrl , ILocalAccountPerson account , Locale locale ) { final STGroup group = new STGroupDir ( templateDir , '$' , '$' ) ; final ST template = group . getInstanceOf ( templateName ) ; String name = findDisplayNameFromLocalAccountPerson ( account ) ; template . add ( "displayName" , name ) ; template . add ( "url" , resetUrl . toString ( ) ) ; return template . render ( ) ; }
Get the body content of the email .
34,711
protected String findDisplayNameFromLocalAccountPerson ( ILocalAccountPerson person ) { Object name = person . getAttributeValue ( ILocalAccountPerson . ATTR_DISPLAY_NAME ) ; if ( ( name instanceof String ) && ! StringUtils . isEmpty ( ( String ) name ) ) { return ( String ) name ; } return person . getName ( ) ; }
Determine the name to use in the password reset email that identifies the users whose password has been reset .
34,712
final void doPopulateTimeDimensions ( ) { final List < TimeDimension > timeDimensions = this . timeDimensionDao . getTimeDimensions ( ) ; if ( timeDimensions . isEmpty ( ) ) { logger . info ( "No TimeDimensions exist, creating them" ) ; } else if ( timeDimensions . size ( ) != ( 24 * 60 ) ) { this . logger . info ( "There are only " + timeDimensions . size ( ) + " time dimensions in the database, there should be " + ( 24 * 60 ) + " creating missing dimensions" ) ; } else { this . logger . debug ( "Found expected " + timeDimensions . size ( ) + " time dimensions" ) ; return ; } LocalTime nextTime = new LocalTime ( 0 , 0 ) ; final LocalTime lastTime = new LocalTime ( 23 , 59 ) ; for ( final TimeDimension timeDimension : timeDimensions ) { LocalTime dimensionTime = timeDimension . getTime ( ) ; if ( nextTime . isBefore ( dimensionTime ) ) { do { checkShutdown ( ) ; this . timeDimensionDao . createTimeDimension ( nextTime ) ; nextTime = nextTime . plusMinutes ( 1 ) ; } while ( nextTime . isBefore ( dimensionTime ) ) ; } else if ( nextTime . isAfter ( dimensionTime ) ) { do { checkShutdown ( ) ; this . timeDimensionDao . createTimeDimension ( dimensionTime ) ; dimensionTime = dimensionTime . plusMinutes ( 1 ) ; } while ( nextTime . isAfter ( dimensionTime ) ) ; } nextTime = dimensionTime . plusMinutes ( 1 ) ; } while ( nextTime . isBefore ( lastTime ) || nextTime . equals ( lastTime ) ) { checkShutdown ( ) ; this . timeDimensionDao . createTimeDimension ( nextTime ) ; if ( nextTime . equals ( lastTime ) ) { break ; } nextTime = nextTime . plusMinutes ( 1 ) ; } }
Populate the time dimensions
34,713
protected void createDateDimension ( List < QuarterDetail > quartersDetails , List < AcademicTermDetail > academicTermDetails , DateMidnight date ) { final QuarterDetail quarterDetail = EventDateTimeUtils . findDateRangeSorted ( date , quartersDetails ) ; final AcademicTermDetail termDetail = EventDateTimeUtils . findDateRangeSorted ( date , academicTermDetails ) ; this . dateDimensionDao . createDateDimension ( date , quarterDetail . getQuarterId ( ) , termDetail != null ? termDetail . getTermName ( ) : null ) ; }
Creates a date dimension handling the quarter and term lookup logic
34,714
public static String getStringFromPortletUrl ( PortletUrl portletUrl , HttpServletRequest request ) { if ( portletUrl == null ) { return null ; } UrlType urlType = UrlType . RENDER ; final PortletUrlType type = portletUrl . getType ( ) ; switch ( type ) { case ACTION : urlType = UrlType . ACTION ; break ; case RESOURCE : urlType = UrlType . RESOURCE ; break ; default : urlType = UrlType . RENDER ; break ; } IPortletWindow marketplaceWindow = portletWindowRegistry . getOrCreateDefaultPortletWindowByFname ( request , MarketplacePortletDefinition . MARKETPLACE_FNAME ) ; IPortalUrlBuilder portalUrlBuilder = portalUrlProvider . getPortalUrlBuilderByPortletWindow ( request , marketplaceWindow . getPortletWindowId ( ) , urlType ) ; IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder . getTargetedPortletUrlBuilder ( ) ; final String portletMode = portletUrl . getPortletMode ( ) ; if ( portletMode != null ) { portletUrlBuilder . setPortletMode ( PortletUtils . getPortletMode ( portletMode ) ) ; } final String windowState = portletUrl . getWindowState ( ) ; if ( windowState != null ) { portletUrlBuilder . setWindowState ( PortletUtils . getWindowState ( windowState ) ) ; } for ( final PortletUrlParameter param : portletUrl . getParam ( ) ) { final String name = param . getName ( ) ; final List < String > values = param . getValue ( ) ; portletUrlBuilder . addParameter ( name , values . toArray ( new String [ values . size ( ) ] ) ) ; } return portalUrlBuilder . getUrlString ( ) ; }
A static EL function that is defined in portletUrl . tld Takes a portletUrl object and coverts it into an actual Url Example is in search returns a marketplace entry Url
34,715
public void setChannelPublishingDefinition ( PortletPublishingDefinition cpd ) { if ( cpd . getPortletDescriptor ( ) != null ) { final PortletDescriptor pDesc = cpd . getPortletDescriptor ( ) ; final boolean isFramework = pDesc . isIsFramework ( ) != null ? pDesc . isIsFramework ( ) : false ; applicationId = isFramework ? FRAMEWORK_PORTLET_URL : pDesc . getWebAppName ( ) ; portletName = pDesc . getPortletName ( ) ; } for ( Step step : cpd . getSteps ( ) ) { if ( step . getParameters ( ) != null ) { for ( Parameter param : step . getParameters ( ) ) { Attribute attribute = parameters . get ( param . getName ( ) ) ; if ( attribute == null || attribute . getValue ( ) == null || attribute . getValue ( ) . trim ( ) . equals ( "" ) ) { ParameterInputType input = param . getParameterInput ( ) . getValue ( ) ; if ( input != null ) { parameters . put ( param . getName ( ) , new Attribute ( input . getDefault ( ) ) ) ; } } } } if ( step . getPreferences ( ) != null ) { for ( Preference pref : step . getPreferences ( ) ) { if ( ! portletPreferences . containsKey ( pref . getName ( ) ) || portletPreferences . get ( pref . getName ( ) ) . getValue ( ) . size ( ) == 0 || ( portletPreferences . get ( pref . getName ( ) ) . getValue ( ) . size ( ) == 1 && portletPreferences . get ( pref . getName ( ) ) . getValue ( ) . get ( 0 ) . trim ( ) . equals ( "" ) ) ) { if ( ! portletPreferences . containsKey ( pref . getName ( ) ) ) { portletPreferences . put ( pref . getName ( ) , new StringListAttribute ( ) ) ; } PreferenceInputType input = pref . getPreferenceInput ( ) . getValue ( ) ; if ( input instanceof SingleValuedPreferenceInputType ) { SingleValuedPreferenceInputType singleValued = ( SingleValuedPreferenceInputType ) input ; if ( singleValued . getDefault ( ) != null ) { portletPreferences . get ( pref . getName ( ) ) . getValue ( ) . add ( singleValued . getDefault ( ) ) ; } } else if ( input instanceof MultiValuedPreferenceInputType ) { MultiValuedPreferenceInputType multiValued = ( MultiValuedPreferenceInputType ) input ; if ( multiValued . getDefaults ( ) != null ) { portletPreferences . get ( pref . getName ( ) ) . getValue ( ) . addAll ( multiValued . getDefaults ( ) ) ; } } } } } } }
Sets the Java class name and parameter defaults based on the PortletPublishingDefinition .
34,716
private void initPermissionsForPrincipal ( JsonEntityBean principal ) { permissions . add ( principal . getTypeAndIdHash ( ) + "_" + PortletAdministrationHelper . PortletPermissionsOnForm . BROWSE . getActivity ( ) ) ; permissions . add ( principal . getTypeAndIdHash ( ) + "_" + PortletAdministrationHelper . PortletPermissionsOnForm . SUBSCRIBE . getActivity ( ) ) ; }
Sets the default collection of permissions for newly - added principals . They are BROWSE and SUBSCRIBE .
34,717
public void setExpirationDateString ( String date ) throws ParseException { if ( StringUtils . isBlank ( date ) ) { expirationDate = null ; return ; } expirationDate = dateFormat . parse ( date ) ; }
Set the expiration date as a string .
34,718
public void setPublishDateString ( String date ) throws ParseException { if ( StringUtils . isBlank ( date ) ) { publishDate = null ; return ; } publishDate = dateFormat . parse ( date ) ; }
Set the publish date as a string . This is just a webflow workaround .
34,719
public void setServiceName ( Name newServiceName ) throws GroupsException { try { getCompositeEntityIdentifier ( ) . setServiceName ( newServiceName ) ; } catch ( javax . naming . InvalidNameException ine ) { throw new GroupsException ( "Problem setting service name" , ine ) ; } }
Sets the service Name of the group service of origin .
34,720
public void updateMembers ( ) throws GroupsException { Set < IGroupMember > invalidate = new HashSet < > ( ) ; invalidate . addAll ( getAddedMembers ( ) . values ( ) ) ; invalidate . addAll ( getRemovedMembers ( ) . values ( ) ) ; getLocalGroupService ( ) . updateGroupMembers ( this ) ; clearPendingUpdates ( ) ; this . invalidateInParentGroupsCache ( invalidate ) ; }
Delegate to the factory .
34,721
public static String getEventName ( int eventId ) { switch ( eventId ) { case XMLStreamConstants . START_ELEMENT : return "StartElementEvent" ; case XMLStreamConstants . END_ELEMENT : return "EndElementEvent" ; case XMLStreamConstants . PROCESSING_INSTRUCTION : return "ProcessingInstructionEvent" ; case XMLStreamConstants . CHARACTERS : return "CharacterEvent" ; case XMLStreamConstants . COMMENT : return "CommentEvent" ; case XMLStreamConstants . START_DOCUMENT : return "StartDocumentEvent" ; case XMLStreamConstants . END_DOCUMENT : return "EndDocumentEvent" ; case XMLStreamConstants . ENTITY_REFERENCE : return "EntityReferenceEvent" ; case XMLStreamConstants . ATTRIBUTE : return "AttributeBase" ; case XMLStreamConstants . DTD : return "DTDEvent" ; case XMLStreamConstants . CDATA : return "CDATA" ; } return "UNKNOWN_EVENT_TYPE" ; }
Get the human readable event name for the numeric event id
34,722
public Evaluator getAttributeEvaluator ( String name , String mode , String value ) { return new GroupMembershipEvaluator ( mode , name ) ; }
Returns an instance of an evaluator specific to this factory and the passed in values . Name should be a well known group name . Case is important . The mode should be memberOf for now . Other modes may be added in the future like deepMemberOf .
34,723
private List < IPersonAttributes > getVisiblePersons ( final IAuthorizationPrincipal principal , final Set < String > permittedAttributes , List < IPersonAttributes > peopleList ) { List < Future < IPersonAttributes > > futures = new ArrayList < > ( ) ; List < IPersonAttributes > list = new ArrayList < > ( ) ; RequestAttributes requestAttributes = RequestContextHolder . getRequestAttributes ( ) ; for ( IPersonAttributes person : peopleList ) { Callable < IPersonAttributes > worker = new FetchVisiblePersonCallable ( principal , person , permittedAttributes , requestAttributes ) ; Future < IPersonAttributes > task = executor . submit ( worker ) ; futures . add ( task ) ; } for ( Future < IPersonAttributes > future : futures ) { try { final IPersonAttributes visiblePerson = future . get ( searchThreadTimeoutSeconds , TimeUnit . SECONDS ) ; if ( visiblePerson != null ) { list . add ( visiblePerson ) ; } } catch ( InterruptedException e ) { logger . error ( "Processing person search interrupted" , e ) ; } catch ( ExecutionException e ) { logger . error ( "Error Processing person search" , e ) ; } catch ( TimeoutException e ) { future . cancel ( true ) ; logger . warn ( "Exceeded {} ms waiting for getVisiblePerson to return result" , searchThreadTimeoutSeconds ) ; } } logger . debug ( "Found {} results" , list . size ( ) ) ; return list ; }
Returns a list of the personAttributes that this principal has permission to view . This implementation does the check on the list items in parallel because personDirectory is consulted for non - admin principals to get the person attributes which is really slow if done on N entries in parallel because personDirectory often goes out to LDAP or another external source for additional attributes . This processing will not retain list order .
34,724
private boolean allListItemsHaveDisplayName ( List < IPersonAttributes > people ) { for ( IPersonAttributes person : people ) { if ( person . getAttributeValue ( "displayName" ) == null ) { return false ; } } return true ; }
Utility class to determine if all items in the list of people have a displayName .
34,725
protected IAuthorizationPrincipal getPrincipalForUser ( final IPerson person ) { final EntityIdentifier ei = person . getEntityIdentifier ( ) ; return AuthorizationServiceFacade . instance ( ) . newPrincipal ( ei . getKey ( ) , ei . getType ( ) ) ; }
Get the authoriztaion principal matching the supplied IPerson .
34,726
protected Set < String > getPermittedAttributes ( final IAuthorizationPrincipal principal ) { final Set < String > attributeNames = personAttributeDao . getPossibleUserAttributeNames ( ) ; return getPermittedAttributes ( principal , attributeNames ) ; }
Get the set of all user attribute names defined in the portal for which the specified principal has the attribute viewing permission .
34,727
public Map < String , Document > getFragmentLayoutCopies ( ) { final Locale defaultLocale = localeManagerFactory . getPortalLocales ( ) . get ( 0 ) ; final Map < String , Document > layouts = new HashMap < > ( ) ; final List < FragmentDefinition > definitions = this . fragmentUtils . getFragmentDefinitions ( ) ; for ( final FragmentDefinition fragmentDefinition : definitions ) { final Document layout = DocumentFactory . getThreadDocument ( ) ; final UserView userView = this . fragmentUtils . getUserView ( fragmentDefinition , defaultLocale ) ; if ( userView == null ) { logger . warn ( "No UserView found for FragmentDefinition {}, it will be skipped." , fragmentDefinition . getName ( ) ) ; continue ; } final Node copy = layout . importNode ( userView . getLayout ( ) . getDocumentElement ( ) , true ) ; layout . appendChild ( copy ) ; layouts . put ( fragmentDefinition . getOwnerId ( ) , layout ) ; } return layouts ; }
Method for acquiring copies of fragment layouts to assist in debugging . No infrastructure code calls this but channels designed to expose the structure of the cached fragments use this to obtain copies .
34,728
public DistributedUserLayout getUserLayout ( IPerson person , IUserProfile profile ) { final DistributedUserLayout layout = this . _getUserLayout ( person , profile ) ; return layout ; }
Returns the layout for a user decorated with any specified decorator . The layout returned is 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 .
34,729
private Document _safeGetUserLayout ( IPerson person , IUserProfile profile ) { Document layoutDoc ; Tuple < String , String > key = null ; final Cache < Tuple < String , String > , Document > layoutCache = getLayoutImportExportCache ( ) ; if ( layoutCache != null ) { key = new Tuple < > ( person . getUserName ( ) , profile . getProfileFname ( ) ) ; layoutDoc = layoutCache . getIfPresent ( key ) ; if ( layoutDoc != null ) { return ( Document ) layoutDoc . cloneNode ( true ) ; } } layoutDoc = super . getPersonalUserLayout ( person , profile ) ; Element layout = layoutDoc . getDocumentElement ( ) ; layout . setAttribute ( Constants . NS_DECL , Constants . NS_URI ) ; if ( layoutCache != null && key != null ) { layoutCache . put ( key , ( Document ) layoutDoc . cloneNode ( true ) ) ; } return layoutDoc ; }
Handles locking and identifying proper root and namespaces that used to take place in super class .
34,730
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 ( 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 ) ; 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 .
34,731
public Document getFragmentLayout ( IPerson person , IUserProfile profile ) { return this . _safeGetUserLayout ( person , profile ) ; }
Convenience method for fragment activator to obtain raw layouts for fragments during initialization .
34,732
private void updateCachedLayout ( Document layout , IUserProfile profile , FragmentDefinition fragment ) { final Locale locale = profile . getLocaleManager ( ) . getLocales ( ) . get ( 0 ) ; layout = ( Document ) layout . cloneNode ( true ) ; final Element root = layout . getDocumentElement ( ) ; final UserView userView = this . fragmentUtils . getUserView ( fragment , locale ) ; if ( userView == null ) { throw new IllegalStateException ( "No UserView found for fragment: " + fragment . getName ( ) ) ; } root . setAttribute ( Constants . ATT_ID , Constants . FRAGMENT_ID_USER_PREFIX + userView . getUserId ( ) + Constants . FRAGMENT_ID_LAYOUT_PREFIX + "1" ) ; try { this . fragmentActivator . clearChacheForOwner ( fragment . getOwnerId ( ) ) ; this . fragmentUtils . getUserView ( fragment , locale ) ; } catch ( final Exception e ) { logger . error ( "An exception occurred attempting to update a layout." , e ) ; } }
Replaces the layout Document stored on a fragment definition with a new version . This is called when a fragment owner updates their layout .
34,733
private boolean isLayoutOwnerDefault ( IPerson person ) { final String userName = ( String ) person . getAttribute ( "username" ) ; final List < FragmentDefinition > definitions = this . fragmentUtils . getFragmentDefinitions ( ) ; if ( userName != null && definitions != null ) { for ( final FragmentDefinition fragmentDefinition : definitions ) { if ( fragmentDefinition . defaultLayoutOwnerID != null && fragmentDefinition . defaultLayoutOwnerID . equals ( userName ) ) { return true ; } } } final String globalDefault = PropertiesManager . getProperty ( DEFAULT_LAYOUT_OWNER_PROPERTY ) ; if ( globalDefault != null && globalDefault . equals ( userName ) ) { return true ; } return false ; }
Returns true if the user is the owner of a layout which is copied as the default for any fragment when first created .
34,734
public void setUserLayout ( IPerson person , IUserProfile profile , Document layoutXML , boolean channelsAdded ) { this . setUserLayout ( person , profile , layoutXML , channelsAdded , true ) ; }
This method overrides the same method in the super class to persist only layout information stored in the user s person layout fragment or PLF . If this person is a layout owner then their changes are pushed into the appropriate layout fragment .
34,735
public void setUserLayout ( IPerson person , IUserProfile profile , Document layoutXML , boolean channelsAdded , boolean updateFragmentCache ) { final Document plf = ( Document ) person . getAttribute ( Constants . PLF ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "PLF for {}\n{}" , person . getAttribute ( IPerson . USERNAME ) , XmlUtilitiesImpl . toString ( plf ) ) ; } super . setUserLayout ( person , profile , plf , channelsAdded ) ; if ( updateFragmentCache ) { final FragmentDefinition fragment = this . fragmentUtils . getFragmentDefinitionByOwner ( person ) ; if ( fragment != null ) { this . updateCachedLayout ( plf , profile , fragment ) ; } } }
This method overrides the same method in the super class to persist only layout information stored in the user s person layout fragment or PLF . If fragment cache update is requested then it checks to see if this person is a layout owner and if so then their changes are pushed into the appropriate layout fragment .
34,736
private static synchronized void storeSingleton ( ) { if ( PERSON_DIR_NAME_FINDER_INSTANCE == null ) { IPersonAttributeDao personAttributeDao = PersonAttributeDaoLocator . getPersonAttributeDao ( ) ; PERSON_DIR_NAME_FINDER_INSTANCE = new PersonDirNameFinder ( personAttributeDao ) ; } }
Instantiates the static singleton field PERSON_DIR_NAME_FINDER_INSTANCE . Synchronized to guarantee singleton - ness of the field .
34,737
protected String getResourceId ( IPortletWindowId portletWindowId , final IPortalRequestInfo portalRequestInfo ) { final IPortletRequestInfo portletRequestInfo = portalRequestInfo . getPortletRequestInfo ( portletWindowId ) ; if ( portletRequestInfo == null ) { return null ; } return portletRequestInfo . getResourceId ( ) ; }
The portlet resource request resourceId
34,738
protected final Object getEventSessionMutex ( HttpSession session ) { synchronized ( WebUtils . getSessionMutex ( session ) ) { SerializableObject mutex = ( SerializableObject ) session . getAttribute ( EVENT_SESSION_MUTEX ) ; if ( mutex == null ) { mutex = new SerializableObject ( ) ; session . setAttribute ( EVENT_SESSION_MUTEX , mutex ) ; } return mutex ; } }
Get a session scoped mutex specific to this class
34,739
public GroupForm getGroupForm ( String key ) { log . debug ( "Initializing group form for group key " + key ) ; IEntityGroup group = GroupService . findGroup ( key ) ; GroupForm form = new GroupForm ( ) ; form . setKey ( key ) ; form . setName ( group . getName ( ) ) ; form . setDescription ( group . getDescription ( ) ) ; form . setCreatorId ( group . getCreatorID ( ) ) ; form . setType ( groupListHelper . getEntityType ( group ) . toString ( ) ) ; for ( IGroupMember child : group . getChildren ( ) ) { JsonEntityBean childBean = groupListHelper . getEntity ( child ) ; form . addMember ( childBean ) ; } return form ; }
Construct a group form for the group with the specified key .
34,740
public void deleteGroup ( String key , IPerson deleter ) { if ( ! canDeleteGroup ( deleter , key ) ) { throw new RuntimeAuthorizationException ( deleter , IPermission . DELETE_GROUP_ACTIVITY , key ) ; } log . info ( "Deleting group with key " + key ) ; IEntityGroup group = GroupService . findGroup ( key ) ; for ( IEntityGroup parent : group . getParentGroups ( ) ) { parent . removeChild ( group ) ; parent . updateMembers ( ) ; } group . delete ( ) ; }
Delete a group from the group store
34,741
public void updateGroupDetails ( GroupForm groupForm , IPerson updater ) { if ( ! canEditGroup ( updater , groupForm . getKey ( ) ) ) { throw new RuntimeAuthorizationException ( updater , IPermission . EDIT_GROUP_ACTIVITY , groupForm . getKey ( ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Updating group for group form [" + groupForm . toString ( ) + "]" ) ; } IEntityGroup group = GroupService . findGroup ( groupForm . getKey ( ) ) ; group . setName ( groupForm . getName ( ) ) ; group . setDescription ( groupForm . getDescription ( ) ) ; group . update ( ) ; }
Update the title and description of an existing group in the group store .
34,742
public void updateGroupMembers ( GroupForm groupForm , IPerson updater ) { if ( ! canEditGroup ( updater , groupForm . getKey ( ) ) ) { throw new RuntimeAuthorizationException ( updater , IPermission . EDIT_GROUP_ACTIVITY , groupForm . getKey ( ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Updating group members for group form [" + groupForm . toString ( ) + "]" ) ; } IEntityGroup group = GroupService . findGroup ( groupForm . getKey ( ) ) ; for ( IGroupMember child : group . getChildren ( ) ) { group . removeChild ( child ) ; } for ( JsonEntityBean child : groupForm . getMembers ( ) ) { EntityEnum type = EntityEnum . getEntityEnum ( child . getEntityTypeAsString ( ) ) ; if ( type . isGroup ( ) ) { IEntityGroup member = GroupService . findGroup ( child . getId ( ) ) ; group . addChild ( member ) ; } else { IGroupMember member = GroupService . getGroupMember ( child . getId ( ) , type . getClazz ( ) ) ; group . addChild ( member ) ; } } group . updateMembers ( ) ; }
Update the members of an existing group in the group store .
34,743
public void createGroup ( GroupForm groupForm , JsonEntityBean parent , IPerson creator ) { if ( ! canCreateMemberGroup ( creator , parent . getId ( ) ) ) { throw new RuntimeAuthorizationException ( creator , IPermission . CREATE_GROUP_ACTIVITY , groupForm . getKey ( ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Creating new group for group form [" + groupForm . toString ( ) + "] and parent [" + parent . toString ( ) + "]" ) ; } EntityEnum type = EntityEnum . getEntityEnum ( groupForm . getType ( ) ) ; IEntityGroup group = GroupService . newGroup ( type . getClazz ( ) ) ; group . setCreatorID ( creator . getUserName ( ) ) ; group . setName ( groupForm . getName ( ) ) ; group . setDescription ( groupForm . getDescription ( ) ) ; for ( JsonEntityBean child : groupForm . getMembers ( ) ) { EntityEnum childType = EntityEnum . getEntityEnum ( child . getEntityTypeAsString ( ) ) ; if ( childType . isGroup ( ) ) { IEntityGroup member = GroupService . findGroup ( child . getId ( ) ) ; group . addChild ( member ) ; } else { IGroupMember member = GroupService . getGroupMember ( child . getId ( ) , type . getClazz ( ) ) ; group . addChild ( member ) ; } } group . update ( ) ; IEntityGroup parentGroup = GroupService . findGroup ( parent . getId ( ) ) ; parentGroup . addChild ( group ) ; parentGroup . updateMembers ( ) ; }
Create a new group under the specified parent . The new group will automatically be added to the parent group .
34,744
private void selectFormExecutionType ( final PortletExecutionReportForm report ) { if ( ! report . getExecutionTypeNames ( ) . isEmpty ( ) ) { return ; } report . getExecutionTypeNames ( ) . add ( ExecutionType . RENDER . name ( ) ) ; }
Select the XXXX execution type by default for the form
34,745
protected List < ColumnDescription > getColumnDescriptions ( PortletExecutionAggregationDiscriminator reportColumnDiscriminator , PortletExecutionReportForm form ) { int groupSize = form . getGroups ( ) . size ( ) ; int portletSize = form . getPortlets ( ) . size ( ) ; int executionTypeSize = form . getExecutionTypeNames ( ) . size ( ) ; String portletName = reportColumnDiscriminator . getPortletMapping ( ) . getFname ( ) ; String groupName = reportColumnDiscriminator . getAggregatedGroup ( ) . getGroupName ( ) ; String executionTypeName = reportColumnDiscriminator . getExecutionType ( ) . getName ( ) ; TitleAndCount [ ] items = new TitleAndCount [ ] { new TitleAndCount ( portletName , portletSize ) , new TitleAndCount ( executionTypeName , executionTypeSize ) , new TitleAndCount ( groupName , groupSize ) } ; return titleAndColumnDescriptionStrategy . getColumnDescriptions ( items , showFullColumnHeaderDescriptions ( form ) , form ) ; }
Create column descriptions for the portlet report using the configured report labelling strategy .
34,746
public void setServerRegex ( String serverRegex ) { Validate . notBlank ( serverRegex ) ; this . serverRegex = serverRegex ; this . pattern = Pattern . compile ( this . serverRegex ) ; }
Sets the regular expression for the servers you want to select a profile for
34,747
public synchronized Name getServiceName ( ) { if ( size ( ) < 2 ) { return null ; } if ( cachedServiceName == null ) { cachedServiceName = getCompositeKey ( ) . getPrefix ( size ( ) - 1 ) ; } return cachedServiceName ; }
If the composite key is either empty or has a single node there is no service name .
34,748
protected String getMediaType ( HttpServletRequest req , HttpServletResponse res , PipelineEventReader < CharacterEventReader , CharacterEvent > pipelineEventReader ) { final String mediaType = pipelineEventReader . getOutputProperty ( OutputKeys . MEDIA_TYPE ) ; if ( mediaType != null ) { return mediaType ; } this . logger . warn ( "No mediaType was specified in the pipeline output properties, defaulting to " + DEFAULT_MEDIA_TYPE ) ; return DEFAULT_MEDIA_TYPE ; }
Determine the media type to use for the response
34,749
protected Set < AggregatedGroupMapping > getGroupsForEvent ( PortalEvent event ) { final Set < AggregatedGroupMapping > groupMappings = new LinkedHashSet < AggregatedGroupMapping > ( ) ; if ( event instanceof LoginEvent ) { for ( final String groupKey : ( ( LoginEvent ) event ) . getGroups ( ) ) { final AggregatedGroupMapping groupMapping = this . aggregatedGroupLookupDao . getGroupMapping ( groupKey ) ; if ( groupMapping != null ) { groupMappings . add ( groupMapping ) ; } } } else { final String userName = event . getUserName ( ) ; final IGroupMember groupMember = this . compositeGroupService . getGroupMember ( userName , IPerson . class ) ; for ( @ SuppressWarnings ( "unchecked" ) final Iterator < IEntityGroup > containingGroups = this . compositeGroupService . findParentGroups ( groupMember ) ; containingGroups . hasNext ( ) ; ) { final IEntityGroup group = containingGroups . next ( ) ; final AggregatedGroupMapping groupMapping = this . aggregatedGroupLookupDao . getGroupMapping ( group . getServiceName ( ) . toString ( ) , group . getName ( ) ) ; groupMappings . add ( groupMapping ) ; } } return groupMappings ; }
Get groups for the event
34,750
public static void finishedSession ( IPerson person ) { LOGGER . trace ( "Invoking finishedSession for IPerson [{}]" , person ) ; try { instance ( ) . ifinishedSession ( person ) ; } catch ( GroupsException ge ) { LOGGER . error ( "Error upon session finishing for person [{}]" , person , ge ) ; } }
Receives notice that the UserInstance has been unbound from the HttpSession . In response we remove the corresponding group member from the cache .
34,751
private void ifinishedSession ( IPerson person ) throws GroupsException { IGroupMember gm = getGroupMember ( person . getEntityIdentifier ( ) ) ; try { final EntityIdentifier entityIdentifier = gm . getEntityIdentifier ( ) ; EntityCachingService . getEntityCachingService ( ) . remove ( entityIdentifier . getType ( ) , entityIdentifier . getKey ( ) ) ; } catch ( CachingException ce ) { throw new GroupsException ( "Problem removing group member " + gm . getKey ( ) + " from cache" , ce ) ; } }
Receives notice that the UserInstance has been unbound from the HttpSession . In response we remove the corresponding group member from the cache . We use the roundabout route of creating a group member and then getting its EntityIdentifier because we need the EntityIdentifier for the group member which is cached not the EntityIdentifier for the IPerson which is not .
34,752
public String generateToken ( final DynamicSkinInstanceData data ) { final PortletPreferences preferences = data . getPortletRequest ( ) . getPreferences ( ) ; int hash = 0 ; final Map < String , String [ ] > prefs = preferences . getMap ( ) ; final TreeSet < String > orderedNames = new TreeSet < String > ( prefs . keySet ( ) ) ; final Iterator < String > iterator = orderedNames . iterator ( ) ; while ( iterator . hasNext ( ) ) { final String preferenceName = iterator . next ( ) ; if ( preferenceName . startsWith ( DynamicRespondrSkinConstants . CONFIGURABLE_PREFIX ) ) { hash = hash * 31 + preferences . getValue ( preferenceName , "" ) . trim ( ) . hashCode ( ) ; } } return Integer . toString ( hash ) ; }
Returns a String hashcode of the values for the portlet preferences that are configurable by the Dynamic Skin portlet . The hashcode is generated in a repeatable fashion by calculating it based on sorted portlet preference names . Though hashcode does not guarantee uniqueness from a practical perspective we ll have so few different values we can reasonably assume preference value combinations will be unique .
34,753
public String initializeView ( WebRequest webRequest , PortletRequest portletRequest , Model model , @ RequestParam ( required = false ) String initialFilter ) { this . setUpInitialView ( webRequest , portletRequest , model , initialFilter ) ; return "jsp/Marketplace/portlet/view" ; }
Returns a view of the marketplace landing page
34,754
public Map < String , Set < ? > > getRegistry ( final IPerson user , final PortletRequest req ) { Map < String , Set < ? > > registry = new TreeMap < String , Set < ? > > ( ) ; final Set < PortletCategory > permittedCategories = getPermittedCategories ( req ) ; final Set < MarketplaceEntry > visiblePortlets = this . marketplaceService . browseableMarketplaceEntriesFor ( user , permittedCategories ) ; final Set < PortletCategory > visibleCategories = this . marketplaceService . browseableNonEmptyPortletCategoriesFor ( user , permittedCategories ) ; final Set < MarketplaceEntry > featuredPortlets = this . marketplaceService . featuredEntriesForUser ( user , permittedCategories ) ; registry . put ( "portlets" , visiblePortlets ) ; registry . put ( "categories" , visibleCategories ) ; registry . put ( "featured" , featuredPortlets ) ; return registry ; }
Returns a set of MarketplacePortletDefinitions . Supply a user to limit the set to only portlets the user can use . If user is null this will return all portlets . Setting user to null will superscede all other parameters .
34,755
public static void deleteNode ( Element compViewNode , IPerson person ) throws PortalException { String ID = compViewNode . getAttribute ( Constants . ATT_ID ) ; if ( ID . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ) DeleteManager . addDeleteDirective ( compViewNode , ID , person ) ; else { Document plf = ( Document ) person . getAttribute ( Constants . PLF ) ; Element node = plf . getElementById ( ID ) ; if ( node == null ) return ; Element parent = ( Element ) node . getParentNode ( ) ; if ( parent == null ) return ; parent . removeChild ( node ) ; } }
Handles user requests to delete UI elements . For ILF owned nodes it delegates to the DeleteManager to add a delete directive . For PLF owned nodes it deletes the node outright .
34,756
private Set < String > detectInvalidFields ( final String name , final String fname , final Map < String , String > attributes ) { final Set < String > rslt = new HashSet < > ( ) ; try { tenantService . validateName ( name ) ; tenantService . validateFname ( fname ) ; } catch ( Exception e ) { log . warn ( "Validation failure for tenant name={}" , name , e ) ; rslt . add ( "name" ) ; } for ( String attributeName : tenantManagerAttributes . keySet ( ) ) { try { final String value = attributes . get ( attributeName ) ; tenantService . validateAttribute ( attributeName , value ) ; } catch ( Exception e ) { log . warn ( "Validation failure for tenant name={}" , name , e ) ; rslt . add ( attributeName ) ; } } return rslt ; }
Returns a collection of invalid fields if any .
34,757
protected Map < D , SortedSet < T > > getDefaultGroupedColumnDiscriminatorMap ( F form ) { List < Long > groups = form . getGroups ( ) ; final Map < D , SortedSet < T > > groupedAggregations = new TreeMap < D , SortedSet < T > > ( ( Comparator < ? super D > ) getDiscriminatorComparator ( ) ) ; for ( final Long queryGroupId : groups ) { final D groupMapping = createGroupedDiscriminatorInstance ( this . aggregatedGroupDao . getGroupMapping ( queryGroupId ) ) ; final SortedSet < T > aggregations = new TreeSet < T > ( BaseAggregationDateTimeComparator . INSTANCE ) ; groupedAggregations . put ( groupMapping , aggregations ) ; } return groupedAggregations ; }
Default implementation to create a map of the report column discriminators based on the submitted form to collate the aggregation data into each column of a report when the only grouping parameter is AggregatedGroupMapping .
34,758
protected void doHeaders ( RenderRequest request , RenderResponse response ) { try { doDispatch ( request , response ) ; } catch ( IOException | PortletException ex ) { logger . error ( "Exception rendering headers for portlet " + getPortletName ( ) + ". Aborting doHeaders" , ex ) ; } }
Used by the render method to set the response properties and headers .
34,759
protected void doRenderService ( RenderRequest request , RenderResponse response ) throws Exception { super . doRenderService ( request , response ) ; }
Processes the actual dispatching to the handler for render requests .
34,760
public int purgeCacheEntries ( CacheEntryTag tag ) { final String tagType = tag . getTagType ( ) ; final Set < Ehcache > caches = taggedCaches . getIfPresent ( tagType ) ; if ( caches == null || caches . isEmpty ( ) ) { return 0 ; } int purgeCount = 0 ; for ( final Ehcache cache : caches ) { final String cacheName = cache . getName ( ) ; final LoadingCache < CacheEntryTag , Set < Object > > cacheKeys = taggedCacheKeys . getIfPresent ( cacheName ) ; if ( cacheKeys != null ) { final Set < Object > taggedKeys = cacheKeys . asMap ( ) . remove ( tag ) ; if ( taggedKeys != null ) { final int keyCount = taggedKeys . size ( ) ; purgeCount += keyCount ; logger . debug ( "Removing {} keys from {} for tag {}" , keyCount , cacheName , tag ) ; cache . removeAll ( taggedKeys ) ; } } } return purgeCount ; }
Remove all cache entries with keys that have the specified tag
34,761
protected Set < CacheEntryTag > getTags ( Element element ) { final Object key = element . getObjectKey ( ) ; if ( key instanceof TaggedCacheEntry ) { return ( ( TaggedCacheEntry ) key ) . getTags ( ) ; } final Object value = element . getObjectValue ( ) ; if ( value instanceof TaggedCacheEntry ) { return ( ( TaggedCacheEntry ) value ) . getTags ( ) ; } return null ; }
Get the tags associated with the element
34,762
protected void putElement ( Ehcache cache , Element element ) { final Set < CacheEntryTag > tags = this . getTags ( element ) ; if ( tags != null && ! tags . isEmpty ( ) ) { final String cacheName = cache . getName ( ) ; final Object key = element . getObjectKey ( ) ; final LoadingCache < CacheEntryTag , Set < Object > > cacheKeys = taggedCacheKeys . getUnchecked ( cacheName ) ; logger . debug ( "Tracking {} tags in cache {} for key {}" , tags . size ( ) , cacheName , key ) ; for ( final CacheEntryTag tag : tags ) { final String tagType = tag . getTagType ( ) ; final Set < Ehcache > caches = taggedCaches . getUnchecked ( tagType ) ; caches . add ( cache ) ; final Set < Object > taggedKeys = cacheKeys . getUnchecked ( tag ) ; taggedKeys . add ( key ) ; } } }
If the element has a TaggedCacheKey record the tag associations
34,763
protected void removeElement ( Ehcache cache , Element element ) { final Set < CacheEntryTag > tags = this . getTags ( element ) ; if ( tags != null && ! tags . isEmpty ( ) ) { final String cacheName = cache . getName ( ) ; final LoadingCache < CacheEntryTag , Set < Object > > cacheKeys = taggedCacheKeys . getIfPresent ( cacheName ) ; if ( cacheKeys != null ) { final Object key = element . getObjectKey ( ) ; logger . debug ( "Tracking removing key cache {} with tag {} : {}" , cacheName , tags , key ) ; for ( final CacheEntryTag tag : tags ) { final Set < Object > taggedKeys = cacheKeys . getIfPresent ( tag ) ; if ( taggedKeys != null ) { taggedKeys . remove ( key ) ; } } } } }
If the element has a TaggedCacheKey remove the tag associations
34,764
public Evaluator getAttributeEvaluator ( String name , String mode , String value ) throws Exception { return new AttributeEvaluator ( name , mode , value ) ; }
returns an Evaluator unique to the type of attribute being evaluated . subclasses can override this method to return the Evaluator that s appropriate to their implementation .
34,765
public synchronized void authenticate ( ) throws PortalSecurityException { if ( this . remoteUser != null ) { this . myPrincipal . setUID ( this . remoteUser ) ; final String newUid = this . myPrincipal . getUID ( ) ; if ( this . remoteUser . equals ( newUid ) ) { if ( log . isInfoEnabled ( ) ) { log . info ( "Authentication REMOTE_USER(" + this . remoteUser + ")." ) ; } this . isauth = true ; } else if ( log . isInfoEnabled ( ) ) { log . info ( "Authentication failed. REMOTE_USER(" + this . remoteUser + ") != user(" + newUid + ")." ) ; } } else if ( log . isInfoEnabled ( ) ) { log . info ( "Authentication failed. REMOTE_USER not set for(" + this . myPrincipal . getUID ( ) + ")." ) ; } super . authenticate ( ) ; return ; }
Verify that remoteUser is not null and set the principal s UID to this value .
34,766
public synchronized boolean updateNode ( IUserLayoutNodeDescription node ) throws PortalException { if ( canUpdateNode ( node ) ) { String nodeId = node . getId ( ) ; IUserLayoutNodeDescription oldNode = getNode ( nodeId ) ; if ( oldNode instanceof IUserLayoutChannelDescription ) { IUserLayoutChannelDescription oldChanDesc = ( IUserLayoutChannelDescription ) oldNode ; if ( ! ( node instanceof IUserLayoutChannelDescription ) ) { throw new PortalException ( "Change channel to folder is " + "not allowed by updateNode() method! Occurred " + "in layout for " + owner . getUserName ( ) + "." ) ; } IUserLayoutChannelDescription newChanDesc = ( IUserLayoutChannelDescription ) node ; updateChannelNode ( nodeId , newChanDesc , oldChanDesc ) ; } else { IUserLayoutFolderDescription oldFolderDesc = ( IUserLayoutFolderDescription ) oldNode ; if ( oldFolderDesc . getId ( ) . equals ( getRootFolderId ( ) ) ) throw new PortalException ( "Update of root node is not currently allowed!" ) ; if ( node instanceof IUserLayoutFolderDescription ) { IUserLayoutFolderDescription newFolderDesc = ( IUserLayoutFolderDescription ) node ; updateFolderNode ( nodeId , newFolderDesc , oldFolderDesc ) ; } } this . updateCacheKey ( ) ; return true ; } return false ; }
Handles pushing changes made to the passed - in node into the user s layout . If the node is an ILF node then the change is recorded via directives in the PLF if such changes are allowed by the owning fragment . If the node is a user owned node then the changes are applied directly to the corresponding node in the PLF .
34,767
private void updateFolderNode ( String nodeId , IUserLayoutFolderDescription newFolderDesc , IUserLayoutFolderDescription oldFolderDesc ) throws PortalException { Element ilfNode = ( Element ) getUserLayoutDOM ( ) . getElementById ( nodeId ) ; List < ILayoutProcessingAction > pendingActions = new ArrayList < ILayoutProcessingAction > ( ) ; if ( isFragmentOwner && ( newFolderDesc . isDeleteAllowed ( ) != oldFolderDesc . isDeleteAllowed ( ) || newFolderDesc . isEditAllowed ( ) != oldFolderDesc . isEditAllowed ( ) || newFolderDesc . isAddChildAllowed ( ) != oldFolderDesc . isAddChildAllowed ( ) || newFolderDesc . isMoveAllowed ( ) != oldFolderDesc . isMoveAllowed ( ) ) ) { pendingActions . add ( new LPAEditRestriction ( owner , ilfNode , newFolderDesc . isMoveAllowed ( ) , newFolderDesc . isDeleteAllowed ( ) , newFolderDesc . isEditAllowed ( ) , newFolderDesc . isAddChildAllowed ( ) ) ) ; } updateNodeAttribute ( ilfNode , nodeId , Constants . ATT_NAME , newFolderDesc . getName ( ) , oldFolderDesc . getName ( ) , pendingActions ) ; for ( Iterator itr = pendingActions . iterator ( ) ; itr . hasNext ( ) ; ) { ILayoutProcessingAction action = ( ILayoutProcessingAction ) itr . next ( ) ; action . perform ( ) ; } }
Compares the new folder description object with the old folder description object to determine what items were changed and if those changes are allowed . Once all changes are verified as being allowed changes then they are pushed into both the ILF and the PLF as appropriate . No changes are made until we determine that all changes are allowed .
34,768
private void updateNodeAttribute ( Element ilfNode , String nodeId , String attName , String newVal , String oldVal , List < ILayoutProcessingAction > pendingActions ) throws PortalException { if ( newVal == null && oldVal != null || newVal != null && oldVal == null || ( newVal != null && oldVal != null && ! newVal . equals ( oldVal ) ) ) { boolean isIncorporated = nodeId . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ; if ( isIncorporated ) { FragmentNodeInfo fragNodeInf = this . distributedLayoutStore . getFragmentNodeInfo ( nodeId ) ; if ( fragNodeInf == null ) { pendingActions . add ( new LPAChangeAttribute ( nodeId , attName , newVal , owner , ilfNode ) ) ; } else if ( ! fragNodeInf . canOverrideAttributes ( ) ) { throw new PortalException ( "Layout element '" + fragNodeInf . getAttributeValue ( attName ) + "' does not allow overriding attribute '" + attName + "'." ) ; } else if ( ! fragNodeInf . getAttributeValue ( attName ) . equals ( newVal ) ) { pendingActions . add ( new LPAChangeAttribute ( nodeId , attName , newVal , owner , ilfNode ) ) ; } else { pendingActions . add ( new LPAResetAttribute ( nodeId , attName , fragNodeInf . getAttributeValue ( attName ) , owner , ilfNode ) ) ; } } else { pendingActions . add ( new LPAChangeAttribute ( nodeId , attName , newVal , owner , ilfNode ) ) ; } } }
Handles checking for updates to a named attribute verifying such change is allowed and generates an action object to make that change .
34,769
private Map getPublishedChannelParametersMap ( String channelPublishId ) throws PortalException { try { IPortletDefinitionRegistry registry = PortletDefinitionRegistryLocator . getPortletDefinitionRegistry ( ) ; IPortletDefinition def = registry . getPortletDefinition ( channelPublishId ) ; return def . getParametersAsUnmodifiableMap ( ) ; } catch ( Exception e ) { throw new PortalException ( "Unable to acquire channel definition." , e ) ; } }
Return a map parameter names to channel parameter objects representing the parameters specified at publish time for the channel with the passed - in publish id .
34,770
protected boolean canDeleteNode ( IUserLayoutNodeDescription node ) throws PortalException { if ( node == null ) return false ; return isFragmentOwner || node . isDeleteAllowed ( ) ; }
Returns true if the node exists in the underlying DOM model and it does not contain a deleteAllowed attribute with a value of false .
34,771
public boolean canUpdateNode ( IUserLayoutNodeDescription node ) { if ( node == null ) return false ; return isFragmentOwner || node . isEditAllowed ( ) || node instanceof IUserLayoutChannelDescription ; }
Returns true if we are dealing with a fragment layout or if editing of attributes is allowed or the node is a channel since ad - hoc parameters can always be added .
34,772
public String getSubscribeId ( String fname ) { final Document userLayout = this . getUserLayoutDOM ( ) ; return new PortletSubscribeIdResolver ( fname ) . traverseDocument ( userLayout ) ; }
Returns the subscribe ID of a channel having the passed in functional name or null if it can t find such a channel in the layout .
34,773
public boolean resetLayout ( String loginId ) { boolean resetSuccess = false ; boolean resetCurrentUserLayout = ( null == loginId ) ; if ( resetCurrentUserLayout || ( ! resetCurrentUserLayout && AdminEvaluator . isAdmin ( owner ) ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Reset layout requested for user with id " + loginId + "." ) ; } int portalID = IPerson . UNDEFINED_ID ; IPerson person ; if ( resetCurrentUserLayout || loginId . equals ( owner . getUserName ( ) ) ) { person = owner ; portalID = owner . getID ( ) ; } else { person = PersonFactory . createPerson ( ) ; person . setAttribute ( IPerson . USERNAME , loginId ) ; try { portalID = userIdentityStore . getPortalUID ( person ) ; person . setID ( portalID ) ; } catch ( Exception e ) { } } if ( portalID != IPerson . UNDEFINED_ID ) { resetSuccess = resetLayout ( person ) ; } } else { LOG . error ( "Layout reset requested for user " + loginId + " by " + owner . getID ( ) + " who is not an administrative user." ) ; } return resetSuccess ; }
Resets the layout of the user with the specified user id if the current user is an administrator or a member of any administrative sub - group . Has no effect if these requirements are not met .
34,774
private boolean resetLayout ( IPerson person ) { final String userName = person . getUserName ( ) ; if ( PersonFactory . getGuestUsernames ( ) . contains ( userName ) ) { throw new IllegalArgumentException ( "CANNOT RESET LAYOUT FOR A GUEST USER: " + person ) ; } LOG . warn ( "Resetting user layout for: " + userName , new Throwable ( ) ) ; boolean layoutWasReset = false ; try { userIdentityStore . removePortalUID ( person . getID ( ) ) ; userIdentityStore . getPortalUID ( person , true ) ; if ( person == owner ) { this . layoutCachingService . removeCachedLayout ( person , profile ) ; updateCacheKey ( ) ; getUserLayoutDOM ( ) ; } layoutWasReset = true ; } catch ( Exception e ) { LOG . error ( "Unable to reset layout for " + person . getUserName ( ) + "." , e ) ; } return layoutWasReset ; }
Resets the layout of the specified user .
34,775
protected String getDefaultTabIndex ( HttpServletRequest httpServletRequest ) { final String stylesheetParameter = this . stylesheetUserPreferencesService . getStylesheetParameter ( httpServletRequest , PreferencesScope . STRUCTURE , this . defaultTabParameter ) ; if ( stylesheetParameter != null ) { return stylesheetParameter ; } final IStylesheetDescriptor stylesheetDescriptor = this . stylesheetUserPreferencesService . getStylesheetDescriptor ( httpServletRequest , PreferencesScope . STRUCTURE ) ; final IStylesheetParameterDescriptor stylesheetParameterDescriptor = stylesheetDescriptor . getStylesheetParameterDescriptor ( this . defaultTabParameter ) ; if ( stylesheetParameterDescriptor != null ) { return stylesheetParameterDescriptor . getDefaultValue ( ) ; } return null ; }
Get the index of the default tab for the user
34,776
public void delete ( IEntityLock lock ) throws LockingException { Map m = getLockCache ( lock . getEntityType ( ) ) ; synchronized ( m ) { m . remove ( getCacheKey ( lock ) ) ; } }
Deletes this IEntityLock from the store .
34,777
public IEntityLock find ( IEntityLock lock ) throws LockingException { IEntityLock foundLock = null ; Map m = getLockCache ( lock . getEntityType ( ) ) ; foundLock = getLockFromCache ( getCacheKey ( lock ) , m ) ; if ( foundLock != null ) { if ( lock . getLockType ( ) != foundLock . getLockType ( ) || ! lock . getExpirationTime ( ) . equals ( foundLock . getExpirationTime ( ) ) ) { foundLock = null ; } } return foundLock ; }
Returns this lock if it exists in the store .
34,778
public void update ( IEntityLock lock , java . util . Date newExpiration , Integer newLockType ) throws LockingException { if ( find ( lock ) == null ) { throw new LockingException ( "Problem updating " + lock + " : not found in store." ) ; } primAdd ( lock , newExpiration ) ; }
Make sure the store has a reference to the lock and then add the lock to refresh the SmartCache wrapper .
34,779
private void primAdd ( IEntityLock lock , Date expiration ) throws LockingException { long now = System . currentTimeMillis ( ) ; long willExpire = expiration . getTime ( ) ; long cacheIntervalSecs = ( willExpire - now ) / 1000 ; if ( cacheIntervalSecs > 0 ) { SmartCache sc = ( SmartCache ) getLockCache ( lock . getEntityType ( ) ) ; synchronized ( sc ) { sc . put ( getCacheKey ( lock ) , lock , ( cacheIntervalSecs ) ) ; } } }
Adds this IEntityLock to the store .
34,780
public IEntityLock newReadLock ( Class entityType , String entityKey , String owner ) throws LockingException { return lockService . newLock ( entityType , entityKey , IEntityLockService . READ_LOCK , owner ) ; }
Returns a read lock for the entity type entity key and owner .
34,781
public IEntityLock newWriteLock ( Class entityType , String entityKey , String owner ) throws LockingException { return lockService . newLock ( entityType , entityKey , IEntityLockService . WRITE_LOCK , owner ) ; }
Returns a write lock for the entity type entity key and owner .
34,782
public void storeJson ( PortletPreferences prefs , String key , Object data ) throws IOException , ReadOnlyException , ValidatorException { final String configData = mapper . writeValueAsString ( data ) ; prefs . setValue ( key , configData ) ; prefs . store ( ) ; }
Stores a Java object as JSON in a portlet preference
34,783
public < E > E getJson ( PortletPreferences prefs , String key , Class < E > type ) throws IOException { final String prefValue = StringUtils . trimToNull ( prefs . getValue ( key , null ) ) ; if ( prefValue == null ) { return null ; } return mapper . readValue ( prefValue , type ) ; }
Read the specified portlet preference and parse it as a JSON string into the specified type . If the preference is null returns null .
34,784
public List < Preference > getEditableUserAttributes ( IPerson currentUser ) { EntityIdentifier ei = currentUser . getEntityIdentifier ( ) ; IAuthorizationPrincipal ap = AuthorizationServiceFacade . instance ( ) . newPrincipal ( ei . getKey ( ) , ei . getType ( ) ) ; List < Preference > allowedAttributes = new ArrayList < Preference > ( ) ; for ( Preference attr : accountEditAttributes ) { if ( ap . hasPermission ( "UP_USERS" , "EDIT_USER_ATTRIBUTE" , attr . getName ( ) ) ) { allowedAttributes . add ( attr ) ; } } return allowedAttributes ; }
Returns the collection of attributes that the specified currentUser can edit .
34,785
private String fixPortletPath ( HttpServletRequest request , IPortalUrlBuilder urlBuilder ) { String path = urlBuilder . getUrlString ( ) ; String context = request . getContextPath ( ) ; if ( StringUtils . isBlank ( context ) ) { context = "/" ; } if ( ! path . startsWith ( context + "/f/" ) ) { return path . replaceFirst ( context , context + "/f/" + loginPortletFolderName ) ; } return path ; }
This entire method is a hack! The login portlet URL only seems to load correctly if you pass in the folder name for the guest layout . For the short term allow configuration of the folder name and manually re - write the URL to include the folder if it doesn t already .
34,786
private void saveLayout ( UserView view , IPerson owner ) throws Exception { IUserProfile profile = new UserProfile ( ) ; profile . setProfileId ( view . getProfileId ( ) ) ; userLayoutStore . setUserLayout ( owner , profile , view . getLayout ( ) , true , false ) ; }
Saves the loaded layout in the database for the user and profile .
34,787
private void fragmentizeLayout ( UserView view , FragmentDefinition fragment ) { if ( view . getUserId ( ) == - 1 || view . getLayout ( ) == null ) { return ; } Pattern contentPattern = STANDARD_PATTERN ; boolean allowExpandedContent = Boolean . parseBoolean ( PropertiesManager . getProperty ( PROPERTY_ALLOW_EXPANDED_CONTENT ) ) ; if ( allowExpandedContent ) { contentPattern = EXPANDED_PATTERN ; } Element layout = view . getLayout ( ) . getDocumentElement ( ) ; Element root = ( Element ) layout . getFirstChild ( ) ; NodeList children = root . getChildNodes ( ) ; for ( int i = children . getLength ( ) - 1 ; i >= 0 ; i -- ) { Node node = children . item ( i ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE && node . getNodeName ( ) . equals ( "folder" ) ) { Element folder = ( Element ) node ; boolean isApplicable = contentPattern . matcher ( folder . getAttribute ( "type" ) ) . matches ( ) ; if ( ! isApplicable || folder . getAttribute ( "hidden" ) . equals ( "true" ) ) { try { root . removeChild ( folder ) ; } catch ( Exception e ) { throw new RuntimeException ( "Anomaly occurred while stripping out " + " portions of layout for fragment '" + fragment . getName ( ) + "'. The fragment will not be available for " + "inclusion into user layouts." , e ) ; } } } } setIdsAndAttribs ( layout , layout . getAttribute ( Constants . ATT_ID ) , "" + fragment . getId ( ) , "" + fragment . getPrecedence ( ) ) ; }
Removes unwanted and hidden folders then changes all node ids to their globally safe incorporated version .
34,788
private void setIdsAndAttribs ( Element parent , String labelBase , String index , String precedence ) { NodeList children = parent . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { if ( children . item ( i ) . getNodeType ( ) == Node . ELEMENT_NODE ) { Element child = ( Element ) children . item ( i ) ; String id = child . getAttribute ( Constants . ATT_ID ) ; if ( ! id . equals ( "" ) ) { String newId = labelBase + id ; child . setAttribute ( Constants . ATT_ID , newId ) ; child . setIdAttribute ( Constants . ATT_ID , true ) ; child . setAttributeNS ( Constants . NS_URI , Constants . ATT_FRAGMENT , index ) ; child . setAttributeNS ( Constants . NS_URI , Constants . ATT_PRECEDENCE , precedence ) ; setIdsAndAttribs ( child , labelBase , index , precedence ) ; } } } }
Recursive method that passes through a layout tree and changes all ids from the regular format of sXX or nXX to the globally safe incorporated id of form uXlXsXX or uXlXnXX indicating the user id and layout id from which this node came .
34,789
public boolean isPasswordRequested ( PortletRequest request , PortletWindow plutoPortletWindow ) throws PortletContainerException { final HttpServletRequest httpServletRequest = this . portalRequestUtils . getPortletHttpRequest ( request ) ; final IPortletWindow portletWindow = this . portletWindowRegistry . convertPortletWindow ( httpServletRequest , plutoPortletWindow ) ; final IPortletEntity portletEntity = portletWindow . getPortletEntity ( ) ; final IPortletDefinition portletDefinition = portletEntity . getPortletDefinition ( ) ; final PortletApplicationDefinition portletApplicationDescriptor = this . portletDefinitionRegistry . getParentPortletApplicationDescriptor ( portletDefinition . getPortletDefinitionId ( ) ) ; List < ? extends UserAttribute > requestedUserAttributes = portletApplicationDescriptor . getUserAttributes ( ) ; for ( final UserAttribute userAttributeDD : requestedUserAttributes ) { final String attributeName = userAttributeDD . getName ( ) ; if ( attributeName . equals ( this . passwordKey ) ) return true ; } return false ; }
Determine whether the portlet has expects a password as one of the user attributes .
34,790
private String getPassword ( ISecurityContext baseContext ) { String password = null ; IOpaqueCredentials oc = baseContext . getOpaqueCredentials ( ) ; if ( oc instanceof NotSoOpaqueCredentials ) { NotSoOpaqueCredentials nsoc = ( NotSoOpaqueCredentials ) oc ; password = nsoc . getCredentials ( ) ; } Enumeration en = baseContext . getSubContexts ( ) ; while ( password == null && en . hasMoreElements ( ) ) { ISecurityContext subContext = ( ISecurityContext ) en . nextElement ( ) ; password = this . getPassword ( subContext ) ; } return password ; }
Retrieves the users password by iterating over the user s security contexts and returning the first available cached password .
34,791
public void perform ( ) throws PortalException { if ( nodeId . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ) { ParameterEditManager . addParmEditDirective ( nodeId , name , value , person ) ; } else { Document plf = RDBMDistributedLayoutStore . getPLF ( person ) ; Element plfNode = plf . getElementById ( nodeId ) ; changeParameterChild ( plfNode , name , value ) ; } changeParameterChild ( ilfNode , name , value ) ; }
Change the parameter for a channel in both the ILF and PLF using the appropriate mechanisms for incorporated nodes versus owned nodes .
34,792
static void changeParameterChild ( Element node , String name , String value ) { if ( node != null ) { boolean foundIt = false ; for ( Element parm = ( Element ) node . getFirstChild ( ) ; parm != null ; parm = ( Element ) parm . getNextSibling ( ) ) { Attr att = parm . getAttributeNode ( Constants . ATT_NAME ) ; if ( att != null && att . getValue ( ) . equals ( name ) ) { parm . setAttribute ( Constants . ATT_VALUE , value ) ; foundIt = true ; break ; } } if ( ! foundIt ) LPAAddParameter . addParameterChild ( node , name , value ) ; } }
Look in the passed - in element for a parameter child element whose value is to be changed to the passed - in value .
34,793
@ Bean ( name = "resourcesElementsProvider" ) public ResourcesElementsProvider getResourcesElementsProvider ( ) { ResourcesElementsProviderImpl rslt = new ResourcesElementsProviderImpl ( ) ; rslt . setResourcesDao ( getResourcesDao ( ) ) ; return rslt ; }
This bean is not an element of the rendering pipeline .
34,794
protected void checkAttributesMap ( MessageContext context , String basePath , Set < String > swappableAttributes , Map < String , Attribute > attributesToCopy ) { for ( final String attribute : attributesToCopy . keySet ( ) ) { if ( ! swappableAttributes . contains ( attribute ) ) { final MessageBuilder messageBuilder = new MessageBuilder ( ) ; messageBuilder . error ( ) ; messageBuilder . source ( basePath + "[" + attribute + "].value" ) ; messageBuilder . code ( "x.is.not.a.valid.attribute" ) ; messageBuilder . arg ( attribute ) ; final MessageResolver errorMessage = messageBuilder . build ( ) ; context . addMessage ( errorMessage ) ; } } }
Checks the keys in the Map on the model against a Set to ensure there are no values in the Map that aren t also in the Set
34,795
@ RequestMapping ( value = "/layoutDoc" , method = RequestMethod . GET ) public ModelAndView getRESTController ( HttpServletRequest request , @ RequestParam ( value = "tab" , required = false ) String tab ) { final IPerson person = personManager . getPerson ( request ) ; List < LayoutPortlet > portlets = new ArrayList < LayoutPortlet > ( ) ; try { final IUserInstance ui = userInstanceManager . getUserInstance ( request ) ; final IUserPreferencesManager upm = ui . getPreferencesManager ( ) ; final IUserProfile profile = upm . getUserProfile ( ) ; final DistributedUserLayout userLayout = userLayoutStore . getUserLayout ( person , profile ) ; Document document = userLayout . getLayout ( ) ; NodeList portletNodes = null ; if ( tab != null ) { NodeList folders = document . getElementsByTagName ( "folder" ) ; for ( int i = 0 ; i < folders . getLength ( ) ; i ++ ) { Node node = folders . item ( i ) ; if ( tab . equalsIgnoreCase ( node . getAttributes ( ) . getNamedItem ( "name" ) . getNodeValue ( ) ) ) { TabListOfNodes tabNodes = new TabListOfNodes ( ) ; tabNodes . addAllChannels ( node . getChildNodes ( ) ) ; portletNodes = tabNodes ; break ; } } } else { portletNodes = document . getElementsByTagName ( "channel" ) ; } for ( int i = 0 ; i < portletNodes . getLength ( ) ; i ++ ) { try { NamedNodeMap attributes = portletNodes . item ( i ) . getAttributes ( ) ; IPortletDefinition def = portletDao . getPortletDefinitionByFname ( attributes . getNamedItem ( "fname" ) . getNodeValue ( ) ) ; LayoutPortlet portlet = new LayoutPortlet ( def ) ; portlet . setNodeId ( attributes . getNamedItem ( "ID" ) . getNodeValue ( ) ) ; String alternativeMaximizedLink = def . getAlternativeMaximizedLink ( ) ; if ( alternativeMaximizedLink != null ) { portlet . setUrl ( alternativeMaximizedLink ) ; portlet . setAltMaxUrl ( true ) ; } else { final IPortalUrlBuilder portalUrlBuilder = urlProvider . getPortalUrlBuilderByLayoutNode ( request , attributes . getNamedItem ( "ID" ) . getNodeValue ( ) , UrlType . RENDER ) ; final IPortletWindowId targetPortletWindowId = portalUrlBuilder . getTargetPortletWindowId ( ) ; if ( targetPortletWindowId != null ) { final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder . getPortletUrlBuilder ( targetPortletWindowId ) ; portletUrlBuilder . setWindowState ( WindowState . MAXIMIZED ) ; } portlet . setUrl ( portalUrlBuilder . getUrlString ( ) ) ; portlet . setAltMaxUrl ( false ) ; } portlets . add ( portlet ) ; } catch ( Exception e ) { log . warn ( "Exception construction JSON representation of mobile portlet" , e ) ; } } ModelAndView mv = new ModelAndView ( ) ; mv . addObject ( "layout" , portlets ) ; mv . setViewName ( "json" ) ; return mv ; } catch ( Exception e ) { log . error ( "Error retrieving user layout document" , e ) ; } return null ; }
A REST call to get a json feed of the current users layout . Intent was to provide a layout document without per - tab information for mobile device rendering .
34,796
public Set < IPersonAttributesGroupDefinition > getPagsDefinitions ( IPerson person ) { Set < IPersonAttributesGroupDefinition > rslt = new HashSet < > ( ) ; for ( IPersonAttributesGroupDefinition def : pagsGroupDefDao . getPersonAttributesGroupDefinitions ( ) ) { if ( hasPermission ( person , IPermission . VIEW_GROUP_ACTIVITY , def . getCompositeEntityIdentifierForGroup ( ) . getKey ( ) ) ) { rslt . add ( def ) ; } } logger . debug ( "Returning PAGS definitions '{}' for user '{}'" , rslt , person . getUserName ( ) ) ; return rslt ; }
All the definitions filtered by the user s access rights .
34,797
public synchronized void authenticate ( ) throws PortalSecurityException { this . isauth = false ; if ( this . myPrincipal . UID != null && this . myOpaqueCredentials . credentialstring != null ) { try { ILocalAccountDao accountStore = LocalAccountDaoLocator . getLocalAccountDao ( ) ; IPortalPasswordService passwordService = PortalPasswordServiceLocator . getPortalPasswordService ( ) ; ILocalAccountPerson account = accountStore . getPerson ( this . myPrincipal . UID ) ; if ( account != null ) { String loginPassword = new String ( this . myOpaqueCredentials . credentialstring , UTF_8 ) ; if ( passwordService . validatePassword ( loginPassword , account . getPassword ( ) ) ) { String fullName = ( String ) account . getAttributeValue ( "displayName" ) ; this . myPrincipal . FullName = fullName ; if ( log . isInfoEnabled ( ) ) log . info ( "User " + this . myPrincipal . UID + " is authenticated" ) ; this . isauth = true ; } else { log . info ( "Password Invalid" ) ; } } else { if ( log . isInfoEnabled ( ) ) log . info ( "No such user: " + this . myPrincipal . UID ) ; } } catch ( Exception e ) { log . error ( "Error authenticating user" , e ) ; throw new RuntimeException ( "Error authenticating user" , e ) ; } } else { log . info ( "Principal or OpaqueCredentials not initialized prior to authenticate" ) ; } super . authenticate ( ) ; return ; }
Authenticate user .
34,798
@ Resource ( name = "portletPropertyToAttributeMappings" ) public void setPropertyMappings ( Map < String , String > propertyMappings ) { this . propertyToAttributeMappings = ImmutableBiMap . copyOf ( propertyMappings ) ; this . attributeToPropertyMappings = this . propertyToAttributeMappings . inverse ( ) ; }
Map of portlet property names to attribute names if the value is null the key will be used for both the property and attribute name
34,799
@ Resource ( name = "nonNamespacedPortletProperties" ) public void setNonNamespacedProperties ( Set < String > nonNamespacedProperties ) { this . nonNamespacedProperties = ImmutableSet . copyOf ( nonNamespacedProperties ) ; }
Properties that should not be namespaced with the portlet s windowId when stored as request attributes