// 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;
/*
 * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. 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.
 */
package org.wso2.carbon.logging.view.ui;




/**
 * This class will handle log file related operations.
 */
public class LogFileProvider {

    private static final Log log = LogFactory.getLog(LogFileProvider.class);
    private static final String SERVER_KEY = "ServerKey";
    private static final String APPLICATION_TYPE_ZIP = "application/zip";

    /**
     * This method will return the information of log files in repository/logs.
     *
     * @param tenantDomain - Tenant domain eg: t1.com.
     * @param serverKey    Server name.
     * @return Info list of log files.
     */
// 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;

/*
 * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. 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.
 */
package org.wso2.carbon.logging.view.ui;




/**
 * This class will handle log file related operations.
 */
public class LogFileProvider {

    private static final Log log = LogFactory.getLog(LogFileProvider.class);
    private static final String SERVER_KEY = "ServerKey";
    private static final String APPLICATION_TYPE_ZIP = "application/zip";

    /**
     * This method will return the information of log files in repository/logs.
     *
     * @param tenantDomain - Tenant domain eg: t1.com.
     * @param serverKey    Server name.
     * @return Info list of log files.
     */
    public List<LogFileInfo> getLogFileInfoList(String tenantDomain, String serverKey) {