public final int doWikiStartTag()

in jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java [104:158]


    public final int doWikiStartTag() throws IOException {
        final UserManager manager = m_wikiContext.getEngine().getManager( UserManager.class );
        final UserProfile profile = manager.getUserProfile( m_wikiContext.getWikiSession() );
        String result = null;

        if( EXISTS.equals( m_prop ) || NOT_NEW.equals( m_prop ) ) {
            return profile.isNew() ? SKIP_BODY : EVAL_BODY_INCLUDE;
        } else if( NEW.equals( m_prop ) || NOT_EXISTS.equals( m_prop ) ) {
            return profile.isNew() ? EVAL_BODY_INCLUDE : SKIP_BODY;
        } else if( CREATED.equals( m_prop ) && profile.getCreated() != null ) {
            result = profile.getCreated().toString();
        } else if( EMAIL.equals( m_prop ) ) {
            result = profile.getEmail();
        } else if( FULLNAME.equals( m_prop ) ) {
            result = profile.getFullname();
        } else if( GROUPS.equals( m_prop ) ) {
            result = printGroups( m_wikiContext );
        } else if( LOGINNAME.equals( m_prop ) ) {
            result = profile.getLoginName();
        } else if( MODIFIED.equals( m_prop ) && profile.getLastModified() != null ) {
            result = profile.getLastModified().toString();
        } else if( ROLES.equals( m_prop ) ) {
            result = printRoles( m_wikiContext );
        } else if( WIKINAME.equals( m_prop ) ) {
            result = profile.getWikiName();

            if( result == null ) {
                //
                //  Default back to the declared user name
                //
                final Engine engine = this.m_wikiContext.getEngine();
                final Session wikiSession = Wiki.session().find( engine, ( HttpServletRequest )pageContext.getRequest() );
                final Principal user = wikiSession.getUserPrincipal();

                if( user != null ) {
                    result = user.getName();
                }
            }
        } else if( CHANGE_PASSWORD.equals( m_prop ) || CHANGE_LOGIN_NAME.equals( m_prop ) ) {
            final AuthenticationManager authMgr = m_wikiContext.getEngine().getManager( AuthenticationManager.class );
            if( !authMgr.isContainerAuthenticated() ) {
                return EVAL_BODY_INCLUDE;
            }
        } else if( NOT_CHANGE_PASSWORD.equals( m_prop ) || NOT_CHANGE_LOGIN_NAME.equals( m_prop ) ) {
            final AuthenticationManager authMgr = m_wikiContext.getEngine().getManager( AuthenticationManager.class );
            if( authMgr.isContainerAuthenticated() ) {
                return EVAL_BODY_INCLUDE;
            }
        }

        if( result != null ) {
            pageContext.getOut().print( TextUtil.replaceEntities( result ) );
        }
        return SKIP_BODY;
    }