// Path: components/logging/org.wso2.carbon.logging.view.ui/src/main/java/org/wso2/carbon/logging/view/ui/data/LogFileInfo.java
// public class LogFileInfo {
// 
//     private String logName;
//     private String logDate;
//     private String fileSize;
// 
//     public LogFileInfo(String logName, String logDate, String fileSize) {
//         this.logName = logName;
//         this.logDate = logDate;
//         this.fileSize = fileSize;
//     }
// 
//     public String getLogName() {
//         return logName;
//     }
// 
//     public void setLogName(String logName) {
//         this.logName = logName;
//     }
// 
//     public String getLogDate() {
//         return logDate;
//     }
// 
//     public void setLogDate(String logDate) {
//         this.logDate = logDate;
//     }
// 
//     public String getFileSize() {
//         return fileSize;
//     }
// 
//     public void setFileSize(String fileSize) {
//         this.fileSize = fileSize;
//     }
// }
// 
// Path: components/logging/org.wso2.carbon.logging.view.ui/src/main/java/org/wso2/carbon/logging/view/ui/util/LoggingConstants.java
// public final class LoggingConstants {
// 
//     public static final String URL_SEPARATOR = "/";
//     public static final String WSO2_STRATOS_MANAGER = "manager";
//     public static final String CONFIG_FILENAME = "cloud-services-desc.xml";
//     public static final String MULTITENANCY_CONFIG_FOLDER = "multitenancy";
// 
//     public static final class RegexPatterns {
// 
//         public static final String LOCAL_CARBON_LOG_PATTERN = "wso2carbon*.log";
//         public static final String LOG_FILE_DATE_SEPARATOR = "wso2carbon-";
//         public static final String CURRENT_LOG = "0_Current Log";
//     }
// }


import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.logging.view.ui.data.LogFileInfo;
import org.wso2.carbon.logging.view.ui.util.LoggingConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.activation.DataHandler;
import javax.mail.util.ByteArrayDataSource;
                    if (filename.contains("-")) {
                        String fileDate = filename;
                        fileDate = fileDate.substring(LoggingConstants.RegexPatterns.LOG_FILE_DATE_SEPARATOR.length(),
                                fileDate.length() - ".log".length());
                        logFileInfo = new LogFileInfo(filename, fileDate, getFileSize(logfile));
                    } else {
                        logFileInfo = new LogFileInfo(filename, LoggingConstants.RegexPatterns.CURRENT_LOG,
                                getFileSize(logfile));
                    }
                    logs.add(logFileInfo);
                }
            }
        }
        return getSortedPerLogInfoList(logs);
    }

    // return default response.
    private List<LogFileInfo> getDefaultLogInfoList() {

        List<LogFileInfo> defaultLogFileInfoList = new ArrayList<>();
        defaultLogFileInfoList.add(new LogFileInfo("NO_LOG_FILES",
                "---", "---"));
        return defaultLogFileInfoList;
    }

    private String getCurrentServerName() {
        return ServerConfiguration.getInstance().getFirstProperty(SERVER_KEY);
    }

    private boolean isSuperTenantUser() {
// Path: components/logging/org.wso2.carbon.logging.view.ui/src/main/java/org/wso2/carbon/logging/view/ui/data/LogFileInfo.java
// public class LogFileInfo {
// 
//     private String logName;
//     private String logDate;
//     private String fileSize;
// 
//     public LogFileInfo(String logName, String logDate, String fileSize) {
//         this.logName = logName;
//         this.logDate = logDate;
//         this.fileSize = fileSize;
//     }
// 
//     public String getLogName() {
//         return logName;
//     }
// 
//     public void setLogName(String logName) {
//         this.logName = logName;
//     }
// 
//     public String getLogDate() {
//         return logDate;
//     }
// 
//     public void setLogDate(String logDate) {
//         this.logDate = logDate;
//     }
// 
//     public String getFileSize() {
//         return fileSize;
//     }
// 
//     public void setFileSize(String fileSize) {
//         this.fileSize = fileSize;
//     }
// }
// 
// Path: components/logging/org.wso2.carbon.logging.view.ui/src/main/java/org/wso2/carbon/logging/view/ui/util/LoggingConstants.java
// public final class LoggingConstants {
// 
//     public static final String URL_SEPARATOR = "/";
//     public static final String WSO2_STRATOS_MANAGER = "manager";
//     public static final String CONFIG_FILENAME = "cloud-services-desc.xml";
//     public static final String MULTITENANCY_CONFIG_FOLDER = "multitenancy";
// 
//     public static final class RegexPatterns {
// 
//         public static final String LOCAL_CARBON_LOG_PATTERN = "wso2carbon*.log";
//         public static final String LOG_FILE_DATE_SEPARATOR = "wso2carbon-";
//         public static final String CURRENT_LOG = "0_Current Log";
//     }
// }


// Path: components/logging/org.wso2.carbon.logging.view.ui/src/main/java/org/wso2/carbon/logging/view/ui/LogFileProvider.java
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.logging.view.ui.data.LogFileInfo;
import org.wso2.carbon.logging.view.ui.util.LoggingConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.activation.DataHandler;
import javax.mail.util.ByteArrayDataSource;

                    if (filename.contains("-")) {
                        String fileDate = filename;
                        fileDate = fileDate.substring(LoggingConstants.RegexPatterns.LOG_FILE_DATE_SEPARATOR.length(),
                                fileDate.length() - ".log".length());
                        logFileInfo = new LogFileInfo(filename, fileDate, getFileSize(logfile));
                    } else {
                        logFileInfo = new LogFileInfo(filename, LoggingConstants.RegexPatterns.CURRENT_LOG,
                                getFileSize(logfile));
                    }
                    logs.add(logFileInfo);
                }
            }
        }
        return getSortedPerLogInfoList(logs);
    }

    // return default response.
    private List<LogFileInfo> getDefaultLogInfoList() {

        List<LogFileInfo> defaultLogFileInfoList = new ArrayList<>();
        defaultLogFileInfoList.add(new LogFileInfo("NO_LOG_FILES",
                "---", "---"));
        return defaultLogFileInfoList;
    }

    private String getCurrentServerName() {
        return ServerConfiguration.getInstance().getFirstProperty(SERVER_KEY);
    }

    private boolean isSuperTenantUser() {
        CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();