Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
//
// Copyright (C) 2010-2016 Micromata GmbH
//
// Licensed 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.
//
package de.micromata.genome.logging.loghtmlwindow;
import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue;
import de.micromata.genome.logging.LogAttributeType;
import de.micromata.genome.logging.LogCategory;
import de.micromata.genome.logging.LogConfigurationDAO;
import de.micromata.genome.logging.LogLevel;
import de.micromata.genome.logging.LogWriteEntry;
import de.micromata.genome.logging.Logging;
import de.micromata.genome.logging.Logging.OrderBy;
import de.micromata.genome.logging.LoggingServiceManager;
import de.micromata.genome.logging.spi.log4j.RoundList;
import de.micromata.genome.util.runtime.RuntimeIOException;
import de.micromata.genome.util.types.Pair;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.log4j.Logger;
/**
* Service to work with glogviewer.js.
*
* @author Roger Rene Kommer ([email protected])
*/
public abstract class LogHtmlWindowServlet extends HttpServlet {
private static final Logger LOG = Logger.getLogger(LogHtmlWindowServlet.class);
private RoundList logWriteEntries = new RoundList<>(2000);
static LogHtmlWindowServlet INSTANCE;
/**
* Will be called by doPost.
*
* If a valid user to show logs, call the execute method.
*
* @param req the servlet request
* @param resp the servlet response
* @throws ServletException exception thrown when an error happened while executing this method
* @throws IOException exception thrown when an error happened while executing this method
*/
protected abstract void executeWithAuthentifcation(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException;
@Override
public void init() {
INSTANCE = this;
LoggingServiceManager.get().getLoggingEventListenerRegistryService().registerListener(LogHtmlLiveBuffer.class);
}
public void addLogEntry(LogWriteEntry le) {
synchronized (logWriteEntries) {
logWriteEntries.add(le);
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
executeWithAuthentifcation(req, resp);
}
protected void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String cmd = req.getParameter("cmd");
if ("poll".equals(cmd) == true) {
poll(req, resp);
} else if ("getConfiguration".equals(cmd) == true) {
getConfiguration(req, resp);
} else if ("search".equals(cmd) == true) {
filter(req, resp);
} else if ("logSelectAttributes".equals(cmd) == true) {
logSelectAttributes(req, resp);
} else {
error(req, resp, "Unknown command");
}
}
private void logSelectAttributes(HttpServletRequest req, HttpServletResponse resp) throws IOException {
Logging logging = LoggingServiceManager.get().getLogging();
String id = req.getParameter("id");
Object logid = logging.parseLogId(id);
List