📄 servicedetailsaction.java
字号:
/* * ServiceDetailsAction.java * * Created on July 21, 2003, 3:02 PM */package gov.nist.struts.webapp.monitor;import gov.nist.security.authentication.UserTag;import java.io.File;import java.util.Vector;import javax.servlet.*;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;/** * The class represents the action of see the standard output log of a service * @author DERUELLE Jean */public class ServiceDetailsAction extends org.apache.struts.action.Action { /** * @see org.apache.struts.action.Action#perform(org.apache.struts.action.ActionMapping actionMapping, org.apache.struts.action.ActionForm actionForm, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) */ public org.apache.struts.action.ActionForward perform(org.apache.struts.action.ActionMapping actionMapping, org.apache.struts.action.ActionForm actionForm, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws java.io.IOException, javax.servlet.ServletException { ServiceForm startServiceForm=(ServiceForm)actionForm; //Get the file name String mainClass=startServiceForm.getMainClass(); String userURI=startServiceForm.getUserURI(); UserTag userTag=findUser(userURI); String path=startServiceForm.getPath(); if(path==null){ //Get the application context ServletContext applicationContext=this.getServlet().getServletContext(); //String uploadPath=(String)httpServletRequest.getSession().getAttribute("uploadPath"); //constructs the upload path from the session context //Done this way because admin can start services of other users String uploadLocation=(String)applicationContext.getAttribute("uploadDirectory"); String uploadPath= uploadLocation.concat(userTag.getUserGroup())+ File.separatorChar+ userTag.getUserName()+File.separatorChar; String logPath=uploadPath.concat(mainClass+"_log.txt"); java.io.File dir=new java.io.File(logPath); if(!dir.exists()){ ActionErrors errors = new ActionErrors(); errors.add("path", new ActionError("error.file.does.not.exist")); saveErrors(httpServletRequest, errors); return actionMapping.findForward("error"); } httpServletRequest.setAttribute("logFile",logPath); return actionMapping.findForward("details"); } else{ ServletContext applicationContext=this.getServlet().getServletContext(); String uploadPath=(String)httpServletRequest.getSession().getAttribute("uploadPath"); String logPath=uploadPath+"dump//"+path+"//"+mainClass; java.io.File dir=new java.io.File(logPath); if(!dir.exists()){ ActionErrors errors = new ActionErrors(); errors.add("path", new ActionError("error.file.does.not.exist")); saveErrors(httpServletRequest, errors); return actionMapping.findForward("error"); } httpServletRequest.setAttribute("logFile",logPath); return actionMapping.findForward("details"); } } private UserTag findUser(String userURI){ //Get the application context ServletContext applicationContext=this.getServlet().getServletContext(); //Get the database of the users Vector users=(Vector)applicationContext.getAttribute("users"); if(users!=null){ for(int i=0;i<users.size();i++){ UserTag user=(UserTag)users.elementAt(i); if(user.getUri().equalsIgnoreCase(userURI) ) return user; } } return null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -