web.log-view.application_log_viewer.jsp Maven / Gradle / Ivy
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar"
prefix="carbon"%>
<%@ page import="org.wso2.carbon.logging.view.ui.LogViewerClient"%>
<%@ page import="org.apache.axis2.context.ConfigurationContext"%>
<%@ page import="org.wso2.carbon.CarbonConstants"%>
<%-- <%@ page --%>
<%@ page import="org.wso2.carbon.utils.ServerConstants"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil"%>
<%@ page import="org.wso2.carbon.logging.view.stub.types.carbon.PaginatedLogEvent"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIMessage"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil"%>
<%@ page import="org.wso2.carbon.ui.util.CharacterEncoder" %>
<%@ page import="org.wso2.carbon.logging.view.stub.types.carbon.LogEvent"%>
<%@ page import="java.text.SimpleDateFormat" %>
View Application Logs
<%
String backendServerURL = CarbonUIUtil
.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
LogViewerClient logViewerClient;
LogEvent[] events = null;
String type;
String keyword;
String action;
String pageNumberStr = request.getParameter("pageNumber");
int pageNumber = 0;
int numberOfPages = 0;
PaginatedLogEvent paginatedLogEvents = null;
String parameter = "";
boolean isSuperTenant = CarbonUIUtil.isSuperTenant(request);
boolean isManager = false;
String tenantDomain = request.getParameter("tenantDomain");
String serviceName = request.getParameter("serviceName");
String showMaxStr = request.getParameter("showMax");
String serviceNames[];
boolean isValidTenant = true;
boolean showMax= false;
showMax = Boolean.parseBoolean(showMaxStr);
try {
pageNumber = Integer.parseInt(pageNumberStr);
} catch (NumberFormatException ignored) {
// page number format exception
}
String appName;
String applicationNames[] = null;
try {
type = CharacterEncoder.getSafeText(request.getParameter("type"));
type = (type == null) ? "":type;
keyword = CharacterEncoder.getSafeText(request.getParameter("keyword"));
keyword = (keyword == null )? "":keyword;
action = CharacterEncoder.getSafeText(request.getParameter("action"));
appName = request.getParameter("appName");
logViewerClient = new LogViewerClient(cookie, backendServerURL, configContext);
isValidTenant = logViewerClient.isValidTenant(tenantDomain);
if (tenantDomain == null) {
tenantDomain = "";
}
if (serviceName == null) {
serviceName = "";
}
if(isValidTenant) {
applicationNames = logViewerClient.getApplicationNames(tenantDomain, serviceName);
if (appName == null && applicationNames !=null && applicationNames.length > 0) {
appName = applicationNames[0];
}
if (applicationNames == null) {
applicationNames = new String[]{"No applications"};
appName = applicationNames[0];
} else if(applicationNames != null && applicationNames.length == 0) {
applicationNames = new String[]{"No applications"};
appName = applicationNames[0];
}
paginatedLogEvents = logViewerClient.getPaginatedApplicationLogEvents(pageNumber,type,keyword,appName, tenantDomain, serviceName);
}
if (applicationNames == null) {
applicationNames = new String[]{"No applications"};
appName = applicationNames[0];
}
isManager = logViewerClient.isManager();
serviceNames = logViewerClient.getServiceNames();
if (paginatedLogEvents != null) {
events = paginatedLogEvents.getLogInfo();
numberOfPages = paginatedLogEvents.getNumberOfPages();
}
parameter = "type=" + type + "&keyword=" + keyword+ "&appName="+appName;
} catch (Exception e) {
CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR, request,
e);
%>
<%
return;
}
%>
<%
SimpleDateFormat dateFormat = new SimpleDateFormat("Z");
String date = dateFormat.format(System.currentTimeMillis());
%>
<%= "GMT " + date%>