//# 0 errors, 78 messages
//#
/*
    //#UIActionInterceptor.java:1:1: class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.struts2.util;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.business.UserManager;
import org.apache.roller.weblogger.pojos.Weblog;
import org.apache.roller.weblogger.ui.core.RollerSession;
import org.apache.struts2.StrutsStatics;


/**
 * A struts2 interceptor for configuring specifics of the weblogger ui.
 */
public class UIActionInterceptor extends AbstractInterceptor 
    //#UIActionInterceptor.java:38: method: void org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor()
    //#UIActionInterceptor.java:38: Warning: method not available
    //#    -- call on void com.opensymphony.xwork2.interceptor.AbstractInterceptor()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: void org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor()
    //#    unanalyzed callee: void com.opensymphony.xwork2.interceptor.AbstractInterceptor()
    //#input(void org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor()): this
    //#UIActionInterceptor.java:38: end of method: void org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor()
        implements StrutsStatics {
    
    private static Log log = LogFactory.getLog(UIActionInterceptor.class);
    //#UIActionInterceptor.java:41: method: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init
    //#UIActionInterceptor.java:41: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIActionInterceptor]
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): __Dispatch_Table.intercept(Lcom/opensymphony/xwork2/ActionInvocation;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): log
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIActionInterceptor] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): __Dispatch_Table.intercept(Lcom/opensymphony/xwork2/ActionInvocation;)Ljava/lang/String; == &intercept
    //#post(org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init): init'ed(log)
    //#UIActionInterceptor.java:41: end of method: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor__static_init
    
    
    public String intercept(ActionInvocation invocation) throws Exception {
        
        log.debug("Entering UIActionInterceptor");
    //#UIActionInterceptor.java:46: method: String org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.intercept(ActionInvocation)
    //#UIActionInterceptor.java:46: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    //#input(String intercept(ActionInvocation)): "Error looking up action weblog - "._tainted
    //#input(String intercept(ActionInvocation)): invocation
    //#input(String intercept(ActionInvocation)): log
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/Templates.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/Templates.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/Templates.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogRemove.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogRemove.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/editor/WeblogRemove.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/Templates]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/editor/WeblogRemove]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[org/apache/roller/weblogger/ui/struts2/util/UIAction]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Descendant_Table[others]
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Dispatch_Table.getWeblog()Ljava/lang/String;
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Dispatch_Table.setActionWeblog(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#input(String intercept(ActionInvocation)): org/apache/roller/weblogger/ui/struts2/util/UIAction.__Dispatch_Table.setAuthenticatedUser(Lorg/apache/roller/weblogger/pojos/User;)V
    //#output(String intercept(ActionInvocation)): return_value
    //#pre[1] (String intercept(ActionInvocation)): invocation != null
    //#pre[2] (String intercept(ActionInvocation)): log != null
    //#presumption(String intercept(ActionInvocation)): action.__Tag@48 in {org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit, org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit, org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove, org/apache/roller/weblogger/ui/struts2/editor/Templates, org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit, org/apache/roller/weblogger/ui/struts2/editor/WeblogConfig, org/apache/roller/weblogger/ui/struts2/editor/WeblogRemove, org/apache/roller/weblogger/ui/struts2/util/UIAction}
    //#presumption(String intercept(ActionInvocation)): com.opensymphony.xwork2.ActionInvocation:getInvocationContext(...)@49 != null
    //#presumption(String intercept(ActionInvocation)): org.apache.roller.weblogger.business.Weblogger:getUserManager(...)@71 != null
    //#presumption(String intercept(ActionInvocation)): org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@71 != null
    //#post(String intercept(ActionInvocation)): init'ed(return_value)
    //#test_vector(String intercept(ActionInvocation)): org.apache.commons.lang.StringUtils:isEmpty(...)@68: {1}, {0}
    //#test_vector(String intercept(ActionInvocation)): org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(...)@72: Addr_Set{null}, Inverse{null}
    //#test_vector(String intercept(ActionInvocation)): org.apache.roller.weblogger.ui.core.RollerSession:getRollerSession(...)@61: Addr_Set{null}, Inverse{null}
        
        final Object action = invocation.getAction();
    //#UIActionInterceptor.java:48: Warning: method not available
    //#    -- call on Object com.opensymphony.xwork2.ActionInvocation:getAction()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: Object com.opensymphony.xwork2.ActionInvocation:getAction()
        final ActionContext context = invocation.getInvocationContext();
    //#UIActionInterceptor.java:49: Warning: method not available
    //#    -- call on ActionContext com.opensymphony.xwork2.ActionInvocation:getInvocationContext()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: ActionContext com.opensymphony.xwork2.ActionInvocation:getInvocationContext()
        
        HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
    //#UIActionInterceptor.java:51: Warning: method not available
    //#    -- call on Object com.opensymphony.xwork2.ActionContext:get(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: Object com.opensymphony.xwork2.ActionContext:get(Object)
        
        // is this one of our own UIAction classes?
        if (action instanceof UIAction) {
            
            log.debug("action is a UIAction, setting relevant attributes");
    //#UIActionInterceptor.java:56: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            
            UIAction theAction = (UIAction) action;
            
            // extract the authenticated user and set it
            RollerSession rses = RollerSession.getRollerSession(request);
    //#UIActionInterceptor.java:61: Warning: method not available
    //#    -- call on RollerSession org.apache.roller.weblogger.ui.core.RollerSession:getRollerSession(HttpServletRequest)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: RollerSession org.apache.roller.weblogger.ui.core.RollerSession:getRollerSession(HttpServletRequest)
            if(rses != null) {
                theAction.setAuthenticatedUser(rses.getAuthenticatedUser());
    //#UIActionInterceptor.java:63: Warning: method not available
    //#    -- call on User org.apache.roller.weblogger.ui.core.RollerSession:getAuthenticatedUser()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: User org.apache.roller.weblogger.ui.core.RollerSession:getAuthenticatedUser()
            }
            
            // extract the work weblog and set it
            String weblogHandle = theAction.getWeblog();
            if(!StringUtils.isEmpty(weblogHandle)) {
    //#UIActionInterceptor.java:68: Warning: method not available
    //#    -- call on bool org.apache.commons.lang.StringUtils:isEmpty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: bool org.apache.commons.lang.StringUtils:isEmpty(String)
                Weblog weblog = null;
    //#UIActionInterceptor.java:69: Warning: unused assignment
    //#    unused assignment into weblog
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    Attribs:  Uncertain
                try {
                    UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
    //#UIActionInterceptor.java:71: Warning: method not available
    //#    -- call on Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#UIActionInterceptor.java:71: Warning: method not available
    //#    -- call on UserManager org.apache.roller.weblogger.business.Weblogger:getUserManager()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: UserManager org.apache.roller.weblogger.business.Weblogger:getUserManager()
                    weblog = mgr.getWebsiteByHandle(weblogHandle);
    //#UIActionInterceptor.java:72: Warning: method not available
    //#    -- call on Weblog org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: Weblog org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(String)
                    if(weblog != null) {
                        theAction.setActionWeblog(weblog);
                    }
                } catch(Exception e) {
                    log.error("Error looking up action weblog - "+weblogHandle, e);
    //#UIActionInterceptor.java:77: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
                }
            }
        }
        
        return invocation.invoke();
    //#UIActionInterceptor.java:82: Warning: method not available
    //#    -- call on String com.opensymphony.xwork2.ActionInvocation:invoke()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
    //#    method: String intercept(ActionInvocation)
    //#    unanalyzed callee: String com.opensymphony.xwork2.ActionInvocation:invoke()
    //#UIActionInterceptor.java:82: end of method: String org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor.intercept(ActionInvocation)
    }
    
}
    //#UIActionInterceptor.java:: end of class: org.apache.roller.weblogger.ui.struts2.util.UIActionInterceptor
