private boolean moveElementInternal ( HttpServletRequest request , String sourceId , String destinationId , String method ) { logger . debug ( "moveElementInternal invoked for sourceId={}, destinationId={}, method={}" , sourceId , destinationId , method ) ; if ( StringUtils . isEmpty ( destinationId ) ) { // shortcut for beginning and end return true ; } IUserInstance ui = userInstanceManager . getUserInstance ( request ) ; UserPreferencesManager upm = ( UserPreferencesManager ) ui . getPreferencesManager ( ) ; IUserLayoutManager ulm = upm . getUserLayoutManager ( ) ; boolean success = false ; if ( isTab ( ulm , destinationId ) ) { // If the target is a tab type node, move the element to the end of the first column. // TODO Try to insert it into the first available column if multiple columns Enumeration < String > columns = ulm . getChildIds ( destinationId ) ; if ( columns . hasMoreElements ( ) ) { success = attemptNodeMove ( ulm , sourceId , columns . nextElement ( ) , null ) ; } else { // Attempt to create a new column IUserLayoutFolderDescription newColumn = new UserLayoutFolderDescription ( ) ; newColumn . setName ( "Column" ) ; newColumn . setId ( "tbd" ) ; newColumn . setFolderType ( IUserLayoutFolderDescription . REGULAR_TYPE ) ; newColumn . setHidden ( false ) ; newColumn . setUnremovable ( false ) ; newColumn . setImmutable ( false ) ; // add the column to our layout IUserLayoutNodeDescription col = ulm . addNode ( newColumn , destinationId , null ) ; // If column was created (might not if the tab had addChild=false), move the // channel. if ( col != null ) { success = attemptNodeMove ( ulm , sourceId , col . getId ( ) , null ) ; } else { logger . info ( "Unable to move item into existing columns on tab {} and unable to create new column" , destinationId ) ; } } } else { // If destination is a column, attempt to move into end of column if ( isFolder ( ulm , destinationId ) ) { success = attemptNodeMove ( ulm , sourceId , destinationId , null ) ; } else { // If insertBefore move to prior to node else to end of folder containing node success = attemptNodeMove ( ulm , sourceId , ulm . getParentId ( destinationId ) , "insertBefore" . equals ( method ) ? destinationId : null ) ; } } try { if ( success ) { ulm . saveUserLayout ( ) ; } } catch ( PortalException e ) { logger . warn ( "Error saving layout" , e ) ; return false ; } return success ; }
Moves the source element .