file_name stringlengths 6 86 | file_path stringlengths 45 249 | content stringlengths 47 6.26M | file_size int64 47 6.26M | language stringclasses 1 value | extension stringclasses 1 value | repo_name stringclasses 767 values | repo_stars int64 8 14.4k | repo_forks int64 0 1.17k | repo_open_issues int64 0 788 | repo_created_at stringclasses 767 values | repo_pushed_at stringclasses 767 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
VerificationService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/VerificationService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssNotice;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2File;
public interface VerificationService {
Map<String, Object> getVerificationOne(Project project);
Map<String, Object> registOssNotice(OssNotice ossNotice);
String getNoticeHtml(OssNotice ossNotice) throws IOException;
boolean getNoticeHtmlFile(OssNotice ossNotice) throws IOException;
boolean getNoticeHtmlFile(OssNotice ossNotice, String html) throws IOException;
boolean getReviewReportPdfFile(String prjId) throws IOException;
boolean getReviewReportPdfFile(String prjId, String html) throws IOException;
ResponseEntity<FileSystemResource> getNotice(String fileName, String rESOURCE_PUBLIC_DOWNLOAD_EXCEL_PATH_PREFIX) throws IOException;
ResponseEntity<FileSystemResource> getReviewReport(String fileName, String rESOURCE_PUBLIC_DOWNLOAD_REVIEW_REPORT_FILE_PATH_PREFIX) throws IOException;
ResponseEntity<FileSystemResource> getPackage(String prjId, String rESOURCE_PUBLIC_DOWNLOAD_EXCEL_PATH_PREFIX) throws IOException;
ResponseEntity<FileSystemResource> getPackageMulti(String prjId, String rESOURCE_PUBLIC_DOWNLOAD_EXCEL_PATH_PREFIX, String fileIdx) throws IOException;
List<OssComponents> getVerifyOssList(Project projectMaster);
Map<String, Object> processVerification(Map<Object, Object> map, T2File file, Project project);
void savePath(Map<Object, Object> map);
String getNoticeHtmlFileForPreview(OssNotice ossNotice) throws IOException;
boolean checkNetworkServer(String prjId);
String getNoticeTextFileForPreview(OssNotice ossNotice) throws IOException;
String getNoticeTextFileForPreview(OssNotice ossNotice, boolean isConfirm) throws IOException;
void changePackageFileNameDistributeFormat(String prjId);
Map<String, Object> getNoticeHtmlInfo(OssNotice ossNotice);
Map<String, Object> getNoticeHtmlInfo(OssNotice ossNotice, boolean isProtocol);
OssNotice selectOssNoticeOne(String prjId);
void updateStatusWithConfirm(Project project, OssNotice ossNotice, boolean copyConfirmFlag) throws Exception;
Map<String, Integer> setAddFileCount(Map<String, Integer> deCompResultMap, String url, int fileCnt) throws Exception;
List<String> sortByValue(Map<String, Integer> map) throws Exception;
void updateVerifyFileCount(HashMap<String,Object> fileCounts);
void updateVerifyFileCount(ArrayList<String> fileCounts);
boolean getChangedPackageFile(String prjId, List<String> fileSeqs);
Map<String, Object> getReuseProject(Project project);
Map<String, Object> getReuseProjectPackagingFile(Project project);
boolean setReusePackagingFile(Map<String, Object> map);
List<OssComponents> setMergeGridData(List<OssComponents> gridData);
void setUploadFileSave(String prjId, String fileSeq, String registFileId) throws Exception;
public void updateProjectAllowDownloadBitFlag(Project project);
void registOssNoticeConfirmStatus(OssNotice ossNotice);
String changePackageFileNameCombine(String prjId);
void deleteFile(Map<Object, Object> map);
} | 3,550 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
NoticeService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/NoticeService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import oss.fosslight.domain.Notice;
public interface NoticeService {
Map<String, Object> getNoticeList(Notice vo) throws Exception;
public void setNotice(Notice vo) throws Exception;
Map<String, Object> getPublishedNotice(Notice vo) throws Exception;
}
| 427 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiBatService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiBatService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
public interface ApiBatService {
public List<Map<String, Object>> getBatList(Map<String, Object> paramMap);
}
| 282 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
MailService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/MailService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import oss.fosslight.domain.History;
public interface MailService {
public void sendMailRunTimeout();
public void sendMail(History h, String[] receivers /*์์ ์*/, String[] ccIds/*์ฐธ์กฐ*/, String[] bccIds/*์จ์์ฐธ์กฐ*/);
public String[] selectMailAddrFromIds(String[] toIds);
public void sendTempMail();
}
| 448 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SentMailService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/SentMailService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import oss.fosslight.domain.CoMail;
public interface SentMailService {
Map<String, Object> getMailList(CoMail vo);
}
| 281 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
NvdDataService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/NvdDataService.java | package oss.fosslight.service;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.file.Paths;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TimeZone;
import javax.annotation.PostConstruct;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.ibatis.session.SqlSessionFactory;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.repository.NvdDataMapper;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
@Service("NvdDataService")
public class NvdDataService {
final static Logger log = LoggerFactory.getLogger("SCHEDULER_LOG");
private final String NVD_DATA_FILE_NAME_CPEMATCH = "nvdcpematch-1.0";
private final String NVD_DATA_FILE_NAME_NVDCVE = "nvdcve-1.1-modified";
private final String NVD_META_URL = "https://nvd.nist.gov/feeds/json/cpematch/1.0/";
private final String NVD_CVE_URL = "https://nvd.nist.gov/feeds/json/cve/1.1/";
private final String NVD_META_REST_URL = "https://services.nvd.nist.gov/rest/json/cpematch/2.0";
private final String NVD_CVE_REST_URL = "https://services.nvd.nist.gov/rest/json/cves/2.0";
private final String NVD_API_KEY = CommonFunction.getProperty("nvd.nist.gov.api.key");
private final int BATCH_SIZE = 1000;
private String JDBC_DRIVER;
private String DB_URL;
private String USERNAME;
private String PASSWORD;
private String lastModStartDate;
private String lastModEndDate;
boolean initializeFlag = false;
@Autowired NvdDataMapper nvdDataMapper;
@Autowired CodeMapper codeMapper;
@Autowired Environment env;
@Autowired SqlSessionFactory sqlSessionFactory;
@PostConstruct
public void setResourcePathPrefix(){
JDBC_DRIVER = env.getRequiredProperty("spring.datasource.driver-class-name");
DB_URL = env.getRequiredProperty("spring.datasource.url");
if (!DB_URL.startsWith("jdbc:mariadb")) DB_URL = "jdbc:mariadb://" + DB_URL;
USERNAME = env.getRequiredProperty("spring.datasource.username");
PASSWORD = env.getRequiredProperty("spring.datasource.password");
}
public String executeNvdDataSync() throws IOException {
// GET Nvd Meta Data
// ์์
๋ฑ๋ก
// try {
// boolean fileCheck = nvdMetaCheckJob(NVD_DATA_FILE_NAME_CPEMATCH, "MATCH");
// if (!fileCheck) {
// fileCheck = nvdMetaRetryCheckJob(NVD_DATA_FILE_NAME_CPEMATCH, "MATCH", fileCheck, 0);
// }
//
// if (fileCheck) {
// nvdFeedDataDownloadJob(NVD_DATA_FILE_NAME_CPEMATCH);
// nvdMetaDataSyncJob();
// }
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// return "91";
// }
try {
// rest api NVD Data
// check initialize flag
if ("Y".equalsIgnoreCase(codeMapper.getCodeDtlNm("990", "100")) ) {
codeMapper.updateCodeDtlNm("990", "100", "N");
initializeFlag = true;
}
} catch (Exception e) {
log.error("Failed to NVD Data initiallize", e);
}
if (!initializeFlag) {
Date today = new Date();
SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
sdformat.setTimeZone(TimeZone.getTimeZone("UTC"));
Calendar cal = Calendar.getInstance();
cal.setTime(today);
cal.add(Calendar.HOUR, -1);
String endTime = sdformat.format(cal.getTime());
Calendar mon = Calendar.getInstance();
mon.add(Calendar.MONTH, -1);
String startTime = sdformat.format(mon.getTime());
lastModStartDate = startTime + "%2B01:00";
lastModEndDate = endTime + "%2B01:00";
}
try {
Map<String, Object> rtnMap = nvdMetaDataApiCheckJob(NVD_META_REST_URL, 1, 0);
if (rtnMap.containsKey("checkUrlFlag") && !(boolean) rtnMap.get("checkUrlFlag")) {
rtnMap = nvdMetaDataApiJob(NVD_META_REST_URL, 2000, rtnMap);
if (!(boolean) rtnMap.get("connectionFlag")) {
log.info("nvd meta api connection error");
return "91";
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return "91";
}
// try {
// initialize NVD Data Feed
// check initialize flag
// if ("Y".equalsIgnoreCase(codeMapper.getCodeDtlNm("990", "100")) ) {
// codeMapper.updateCodeDtlNm("990", "100", "N");
// delete all NVD Data and Max Score
// resetNvdFeedData();
// Put NVD Data feed from CPE2002 ~ current date year
// initNvdDataFeed();
// }
// } catch (Exception e) {
// log.error("Failed to NVD Data initiallize", e);
// }
try {
Map<String, Object> rtnMap = nvdMetaDataApiCheckJob(NVD_CVE_REST_URL, 1, 0);
if (rtnMap.containsKey("checkUrlFlag") && !(boolean) rtnMap.get("checkUrlFlag")) {
rtnMap = nvdCveDataApiJob(NVD_CVE_REST_URL, 2000, rtnMap);
if ((boolean) rtnMap.get("connectionFlag")) {
nvdCveDataSyncJob(true);
} else {
log.info("nvd meta api connection error");
return "91";
}
}
// boolean fileCheck = nvdMetaCheckJob(NVD_DATA_FILE_NAME_NVDCVE, "CVE");
// if (!fileCheck) {
// fileCheck = nvdMetaRetryCheckJob(NVD_DATA_FILE_NAME_NVDCVE, "CVE", fileCheck, 0);
// }
//
// if (fileCheck) {
// nvdFeedDataDownloadJob(NVD_DATA_FILE_NAME_NVDCVE);
// nvdCveDataSyncJob();
// }
} catch (Exception e) {
log.error(e.getMessage(), e);
return "92";
}
initializeFlag = false;
return "00";
}
@SuppressWarnings("unchecked")
@Transactional
public Map<String, Object> nvdCveDataApiJob(String restApiUrl, int resultsPerPage, Map<String, Object> rtnMap) {
int totalResults = (int) rtnMap.get("totalResults");
String urlConnTimestamp = (String) rtnMap.get("timestamp");
String format = (String) rtnMap.get("format");
String fileNm = restApiUrl.replace("https://services.nvd.nist.gov", "");
Map<String, Object> responseMap = new HashMap<>();
boolean httpsUrlConnectionFlag = false;
List<Map<String, Object>> vulnerabilities = null;
Map<String, Object> cveInfo = null;
Map<String, Object> comapare = null;
List<Map<String, String>> ossList = new ArrayList<>();
List<Map<String, String>> insertDataList = new ArrayList<>();
List<Map<String, Object>> cpe_match_all = null;
List<Map<String, Object>> cvePatchList = null;
log.info("nvdCveDataApiJob start");
try {
for (int i=0; i < totalResults; i+=2000) {if (i > totalResults) break;
for (int j=0; j<5; j++) {
responseMap = getDataForRestApiConnection(restApiUrl, resultsPerPage, i, j);
httpsUrlConnectionFlag = (boolean) responseMap.get("connectionFlag");
if (httpsUrlConnectionFlag) {
break;
}
}
log.info("nvdCveData index : "+i +" / " + "totalResults : " + totalResults);
if (httpsUrlConnectionFlag) {
if (responseMap.containsKey("vulnerabilities")) {
vulnerabilities = (List<Map<String, Object>>) responseMap.get("vulnerabilities");
if (vulnerabilities != null) {
for (Map<String, Object> vulnerability : vulnerabilities) {
cveInfo = restApiCveDatajsonReader(vulnerability);
if (cveInfo == null || cveInfo.isEmpty()) {
continue;
}
String cveId = (String) cveInfo.get("cveId");
List<String> matchNames = null;
cpe_match_all = (List<Map<String, Object>>) cveInfo.get("cpe_match_all");
ossList.clear();
for (Map<String, Object> cpe_match_data : cpe_match_all) {
// ์ ๋ณด์์ Version Range ์กฐ๊ฑด์ ๊ณ ๋ คํ์ฌ Cpe match ์ ๋ณด๋ก ๋ถํฐ ์ต์ข
์ ์์ผ๋ก ์ ์ฉํ ๋ชจ๋ ๋์ cpe23uri๋ฅผ ์ทจ๋ํ๋ค.
// Version Range ์กฐ๊ฑด ์ทจ๋
// ๊ฒ์ ์กฐ๊ฑด ์ค์
Map<String, String> _matchNameParams = new HashMap<>();
String criteria = (String) cpe_match_data.get("criteria");
String matchCriteriaId = (String) cpe_match_data.get("matchCriteriaId");
_matchNameParams.put("cpe23Uri", criteria);
_matchNameParams.put("matchCriteriaId", matchCriteriaId);
String versionStartIncluding = null;
String versionEndIncluding = null;
String versionStartExcluding = null;
String versionEndExcluding = null;
if (cpe_match_data.containsKey("versionStartIncluding")) {
versionStartIncluding = (String) cpe_match_data.get("versionStartIncluding");
_matchNameParams.put("versionStartIncluding", versionStartIncluding);
}
if (cpe_match_data.containsKey("versionEndIncluding")) {
versionEndIncluding = (String) cpe_match_data.get("versionEndIncluding");
_matchNameParams.put("versionEndIncluding", versionEndIncluding);
}
if (cpe_match_data.containsKey("versionStartExcluding")) {
versionStartExcluding = (String) cpe_match_data.get("versionStartExcluding");
_matchNameParams.put("versionStartExcluding", versionStartExcluding);
}
if (cpe_match_data.containsKey("versionEndExcluding")) {
versionEndExcluding = (String) cpe_match_data.get("versionEndExcluding");
_matchNameParams.put("versionEndExcluding", versionEndExcluding);
}
matchNames = nvdDataMapper.selectNvdMatchList(_matchNameParams);
// ๋ง์ฝ cpe match์์ cpe23uri๋ก ์กฐํ๋ ๊ฒฐ๊ณผ๊ฐ ์์ ๊ฒฝ์ฐ ํด๋น cpe23uri ๋ง ์ค์ ํ๋ค.
if (matchNames == null) {
matchNames = new ArrayList<>();
}
if (matchNames.isEmpty()) {
matchNames.add((String) cpe_match_data.get("criteria"));
}
// cpe23uri์์ product, version ์ ๋ณด๋ฅผ ์ถ์ถํ๋ค.
for (String cpe23uri : matchNames) {
String[] cpeInfoArr = cpe23uri.split(":");
Map<String, String> _productInfo = new HashMap<>();
_productInfo.put("cveId", cveId);
_productInfo.put("vendor", cpeInfoArr[3]);
_productInfo.put("product", cpeInfoArr[4]);
_productInfo.put("version", cpeInfoArr[5]);
ossList.add(_productInfo);
}
Map<String, String> configurationInsertParam = new HashMap<>();
configurationInsertParam.put("cveId", cveId);
configurationInsertParam.put("matchCriteriaId", (String) cpe_match_data.get("matchCriteriaId"));
configurationInsertParam.put("criteria", criteria);
String[] criteriaArr = criteria.split(":");
configurationInsertParam.put("vendor", criteriaArr[3]);
configurationInsertParam.put("product", criteriaArr[4]);
configurationInsertParam.put("version", criteriaArr[5]);
if (versionStartIncluding != null) {
configurationInsertParam.put("versionStartIncluding", versionStartIncluding);
}
if (versionEndIncluding != null) {
configurationInsertParam.put("versionEndIncluding", versionEndIncluding);
}
if (versionStartExcluding != null) {
configurationInsertParam.put("versionStartExcluding", versionStartExcluding);
}
if (versionEndExcluding != null) {
configurationInsertParam.put("versionEndExcluding", versionEndExcluding);
}
if (!initializeFlag) {
nvdDataMapper.deleteNvdDataConfigurations(configurationInsertParam);
}
nvdDataMapper.insertNvdDataConfigurationsTemp(configurationInsertParam);
}
cvePatchList = (List<Map<String, Object>>) cveInfo.get("cvePatchList");
if (cvePatchList != null) {
nvdDataMapper.deleteNvdDataPatchLink(cveId);
for (Map<String, Object> cvePatchInfo : cvePatchList) {
Map<String, Object> _patchInfo = new HashMap<>();
_patchInfo.put("cveId", cveId);
_patchInfo.put("patchLink", cvePatchInfo.get("url"));
_patchInfo.put("publDate", cveInfo.get("publDate"));
nvdDataMapper.insertNvdDataPatchLink(_patchInfo);
}
cvePatchList = null;
}
comapare = nvdDataMapper.selectOneCveInfoV3(cveInfo);
// ์ ๊ท๋ฑ๋ก
if (comapare == null){
nvdDataMapper.insertCveInfoV3(cveInfo);
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
}
// ๋ณ๊ฒฝ(delete > insert)
else if (!DateUtil.equals((Date)comapare.get("modiDate"), (Date) cveInfo.get("modiDate"))
|| !((Float)comapare.get("cvssScore")).equals(Float.valueOf((String)cveInfo.get("cvssScore"))) ){
// ๊ธฐ์กด ๋ฐ์ดํฐ ์ญ์
nvdDataMapper.deleteCveDataV3(cveInfo);
nvdDataMapper.deleteNvdDataV3(cveInfo);
// ๋ณ๊ฒฝ ๋ฐ์ดํฐ ๋ฑ๋ก
nvdDataMapper.insertCveInfoV3(cveInfo);
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
} else if (DateUtil.equals((Date)comapare.get("modiDate"), (Date) cveInfo.get("modiDate"))
&& ((Float)comapare.get("cvssScore")).equals(Float.valueOf((String)cveInfo.get("cvssScore")))) {
// NVD_CVE_V3๋ ๋ณ๊ฒฝ ๋์์ด ์๋์ง๋ง NVD_DATA_V3์ ์ ์ฉ ๋ ๋์์ด ์กด์ฌ ํ ๊ฒฝ์ฐ
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
}
if (insertDataList.size() % BATCH_SIZE == 0) {
prepareStatementUpdateNvdData(insertDataList);
insertDataList.clear();
}
}
if (insertDataList.size() > 0) {
prepareStatementUpdateNvdData(insertDataList);
}
}
}
} else {
log.error("url connection attempts exceeded");
break;
}
}
} catch(Exception e) {
log.error(e.getMessage(), e);
httpsUrlConnectionFlag = false;
}
if (httpsUrlConnectionFlag) {
// configuration data delete & insert
if (initializeFlag) {
nvdDataMapper.truncateNvdDataConfigurations();
}
nvdDataMapper.copyNvdDataConfigurationsFromTemp();
nvdDataMapper.truncateNvdDataConfigurationsTemp();
int vendorProductNvdDataV3Cnt = nvdDataMapper.selectVendorProductNvdDataV3Cnt();
if (vendorProductNvdDataV3Cnt > 0) {
log.info("Vendor Product Nvd Data V3 Update Count : " + vendorProductNvdDataV3Cnt);
nvdDataMapper.updateVendorProductNvdDataV3();
}
// success data insert > nvd_meta table
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileNm", fileNm);
param.put("fileType", format);
param.put("modiDate", urlConnTimestamp);
nvdDataMapper.insertNewMetaDataUrlConnection(param);
log.info("nvdCveDataApiJob end");
}
responseMap.put("connectionFlag", httpsUrlConnectionFlag);
return responseMap;
}
@SuppressWarnings("unchecked")
private Map<String, Object> restApiCveDatajsonReader(Map<String, Object> vulnerability) {
Map<String, Object> resultMap = new HashMap<>();
try {
Map<String, Object> cveItem = (Map<String, Object>) vulnerability.get("cve");
String publishedDate = (String) cveItem.get("published");
String lastModifiedDate = (String) cveItem.get("lastModified");
String cveId = (String) cveItem.get("id");
// summary
List<Map<String, Object>> descriptions = (List<Map<String, Object>>) cveItem.get("descriptions");
String descriptionStr = "";
for (Map<String, Object> description : descriptions) {
if (!StringUtil.isEmpty(descriptionStr)) {
descriptionStr += "\n";
}
descriptionStr += description.get("value");
}
// metrics
Map<String, Object> metrics = (Map<String, Object>) cveItem.get("metrics");
// CVSS V3๊ฐ ์๋ ๊ฒฝ์ฐ V2 Score๋ฅผ ์ฌ์ฉ
String baseScore = "0";
String baseMetric = "";
if (metrics.containsKey("cvssMetricV31")) {
List<Map<String, Object>> cvssMetricV3 = (List<Map<String, Object>>) metrics.get("cvssMetricV31");
Map<String, Object> cvssV3 = (Map<String, Object>) cvssMetricV3.get(0);
Map<String, Object> cvssData = (Map<String, Object>) cvssV3.get("cvssData");
baseScore = String.valueOf(cvssData.get("baseScore"));
baseMetric = "V3";
} else if (metrics.containsKey("cvssMetricV30")){
List<Map<String, Object>> cvssMetricV2 = (List<Map<String, Object>>) metrics.get("cvssMetricV30");
Map<String, Object> cvssV2 = (Map<String, Object>) cvssMetricV2.get(0);
Map<String, Object> cvssData = (Map<String, Object>) cvssV2.get("cvssData");
baseScore = String.valueOf(cvssData.get("baseScore"));
baseMetric = "V3";
} else if (metrics.containsKey("cvssMetricV2")){
List<Map<String, Object>> cvssMetricV2 = (List<Map<String, Object>>) metrics.get("cvssMetricV2");
Map<String, Object> cvssV2 = (Map<String, Object>) cvssMetricV2.get(0);
Map<String, Object> cvssData = (Map<String, Object>) cvssV2.get("cvssData");
baseScore = String.valueOf(cvssData.get("baseScore"));
baseMetric = "V2";
}
List<Map<String, String>> ossList = new ArrayList<>();
List<Map<String, Object>> cpe_match_all = new ArrayList<>();
if (cveItem.containsKey("configurations")) {
List<Map<String, Object>> configurationsInfo = (List<Map<String, Object>>) cveItem.get("configurations");
for (Map<String, Object> configurations : configurationsInfo) {
List<Map<String, Object>> configurations_nodes = (List<Map<String, Object>>) configurations.get("nodes");
// ์ ์๋ ๋ชจ๋ cpe match ์ ๋ณด
for (Map<String, Object> node_data : configurations_nodes) {
// children cpe_match ๋์ children ๋
ธ๋๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ, children ๋
ธ๋ ํ์์์ cpe_match ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
if (node_data.containsKey("cpeMatch")) {
cpe_match_all.addAll((List<Map<String, Object>>) node_data.get("cpeMatch"));
}
}
}
}
List<Map<String, Object>> cvePatchList = new ArrayList<>();
if (cveItem.containsKey("references")) {
List<Map<String, Object>> referencesInfo = (List<Map<String, Object>>) cveItem.get("references");
for (Map<String, Object> references : referencesInfo) {
if (references.containsKey("tags")) {
boolean checkPatchLinkFlag = false;
List<String> tagsList = (List<String>) references.get("tags");
for (String tag : tagsList) {
tag = tag.toUpperCase();
if (tag.equals("PATCH") || tag.equals("MITIGATION") || tag.equals("RELEASE NOTES")) {
checkPatchLinkFlag = true;
break;
}
}
if (checkPatchLinkFlag) {
cvePatchList.add(references);
}
}
}
}
resultMap.put("ossList", ossList);
resultMap.put("cveId", cveId);
resultMap.put("publDate", DateUtil.convertStringToTimestamp((publishedDate), "yyyy-MM-dd'T'HH:mm:ss.SSS"));
resultMap.put("modiDate", DateUtil.convertStringToTimestamp((lastModifiedDate), "yyyy-MM-dd'T'HH:mm:ss.SSS"));
resultMap.put("cvssScore", baseScore);
resultMap.put("summary", descriptionStr);
resultMap.put("baseMetric", baseMetric);
resultMap.put("cpe_match_all", cpe_match_all);
resultMap.put("cvePatchList", cvePatchList);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return resultMap;
}
private Map<String, Object> nvdMetaDataApiCheckJob(String restApiUrl, int resultsPerPage, int startIndex) throws IOException {
Map<String, Object> responseMap = new HashMap<>();
String fileNm = restApiUrl.replace("https://services.nvd.nist.gov", "");
try {
for (int i=0; i<5; i++) {
responseMap = getDataForRestApiConnection(restApiUrl, resultsPerPage, startIndex, i);
if ((boolean) responseMap.get("connectionFlag")) {
break;
}
}
if ((boolean) responseMap.get("connectionFlag")) {
// check url connection timestamp
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileType", (String) responseMap.get("format"));
param.put("fileNm", fileNm);
param.put("modiDate", (String) responseMap.get("timestamp"));
responseMap.put("checkUrlFlag", nvdDataMapper.selectUseMetaDataUrlConnection(param).size() > 0 ? true : false);
}
} catch (Exception e) {
log.error(e.getMessage());
responseMap.put("connectionFlag", false);
}
return responseMap;
}
@SuppressWarnings("unchecked")
@Transactional
public Map<String, Object> nvdMetaDataApiJob(String restApiUrl, int resultsPerPage, Map<String, Object> rtnMap) {
log.info("nvdMetaDataApiJob start");
int totalResults = (int) rtnMap.get("totalResults");
String urlConnTimestamp = (String) rtnMap.get("timestamp");
String format = (String) rtnMap.get("format");
String fileNm = restApiUrl.replace("https://services.nvd.nist.gov", "");
Map<String, Object> responseMap = new HashMap<>();
Connection conn = null;
PreparedStatement stmt = null;
PreparedStatement stmt2 = null;
List<Map<String, Object>> matchStrings = null;
boolean httpsUrlConnectionFlag = false;
boolean deleteCpeMatchDataFlag = false;
responseMap.put("totalResults", totalResults);
int seq = 1;
try {
String SQL_INSERT = "INSERT INTO NVD_CPE_MATCH_TEMP (MATCH_CRITERIA_ID, CPE23URI, VER_START_INC, VER_END_INC, VER_START_EXC, VER_END_EXC) VALUES (?,?,?,?,?,?)";
String SQL_INSERT2 = "INSERT INTO NVD_CPE_MATCH_NAMES_TEMP (MATCH_CRITERIA_ID, IDX, CPE23URI) VALUES (?,?,?)";
List<Map<String, Object>> cpeMatchDataList = new ArrayList<>();
List<Map<String, Object>> cpeMatchNamesDataList = new ArrayList<>();
for (int i=0; i < totalResults; i+=2000) {if (i > totalResults) break;
log.info("nvdMetaMatch index : " + i + " / " + "totalResults : " + totalResults);
for (int j=0; j<5; j++) {
responseMap = getDataForRestApiConnection(restApiUrl, resultsPerPage, i, j);
httpsUrlConnectionFlag = (boolean) responseMap.get("connectionFlag");
if (httpsUrlConnectionFlag) break;
}
if (httpsUrlConnectionFlag) {
if (responseMap.containsKey("matchStrings")) {
if (i == 0) {
// truncate table for first order
nvdDataMapper.createTableCpeMatchTemp();
nvdDataMapper.createTableCpeMatchNameTemp();
nvdDataMapper.truncateCpeMatchTemp();
nvdDataMapper.truncateCpeMatchNameTemp();
}
matchStrings = (List<Map<String, Object>>) responseMap.get("matchStrings");
if (matchStrings != null) {
int seq2 = 1;
for (Map<String, Object> matchStringObj : matchStrings) {
if (matchStringObj.containsKey("matchString")) {
Map<String, Object> matchString = (Map<String, Object>) matchStringObj.get("matchString");
String matchCriteriaId = (String) matchString.get("matchCriteriaId");
String cpe23Uri = (String) matchString.get("criteria");
Map<String, Object> cpeMatchMap = new HashMap<>();
cpeMatchMap.put("matchCriteriaId", matchCriteriaId);
cpeMatchMap.put("criteria", cpe23Uri);
if (matchString.containsKey("versionStartIncluding")) {
cpeMatchMap.put("versionStartIncluding", (String) matchString.get("versionStartIncluding"));
}
if (matchString.containsKey("versionEndIncluding")) {
cpeMatchMap.put("versionEndIncluding", (String) matchString.get("versionEndIncluding"));
}
if (matchString.containsKey("versionStartExcluding")) {
cpeMatchMap.put("versionStartExcluding", (String) matchString.get("versionStartExcluding"));
}
if (matchString.containsKey("versionEndExcluding")) {
cpeMatchMap.put("versionEndExcluding", (String) matchString.get("versionEndExcluding"));
}
int checkMatchCriteriaId = nvdDataMapper.selectNvdCpeMatch(matchCriteriaId);
if (checkMatchCriteriaId > 0) { // delete
deleteCpeMatchDataFlag = true;
nvdDataMapper.deleteNvdCpeMatch(matchCriteriaId);
}
cpeMatchDataList.add(cpeMatchMap);
if (cpeMatchDataList.size() % BATCH_SIZE == 0) {
prepareStatementUpdateCpeMatchData(conn, stmt, SQL_INSERT, cpeMatchDataList);
cpeMatchDataList.clear();
}
if (matchString.containsKey("matches")) {
List<Map<String, Object>> matches = (List<Map<String, Object>>) matchString.get("matches");
if (deleteCpeMatchDataFlag) {
nvdDataMapper.deleteNvdCpeMatchNames(matchCriteriaId);
}
int nameIdx = 0;
for (Map<String, Object> match : matches) {
if (match.containsKey("cpeName")) {
Map<String, Object> cpeMatchNamesMap = new HashMap<>();
cpeMatchNamesMap.put("matchCriteriaId", matchCriteriaId);
cpeMatchNamesMap.put("idx", nameIdx);
cpeMatchNamesMap.put("cpeName", (String) match.get("cpeName"));
cpeMatchNamesDataList.add(cpeMatchNamesMap);
if (cpeMatchNamesDataList.size() % BATCH_SIZE == 0) {
prepareStatementUpdateCpeMatchNamesData(conn, stmt2, SQL_INSERT2, cpeMatchNamesDataList);
cpeMatchNamesDataList.clear();
}
nameIdx++;
seq2++;
}
}
}
seq++;
deleteCpeMatchDataFlag = false;
}
}
if (!cpeMatchDataList.isEmpty()) {
prepareStatementUpdateCpeMatchData(conn, stmt, SQL_INSERT, cpeMatchDataList);
cpeMatchDataList.clear();
}
if (!cpeMatchNamesDataList.isEmpty()) {
prepareStatementUpdateCpeMatchNamesData(conn, stmt2, SQL_INSERT2, cpeMatchNamesDataList);
cpeMatchNamesDataList.clear();
}
}
}
} else {
log.error("url connection attempts exceeded");
break;
}
}
} catch(Exception e) {
log.error(e.getMessage(), e);
httpsUrlConnectionFlag = false;
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch(SQLException e) {}
try {
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException e) {}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e) {}
}
log.info("httpsUrlConnectionFlag : "+httpsUrlConnectionFlag);
if (httpsUrlConnectionFlag) {
if (initializeFlag && totalResults > 0) {
nvdDataMapper.truncateCpeMatch();
nvdDataMapper.truncateCpeMatchNames();
}
nvdDataMapper.copyNvdDataMatchFromTemp();
nvdDataMapper.copyNvdDataMatchNameFromTemp();
nvdDataMapper.truncateCpeMatchTemp();
nvdDataMapper.truncateCpeMatchNameTemp();
// success data insert > nvd_meta table
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileNm", fileNm);
param.put("fileType", format);
param.put("modiDate", urlConnTimestamp);
nvdDataMapper.insertNewMetaDataUrlConnection(param);
log.info("nvdMetaDataApiJob end");
}
responseMap.put("connectionFlag", httpsUrlConnectionFlag);
return responseMap;
}
private void prepareStatementUpdateCpeMatchData(Connection conn, PreparedStatement stmt, String query, List<Map<String, Object>> cpeMatchDataList) {
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
stmt = conn.prepareStatement(query);
for (Map<String, Object> cpeMatchData : cpeMatchDataList) {
stmt.setString(1, (String) cpeMatchData.get("matchCriteriaId"));
stmt.setString(2, (String) cpeMatchData.get("criteria"));
if (cpeMatchData.containsKey("versionStartIncluding")) {
stmt.setString(3, (String) cpeMatchData.get("versionStartIncluding"));
} else {
stmt.setString(3, null);
}
if (cpeMatchData.containsKey("versionEndIncluding")) {
stmt.setString(4, (String) cpeMatchData.get("versionEndIncluding"));
} else {
stmt.setString(4, null);
}
if (cpeMatchData.containsKey("versionStartExcluding")) {
stmt.setString(5, (String) cpeMatchData.get("versionStartExcluding"));
} else {
stmt.setString(5, null);
}
if (cpeMatchData.containsKey("versionEndExcluding")) {
stmt.setString(6, (String) cpeMatchData.get("versionEndExcluding"));
} else {
stmt.setString(6, null);
}
stmt.addBatch();
stmt.clearParameters();
}
stmt.executeBatch(); // Batch ์คํ
stmt.clearBatch(); // Batch ์ด๊ธฐํ
conn.commit(); // ์ปค๋ฐ
} catch (Exception e) {
log.error(e.getMessage(), e);
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException e1){}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e1){}
} finally {
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException e){}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e){}
}
}
private void prepareStatementUpdateCpeMatchNamesData(Connection conn, PreparedStatement stmt2, String query, List<Map<String, Object>> cpeMatchNamesDataList) {
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
stmt2 = conn.prepareStatement(query);
for (Map<String, Object> cpeMatchData : cpeMatchNamesDataList) {
stmt2.setString(1, (String) cpeMatchData.get("matchCriteriaId"));
stmt2.setInt(2, (int) cpeMatchData.get("idx"));
stmt2.setString(3, (String) cpeMatchData.get("cpeName"));
stmt2.addBatch();
stmt2.clearParameters();
}
stmt2.executeBatch(); // Batch ์คํ
stmt2.clearBatch(); // Batch ์ด๊ธฐํ
conn.commit(); // ์ปค๋ฐ
} catch (Exception e) {
log.error(e.getMessage(), e);
try{
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException e1){}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e1){}
} finally {
try{
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException e){}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e){}
}
}
private Map<String, Object> getDataForRestApiConnection(String restApiUrl, int resultsPerPage, int startIndex, int cnt) {
HttpsURLConnection httpsURLConnection = null;
Map<String, Object> rtnMap = new HashMap<>();
String urlString = restApiUrl + "?resultsPerPage=" + resultsPerPage + "&startIndex=" + startIndex;
if (!initializeFlag) {
urlString += "&lastModStartDate=" + lastModStartDate + "&lastModEndDate=" + lastModEndDate;
}
boolean connectionFlag = true;
try {
URL url = new URL(urlString);
ignoreSsl();
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestMethod("GET");
httpsURLConnection.addRequestProperty("x-api-key", NVD_API_KEY);
httpsURLConnection.setConnectTimeout(1000 * 15);
if (httpsURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
Map<String, Object> convertMap = getFromJSONObjectToMap(bufferedReader);
if (convertMap != null) {
connectionFlag = true;
rtnMap = convertMap;
} else {
connectionFlag = false;
}
} else {
log.error("httpsURLConnection error : " + CommonFunction.httpCodePrint(httpsURLConnection.getResponseCode()));
connectionFlag = false;
}
} catch (Exception e) {
log.error(e.getMessage());
connectionFlag = false;
} finally {
httpsURLConnection.disconnect();
if (connectionFlag) {
try {
Thread.sleep(1000 * 6);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
} else {
try {
log.warn("Try again in 15 seconds...");
Thread.sleep(1000 * 15);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
}
rtnMap.put("connectionFlag", connectionFlag);
return rtnMap;
}
@SuppressWarnings({ "unchecked" })
private Map<String, Object> getFromJSONObjectToMap(BufferedReader br) {
Map<String, Object> map = null;
if (br != null) {
try {
JSONTokener tokener = new JSONTokener(br);
JSONObject json = new JSONObject(tokener);
map = new ObjectMapper().readValue(json.toString(), Map.class);
} catch (Exception e) {
log.error(e.getMessage(), e);
map = null;
}
} else {
log.error("url connection response buffered reader null");
}
return map;
}
@Transactional
public String nvdCveDataSyncJob(boolean restApiFlag) throws JsonParseException, JsonMappingException, IOException {
String resCd = "00";
log.info("Start CVE Data Sync Job");
// // 1. Wait Job ๋ฐ์ดํฐ ์กฐํ
// HashMap<String, Object> param = new HashMap<String, Object>();
// param.put("fileType", "CVE");
// List<HashMap<String, Object>> waitList = nvdDataMapper.selectWaitJobData(param);
//
// boolean updateFlag = restApiFlag;
// // 2. Json File -> DB Insert
// for (Map<String, Object> wMetaMap : waitList){
//
// param.put("fileNm", wMetaMap.get("fileNm"));
// param.put("modiDate", wMetaMap.get("modiDate"));
// param.put("jobStatus", "G");
// // JobStatus๊ฐ W์ธ ๋์์ด ์์
์ด ๋ค์ด๊ฐ๋ค๋ฉด G๋ก ๋ณ๊ฒฝ์ ํ์ฌ ์ถํ์ ๋ค์ loop ๋์ง ์๋๋ก ์ฒ๋ฆฌํจ.
// nvdDataMapper.updateJobStatus(param);
//
// String NVD_CVE_PATH = env.getProperty("root.dir");
// if (StringUtil.isEmpty(NVD_CVE_PATH)) {
// NVD_CVE_PATH = new FileSystemResource("").getFile().getAbsolutePath();
// }
// NVD_CVE_PATH = Paths.get(NVD_CVE_PATH, "nvd/cve").toString();
//
// updateFlag = updateNvdData(NVD_CVE_PATH, (String) wMetaMap.get("fileNm"));
//
// param.put("jobStatus", "C");
// nvdDataMapper.updateJobStatus(param);
//
// }
// NVD ๊ด๋ จ Data ์ค๋ณตํ์(cpe_nm์ ๋ง์ด๋ ๋ฒ์ ์ด ํฌํจ๋จ), ๋ฐ ์ฑ๋ฅ ๊ฐ์ ์ ์ํด ๋ณ๋์ ํ
์ด๋ธ์ ์ถ๊ฐ
// truncate and insert ์ฒ๋ฆฌ
// ์ํ์ฑ : truncate๋ transaction ์ผ๋ก ๊ด๋ฆฌ ํ ์ ์๋ค. truncate์ดํ์ insert ์คํจ์ data ์์ ์ ์์
if (restApiFlag){
String insertQuery = "INSERT INTO NVD_DATA_TEMP_V3 (PRODUCT, VERSION, VENDOR, CVE_ID, CVSS_SCORE, VULN_SUMMARY, MODI_DATE ) VALUES (?,?,?,?,?,?,?) "
+ "ON DUPLICATE KEY UPDATE PRODUCT = values(PRODUCT), VERSION = values(VERSION), VENDOR = values(VENDOR), CVE_ID = values(CVE_ID), CVSS_SCORE = values(CVSS_SCORE), VULN_SUMMARY = values(VULN_SUMMARY), MODI_DATE = values(MODI_DATE)";
String selectQuery = "SELECT NVD.PRODUCT, NVD.VERSION, GROUP_CONCAT(DISTINCT(NVD.VENDOR)) AS VENDOR FROM (SELECT T2.* FROM (SELECT @ROWNUM:=@ROWNUM+1 AS SEQ, T1.PRODUCT FROM ("
+ "SELECT PRODUCT FROM NVD_DATA_V3 GROUP BY PRODUCT ORDER BY PRODUCT ) T1, (SELECT @ROWNUM:=0) AS R ) T2 WHERE T2.SEQ BETWEEN ? AND ? ) NVD_PRODUCT JOIN NVD_DATA_V3 NVD ON NVD_PRODUCT.PRODUCT = NVD.PRODUCT GROUP BY NVD.PRODUCT, NVD.VERSION";
String selectQuery2 = "SELECT T2.PRODUCT, T2.VERSION, T1.CVE_ID, T1.CVSS_SCORE, T1.VULN_SUMMARY, T1.MODI_DATE FROM NVD_CVE_V3 T1, NVD_DATA_V3 T2 WHERE T1.CVE_ID = T2.CVE_ID AND T2.PRODUCT = ? AND T2.VERSION = ? "
+ "AND T1.CVSS_SCORE = (SELECT MAX(CVSS_SCORE) AS CVSS_SCORE FROM NVD_CVE_V3 WHERE CVE_ID IN (SELECT CVE_ID FROM NVD_DATA_V3 WHERE PRODUCT = ? AND VERSION = ?)) ORDER BY CVE_ID DESC LIMIT 1";
// temp table์ data insert ์ดํ, real table๋ก copy
nvdDataMapper.deleteNvdDataTempV3();
int cnt = nvdDataMapper.getProducVerCnt();
List<Map<String, Object>> itemList = new ArrayList<>();
List<Map<String, Object>> params = new ArrayList<>();
int endIdx = BATCH_SIZE;
Connection conn = null;
Connection conn1 = null;
Connection conn2 = null;
PreparedStatement getProductStmt = null;
PreparedStatement getMaxScoreProductVerStmt = null;
PreparedStatement insertStmt = null;
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
conn1 = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn1.setAutoCommit(false);
conn2 = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn2.setAutoCommit(false);
getProductStmt = conn.prepareStatement(selectQuery);
getMaxScoreProductVerStmt = conn1.prepareStatement(selectQuery2);
insertStmt = conn2.prepareStatement(insertQuery);
for (int idx = 0; idx < cnt; ) {
if (endIdx >= cnt) {
endIdx = cnt;
}
preparedStatementGetProductList(conn2, itemList, params, getProductStmt, getMaxScoreProductVerStmt, insertStmt, idx, endIdx);
idx = idx+BATCH_SIZE;
endIdx = idx+BATCH_SIZE;
if (idx % 10000 == 0) {
log.info("NVD_DATA_TEMP_V3 process : " + idx + " / " + cnt);
}
}
log.info("NVD_DATA_TEMP_V3 process : " + cnt + " / " + cnt);
} catch(Exception e) {
log.error(e.getMessage(), e);
try {
if (insertStmt != null) {
insertStmt.close();
}
} catch(SQLException e1) {}
try {
if (getMaxScoreProductVerStmt != null) {
getMaxScoreProductVerStmt.close();
}
} catch(SQLException e1) {}
try{
if (getMaxScoreProductVerStmt != null) {
getMaxScoreProductVerStmt.close();
}
} catch(SQLException e1) {}
try{
if (conn2 != null) {
conn2.rollback();
conn2.close();
}
} catch(SQLException e1) {}
try {
if (conn1 != null) {
conn1.close();
}
} catch(SQLException e1) {}
try{
if (conn != null) {
conn.close();
}
}catch(SQLException e1){}
} finally {
try{
if (insertStmt != null) {
insertStmt.close();
}
} catch(SQLException e1) {}
try{
if (getMaxScoreProductVerStmt != null) {
getMaxScoreProductVerStmt.close();
}
} catch(SQLException e1) {}
try{
if (getMaxScoreProductVerStmt != null) {
getMaxScoreProductVerStmt.close();
}
} catch(SQLException e1) {}
try {
if (conn2 != null) {
conn2.close();
}
} catch(SQLException e1) {}
try {
if (conn1 != null) {
conn1.close();
}
} catch(SQLException e1) {}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e1) {}
}
nvdDataMapper.deleteNvdDataScoreV3();
nvdDataMapper.insertNvdDataScoreV3();
nvdDataMapper.deleteNvdDataTempV3();
log.info("End CVE Data Sync Job");
}
int nickNameMgrCnt = nvdDataMapper.selectNickNameMgrtNvdDataScoreV3();
if (nickNameMgrCnt > 0) {
log.info("Nickname Migration Count : " + nickNameMgrCnt);
// OSS_NICKNAME ๊ธฐ์ค์ผ๋ก NVD_DATA_SCORE_V3์ NICKNAME์ ์ถ๊ฐํจ.
nvdDataMapper.insertNickNameMgrtNvdDataScoreV3();
}else{
log.info("Nickname Migration Count : 0");
}
int MaxCvssScoreCnt = nvdDataMapper.selectMaxCvssScoreNvdDataScoreV3();
if (MaxCvssScoreCnt > 0) {
log.info("MaxCvssScore Added Count : " + MaxCvssScoreCnt);
// NVD_DATA_SCORE_V3์์ CVSS_SCORE MAX๊ฐ์ ๊ธฐ์ค์ผ๋ก PRODUCT์์ VERSION์ด ์๋ DATA๋ฅผ ์ถ๊ฐํจ.
nvdDataMapper.insertMaxCvssScoreNvdDataScoreV3();
}else{
log.info("MaxCvssScore Added Count : 0");
}
int diffCvssScoreCnt = nvdDataMapper.ossNameNickNameCvssScoreDiffCnt();
if (diffCvssScoreCnt > 0){
log.info("NickName -> ossName cvssScore Diff Count : " + diffCvssScoreCnt);
nvdDataMapper.ossNameToNickNameMgrtCvssScore();
} else{
log.info("NickName -> ossName cvssScore Diff Count : 0");
}
int ossNameToNickDiffCvssScoreCnt = nvdDataMapper.ossNameToNickMgrtCvssScoreDiffCnt();
if (ossNameToNickDiffCvssScoreCnt > 0){
log.info("ossName -> NickName cvssScore Diff Count : " + ossNameToNickDiffCvssScoreCnt);
nvdDataMapper.nickNameToOssNameMgrtCvssScore();
} else{
log.info("ossName -> NickName cvssScore Diff Count : 0");
}
int vendorProductNvdDataScoreV3Cnt = nvdDataMapper.selectVendorProductNvdDataScoreV3Cnt();
if (vendorProductNvdDataScoreV3Cnt > 0) {
log.info("Vendor Product NVD Data Score V3 Update Count : " + vendorProductNvdDataScoreV3Cnt);
nvdDataMapper.updateVendorProductNvdDataScoreV3();
}
return resCd;
}
private void preparedStatementGetProductList(Connection conn2, List<Map<String, Object>> itemList, List<Map<String, Object>> params,
PreparedStatement getProductStmt, PreparedStatement getMaxScoreProductVerStmt, PreparedStatement insertStmt, int batchIdx, int batchEndIdx) {
ResultSet rs = null;
Map<String, Object> itemMap = null;
try {
getProductStmt.setInt(1, batchIdx);
getProductStmt.setInt(2, batchEndIdx);
rs = getProductStmt.executeQuery();
getProductStmt.clearParameters();
while (rs.next()) {
itemMap = new HashMap<>();
itemMap.put("ossName", rs.getString(1));
itemMap.put("ossVersion", rs.getString(2));
itemMap.put("vendor", rs.getString(3));
itemList.add(itemMap);
if (itemList.size() % BATCH_SIZE == 0) {
preparedStatementGetMaxScoreProductVer(conn2, getMaxScoreProductVerStmt, insertStmt, itemList, params);
itemList.clear();
}
}
if (itemList.size() > 0) {
preparedStatementGetMaxScoreProductVer(conn2, getMaxScoreProductVerStmt, insertStmt, itemList, params);
}
} catch(Exception e) {
itemList.clear();
log.error(e.getMessage(), e);
try{
if (rs != null) {
rs.close();
}
} catch(SQLException e1) {}
} finally {
itemList.clear();
try{
if (rs != null) {
rs.close();
}
} catch(SQLException e1) {}
}
}
private void preparedStatementGetMaxScoreProductVer(Connection conn2, PreparedStatement getMaxScoreProductVerStmt, PreparedStatement insertStmt, List<Map<String, Object>> itemList, List<Map<String, Object>> params) {
ResultSet getMaxScoreProductVerRs = null;
Map<String, Object> paramMap = null;
try {
String vendor = "";
List<String> vendorList = new ArrayList<>();
for (Map<String, Object> item : itemList) {
vendor = (String) item.get("vendor");
for (String chk : vendor.split(",")) {
if (!StringUtil.isEmpty(chk)) {
vendorList.add(chk);
}
}
getMaxScoreProductVerStmt.setString(1, (String) item.get("ossName"));
getMaxScoreProductVerStmt.setString(2, (String) item.get("ossVersion"));
getMaxScoreProductVerStmt.setString(3, (String) item.get("ossName"));
getMaxScoreProductVerStmt.setString(4, (String) item.get("ossVersion"));
getMaxScoreProductVerRs = getMaxScoreProductVerStmt.executeQuery();
getMaxScoreProductVerStmt.clearParameters();
if (vendorList.size() > 0) {
while (getMaxScoreProductVerRs.next()) {
for (String vn : vendorList) {
paramMap = new HashMap<>();
paramMap.put("PRODUCT", getMaxScoreProductVerRs.getString(1));
paramMap.put("VERSION", getMaxScoreProductVerRs.getString(2));
paramMap.put("VENDOR", vn);
paramMap.put("CVE_ID", getMaxScoreProductVerRs.getString(3));
paramMap.put("CVSS_SCORE", getMaxScoreProductVerRs.getFloat(4));
paramMap.put("VULN_SUMMARY", getMaxScoreProductVerRs.getString(5));
paramMap.put("MODI_DATE", getMaxScoreProductVerRs.getTimestamp(6));
params.add(paramMap);
if (params.size() % BATCH_SIZE == 0) {
preparedStatementInsertNvdDataListTempV3(conn2, insertStmt, params);
params.clear();
}
}
}
} else {
while (getMaxScoreProductVerRs.next()) {
paramMap = new HashMap<>();
paramMap.put("PRODUCT", getMaxScoreProductVerRs.getString(1));
paramMap.put("VERSION", getMaxScoreProductVerRs.getString(2));
paramMap.put("VENDOR", "");
paramMap.put("CVE_ID", getMaxScoreProductVerRs.getString(3));
paramMap.put("CVSS_SCORE", getMaxScoreProductVerRs.getFloat(4));
paramMap.put("VULN_SUMMARY", getMaxScoreProductVerRs.getString(5));
paramMap.put("MODI_DATE", getMaxScoreProductVerRs.getTimestamp(6));
params.add(paramMap);
if (params.size() % BATCH_SIZE == 0) {
preparedStatementInsertNvdDataListTempV3(conn2, insertStmt, params);
params.clear();
}
}
}
vendorList.clear();
}
if (params.size() > 0) {
preparedStatementInsertNvdDataListTempV3(conn2, insertStmt, params);
params.clear();
}
} catch(Exception e) {
params.clear();
log.error(e.getMessage(), e);
try {
if (getMaxScoreProductVerRs != null) {
getMaxScoreProductVerRs.close();
}
} catch(SQLException e1) {}
try {
if (getMaxScoreProductVerStmt != null) {
getMaxScoreProductVerStmt.close();
}
} catch(SQLException e1) {}
} finally {
params.clear();
try{
if (getMaxScoreProductVerRs != null) {
getMaxScoreProductVerRs.close();
}
} catch(SQLException e) {}
}
}
private void preparedStatementInsertNvdDataListTempV3(Connection conn2, PreparedStatement insertStmt, List<Map<String, Object>> params) {
try{
for (Map<String, Object> item : params) {
insertStmt.setString(1, (String) item.get("PRODUCT"));
insertStmt.setString(2, (String) item.get("VERSION"));
insertStmt.setString(3, (String) item.get("VENDOR"));
insertStmt.setString(4, (String) item.get("CVE_ID"));
insertStmt.setFloat(5, (float) item.get("CVSS_SCORE"));
insertStmt.setString(6, (String) item.get("VULN_SUMMARY"));
insertStmt.setTimestamp(7, Timestamp.valueOf(item.get("MODI_DATE").toString()));
insertStmt.addBatch();
insertStmt.clearParameters();
}
// ์ปค๋ฐ๋์ง ๋ชปํ ๋๋จธ์ง ๊ตฌ๋ฌธ์ ๋ํ์ฌ ์ปค๋ฐ
insertStmt.executeBatch() ;
conn2.commit();
} catch(Exception e) {
log.error(e.getMessage(), e);
}
}
@SuppressWarnings("unchecked")
private boolean updateNvdData(String cpeFileRootPath, String cpeFileName) throws JsonParseException, JsonMappingException, IOException {
boolean updateFlag = false;
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = mapper.readValue( new File(cpeFileRootPath + File.separator + cpeFileName + ".json") , new TypeReference<Map<String, Object>>() { });
if (map.containsKey("CVE_Items")) {
List<Map<String, Object>> cveItems = (List<Map<String, Object>>) map.get("CVE_Items");
Map<String, Object> cveInfo = null;
Map<String, Object> comapare = null;
List<Map<String, String>> ossList = new ArrayList<>();
List<Map<String, String>> insertDataList = new ArrayList<>();
List<Map<String, Object>> cpe_match_all = null;
for (Map<String, Object> cveItem : cveItems) {
cveInfo = cveDatajsonReader(cveItem);
if (cveInfo == null || cveInfo.isEmpty()) {
continue;
}
String cveId = (String) cveInfo.get("cveId");
// ์ ์ฒด cpe match ์ ๋ณด์์ vulnerable ๊ฐ false์ธ ๊ฒฝ์ฐ๋ ์ ์ธํ๋ค.
// ์ ์ฉ๋์ cpe match list
List<String> matchNames = null;
cpe_match_all = (List<Map<String, Object>>) cveInfo.get("cpe_match_all");
// if (cpe_match_all.isEmpty()) {
// log.info("REJECTED CVE " + cveId);
// }
ossList.clear();
for (Map<String, Object> cpe_match_data : cpe_match_all) {
// ์ ๋ณด์์ Version Range ์กฐ๊ฑด์ ๊ณ ๋ คํ์ฌ Cpe match ์ ๋ณด๋ก ๋ถํฐ ์ต์ข
์ ์์ผ๋ก ์ ์ฉํ ๋ชจ๋ ๋์ cpe23uri๋ฅผ ์ทจ๋ํ๋ค.
// Version Range ์กฐ๊ฑด ์ทจ๋
// ๊ฒ์ ์กฐ๊ฑด ์ค์
Map<String, String> _matchNameParams = new HashMap<>();
_matchNameParams.put("cpe23Uri", (String) cpe_match_data.get("cpe23Uri"));
if (cpe_match_data.containsKey("versionStartIncluding")) {
_matchNameParams.put("versionStartIncluding",
(String) cpe_match_data.get("versionStartIncluding"));
}
if (cpe_match_data.containsKey("versionEndIncluding")) {
_matchNameParams.put("versionEndIncluding",
(String) cpe_match_data.get("versionEndIncluding"));
}
if (cpe_match_data.containsKey("versionStartExcluding")) {
_matchNameParams.put("versionStartExcluding",
(String) cpe_match_data.get("versionStartExcluding"));
}
if (cpe_match_data.containsKey("versionEndExcluding")) {
_matchNameParams.put("versionEndExcluding",
(String) cpe_match_data.get("versionEndExcluding"));
}
matchNames = nvdDataMapper.selectNvdMatchList(_matchNameParams);
// ๋ง์ฝ cpe match์์ cpe23uri๋ก ์กฐํ๋ ๊ฒฐ๊ณผ๊ฐ ์์ ๊ฒฝ์ฐ ํด๋น cpe23uri ๋ง ์ค์ ํ๋ค.
if (matchNames == null) {
matchNames = new ArrayList<>();
}
if (matchNames.isEmpty()) {
matchNames.add((String) cpe_match_data.get("cpe23Uri"));
}
// cpe23uri์์ product, version ์ ๋ณด๋ฅผ ์ถ์ถํ๋ค.
for (String cpe23uri : matchNames) {
String[] cpeInfoArr = cpe23uri.split(":");
Map<String, String> _productInfo = new HashMap<>();
_productInfo.put("cveId", cveId);
_productInfo.put("vendor", cpeInfoArr[3]);
_productInfo.put("product", cpeInfoArr[4]);
_productInfo.put("version", cpeInfoArr[5]);
ossList.add(_productInfo);
}
}
comapare = nvdDataMapper.selectOneCveInfoV3(cveInfo);
// ์ ๊ท๋ฑ๋ก
if (comapare == null){
nvdDataMapper.insertCveInfoV3(cveInfo);
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
updateFlag = true;
}
// ๋ณ๊ฒฝ(delete > insert)
else if (!DateUtil.equals((Date)comapare.get("modiDate"), (Date) cveInfo.get("modiDate"))
|| !((Float)comapare.get("cvssScore")).equals(Float.valueOf((String)cveInfo.get("cvssScore"))) ){
// ๊ธฐ์กด ๋ฐ์ดํฐ ์ญ์
nvdDataMapper.deleteCveDataV3(cveInfo);
nvdDataMapper.deleteNvdDataV3(cveInfo);
// ๋ณ๊ฒฝ ๋ฐ์ดํฐ ๋ฑ๋ก
nvdDataMapper.insertCveInfoV3(cveInfo);
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
} else if (DateUtil.equals((Date)comapare.get("modiDate"), (Date) cveInfo.get("modiDate"))
&& ((Float)comapare.get("cvssScore")).equals(Float.valueOf((String)cveInfo.get("cvssScore")))) {
// NVD_CVE_V3๋ ๋ณ๊ฒฝ ๋์์ด ์๋์ง๋ง NVD_DATA_V3์ ์ ์ฉ ๋ ๋์์ด ์กด์ฌ ํ ๊ฒฝ์ฐ
if (!ossList.isEmpty()) {
insertDataList.addAll(ossList);
}
}
if (insertDataList.size() % BATCH_SIZE == 0) {
prepareStatementUpdateNvdData(insertDataList);
insertDataList.clear();
}
}
if (insertDataList.size() > 0) {
prepareStatementUpdateNvdData(insertDataList);
}
int vendorProductNvdDataV3Cnt = nvdDataMapper.selectVendorProductNvdDataV3Cnt();
if (vendorProductNvdDataV3Cnt > 0) {
log.info("Vendor Product Nvd Data V3 Update Count : " + vendorProductNvdDataV3Cnt);
nvdDataMapper.updateVendorProductNvdDataV3();
}
}
return updateFlag;
}
private void prepareStatementUpdateNvdData(List<Map<String, String>> insertDataList) {
Connection conn = null;
PreparedStatement stmt = null;
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
String SQL_INSERT = "INSERT INTO NVD_DATA_V3 (CVE_ID, PRODUCT, VERSION, VENDOR) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE CVE_ID = values(cve_id), PRODUCT = values(product), VERSION = values(version), VENDOR = values(vendor)";
stmt = conn.prepareStatement(SQL_INSERT);
int seq = 1;
for (Map<String, String> item : insertDataList){
stmt.setString(1, (String) item.get("cveId"));
stmt.setString(2, (String) item.get("product"));
stmt.setString(3, (String) item.get("version"));
stmt.setString(4, (String) item.get("vendor"));
stmt.addBatch();
stmt.clearParameters();
if ((seq % BATCH_SIZE) == 0 ) {
stmt.executeBatch();
stmt.clearBatch();
conn.commit();
}
seq++;
}
stmt.executeBatch();
conn.commit();
} catch (Exception e) {
log.error(e.getMessage(), e);
if (conn != null) {
try {
conn.rollback();
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
} finally {
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException e){}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e){}
}
}
@SuppressWarnings("unchecked")
private Map<String, Object> cveDatajsonReader(Map<String, Object> cveItem) throws JsonParseException, JsonMappingException, IOException {
String publishedDate = (String) cveItem.get("publishedDate");
String lastModifiedDate = (String) cveItem.get("lastModifiedDate");
Map<String, Object> cveInfo = (Map<String, Object>) cveItem.get("cve");
Map<String, Object> cveDataInfo = (Map<String, Object>) cveInfo.get("CVE_data_meta");
String cveId = (String) cveDataInfo.get("ID");
// impact
Map<String, Object> impact = (Map<String, Object>) cveItem.get("impact");
// if (!impact.containsKey("baseMetricV3") && !impact.containsKey("baseMetricV2")) {
// // REJECT
// return null;
// }
// CVSS V3๊ฐ ์๋ ๊ฒฝ์ฐ V2 Score๋ฅผ ์ฌ์ฉ
String baseScore = "0";
String baseMetric = "";
if (impact.containsKey("baseMetricV3")) {
Map<String, Object> baseMetricV3 = (Map<String, Object>) impact.get("baseMetricV3");
Map<String, Object> cvssV3 = (Map<String, Object>) baseMetricV3.get("cvssV3");
baseScore = String.valueOf(cvssV3.get("baseScore"));
baseMetric = "V3";
} else if (impact.containsKey("baseMetricV2")){
Map<String, Object> baseMetricV2 = (Map<String, Object>) impact.get("baseMetricV2");
Map<String, Object> cvssV2 = (Map<String, Object>) baseMetricV2.get("cvssV2");
baseScore = String.valueOf(cvssV2.get("baseScore"));
baseMetric = "V2";
}
List<Map<String, String>> ossList = new ArrayList<>();
List<Map<String, Object>> cpe_match_all = new ArrayList<>();
Map<String, Object> configurationsInfo = (Map<String, Object>) cveItem.get("configurations");
List<Map<String, Object>> configurations_nodes = (List<Map<String, Object>>) configurationsInfo.get("nodes");
// ์ ์๋ ๋ชจ๋ cpe match ์ ๋ณด
for (Map<String, Object> node_data : configurations_nodes) {
// children cpe_match ๋์ children ๋
ธ๋๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ, children ๋
ธ๋ ํ์์์ cpe_match ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
if (node_data.containsKey("cpe_match")) {
cpe_match_all.addAll((List<Map<String, Object>>) node_data.get("cpe_match"));
}
if (node_data.containsKey("children")) {
List<Map<String, Object>> children = (List<Map<String, Object>>) node_data.get("children");
// ์คํค๋ง ๊ตฌ์กฐ์์ผ๋ก๋ children ํ์ ๋
ธ๋์์ ๋ค์ operator AND ์กฐ๊ฑด์ด ๋ฐ์ํ ์ ์์ง๋ง, ์ค์ Data ์กด์ฌํ์ง ์์๊ธฐ ๋๋ฌธ์
// ์ฌ๊ท์ฒ๋ฆฌ๋ ์๋ตํ๊ณ 1Depth ๊น์ง๋ง ์ฐพ๋๋ค.
for (Map<String, Object> children_data : children) {
cpe_match_all.addAll((List<Map<String, Object>>) children_data.get("cpe_match"));
}
}
}
Map<String, Object> description = (Map<String, Object>) cveInfo.get("description");
List<Map<String, Object>> description_datas = (List<Map<String, Object>>) description.get("description_data");
String descriptionStr = "";
for (Map<String, Object> description_data : description_datas) {
if (!StringUtil.isEmpty(descriptionStr)) {
descriptionStr += "\n";
}
descriptionStr += description_data.get("value");
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("ossList", ossList);
resultMap.put("cveId", cveId);
resultMap.put("publDate", DateUtil.convertStringToTimestamp((publishedDate), "yyyy-MM-dd'T'HH:mmZ"));
resultMap.put("modiDate", DateUtil.convertStringToTimestamp((lastModifiedDate), "yyyy-MM-dd'T'HH:mmZ"));
resultMap.put("cvssScore", baseScore);
resultMap.put("summary", descriptionStr);
resultMap.put("baseMetric", baseMetric);
resultMap.put("cpe_match_all", cpe_match_all);
return resultMap;
}
private boolean nvdMetaCheckJob(String FILE_NM, String FILE_TYPE) throws IOException {
HashMap<String, String> metaInfo = nvdMetaData(FILE_NM);
if (metaInfo != null){
// 1. ์ฌ์ฉ์ค์ธ ๋ฉํ ๋ฐ์ดํฐ ์กฐํ
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileType", FILE_TYPE);
param.put("fileNm", FILE_NM);
List<HashMap<String, Object>> useList = nvdDataMapper.selectUseMetaData(param);
// 2. ๋ฉํ ๋ฐ์ดํฐ๋ฅผ ๋น๊ตํ๋ค.
// 2.1. ์ ๊ท ํ์ผ๋ฉด ๋ฉํ ๋ฐ์ดํฐ๋ฅผ ์ ๊ท ๋ฑ๋กํ๋ค.
if ( useList.size() == 0 || !metaInfo.get("modiDate").equals(useList.get(0).get("modiDate")) ){
param.put("modiDate", metaInfo.get("modiDate"));
param.put("size", Integer.parseInt(metaInfo.get("size")));
param.put("zipSize",Integer.parseInt(metaInfo.get("zipSize")));
param.put("gzSize", Integer.parseInt(metaInfo.get("gzSize")));
param.put("sha256", metaInfo.get("sha256"));
nvdDataMapper.insertNewMetaData(param);
return true;
}
// 2.2. ๋ณ๊ฒฝ๋ ํ์ผ์ด๋ฉด ๋ฉํ ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํ๋ค.
if ( useList.size() > 0 && !metaInfo.get("modiDate").equals(useList.get(0).get("modiDate")) ){
param.put("fileNm", FILE_NM);
param.put("modiDate", useList.get(0).get("modiDate"));
param.put("useYn", "N");
nvdDataMapper.updateUseYN(param);
nvdDataMapper.updateJobStatus(param);
return true;
}
} else {
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileType", FILE_TYPE);
param.put("fileNm", FILE_NM);
nvdDataMapper.insertErrorMetaData(param);
}
return false;
}
private boolean nvdMetaRetryCheckJob(String FILE_NM, String FILE_TYPE, boolean fileCheck, int cnt) {
int maxCnt = 3;
log.warn("Try again in 5 minutes...");
try {
Thread.sleep(1000 * 60 * 5);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
try {
fileCheck = nvdMetaCheckJob(FILE_NM, FILE_TYPE);
} catch (IOException ioe) {
log.error(ioe.getMessage(), ioe);
}
if (!fileCheck && cnt < maxCnt) {
fileCheck = nvdMetaRetryCheckJob(FILE_NM, FILE_TYPE, fileCheck, ++cnt);
}
return fileCheck;
}
/**
* Nvd feed data download job.
*
* @param FILE_NAME the file name
* @throws Exception the exception
*/
private void nvdFeedDataDownloadJob(String FILE_NAME) throws Exception {
String NVD_CVE_PATH = env.getProperty("root.dir");
if (StringUtil.isEmpty(NVD_CVE_PATH)) {
NVD_CVE_PATH = new FileSystemResource("").getFile().getAbsolutePath();
}
String NVD_DATA_BACKUP_PATH = NVD_CVE_PATH;
NVD_CVE_PATH = Paths.get(NVD_CVE_PATH, "nvd/cve").toString();
NVD_DATA_BACKUP_PATH = Paths.get(NVD_DATA_BACKUP_PATH, "nvd/backup").toString();
try {
FileUtil.backupRawData(NVD_CVE_PATH + File.separator + FILE_NAME + ".json.zip", NVD_DATA_BACKUP_PATH);
} catch(Exception e) {
log.error(e.getMessage(), e);
}
String downloadUrl = (NVD_DATA_FILE_NAME_CPEMATCH.equals(FILE_NAME) ? NVD_META_URL : NVD_CVE_URL) + FILE_NAME + ".json.zip";
try {
FileUtil.downloadFile(downloadUrl, NVD_CVE_PATH);
} catch (Exception e) {
log.warn(e.getMessage(), e);
Thread.sleep(1000 * 30);
log.info("Retry downloading the NVD data file. FILE_NAME : " + FILE_NAME);
if (Paths.get(NVD_CVE_PATH, FILE_NAME + ".json.zip").toFile().exists()) {
try {
Paths.get(NVD_CVE_PATH, FILE_NAME + ".json.zip").toFile().delete();
} catch (Exception e2) {}
}
FileUtil.downloadFile(downloadUrl, NVD_CVE_PATH);
}
FileUtil.decompress(NVD_CVE_PATH + File.separator + FILE_NAME + ".json.zip", NVD_CVE_PATH); // ์์ถํด์
}
@SuppressWarnings("unchecked")
public String nvdMetaDataSyncJob() throws Exception {
String resCd = "00";
// 1. Wait Job ๋ฐ์ดํฐ ์กฐํ
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("fileType", "MATCH");
List<HashMap<String, Object>> waitList = nvdDataMapper.selectWaitJobData(param);
String NVD_CVE_PATH = env.getProperty("root.dir");
if (StringUtil.isEmpty(NVD_CVE_PATH)) {
NVD_CVE_PATH = new FileSystemResource("").getFile().getAbsolutePath();
}
NVD_CVE_PATH = Paths.get(NVD_CVE_PATH, "nvd/cve").toString();
Connection conn = null;
PreparedStatement stmt = null;
PreparedStatement stmt2 = null;
String SQL_INSERT = "INSERT INTO NVD_CPE_MATCH_TEMP (SEQ, CPE23URI, VER_START_INC, VER_END_INC, VER_START_EXC, VER_END_EXC) VALUES (?,?,?,?,?,?)";
String SQL_INSERT2 = "INSERT INTO NVD_CPE_MATCH_NAMES_TEMP (SEQ, IDX, CPE23URI) VALUES (?,?,?)";
// 2. Json File -> DB Insert
for (Map<String, Object> wMetaMap : waitList) {
param.put("fileNm", wMetaMap.get("fileNm"));
param.put("modiDate", wMetaMap.get("modiDate"));
param.put("jobStatus", "G");
// JobStatus๊ฐ W์ธ ๋์์ด ์์
์ด ๋ค์ด๊ฐ๋ค๋ฉด G๋ก ๋ณ๊ฒฝ์ ํ์ฌ ์ถํ์ ๋ค์ loop ๋์ง ์๋๋ก ์ฒ๋ฆฌํจ.
log.info("Start NVD Meta Job");
nvdDataMapper.updateJobStatus(param);
int totSize = 0;
try {
log.info("Read NVD Meta Data, fileName: " + wMetaMap.get("fileNm"));
Map<String, Object> dataMap = new ObjectMapper().readValue(new File(
NVD_CVE_PATH + File.separator + ((String) wMetaMap.get("fileNm")).toLowerCase() + ".json"),
new TypeReference<Map<String, Object>>() {
});
if (dataMap.containsKey("matches")) {
List<Map<String, Object>> matchItems = (List<Map<String, Object>>) dataMap.get("matches");
int seq = 1;
totSize = matchItems.size();
log.info("Find NVD Meta matches item : " + totSize);
// ์กฐ๊ฑด์ด ๋ณ๊ฒฝ๋๊ฑฐ๋, ์ญ์ ๋๋ ๊ฒฝ์ฐ๋ฅผ ๊ณ ๋ คํ์ฌ ์ ์ฒด ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํ๊ณ ๋ค์ ๋ฑ๋กํ๋ค.
// truncate table
nvdDataMapper.createTableCpeMatchTemp();
nvdDataMapper.createTableCpeMatchNameTemp();
nvdDataMapper.truncateCpeMatchTemp();
nvdDataMapper.truncateCpeMatchNameTemp();
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
stmt = conn.prepareStatement(SQL_INSERT);
stmt2 = conn.prepareStatement(SQL_INSERT2);
int seq2 = 1;
for (Map<String, Object> matchItem : matchItems) {
// cpe23uri (key)
String cpe23Uri = (String) matchItem.get("cpe23Uri");
// version range conditions
String versionStartIncluding = null;
String versionEndIncluding = null;
String versionStartExcluding = null;
String versionEndExcluding = null;
if (matchItem.containsKey("versionStartIncluding")) {
versionStartIncluding = (String) matchItem.get("versionStartIncluding");
}
if (matchItem.containsKey("versionEndIncluding")) {
versionEndIncluding = (String) matchItem.get("versionEndIncluding");
}
if (matchItem.containsKey("versionStartExcluding")) {
versionStartExcluding = (String) matchItem.get("versionStartExcluding");
}
if (matchItem.containsKey("versionEndExcluding")) {
versionEndExcluding = (String) matchItem.get("versionEndExcluding");
}
stmt.setInt(1, seq);
stmt.setString(2, cpe23Uri);
stmt.setString(3, versionStartIncluding);
stmt.setString(4, versionEndIncluding);
stmt.setString(5, versionStartExcluding);
stmt.setString(6, versionEndExcluding);
stmt.addBatch();
stmt.clearParameters();
// CPE Names
if (matchItem.containsKey("cpe_name")) {
int nameIdx = 0;
for (Map<String, Object> cpe_name : (List<Map<String, Object>>) matchItem.get("cpe_name")) {
stmt2.setInt(1, seq);
stmt2.setInt(2, nameIdx);
stmt2.setString(3, (String) cpe_name.get("cpe23Uri"));
stmt2.addBatch();
stmt2.clearParameters();
if (seq2 % BATCH_SIZE == 0) {
stmt2.executeBatch(); // Batch ์คํ
stmt2.clearBatch(); // Batch ์ด๊ธฐํ
conn.commit(); // ์ปค๋ฐ
}
nameIdx++;
seq2++;
}
}
if (seq % BATCH_SIZE == 0) {
stmt.executeBatch(); // Batch ์คํ
stmt.clearBatch(); // Batch ์ด๊ธฐํ
conn.commit(); // ์ปค๋ฐ
log.info("In progress : " + seq + "/" + totSize);
}
seq++;
}
stmt.executeBatch(); // Batch ์คํ
stmt2.executeBatch(); // Batch ์คํ
conn.commit();
} catch (Exception e) {
log.error(e.getMessage(), e);
if (conn != null) {
try {
conn.rollback();
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch(SQLException e) {}
try {
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException e) {}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e) {}
}
}
if (totSize > 0) {
nvdDataMapper.truncateCpeMatch();
nvdDataMapper.truncateCpeMatchNames();
nvdDataMapper.copyNvdDataMatchFromTemp();
nvdDataMapper.copyNvdDataMatchNameFromTemp();
}
nvdDataMapper.truncateCpeMatchTemp();
nvdDataMapper.truncateCpeMatchNameTemp();
param.put("jobStatus", "C");
nvdDataMapper.updateJobStatus(param);
log.info("End NVD Meta Job");
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
return resCd;
}
private HashMap<String, String> nvdMetaData(String FILE_NM) throws IOException{
HashMap<String, String> metaInfo = null;
HttpsURLConnection con = null;
Scanner s = null;
try {
URL url = new URL( (NVD_DATA_FILE_NAME_CPEMATCH.equals(FILE_NM) ? NVD_META_URL : NVD_CVE_URL) +FILE_NM+".meta");
ignoreSsl();
con = (HttpsURLConnection)url.openConnection();
con.setRequestMethod("HEAD");
if (con.getResponseCode() == HttpURLConnection.HTTP_OK){
s = new Scanner(url.openConnection().getInputStream());
metaInfo = new HashMap<String, String>();
while (s.hasNext()){
String txt = s.next();
String[] d = txt.split(":");
String k = d[0].equals("lastModifiedDate") ? "modiDate" : d[0];
String v = txt.substring(d[0].length()+1, txt.length());
metaInfo.put(k, v);
}
}else{
log.warn("connection error : " + CommonFunction.httpCodePrint(con.getResponseCode()) + " - " + con.getResponseCode() + ", file name:" + FILE_NM);
}
} catch(UnknownHostException e) {
log.error("unknownHost connection error : " + CommonFunction.httpCodePrint(con.getResponseCode()) + " - " + con.getResponseCode() + ", file name:" + FILE_NM);
return metaInfo;
} finally {
if (s != null) {
try {s.close();} catch (Exception e) {}
}
if (con != null) {
try {con.disconnect();} catch (Exception e) {}
}
}
return metaInfo;
}
@Transactional
private void initNvdDataFeed() throws Exception {
int nvdBeginDateYear = 2002;
int currentDateYear = StringUtil.string2integer(DateUtil.getCurrentDateAsString("yyyy")) ;
for (int year = nvdBeginDateYear; year <= currentDateYear; year ++) {
nvdFeedDataDownloadJob("nvdcve-1.1-" + year);
}
String NVD_CVE_PATH = env.getProperty("root.dir");
if (StringUtil.isEmpty(NVD_CVE_PATH)) {
NVD_CVE_PATH = new FileSystemResource("").getFile().getAbsolutePath();
}
NVD_CVE_PATH = Paths.get(NVD_CVE_PATH, "nvd/cve").toString();
for (int year = nvdBeginDateYear; year <= currentDateYear; year ++) {
updateNvdData(NVD_CVE_PATH, "nvdcve-1.1-" + year);
}
}
/**
* Reset ALL NVD Feed Data
*/
private void resetNvdFeedData() {
nvdDataMapper.resetCveDataV3();
nvdDataMapper.resetNvdDataV3();
}
private void ignoreSsl() {
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
return true;
}
};
try {
trustAllHttpsCertificates();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
private static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new miTM();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements TrustManager,X509TrustManager {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(X509Certificate[] certs) {
return true;
}
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
}
}
| 73,019 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryDataService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/BinaryDataService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.BinaryAnalysisResult;
import oss.fosslight.domain.BinaryData;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.T2File;
import oss.fosslight.repository.BinaryDataMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.StringUtil;
import oss.fosslight.util.TlshUtil;
@Service
@Slf4j
public class BinaryDataService extends CoTopComponent {
@Autowired private BinaryDataMapper binaryDataMapper;
@Autowired private FileService fileService;
@Autowired private ProjectMapper projectMapper;
@Autowired private PartnerMapper partnerMapper;
@Autowired AutoIdService autoIDService;
public Map<String, Object> getBinaryList(String page, String rows , BinaryData vo) {
int records = 0;
HashMap<String, Object> map = new HashMap<String, Object>();
if(!StringUtil.isEmpty(vo.getFileName()) && vo.getFileName().indexOf("/") > -1) {
String[] splitFileName = vo.getFileName().split("/");
vo.setFileName(splitFileName[splitFileName.length-1]);
}
records = binaryDataMapper.countBinaryList(vo);
if(CoConstDef.FLAG_NO.equals(vo.getBinaryPopupFlag())) {
vo.setCurPage(Integer.parseInt( StringUtil.isNotEmpty(page) ? page : "1"));
vo.setPageListSize(Integer.parseInt( StringUtil.isNotEmpty(rows) ? rows : "20"));
}
List<BinaryData> list = binaryDataMapper.getBinaryList(vo);
for(BinaryData item : list) {
item.setDownloadlocation(CommonFunction.getOssDownloadLocation(item.getOssName(), item.getOssVersion()));
}
if(CoConstDef.FLAG_NO.equals(vo.getBinaryPopupFlag())) {
map.put("page", vo.getCurPage());
map.put("total", vo.getTotBlockSize());
}
map.put("records", records);
map.put("rows", list);
return map;
}
@Transactional
@CacheEvict(value={"tlshFindOssInfoCache", "tlshDistanceCache"}, allEntries=true)
public void setBinaryDataModify(BinaryData bean) {
// Connection conn = null;
// PreparedStatement stmt = null;
// String SQL_UPDATE_LGBAT = "UPDATE lgematching SET ossname = ?, ossversion = ?, license = ? , parentname = ?, pathname = ?, sourcepath = ?,platformname=?,platformversion=?, updatedate = CURRENT_TIMESTAMP WHERE concat( filename , '-' , checksum, '-', COALESCE(ossname,''), '-', COALESCE(ossversion,''), '-', COALESCE(REPLACE(license, ',','|'),'') ) = ?";
// String SQL_DELETE_LGBAT = "DELETE FROM lgematching WHERE concat( filename , '-' , checksum, '-', COALESCE(ossname,''), '-', COALESCE(ossversion,''), '-', COALESCE(REPLACE(license, ',','|'),'') ) = ?";
boolean isDeleteMode = CoConstDef.GRID_OPERATION_DELETE.equals(bean.getOper());
List<BinaryData> historyList = new ArrayList<>();
if(!StringUtil.isEmpty(bean.getId()) && StringUtil.isEmpty(bean.getBatId())) {
bean.setBatId(bean.getId());
}
if(StringUtil.isEmpty(bean.getBatId())) {
bean.setBatId(bean.getFileName() + "-" + bean.getCheckSum() + "-" + avoidNull(bean.getOssName()) + "-" + avoidNull(bean.getOssVersion()) + "-" + avoidNull(bean.getLicense()));
}
// ๋ณ๊ฒฝ ์ด๋ ฅ์ ๋จ๊ธฐ๊ธฐ ์ํด ์ญ์ ์ธ ๊ฒฝ์ฐ ๊ธฐ์กด ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
if(isDeleteMode) {
BinaryData searchParam = new BinaryData();
for(String id : bean.getId().split(",")) {
if(!StringUtil.isEmpty(id)) {
searchParam.setBatId(id);
Map<String, Object> searchResultMap = getBinaryList(null, null, searchParam);
if(searchResultMap.get("rows") != null) {
historyList.addAll( (List<BinaryData>) searchResultMap.get("rows"));
}
}
}
}
if("N/A".equals(bean.getOssVersion())) {
bean.setOssVersion("");
}
if(isDeleteMode) {
BinaryData searchParam = new BinaryData();
for(String id : bean.getId().split(",")) {
if(!StringUtil.isEmpty(id)) {
searchParam.setBatId(id);
binaryDataMapper.deleteBinaryData(id);
}
}
} else {
binaryDataMapper.updateBinaryData(bean);
historyList.add(bean);
}
// ๋ณ๊ฒฝ ์ด๋ ฅ
if(!historyList.isEmpty()) {
try {
String actionId = isEmpty(bean.getActionId()) ? DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN) : bean.getActionId();
// bat vo => BinaryAnalysisResult
for(BinaryData hisVo : historyList) {
hisVo.setActionId(actionId);
hisVo.setActionType(isDeleteMode ? "DELETE" : "MODIFY");
binaryDataMapper.insertBinaryDataLog(hisVo);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
@Transactional
public void setBinaryDataListModify(List<BinaryData> list) {
String actionId = DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN);
for(BinaryData bean : list) {
bean.setActionId(actionId);
setBinaryDataModify(bean);
}
}
private List<BinaryData> getBinaryDbLogBean(String type, List<BinaryData> checkList) {
if(checkList != null) {
for(BinaryData item : checkList) {
item.setActionType(type);
}
}
return checkList;
}
public Map<String, Object> getExistBinaryName (BinaryData vo){
HashMap<String, Object> map = new HashMap<String, Object>();
int totalCnt = binaryDataMapper.countExistsBinaryName(vo.getFileName());
map.put("isValid", totalCnt > 0);
return map;
}
private boolean checkTlshDistance(String tlsh1, String tlsh2) {
log.debug("check tlsh distance : tlsh1 = " + avoidNull(tlsh1) +", tlsh2 = " + avoidNull(tlsh2));
if(!isEmpty(tlsh1) && !isEmpty(tlsh2)) {
int rtn = TlshUtil.compareTlshDistance(tlsh1,tlsh2);
log.debug("distance result = " + rtn);
return rtn > -1 && rtn <= 120;
}
return false;
}
public void insertBatConfirmBinOssWithChecksum(String prjName, String platformName, String platformVer, String fileId, List<ProjectIdentification> list) {
T2File binaryTextFile = new T2File();
if(!isEmpty(fileId) && list != null && !list.isEmpty()) {
binaryTextFile = fileService.selectFileInfoById(fileId);
}
insertBatConfirmBinOssWithChecksum(null, prjName, platformName, platformVer, binaryTextFile, list);
}
public void insertBatConfirmBinOssWithChecksum(String gubn, String prjName, String platformName, String platformVer, T2File binaryTextFile, List<ProjectIdentification> list) {
//bin binary.txt ํ์ผ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ค.
if(binaryTextFile != null) {
String _contents = avoidNull(CommonFunction.getStringFromFile(binaryTextFile.getLogiPath() + "/" + binaryTextFile.getLogiNm()));
// Binary sha256sum tlsh
// ./tlsh_unittest 404b0e9fad52eecd8c342779e8cddff9385d7c094a9e3a29142aa4ef3e2398ea 46B3DE93D364FEAFDA28FBFC598A78D9C4C5A0522DF00A4B65461F9A00CE1D06B453ED
// ./rand_tags 40d2efb42d536f0a1afb2cbcac8e0b38994a8caa3d50d95fa663a852ea655725 B9B3CD93D364FEAFDA28FAFC598978D9C4CAD4122DF00A5B65021F9A04CD2D06B453ED
// ./tlsh_version ee2a667560664b50a13414db878ef31a826f627b11bce658d3b74421140d6253 39021FC7A3E1CAAFCC9822BD085F077532B3D4B2436383120A0AA7741F41BD91F59999
// ./simple_unittest 79a24b0c4dbcef50e1f59dd078e913d06d0ad5115a459a9ddd743b909a8edf89 90939A93D364FE9FEA28EAFC598978D9C4C994132DF00A5B65421F9A40CE1D03B453EE
Map<String, String[]> checksumInfoMap = new HashMap<>();
Map<String, String[]> checksumInfoMapByBinaryPath = new HashMap<>();
boolean isHeader = true;
for(String line : _contents.split(System.lineSeparator())) {
if(isHeader) {
isHeader = false;
continue;
}
// binary name์ key๋ก sha256sum๊ณผ tlsh ๋ฅผ ๊ฒฉ๋ฉํ๋ค.
String[] data = line.split("\t", -1);
if(data == null || data.length !=3
|| isEmpty(data[0]) || isEmpty(data[1])/* || isEmpty(data[2])*/) {
log.warn("unexpected format Bin binary text ("+prjName+") : " + line);
continue;
}
String binaryName = data[0].trim();
if(binaryName.endsWith("/") || binaryName.endsWith("\\")) {
log.warn("unexpected format Bin binary text (is not file) ("+prjName+") : " + line);
continue;
}
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
if(isEmpty(binaryName)) {
continue;
}
checksumInfoMapByBinaryPath.put(data[0].trim(), new String[]{data[1], avoidNull(data[2], "0")});
checksumInfoMap.put(binaryName, new String[]{data[1], avoidNull(data[2], "0")});
}
// checksum ์ ๋ณด๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
// bat db ๋ฑ๋ก์ ์ํด oss list์์ checksum ์ ๋ณด์ ์กด์ฌํ๋ oss ์ ๋ณด๋ฅผ ๊ฒฉ๋ฉํ๋ค.
Map<String, BinaryAnalysisResult> batInfoMap = new HashMap<>();
if(!checksumInfoMap.isEmpty() || !checksumInfoMapByBinaryPath.isEmpty()) {
for(ProjectIdentification bean : list) {
if(CoConstDef.FLAG_YES.equals(bean.getExcludeYn()) || isEmpty(bean.getBinaryName()) || bean.getBinaryName().endsWith("/") || bean.getBinaryName().endsWith("\\")) {
continue;
}
String[] checkSumData = null;
String binaryName = bean.getBinaryName();
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
if(checksumInfoMapByBinaryPath.containsKey(bean.getBinaryName())) { // full path๋ก ๊ฒ์ํด์ ์๋ค๋ฉด ํด๋น ์ ๋ณด๋ฅผ ๋ด๋๋ค.
checkSumData = checksumInfoMapByBinaryPath.get(bean.getBinaryName());
}
if(ArrayUtils.isEmpty(checkSumData) && checksumInfoMap.containsKey(binaryName)) { // full path๋ก ๊ฒ์ํด์ ์กด์ฌํ์ง ์๋ ์ ๋ณด๋ผ๋ฉด binary name์ผ๋ก ๊ฒ์์ ํ๊ณ ๋์ ๋ ์ ์ผ ๋ง์ง๋ง ์ ๋ณด๋ฅผ ๋ด๋๋ค.
checkSumData = checksumInfoMap.get(binaryName);
}
if(!ArrayUtils.isEmpty(checkSumData)){
BinaryAnalysisResult _updateBean = new BinaryAnalysisResult();
_updateBean.setBinaryName(binaryName);
_updateBean.setFilePath(bean.getBinaryName());
_updateBean.setCheckSum(checkSumData[0]);
_updateBean.setTlsh(checkSumData[1]);
_updateBean.setOssName(bean.getOssName());
_updateBean.setOssVersion(bean.getOssVersion());
_updateBean.setLicense(CommonFunction.getSelectedLicenseString(bean.getComponentLicenseList()));
_updateBean.setParentname(prjName);
_updateBean.setPlatformname(platformName);
_updateBean.setPlatformversion(platformVer);
_updateBean.setDownloadLocation(bean.getDownloadLocation());
_updateBean.setPrjId(bean.getReferenceId());
batInfoMap.put(_updateBean.getBinaryName() + "|" + _updateBean.getCheckSum()+ "|" +avoidNull(_updateBean.getOssName())+ "|" +avoidNull(_updateBean.getOssVersion())+ "|" +avoidNull(_updateBean.getLicense()), _updateBean);
}
}
}
// db ๋ฑ๋ก
if(!batInfoMap.isEmpty()) {
try {
mergeBinaryOssInfo(batInfoMap);
String mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_BINARY_DATA_COMMIT;
if(!isEmpty(gubn)) {
mailType = CoConstDef.CD_MAIL_TYPE_PARTNER_BINARY_DATA_COMMIT;
}
String comment = "Data is added to the Binary DB. : Success";
CoMail mailBean = new CoMail(mailType);
if(!isEmpty(gubn)) {
mailBean.setParamPartnerId(batInfoMap.get(batInfoMap.keySet().toArray()[0]).getPrjId());
} else {
mailBean.setParamPrjId(batInfoMap.get(batInfoMap.keySet().toArray()[0]).getPrjId());
}
mailBean.setComment(comment);
mailBean.setBinaryCommitResult("Success");
//CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
String mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_BINARY_DATA_COMMIT;
if(!isEmpty(gubn)) {
mailType = CoConstDef.CD_MAIL_TYPE_PARTNER_BINARY_DATA_COMMIT;
}
String comment = "Data is added to the Binary DB. : Failed";
CoMail mailBean = new CoMail(mailType);
if(!isEmpty(gubn)) {
mailBean.setParamPartnerId(batInfoMap.get(batInfoMap.keySet().toArray()[0]).getPrjId());
} else {
mailBean.setParamPrjId(batInfoMap.get(batInfoMap.keySet().toArray()[0]).getPrjId());
}
mailBean.setComment(comment);
mailBean.setBinaryCommitResult("Failed");
//CoMailManager.getInstance().sendMail(mailBean);
}
}
}
}
@Transactional
private void mergeBinaryOssInfo(Map<String, BinaryAnalysisResult> batInfoMap) {
List<BinaryData> historyList = new ArrayList<>();
String actionId = DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN);
// tlsh distance๊ฐ 120์ดํ์ด๊ณ , OSS / Version์ด ๋์ผํ ๊ฒฝ์ฐ
Map<String, String> binaryList = new HashMap<String, String>();
List<String> duplicatedList = new ArrayList<>();
for(BinaryAnalysisResult bean : batInfoMap.values()) {
/**
* OSC-1257 - BIN(Android), BIN > Binary DB ์ ์ฅํ ๋ ์ค๋ณต Data ์ ์ฅ๋จ
* binary name + checksum๊ฐ์ด ๋์ผํ๊ณ path name๋ง ๋ค๋ฅผ ๊ฒฝ์ฐ duplicatedList์ ์ถ๊ฐํ์ฌ insert๋ฅผ ์ ํํจ.(์ต์ด์ ๋ฐ๊ฒฌ๋ path name๋ง insertํจ.)
* binary name + checksum ๋์ผํ๋ฉด์ oss name๊ณผ license name์ด ๋ค๋ฅผ ๊ฒฝ์ฐ๋ ์ ์์ ์ผ๋ก ๋ฑ๋ก๋จ.
*/
String binaryKey = bean.getBinaryName() + "_" + bean.getCheckSum();
if(isEmpty((String) binaryList.get(binaryKey))) {
binaryList.put(binaryKey, bean.getFilePath());
} else {
String pathData = binaryList.get(binaryKey);
if(!pathData.equals(bean.getFilePath())) {
duplicatedList.add(bean.getFilePath());
}
}
// OSC-673
// OSC-1056 binary name + checksum ์ด ๋์ผํ๋ฉด ๋์ผํ ๋ฐ์ด๋๋ฆฌ ์, ์ญ์ ํ๊ณ ์ต์ ํ
bean.setOssName(avoidNull(bean.getOssName(), "-"));
List<BinaryData> checkList = binaryDataMapper.getBinaryListWithNameAndChecksum(bean.getBinaryName(), bean.getCheckSum());
if(checkList != null && checkList.size() > 0) {
// For change history, change target information is acquired before updating.
historyList.addAll(getBinaryDbLogBean("DELETE", checkList));
// delete old data
binaryDataMapper.deleteBinaryListWithNameAndChecksum(bean.getBinaryName(), bean.getCheckSum());
}
// Update if tlsh distance is within 120
if(!"0".equals(bean.getTlsh())) {
List<BinaryData> tlshList = binaryDataMapper.getBinaryTlshListWithoutChecksum(bean.getBinaryName(), bean.getCheckSum());
if(tlshList != null) {
for(BinaryData item : tlshList) {
String _tlsh = item.getTlshCheckSum();
String _checksum = item.getCheckSum();
String _ossname = avoidNull(item.getOssName(), "-");
String _ossversion = item.getOssVersion();
if(checkTlshDistance(bean.getTlsh(), _tlsh)) {
//log.debug("update tish distance under 120. binary name : " + bean.getBinaryName() + " , checksum : " + _checksum);
// oss name ์ด ๋ค๋ฅด๋ฉด ํํํ ๋์
// oss name ๊ณผ version ์ด ๊ฐ์ผ๋ฉด ํํํ (๋์ผํ ๋ฐ์ด๋๋ฆฌ์ ๋ํด์ ๋ผ์ด์ ์ค ์ ๋ณด๋ฅผ ํํํ)
// oss name์ ๊ฐ์ผ๋ version์ด ๋ค๋ฅธ ๊ฒฝ์ฐ ์ ๊ท ์ถ๊ฐ๋ง
if(!bean.getOssName().equalsIgnoreCase(_ossname)
|| (bean.getOssName().equalsIgnoreCase(_ossname) && avoidNull(bean.getOssVersion()).equalsIgnoreCase(avoidNull(_ossversion)))) {
// OSC-1056 oss name์ด ๋ค๋ฅด๊ฑฐ๋, ๋์ผํ oss ์ธ ๊ฒฝ์ฐ (oss name + version์ด ๋์ผ) ์ญ์ ํ์ง ์๊ณ , tlsh ๋ฅผ 0์ผ๋ก ์
๋ฐ์ดํธํ์ฌ ๊ธฐ์กด์ ๋ฑ๋ก๋ binary์ ๋ณด๊ฐ ๋ณ๊ฒฝ๋์ง ์๋๋ก ํจ (checksum์ด ๋์ผํ ๋ฐ๋ฆฌ๋๋ฆฌ๋ฅผ ์ฐ์ ํด์ ์ฐพ๊ธฐ ๋๋ฌธ์ tlsh๊ฐ ๋ฌ๋ผ์ ธ๋ ๋์ผํ binary์ ๊ฒฝ์ฐ ๋ฌด๊ดํจ)
item.setActionType("UPDATE");
//item.setTlsh("0");// TLSH_CHECK_SUM
historyList.add(item);
binaryDataMapper.updateTlshCheckSumToZero(bean.getBinaryName(), _checksum, _ossname, _ossversion);
}
}
}
}
}
}
for(BinaryAnalysisResult bean : batInfoMap.values()) {
// binary Name๊ณผ binary Path์ด ์ ๋ถ ๋์ผํ ๊ฐ์ด์ธ์ ๊ฐ๋ค์ ์ ๋ถ ๋ฌด์ํจ. ** ๋์ผํ checksum๊ฐ์ด๋ผ๊ณ ํ๋๋ผ๋ path์ ๋ณด๊ฐ ๋ค๋ฅด๋ค๋ฉด ๋ฌด์.
if(duplicatedList.contains(bean.getFilePath())) {
continue;
}
BinaryData item = new BinaryData();
item.setFileName(bean.getBinaryName());
item.setPathName(bean.getFilePath());
item.setSourcePath(bean.getSourcePath());
item.setCheckSum(bean.getCheckSum());
item.setTlshCheckSum(bean.getTlsh());
item.setOssName(avoidNull(bean.getOssName(), "-"));
item.setOssVersion(bean.getOssVersion());
item.setLicense(bean.getLicense());
item.setParentName(bean.getParentname());
item.setPlatformName(bean.getPlatformname());
item.setPlatformVersion(bean.getPlatformversion());
binaryDataMapper.insertBinaryData(item);
item.setActionType("INSERT");
historyList.add(item);
}
try{
// commit ์ฑ๊ณตํ๋ฉด ์ด๋ ฅ ๋ฑ๋ก
for(BinaryData tempBean : historyList) {
tempBean.setActionId(actionId);
binaryDataMapper.insertBinaryDataLog(tempBean);
}
}catch(Exception e){
log.error(e.getMessage(), e);
}
}
public void insertBatConfirmAndroidBinOssWithChecksum(String prjName, String platformName, String platformVer,
String fileId, List<ProjectIdentification> list) {
if(!isEmpty(fileId) && list != null && !list.isEmpty()) {
log.debug("Start insertBatConfirmAndroidBinOssWithChecksum");
//bin binary.txt ํ์ผ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ค.
T2File binaryTextFile = fileService.selectFileInfoById(fileId);
if(binaryTextFile != null) {
Map<String, Object> readFileData = CommonFunction.getAndroidResultFileInfo(binaryTextFile, new ArrayList<String>());
if(readFileData != null && readFileData.containsKey("addCheckList")) {
Map<String, String[]> checksumInfoMap = new HashMap<>();
Map<String, String[]> checksumInfoMapByBinaryPath = new HashMap<>();
List<OssComponents> _list = (List<OssComponents>) readFileData.get("addCheckList");
for(OssComponents bean : _list) {
// binary name์ key๋ก sha256sum๊ณผ tlsh ๋ฅผ ๊ฒฉ๋ฉํ๋ค.
if(isEmpty(bean.getBinaryName()) || isEmpty(bean.getCheckSum()) || isEmpty(bean.getTlsh())) {
continue;
}
String binaryName = bean.getBinaryName();
if(binaryName.endsWith("/") || bean.getBinaryName().endsWith("\\")) {
continue;
}
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
if(isEmpty(binaryName)) {
continue;
}
checksumInfoMapByBinaryPath.put(bean.getBinaryName(), new String[]{bean.getCheckSum(), bean.getTlsh(), avoidNull(bean.getSourceCodePath())});
checksumInfoMap.put(binaryName, new String[]{bean.getCheckSum(), bean.getTlsh(), avoidNull(bean.getSourceCodePath())});
}
// checksum ์ ๋ณด๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
// bat db ๋ฑ๋ก์ ์ํด oss list์์ checksum ์ ๋ณด์ ์กด์ฌํ๋ oss ์ ๋ณด๋ฅผ ๊ฒฉ๋ฉํ๋ค.
Map<String, BinaryAnalysisResult> batInfoMap = new HashMap<>();
if(!checksumInfoMap.isEmpty() || !checksumInfoMapByBinaryPath.isEmpty()) {
for(ProjectIdentification bean : list) {
if(CoConstDef.FLAG_YES.equals(bean.getExcludeYn()) || isEmpty(bean.getBinaryName()) || bean.getBinaryName().endsWith("/") || bean.getBinaryName().endsWith("\\")) {
continue;
}
String[] checkSumData = null;
String binaryName = bean.getBinaryName();
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
if(checksumInfoMapByBinaryPath.containsKey(bean.getBinaryName())) { // full path๋ก ๊ฒ์ํด์ ์๋ค๋ฉด ํด๋น ์ ๋ณด๋ฅผ ๋ด๋๋ค.
checkSumData = checksumInfoMapByBinaryPath.get(bean.getBinaryName());
}
if(ArrayUtils.isEmpty(checkSumData) && checksumInfoMap.containsKey(binaryName)) { // full path๋ก ๊ฒ์ํด์ ์กด์ฌํ์ง ์๋ ์ ๋ณด๋ผ๋ฉด binary name์ผ๋ก ๊ฒ์์ ํ๊ณ ๋์ ๋ ์ ์ผ ๋ง์ง๋ง ์ ๋ณด๋ฅผ ๋ด๋๋ค.
checkSumData = checksumInfoMap.get(binaryName);
}
if(!ArrayUtils.isEmpty(checkSumData)){
BinaryAnalysisResult _updateBean = new BinaryAnalysisResult();
_updateBean.setBinaryName(binaryName);
_updateBean.setFilePath(bean.getBinaryName());
_updateBean.setCheckSum(checkSumData[0]);
_updateBean.setTlsh(checkSumData[1]);
_updateBean.setSourcePath(checkSumData[2]);
_updateBean.setOssName(bean.getOssName());
_updateBean.setOssVersion(bean.getOssVersion());
_updateBean.setLicense(CommonFunction.getSelectedLicenseString(bean.getComponentLicenseList()));
_updateBean.setParentname(prjName);
_updateBean.setPlatformname(platformName);
_updateBean.setPlatformversion(platformVer);
_updateBean.setDownloadLocation(bean.getDownloadLocation());
_updateBean.setPrjId(bean.getReferenceId());
// ํ๋์ binary์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ๋ฑ๋ก๋์ด ์๋ ๊ฒฝ์ฐ + OSS Name ์ด ์๊ณ (ํ์ดํ), ๋ผ์ด์ ์ค๋ง ๋ค๋ฅธ ๊ฒฝ์ฐ key ์ค๋ณต์ผ๋ก ๋ฑ๋ก๋์ง ์๋ ํ์์ ์ํด, ๋ผ์ด์ ์ค๋ ํฌํจ
// OSC-806
batInfoMap.put(_updateBean.getBinaryName() + "|" + _updateBean.getCheckSum()+ "|" +avoidNull(_updateBean.getOssName())+ "|" +avoidNull(_updateBean.getOssVersion())+ "|" +avoidNull(_updateBean.getLicense()), _updateBean);
}
}
} else {
log.debug("insertBatConfirmAndroidBinOssWithChecksum : checksumInfoMap is empty");
}
// db ๋ฑ๋ก
if(!batInfoMap.isEmpty()) {
mergeBinaryOssInfo(batInfoMap);
} else {
log.debug("insertBatConfirmAndroidBinOssWithChecksum : batInfoMap is empty");
}
}
} else {
log.debug("insertBatConfirmAndroidBinOssWithChecksum : cannot find file android result.txt");
}
log.debug("End insertBatConfirmAndroidBinOssWithChecksum");
}
}
@Transactional
public void autoIdentificationWithBinryTextFile(Project project) {
if(!isEmpty(project.getBinBinaryFileId())) {
// oss name๊ณผ license๊ฐ ์ค์ ๋์ง ์์ oss coponent๋ฅผ ์ฐพ๋๋ค.
// component_id์ binary name๋ง ๋ฐํํ๋ค.
List<OssComponents> componentList = projectMapper.findBinAutoIdentificationWithBinaryText(project.getPrjId());
if(componentList != null && !componentList.isEmpty()) {
// DB์์ binary๋ก ๋งคํ๋๋ ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
Map<String, String[]> mappingData = loadBinaryText(project.getBinBinaryFileId(), true);
if(mappingData != null && !mappingData.isEmpty()) {
Map<String, List<BinaryData>> binaryRegInfoMap = new HashMap<>();
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
if(isEmpty(binaryName)) {
continue;
}
// ์
๋ก๋ํ binaryํ์ผ๊ณผ grid์ ๋ฑ๋กํ binaryname์ด ๋์ผํ data์ธ ๊ฒฝ์ฐ, bat DB์์ oss ์ ๋ณด๋ฅผ ์ฐพ๋๋ค.
String checkBinaryName = "";
String[] tlshData = null;
if(mappingData.containsKey(binaryName)) {
tlshData = mappingData.get(binaryName);
checkBinaryName = binaryName;
if(checkBinaryName.indexOf("/") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("/") + 1);
}
if(checkBinaryName.indexOf("\\") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("\\") + 1);
}
}
if(isEmpty(checkBinaryName) && ArrayUtils.isEmpty(tlshData)){
checkBinaryName = binaryName;
if(checkBinaryName.indexOf("/") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("/") + 1);
}
if(checkBinaryName.indexOf("\\") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("\\") + 1);
}
if(mappingData.containsKey(checkBinaryName)) {
tlshData = mappingData.get(checkBinaryName);
}
}
if(!isEmpty(checkBinaryName) && !ArrayUtils.isEmpty(tlshData)){
List<BinaryData> binaryInfoList = autoIDService.findOssInfoWithBinaryName(checkBinaryName, tlshData[0], tlshData[1]);
if(binaryInfoList != null) {
binaryRegInfoMap.put(binaryName, binaryInfoList);
}
}
}
// binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์๊ฐ์ด ์ค๋๊ฑธ๋ฆด ์ ์๊ธฐ ๋๋ฌธ์ ํ๋์ ์
์ด์๋ฅผ ์ต์ํ ํ๊ธฐ ์ํด ์ผ๋จ binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์ฒ๋ฆฌ๋ง ๋จผ์ ์ํํ๊ณ ํธ๋์ ์
์ ๋ถ๋ฆฌํ์ฌ ๋ฑ๋ก ํ๋ค.
addOssComponentByBinaryInfo(componentList, binaryRegInfoMap);
}
}
}
}
private Map<String, String[]> loadBinaryText(String fileId, boolean pathFlag) {
Map<String, String[]> loadData = new HashMap<>();
T2File binaryTextFile = fileService.selectFileInfoById(fileId);
if(binaryTextFile != null && binaryTextFile.getExt().equals("txt")) {
log.info("loadBinaryText : " + binaryTextFile.getLogiNm());
String _contents = avoidNull(CommonFunction.getStringFromFile(binaryTextFile.getLogiPath() + "/" + binaryTextFile.getLogiNm()));
if(!isEmpty(_contents)) {
boolean isHeader = true;
int idx_checkSum = -1;
int idx_tlsh = -1;
int idx_binaryName = -1;
for(String line : _contents.split(System.lineSeparator())) {
if(isHeader) {
String[] hdata = line.split("\t", -1);
// header ์ ๋ณด๊ฐ ์์ ๊ฒฝ์ฐ ์ฒ๋ฆฌ ์ค๋จ
if(hdata == null || isEmpty(line)) {
log.warn("Header row is empty :" + binaryTextFile.getLogiNm());
break;
}
int idx = 0;
for(String s : hdata) {
if(idx_binaryName < 0 && (s.trim().equalsIgnoreCase("Binary Name") || s.trim().equalsIgnoreCase("Binary"))) {
idx_binaryName = idx;
} else if(idx_checkSum < 0 && (s.trim().equalsIgnoreCase("checksum") || s.trim().equalsIgnoreCase("sha1sum"))) {
idx_checkSum = idx;
} else if(idx_tlsh < 0 && (s.trim().equalsIgnoreCase("tlsh"))) {
idx_tlsh = idx;
}
idx ++;
}
isHeader = false;
continue;
}
String binaryName, checkSum, tlsh;
String[] data = line.split("\t", -1);
if(idx_binaryName > -1 && idx_checkSum > -1 && idx_tlsh > -1) {
if(data == null) {
log.warn("unexpected format Bin binary text : " + line);
continue;
} else if(data.length < idx_binaryName + 1) {
log.warn("unexpected format Bin binary text (idx_binaryName index): " + line); continue;
} else if(data.length < idx_checkSum + 1) {
log.warn("unexpected format Bin binary text (idx_checkSum index): " + line); continue;
} else if(data.length < idx_tlsh + 1) {
log.warn("unexpected format Bin binary text (idx_tlsh index): " + line); continue;
}
binaryName = data[idx_binaryName].trim();
checkSum = data[idx_checkSum].trim();
tlsh = data[idx_tlsh].trim();
// OSC-1028 tils๊ฐ ์ถ์ถ๋์ง ์์ ๊ฒฝ์ฐ ๊ณต๋ฐฑ
if(isEmpty(binaryName) || isEmpty(checkSum)/* || isEmpty(tlsh)*/) {
log.warn("unexpected format Bin binary text : " + line);
continue;
}
} else {
// binary name์ key๋ก sha256sum๊ณผ tlsh ๋ฅผ ๊ฒฉ๋ฉํ๋ค.
if(data == null || data.length !=3
|| isEmpty(data[0]) || isEmpty(data[1])/* || isEmpty(data[2])*/) {
log.warn("unexpected format Bin binary text : " + line);
continue;
}
binaryName = data[0].trim();
if(binaryName.endsWith("/") || binaryName.endsWith("\\")) {
log.warn("unexpected format Bin binary text (is not file) : " + line);
continue;
}
checkSum = data[1].trim();
tlsh = data[2].trim();
}
if(!pathFlag){
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
}
if(isEmpty(binaryName)) {
continue;
}
loadData.put(binaryName, new String[]{checkSum, avoidNull(tlsh, "0")});
}
}
}
return loadData;
}
@Transactional
private void addOssComponentByBinaryInfo(List<OssComponents> componentList,
Map<String, List<BinaryData>> binaryRegInfoMap) {
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
String componentId = bean.getComponentId();
if(isEmpty(binaryName)) {
continue;
}
if(!binaryRegInfoMap.containsKey(binaryName)) {
continue;
}
List<BinaryData> binaryInfoList = binaryRegInfoMap.get(binaryName);
boolean addOssComponentFlag = false;
for(BinaryData binaryInfo : binaryInfoList) {
if(!isEmpty(binaryInfo.getOssName())) {
Map<String, OssMaster> ossInfo = CoCodeManager.OSS_INFO_UPPER;
String key = binaryInfo.getOssName() + "_" + avoidNull(binaryInfo.getOssVersion());
String _binaryLicenseStr = binaryInfo.getLicense();
// binary db์ ํ์ดํ์ผ๋ก ๋ฑ๋ก๋ case๋ก ๊ณ ๋ คํด์ผํจ
//if(ossInfo.containsKey(key.toUpperCase()) || "-".equals(binaryInfo.getOssName()) ) {
// oss name + version ์ด ์ผ์นํ๋ oss ๊ฐ ์กด์ฌํ๋ฉด, update ํ๋ค.
OssMaster ossBean = ossInfo.get(key.toUpperCase());
boolean isEmptyOss = (ossBean == null || "-".equals(binaryInfo.getOssName()));
// update๋ฅผ ์ํด
// ossmaster => projectIdentification ์ผ๋ก ๋ณํ
ProjectIdentification updateBean = new ProjectIdentification();
if(ossBean != null) {
if(!isEmptyOss) {
updateBean.setOssId(ossBean.getOssId());
}
updateBean.setOssName(isEmptyOss ? "-" : ossBean.getOssNameTemp()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(isEmptyOss ? avoidNull(binaryInfo.getOssVersion()) : ossBean.getOssVersion());
updateBean.setDownloadLocation(isEmptyOss ? "" : ossBean.getDownloadLocation());
updateBean.setHomepage(isEmptyOss ? "" : ossBean.getHomepage());
updateBean.setCopyrightText(isEmptyOss ? "" : ossBean.getCopyright());
} else {
updateBean.setOssId(null);
updateBean.setOssName(binaryInfo.getOssName()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(avoidNull(binaryInfo.getOssVersion()));
updateBean.setDownloadLocation(null);
updateBean.setHomepage(null);
updateBean.setCopyrightText(null);
}
// ๊ธฐ์กด๊ฐ ์ ์ง
updateBean.setFilePath(bean.getFilePath());
updateBean.setExcludeYn(bean.getExcludeYn());
updateBean.setBinaryName(bean.getBinaryName());
updateBean.setBinaryNotice(bean.getBinaryNotice());
updateBean.setCustomBinaryYn(bean.getCustomBinaryYn());
// ํ๋์ binary์ ๋ํด์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ์ ์ฉ๋ ๊ฒฝ์ฐ, ์ต์ด ํ๋ฒ๋ง ์
๋ฐ์ดํธํ๊ณ ์ดํ๋ถํฐ๋ ์ ๊ท ๋ฑ๋กํ๋ค.
if(addOssComponentFlag) {
updateBean.setReferenceId(bean.getReferenceId());
updateBean.setReferenceDiv(bean.getReferenceDiv());
projectMapper.insertOssComponents(updateBean);
componentId = updateBean.getComponentId();
} else {
updateBean.setComponentId(componentId);
projectMapper.updateSrcOssList(updateBean);
addOssComponentFlag = true;
// ๊ธฐ์กด license ์ญ์
projectMapper.deleteOssComponentsLicense(bean);
}
List<String> selectedLicenseIdList = new ArrayList<>();
if(!isEmpty(_binaryLicenseStr)) {
for(String _licenseName : _binaryLicenseStr.split(",")) {
if(isEmpty(_licenseName)) {
continue;
}
_licenseName = _licenseName.trim();
String _licenseId = CommonFunction.getLicenseIdByName(_licenseName);
if(!isEmpty(_licenseId)) {
selectedLicenseIdList.add(_licenseId);
}
}
}
List<OssComponentsLicense> updateLicenseList = new ArrayList<>();
//List<ProjectIdentification> updateLicenseDefaultList = new ArrayList<>();
// oss name์ด ํ์ดํ์ด ์๋๋ผ๋ฉด, OSS List์ ๋ฑ๋ก๋ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ทจํฉ
if(!isEmptyOss) {
boolean hasSelectedLicense = false;
for(OssLicense license : ossBean.getOssLicenses()) {
OssComponentsLicense componentLicense = new OssComponentsLicense();
componentLicense.setComponentId(componentId);
componentLicense.setLicenseId(license.getLicenseId());
componentLicense.setLicenseName(license.getLicenseName());
// license text ์ค์ ์ ๋ถํ์ํจ
if(selectedLicenseIdList.contains(componentLicense.getLicenseId())) {
hasSelectedLicense = true;
componentLicense.setExcludeYn(CoConstDef.FLAG_NO);
}
updateLicenseList.add(componentLicense);
}
for(OssComponentsLicense license : updateLicenseList) {
if(hasSelectedLicense) {
license.setExcludeYn(avoidNull(license.getExcludeYn(), CoConstDef.FLAG_YES));
} else {
license.setExcludeYn(CoConstDef.FLAG_NO);
}
projectMapper.insertOssComponentsLicense(license);
}
}
// oss name์ด ํ์ดํ์ด๋ผ๋ฉด ๋ผ์ด์ ์ค binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ license๊ฐ ๋ณต์๊ฐ๋ก ๋ฑ๋ก๋์ด ์์ ์ ์์
else {
OssComponentsLicense license = new OssComponentsLicense();
license.setExcludeYn(CoConstDef.FLAG_NO);
license.setComponentId(componentId);
// binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๊ฐ license master์ ๋ฑ๋ก๋์ด ์๋ค๋ฉด master ์ ๋ณด๋ฅผ ์ฌ์ฉ
if(!isEmpty(_binaryLicenseStr) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(_binaryLicenseStr.toUpperCase().trim())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_binaryLicenseStr.toUpperCase().trim());
license.setLicenseId(licenseMaster.getLicenseId());
license.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseName()));
}
// ๋ฑ๋ก๋์ด ์์ง ์๋ค๋ฉด, license name๋ง ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฌ์คํญ ์กด์ฌํ ์ ์์
else {
license.setLicenseName(avoidNull(_binaryLicenseStr));
}
projectMapper.insertOssComponentsLicense(license);
}
//}
}
}
}
}
@Transactional
private void addOssComponentByBinaryInfoPartner(List<OssComponents> componentList,
Map<String, List<BinaryData>> binaryRegInfoMap) {
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
String componentId = bean.getComponentId();
if(isEmpty(binaryName)) {
continue;
}
if(!binaryRegInfoMap.containsKey(binaryName)) {
continue;
}
List<BinaryData> binaryInfoList = binaryRegInfoMap.get(binaryName);
boolean addOssComponentFlag = false;
for(BinaryData binaryInfo : binaryInfoList) {
if(!isEmpty(binaryInfo.getOssName())) {
Map<String, OssMaster> ossInfo = CoCodeManager.OSS_INFO_UPPER;
String key = binaryInfo.getOssName() + "_" + avoidNull(binaryInfo.getOssVersion());
String _binaryLicenseStr = binaryInfo.getLicense();
// binary db์ ํ์ดํ์ผ๋ก ๋ฑ๋ก๋ case๋ก ๊ณ ๋ คํด์ผํจ
//if(ossInfo.containsKey(key.toUpperCase()) || "-".equals(binaryInfo.getOssName()) ) {
// oss name + version ์ด ์ผ์นํ๋ oss ๊ฐ ์กด์ฌํ๋ฉด, update ํ๋ค.
OssMaster ossBean = ossInfo.get(key.toUpperCase());
boolean isEmptyOss = (ossBean == null || "-".equals(binaryInfo.getOssName()));
// update๋ฅผ ์ํด
// ossmaster => projectIdentification ์ผ๋ก ๋ณํ
ProjectIdentification updateBean = new ProjectIdentification();
if(ossBean != null) {
if(!isEmptyOss) {
updateBean.setOssId(ossBean.getOssId());
}
updateBean.setOssName(isEmptyOss ? "-" : ossBean.getOssNameTemp()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(isEmptyOss ? avoidNull(binaryInfo.getOssVersion()) : ossBean.getOssVersion());
updateBean.setDownloadLocation(isEmptyOss ? "" : ossBean.getDownloadLocation());
updateBean.setHomepage(isEmptyOss ? "" : ossBean.getHomepage());
updateBean.setCopyrightText(isEmptyOss ? "" : ossBean.getCopyright());
} else {
updateBean.setOssId(null);
updateBean.setOssName(binaryInfo.getOssName()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(avoidNull(binaryInfo.getOssVersion()));
updateBean.setDownloadLocation(null);
updateBean.setHomepage(null);
updateBean.setCopyrightText(null);
}
// ๊ธฐ์กด๊ฐ ์ ์ง
updateBean.setFilePath(bean.getFilePath());
updateBean.setExcludeYn(bean.getExcludeYn());
updateBean.setBinaryName(bean.getBinaryName());
updateBean.setBinaryNotice(bean.getBinaryNotice());
updateBean.setCustomBinaryYn(bean.getCustomBinaryYn());
// ํ๋์ binary์ ๋ํด์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ์ ์ฉ๋ ๊ฒฝ์ฐ, ์ต์ด ํ๋ฒ๋ง ์
๋ฐ์ดํธํ๊ณ ์ดํ๋ถํฐ๋ ์ ๊ท ๋ฑ๋กํ๋ค.
if(addOssComponentFlag) {
updateBean.setReferenceId(bean.getReferenceId());
updateBean.setReferenceDiv(bean.getReferenceDiv());
partnerMapper.insertBinaryOssComponents(updateBean);
componentId = updateBean.getComponentId();
} else {
updateBean.setComponentId(componentId);
partnerMapper.updateOssList(updateBean);
addOssComponentFlag = true;
// ๊ธฐ์กด license ์ญ์
partnerMapper.deleteOssComponentsLicense(bean);
}
List<String> selectedLicenseIdList = new ArrayList<>();
if(!isEmpty(_binaryLicenseStr)) {
for(String _licenseName : _binaryLicenseStr.split(",")) {
if(isEmpty(_licenseName)) {
continue;
}
_licenseName = _licenseName.trim();
String _licenseId = CommonFunction.getLicenseIdByName(_licenseName);
if(!isEmpty(_licenseId)) {
selectedLicenseIdList.add(_licenseId);
}
}
}
List<OssComponentsLicense> updateLicenseList = new ArrayList<>();
//List<ProjectIdentification> updateLicenseDefaultList = new ArrayList<>();
// oss name์ด ํ์ดํ์ด ์๋๋ผ๋ฉด, OSS List์ ๋ฑ๋ก๋ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ทจํฉ
if(!isEmptyOss) {
boolean hasSelectedLicense = false;
for(OssLicense license : ossBean.getOssLicenses()) {
OssComponentsLicense componentLicense = new OssComponentsLicense();
componentLicense.setComponentId(componentId);
componentLicense.setLicenseId(license.getLicenseId());
componentLicense.setLicenseName(license.getLicenseName());
// license text ์ค์ ์ ๋ถํ์ํจ
if(selectedLicenseIdList.contains(componentLicense.getLicenseId())) {
hasSelectedLicense = true;
componentLicense.setExcludeYn(CoConstDef.FLAG_NO);
}
updateLicenseList.add(componentLicense);
}
for(OssComponentsLicense license : updateLicenseList) {
if(hasSelectedLicense) {
license.setExcludeYn(avoidNull(license.getExcludeYn(), CoConstDef.FLAG_YES));
} else {
license.setExcludeYn(CoConstDef.FLAG_NO);
}
partnerMapper.insertOssComponentsLicense(license);
}
}
// oss name์ด ํ์ดํ์ด๋ผ๋ฉด ๋ผ์ด์ ์ค binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ license๊ฐ ๋ณต์๊ฐ๋ก ๋ฑ๋ก๋์ด ์์ ์ ์์
else {
OssComponentsLicense license = new OssComponentsLicense();
license.setExcludeYn(CoConstDef.FLAG_NO);
license.setComponentId(componentId);
// binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๊ฐ license master์ ๋ฑ๋ก๋์ด ์๋ค๋ฉด master ์ ๋ณด๋ฅผ ์ฌ์ฉ
if(!isEmpty(_binaryLicenseStr) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(_binaryLicenseStr.toUpperCase().trim())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_binaryLicenseStr.toUpperCase().trim());
license.setLicenseId(licenseMaster.getLicenseId());
license.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseName()));
}
// ๋ฑ๋ก๋์ด ์์ง ์๋ค๋ฉด, license name๋ง ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฌ์คํญ ์กด์ฌํ ์ ์์
else {
license.setLicenseName(avoidNull(_binaryLicenseStr));
}
partnerMapper.insertOssComponentsLicense(license);
}
//}
}
}
}
}
@Transactional
public void autoIdentificationWithAndroidResultTextFile(Project project) {
if(!isEmpty(project.getSrcAndroidResultFileId())) {
// oss name๊ณผ license๊ฐ ์ค์ ๋์ง ์์ oss coponent๋ฅผ ์ฐพ๋๋ค.
// component_id์ binary name๋ง ๋ฐํํ๋ค.
//List<OssComponents> componentList = projectMapper.findBinAutoIdentificationWithBinaryText(project.getPrjId());
List<OssComponents> componentList = projectMapper.findBinAutoIdentificationWithResultText(project.getPrjId());
if(componentList != null && !componentList.isEmpty()) {
// ๋ฏธ์ค์ ๋์์ด ์๋ ๊ฒฝ์ฐ ์
๋ก๋ ํ์ผ์์ ๋์ผํ binary๋ฅผ ์ฐพ๋๋ค.
// DB์์ binary๋ก ๋งคํ๋๋ ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
//Map<String, String[]> mappingData = loadBinaryText(project.getBinBinaryFileId());
T2File binaryTextFile = fileService.selectFileInfoById(project.getSrcAndroidResultFileId());
if(binaryTextFile != null) {
Map<String, Object> readFileData = CommonFunction.getAndroidResultFileInfo(binaryTextFile, new ArrayList<String>());
if(readFileData != null && readFileData.containsKey("addCheckList")) {
@SuppressWarnings("unchecked")
List<OssComponents> binaryList = (List<OssComponents>) readFileData.get("addCheckList");
Map<String, String[]> mappingData = new HashMap<>(); // 1:checksum, 2:tlsh
if(binaryList != null && !binaryList.isEmpty()) {
for(OssComponents _tmpBean : binaryList) {
if(!isEmpty(_tmpBean.getCheckSum()) && !isEmpty(_tmpBean.getBinaryName()) && !isEmpty(_tmpBean.getTlsh())) {
String _binaryName = _tmpBean.getBinaryName();
if(_binaryName.indexOf("/") > -1) {
_binaryName = _binaryName.substring(_binaryName.lastIndexOf("/") + 1);
}
if(isEmpty(_binaryName)) {
continue;
}
mappingData.put(_binaryName, new String[]{_tmpBean.getCheckSum(), _tmpBean.getTlsh()});
}
}
}
if(!mappingData.isEmpty()) {
Map<String, List<BinaryData>> binaryRegInfoMap = new HashMap<>();
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(isEmpty(binaryName)) {
continue;
}
// ์ฌ์ฉ์๊ฐ ์
๋ ฅํ oss๊ฐ ์์ผ๋ฉด ์ค์ ํ์ง ์์
if(!isEmpty(bean.getOssName())) {
continue;
}
// ์
๋ก๋ํ binaryํ์ผ๊ณผ grid์ ๋ฑ๋กํ binaryname์ด ๋์ผํ data์ธ ๊ฒฝ์ฐ, bat DB์์ oss ์ ๋ณด๋ฅผ ์ฐพ๋๋ค.
if(mappingData.containsKey(binaryName)) {
String[] tlshData = mappingData.get(binaryName);
List<BinaryData> binaryInfoList = autoIDService.findOssInfoWithBinaryName(binaryName, tlshData[0], tlshData[1]);
if(binaryInfoList != null) {
binaryRegInfoMap.put(binaryName, binaryInfoList);
}
}
}
// 2019.04.03 ryan.yun binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์๊ฐ์ด ์ค๋๊ฑธ๋ฆด ์ ์๊ธฐ ๋๋ฌธ์ ํ๋์ ์
์ด์๋ฅผ ์ต์ํ ํ๊ธฐ ์ํด ์ผ๋จ binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์ฒ๋ฆฌ๋ง ๋จผ์ ์ํํ๊ณ ํธ๋์ ์
์ ๋ถ๋ฆฌํ์ฌ ๋ฑ๋ก ํ๋ค.
addOssComponentByBinaryInfoAndroid(componentList, binaryRegInfoMap);
}
}
}
}
}
}
@Transactional
private void addOssComponentByBinaryInfoAndroid(List<OssComponents> componentList,
Map<String, List<BinaryData>> binaryRegInfoMap) {
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(isEmpty(binaryName)) {
continue;
}
// ์ฌ์ฉ์๊ฐ ์
๋ ฅํ oss๊ฐ ์์ผ๋ฉด ์ค์ ํ์ง ์์
if(!isEmpty(bean.getOssName())) {
continue;
}
if(!binaryRegInfoMap.containsKey(binaryName)) {
continue;
}
List<BinaryData> binaryInfoList = binaryRegInfoMap.get(binaryName);
boolean addOssComponentFlag = false;
for(BinaryData binaryInfo : binaryInfoList) {
if(!isEmpty(binaryInfo.getOssName())) {
Map<String, OssMaster> ossInfo = CoCodeManager.OSS_INFO_UPPER;
String key = binaryInfo.getOssName() + "_" + avoidNull(binaryInfo.getOssVersion());
String _binaryLicenseStr = binaryInfo.getLicense();
if("-".equals(binaryInfo.getOssName()) || ossInfo.containsKey(key.toUpperCase())) {
// oss name + version ์ด ์ผ์นํ๋ oss ๊ฐ ์กด์ฌํ๋ฉด, update ํ๋ค.
boolean isEmptyOss = "-".equals(binaryInfo.getOssName());
OssMaster ossBean = ossInfo.get(key.toUpperCase());
// update๋ฅผ ์ํด
// ossmaster => projectIdentification ์ผ๋ก ๋ณํ
ProjectIdentification updateBean = new ProjectIdentification();
if(!isEmptyOss) {
updateBean.setOssId(ossBean.getOssId());
}
updateBean.setOssName(isEmptyOss ? "-" : ossBean.getOssNameTemp()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(isEmptyOss ? avoidNull(binaryInfo.getOssVersion()) : ossBean.getOssVersion());
updateBean.setDownloadLocation(isEmptyOss ? "" : ossBean.getDownloadLocation());
updateBean.setHomepage(isEmptyOss ? "" : ossBean.getHomepage());
updateBean.setCopyrightText(isEmptyOss ? "" : ossBean.getCopyright());
// ๊ธฐ์กด๊ฐ ์ ์ง
updateBean.setFilePath(bean.getFilePath());
updateBean.setExcludeYn(bean.getExcludeYn());
updateBean.setBinaryName(bean.getBinaryName());
updateBean.setBinaryNotice(bean.getBinaryNotice());
updateBean.setCustomBinaryYn(bean.getCustomBinaryYn());
// ํ๋์ binary์ ๋ํด์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ์ ์ฉ๋ ๊ฒฝ์ฐ, ์ต์ด ํ๋ฒ๋ง ์
๋ฐ์ดํธํ๊ณ ์ดํ๋ถํฐ๋ ์ ๊ท ๋ฑ๋กํ๋ค.
if(addOssComponentFlag) {
updateBean.setReferenceId(bean.getReferenceId());
updateBean.setReferenceDiv(bean.getReferenceDiv());
projectMapper.insertOssComponents(updateBean);
} else {
updateBean.setComponentId(bean.getComponentId());
projectMapper.updateSrcOssList(updateBean);
addOssComponentFlag = true;
// ๊ธฐ์กด license ์ญ์
projectMapper.deleteOssComponentsLicense(bean);
}
List<String> selectedLicenseIdList = new ArrayList<>();
if(!isEmpty(_binaryLicenseStr)) {
for(String _licenseName : _binaryLicenseStr.split(",")) {
if(isEmpty(_licenseName)) {
continue;
}
_licenseName = _licenseName.trim();
String _licenseId = CommonFunction.getLicenseIdByName(_licenseName);
if(!isEmpty(_licenseId)) {
selectedLicenseIdList.add(_licenseId);
}
}
}
List<OssComponentsLicense> updateLicenseList = new ArrayList<>();
//List<ProjectIdentification> updateLicenseDefaultList = new ArrayList<>();
// oss name์ด ํ์ดํ์ด ์๋๋ผ๋ฉด, OSS List์ ๋ฑ๋ก๋ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ทจํฉ
if(!isEmptyOss) {
boolean hasSelectedLicense = false;
for(OssLicense license : ossBean.getOssLicenses()) {
OssComponentsLicense componentLicense = new OssComponentsLicense();
componentLicense.setComponentId(bean.getComponentId());
componentLicense.setLicenseId(license.getLicenseId());
componentLicense.setLicenseName(license.getLicenseName());
// license text ์ค์ ์ ๋ถํ์ํจ
if(selectedLicenseIdList.contains(componentLicense.getLicenseId())) {
hasSelectedLicense = true;
componentLicense.setExcludeYn(CoConstDef.FLAG_NO);
}
updateLicenseList.add(componentLicense);
}
for(OssComponentsLicense license : updateLicenseList) {
if(hasSelectedLicense) {
license.setExcludeYn(avoidNull(license.getExcludeYn(), CoConstDef.FLAG_YES));
} else {
license.setExcludeYn(CoConstDef.FLAG_NO);
}
projectMapper.insertOssComponentsLicense(license);
}
}
// oss name์ด ํ์ดํ์ด๋ผ๋ฉด ๋ผ์ด์ ์ค binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ license๊ฐ ๋ณต์๊ฐ๋ก ๋ฑ๋ก๋์ด ์์ ์ ์์
else {
OssComponentsLicense license = new OssComponentsLicense();
license.setExcludeYn(CoConstDef.FLAG_NO);
license.setComponentId(addOssComponentFlag ? updateBean.getComponentId() : bean.getComponentId());
// binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๊ฐ license master์ ๋ฑ๋ก๋์ด ์๋ค๋ฉด master ์ ๋ณด๋ฅผ ์ฌ์ฉ
if(!isEmpty(_binaryLicenseStr) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(_binaryLicenseStr.toUpperCase().trim())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_binaryLicenseStr.toUpperCase().trim());
license.setLicenseId(licenseMaster.getLicenseId());
license.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseName()));
}
// ๋ฑ๋ก๋์ด ์์ง ์๋ค๋ฉด, license name๋ง ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฌ์คํญ ์กด์ฌํ ์ ์์
else {
license.setLicenseName(avoidNull(_binaryLicenseStr));
}
projectMapper.insertOssComponentsLicense(license);
}
}
}
}
}
}
public void autoIdentificationWithBinryTextFilePartner(PartnerMaster partner) {
// oss name๊ณผ license๊ฐ ์ค์ ๋์ง ์์ oss coponent๋ฅผ ์ฐพ๋๋ค.
// component_id์ binary name๋ง ๋ฐํํ๋ค.
List<OssComponents> componentList = partnerMapper.findBinAutoIdentificationWithBinaryText(partner.getPartnerId());
if(componentList != null && !componentList.isEmpty()) {
// ๋ฏธ์ค์ ๋์์ด ์๋ ๊ฒฝ์ฐ ์
๋ก๋ ํ์ผ์์ ๋์ผํ binary๋ฅผ ์ฐพ๋๋ค.
// DB์์ binary๋ก ๋งคํ๋๋ ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
Map<String, String[]> mappingData = loadBinaryText(fileService.selectFileInfo(partner.getBinaryFileId()).getFileId(), true);
if(mappingData != null && !mappingData.isEmpty()) {
Map<String, List<BinaryData>> binaryRegInfoMap = new HashMap<>();
for(OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
/*
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
*/
if(isEmpty(binaryName)) {
continue;
}
// ์
๋ก๋ํ binaryํ์ผ๊ณผ grid์ ๋ฑ๋กํ binaryname์ด ๋์ผํ data์ธ ๊ฒฝ์ฐ, bat DB์์ oss ์ ๋ณด๋ฅผ ์ฐพ๋๋ค.
String checkBinaryName = "";
String[] tlshData = null;
if(mappingData.containsKey(binaryName)) {
tlshData = mappingData.get(binaryName);
checkBinaryName = binaryName;
if(checkBinaryName.indexOf("/") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("/") + 1);
}
if(checkBinaryName.indexOf("\\") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("\\") + 1);
}
}
if(isEmpty(checkBinaryName) && ArrayUtils.isEmpty(tlshData)){
checkBinaryName = binaryName;
if(checkBinaryName.indexOf("/") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("/") + 1);
}
if(checkBinaryName.indexOf("\\") > -1) {
checkBinaryName = checkBinaryName.substring(checkBinaryName.lastIndexOf("\\") + 1);
}
if(mappingData.containsKey(checkBinaryName)) {
tlshData = mappingData.get(checkBinaryName);
}
}
if(!isEmpty(checkBinaryName) && !ArrayUtils.isEmpty(tlshData)){
List<BinaryData> binaryInfoList = autoIDService.findOssInfoWithBinaryName(checkBinaryName, tlshData[0], tlshData[1]);
if(binaryInfoList != null) {
binaryRegInfoMap.put(binaryName, binaryInfoList);
}
}
}
// binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์๊ฐ์ด ์ค๋๊ฑธ๋ฆด ์ ์๊ธฐ ๋๋ฌธ์ ํ๋์ ์
์ด์๋ฅผ ์ต์ํ ํ๊ธฐ ์ํด ์ผ๋จ binary ์ ๋ณด๋ฅผ ์ฐพ๋ ์ฒ๋ฆฌ๋ง ๋จผ์ ์ํํ๊ณ ํธ๋์ ์
์ ๋ถ๋ฆฌํ์ฌ ๋ฑ๋ก ํ๋ค.
addOssComponentByBinaryInfoPartner(componentList, binaryRegInfoMap);
}
}
}
public Map<String, List<BinaryData>> getBinaryListFromBinaryDB(boolean isAndroid, Project projectInfo) {
Map<String, List<BinaryData>> listMap = new HashMap<>();
if(projectInfo != null ) {
if(isAndroid) {
if(!isEmpty(projectInfo.getSrcAndroidResultFileId())) {
T2File binaryTextFile = fileService.selectFileInfoById(projectInfo.getSrcAndroidResultFileId());
if(binaryTextFile != null) {
Map<String, Object> readFileData = CommonFunction.getAndroidResultFileInfo(binaryTextFile, new ArrayList<String>());
if(readFileData != null && readFileData.containsKey("addCheckList")) {
Map<String, String[]> checksumInfoMap = new HashMap<>();
List<OssComponents> _loadlist = (List<OssComponents>) readFileData.get("addCheckList");
for(OssComponents bean : _loadlist) {
// binary name์ key๋ก sha256sum๊ณผ tlsh ๋ฅผ ๊ฒฉ๋ฉํ๋ค.
if(isEmpty(bean.getBinaryName()) || isEmpty(bean.getCheckSum()) || isEmpty(bean.getTlsh())) {
continue;
}
String binaryName = bean.getBinaryName();
if(binaryName.endsWith("/") || binaryName.endsWith("\\")) {
continue;
}
if(isEmpty(binaryName)) {
continue;
}
checksumInfoMap.put(bean.getBinaryName(), new String[]{bean.getCheckSum(), bean.getTlsh(), avoidNull(bean.getSourceCodePath())});
}
try {
for(String binaryname : checksumInfoMap.keySet()) {
String[] datas = checksumInfoMap.get(binaryname);
List<BinaryData> _list = autoIDService.findOssInfoWithBinaryName(binaryname, datas[0], datas[1]);
if(listMap.containsKey(binaryname) && _list != null) {
List<BinaryData> resultList = listMap.get(binaryname);
if(resultList != null){
resultList.addAll(_list);
listMap.put(binaryname, resultList);
}
} else {
listMap.put(binaryname, _list);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
} else {
if(!isEmpty(projectInfo.getBinBinaryFileId())) {
T2File binaryTextFile = fileService.selectFileInfoById(projectInfo.getBinBinaryFileId());
Map<String, String[]> loadDataMap = loadBinaryText(binaryTextFile, true);
if(loadDataMap != null && !loadDataMap.isEmpty()) {
try {
for(String binaryname : loadDataMap.keySet()) {
String[] datas = loadDataMap.get(binaryname);
List<BinaryData> _list = autoIDService.findOssInfoWithBinaryName(binaryname, datas[0], datas[1]);
if(listMap.containsKey(binaryname) && _list != null) {
List<BinaryData> resultList = listMap.get(binaryname);
if(resultList != null){
resultList.addAll(_list);
listMap.put(binaryname, resultList);
}
} else {
listMap.put(binaryname, _list);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
}
return listMap;
}
private static Map<String, String[]> loadBinaryText(T2File binaryTextFile, boolean pathFlag) {
Map<String, String[]> loadData = new HashMap<>();
if(binaryTextFile != null && binaryTextFile.getExt().equals("txt")) {
log.info("loadBinaryText : " + binaryTextFile.getLogiNm());
String _contents = avoidNull(CommonFunction.getStringFromFile(binaryTextFile.getLogiPath() + "/" + binaryTextFile.getLogiNm()));
if(!isEmpty(_contents)) {
boolean isHeader = true;
int idx_checkSum = -1;
int idx_tlsh = -1;
int idx_binaryName = -1;
for(String line : _contents.split(System.lineSeparator())) {
if(isHeader) {
String[] hdata = line.split("\t", -1);
// header ์ ๋ณด๊ฐ ์์ ๊ฒฝ์ฐ ์ฒ๋ฆฌ ์ค๋จ
if(hdata == null || isEmpty(line)) {
log.warn("Header row is empty :" + binaryTextFile.getLogiNm());
break;
}
int idx = 0;
for(String s : hdata) {
if(idx_binaryName < 0 && (s.trim().equalsIgnoreCase("Binary Name") || s.trim().equalsIgnoreCase("Binary"))) {
idx_binaryName = idx;
} else if(idx_checkSum < 0 && (s.trim().equalsIgnoreCase("checksum") || s.trim().equalsIgnoreCase("sha1sum"))) {
idx_checkSum = idx;
} else if(idx_tlsh < 0 && (s.trim().equalsIgnoreCase("tlsh"))) {
idx_tlsh = idx;
}
idx ++;
}
isHeader = false;
continue;
}
String binaryName, checkSum, tlsh;
String[] data = line.split("\t", -1);
if(idx_binaryName > -1 && idx_checkSum > -1 && idx_tlsh > -1) {
if(data == null) {
log.warn("unexpected format Bin binary text : " + line);
continue;
} else if(data.length < idx_binaryName + 1) {
log.warn("unexpected format Bin binary text (idx_binaryName index): " + line);
continue;
} else if(data.length < idx_checkSum + 1) {
log.warn("unexpected format Bin binary text (idx_checkSum index): " + line);
continue;
} else if(data.length < idx_tlsh + 1) {
log.warn("unexpected format Bin binary text (idx_tlsh index): " + line);
continue;
}
binaryName = data[idx_binaryName].trim();
checkSum = data[idx_checkSum].trim();
tlsh = data[idx_tlsh].trim();
// tils๊ฐ ์ถ์ถ๋์ง ์์ ๊ฒฝ์ฐ ๊ณต๋ฐฑ
if(isEmpty(binaryName) || isEmpty(checkSum)) {
log.warn("unexpected format Bin binary text : " + line);
continue;
}
} else {
// binary name์ key๋ก sha256sum๊ณผ tlsh ๋ฅผ ๊ฒฉ๋ฉํ๋ค.
if(data == null || data.length !=3 || isEmpty(data[0]) || isEmpty(data[1])) {
log.warn("unexpected format Bin binary text : " + line);
continue;
}
binaryName = data[0].trim();
if(binaryName.endsWith("/") || binaryName.endsWith("\\")) {
log.warn("unexpected format Bin binary text (is not file) : " + line);
continue;
}
checkSum = data[1].trim();
tlsh = data[2].trim();
}
if(!pathFlag){
if(binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if(binaryName.indexOf("\\") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("\\") + 1);
}
}
if(isEmpty(binaryName)) {
continue;
}
loadData.put(binaryName, new String[]{checkSum, avoidNull(tlsh, "0")});
}
}
}
return loadData;
}
}
| 61,808 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiFileService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiFileService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
import oss.fosslight.domain.UploadFile;
public interface ApiFileService {
public UploadFile uploadFile(MultipartFile uploadFile);
public UploadFile uploadFile(MultipartFile uploadFile, String filePath);
public UploadFile uploadFile(MultipartFile uploadFile, String filePath, String fileId);
public Map<String, UploadFile> uploadNoticeXMLFile(MultipartFile uploadFile, String prjId);
}
| 623 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiPartnerService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiPartnerService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
@Service
public interface ApiPartnerService {
Map<String, Object> getPartnerMasterList(Map<String, Object> paramMap);
boolean existPartnertCnt(Map<String, Object> paramMap);
boolean existLdapUserToEmail(String email);
boolean existsWatcherByEmail(String partnerId, String email);
void insertWatcher(Map<String, Object> paramMap);
}
| 556 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SystemConfigurationService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/SystemConfigurationService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
public interface SystemConfigurationService {
public Map<String, Object> saveConfiguration(Map<String, Object> configrationMap) throws Exception;
}
| 297 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
StatisticsService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/StatisticsService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import oss.fosslight.config.HistoryConfig;
import oss.fosslight.domain.Statistics;
public interface StatisticsService extends HistoryConfig{
public Map<String, Object> getDivisionalProjectChartData(Statistics statistics);
public Map<String, Object> getMostUsedChartData(Statistics statistics);
public Map<String, Object> getUpdatedOssChartData(Statistics statistics);
public Map<String, Object> getUpdatedLicenseChartData(Statistics statistics);
public Map<String, Object> getTrdPartyRelatedChartData(Statistics statistics);
public Map<String, Object> getUserRelatedChartData(Statistics statistics);
}
| 792 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CommentService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/CommentService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
import oss.fosslight.domain.CommentsHistory;
public interface CommentService{
public CommentsHistory registComment(CommentsHistory commentsHistory);
public CommentsHistory registComment(CommentsHistory commentsHistory, boolean deleteUserComment);
public List<CommentsHistory> getCommentList(CommentsHistory commentHistory);
public int deleteComment(CommentsHistory commentsHistory);
public String getUserComment(CommentsHistory comHisBean);
public List<CommentsHistory> getCommentListHis(CommentsHistory commentsHistory);
public int updateComment(CommentsHistory bean);
public int updateComment(CommentsHistory bean, boolean emailSendFlag);
public List<CommentsHistory> getMoreCommentListHis(CommentsHistory commentsHistory);
public int getCommentListHisCnt(CommentsHistory bean);
public Map<String, Object> getCommnetInfo(String commId);
} | 1,072 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiOssService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiOssService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
public interface ApiOssService {
public List<Map<String, Object>> getOssInfo(Map<String, Object> paramMap);
public List<Map<String, Object>> getOssInfoByDownloadLocation(String downloadLocation);
public List<Map<String, Object>> getLicenseInfo(String licenseName);
String[] getOssNickNameListByOssName(String ossName);
}
| 550 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryDataHistoryService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/BinaryDataHistoryService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import oss.fosslight.domain.BinaryAnalysisResult;
public interface BinaryDataHistoryService {
Map<String, Object> getBinaryDataHistoryList(BinaryAnalysisResult bean);
}
| 333 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiProjectService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiProjectService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.UploadFile;
@Service
public interface ApiProjectService {
public Map<String, Object> selectProjectList(Map<String, Object> paramMap);
public boolean existProjectCnt(Map<String, Object> paramMap);
public Map<String, Object> getSheetData(UploadFile ufile, String prjId, String readType, String[] sheet);
public Map<String, Object> getSheetData(UploadFile ufile, String prjId, String readType, String[] sheet, boolean exactMatchFlag);
public Map<String, Object> readAndroidBuildImage(UploadFile ossReportBean, UploadFile noticeHtmlBean, UploadFile resultTxtBean);
public Map<String, Object> selectVerificationCheck(String prjId);
public boolean updatePackageFile(Map<String, Object> paramMap);
public int getCreateProjectCnt(String prjId);
Map<String, Object> createProject(Map<String, Object> paramMap);
public int makeOssNotice(Map<String, Object> paramMap);
public List<Map<String, Object>> getBomList(String prjId);
public List<Map<String, Object>> setMergeGridData(List<Map<String, Object>> list);
public Map<String, Object> getBomExportJson(String prjId);
public Map<String, Object> getBomCompare(List<Map<String, Object>> beforeBomList, List<Map<String, Object>> afterBomList);
public boolean checkDistributionType(Map<String, Object> paramMap);
public Map<String, Object> selectModelList(Map<String, Object> paramMap);
public List<Map<String, Object>> getVerifyOssList(Map<String, Object> project);
public List<Map<String, Object>> serMergeGridData(List<Map<String, Object>> list);
public String setClearFiles(Map<String, Object> map);
public boolean getChangedPackageFile(String prjId, List<String> fileSeqs);
public Map<String, Object> processVerification(Map<String, Object> map, Map<String, Object> file, Map<String, Object> project);
public void updateVerifyFileCount(ArrayList<String> arrayList);
public void updateVerifyFileCount(HashMap<String, Object> hashMap);
public List<String> getPackageFileList(String prjId);
public void registBom(String prjId, String string);
public int existProjectCntBomCompare(Map<String, Object> paramMap);
public boolean existLdapUserToEmail(String email);
public boolean existsWatcherByEmail(String prjId, String email);
public void insertWatcher(Map<String, Object> paramMap);
public Map<String, Object> selectProjectMaster(String prjId);
public void getIdentificationGridList(String prjId, String code, List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentsLicenseList, List<Map<String, Object>> gridDataList);
public void registDepOss(List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentsLicenseList, Project project, String refDiv);
public void updateSubStatus(Map<String, Object> param);
public Map<String, Object> getProjectBasicInfo(String prjId);
public Map<String, Object> getProcessSheetData(Map<String, Object> result, String prjId, String resetFlag, String registFileId, String userId, String comment, String tabGubn, String sheetName, boolean sheetNamesEmptyFlag, boolean loopFlag, int sheetIdx);
}
| 3,509 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProcessGuideService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ProcessGuideService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.Map;
import oss.fosslight.domain.ProcessGuide;
public interface ProcessGuideService {
Map<String, Object> getProcessGuideList(ProcessGuide vo) throws Exception;
public void setProcessGuide(ProcessGuide vo) throws Exception;
Map<String, Object> getProcessGuide(ProcessGuide vo) throws Exception;
}
| 466 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiCodeService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiCodeService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
public interface ApiCodeService {
public List<Map<String, Object>> getCodeList(String codeType, String detailValue);
}
| 291 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiSelfCheckService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/ApiSelfCheckService.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import oss.fosslight.domain.ProjectIdentification;
@Service
public interface ApiSelfCheckService {
int getCreateProjectCnt(String userId);
Map<String, Object> createSelfCheck(Map<String, Object> paramMap);
boolean existProjectCnt(Map<String, Object> paramMap);
Map<String, Object> selectProjectMaster(String prjId);
void getIdentificationGridList(String prjId, String code, List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentsLicenseList);
boolean existsWatcherByEmail(String prjId, String email);
void insertWatcher(Map<String, Object> paramMap);
}
| 826 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
AutoFillOssInfoService.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/AutoFillOssInfoService.java | /*
* Copyright (c) 2021 Dongmin Kang
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service;
import java.util.List;
import java.util.Map;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.ProjectIdentification;
import reactor.core.publisher.Mono;
import reactor.core.publisher.ParallelFlux;
public interface AutoFillOssInfoService {
List<ProjectIdentification> checkOssLicenseData(List<ProjectIdentification> componentData, Map<String, String> validMap, Map<String, String> diffMap);
Map<String, Object> checkOssLicense(List<ProjectIdentification> list);
Map<String, Object> saveOssCheckLicense(ProjectIdentification paramBean, String targetName);
ParallelFlux<Object> getGithubLicenses(List<String> locations);
Mono<Object> requestGithubLicense(String location);
ParallelFlux<Object> getClearlyDefinedLicenses(List<String> locations);
Mono<Object> requestClearlyDefinedLicense(String location);
} | 950 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
StatisticsServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/StatisticsServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.History;
import oss.fosslight.domain.Statistics;
import oss.fosslight.repository.StatisticsMapper;
import oss.fosslight.service.StatisticsService;
import oss.fosslight.util.DateUtil;
@Service
public class StatisticsServiceImpl extends CoTopComponent implements StatisticsService{
// Mapper
@Autowired StatisticsMapper statisticsMapper;
final String[] colorArray = new String[] {"#70ad47", "#ed7d31", "#a5a5a5", "#ffc000", "#5b9bd5", "#5bd597", "#d55bab", "#6f5bd5"};
@Override
public History work(Object param) {
return null;
}
@Override
public Map<String, Object> getDivisionalProjectChartData(Statistics statistics) {
Map<String, Object> result = new HashMap<String, Object>();
Statistics chartData = new Statistics();
chartData.setColorArray(colorArray);
List<Statistics> titleList = new ArrayList<Statistics>();
List<String> titleArray = new ArrayList<String>();
if (!"NET".equals(statistics.getCategoryType())) {
titleList = statisticsMapper.getChartTitle(statistics);
}
if ("REV".equals(statistics.getCategoryType())) {
titleArray.add("unassigned");
statistics.setNoneUser(statisticsMapper.getNoneUser());
}
for (Statistics title : titleList) {
titleArray.add(title.getTitleNm());
}
if ("NET".equals(statistics.getCategoryType())) {
titleArray.add("Network Service");
titleArray.add("Others");
}
titleArray = titleArray.stream().distinct().collect(Collectors.toList());
if ("REV".equals(statistics.getCategoryType())) {
statistics.setCategorySize(titleArray.size());
}
statistics.setTitleArray(titleArray); // Chart Title
List<Statistics> list = statisticsMapper.getDivisionalProjectChartData(statistics);
if ("REV".equals(statistics.getCategoryType())) {
// Reviewer None Statistic Sum Check
if (noneCheck(titleArray, list) > 0) {
titleArray.add("NONE");
}
}
if (CoConstDef.FLAG_YES.equals(statistics.getIsRawData())) {
for (Statistics stat : list) {
stat.setTotal();
}
titleArray.add("Total");
result.put("chartData", list);
result.put("titleArray", titleArray);
} else {
for (Statistics data : list) {
int categoryIdx = 0;
if (data.getCategory0Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory0Cnt(), categoryIdx++);
}
if (data.getCategory1Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory1Cnt(), categoryIdx++);
}
if (data.getCategory2Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory2Cnt(), categoryIdx++);
}
if (data.getCategory3Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory3Cnt(), categoryIdx++);
}
if (data.getCategory4Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory4Cnt(), categoryIdx++);
}
if (data.getCategory5Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory5Cnt(), categoryIdx++);
}
if (data.getCategory6Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory6Cnt(), categoryIdx++);
}
if (data.getCategory7Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory7Cnt(), categoryIdx++);
}
if (data.getCategory8Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory8Cnt(), categoryIdx++);
}
}
chartData.setTitleArray(titleArray); // Chart Title
result.put("chartData", chartData);
}
return result;
}
public Map<String, Object> getMostUsedChartData(Statistics statistics) {
Map<String, Object> result = new HashMap<String, Object>();
List<Statistics> list = statisticsMapper.getMostUsedChartData(statistics);
/*
if ("OSS".equals(statistics.getChartType())) {
list = statisticsMapper.getMostUsedOssChartData(statistics);
} else if ("LICENSE".equals(statistics.getChartType())) {
list = statisticsMapper.getMostUsedLicenseChartData(statistics);
}
*/
result.put("chartData", list);
return result;
}
public Map<String, Object> getUpdatedOssChartData(Statistics statistics){
Map<String, Object> result = new HashMap<String, Object>();
Statistics chartData = new Statistics();
chartData.setColorArray(colorArray);
List<Statistics> titleList = statisticsMapper.getChartTitle(statistics);
List<String> titleArray = new ArrayList<String>();
for (Statistics title : titleList) {
titleArray.add(title.getTitleNm());
}
titleArray = titleArray.stream().distinct().collect(Collectors.toList());
statistics.setTitleArray(titleArray); // Chart Title
statistics.setDiffMonthCnt(DateUtil.getDiffMonth(statistics.getStartDate(), statistics.getEndDate()));
statistics.setNoneUser(statisticsMapper.getNoneUser());
statistics.setCategorySize(titleArray.size());
statistics.setUpdateType("ADD");
List<Statistics> list = statisticsMapper.getUpdatedOssChartData(statistics);
statistics.setUpdateType("MOD");
list.addAll(statisticsMapper.getUpdatedOssChartData(statistics));
list = list.stream().sorted(Comparator.comparing((Statistics s) -> s.getColumnName())).collect(Collectors.toList());
// Reviewer None Statistic Sum Check
if (noneCheck(titleArray, list) > 0) {
titleArray.add("NONE");
}
if (CoConstDef.FLAG_YES.equals(statistics.getIsRawData())) {
for (Statistics stat : list) {
stat.setTotal();
}
titleArray.add("Total");
result.put("chartData", list);
result.put("titleArray", titleArray);
} else {
for (Statistics data : list) {
int categoryIdx = 0;
chartData.addCategoryList(data.getColumnName());
if (data.getCategory0Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory0Cnt(), categoryIdx++);
}
if (data.getCategory1Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory1Cnt(), categoryIdx++);
}
if (data.getCategory2Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory2Cnt(), categoryIdx++);
}
if (data.getCategory3Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory3Cnt(), categoryIdx++);
}
if (data.getCategory4Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory4Cnt(), categoryIdx++);
}
if (data.getCategory5Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory5Cnt(), categoryIdx++);
}
if (data.getCategory6Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory6Cnt(), categoryIdx++);
}
if (data.getCategory7Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory7Cnt(), categoryIdx++);
}
if (data.getCategory8Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory8Cnt(), categoryIdx++);
}
}
chartData.setTitleArray(titleArray); // Chart Title
result.put("chartData", chartData);
}
return result;
}
public Map<String, Object> getUpdatedLicenseChartData(Statistics statistics){
Map<String, Object> result = new HashMap<String, Object>();
Statistics chartData = new Statistics();
chartData.setColorArray(colorArray);
List<Statistics> titleList = statisticsMapper.getChartTitle(statistics);
List<String> titleArray = new ArrayList<String>();
for (Statistics title : titleList) {
titleArray.add(title.getTitleNm());
}
titleArray = titleArray.stream().distinct().collect(Collectors.toList());
statistics.setTitleArray(titleArray); // Chart Title
statistics.setDiffMonthCnt(DateUtil.getDiffMonth(statistics.getStartDate(), statistics.getEndDate()));
statistics.setNoneUser(statisticsMapper.getNoneUser());
statistics.setCategorySize(titleArray.size());
statistics.setUpdateType("ADD");
List<Statistics> list = statisticsMapper.getUpdatedLicenseChartData(statistics);
statistics.setUpdateType("MOD");
list.addAll(statisticsMapper.getUpdatedLicenseChartData(statistics));
list = list.stream().sorted(Comparator.comparing((Statistics s) -> s.getColumnName())).collect(Collectors.toList());
// Reviewer None Statistic Sum Check
if (noneCheck(titleArray, list) > 0) {
titleArray.add("NONE");
}
if (CoConstDef.FLAG_YES.equals(statistics.getIsRawData())) {
for (Statistics stat : list) {
stat.setTotal();
}
titleArray.add("Total");
result.put("chartData", list);
result.put("titleArray", titleArray);
} else {
for (Statistics data : list) {
int categoryIdx = 0;
chartData.addCategoryList(data.getColumnName());
if (data.getCategory0Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory0Cnt(), categoryIdx++);
}
if (data.getCategory1Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory1Cnt(), categoryIdx++);
}
if (data.getCategory2Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory2Cnt(), categoryIdx++);
}
if (data.getCategory3Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory3Cnt(), categoryIdx++);
}
if (data.getCategory4Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory4Cnt(), categoryIdx++);
}
if (data.getCategory5Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory5Cnt(), categoryIdx++);
}
if (data.getCategory6Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory6Cnt(), categoryIdx++);
}
if (data.getCategory7Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory7Cnt(), categoryIdx++);
}
if (data.getCategory8Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory8Cnt(), categoryIdx++);
}
}
chartData.setTitleArray(titleArray); // Chart Title
result.put("chartData", chartData);
}
return result;
}
public Map<String, Object> getTrdPartyRelatedChartData(Statistics statistics){
Map<String, Object> result = new HashMap<String, Object>();
Statistics chartData = new Statistics();
chartData.setColorArray(colorArray);
List<Statistics> titleList = statisticsMapper.getChartTitle(statistics);
List<String> titleArray = new ArrayList<String>();
if ("REV".equals(statistics.getCategoryType())) {
titleArray.add("unassigned");
statistics.setNoneUser(statisticsMapper.getNoneUser());
}
for (Statistics title : titleList) {
titleArray.add(title.getTitleNm());
}
titleArray = titleArray.stream().distinct().collect(Collectors.toList());
statistics.setTitleArray(titleArray); // Chart Title
statistics.setCategorySize(titleArray.size());
List<Statistics> list = statisticsMapper.getTrdPartyRelatedChartData(statistics);
if ("REV".equals(statistics.getCategoryType())) {
// Reviewer None Statistic Sum Check
if (noneCheck(titleArray, list) > 0) {
titleArray.add("NONE");
}
}
if (CoConstDef.FLAG_YES.equals(statistics.getIsRawData())) {
for (Statistics stat : list) {
stat.setTotal();
}
titleArray.add("Total");
result.put("chartData", list);
result.put("titleArray", titleArray);
} else {
for (Statistics data : list) {
int categoryIdx = 0;
if (data.getCategory0Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory0Cnt(), categoryIdx++);
}
if (data.getCategory1Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory1Cnt(), categoryIdx++);
}
if (data.getCategory2Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory2Cnt(), categoryIdx++);
}
if (data.getCategory3Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory3Cnt(), categoryIdx++);
}
if (data.getCategory4Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory4Cnt(), categoryIdx++);
}
if (data.getCategory5Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory5Cnt(), categoryIdx++);
}
if (data.getCategory6Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory6Cnt(), categoryIdx++);
}
if (data.getCategory7Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory7Cnt(), categoryIdx++);
}
if (data.getCategory8Cnt() > -1) {
chartData.addCategoryCnt(data.getCategory8Cnt(), categoryIdx++);
}
}
chartData.setTitleArray(titleArray); // Chart Title
result.put("chartData", chartData);
}
return result;
}
public Map<String, Object> getUserRelatedChartData(Statistics statistics){
Map<String, Object> result = new HashMap<String, Object>();
Statistics chartData = new Statistics();
chartData.setColorArray(colorArray);
List<Statistics> list = statisticsMapper.getUserRelatedChartData(statistics);
List<String> titleList = new ArrayList<String>();
titleList.add("Total");
titleList.add("Activator");
if (CoConstDef.FLAG_YES.equals(statistics.getIsRawData())) {
for (Statistics stat : list) {
stat.setTotal();
}
titleList.add("Total");
result.put("chartData", list);
result.put("titleArray", titleList);
} else {
for (Statistics data : list) {
int categoryIdx = 0;
chartData.addCategoryCnt(data.getCategory0Cnt()-data.getCategory1Cnt(), categoryIdx++); // total Cnt = ๋ถ์์ - activator
chartData.addCategoryCnt(data.getCategory1Cnt(), categoryIdx++); // activator Cnt
}
chartData.setTitleArray(titleList); // Chart Title
result.put("chartData", chartData);
}
return result;
}
public int noneCheck(List<String> titleArray, List<Statistics> list) {
int noneSum = 0;
switch(titleArray.size()) {
case 1:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory1Cnt();
noneSum += cnt;
}
break;
case 2:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory2Cnt();
noneSum += cnt;
}
break;
case 3:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory3Cnt();
noneSum += cnt;
}
break;
case 4:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory4Cnt();
noneSum += cnt;
}
break;
case 5:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory5Cnt();
noneSum += cnt;
}
break;
case 6:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory6Cnt();
noneSum += cnt;
}
break;
case 7:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory7Cnt();
noneSum += cnt;
}
break;
case 8:
for (int i=0; i<list.size(); i++) {
int cnt = list.get(i).getCategory8Cnt();
noneSum += cnt;
}
break;
}
return noneSum;
}
}
| 15,382 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ConfigurationServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ConfigurationServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import oss.fosslight.domain.Configuration;
import oss.fosslight.domain.T2Users;
import oss.fosslight.repository.ConfigurationMapper;
import oss.fosslight.service.ConfigurationService;
import oss.fosslight.service.T2UserService;
@Service
public class ConfigurationServiceImpl implements ConfigurationService {
// Service
@Autowired T2UserService userService;
// Mapper
@Autowired ConfigurationMapper configurationMapper;
@Override
public void updateDefaultSetting(Configuration configuration) {
HashMap<String, Object> info = new HashMap<String, Object>();
configurationMapper.updateDefaultLocale(configuration);
configurationMapper.updateDefaultTab(configuration);
// Security session์ ์ถ๊ฐ ์ ๋ณด(Cusom)๋ฅผ ์ ์ฅํ๋ค(Mapํํ)
SecurityContext sec = SecurityContextHolder.getContext();
AbstractAuthenticationToken auth = (AbstractAuthenticationToken)sec.getAuthentication();
//User Detail
T2Users user = new T2Users();
user.setUserId(auth.getName());
T2Users getUser = userService.getUserAndAuthorities(user);
info.put("sessUserInfo", getUser);
auth.setDetails(info);
}
// @Override
// public void updateDefaultLocale(Configuration configuration) {
// HashMap<String, Object> info = new HashMap<String, Object>();
//
// configurationMapper.updateDefaultLocale(configuration);
//
// // Security session์ ์ถ๊ฐ ์ ๋ณด(Cusom)๋ฅผ ์ ์ฅํ๋ค(Mapํํ)
// SecurityContext sec = SecurityContextHolder.getContext();
// AbstractAuthenticationToken auth = (AbstractAuthenticationToken)sec.getAuthentication();
//
// //User Detail
// T2Users user = new T2Users();
// user.setUserId(auth.getName());
// T2Users getUser = userService.getUserAndAuthorities(user);
//
// info.put("sessUserInfo", getUser);
//
// auth.setDetails(info);
// }
}
| 2,422 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
VerificationServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/VerificationServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
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.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.common.ShellCommander;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.OssNotice;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2File;
import oss.fosslight.repository.CommentMapper;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.VerificationMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.FileService;
import oss.fosslight.service.ProjectService;
import oss.fosslight.service.VerificationService;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.ExcelDownLoadUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.SPDXUtil2;
import oss.fosslight.util.StringUtil;
import oss.fosslight.util.PdfUtil;
@Service
@Slf4j
public class VerificationServiceImpl extends CoTopComponent implements VerificationService {
// Service
@Autowired CommentService commentService;
@Autowired ProjectService projectService;
@Autowired FileService fileService;
// Mapper
@Autowired ProjectMapper projectMapper;
@Autowired CommentMapper commentMapper;
@Autowired VerificationMapper verificationMapper;
@Autowired FileMapper fileMapper;
private static String VERIFY_HOME_PATH = CommonFunction.emptyCheckProperty("verify.home.path", "/verify");
private static String VERIFY_BIN_PATH = CommonFunction.emptyCheckProperty("verify.bin.path", "/verify");
private static String VERIFY_PATH_DECOMP = CommonFunction.emptyCheckProperty("verify.decompress.path", "/verify/decompression");
private static String VERIFY_PATH_OUTPUT = CommonFunction.emptyCheckProperty("verify.output.path", "/verify/output");
private static String NOTICE_PATH = CommonFunction.emptyCheckProperty("notice.path", "/notice");
private static String EXPORT_TEMPLATE_PATH = CommonFunction.emptyCheckProperty("export.template.path", "/template");
private static String REVIEW_REPORT_PATH=CommonFunction.emptyCheckProperty("reviewReport.path", "/reviewReport");
@Override
public Map<String, Object> getVerificationOne(Project project) {
// 1. Verification์ ๋ณด
// 2. Comment ์ ๋ณด
HashMap<String, Object> map = new HashMap<String, Object>();
Project prj = projectMapper.selectProjectMaster(project);
String comment = prj != null ? prj.getComment() : null;
String content = commentMapper.getContent(comment);
OssNotice ossNotice = verificationMapper.selectOssNoticeOne(project);
map.put("data", prj);
map.put("commentText", content);
map.put("notice", ossNotice);
return map;
}
@Override
public OssNotice selectOssNoticeOne(String prjId) {
Project project = new Project();
project.setPrjId(prjId);
return verificationMapper.selectOssNoticeOne(project);
}
@Override
public List<OssComponents> getVerifyOssList(Project projectMaster) {
List<OssComponents> componentList = verificationMapper.selectVerifyOssList(projectMaster);
if (componentList != null && !componentList.isEmpty() && componentList.get(0) == null) {
componentList = new ArrayList<>();
}
return componentList;
}
@Override
public boolean getChangedPackageFile(String prjId, List<String> fileSeqs) {
String packageFileId = fileSeqs.get(0);
String packageFileId2 = fileSeqs.size() > 1 ? fileSeqs.get(1) : null;
String packageFileId3 = fileSeqs.size() > 2 ? fileSeqs.get(2) : null;
int result = verificationMapper.checkPackagingFileId(prjId,packageFileId, packageFileId2, packageFileId3);
if (result > 0){
return false;
} else{
return true;
}
}
@SuppressWarnings("unchecked")
@Transactional
@Override
public void savePath(Map<Object, Object> map) {
try {
List<String> gridComponentIds = (List<String>)map.get("gridComponentIds");
List<String> gridFilePaths = (List<String>)map.get("gridFilePaths");
List<String> fileSeqs = (List<String>) map.get("fileSeqs");
String prjId = (String) map.get("prjId");
String deleteFlag = (String) map.get("deleteFlag");
String verifyFlag = (String) map.get("statusVerifyYn");
String deleteFiles = (String) map.get("deleteFiles");
String deleteComment = "";
String uploadComment = "";
// verify ๋ฒํผ ํด๋ฆญ์ file path๋ฅผ ์ ์ฅํ๋ค.
if (gridComponentIds != null && !gridComponentIds.isEmpty()) {
int idx = 0;
for (String s : gridComponentIds){
OssComponents param = new OssComponents();
param.setComponentId(s);
param.setFilePath(gridFilePaths.get(idx++));
if (verifyFlag.equals(CoConstDef.FLAG_YES)){
param.setVerifyFileCount("");
verificationMapper.updateVerifyFileCount(param);
}
verificationMapper.updateVerifyFilePath(param);
}
}
if (!isEmpty(prjId)) {
Project prjParam = new Project();
prjParam.setPrjId(prjId);
ArrayList<String> newPackagingFileIdList = new ArrayList<String>();
newPackagingFileIdList.add(fileSeqs.size() > 0 ? fileSeqs.get(0) : null);
newPackagingFileIdList.add(fileSeqs.size() > 1 ? fileSeqs.get(1) : null);
newPackagingFileIdList.add(fileSeqs.size() > 2 ? fileSeqs.get(2) : null);
prjParam.setPackageFileId(newPackagingFileIdList.get(0));
prjParam.setPackageFileId2(newPackagingFileIdList.get(1));
prjParam.setPackageFileId3(newPackagingFileIdList.get(2));
if (deleteFiles.equals(CoConstDef.FLAG_YES)){
prjParam.setStatusVerifyYn(CoConstDef.FLAG_NO);
}
List<T2File> deleteFileList = new ArrayList<>();
// packaging File comment
try {
Project project = projectMapper.selectProjectMaster(prjParam);
ArrayList<String> origPackagingFileIdList = new ArrayList<String>();
origPackagingFileIdList.add(project.getPackageFileId());
origPackagingFileIdList.add(project.getPackageFileId2());
origPackagingFileIdList.add(project.getPackageFileId3());
int idx = 0;
for (String fileId : origPackagingFileIdList){
T2File fileInfo = new T2File();
if (!isEmpty(fileId) && !fileId.equals(newPackagingFileIdList.get(idx))){
fileInfo.setFileSeq(fileId);
fileInfo = fileMapper.getFileInfo(fileInfo);
deleteComment += "Packaging file, "+fileInfo.getOrigNm()+", was deleted by "+loginUserName()+". <br>";
deleteFileList.add(fileInfo);
}
if (!isEmpty(newPackagingFileIdList.get(idx)) && !newPackagingFileIdList.get(idx).equals(fileId)){
fileInfo.setFileSeq(newPackagingFileIdList.get(idx));
fileInfo = fileMapper.getFileInfo(fileInfo);
oss.fosslight.domain.File result = verificationMapper.selectVerificationFile(newPackagingFileIdList.get(idx));
if (CoConstDef.FLAG_YES.equals(result.getReuseFlag())){
uploadComment += "Packaging file, "+fileInfo.getOrigNm()+", was loaded from Project ID: "+result.getRefPrjId()+" by "+loginUserName()+". <br>";
}else{
uploadComment += "Packaging file, "+fileInfo.getOrigNm()+", was uploaded by "+loginUserName()+". <br>";
}
}
idx++;
}
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents(deleteComment+uploadComment);
commentService.registComment(commHisBean, false);
} catch (Exception e) {
log.error(e.getMessage());
}
verificationMapper.updatePackagingReuseMap(prjParam);
verificationMapper.updatePackageFile(prjParam);
// delete physical file
for (T2File delFile : deleteFileList){
if (verificationMapper.selectVerificationFile(delFile.getFileSeq()) == null) {
fileService.deletePhysicalFile(delFile, "VERIFY");
}
}
if (CoConstDef.FLAG_YES.equals(deleteFlag)){
projectMapper.updateReadmeContent(prjParam); // README Clear
projectMapper.updateVerifyContents(prjParam); // File List, Banned List Clear
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@Override
public boolean getNoticeHtmlFile(OssNotice ossNotice) throws IOException {
return getNoticeHtmlFile(ossNotice, null);
}
@Override
public boolean getNoticeHtmlFile(OssNotice ossNotice, String contents) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
// OSS Notice๊ฐ N/A์ด๋ฉด ๊ณ ์ง๋ฌธ์ ์์ฑํ์ง ์๋๋ค.
if (CoConstDef.CD_NOTICE_TYPE_NA.equals(prjInfo.getNoticeType())) {
return true;
}
prjInfo.setUseCustomNoticeYn(!isEmpty(contents) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
contents = avoidNull(contents, getNoticeHtml(ossNotice));
if ("binAndroid".equals(contents)) {
return getAndroidNoticeVelocityTemplateFile(prjInfo); // file Content ์ฎ๊ธฐ๋ ๊ธฐ๋ฅ์์ files.copy๋ก ๋ณ๊ฒฝ
} else {
return getNoticeVelocityTemplateFile(contents, prjInfo);
}
}
@Override
public boolean getReviewReportPdfFile(String prjId) throws IOException {
return getReviewReportPdfFile(prjId, null);
}
@Override
public boolean getReviewReportPdfFile(String prjId, String contents) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(prjId);
try {
contents = avoidNull(contents, PdfUtil.getInstance().getReviewReportHtml(prjId));
}catch(Exception e){
log.error(e.getMessage());
return false;
}
if ("binAndroid".equals(contents)) {
return getAndroidNoticeVelocityTemplateFile(prjInfo); // file Content ์ฎ๊ธฐ๋ ๊ธฐ๋ฅ์์ files.copy๋ก ๋ณ๊ฒฝ
} else {
return getReviewReportVelocityTemplateFile(contents, prjInfo);
}
}
private boolean getAndroidNoticeVelocityTemplateFile(Project project) {
boolean procResult = true;
try {
// file path and name ์ค์
// ํ์ผ path : <upload_home>/notice/
// ํ์ผ๋ช
: ์์: ํ๋ก์ ํธID_yyyyMMdd\
String filePath = NOTICE_PATH + "/" + project.getPrjId();
T2File baseFile = null;
String basePath = null;
if (isEmpty(project.getSrcAndroidNoticeXmlId()) && !isEmpty(project.getSrcAndroidNoticeFileId())) {
baseFile = fileMapper.selectFileInfoById(project.getSrcAndroidNoticeFileId());
basePath = CommonFunction.emptyCheckProperty("upload.path", "/upload") + "/" + baseFile.getLogiNm();
} else {
baseFile = fileMapper.selectFileInfoById(project.getSrcAndroidNoticeXmlId());
basePath = baseFile.getLogiPath() + "/" + baseFile.getLogiNm();
}
// ์ด์ ์ ์์ฑ๋ ํ์ผ์ ๋ชจ๋ ์ญ์ ํ๋ค.
Path rootPath = Paths.get(filePath);
if (rootPath.toFile().exists()) {
for (String _fName : rootPath.toFile().list()) {
Files.deleteIfExists(rootPath.resolve(_fName));
T2File file = new T2File();
file.setLogiNm(_fName);
file.setLogiPath(filePath);
int returnSuccess = fileMapper.updateFileDelYnByFilePathNm(file);
if (returnSuccess > 0){
log.debug(filePath + "/" + _fName + " is delete success.");
}else{
log.debug(filePath + "/" + _fName + " is delete failed.");
}
}
}
String fileName = CommonFunction.getNoticeFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), "html");
if (oss.fosslight.util.FileUtil.copyFile(basePath, filePath, fileName)) {
// ํ์ผ ๋ฑ๋ก
String FileSeq = fileService.registFileWithFileName(filePath, fileName);
// project ์ ๋ณด ์
๋ฐ์ดํธ
Project projectParam = new Project();
projectParam.setPrjId(project.getPrjId());
projectParam.setNoticeFileId(FileSeq);
projectParam.setUseCustomNoticeYn(StringUtil.nvl(project.getUseCustomNoticeYn(),CoConstDef.FLAG_NO));
verificationMapper.updateNoticeFileInfo(projectParam);
} else {
procResult = false;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
procResult = false;
}
return procResult;
}
private boolean getNoticeVelocityTemplateFile(String contents, Project project) {
boolean procResult = true;
try {
// file path and name ์ค์
// ํ์ผ path : <upload_home>/notice/
// ํ์ผ๋ช
: ์์: ํ๋ก์ ํธID_yyyyMMdd\
String filePath = NOTICE_PATH + "/" + project.getPrjId();
// ์ด์ ์ ์์ฑ๋ ํ์ผ์ ๋ชจ๋ ์ญ์ ํ๋ค.
Path rootPath = Paths.get(filePath);
if (rootPath.toFile().exists()) {
for (String _fName : rootPath.toFile().list()) {
Files.deleteIfExists(rootPath.resolve(_fName));
T2File file = new T2File();
file.setLogiNm(_fName);
file.setLogiPath(filePath);
int returnSuccess = fileMapper.updateFileDelYnByFilePathNm(file);
if (returnSuccess > 0) {
log.debug(filePath + "/" + _fName + " is delete success.");
} else {
log.debug(filePath + "/" + _fName + " is delete failed.");
}
}
}
String fileName = CommonFunction.getNoticeFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), "html");
if (oss.fosslight.util.FileUtil.writeFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
String FileSeq = fileService.registFileWithFileName(filePath, fileName);
// project ์ ๋ณด ์
๋ฐ์ดํธ
Project projectParam = new Project();
projectParam.setPrjId(project.getPrjId());
projectParam.setNoticeFileId(FileSeq);
projectParam.setUseCustomNoticeYn(StringUtil.nvl(project.getUseCustomNoticeYn(),CoConstDef.FLAG_NO));
verificationMapper.updateNoticeFileInfo(projectParam);
} else {
procResult = false;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
procResult = false;
}
return procResult;
}
public boolean getReviewReportVelocityTemplateFile(String contents, Project project) {
boolean procResult = true;
try {
// file path and name ์ค์
// ํ์ผ path : <upload_home>/reviewReport/
// ํ์ผ๋ช
: ์์: ํ๋ก์ ํธID_yyyyMMdd\
String filePath = REVIEW_REPORT_PATH + "/" + project.getPrjId();
// ์ด์ ์ ์์ฑ๋ pdf ํ์ผ์ ๋ชจ๋ ์ญ์ ํ๋ค.
Path rootPath = Paths.get(filePath);
if (rootPath.toFile().exists()) {
for (String _fName : rootPath.toFile().list()) {
String[] fNameList = _fName.split("\\.");
if (fNameList[fNameList.length - 1].equals("pdf")) {
Files.deleteIfExists(rootPath.resolve(_fName));
T2File file = new T2File();
file.setLogiNm(_fName);
file.setLogiPath(filePath);
int returnSuccess = fileMapper.updateFileDelYnByFilePathNm(file);
if (returnSuccess > 0){
log.debug(filePath + "/" + _fName + " is delete success.");
}else{
log.debug(filePath + "/" + _fName + " is delete failed.");
}
}
}
}
String fileName = CommonFunction.getReviewReportFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), ".pdf");
if (oss.fosslight.util.FileUtil.writeReviewReportFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
String FileSeq = fileService.registFileWithFileName(filePath, fileName);
// project ์ ๋ณด ์
๋ฐ์ดํธ
Project projectParam = new Project();
projectParam.setPrjId(project.getPrjId());
projectParam.setReviewReportFileId(FileSeq);
verificationMapper.updateReviewReportFileInfo(projectParam);
} else {
procResult = false;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
procResult = false;
}
return procResult;
}
@Override
public String getNoticeHtml(OssNotice ossNotice) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
String androidNoticeContents = getAndroidNotice(prjInfo);
if (CoConstDef.FLAG_YES.equals(ossNotice.getPreviewOnly()) && !isEmpty(androidNoticeContents)) {
return androidNoticeContents;
} else {
if (!isEmpty(androidNoticeContents)) {
return "binAndroid";
} else {
ossNotice.setNetworkServerFlag(prjInfo.getNetworkServerType());
// Convert Map to Apache Velocity Template
return CommonFunction.VelocityTemplateToString(getNoticeHtmlInfo(ossNotice, true));
}
}
}
private String getAndroidNotice(Project prjInfo) throws IOException {
// distribution type์ด Android ์ด๋ฉด์
// Android Build Image์ด์ธ์ OSS List๊ฐ ํฌํจ๋ ๊ฒฝ์ฐ๋ ๋ณํฉ
// android build image๋ง ์ฌ์ฉ๋ ๊ฒฝ์ฐ๋ notice.html์ ๋ฐํํ๋ค.
// ์ด์๋ก ์ธํด android project ๊ธฐ์ค์ด ๋ณ๊ฒฝ์ด ๋์์ผ๋ฉฐ NoticeType์ด 20์ธ ๊ฒฝ์ฐ๋ ์ ๋ถ Android Projectํํ๋ฅผ ๋๊ณ ์๋๋ก ๋ณ๊ฒฝ์ด ๋์์.
Map<String, Object> NoticeInfo = projectMapper.getNoticeType(prjInfo.getPrjId());
if (prjInfo != null
&& CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equals(avoidNull((String) NoticeInfo.get("noticeType"), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL))
&& !isEmpty(prjInfo.getSrcAndroidNoticeFileId())) {
T2File androidFile = fileService.selectFileInfoById(prjInfo.getSrcAndroidNoticeFileId());
return CommonFunction.getStringFromFile(androidFile.getLogiPath() + "/" + androidFile.getLogiNm());
}
return null;
}
@SuppressWarnings("unchecked")
// @Transactional // verify ์ํ์๊ฐ์ด 50์ด์ด์์ธ ๊ฒฝ์ฐ(SELECT @@innodb_lock_wait_timeout;) ์๋ฌ๊ฐ ๋ฐ์ํ๋ ๊ฒ์ ์์ฌ๋์ด Transactional ์์ฑ์ ์ญ์ ํจ
@Override
public Map<String, Object> processVerification(Map<Object, Object> map, T2File file, Project project) {
HashMap<String, Object> resMap = new HashMap<>();
String resCd = "00";
String resMsg = "";
log.info("VERIFY START PROJECT ID : " + (String)map.get("prjId"));
int allFileCount = 0;
String[] result = null;
String readmePath = "";
String exceptFileContent = "";
String prjId = (String)map.get("prjId");
String fileSeq = (String)map.get("fileSeq");
int packagingFileIdx = (int)map.get("packagingFileIdx");
List<String> fileSeqs = (List<String>)map.get("fileSeqs");
String filePath = "";
List<String> gridFilePaths = (List<String>)map.get("gridFilePaths");
List<String> gridComponentIds = (List<String>)map.get("gridComponentIds");
boolean isChangedPackageFile = (boolean)map.get("isChangedPackageFile");
String packagingComment = (String)map.get("packagingComment");
List<String> checkExceptionWordsList = CoCodeManager.getCodeNames(CoConstDef.CD_VERIFY_EXCEPTION_WORDS);
List<String> checkExceptionIgnoreWorksList = CoCodeManager.getCodeNames(CoConstDef.CD_VERIFY_IGNORE_WORDS);
Project prjInfo = null;
boolean doUpdate = true;
try {
// ํ๋ก์ ํธ ์ ๋ณด ์ทจ๋ (verification status ์ ๋ฐ๋ผ DB update ์ฌ๋ถ๋ฅผ ๊ฒฐ์
{
prjInfo = projectService.getProjectBasicInfo(prjId);
if (prjInfo != null && CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(prjInfo.getVerificationStatus())) {
doUpdate = false;
}
}
File chk_list_file = new File(VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list_"+packagingFileIdx);
if (!chk_list_file.exists()) {
isChangedPackageFile = true;
}
file.setFileSeq(fileSeq);
file = fileMapper.getFileInfo(file);
filePath = file.getLogiPath()+"/"+file.getLogiNm();
log.debug("VERIFY TARGET FILE : " + filePath);
if (packagingFileIdx == 1 && isChangedPackageFile) {
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "find " + VERIFY_PATH_OUTPUT + " -maxdepth 1 -name "+prjId+" -type d -exec rm -rf {} \\;"});
}
String exceptionWordsPatten = "proprietary\\|commercial";
if (checkExceptionWordsList != null && !checkExceptionWordsList.isEmpty()) {
exceptionWordsPatten = "";
for (String s : checkExceptionWordsList) {
if (!isEmpty(exceptionWordsPatten)) {
exceptionWordsPatten += "\\|";
}
exceptionWordsPatten += s;
}
}
log.info("VERIFY prjName : " + prjInfo.getPrjName());
log.info("VERIFY OrigNm : " + file.getOrigNm());
String projectNm = (prjInfo.getPrjName()).replace(" ", "@@");
if (!isEmpty(prjInfo.getPrjVersion())){
projectNm +="_"+(prjInfo.getPrjVersion()).replace(" ", "@@");
}
projectNm +="_"+Integer.toString(packagingFileIdx)+"("+(file.getOrigNm()).replace(" ", "@@")+")";
String commandStr = VERIFY_BIN_PATH+"/verify "+filePath+" "+prjId+" "+exceptionWordsPatten+" "+projectNm+" "+packagingFileIdx+" "+VERIFY_HOME_PATH;
log.info("VERIFY COMMAND : " + commandStr);
log.info("VERIFY START : " + prjId);
if (isChangedPackageFile){ // packageFile์ ๋ณ๊ฒฝํ์ง ์๊ณ ๋ค์ verifyํ ๊ฒฝ์ฐ ์๋ shellCommander๋ ์ค๋ณต ๋์ ํ์ง ์์.
ShellCommander.shellCommandWaitFor(commandStr);
}
log.info("VERIFY END : " + prjId);
//STEP 2 : Verify ์งํํ ํน์ ์์น์ ํ์ผ๋ฆฌ์คํธ ์ถ๋ ฅ
//STEP 3 : ๊ฒฐ๊ณผ ๋ฌธ์์ด ๋ฆฌ์คํธ๊ฐ์ ๋ฐฐ์ด๋ก ๋ณํ
String chk_list_file_path = null;
if (packagingFileIdx == 1) {
chk_list_file_path = VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list_1";
} else {
chk_list_file_path = VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list";
}
String verify_chk_list = CommonFunction.getStringFromFile(chk_list_file_path).replaceAll(VERIFY_PATH_DECOMP +"/"+ prjId + "/", "");
if (verify_chk_list.contains(VERIFY_PATH_DECOMP +"/"+ prjId)) {
verify_chk_list = verify_chk_list.replaceAll(VERIFY_PATH_DECOMP +"/"+ prjId, "");
}
log.info("VERIFY Read verify_chk_list END : " + prjId);
result = verify_chk_list.split(System.lineSeparator());
allFileCount = StringUtils.countMatches(verify_chk_list, "*");
// ์์ถ ํด์ ํ ๋๋ ํ ๋ฆฌ๋ฅผ ํฌํจํ์ฌ ์ํธ๋น๊ต ํ๊ธฐ ์ํด ์ ์ธํ ๋๋ ํ ๋ฆฌ ๋ช
์ถ์ถ
// ๋๋ฒ์งธ ๋๋ ํ ๋ฆฌ ๊น์ง ์นํํ ๋ฌธ์์ด ์ถ์ถ
log.debug("file.getOrigNm() : " + file.getOrigNm());
log.debug("file.getExt() : " + file.getExt());
String tempFileOrgName = file.getOrigNm();
String tempFileOrgExt = file.getExt();
log.debug("lastIndexOf(file.getExt()) : " + tempFileOrgName.lastIndexOf(tempFileOrgExt));
String rePath = FilenameUtils.removeExtension(tempFileOrgName);
log.debug("rePath : " + rePath);
if (rePath.indexOf(".tar") > -1){
rePath = rePath.substring(0, rePath.lastIndexOf(".tar"));
}
String decompressionDirName = "/" + rePath;
String packageFileName = rePath;
String decompressionRootPath = "";
List<String> collectDataDeCompResultList = new ArrayList<>();
// ์ฌ์ฉ์ ์
๋ ฅ๊ณผ packaging ํ์ผ์ ๋๋ ํ ๋ฆฌ ์ ๋ณด ๋น๊ต๋ฅผ ์ํด
// ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๊ฒฉ๋ฉ (dir or file n ame : count)
Map<String, Integer> deCompResultMap = new HashMap<>();
List<String> readmePathList = new ArrayList<String>();
if (result != null) {
boolean isFirst = true;
for (String s : result) {
if (s.contains("?")) s = s.replaceAll("[?]", "0x3F");
if (!isEmpty(s) && !(s.contains("(") && s.contains(")"))) {
// packaging file name์ ๊ฒฝ์ฐ Path๋ก ์ธ์ํ์ง ๋ชปํ๋๋ก ์ฒ๋ฆฌํจ.
boolean isFile = s.endsWith("*");
s = s.replace(VERIFY_PATH_DECOMP +"/" + prjId + "/", "");
s = s.replaceAll("//", "/");
if (s.startsWith("/")) {
s = s.substring(1);
}
if (s.startsWith(packageFileName)) {
String removePackageFileName = s.replace(packageFileName, "");
if (removePackageFileName.startsWith("/")) {
removePackageFileName = removePackageFileName.substring(1);
}
collectDataDeCompResultList.add(removePackageFileName);
if (s.startsWith("/")) {
s = s.substring(1);
}
} else {
collectDataDeCompResultList.add(packageFileName + "/" + s);
}
if (s.endsWith("*")) {
s = s.substring(0, s.length()-1);
}
if (s.endsWith("/")) {
s = s.substring(0, s.length() -1);
}
if (isFirst) {
if (!isFile) {
// ์ฒซ๋ฒ์งธ path๋ฅผ ์์ถ์ ํผ ์ฒ๋ฒ์งธ dir๋ก ์ฌ์ฉ
decompressionRootPath = s;
isFirst = false;
}
}
int cnt = 0;
//ํ์ผ path์ธ ๊ฒฝ์ฐ, ์์ dir์ ํ์ผ count๋ฅผ +1 ํ๋ค.
if (isFile){
String _dir = s;
if (s.toUpperCase().indexOf("README") > -1) {
readmePathList.add(s);
}
if (s.indexOf("/") > -1) {
_dir = s.substring(0, s.lastIndexOf("/"));
}
if (deCompResultMap.containsKey(_dir)) {
cnt = deCompResultMap.get(_dir);
}
cnt++;
deCompResultMap.put(_dir, cnt);
}
deCompResultMap.put(s, 0);
}
}
}
if (collectDataDeCompResultList != null && !collectDataDeCompResultList.isEmpty()) {
for (String s : collectDataDeCompResultList) {
boolean isFile = s.endsWith("*");
int cnt = 0;
if (isFile){
String _dir = s;
if (s.indexOf("/") > -1) {
_dir = s.substring(0, s.lastIndexOf("/"));
}
if (deCompResultMap.containsKey(_dir)) {
cnt = deCompResultMap.get(_dir);
}
cnt++;
deCompResultMap.put(_dir, cnt);
}
deCompResultMap.put(s, 0);
}
}
List<String> paths = sortByValue(deCompResultMap);
for (String path : paths){
if (deCompResultMap.get(path) != null){
deCompResultMap = setAddFileCount(deCompResultMap, path, (int)deCompResultMap.get(path));
}
}
// ๊ฒฐ๊ณผ file path์ ๋ํด์ 4๊ฐ์ง ํ์ฉ ํจํด์ผ๋ก ๊ฒ์ฌํ๋ค.
Map<String, Integer> checkResultMap = new HashMap<>();
List<String> pathCheckList1 = new ArrayList<>();
List<String> pathCheckList2 = new ArrayList<>();
List<String> pathCheckList3 = new ArrayList<>();
List<String> pathCheckList4 = new ArrayList<>();
List<String> pathCheckList11 = new ArrayList<>();
List<String> pathCheckList21 = new ArrayList<>();
List<String> pathCheckList31 = new ArrayList<>();
List<String> pathCheckList41 = new ArrayList<>();
List<String> pathCheckList12 = new ArrayList<>();
List<String> pathCheckList22 = new ArrayList<>();
List<String> pathCheckList32 = new ArrayList<>();
List<String> pathCheckList42 = new ArrayList<>();
List<String> pathCheckList13 = new ArrayList<>();
List<String> pathCheckList23 = new ArrayList<>();
List<String> pathCheckList33 = new ArrayList<>();
List<String> pathCheckList43 = new ArrayList<>();
List<String> pathCheckList14 = new ArrayList<>();
List<String> pathCheckList24 = new ArrayList<>();
List<String> pathCheckList34 = new ArrayList<>();
List<String> pathCheckList44 = new ArrayList<>();
List<String> pathCheckList15 = new ArrayList<>();
List<String> pathCheckList25 = new ArrayList<>();
List<String> pathCheckList35 = new ArrayList<>();
List<String> pathCheckList45 = new ArrayList<>();
List<String> pathCheckList16 = new ArrayList<>();
List<String> pathCheckList26 = new ArrayList<>();
List<String> pathCheckList36 = new ArrayList<>();
List<String> pathCheckList46 = new ArrayList<>();
for (String path : deCompResultMap.keySet()) {
pathCheckList1.add(path);
pathCheckList2.add("/" + path);
pathCheckList3.add(path + "/");
pathCheckList4.add("/"+path + "/");
String replaceFilePath = path.substring(0, path.endsWith("*") ? path.length()-1 : path.length());
if (replaceFilePath.startsWith("/")) {
replaceFilePath = replaceFilePath.substring(1);
}
if (replaceFilePath.endsWith("/")) {
replaceFilePath = replaceFilePath.substring(0, replaceFilePath.length()-1);
}
pathCheckList11.add(replaceFilePath);
pathCheckList21.add("/" + replaceFilePath);
pathCheckList31.add(replaceFilePath + "/");
pathCheckList41.add("/"+replaceFilePath + "/");
String addRootDir = decompressionDirName + "/" + path;
if (addRootDir.startsWith("/")) {
addRootDir = addRootDir.substring(1);
}
if (addRootDir.endsWith("/")) {
addRootDir = addRootDir.substring(0, addRootDir.length()-1);
}
pathCheckList12.add(addRootDir);
pathCheckList22.add("/" + addRootDir);
pathCheckList32.add(addRootDir + "/");
pathCheckList42.add("/"+addRootDir + "/");
String addRootDirReplaceFilePath = decompressionDirName + "/" + path.substring(0, path.endsWith("*") ? path.length()-1 : path.length());
if (addRootDirReplaceFilePath.startsWith("/")) {
addRootDirReplaceFilePath = addRootDirReplaceFilePath.substring(1);
}
if (addRootDirReplaceFilePath.endsWith("/")) {
addRootDirReplaceFilePath = addRootDirReplaceFilePath.substring(0, addRootDirReplaceFilePath.length());
}
pathCheckList13.add(addRootDirReplaceFilePath);
pathCheckList23.add("/" + addRootDirReplaceFilePath);
pathCheckList33.add(addRootDirReplaceFilePath + "/");
pathCheckList43.add("/"+addRootDirReplaceFilePath + "/");
String replaceRootDir = path.replaceFirst(packageFileName, "").replaceAll("//", "/");
if (replaceRootDir.startsWith("/")) {
replaceRootDir = replaceRootDir.substring(1);
}
if (replaceRootDir.endsWith("/")) {
replaceRootDir = replaceRootDir.substring(0, replaceRootDir.length()-1);
}
pathCheckList14.add(replaceRootDir);
pathCheckList24.add("/" + replaceRootDir);
pathCheckList34.add(replaceRootDir + "/");
pathCheckList44.add("/"+replaceRootDir + "/");
String replaceRootDirReplaceFilePath = replaceRootDir;
if (replaceRootDirReplaceFilePath.endsWith("*")) {
replaceRootDirReplaceFilePath = replaceRootDirReplaceFilePath.substring(0, replaceRootDirReplaceFilePath.length()-1);
}
if (replaceRootDirReplaceFilePath.endsWith("/")) {
replaceRootDirReplaceFilePath = replaceRootDirReplaceFilePath.substring(0, replaceRootDirReplaceFilePath.length()-1);
}
pathCheckList15.add(replaceRootDirReplaceFilePath);
pathCheckList25.add("/" + replaceRootDirReplaceFilePath);
pathCheckList35.add(replaceRootDirReplaceFilePath + "/");
pathCheckList45.add("/"+replaceRootDirReplaceFilePath + "/");
String replaceDecomFileRootDir = path.replaceFirst(decompressionRootPath, "").replaceAll("//", "/");
if (replaceDecomFileRootDir.startsWith("/")) {
replaceDecomFileRootDir = replaceDecomFileRootDir.substring(1);
}
if (replaceDecomFileRootDir.endsWith("/")) {
replaceDecomFileRootDir = replaceDecomFileRootDir.substring(0, replaceDecomFileRootDir.length()-1);
}
pathCheckList16.add(replaceDecomFileRootDir);
pathCheckList26.add("/" + replaceDecomFileRootDir);
pathCheckList36.add(replaceDecomFileRootDir + "/");
pathCheckList46.add("/"+replaceDecomFileRootDir + "/");
}
// ํตํฉ Map ์ ๋ชจ๋ ํ์ฉ ํจํด์ ์ ์ฅ
int idx = 0;
for (String s : pathCheckList1) {
checkResultMap.put(s, deCompResultMap.containsKey(s) ? deCompResultMap.get(s) : 0);
checkResultMap.put(pathCheckList2.get(idx), deCompResultMap.containsKey(pathCheckList2.get(idx)) ? deCompResultMap.get(pathCheckList2.get(idx)) : 0);
checkResultMap.put(pathCheckList3.get(idx), deCompResultMap.containsKey(pathCheckList3.get(idx)) ? deCompResultMap.get(pathCheckList3.get(idx)) : 0);
checkResultMap.put(pathCheckList4.get(idx), deCompResultMap.containsKey(pathCheckList4.get(idx)) ? deCompResultMap.get(pathCheckList4.get(idx)) : 0);
checkResultMap.put(pathCheckList11.get(idx), deCompResultMap.containsKey(pathCheckList11.get(idx)) ? deCompResultMap.get(pathCheckList11.get(idx)) : 0);
checkResultMap.put(pathCheckList21.get(idx), deCompResultMap.containsKey(pathCheckList21.get(idx)) ? deCompResultMap.get(pathCheckList21.get(idx)) : 0);
checkResultMap.put(pathCheckList31.get(idx), deCompResultMap.containsKey(pathCheckList31.get(idx)) ? deCompResultMap.get(pathCheckList31.get(idx)) : 0);
checkResultMap.put(pathCheckList41.get(idx), deCompResultMap.containsKey(pathCheckList41.get(idx)) ? deCompResultMap.get(pathCheckList41.get(idx)) : 0);
checkResultMap.put(pathCheckList12.get(idx), deCompResultMap.containsKey(pathCheckList12.get(idx)) ? deCompResultMap.get(pathCheckList12.get(idx)) : 0);
checkResultMap.put(pathCheckList22.get(idx), deCompResultMap.containsKey(pathCheckList22.get(idx)) ? deCompResultMap.get(pathCheckList22.get(idx)) : 0);
checkResultMap.put(pathCheckList32.get(idx), deCompResultMap.containsKey(pathCheckList32.get(idx)) ? deCompResultMap.get(pathCheckList32.get(idx)) : 0);
checkResultMap.put(pathCheckList42.get(idx), deCompResultMap.containsKey(pathCheckList42.get(idx)) ? deCompResultMap.get(pathCheckList42.get(idx)) : 0);
checkResultMap.put(pathCheckList13.get(idx), deCompResultMap.containsKey(pathCheckList13.get(idx)) ? deCompResultMap.get(pathCheckList13.get(idx)) : 0);
checkResultMap.put(pathCheckList23.get(idx), deCompResultMap.containsKey(pathCheckList23.get(idx)) ? deCompResultMap.get(pathCheckList23.get(idx)) : 0);
checkResultMap.put(pathCheckList33.get(idx), deCompResultMap.containsKey(pathCheckList33.get(idx)) ? deCompResultMap.get(pathCheckList33.get(idx)) : 0);
checkResultMap.put(pathCheckList43.get(idx), deCompResultMap.containsKey(pathCheckList43.get(idx)) ? deCompResultMap.get(pathCheckList43.get(idx)) : 0);
checkResultMap.put(pathCheckList14.get(idx), deCompResultMap.containsKey(pathCheckList14.get(idx)) ? deCompResultMap.get(pathCheckList14.get(idx)) : 0);
checkResultMap.put(pathCheckList24.get(idx), deCompResultMap.containsKey(pathCheckList24.get(idx)) ? deCompResultMap.get(pathCheckList24.get(idx)) : 0);
checkResultMap.put(pathCheckList34.get(idx), deCompResultMap.containsKey(pathCheckList34.get(idx)) ? deCompResultMap.get(pathCheckList34.get(idx)) : 0);
checkResultMap.put(pathCheckList44.get(idx), deCompResultMap.containsKey(pathCheckList44.get(idx)) ? deCompResultMap.get(pathCheckList44.get(idx)) : 0);
checkResultMap.put(pathCheckList15.get(idx), deCompResultMap.containsKey(pathCheckList15.get(idx)) ? deCompResultMap.get(pathCheckList15.get(idx)) : 0);
checkResultMap.put(pathCheckList25.get(idx), deCompResultMap.containsKey(pathCheckList25.get(idx)) ? deCompResultMap.get(pathCheckList25.get(idx)) : 0);
checkResultMap.put(pathCheckList35.get(idx), deCompResultMap.containsKey(pathCheckList35.get(idx)) ? deCompResultMap.get(pathCheckList35.get(idx)) : 0);
checkResultMap.put(pathCheckList45.get(idx), deCompResultMap.containsKey(pathCheckList45.get(idx)) ? deCompResultMap.get(pathCheckList45.get(idx)) : 0);
String _tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList16.get(idx)), pathCheckList16.get(idx));
checkResultMap.put(pathCheckList16.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList26.get(idx)), pathCheckList26.get(idx));
checkResultMap.put(pathCheckList26.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList36.get(idx)), pathCheckList36.get(idx));
checkResultMap.put(pathCheckList36.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList46.get(idx)), pathCheckList46.get(idx));
checkResultMap.put(pathCheckList46.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
idx ++;
}
int gridIdx = 0;
ArrayList<String> gValidIdxlist = new ArrayList<>();
HashMap<String,Object> gFileCountMap = new HashMap<>();
boolean separatorErrFlag = false;
log.info("VERIFY Path Check START -----------------");
for (String gridPath : gridFilePaths){
if (gridPath.contains("?")) {
gridPath = gridPath.replaceAll("[?]", "0x3F");
}
if (!separatorErrFlag) {
separatorErrFlag = gridPath.contains("\\") ? true : false;
}
//์ฌ์ฉ์๊ฐ * ์
๋ ฅํ์๋
if (!gridPath.trim().equals("/*") && !gridPath.trim().equals("/")){
if (gridPath.endsWith("*")) {
gridPath = gridPath.substring(0, gridPath.length()-1);
}
if (gridPath.startsWith(".")) {
gridPath = gridPath.substring(1, gridPath.length());
}
// ์๋ค path๊ตฌ๋ถ ์ ๊ฑฐ
if (gridPath.endsWith("/")) {
gridPath = gridPath.substring(0, gridPath.length()-1);
}
if (gridPath.startsWith("/")) {
gridPath = gridPath.substring(1);
}
int gFileCount = 0;
/*
* SUB_STEP 1. verify ๊ฒฐ๊ณผ ๋ฐฐ์ด์ ๋ฐ์์จ grid filepath์ ๋น๊ตํ์ฌ ์ค์ ๋ก ๊ทธ path๊ฐ ์กด์ฌํ๋์ง ํ์ธํ
* ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ grid index ์ ์ฅ
*/
boolean resultFlag = false;
if (checkResultMap.containsKey(gridPath)) {
resultFlag = true;
gFileCount = checkResultMap.get(gridPath);
}
if (!resultFlag) {//path๊ฐ ์กด์ฌํ์ง์์ ๋
gValidIdxlist.add(gridComponentIds.get(gridIdx));
} else {//path๊ฐ ์กด์ฌํ ๋
// file์ ์ง์ ๋น๊ตํ๋ ๊ฒฝ์ฐ count๋์ง ์๊ธฐ ๋๋ฌธ์, 1๋ก ๊ณ ์
// resultFlag == true ์ธ๊ฒฝ์ฐ๋ ์กด์ฌํ๊ธฐ ํด๋น path or file ๋์์ด ์กด์ฌํ๋ค๋ ์๋ฏธ์ด๊ธฐ ๋๋ฌธ์ 0์ด ๋ ์ ์๋ค.
if (gFileCount == 0) {
gFileCount = 1;
}
gFileCountMap.put(gridComponentIds.get(gridIdx), Integer.toString(gFileCount));
}
} else {
gFileCountMap.put(gridComponentIds.get(gridIdx), Integer.toString(allFileCount));
}
gridIdx++;
}
log.info("VERIFY Path Check END -----------------");
//STEP 4 : README ํ์ผ ์กด์ฌ ์ ๋ฌด ํ์ธ(README ์ฌ๋ฌ๊ฐ ์ผ๊ฒฝ์ฐ๋ ์๊ฐํด์ผํจ ---์ฐจํ)
// depth๊ฐ ๋ฎ์ readme ํ์ผ์ ๊ตฌํ๊ธฐ ์ํด sort
if (packagingFileIdx == 1){ // packageFile์์ readMe File์ ์ฒซ๋ฒ์งธ file์์๋ง ์ฐพ์.
// List<String> sortList = new ArrayList<>(deCompResultMap.keySet());
Collections.sort(readmePathList, new Comparator<String>() {
@Override
public int compare(String arg1, String arg2) {
if (arg1.split("\\/").length > arg2.split("\\/").length) {
return 1;
} else if (arg1.split("\\/").length < arg2.split("\\/").length) {
return -1;
} else {
return arg1.compareTo(arg2);
}
};
});
// String lastReadmeFilePath = "";
for (String r : readmePathList) {
String _upperPath = avoidNull(r).toUpperCase();
if (_upperPath.endsWith("/")) {
continue;
}
// String _currentReadmeFilePath = _upperPath.indexOf("/") < 0 ? _upperPath : _upperPath.substring(0,_upperPath.lastIndexOf("/"));
//
// if (!lastReadmeFilePath.equals(_currentReadmeFilePath)) {
// if (!isEmpty(readmePath)) {
// break;
// }
//
// lastReadmeFilePath = _currentReadmeFilePath;
// }
if (_upperPath.indexOf("/") > -1) {
_upperPath = _upperPath.substring(_upperPath.lastIndexOf("/"), _upperPath.length());
}
if (_upperPath.indexOf("README") > -1){
String _readmePath = r.replaceAll("\\n", "");
int afterDepthCnt = StringUtils.countMatches(_readmePath, "/");
int beforeDepthCnt = StringUtils.countMatches(readmePath, "/");
if (isEmpty(readmePath) || beforeDepthCnt > afterDepthCnt) {
readmePath = _readmePath;
}
}
}
}
String readmeFileName = "";
//STEP 6 : README ํ์ผ ๋ด์ฉ ์ถ๋ ฅ
if (!StringUtil.isEmpty(readmePath)){
if (readmePath.indexOf("*") > -1){
readmePath = readmePath.substring(0, readmePath.length()-1);
}
readmeFileName = readmePath;
if (readmeFileName.indexOf("/") > -1) {
readmeFileName = readmeFileName.substring(readmeFileName.lastIndexOf("/") + 1);
}
if (readmePath.indexOf(" ") > -1) {
log.info("do space replase ok");
readmePath = readmePath.replaceAll(" ", "*");
}
log.info("readmePath : " + readmePath);
log.info("readmeFileName : " + readmeFileName);
log.info("VERIFY Copy Readme file START -----------------");
log.info("VERIFY README MV PATH : " + VERIFY_PATH_DECOMP +"/" + prjId +"/" + readmePath);
if (isChangedPackageFile){
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "cp "+VERIFY_PATH_DECOMP +"/" + prjId +"/" + readmePath+ " " + VERIFY_PATH_OUTPUT +"/" + prjId +"/"});
}
log.info("VERIFY Copy Readme file END -----------------");
}
//STEP 7 : README ํ์ผ ๋ด์ฉ DB ์ ์ ์ฅ
if (doUpdate && packagingFileIdx == 1) {
log.debug("VERIFY readme ๋ฑ๋ก");
project.setPrjId(prjId);
project.setReadmeFileName(readmeFileName);
project.setReadmeYn(StringUtil.isEmpty(readmeFileName) ? CoConstDef.FLAG_NO : CoConstDef.FLAG_YES);
projectService.registReadmeContent(project);
log.debug("VERIFY readme ๋ฑ๋ก ์๋ฃ");
}
//STEP 8 : Verify ๋์ ํ Except File Result DB ์ ์ฅ
log.info("VERIFY Read exceptFileContent file START -----------------");
exceptFileContent = CommonFunction.getStringFromFile(VERIFY_PATH_OUTPUT +"/"+prjId+"/except_file_result", VERIFY_PATH_DECOMP +"/" + prjId +"/", checkExceptionWordsList, checkExceptionIgnoreWorksList);
log.info("VERIFY Read exceptFileContent file END -----------------");
// 2017.03.23 yuns contents ์ฉ๋์ด ๋๋ฌด ์ปค์ DB๋ก ๊ด๋ฆฌํ์ง ์์ (flag๋ง ์ฒ๋ฆฌ, empty์ฌ๋ถ๋ก ์ฒดํฌํ๊ธฐ ๋๋ฌธ์ ๋ด์ฉ์ด ์์ ๊ฒฝ์ฐ "Y" ๋ง ๋ฑ๋ก
project.setExceptFileContent(!isEmpty(exceptFileContent) ? CoConstDef.FLAG_YES : "");
project.setVerifyFileContent(!isEmpty(verify_chk_list) ? CoConstDef.FLAG_YES : "");
if (doUpdate) {
projectService.registVerifyContents(project);
}
log.debug("VERIFY ํ์ผ๋ด์ฉ ๋ฑ๋ก ์๋ฃ");
// ์๋ฒ ๋๋ ํ ๋ฆฌ๋ฅผ replaceํ ๋ด์ฉ์ผ๋ก ์๋ก์ด ํ์ผ๋ก ๋ค์ ์ด๋ค.
if (!isEmpty(exceptFileContent)) {
log.info("VERIFY writeFile exceptFileContent file START -----------------");
FileUtil.writeFile(VERIFY_PATH_OUTPUT +"/" + prjId, CoConstDef.PACKAGING_VERIFY_FILENAME_PROPRIETARY, exceptFileContent.replaceAll(VERIFY_PATH_DECOMP +"/" + prjId +"/", ""));
log.info("VERIFY writeFile exceptFileContent file END -----------------");
}
if (!isEmpty(verify_chk_list)) {
log.info("VERIFY writeFile verify_chk_list file START -----------------");
FileUtil.writeFile(VERIFY_PATH_OUTPUT +"/" + prjId, CoConstDef.PACKAGING_VERIFY_FILENAME_FILE_LIST, verify_chk_list.replaceAll(VERIFY_PATH_DECOMP +"/" + prjId +"/", ""));
log.info("VERIFY writeFile verify_chk_list file END -----------------");
}
resCd="10";
if (separatorErrFlag) {
resMsg = getMessage("verify.path.error");
} else {
resMsg= getMessage(gValidIdxlist.isEmpty() ? "msg.common.success" : "msg.common.valid");
}
resMap.put("verifyValid", gValidIdxlist);
resMap.put("verifyValidMsg", "path not found.");
resMap.put("fileCounts", gFileCountMap);
resMap.put("verifyReadme", readmeFileName);
resMap.put("verifyCheckList", !isEmpty(verify_chk_list) ? CoConstDef.FLAG_YES : "");
resMap.put("verifyProprietary", !isEmpty(exceptFileContent) ? CoConstDef.FLAG_YES : "");
//path not found.๊ฐ 1๊ฑด์ด๋ผ๋ ์์ผ๋ฉด status_verify_yn์ flag๋ N์ผ๋ก ์ ์ฅํจ.
// packagingFileId, filePath๋ 1๋ฒ๋ง ์ ์ฅํ๋ฉฐ, gValidIdxlist์ ๊ฐ๋๋ฌธ์ ๋ง์ง๋ง fileSeq์ผ๋ ์ ์ฅํจ.
if (doUpdate && packagingFileIdx == fileSeqs.size()) {
// verify ๋ฒํผ ํด๋ฆญ์ file path๋ฅผ ์ ์ฅํ๋ค.
if (gridComponentIds != null && !gridComponentIds.isEmpty()) {
int seq = 0;
for (String s : gridComponentIds){
OssComponents param = new OssComponents();
param.setComponentId(s);
param.setFilePath(gridFilePaths.get(seq++));
verificationMapper.updateVerifyFilePath(param);
}
}
{
Project prjParam = new Project();
prjParam.setPrjId(prjId);
prjParam.setPackageFileId(fileSeqs.get(0));
prjParam.setPackageFileId2(fileSeqs.size() >= 2 ? fileSeqs.get(1) : null);
prjParam.setPackageFileId3(fileSeqs.size() >= 3 ? fileSeqs.get(2) : null);
if (!isEmpty(prjInfo.getDestributionStatus())){
prjParam.setStatusVerifyYn("C");
} else {
prjParam.setStatusVerifyYn(CoConstDef.FLAG_YES);
}
verificationMapper.updatePackageFile(prjParam);
}
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(prjId); commHisBean.setContents(packagingComment);
commentService.registComment(commHisBean, false);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
resCd="20";
resMsg="process failed. (server error)";
} finally {
try {
if (isChangedPackageFile){
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "find " + VERIFY_PATH_DECOMP + " -maxdepth 1 -name "+prjId+" -type d -exec rm -rf {} \\;"});
}
log.info("VERIFY delete decomp file END -----------------");
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
resMap.put("resCd", resCd);
resMap.put("resMsg", resMsg);
log.debug("verify ์ฒ๋ฆฌ ์๋ฃ resCd : " + resCd);
log.debug("verify ์ฒ๋ฆฌ ์๋ฃ resMsg : " + resMsg);
return resMap;
}
private String addDecompressionRootPath(String path, boolean flag, String val) {
return flag ? val : path + "/" + val;
}
@Override
public void updateVerifyFileCount(HashMap<String,Object> fileCounts) {
for (String componentId : fileCounts.keySet()){
OssComponents param = new OssComponents();
param.setComponentId(componentId);
param.setVerifyFileCount((String) fileCounts.get(componentId));
verificationMapper.updateVerifyFileCount(param);
}
}
@Override
public void updateVerifyFileCount(ArrayList<String> fileCounts) {
for (String componentId : fileCounts){
OssComponents param = new OssComponents();
param.setComponentId(componentId);
param.setVerifyFileCount(" ");
verificationMapper.updateVerifyFileCount(param);
}
}
/**
* APSL ๋๋ AGPL ๋ผ์ด์ ์ค๋ฅผ ์ฌ์ฉํ๋ oss๋ฅผ ํฌํจํ๊ณ ์๋ ๊ฒฝ์ฐ false
* notice๋ฅผ ๋ง๋ค ํ์๊ฐ ์๋ ๊ฒฝ์ฐ true๋ฅผ ๋ฐํ
*/
@Override
public boolean checkNetworkServer(String prjId) {
OssNotice ossNotice = new OssNotice();
ossNotice.setPrjId(prjId);
ossNotice.setNetworkServerFlag(CoConstDef.FLAG_YES);
List<OssComponents> ossComponentList = verificationMapper.selectVerificationNotice(ossNotice);
return ossComponentList == null || ossComponentList.isEmpty();
}
@Transactional
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
private void updateProjectStatus(Project project) {
//๋ค์ด๋ก๋ ํ์ฉ ํ๋๊ทธ
project.setAllowDownloadBitFlag(allowDownloadMultiFlagToBitFlag(project));
// ํ๋ก์ ํธ ์ํ ๋ณ๊ฒฝ
projectMapper.updateProjectMaster(project);
}
@Override
@Transactional
public void updateStatusWithConfirm(Project project, OssNotice ossNotice, boolean copyConfirmFlag) throws Exception {
if (copyConfirmFlag) {
projectMapper.updateConfirmCopyVerificationDestributionStatus(project);
} else {
updateProjectStatus(project);
}
boolean makeZipFile = false;
String spdxComment = "";
// html simple
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleHTMLYn())) {
ossNotice.setSimpleNoticeFlag(CoConstDef.FLAG_YES);
ossNotice.setFileType("html");
project.setSimpleHtmlFileId(getNoticeTextFileForPreview(ossNotice, true));
makeZipFile = true;
}
// text
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadNoticeTextYn())) {
ossNotice.setSimpleNoticeFlag(CoConstDef.FLAG_NO);
ossNotice.setFileType("text");
project.setNoticeTextFileId(getNoticeTextFileForPreview(ossNotice, true));
makeZipFile = true;
}
// text simple
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleTextYn())) {
ossNotice.setSimpleNoticeFlag(CoConstDef.FLAG_YES);
ossNotice.setFileType("text");
project.setSimpleTextFileId(getNoticeTextFileForPreview(ossNotice, true));
makeZipFile = true;
}
// SPDX
String spdxSheetFileId = null;
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXSheetYn())) {
Map<String, String> data = new HashMap<>(); data.put("prjId", project.getPrjId());
String dataStr = toJson(data);
spdxSheetFileId = ExcelDownLoadUtil.getExcelDownloadId("spdx", dataStr, EXPORT_TEMPLATE_PATH);
if (!isEmpty(spdxSheetFileId)) {
T2File spdxFileInfo = fileService.selectFileInfo(spdxSheetFileId);
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
String fileName = "spdx_" + CommonFunction.getNoticeFileName(prjInfo.getPrjId(), prjInfo.getPrjName(), prjInfo.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), "");
fileName += "."+FilenameUtils.getExtension(spdxFileInfo.getOrigNm());
String filePath = NOTICE_PATH + "/" + prjInfo.getPrjId();
FileUtil.moveTo(spdxFileInfo.getLogiPath() + "/" + spdxFileInfo.getLogiNm(), filePath, fileName);
project.setSpdxSheetFileId(fileService.registFileDownload(filePath, fileName, fileName));
spdxSheetFileId = ossNotice.getSpdxSheetFileId();
makeZipFile = true;
}
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXRdfYn())) {
if (isEmpty(spdxSheetFileId)) {
Map<String, String> data = new HashMap<>(); data.put("prjId", project.getPrjId());
String dataStr = toJson(data);
spdxSheetFileId = ExcelDownLoadUtil.getExcelDownloadId("spdx", dataStr, EXPORT_TEMPLATE_PATH);
}
if (!isEmpty(spdxSheetFileId)) {
T2File spdxFileInfo = fileService.selectFileInfo(spdxSheetFileId);
String sheetFullPath = spdxFileInfo.getLogiPath();
if (!sheetFullPath.endsWith("/")) {
sheetFullPath += "/";
}
sheetFullPath += spdxFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(spdxFileInfo.getLogiNm())+".rdf";
String resultFileName = FilenameUtils.getBaseName(spdxFileInfo.getOrigNm())+".rdf";
String tagFullPath = spdxFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
SPDXUtil2.convert(project.getPrjId(), sheetFullPath, tagFullPath);
File spdxRdfFile = new File(tagFullPath);
if (spdxRdfFile.exists() && spdxRdfFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("spdx.rdf.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setSpdxRdfFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXTagYn())) {
if (isEmpty(spdxSheetFileId)) {
Map<String, String> data = new HashMap<>(); data.put("prjId", project.getPrjId());
String dataStr = toJson(data);
spdxSheetFileId = ExcelDownLoadUtil.getExcelDownloadId("spdx", dataStr, EXPORT_TEMPLATE_PATH);
}
if (!isEmpty(spdxSheetFileId)) {
T2File spdxFileInfo = fileService.selectFileInfo(spdxSheetFileId);
String sheetFullPath = spdxFileInfo.getLogiPath();
if (!sheetFullPath.endsWith("/")) {
sheetFullPath += "/";
}
sheetFullPath += spdxFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(spdxFileInfo.getLogiNm())+".tag";
String resultFileName = FilenameUtils.getBaseName(spdxFileInfo.getOrigNm())+".tag";
String tagFullPath = spdxFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
SPDXUtil2.convert(project.getPrjId(), sheetFullPath, tagFullPath);
File spdxTafFile = new File(tagFullPath);
if (spdxTafFile.exists() && spdxTafFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("spdx.tag.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setSpdxTagFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXJsonYn())) {
if (isEmpty(spdxSheetFileId)) {
Map<String, String> data = new HashMap<>(); data.put("prjId", project.getPrjId());
String dataStr = toJson(data);
spdxSheetFileId = ExcelDownLoadUtil.getExcelDownloadId("spdx", dataStr, EXPORT_TEMPLATE_PATH);
}
if (!isEmpty(spdxSheetFileId)) {
T2File spdxFileInfo = fileService.selectFileInfo(spdxSheetFileId);
String sheetFullPath = spdxFileInfo.getLogiPath();
if (!sheetFullPath.endsWith("/")) {
sheetFullPath += "/";
}
sheetFullPath += spdxFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(spdxFileInfo.getLogiNm())+".json";
String resultFileName = FilenameUtils.getBaseName(spdxFileInfo.getOrigNm())+".json";
String tagFullPath = spdxFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
SPDXUtil2.convert(project.getPrjId(), sheetFullPath, tagFullPath);
File spdxJsonFile = new File(tagFullPath);
if (spdxJsonFile.exists() && spdxJsonFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("spdx.json.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setSpdxJsonFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXYamlYn())) {
if (isEmpty(spdxSheetFileId)) {
Map<String, String> data = new HashMap<>(); data.put("prjId", project.getPrjId());
String dataStr = toJson(data);
spdxSheetFileId = ExcelDownLoadUtil.getExcelDownloadId("spdx", dataStr, EXPORT_TEMPLATE_PATH);
}
if (!isEmpty(spdxSheetFileId)) {
T2File spdxFileInfo = fileService.selectFileInfo(spdxSheetFileId);
String sheetFullPath = spdxFileInfo.getLogiPath();
if (!sheetFullPath.endsWith("/")) {
sheetFullPath += "/";
}
sheetFullPath += spdxFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(spdxFileInfo.getLogiNm())+".yaml";
String resultFileName = FilenameUtils.getBaseName(spdxFileInfo.getOrigNm())+".yaml";
String tagFullPath = spdxFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
SPDXUtil2.convert(project.getPrjId(), sheetFullPath, tagFullPath);
File spdxYamlFile = new File(tagFullPath);
if (spdxYamlFile.exists() && spdxYamlFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("spdx.yaml.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setSpdxYamlFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
// cycloneDX
String cdxJsonFileId = null;
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadCDXJsonYn())) {
if (isEmpty(cdxJsonFileId)) {
cdxJsonFileId = ExcelDownLoadUtil.getExcelDownloadId("cycloneDXJson", project.getPrjId(), EXPORT_TEMPLATE_PATH, "verify");
}
if (!isEmpty(cdxJsonFileId)) {
T2File jsonFileInfo = fileService.selectFileInfo(cdxJsonFileId);
String jsonFullPath = jsonFileInfo.getLogiPath();
if (!jsonFullPath.endsWith("/")) {
jsonFullPath += "/";
}
jsonFullPath += jsonFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(jsonFileInfo.getLogiNm())+".json";
String resultFileName = FilenameUtils.getBaseName(jsonFileInfo.getOrigNm())+".json";
String tagFullPath = jsonFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
File cdxJsonFile = new File(tagFullPath);
if (cdxJsonFile.exists() && cdxJsonFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("cyclonedx.json.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setCdxJsonFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
String cdxXmlFileId = null;
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadCDXXmlYn())) {
if (isEmpty(cdxXmlFileId)) {
cdxXmlFileId = ExcelDownLoadUtil.getExcelDownloadId("cycloneDXXml", project.getPrjId(), EXPORT_TEMPLATE_PATH, "verify");
}
if (!isEmpty(cdxXmlFileId)) {
T2File xmlFileInfo = fileService.selectFileInfo(cdxXmlFileId);
String xmlFullPath = xmlFileInfo.getLogiPath();
if (!xmlFullPath.endsWith("/")) {
xmlFullPath += "/";
}
xmlFullPath += xmlFileInfo.getLogiNm();
String targetFileName = FilenameUtils.getBaseName(xmlFileInfo.getLogiNm())+".xml";
String resultFileName = FilenameUtils.getBaseName(xmlFileInfo.getOrigNm())+".xml";
String tagFullPath = xmlFileInfo.getLogiPath();
if (!tagFullPath.endsWith("/")) {
tagFullPath += "/";
}
tagFullPath += targetFileName;
File cdxXmlFile = new File(tagFullPath);
if (cdxXmlFile.exists() && cdxXmlFile.length() <= 0) {
if (!isEmpty(spdxComment)) {
spdxComment += "<br>";
}
spdxComment += getMessage("cyclonedx.xml.failure");
}
String filePath = NOTICE_PATH + "/" + project.getPrjId();
FileUtil.moveTo(tagFullPath, filePath, resultFileName);
project.setCdxXmlFileId(fileService.registFileDownload(filePath, resultFileName, resultFileName));
makeZipFile = true;
}
}
// zipํ์ผ ์์ฑ
if (makeZipFile) {
String noticeRootDir = NOTICE_PATH;
ossNotice.setFileType(".zip");
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
String zipFileName = CommonFunction.getNoticeFileName(prjInfo.getPrjId(), prjInfo.getPrjName(), prjInfo.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), ".zip");
FileUtil.zip(noticeRootDir + "/" + project.getPrjId(), noticeRootDir, zipFileName, "OSS Notice");
String zipFileId = fileService.registFileDownload(noticeRootDir, zipFileName, zipFileName);
project.setZipFileId(zipFileId);
}
verificationMapper.updateNoticeFileInfoEtc(project); // file info update
if (!isEmpty(spdxComment)) { // spdx failure => comment regist
try {
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(project.getPrjId());
commHisBean.setContents(spdxComment);
commHisBean.setStatus(CoCodeManager.getCodeExpString(CoConstDef.CD_IDENTIFICATION_STATUS, CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM));
commentService.registComment(commHisBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
@Override
public void changePackageFileNameDistributeFormat(String prjId) {
// ํ๋ก์ ํธ ๊ธฐ๋ณธ์ ๋ณด ์ทจ๋
Project prjBean = new Project();
prjBean.setPrjId(prjId);
prjBean = projectMapper.selectProjectMaster2(prjBean);
List<String> packageFileIds = new ArrayList<String>();
if (!isEmpty(prjBean.getPackageFileId())) {
packageFileIds.add(prjBean.getPackageFileId());
}
if (!isEmpty(prjBean.getPackageFileId2())) {
packageFileIds.add(prjBean.getPackageFileId2());
}
if (!isEmpty(prjBean.getPackageFileId3())) {
packageFileIds.add(prjBean.getPackageFileId3());
}
int fileSeq = 1;
for (String packageFileId : packageFileIds){
T2File packageFileInfo = new T2File();
packageFileInfo.setFileSeq(packageFileId);
packageFileInfo = fileMapper.getFileInfo(packageFileInfo);
if (packageFileInfo != null) {
String orgFileName = packageFileInfo.getOrigNm();
// Packaging > Confirm์ Packaging ํ์ผ๋ช
๋ณ๊ฒฝ ๊ฑด
String paramSeq = (packageFileIds.size() > 1 ? Integer.toString(fileSeq++) : "");
String chgFileName = getPackageFileName(prjBean.getPrjName(), prjBean.getPrjVersion(), packageFileInfo.getOrigNm(), paramSeq);
packageFileInfo.setOrigNm(chgFileName);
fileMapper.upateOrgFileName(packageFileInfo);
// ์ด๋ ฅ์ ๋จ๊ธด๋ค.
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents("Changed File Name (\""+orgFileName+"\") to \""+chgFileName+"\" ");
commentService.registComment(commHisBean);
}
}
}
@Override
public String changePackageFileNameCombine(String prjId) {
String contents = "";
// ํ๋ก์ ํธ ๊ธฐ๋ณธ์ ๋ณด ์ทจ๋
Project prjBean = new Project();
prjBean.setPrjId(prjId);
prjBean = projectMapper.selectProjectMaster2(prjBean);
List<String> packageFileIds = new ArrayList<String>();
if (!isEmpty(prjBean.getPackageFileId())) {
packageFileIds.add(prjBean.getPackageFileId());
}
if (!isEmpty(prjBean.getPackageFileId2())) {
packageFileIds.add(prjBean.getPackageFileId2());
}
if (!isEmpty(prjBean.getPackageFileId3())) {
packageFileIds.add(prjBean.getPackageFileId3());
}
int fileSeq = 1;
for (String packageFileId : packageFileIds){
T2File packageFileInfo = new T2File();
packageFileInfo.setFileSeq(packageFileId);
packageFileInfo = fileMapper.getFileInfo(packageFileInfo);
if (packageFileInfo != null) {
String orgFileName = packageFileInfo.getOrigNm();
// Packaging > Confirm์ Packaging ํ์ผ๋ช
๋ณ๊ฒฝ ๊ฑด
String paramSeq = (packageFileIds.size() > 1 ? Integer.toString(fileSeq++) : "");
String chgFileName = getPackageFileName(prjBean.getPrjName(), prjBean.getPrjVersion(), packageFileInfo.getOrigNm(), paramSeq);
packageFileInfo.setOrigNm(chgFileName);
fileMapper.upateOrgFileName(packageFileInfo);
contents += "<p>Changed File Name (\""+orgFileName+"\") to \""+chgFileName+"\" </p> ";
}
}
return contents;
}
private String getPackageFileName(String prjName, String prjVersion, String orgFileName, String fileSeq) {
String fileName = prjName;
if (!isEmpty(prjVersion)) {
fileName += "_" + prjVersion;
}
if (!isEmpty(fileSeq)){
fileName += "_" + fileSeq;
}
// file๋ช
์ ์ฌ์ฉํ ์ ์๋ ํน์๋ฌธ์ ์ฒดํฌ
if (!FileUtil.isValidFileName(fileName)) {
fileName = FileUtil.makeValidFileName(fileName, "_");
}
String fileExt = FilenameUtils.getExtension(orgFileName);
if (orgFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (orgFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (orgFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
if (fileExt.startsWith(".")) {
fileExt = fileExt.substring(1);
}
return fileName + "." + fileExt;
}
@Override
@Transactional
public Map<String, Object> registOssNotice(OssNotice ossNotice) {
HashMap<String, Object> resMap = new HashMap<>();
String resCd="00";
String resMsg="none.";
try{
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = projectMapper.selectProjectMaster(project);
Map<String, Object> result = projectMapper.getNoticeType(ossNotice.getPrjId());
// android project๋ notice๋ฅผ ์ฌ์ฉํ์ง ์์.
if (!CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equalsIgnoreCase(avoidNull((String) result.get("noticeType")))) {
if (CoConstDef.FLAG_YES.equals(ossNotice.getEditNoticeYn())){
verificationMapper.insertOssNotice(ossNotice);
}else if (CoConstDef.FLAG_NO.equals(ossNotice.getEditNoticeYn())){
verificationMapper.updateOssNotice(ossNotice);
}
}
projectMapper.updateWithoutVerifyYn(ossNotice);
if (isEmpty(project.getVerificationStatus())){
verificationMapper.updateVerificationStatusProgress(ossNotice);
}
resCd="10";
resMsg="process success.";
}catch(Exception e){
log.error(e.getMessage(), e);
resMsg="backend exception error.";
}
resMap.put("resCd", resCd);
resMap.put("resMsg", resMsg);
return resMap;
}
@Override
public String getNoticeHtmlFileForPreview(OssNotice ossNotice) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag());
}
private String getNoticeVelocityTemplateFileForPreview(String contents, Project project, String fileType, String simpleFlag) throws IOException {
return getNoticeVelocityTemplateFileForPreview(contents, project, fileType, simpleFlag, false);
}
private String getNoticeVelocityTemplateFileForPreview(String contents, Project project, String fileType, String simpleFlag, boolean isConfirm) throws IOException {
String fileId = "";
String filePath = "";
String fileName = "";
// Text ํ์ OSS ๊ณ ์ง๋ฌธ ์์ฑ ์ ๊ฐํ๋ฌธ์ ๋ณ๊ฒฝ
// System.getProperty("line.separator") => "\n" => "\r\n" ๋ณ๊ฒฝ
String line = "\r\n";
if (fileType == "text"){
fileId = "";
filePath = NOTICE_PATH + ( isConfirm ? "/" : "/preview/") + project.getPrjId();
fileName = (CoConstDef.FLAG_YES.equals(simpleFlag) ? "simple_" : "") + CommonFunction.getNoticeFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), ( isConfirm ? CommonFunction.getCurrentDateTime("yyMMdd") : DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN) ), fileType);
contents = contents.replace("\n", line).replace(",)", ")").replace("<br>", line).replace("©", "ยฉ").replace(""", "\"").replace("<", "<").replace(">", ">").replace("'", "\'");
} else {
fileId = "";
filePath = NOTICE_PATH + ( isConfirm ? "/" : "/preview/") + project.getPrjId();
fileName = (CoConstDef.FLAG_YES.equals(simpleFlag) ? "simple_" : "") + CommonFunction.getNoticeFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), ( isConfirm ? CommonFunction.getCurrentDateTime("yyMMdd") : DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN) ), fileType);
// custom edit๋ฅผ ์ฌ์ฉํ๊ณ , packaging confirm ์ธ ๊ฒฝ์ฐ ์ด๋ฉด์ simple์ธ ๊ฒฝ์ฐ
// license text ๋ถ๋ถ๋ง ๋ค์ ๋ณ๊ฒฝํ๋ค.
if (isConfirm && CoConstDef.FLAG_YES.equals(simpleFlag) && CoConstDef.FLAG_YES.equals(project.getUseCustomNoticeYn())) {
// ์ด๋ฏธ ์์ฑ๋ ๊ณ ์ง๋ฌธ๊ตฌ ํ์ผ์ ๋ด์ฉ์ ๊ฐ์ ธ์จ๋ค.
T2File defaultNoticeFileInfo = fileService.selectFileInfo(project.getNoticeFileId());
if (defaultNoticeFileInfo != null) {
File noticeFile = new File(defaultNoticeFileInfo.getLogiPath() + "/" + defaultNoticeFileInfo.getLogiNm());
if (noticeFile.exists()) {
Document doc = Jsoup.parse(noticeFile, "UTF8");
Document doc2 = Jsoup.parse(contents);
doc.select("body > p.bdTop.license").remove();
doc.select("body").append(doc2.select("body > p.bdTop.license").toString());
doc.select("body").append(doc2.select("body > ul.bdTop2.license").toString());
contents = doc.toString();
}
}
}
}
if (FileUtil.writeFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
fileId = fileService.registFileDownload(filePath, fileName, fileName);
}
return fileId;
}
@Override
public String getNoticeTextFileForPreview(OssNotice ossNotice) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag());
}
@Override
public String getNoticeTextFileForPreview(OssNotice ossNotice, boolean isConfirm) throws IOException {
Project prjInfo = projectService.getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag(), isConfirm);
}
@Override
public Map<String, Object> getReuseProject(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = null;
try {
int records = projectMapper.selectReuseProjectTotalCount(project);
project.setTotListSize(records);
if (records > 0){
list = projectMapper.selectReuseProject(project);
}
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
} catch (Exception e) {
log.error(e.getMessage());
}
return map;
}
@Override
public Map<String, Object> getReuseProjectPackagingFile(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<T2File> list = null;
try {
if (!isEmpty(project.getPrjId())){
list = projectMapper.selectReusePackagingFileList(project.getPrjId());
}
map.put("rows", list);
map.put("prjId", project.getPrjId());
} catch (Exception e) {
log.error(e.getMessage());
}
return map;
}
@Override
public boolean setReusePackagingFile(Map<String, Object> map) {
String prjId = (String) map.get("prjId");
String fileSeq = (String) map.get("fileSeq");
String refPrjId = (String) map.get("refPrjId");
String refFileSeq = (String) map.get("refFileSeq");
int result = verificationMapper.setPackagingReuseMap(prjId, fileSeq, refPrjId, refFileSeq);
return result > 0 ? true : false;
}
@Override
public ResponseEntity<FileSystemResource> getPackage(String prjId, String path) throws IOException{
T2File fileInfo = verificationMapper.selectPackageFileName(prjId, "");
String filePath = fileInfo.getLogiPath()+"/"+fileInfo.getLogiNm();
return noticeToResponseEntity(filePath, fileInfo.getOrigNm());
}
@Override
public ResponseEntity<FileSystemResource> getPackageMulti(String prjId, String path, String fileIdx) throws IOException{
T2File fileInfo = verificationMapper.selectPackageFileName(prjId, fileIdx);
String filePath = fileInfo.getLogiPath()+"/"+fileInfo.getLogiNm();
return noticeToResponseEntity(filePath, fileInfo.getOrigNm());
}
@Override
public ResponseEntity<FileSystemResource> getNotice(String prjId,
String rESOURCE_PUBLIC_DOWNLOAD_NOTICE_FILE_PATH_PREFIX) throws IOException {
String fileName = "";
String filePath = rESOURCE_PUBLIC_DOWNLOAD_NOTICE_FILE_PATH_PREFIX;
Project project = new Project();
project.setPrjId(prjId);
project = projectMapper.selectProjectMaster(project);
oss.fosslight.domain.File noticeFile = null;
if (!isEmpty(project.getZipFileId())) {
noticeFile = verificationMapper.selectVerificationFile(project.getZipFileId());
fileName = noticeFile.getOrigNm();
filePath += File.separator+fileName;
} else {
noticeFile = verificationMapper.selectVerificationFile(project.getNoticeFileId());
fileName = noticeFile.getOrigNm();
filePath += File.separator+prjId+File.separator+fileName;
}
return noticeToResponseEntity(filePath, fileName);
}
@Override
public ResponseEntity<FileSystemResource> getReviewReport(String prjId,
String rESOURCE_PUBLIC_DOWNLOAD_REVIEW_REPORT_FILE_PATH_PREFIX) throws IOException {
String fileName = "";
String filePath = rESOURCE_PUBLIC_DOWNLOAD_REVIEW_REPORT_FILE_PATH_PREFIX;
Project project = new Project();
project.setPrjId(prjId);
project = projectMapper.selectProjectMaster(project);
oss.fosslight.domain.File reviewReportFile = null;
if (!isEmpty(project.getZipFileId())) {
reviewReportFile = verificationMapper.selectVerificationFile(project.getZipFileId());
fileName = reviewReportFile.getOrigNm();
filePath += File.separator+fileName;
} else {
reviewReportFile = verificationMapper.selectVerificationFile(project.getReviewReportFileId());
fileName = reviewReportFile.getOrigNm();
filePath += File.separator+prjId+File.separator+fileName;
}
return reviewReportToResponseEntity(filePath, fileName);
};
@Override
public Map<String, Object> getNoticeHtmlInfo(OssNotice ossNotice) {
return getNoticeHtmlInfo(ossNotice, false);
}
@Override
public Map<String, Object> getNoticeHtmlInfo(OssNotice ossNotice, boolean isProtocol) {
Map<String, Object> model = new HashMap<String, Object>();
String noticeType = "";
String prjName = "";
String prjVersion = "";
String prjId = "";
String distributeSite = "";
int dashSeq = 0;
boolean hideOssVersionFlag = CoConstDef.FLAG_YES.equals(ossNotice.getHideOssVersionYn());
// NETWORK SERVER ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = projectMapper.getProjectBasicInfo(project);
if (project != null){
if (isEmpty(prjName)) {
prjName = project.getPrjName();
}
if (isEmpty(prjId)) {
prjId = project.getPrjId();
}
if (isEmpty(prjVersion)) {
prjVersion = project.getPrjVersion();
}
if (isEmpty(distributeSite)) {
distributeSite = project.getDistributeTarget();
}
}
List<OssComponents> ossComponentList = verificationMapper.selectVerificationNotice(ossNotice);
// TYPE๋ณ ๊ตฌ๋ถ
Map<String, OssComponents> noticeInfo = new HashMap<>();
Map<String, OssComponents> srcInfo = new HashMap<>();
Map<String, OssComponentsLicense> licenseInfo = new HashMap<>();
Map<String, List<String>> componentCopyright = new HashMap<>();
Map<String, List<String>> componentAttribution = new HashMap<>();
OssComponents ossComponent;
for (OssComponents bean : ossComponentList) {
OssComponents oc = verificationMapper.checkOssNickName2(bean);
if (oc != null) {
OssMaster om = CoCodeManager.OSS_INFO_BY_ID.get(oc.getOssId());
if (om != null) {
String copyright = om.getCopyright();
String homepage = om.getHomepage();
if (isEmpty(bean.getCopyrightText()) && !isEmpty(copyright)) {
bean.setCopyrightText(copyright);
}
if (isEmpty(bean.getHomepage()) && !isEmpty(homepage)) {
bean.setHomepage(homepage);
}
}
}
String componentKey = (hideOssVersionFlag
? bean.getOssName()
: bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
// type
boolean isDisclosure = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType());
// 2017.05.16 add by yuns start
// obligation์ ํน์ ํ ์ ์๋ oss๋ bom์ merge ๋๋๋ก ์์ ํ๋ฉด์, identification confirm์ refDiv๊ฐ '50'(๊ณ ์ง๋์)์ obligation์ ํน์ ํ ์ ์๋ oss๋ ํฌํจ๋์ด ๋ฑ๋ก๋์ด
// confirm ์ฒ๋ฆฌ์์ obligation์ด ๊ณ ์ง์๋ฌด๊ฐ ์๊ฑฐ๋ ์์ค์ฝ๋ ๊ณต๊ฐ์๋ฌด๊ฐ ์๋ ๊ฒฝ์ฐ๋ง '50'์ผ๋ก copy๋๋๋ก ์์ ํ์์ผ๋, ์ฌ๊ธฐ์ ํ๋ฒ๋ ํํฐ๋งํจ
boolean isNotice = CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType());
if (!isDisclosure && !isNotice) {
continue;
}
// 2017.07.05
// Accompanied with source code ์ ๊ฒฝ์ฐ
// ์์ค๊ณต๊ฐ์ฌ๋ถ์ ์๊ด์์ด ๋ชจ๋ ์์ค๊ณต๊ฐ๊ฐ ํ์ํ oss table์ ํ์
if (CoConstDef.CD_DTL_NOTICE_TYPE_ACCOMPANIED.equals(ossNotice.getNoticeType())) {
isDisclosure = true;
}
// 2017.05.16 add by yuns end
boolean addDisclosure = isDisclosure && srcInfo.containsKey(componentKey);
boolean addNotice = !isDisclosure && noticeInfo.containsKey(componentKey);
if (addDisclosure) {
ossComponent = srcInfo.get(componentKey);
} else if (addNotice) {
ossComponent = noticeInfo.get(componentKey);
} else {
ossComponent = bean;
}
if (hideOssVersionFlag) {
List<String> copyrightList = componentCopyright.containsKey(componentKey)
? (List<String>) componentCopyright.get(componentKey)
: new ArrayList<>();
List<String> attributionList = componentAttribution.containsKey(componentKey)
? (List<String>) componentAttribution.get(componentKey)
: new ArrayList<>();
if (!isEmpty(bean.getCopyrightText())) {
for (String copyright : bean.getCopyrightText().split("\n")) {
copyrightList.add(copyright);
}
}
if (!isEmpty(bean.getOssAttribution())) {
attributionList.add(bean.getOssAttribution());
}
// ๋ผ์ด์ ์ค ์ ๋ณด ์์ฑ
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
}
if (CoConstDef.FLAG_NO.equals(bean.getAdminCheckYn())) {
String ossCopyright = findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright());
// multi license ์ถ๊ฐ copyright
if (!isEmpty(ossCopyright)) {
for (String copyright : ossCopyright.split("\n")) {
copyrightList.add(copyright);
}
}
}
// ์ค๋ณต์ ๊ฑฐ
copyrightList = copyrightList.stream()
.filter(CommonFunction.distinctByKey(c -> avoidNull(c).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setCopyrightText(String.join("\r\n", copyrightList));
componentCopyright.put(componentKey, copyrightList);
attributionList = attributionList.stream()
.filter(CommonFunction.distinctByKey(a -> avoidNull(a).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setOssAttribution(String.join("\r\n", attributionList));
componentAttribution.put(componentKey, attributionList);
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(license.getLicenseName(), license);
}
} else {
// ๋ผ์ด์ ์ค ์ ๋ณด ์์ฑ
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
// ํ๋์ oss์ ๋ํด์ ๋์ผํ LICENSE๊ฐ ๋ณต์ ํ์๋๋ ํ์
// ์ผ๋จ ์ฌ๊ธฐ์ ๋ง๋๋ค. (์ฟผ๋ฆฌ๊ฐ ์๋ชป๋ ๊ฑด์ง, DATA๊ฐ ๊ผฌ์ด๋๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์)
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
// OSS์ Copyright text๋ฅผ ์์ ํ์์์๋ Packaging > Notice Preview์ ์
๋ฐ์ดํธ ์ ๋จ.
// MULTI LICENSE๋ฅผ ๊ฐ์ง๋ oss์ ๊ฐ๋ณ๋ก ์ถ๊ฐ๋ copyright์ ๊ฒฝ์ฐ, Identification Confirm์์ DB์ ์
๋ฐ์ดํธํ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ถ์ถ๋๊ธฐ ๋๋ฌธ์, preview ๋จ๊ณ์์ ์ค๋ฅ๊ฐ ๋ฐ๊ฒฌ๋์ด ์์ ํ์ฌ๋ ๋ฐ์๋์ง ์๋๋ค
// verification๋จ๊ณ์์์ oss_component_license๋ oss_license์ license๋ฑ๋ก ์๋ฒ์ ๊ฐ์ง๊ณ ์์ง ์๊ธฐ ๋๋ฌธ์ (exclude๋ license๋ ์ด๊ดํ์ง ์์)
// ์ฌ๊ธฐ์ oss id์ license id๋ฅผ ์ด์ฉํ์ฌ ์ฐพ๋๋ค.
// ๋์ดํ ๋ผ์ด์ ์ค๋ฅผ or ๊ตฌ๋ถ์ผ๋ก ์ฌ๋ฌ๋ฒ ์ ์ํ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ ์ ์์ผ๋, ๋์ผํ oss์ ๋์ผํ license์ ๊ฒฝ์ฐ ๊ฐ์ copyright๋ฅผ ์ถ๊ฐํ๋ค๋ ์ ์ ํ์ ์ ์ฉํจ (์ด๋ถ๋ถ์์ ์ถ๊ฐ์ ์ธ ์ด์๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ ๋์๋ฐฉ๋ฒ์ด ๋ณต์กํด์ง)
if (CoConstDef.FLAG_NO.equals(ossComponent.getAdminCheckYn())) {
bean.setOssCopyright(findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright()));
// multi license ์ถ๊ฐ copyright
if (!isEmpty(bean.getOssCopyright())) {
String addCopyright = avoidNull(ossComponent.getCopyrightText());
if (!isEmpty(ossComponent.getCopyrightText())) {
addCopyright += "\r\n";
}
addCopyright += bean.getOssCopyright();
ossComponent.setCopyrightText(addCopyright);
}
}
}
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(license.getLicenseName(), license);
}
}
}
// copyleft์ ์กด์ฌํ ๊ฒฝ์ฐ notice์์๋ ์ถ๋ ฅํ์ง ์๊ณ copyleft๋ก mergeํจ.
if (hideOssVersionFlag) {
Map<String, OssComponents> hideOssVersionMergeNoticeInfo = new HashMap<>();
Set<String> noticeKeyList = noticeInfo.keySet();
for (String key : noticeKeyList) {
if (!srcInfo.containsKey(key)) {
hideOssVersionMergeNoticeInfo.put(key, noticeInfo.get(key));
}
}
noticeInfo = hideOssVersionMergeNoticeInfo;
}
// CLASS ํ์ผ๋ง ๋ฑ๋กํ ๊ฒฝ์ฐ ๋ผ์ด์ ์ค ์ ๋ณด๋ง ์ถ๊ฐํ๋ค.
// OSS NAME์ ํ์ดํ ('-') ์ผ๋ก ๋ฑ๋กํ ๊ฒฝ์ฐ (๊ณ ์ง๋ฌธ๊ตฌ์ ๋ผ์ด์ ์ค๋ง ์ถ๊ฐ)
List<OssComponents> addOssComponentList = verificationMapper.selectVerificationNoticeClassAppend(ossNotice);
if (addOssComponentList != null) {
List<String> checkKeyInfo = new ArrayList<>();
for (OssComponents bean : addOssComponentList) {
String componentKey = (hideOssVersionFlag
? bean.getOssName()
: bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
String checkKey = (hideOssVersionFlag
? bean.getOssName() + "|" + bean.getLicenseName()
: bean.getOssName() + "|" + bean.getOssVersion() + "|" + bean.getLicenseName()).toUpperCase();
if (checkKeyInfo.contains(checkKey)) {
continue;
}
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
bean.addOssComponentsLicense(license);
if (CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType())
|| CoConstDef.CD_DTL_NOTICE_TYPE_ACCOMPANIED.equals(ossNotice.getNoticeType())) { // Accompanied with source code ์ ๊ฒฝ์ฐ source ๊ณต๊ฐ ์๋ฌด
srcInfo.put(componentKey, bean);
} else {
noticeInfo.put(componentKey, bean);
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(componentKey, license);
}
checkKeyInfo.add(checkKey);
}
}
boolean isTextNotice = "text".equals(ossNotice.getFileType());
Map<String, String> ossAttributionMap = new HashMap<>();
// ๊ฐํ์ฒ๋ฆฌ ๋ฐ velocity์ฉ list ์์ฑ
List<OssComponents> noticeList = new ArrayList<>();
for (OssComponents bean : noticeInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
if (isProtocol && !isEmpty(bean.getHomepage()) && !bean.getHomepage().contains("://")) bean.setHomepage("http://" + bean.getHomepage());
noticeList.add(bean);
}
Collections.sort(noticeList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> srcList = new ArrayList<>();
for (OssComponents bean : srcInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
if (isProtocol && !bean.getHomepage().contains("://")) bean.setHomepage("//" + bean.getHomepage());
srcList.add(bean);
}
Collections.sort(srcList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponentsLicense> licenseList = new ArrayList<>();
List<OssComponentsLicense> licenseListUrls = new ArrayList<>(); //simple version์ฉ
List<OssComponentsLicense> attributionList = new ArrayList<>();
List<String> ossAttributionList = new ArrayList<>();
// ์ ๋ ฌ
TreeMap<String, OssComponentsLicense> licenseTreeMap = new TreeMap<>( licenseInfo );
for (OssComponentsLicense bean : licenseTreeMap.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
}
// ๋ฐฐํฌ์ฌ์ดํธ license text url
licenseList.add(bean);
if (CoConstDef.FLAG_YES.equals(ossNotice.getSimpleNoticeFlag())) {
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_BY_ID.get(bean.getLicenseId());
if (licenseBean != null) {
// String simpleLicenseFileName = !isEmpty(licenseBean.getShortIdentifier()) ? licenseBean.getShortIdentifier() : licenseBean.getLicenseNameTemp();
// String distributeUrl = CoCodeManager.getCodeExpString(CoConstDef.CD_DISTRIBUTE_CODE, CoConstDef.CD_DTL_DISTRIBUTE_LGE);
// simpleLicenseFileName = simpleLicenseFileName.replaceAll(" ", "_").replaceAll("/", "_") + ".html";
// distributeUrl += "/license/" + simpleLicenseFileName;
boolean distributionFlag = CommonFunction.propertyFlagCheck("distribution.use.flag", CoConstDef.FLAG_YES);
licenseBean.setDomain(ossNotice.getDomain());
bean.setWebpage(CommonFunction.makeLicenseInternalUrl(licenseBean, distributionFlag));
licenseListUrls.add(bean);
}
}
if (!isEmpty(bean.getAttribution())) {
bean.setAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getAttribution()))));
attributionList.add(bean);
}
}
TreeMap<String, String> ossAttributionTreeMap = new TreeMap<>( ossAttributionMap );
ossAttributionList.addAll(ossAttributionTreeMap.values());
// ๋ฐฐํฌ ์ฌ์ดํธ ๊ตฌ๋ถ์ ๋ฐ๋ผ ์ฐธ์กฐ ์ฝ๋๊ฐ ๋ฌ๋ผ์ง
String noticeInfoCode = CoConstDef.CD_DTL_DISTRIBUTE_SKS.equals(avoidNull(distributeSite, CoConstDef.CD_DTL_DISTRIBUTE_LGE)) ? CoConstDef.CD_NOTICE_DEFAULT_SKS : CoConstDef.CD_NOTICE_DEFAULT;
noticeType = avoidNull(ossNotice.getNoticeType(), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL);
String companyNameFull = ossNotice.getCompanyNameFull();
String distributionSiteUrl = ossNotice.getDistributionSiteUrl();
String email = ossNotice.getEmail();
String appendedContentsTEXT = ossNotice.getAppendedTEXT();
String appendedContents = ossNotice.getAppended();
if (!isEmpty(distributionSiteUrl) && !(distributionSiteUrl.startsWith("http://") || distributionSiteUrl.startsWith("https://") || distributionSiteUrl.startsWith("ftp://"))) {
distributionSiteUrl = "http://" + distributionSiteUrl;
}
model.put("noticeType", noticeType);
model.put("noticeTitle", CommonFunction.getNoticeFileName(prjId, prjName, prjVersion, CommonFunction.getCurrentDateTime("yyMMdd"), ossNotice.getFileType()));
model.put("companyNameFull", companyNameFull);
model.put("distributionSiteUrl", distributionSiteUrl);
model.put("email", email);
model.put("noticeObligationSize", noticeList.size());
model.put("disclosureObligationSize", srcList.size());
model.put("noticeObligationList", noticeList);
model.put("disclosureObligationList", srcList);
/* ui ๊ฐ์ ๋ฒ์ ์ผ๋ก ์ ๊ท ์ถ๊ฐ๋ flag */
model.put("editNoticeYn", ossNotice.getEditNoticeYn());
model.put("editCompanyYn", ossNotice.getEditCompanyYn());
model.put("editDistributionSiteUrlYn", ossNotice.getEditDistributionSiteUrlYn());
model.put("editEmailYn", ossNotice.getEditEmailYn());
model.put("hideOssVersionYn", ossNotice.getHideOssVersionYn());
model.put("editAppendedYn", ossNotice.getEditAppendedYn());
/*//ui ๊ฐ์ ๋ฒ์ ์ผ๋ก ์ ๊ท ์ถ๊ฐ๋ flag */
if (CoConstDef.FLAG_YES.equals(ossNotice.getSimpleNoticeFlag())) {
model.put("licenseListUrls", licenseListUrls);
} else {
model.put("licenseList", licenseList);
}
model.put("attributionList", attributionList.isEmpty() ? null : attributionList);
model.put("ossAttributionList", ossAttributionList.isEmpty() ? null : ossAttributionList);
if ("text".equals(ossNotice.getFileType())){
model.put("appended", avoidNull(appendedContentsTEXT, "").replaceAll(" ", " "));
} else {
model.put("appended", appendedContents);
}
if ("text".equals(ossNotice.getFileType())){
model.put("templateURL", CoCodeManager.getCodeExpString(noticeInfoCode, CoConstDef.CD_DTL_NOTICE_TEXT_TEMPLATE));
} else {
model.put("templateURL", CoCodeManager.getCodeExpString(noticeInfoCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_TEMPLATE));
}
model.put("addOssComponentList", addOssComponentList);
model.put("isSimpleNotice", avoidNull(ossNotice.getIsSimpleNotice(), CoConstDef.FLAG_NO));
return model;
}
private boolean checkLicenseDuplicated(List<OssComponentsLicense> ossComponentsLicense,
OssComponentsLicense license) {
if (ossComponentsLicense != null) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseId().equals(license.getLicenseId())) {
return true;
}
}
}
return false;
}
/**
* multi license oss์ ๊ฒฝ์ฐ์ ํด๋นํ๋ฉฐ, oss master์ ์ถ๊ฐ๋ license๋ณ copyright์ ๋ณด๋ฅผ ๋ฐํํ๋ค.
* @param ossId
* @param licenseId
* @param ossCopyright
* @return
*/
private String findAddedOssCopyright(String ossId, String licenseId, String ossCopyright) {
if (!isEmpty(ossId) && !isEmpty(licenseId)) {
OssMaster bean = CoCodeManager.OSS_INFO_BY_ID.get(ossId);
if (bean != null) {
for (OssLicense license : bean.getOssLicenses()) {
if (licenseId.equals(license.getLicenseId()) && !isEmpty(license.getOssCopyright())) {
return license.getOssCopyright();
}
}
}
}
return ossCopyright;
}
@Override
public Map<String, Integer> setAddFileCount(Map<String, Integer> deCompResultMap, String url, int fileCnt) {
try {
url = url.substring(0, url.lastIndexOf("/"));
int pFileCnt = deCompResultMap.get(url);
deCompResultMap.put(url, fileCnt + pFileCnt);
if (deCompResultMap.get(url.substring(0, url.lastIndexOf("/"))) != null){
setAddFileCount(deCompResultMap, url, fileCnt);
}
return deCompResultMap;
} catch (Exception e) {
return deCompResultMap;
}
}
@Override
public List<String> sortByValue(Map<String, Integer> map) throws Exception {
List<String> list = new ArrayList<String>();
list.addAll(map.keySet());
Collections.sort(list, new Comparator<Object>(){
public int compare(Object o1,Object o2){
int o1_depth = o1.toString().split("/").length;
int o2_depth = o2.toString().split("/").length;
return o1_depth-o2_depth;
}
});
return list;
}
@Override
public List<OssComponents> setMergeGridData(List<OssComponents> gridData) {
List<OssComponents> tempData = new ArrayList<OssComponents>();
List<OssComponents> resultGridData = new ArrayList<OssComponents>();
String groupColumn = "";
final Comparator<OssComponents> comp = Comparator.comparing((OssComponents o) -> o.getOssName()+"|"+o.getOssVersion());
gridData = gridData.stream().sorted(comp).collect(Collectors.toList());
for (OssComponents info : gridData) {
if (isEmpty(groupColumn)) {
groupColumn = info.getOssName() + "-" + info.getOssVersion();
}
if (groupColumn.equals(info.getOssName() + "-" + info.getOssVersion()) // ๊ฐ์ groupColumn์ด๋ฉด ๋ฐ์ดํฐ๋ฅผ ์์
&& !("-".equals(info.getOssName())
&& !"NA".equals(info.getLicenseType()))) { // ๋จ, OSS Name: - ์ด๋ฉด์, License Type: Proprietary์ด ์๋ ๊ฒฝ์ฐ Row๋ฅผ ํฉ์น์ง ์์.
tempData.add(info);
} else { // ๋ค๋ฅธ grouping
setMergeData(tempData, resultGridData);
groupColumn = info.getOssName() + "-" + info.getOssVersion();
tempData.clear();
tempData.add(info);
}
}
setMergeData(tempData, resultGridData);
return resultGridData;
}
public static void setMergeData(List<OssComponents> tempData, List<OssComponents> resultGridData){
if (tempData.size() > 0) {
Collections.sort(tempData, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents o1, OssComponents o2) {
if (o1.getLicenseName().length() >= o2.getLicenseName().length()) {
return 1;
}else {
return -1;
}
}
});
OssComponents rtnBean = null;
for (OssComponents temp : tempData) {
if (rtnBean == null) {
rtnBean = temp;
continue;
}
String key = temp.getOssName() + "-" + temp.getLicenseType();
if ("--NA".equals(key)) {
if (!rtnBean.getLicenseName().contains(temp.getLicenseName())) {
resultGridData.add(rtnBean);
rtnBean = temp;
continue;
}
}
for (String licenseName : temp.getLicenseName().split(",")) {
boolean equalFlag = false;
for (String rtnLicenseName : rtnBean.getLicenseName().split(",")) {
if (rtnLicenseName.equals(licenseName)) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
rtnBean.setLicenseName(rtnBean.getLicenseName() + "," + licenseName);
}
}
}
resultGridData.add(rtnBean);
}
}
@Override
public void setUploadFileSave(String prjId, String fileSeq, String registFileId) throws Exception {
Project prjParam = new Project();
prjParam.setPrjId(prjId);
Project project = projectMapper.selectProjectMaster(prjParam);
if (fileSeq.equals("4")) {
prjParam.setPackageVulDocFileId(registFileId);
verificationMapper.updatePackageVulDocFile(prjParam);
} else {
if (fileSeq.equals("1")) {
prjParam.setPackageFileId(registFileId);
prjParam.setPackageFileId2(project.getPackageFileId2() != null ? project.getPackageFileId2() : null);
prjParam.setPackageFileId3(project.getPackageFileId3() != null ? project.getPackageFileId3() : null);
}else if (fileSeq.equals("2")) {
prjParam.setPackageFileId(project.getPackageFileId() != null ? project.getPackageFileId() : null);
prjParam.setPackageFileId2(registFileId);
prjParam.setPackageFileId3(project.getPackageFileId3() != null ? project.getPackageFileId3() : null);
}else {
prjParam.setPackageFileId(project.getPackageFileId() != null ? project.getPackageFileId() : null);
prjParam.setPackageFileId2(project.getPackageFileId2() != null ? project.getPackageFileId2() : null);
prjParam.setPackageFileId3(registFileId);
}
List<String> fileSeqs = new ArrayList<String>();
if (prjParam.getPackageFileId() != null) {
fileSeqs.add(prjParam.getPackageFileId());
}
if (prjParam.getPackageFileId2() != null) {
fileSeqs.add(prjParam.getPackageFileId2());
}
if (prjParam.getPackageFileId3() != null) {
fileSeqs.add(prjParam.getPackageFileId3());
}
Map<Object, Object> map = new HashMap<Object, Object>();
map.put("prjId", prjId);
map.put("fileSeqs", fileSeqs);
String packagingComment = "";
try {
packagingComment = fileService.setClearFiles(map);
}catch(Exception e) {
log.error(e.getMessage(), e);
}
prjParam.setStatusVerifyYn("N");
// project_master packageFileId update
verificationMapper.updatePackageFile(prjParam);
// commentHistory regist
if (!packagingComment.equals("")) {
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents(packagingComment);
commentService.registComment(commHisBean, false);
}
}
}
@Override
public void updateProjectAllowDownloadBitFlag(Project project) {
project.setAllowDownloadBitFlag(allowDownloadMultiFlagToBitFlag(project));
projectMapper.updateProjectAllowDownloadBitFlag(project);
}
public int allowDownloadMultiFlagToBitFlag(Project project) {
int bitFlag = 1;
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadNoticeHTMLYn())) {
bitFlag |= CoConstDef.FLAG_A;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadNoticeTextYn())) {
bitFlag |= CoConstDef.FLAG_B;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleHTMLYn())) {
bitFlag |= CoConstDef.FLAG_C;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleTextYn())) {
bitFlag |= CoConstDef.FLAG_D;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXSheetYn())) {
bitFlag |= CoConstDef.FLAG_E;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXRdfYn())) {
bitFlag |= CoConstDef.FLAG_F;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXTagYn())) {
bitFlag |= CoConstDef.FLAG_G;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXJsonYn())) {
bitFlag |= CoConstDef.FLAG_H;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXYamlYn())) {
bitFlag |= CoConstDef.FLAG_I;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadCDXJsonYn())) {
bitFlag |= CoConstDef.FLAG_J;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadCDXXmlYn())) {
bitFlag |= CoConstDef.FLAG_K;
}
return bitFlag;
}
@Override
public void registOssNoticeConfirmStatus(OssNotice ossNotice) {
try{
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = projectMapper.selectProjectMaster(project);
// android project๋ notice๋ฅผ ์ฌ์ฉํ์ง ์์.
if (!CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equalsIgnoreCase(project.getNoticeType())) {
verificationMapper.insertOssNotice(ossNotice);
}
if (isEmpty(project.getVerificationStatus())){
verificationMapper.updateVerificationStatusProgress(ossNotice);
}
}catch(Exception e){
log.error(e.getMessage(), e);
}
}
@Override
public void deleteFile(Map<Object, Object> map) {
String delFileSeq = (String) map.get("delFileSeq");
String prjId = (String) map.get("prjId");
T2File file = fileService.selectFileInfo(delFileSeq);
// delete logical file
fileMapper.updateFileDelYn(new String[] {delFileSeq});
// delete physical file
fileService.deletePhysicalFile(file, "VERIFY");
// update file id
Project project = new Project();
project.setPrjId(prjId);
project.setPackageVulDocFileId(null);
verificationMapper.updatePackageVulDocFile(project);
}
}
| 107,315 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
MailServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/MailServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.mail.internet.MimeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.History;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2Users;
import oss.fosslight.repository.HistoryMapper;
import oss.fosslight.repository.MailManagerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.service.MailService;
import oss.fosslight.service.T2UserService;
import oss.fosslight.util.StringUtil;
@Service
@Slf4j
public class MailServiceImpl extends CoTopComponent implements MailService {
//Service
@Autowired T2UserService userService;
JavaMailSender mailSender;
// Mapper
@Autowired MailManagerMapper mailManagerMapper;
@Autowired HistoryMapper historyMapper;
@Autowired ProjectMapper projectMapper;
public void sendMailRunTimeout(){
mailManagerMapper.updateSendMailRunTimeout(new CoMail());
}
@Override
public void sendMail(History h, String[] receiverId, String[] ccIds, String[] bccIds) {
CoMail receiverInfo = new CoMail();
receiverInfo.setToIds(selectMailAddrFromIds(receiverId)); // ์์ ์ธ ๋ฉ์ผ ์ฃผ์
if (ccIds != null && ccIds.length != 0) {
selectMailAddrFromIds(ccIds); // ์ฐธ์กฐ ๋ฉ์ผ ์ฃผ์
}
if (bccIds != null && bccIds.length != 0) {
selectMailAddrFromIds(bccIds); // ์จ์์ฐธ์กฐ ๋ฉ์ผ ์ฃผ์
}
sendProcessor(h, receiverInfo);
};
@Override
public String[] selectMailAddrFromIds(String[] toIds) {
Map<String, String[]> param = new HashMap<String, String[]>();
param.put("idArr", toIds);
List<String> mailList = mailManagerMapper.selectMailAddrFromIds(param);
String[] results = new String[mailList.size()];
return mailList.toArray(results);
}
public void sendProcessor(History h, CoMail rcvInfo){
// History mailInfo = historyMapper.selectOneHistoryData(h);// ๋ฐ์์จ History์ idx๋ก ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๋ค.
// Map<String, Object> mailData = new HashMap<String, Object>();
//
// // ์์ ์ ๊ฒฝ์ฐ ๋น๊ต๋ฐ์ดํฐ
// if ("UPDATE".equals(mailInfo.gethAction())){
// mailData = getAsToBeHistoryData(mailInfo);
// } else {
// mailData = toMailData(mailInfo);
// }
CoMail coMail = new CoMail(); // ๋ฉ์ผ ๋ฐ์ดํฐ
coMail.setToIds(rcvInfo.getToIds()); // ์์
coMail.setCcIds(rcvInfo.getCcIds()); // ์ฐธ์กฐ
coMail.setBccIds(rcvInfo.getBccIds()); // ์จ์์ฐธ์กฐ
mailManagerMapper.insertEmailHistory(coMail);
new Thread(() -> sendEmail(coMail)).start();
}
// History์ด์ ๋ฐ์ดํฐ์ ํ์ฌ ๋ฐ์ดํฐ๋ฅผ ๋น๊ตํฉ๋๋ค.
@SuppressWarnings("unchecked")
public Map<String,Object> getAsToBeHistoryData(History history){
History afterData = historyMapper.selectOneHistoryData(history); // ํ์ฌ History(๊ธฐ์ค)
History beforeData = historyMapper.selectOneHistoryBeforeData(afterData); // ์ด์ History
Map<String, Object> beforeMap = beforeData != null ? ((Map<String, Object>)fromJson((String) beforeData.gethData(), Map.class)) : null;
Map<String, Object> afterMap = afterData != null ? ((Map<String, Object>)fromJson((String) afterData.gethData(), Map.class)) : null;
Map<String, Object> asTbl = new HashMap<String, Object>();
Map<String, Object> beTbl = new HashMap<String, Object>();
List<Map<String, Object>> asSubList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> beSubList = new ArrayList<Map<String, Object>>();
// Data : dtlCd
// Param : String CD_NO
// Result : Vector [ String CD_DTL_NO, String CD_DTL_NM(Key), String CD_SUB_NO(Ref Entity) ]
String cdNm = afterData != null ? afterData.gethType() : null;
for (String[] dtlCd : CoCodeManager.getValues(cdNm)){
Object beforeD_ = getDataForType(cdNm, dtlCd, beforeMap);
Object afterD_ = getDataForType(cdNm, dtlCd, afterMap);
// main data
if (beforeD_ instanceof String && afterD_ instanceof String) {
log.debug("String value : " + dtlCd[1]);
String bStr = beforeD_.toString();
String aStr = afterD_.toString();
// ๊ฐ์ด ์์ ๊ฒฝ์ฐ '-'
asTbl.put(dtlCd[1], !StringUtil.isEmpty(bStr) ? bStr : "-");
beTbl.put(dtlCd[1], !StringUtil.isEmpty(aStr) ? aStr : "-");
} else { // sub list data
log.debug("Object Key : " + dtlCd[1]);
asTbl.put(dtlCd[1], "");
beTbl.put(dtlCd[1], "");
asSubList.add((Map<String, Object>)beforeD_);
beSubList.add((Map<String, Object>)afterD_);
}
}
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("before", asTbl);
dataMap.put("after", beTbl);
dataMap.put("bSub", asSubList);
dataMap.put("aSub", beSubList);
dataMap.put("bModifier", beforeData != null ? beforeData.getModifier() : "");
dataMap.put("aModifier", afterData != null ? afterData.getModifier() : "");
dataMap.put("bModifiedDate", beforeData != null ? beforeData.getModifiedDate() : "");
dataMap.put("aModifiedDate", afterData != null ? afterData.getModifiedDate() : "");
if (!StringUtil.isEmpty(beforeData != null ? beforeData.getModifier() : "")) {
T2Users param = new T2Users();
param.setUserId(beforeData.getModifier());
T2Users modifier = userService.getUser(param);
dataMap.put("bModifierNm", modifier.getUserName());
dataMap.put("bModifierMail", modifier.getEmail());
}
if (!StringUtil.isEmpty(beforeData != null ? afterData.getModifier() : "")) {
T2Users param = new T2Users();
param.setUserId(afterData.getModifier());
T2Users modifier = userService.getUser(param);
dataMap.put("aModifierNm", modifier.getUserName());
dataMap.put("aModifierMail", modifier.getEmail());
}
log.debug(dataMap.toString());
return dataMap;
}
// History DTO๋ฅผ ๋ฉ์ผ๋ฐ์ก์ ์ํ HashMap<>์ผ๋ก ๋ณํ
@SuppressWarnings("unchecked")
protected Map<String, Object> toMailData(History history){
Map<String, Object> hMap = history != null ? ((Map<String, Object>)fromJson((String) history.gethData(), Map.class)) : null;
Map<String, Object> mTbl = new HashMap<String, Object>();
List<Map<String, Object>> sTblList = new ArrayList<Map<String, Object>>();
// Data : dtlCd
// Param : String CD_NO
// Result : Vector [ String CD_DTL_NO, String CD_DTL_NM(Key), String CD_SUB_NO(Ref Entity) ]
/*
* hMap ๋งต์์ dtlCd[1]์ ๊ฐ์ ๊ฐ์ ธ์จ๋ค.
*/
String cdNm = history != null ? history.gethType() : null;
CoCodeManager.getValues(cdNm).forEach((dtlCd) -> {
Object d = getDataForType(cdNm, dtlCd, hMap);
// main data
if (d instanceof String) { // d์ Type์ด String์ผ ๊ฒฝ์ฐ
mTbl.put(dtlCd[1], !StringUtil.isEmpty(d.toString()) ? d : "");
} else { // sub list obj
mTbl.put(dtlCd[1], "");
try {
sTblList.add((Map<String, Object>)d);
} catch(Exception e){
log.error("['" + dtlCd[1] + "'] CANNOT TYPE CAST TO 'MAP<String, Object>'. Check this Object.", e);
}
}
});
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("main", mTbl);
dataMap.put("sub", sTblList);
dataMap.put("modifier", history != null ? history.getModifier() : "");
dataMap.put("modifiedDate", history != null ? history.getModifiedDate() : "");
if (!StringUtil.isEmpty(history != null ? history.getModifier() : "")) {
T2Users param = new T2Users();
param.setUserId(history.getModifier());
T2Users modifier = userService.getUser(param);
dataMap.put("modifierNm", modifier.getUserName());
dataMap.put("modifierMail", modifier.getEmail());
}
log.debug(dataMap.toString());
return dataMap;
}
@SuppressWarnings("unchecked")
public Object getDataForType(String cdNm, String[] dtlCd, Map<String, Object> dMap){
Object ret = null;
// EXP : TYPE(String, Code, Array, Object) | NAME | CD_NO
String[] inf = CoCodeManager.getCodeExpString(cdNm, dtlCd[0]).split("\\|");
if (inf[0].equals("String")) {
ret = dMap != null ? escapeSql(nvl((String)dMap.get(dtlCd[1]), "")) : "";
} else if (inf[0].equals("Code")) {
ret = dMap != null ? nvl(CoCodeManager.getCodeString(inf[2], (String)dMap.get(dtlCd[1])), inf[2]) : "";
} else if (inf[0].equals("Array") && dtlCd[2] == null) {
List<String> asArr = dMap != null ? (ArrayList<String>)dMap.get(dtlCd[1]) : null;
ret = asArr != null && asArr.size() > 0 ? String.join(", ", asArr) : "";
} else if (inf[0].equals("Array") && dtlCd[2] != null) {
String sCdNm = dtlCd[2]; // CD_SUB_NO(Ref Entity)
HashMap<String, Object> sTblMap = new HashMap<String, Object>();
// colNames ์์ฑ
List<Map<String, Object>> colNames = new ArrayList<Map<String, Object>>();
// Param : String CD_NO
// Result : Vector&String [ String CD_DTL_NO, String CD_SUB_NO, String CD_DTL_NM, String CD_DTL_NM, String CD_DTL_EXP, String CD_ORDER ]
HashMap<String, Object> colInfo = new HashMap<String, Object>();
colInfo.put("key", "no");
colInfo.put("name", "no");
colInfo.put("order", "0");
colNames.add(colInfo);
for (String[] v : CoCodeManager.getAllValues(sCdNm)){
colInfo = new HashMap<String, Object>();
colInfo.put("key", v[2]);
colInfo.put("name", v[4].split("\\|")[1]);
colInfo.put("order", v[5]);
colNames.add(colInfo);
}
sTblMap.put("type", inf[1]); // model name
sTblMap.put("colNames", colNames); // list columns
// colModel ์์ฑ
List<Map<String, Object>> subList = new ArrayList<Map<String, Object>>();
if (dMap != null && dMap.get(dtlCd[1]) != null){
// sub list ์์ฑ
int sCnt = 1;
for (Map<String, Object> sMap : (List<Map<String, Object>>) dMap.get(dtlCd[1])){
Map<String, Object> sDataMap = new HashMap<String, Object>();
sDataMap.put("no", sCnt++);
// row data ์์ฑ
for (String[] sDtlCd : CoCodeManager.getValues(sCdNm)){
String[] sInf = CoCodeManager.getCodeExpString(sCdNm, sDtlCd[0]).split("\\|"); // EXP : TYPE(String, Code, Array, Object) | NAME | CD_NO
if (sInf[0].equals("String")) {
sDataMap.put(sDtlCd[1], escapeSql(nvl((String)sMap.get(sDtlCd[1]))) );
} else if (sInf[0].equals("Code")) {
sDataMap.put(sDtlCd[1], CoCodeManager.getCodeString(sInf[1], (String)sMap.get(sDtlCd[1])) );
}
}
subList.add(sDataMap);
}
}
sTblMap.put("subList", subList);
ret = sTblMap;
}
return ret;
}
public String escapeSql(String str){
return str == null ? "null" : String.format("%s", str.replace("'", "\\'").replace("\n", "\\n").replace("\r", "\\r").replace("\"", "\\\""));
}
/** ๋ฉ์ผ ๋ฐ์ก **/
public void sendEmail(CoMail coMail) {
// Send Email Info Setting
try {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(coMail.getEmlFrom());
helper.setTo(coMail.getToIds());
helper.setCc(coMail.getCcIds() != null ? coMail.getCcIds() : new String[]{});
helper.setBcc(coMail.getBccIds() != null ? coMail.getBccIds() : new String[]{});
helper.setSubject(coMail.getEmlTitle());
helper.setText(coMail.getEmlMessage(), true);
// Email Send
mailSender.send(message);
// Email History Status Update
coMail.setSndStatus("C"); // ์ ์ก์๋ฃ
mailManagerMapper.updateSendStatus(coMail);
} catch(Exception e) {
log.error(e.getMessage());
coMail.setSndStatus("F"); // ์ ์ก์คํจ
coMail.setErrorMsg(e.getMessage());
mailManagerMapper.updateErrorMsg(coMail);
}
}
public void sendTempMail() {
List<Map<String, Object>> tempMailList = mailManagerMapper.getTempMail();
for (Map<String, Object> mailMap : tempMailList) {
String mailType = (String) mailMap.get("mailType");
String mailSeq = (String) mailMap.get("mailSeq");
CoMail mailBean = new CoMail(mailType);
switch(mailType) {
// BAT Thread return mail
case CoConstDef.CD_MAIL_TYPE_BAT_COMPLETE:
case CoConstDef.CD_MAIL_TYPE_BAT_ERROR:
mailBean.setModifier((String) mailMap.get("modifier"));
mailBean.setCreationUserId((String) mailMap.get("creator"));
mailBean.setParamBatId((String) mailMap.get("paramBatId"));
mailBean.setToIds(new String[] {(String) mailMap.get("toIds")});
CoMailManager.getInstance().sendMail(mailBean);
break;
// Distribution process mail
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE:
mailBean.setParamPrjId((String) mailMap.get("paramPrjId"));
mailBean.setParamExpansion1((String) mailMap.get("paramExpansion1"));
mailBean.setParamExpansion2((String) mailMap.get("paramExpansion2"));
mailBean.setParamExpansion3((String) mailMap.get("paramExpansion3"));
CoMailManager.getInstance().sendMail(mailBean);
break;
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_REJECT:
String prjId = (String) mailMap.get("paramPrjId");
Project prjBean = new Project();
prjBean.setPrjId(prjId);
prjBean = projectMapper.selectProjectMaster2(prjBean);
mailBean.setParamPrjId(prjId);
mailBean.setComment((String) mailMap.get("comment"));
mailBean.setParamPrjInfo(prjBean);
CoMailManager.getInstance().sendMail(mailBean);
break;
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE:
mailBean.setJobType((String) mailMap.get("jobType"));
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_CANCELED:
mailBean.setParamPrjId((String) mailMap.get("paramPrjId"));
CoMailManager.getInstance().sendMail(mailBean);
break;
}
mailManagerMapper.deleteTempMail(mailSeq);
}
}
}
| 14,586 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiOssServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiOssServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.repository.ApiOssMapper;
import oss.fosslight.service.*;
import oss.fosslight.util.StringUtil;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ApiOssServiceImpl extends CoTopComponent implements ApiOssService{
/** The api oss mapper. */
@Autowired ApiOssMapper apiOssMapper;
@Autowired OssService ossService;
@Autowired HistoryService historyService;
@Override
public List<Map<String, Object>> getOssInfo(Map<String, Object> paramMap) {
String rtnOssName = apiOssMapper.getOssName((String) paramMap.get("ossName"));
if (!StringUtil.isEmpty(rtnOssName)) {
paramMap.replace("ossName", rtnOssName);
}
return apiOssMapper.getOssInfo(paramMap);
}
@Override
public List<Map<String, Object>> getOssInfoByDownloadLocation(String downloadLocation) {
return apiOssMapper.getOssInfoByDownloadLocation(downloadLocation);
}
@Override
public List<Map<String, Object>> getLicenseInfo(String licenseName) {
return apiOssMapper.getLicenseInfo(licenseName);
}
public String[] getOssNickNameListByOssName(String ossName) {
List<String> nickList = null;
if (!StringUtil.isEmpty(ossName)) {
nickList = apiOssMapper.selectOssNicknameList(ossName);
if (nickList != null) {
nickList = nickList.stream()
.filter(CommonFunction.distinctByKey(nick -> nick.trim().toUpperCase()))
.collect(Collectors.toList());
}
}
nickList = (nickList != null ? nickList : Collections.emptyList());
return nickList.toArray(new String[nickList.size()]);
}
} | 1,973 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SentMailServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/SentMailServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.repository.SentMailMapper;
import oss.fosslight.service.SentMailService;
@Service
public class SentMailServiceImpl extends CoTopComponent implements SentMailService {
// Mapper
@Autowired SentMailMapper sentMailMapper;
@Override
public Map<String, Object> getMailList(CoMail vo) {
Map<String, Object> map = null;
String filterCondition = CommonFunction.getFilterToString(vo.getFilters());
if (!isEmpty(filterCondition)) {
vo.setFilterCondition(filterCondition);
}
int records = sentMailMapper.selectSentMailTotalCount(vo);
if (records > 0) {
vo.setTotListSize(records);
// Grid paging ์ฒ๋ฆฌ๋ฅผ ์ํ ๊ธฐ๋ณธ param ์ค์ Map ์์ฑ(๋ฐ๋์ totlistsize๋ฅผ set ํ๊ณ ๋์ ์์ฑํด์ผํจ)
map = getGridPagerMap(vo);
map.put("rows", sentMailMapper.selectSentMailList(vo));
}
return map == null ? new HashMap<String, Object>() : map;
}
}
| 1,373 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
AutoFillOssInfoServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/AutoFillOssInfoServiceImpl.java | /*
* Copyright (c) 2021 Dongmin Kang
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.reactive.function.client.WebClient;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.common.DependencyType;
import oss.fosslight.common.ExternalLicenseServiceType;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.repository.OssMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.SelfCheckMapper;
import oss.fosslight.service.AutoFillOssInfoService;
import oss.fosslight.service.CommentService;
import oss.fosslight.validation.T2CoValidationConfig;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.ParallelFlux;
import reactor.core.scheduler.Schedulers;
@Service
@Slf4j
public class AutoFillOssInfoServiceImpl extends CoTopComponent implements AutoFillOssInfoService {
// Service
@Autowired CommentService commentService;
@Autowired WebClient webClient;
@Autowired MessageSource messageSource;
// Mapper
@Autowired OssMapper ossMapper;
@Autowired ProjectMapper projectMapper;
@Autowired SelfCheckMapper selfCheckMapper;
@Autowired PartnerMapper partnerMapper;
@Override
public List<ProjectIdentification> checkOssLicenseData(List<ProjectIdentification> componentData, Map<String, String> validMap, Map<String, String> diffMap){
List<ProjectIdentification> resultData = new ArrayList<ProjectIdentification>();
Map<String, Object> ruleMap = T2CoValidationConfig.getInstance().getRuleAllMap();
if (validMap != null) {
for (String key : validMap.keySet()) {
if (key.toUpperCase().startsWith("LICENSENAME")
&& (validMap.get(key).equals(ruleMap.get("LICENSE_NAME.UNCONFIRMED.MSG"))
|| validMap.get(key).equals(ruleMap.get("LICENSE_NAME.REQUIRED.MSG"))
|| validMap.get(key).equals(ruleMap.get("LICENSE_NAME.NOLICENSE.MSG"))
|| validMap.get(key).equals(ruleMap.get("LICENSE_NAME.INCLUDE_MULTI_OPERATE.MSG"))
|| validMap.get(key).equals(ruleMap.get("LICENSE_NAME.INCLUDE_DUAL_OPERATE.MSG"))
|| validMap.get(key).startsWith("Declared"))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
}
}
if (diffMap != null) {
for (String key : diffMap.keySet()) {
if (key.toUpperCase().startsWith("LICENSENAME") &&
(diffMap.get(key).equals(ruleMap.get("LICENSE_NAME.UNCONFIRMED.MSG"))
|| diffMap.get(key).startsWith("Declared")
|| diffMap.get(key).startsWith("Recommended"))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
}
}
return resultData;
}
@SuppressWarnings("unused")
@Override
public Map<String, Object> checkOssLicense(List<ProjectIdentification> ossList){
Map<String, Object> resMap = new HashMap<>();
List<ProjectIdentification> result = new ArrayList<>();
List<String> errors = new ArrayList<>();
// oss name,๊ณผ download location์ด ๋์ผํ oss์ componentId๋ฅผ ๋ฌถ์ด์ List<ProjectIdentification>์ ๋ง๋ฌ
ossList = ossList.stream()
.collect(Collectors.groupingBy(oss -> oss.getOssName() + "-" + oss.getDownloadLocation() + "-" + oss.getOssVersion() + "-" + oss.getLicenseName()))
.values().stream()
.map(list -> {
ProjectIdentification uniqueOss = list.stream().distinct().findFirst().get();
List<String> componentIds = list.stream().map(oss -> oss.getComponentId()).distinct().collect(Collectors.toList());
uniqueOss.setComponentIdList(componentIds);
return uniqueOss;
})
.collect(Collectors.toList());
// external api health check
boolean isGitHubApiHealth = false;
boolean isClearlyDefinedApiHealth = false;
try {
isGitHubApiHealth = isGitHubApiHealth();
} catch (HttpServerErrorException e) {
errors.add(e.getStatusText());
}
try {
isClearlyDefinedApiHealth = isClearlyDefinedApiHealth();
} catch (HttpServerErrorException e) {
errors.add(e.getStatusText());
}
List<String> checkedLicenseList;
for (ProjectIdentification oss : ossList) {
checkedLicenseList = null;
List<ProjectIdentification> prjOssLicenses;
String downloadLocation = oss.getDownloadLocation();
String ossVersion = oss.getOssVersion();
String currentLicense = getLicenseNameSort(oss.getLicenseName());
String checkedLicense = "";
String checkedLicense1 = "";
String checkedLicense2 = "";
String checkedLicense3 = "";
// Search Priority 1. find by oss name and oss version
prjOssLicenses = projectMapper.getOssFindByNameAndVersion(oss);
checkedLicense1 = combineOssLicenses(prjOssLicenses, currentLicense);
if (!downloadLocation.isEmpty()) {
oss.setDownloadLocation(URLDecoder.decode(oss.getDownloadLocation()));
if (oss.getDownloadLocation().contains(";")) {
oss.setDownloadLocation(oss.getDownloadLocation().split(";")[0]);
}
if (oss.getDownloadLocation().startsWith("git@")){
oss.setDownloadLocation(oss.getDownloadLocation().split("@")[1]);
}
if (oss.getDownloadLocation().startsWith("http://")
|| oss.getDownloadLocation().startsWith("https://")
|| oss.getDownloadLocation().startsWith("git://")
|| oss.getDownloadLocation().startsWith("ftp://")
|| oss.getDownloadLocation().startsWith("svn://")) {
oss.setDownloadLocation(oss.getDownloadLocation().split("//")[1]);
}
if (oss.getDownloadLocation().startsWith("www.")) {
oss.setDownloadLocation(oss.getDownloadLocation().substring(5, oss.getDownloadLocation().length()));
}
if (oss.getDownloadLocation().contains(".git")) {
if (oss.getDownloadLocation().endsWith(".git")) {
oss.setDownloadLocation(oss.getDownloadLocation().substring(0, oss.getDownloadLocation().length()-4));
} else {
if (oss.getDownloadLocation().contains("#")) {
oss.setDownloadLocation(oss.getDownloadLocation().substring(0, oss.getDownloadLocation().indexOf("#")));
oss.setDownloadLocation(oss.getDownloadLocation().substring(0, oss.getDownloadLocation().length()-4));
}
}
}
String[] downloadlocationUrlSplit = oss.getDownloadLocation().split("/");
if (downloadlocationUrlSplit[downloadlocationUrlSplit.length-1].indexOf("#") > -1) {
oss.setDownloadLocation(oss.getDownloadLocation().substring(0, oss.getDownloadLocation().indexOf("#")));
}
// Search Priority 2. find by oss download location and version
prjOssLicenses = projectMapper.getOssFindByVersionAndDownloadLocation(oss);
checkedLicense2 = combineOssLicenses(prjOssLicenses, currentLicense);
// Search Priority 3. find by oss download location
prjOssLicenses = projectMapper.getOssFindByDownloadLocation(oss).stream()
.filter(CommonFunction.distinctByKeys(
ProjectIdentification::getOssName,
ProjectIdentification::getLicenseName
))
.collect(Collectors.toList());
checkedLicense3 = combineOssLicenses(prjOssLicenses, currentLicense);
}
oss.setDownloadLocation(downloadLocation);
if (!isEmpty(checkedLicense1)) {
if (!currentLicense.equals(checkedLicense1)) {
String evidence = getMessage("check.evidence.exist.nameAndVersion");
oss.setCheckOssList("Y");
oss.setCheckLicense(checkedLicense1);
oss.setCheckedEvidence(evidence);
oss.setCheckedEvidenceType("DB");
result.add(oss);
}
continue;
}
if (!isEmpty(checkedLicense2)) {
if (!currentLicense.equals(checkedLicense2)) {
String evidence = getMessage("check.evidence.exist.downloadLocationAndVersion");
oss.setCheckOssList("Y");
oss.setCheckLicense(checkedLicense2);
oss.setCheckedEvidence(evidence);
oss.setCheckedEvidenceType("DB");
oss.setDownloadLocation(downloadLocation);
result.add(oss);
}
continue;
}
if (!isEmpty(checkedLicense3)) {
if (!currentLicense.equals(checkedLicense3)) {
String evidence = getMessage("check.evidence.exist.downloadLocation");
oss.setCheckOssList("Y");
oss.setCheckLicense(checkedLicense3);
oss.setCheckedEvidence(evidence);
oss.setCheckedEvidenceType("DB");
oss.setDownloadLocation(downloadLocation);
result.add(oss);
}
continue;
}
// Search Priority 4. find by Clearly Defined And Github API
DependencyType dependencyType = DependencyType.downloadLocationToType(downloadLocation);
if (dependencyType.equals(DependencyType.UNSUPPORTED) || !isExternalServiceEnable()) {
continue;
}
// Search Priority 4-1. Github API : empty oss version and download location
if (ossVersion.isEmpty() && ExternalLicenseServiceType.GITHUB.hasDependencyType(dependencyType) && isGitHubApiHealth) {
Matcher matcher = dependencyType.getPattern().matcher(downloadLocation);
String owner = "", repo = "";
while (matcher.find()) {
owner = matcher.group(3);
repo = matcher.group(4);
}
String requestUri = ExternalLicenseServiceType.githubLicenseRequestUri(owner, repo);
checkedLicense = avoidNull(requestGithubLicenseApi(requestUri));
if (!currentLicense.equals(checkedLicense) && !checkedLicense.equals("NOASSERTION") && !checkedLicense.equals("NONE") && !checkedLicense.isEmpty()) {
String evidence = getMessage("check.evidence.github.downloadLocation");
oss.setCheckOssList("Y");
oss.setCheckLicense(checkedLicense);
oss.setCheckedEvidence(evidence);
oss.setCheckedEvidenceType("GH");
result.add(oss);
continue;
}
}
// Search Priority 4-2. Clearly Defined : oss version and download location
if (!ossVersion.isEmpty() && ExternalLicenseServiceType.CLEARLY_DEFINED.hasDependencyType(dependencyType) && isClearlyDefinedApiHealth) {
Matcher matcher = dependencyType.getPattern().matcher(downloadLocation);
String type = dependencyType.getType();
String provider = dependencyType.getProvider();
String revision = ossVersion;
String namespace = "", name = "";
while (matcher.find()) {
if (dependencyType.equals(DependencyType.MAVEN_CENTRAL) || dependencyType.equals(DependencyType.MAVEN_GOOGLE)) {
namespace = matcher.group(3);
name = matcher.group(4);
} else {
namespace = "-";
name = matcher.group(3);
}
}
String requestUri = ExternalLicenseServiceType.clearlyDefinedLicenseRequestUri(type, provider, namespace, name, revision);
checkedLicense = avoidNull(requestClearlyDefinedLicenseApi(requestUri));
if (!currentLicense.equals(checkedLicense) && !checkedLicense.equals("NOASSERTION") && !checkedLicense.equals("NONE") && !checkedLicense.isEmpty()) {
String evidence = getMessage("check.evidence.clearlyDefined.downloadLocationAndVersion");
oss.setCheckOssList("Y");
oss.setCheckLicense(checkedLicense);
oss.setCheckedEvidence(evidence);
oss.setCheckedEvidenceType("CD");
result.add(oss);
continue;
}
}
}
// TODO : Request at once when using external API(Clearly Defined, Github API)
/* grouping same oss */
final Comparator<ProjectIdentification> comp = (p1, p2) -> p1.getDownloadLocation().compareTo(p2.getDownloadLocation());
// oss name, oss version, oss license, checked license๋ uniqueํ๊ฒ ์ถ๋ ฅ
List<ProjectIdentification> sortedData = result.stream()
.filter(CommonFunction.distinctByKeys(
ProjectIdentification::getOssName,
ProjectIdentification::getOssVersion,
ProjectIdentification::getLicenseName,
ProjectIdentification::getCheckLicense
))
.sorted(comp)
.collect(Collectors.toList());
// oss name, oss version, oss license์ checked license๊ฐ uniqueํ์ง ์๋ค๋ฉด ์ค๋ณต๋ data์ downloadlocation์ ์ ๋ถ ํฉ์ณ์ ์ถ๋ ฅํจ.
for (ProjectIdentification p : sortedData) {
String downloadLocation = result.stream()
.filter(e -> e.getOssName().equals(p.getOssName()))
.filter(e -> e.getOssVersion().equals(p.getOssVersion()))
.filter(e -> e.getLicenseName().equals(p.getLicenseName()))
.filter(e -> e.getCheckLicense().equals(p.getCheckLicense()))
.map(e -> e.getDownloadLocation())
.collect(Collectors.joining(","));
List<String> componentIds = result.stream()
.filter(e -> e.getOssName().equals(p.getOssName()))
.filter(e -> e.getOssVersion().equals(p.getOssVersion()))
.filter(e -> e.getLicenseName().equals(p.getLicenseName()))
.filter(e -> e.getCheckLicense().equals(p.getCheckLicense()))
.map(e -> e.getComponentIdList())
.flatMap(Collection::stream)
.collect(Collectors.toList());
p.setDownloadLocation(downloadLocation);
p.setComponentIdList(componentIds);
}
resMap.put("checkedData", sortedData);
if (errors.size() > 0) {
resMap.put("error", getMessage("external.service.connect.fail", new Object[]{errors}));
}
return resMap;
}
private String getLicenseNameSort(String licenseName) {
String sortedValue = "";
String splitLicenseNm[] = licenseName.split(",");
Arrays.sort(splitLicenseNm);
for (int i=0; i< splitLicenseNm.length; i++) {
sortedValue += splitLicenseNm[i];
if (i<splitLicenseNm.length-1) {
sortedValue += ",";
}
}
return sortedValue;
}
private String requestClearlyDefinedLicenseApi(String requestUri) {
String checkedLicense;
try {
Mono<Object> mono = requestClearlyDefinedLicense(requestUri);
Map<String, Object> ossInfo = (Map<String, Object>) mono.block();
Map<String, String> licenseInfo = (Map<String, String>) ossInfo.get("licensed");
checkedLicense = licenseInfo.get("declared");
} catch (Exception e) {
log.error("Clearly Defined -> " + requestUri + " : " + e.getMessage());
checkedLicense = "NONE";
}
return checkedLicense;
}
private String requestGithubLicenseApi(String requestUri) {
String checkedLicense;
try {
Mono<Object> mono = requestGithubLicense(requestUri);
Map<String, Object> ossInfo = (Map<String, Object>) mono.block();
Map<String, String> licenseInfo = (Map<String, String>) ossInfo.get("license");
checkedLicense = licenseInfo.get("spdx_id");
} catch (Exception e) {
log.error("Github Request -> " + requestUri + " : " + e.getMessage());
checkedLicense = "NONE";
}
return checkedLicense;
}
private Boolean isEachOssVersionDiff(List<ProjectIdentification> prjOssMasters) {
return prjOssMasters.stream().allMatch(oss -> oss.getVersionDiffFlag().equals("Y"));
}
private Boolean isExternalServiceEnable() {
return "Y".equalsIgnoreCase(CommonFunction.getProperty("external.service.useflag"));
}
private boolean isGitHubApiHealth() throws HttpServerErrorException {
try {
requestGithubLicense("https://api.github.com/").block();
} catch(HttpServerErrorException e) {
String message = "GitHub ";
if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) {
message += getMessage("api.token.invalid");
throw new HttpServerErrorException(e.getStatusCode(), message);
}
if (e.getStatusCode().equals(HttpStatus.FORBIDDEN)) {
message += getMessage("api.server.connect.limit");
throw new HttpServerErrorException(e.getStatusCode(), message);
}
if (e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
message += getMessage("api.server.connect.fail");
throw new HttpServerErrorException(e.getStatusCode(), message);
}
}
return true;
}
private boolean isClearlyDefinedApiHealth() throws HttpServerErrorException {
Map<String, Object> res = new HashMap<>();
try {
res = (Map<String, Object>) requestClearlyDefinedLicense("https://api.clearlydefined.io/").block();
} catch(HttpServerErrorException e) {
String message = "ClearlyDefined ";
if (e.getStatusCode().equals(HttpStatus.FORBIDDEN)) {
message += getMessage("api.server.connect.limit");
throw new HttpServerErrorException(e.getStatusCode(), message);
}
if (e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
message += getMessage("api.server.connect.fail");
throw new HttpServerErrorException(e.getStatusCode(), message);
}
}
return res.get("status").equals("OK");
}
private String combineOssLicenses(List<ProjectIdentification> prjOssMasters, String currentLicense) {
String checkLicense = "";
List<ProjectIdentification> licenses;
prjOssMasters = prjOssMasters.stream().filter(CommonFunction.distinctByKey(p -> p.getOssId())).collect(Collectors.toList());
for (ProjectIdentification prjOssMaster : prjOssMasters) {
if (!isEmpty(checkLicense)) {
checkLicense += "|";
}
licenses = projectMapper.getLicenses(prjOssMaster);
checkLicense += makeLicenseExpression(licenses, currentLicense);
}
return checkLicense;
}
private String makeLicenseExpression(List<ProjectIdentification> licenses, String currentLicense) {
String license = "";
if (licenses.size() != 0){
licenses = CommonFunction.makeLicensePermissiveList(licenses, currentLicense);
licenses = CommonFunction.makeLicenseExcludeYn(licenses);
licenses.sort(Comparator.comparing(ProjectIdentification::getLicenseName));
license = CommonFunction.makeLicenseExpressionIdentify(licenses, ",");
}
return license;
}
@Override
public ParallelFlux<Object> getGithubLicenses(List<String> locations) {
return Flux.fromIterable(locations)
.parallel()
.runOn(Schedulers.elastic())
.flatMap(this::requestGithubLicense);
}
@Override
public Mono<Object> requestGithubLicense(String location) {
String githubToken = CommonFunction.getProperty("external.service.github.token");
return webClient.get()
.uri(location)
.header("Authorization", "token " + githubToken)
.exchange()
.flatMap(response -> {
HttpStatus statusCode = response.statusCode();
if (statusCode.is4xxClientError()) {
return Mono.error(new HttpServerErrorException(statusCode));
}else if (statusCode.is5xxServerError()) {
return Mono.error(new HttpServerErrorException(statusCode));
}
return Mono.just(response);
})
.retry (1)
.flatMap(response -> response.bodyToMono(Object.class));
}
@Override
public ParallelFlux<Object> getClearlyDefinedLicenses(List<String> locations) {
return Flux.fromIterable(locations)
.parallel()
.runOn(Schedulers.elastic())
.flatMap(this::requestClearlyDefinedLicense);
}
@Override
public Mono<Object> requestClearlyDefinedLicense(String location) {
return webClient.get()
.uri(location)
.exchange()
.flatMap(response -> {
HttpStatus statusCode = response.statusCode();
if (statusCode.is4xxClientError()) {
return Mono.error(new HttpServerErrorException(statusCode));
}else if (statusCode.is5xxServerError()) {
return Mono.error(new HttpServerErrorException(statusCode));
}
return Mono.just(response);
})
.retry (1)
.flatMap(response -> response.bodyToMono(Object.class));
}
@Transactional
@Override
public Map<String, Object> saveOssCheckLicense(ProjectIdentification paramBean, String targetName) {
Map<String, Object> map = new HashMap<String, Object>();
try {
int updateCnt = 0;
List<String> componentIds = paramBean.getComponentIdList();
for (String componentId : componentIds) {
OssComponents oc = new OssComponents();
oc.setComponentId(componentId);
switch(targetName.toUpperCase()) {
case CoConstDef.CD_CHECK_OSS_SELF:
selfCheckMapper.deleteOssComponentsLicense(oc);
break;
case CoConstDef.CD_CHECK_OSS_PARTNER:
partnerMapper.deleteOssComponentsLicense(oc);
break;
case CoConstDef.CD_CHECK_OSS_IDENTIFICATION:
projectMapper.deleteOssComponentsLicense(oc);
break;
}
String[] checkLicense = paramBean.getCheckLicense().split(",");
String licenseDev = checkLicense.length > 1 ? CoConstDef.LICENSE_DIV_MULTI : CoConstDef.LICENSE_DIV_SINGLE;
for (String licenseName : checkLicense) {
ProjectIdentification comLicense = new ProjectIdentification();
comLicense.setComponentId(componentId);
comLicense.setLicenseName(licenseName);
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, licenseDev);
switch(targetName.toUpperCase()) {
case CoConstDef.CD_CHECK_OSS_SELF:
selfCheckMapper.registComponentLicense(license);
break;
case CoConstDef.CD_CHECK_OSS_PARTNER:
partnerMapper.insertOssComponentsLicense(license);
break;
case CoConstDef.CD_CHECK_OSS_IDENTIFICATION:
projectMapper.registComponentLicense(license);
break;
}
updateCnt++;
}
}
if (CoConstDef.CD_CHECK_OSS_PARTNER.equals(targetName.toUpperCase())
|| CoConstDef.CD_CHECK_OSS_IDENTIFICATION.equals(targetName.toUpperCase())) {
if (updateCnt >= 1) {
String commentId = CoConstDef.CD_CHECK_OSS_PARTNER.equals(targetName.toUpperCase()) ? paramBean.getRefPrjId() : paramBean.getReferenceId();
String checkOssLicenseComment = "";
String changeOssLicenseInfo = "<p>" + paramBean.getOssName();
if (!paramBean.getOssVersion().isEmpty()) {
changeOssLicenseInfo += " (" + paramBean.getOssVersion() + ") ";
} else {
changeOssLicenseInfo += " ";
}
changeOssLicenseInfo += paramBean.getDownloadLocation() + " "
+ paramBean.getLicenseName() + " => " + paramBean.getCheckLicense() + "</p>";
CommentsHistory commentInfo = null;
if (isEmpty(commentId)) {
checkOssLicenseComment = "<p><b>The following Licenses were modified by \"Check License\"</b></p>";
checkOssLicenseComment += changeOssLicenseInfo;
CommentsHistory commHisBean = new CommentsHistory();
if (CoConstDef.CD_CHECK_OSS_PARTNER.equals(targetName.toUpperCase())) {
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_HIS);
commHisBean.setReferenceId(paramBean.getReferenceId());
}else {
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commHisBean.setReferenceId(paramBean.getRefPrjId());
}
commHisBean.setContents(checkOssLicenseComment);
commentInfo = commentService.registComment(commHisBean, false);
} else {
commentInfo = (CommentsHistory) commentService.getCommnetInfo(commentId).get("info");
if (commentInfo != null) {
if (!isEmpty(commentInfo.getContents())) {
checkOssLicenseComment = commentInfo.getContents();
checkOssLicenseComment += changeOssLicenseInfo;
commentInfo.setContents(checkOssLicenseComment);
commentService.updateComment(commentInfo, false);
}
}
}
if (commentInfo != null) {
map.put("commentId", commentInfo.getCommId());
}
}
}
if (updateCnt >= 1) {
map.put("isValid", true);
map.put("returnType", "Success");
} else {
throw new Exception("update Cnt๊ฐ ๋น์ ์์ ์ธ ๊ฐ์.");
}
} catch (Exception e) {
log.error(e.getMessage());
map.put("isValid", false);
map.put("returnType", "");
}
return map;
}
} | 24,397 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
VulnerabilityServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/VulnerabilityServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.T2CodeDtl;
import oss.fosslight.domain.Vulnerability;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.repository.OssMapper;
import oss.fosslight.repository.VulnerabilityMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.VulnerabilityService;
@Service
@Slf4j
public class VulnerabilityServiceImpl extends CoTopComponent implements VulnerabilityService {
private static final Logger scheduler_log = LoggerFactory.getLogger("SCHEDULER_LOG");
@Autowired Environment env;
@Autowired VulnerabilityMapper vulnerabilityMapper;
@Autowired OssService ossService;
@Autowired OssMapper ossMapper;
@Autowired CodeMapper codeMapper;
@Autowired CommentService commentService;
@Override
public HashMap<String, Object> getVulnerabilityList(Vulnerability vulnerability, boolean exportFlag) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<String> convertOssNicknameList = new ArrayList<>();
List<String> vendorProductCheckList = new ArrayList<>();
// Table alias ์ง์ ์ด ํ์ํ ์นผ๋ผ
Map<String, String> ambiguousMap = new HashMap<>();
ambiguousMap.put("CVE_ID", "T1");
String filterCondition = CommonFunction.getFilterToString(vulnerability.getFilters(), ambiguousMap);
if (!isEmpty(filterCondition)) {
vulnerability.setFilterCondition(filterCondition);
}
if (isEmpty(vulnerability.getOssNameAllSearchFlag())) {
vulnerability.setOssNameAllSearchFlag(CoConstDef.FLAG_NO);
}
if (CoConstDef.FLAG_YES.equals(vulnerability.getOssNameAllSearchFlag()) && "PRODUCT".equals(vulnerability.getSidx().toUpperCase())) {
vulnerability.setSidx("version");
vulnerability.setSord("desc");
}
if (vulnerability.getProduct() != null) {
String searchProduct = vulnerability.getProduct();
if (searchProduct.contains(" ") || searchProduct.contains("_")) {
if (searchProduct.contains("_")) {
vulnerability.setSpecialCharactersProduct(vulnerability.getProduct().replaceAll("_", " "));
} else {
vulnerability.setSpecialCharactersProduct(vulnerability.getProduct().replaceAll(" ", "_"));
}
}
if (searchProduct.contains("-")) {
vendorProductCheckList.add(searchProduct);
}
}
String[] nicknameList = ossService.getOssNickNameListByOssName(vulnerability.getProduct());
if (nicknameList != null) {
for (String nickname : nicknameList) {
if (nickname.contains(" ")) {
convertOssNicknameList.add(nickname.replaceAll(" ", "_"));
} else if (nickname.contains("_")) {
convertOssNicknameList.add(nickname.replaceAll("_", " "));
}
if (nickname.contains("-")) {
vendorProductCheckList.add(nickname);
}
}
if (convertOssNicknameList.size() > 0) {
convertOssNicknameList.addAll(Arrays.asList(nicknameList));
convertOssNicknameList = convertOssNicknameList.stream().distinct().collect(Collectors.toList());
vulnerability.setOssNicknames(convertOssNicknameList.toArray(new String[convertOssNicknameList.size()]));
} else {
vulnerability.setOssNicknames(nicknameList);
}
} else {
if (convertOssNicknameList.size() > 0) {
convertOssNicknameList = convertOssNicknameList.stream().distinct().collect(Collectors.toList());
vulnerability.setOssNicknames(convertOssNicknameList.toArray(new String[convertOssNicknameList.size()]));
} else {
vulnerability.setOssNicknames(nicknameList);
}
}
if (!vendorProductCheckList.isEmpty()) {
vendorProductCheckList = vendorProductCheckList.stream().distinct().collect(Collectors.toList());
vulnerability.setOssNicknameArr(vendorProductCheckList.toArray(new String[vendorProductCheckList.size()]));
}
int records = vulnerabilityMapper.selectVulnerabilityTotalCount(vulnerability);
vulnerability.setTotListSize(records);
List<Vulnerability> list = null;
if (exportFlag) {
list = vulnerabilityMapper.selectVulnerabilityExportList(vulnerability);
}else {
list = vulnerabilityMapper.selectVulnerabilityList(vulnerability);
List<String> replaceVendor = new ArrayList<>();
for (Vulnerability vuln : list) {
String vendor = vuln.getVendor();
for (String vendorNm : vendor.split(",")) {
if (!isEmpty(vendorNm)) {
replaceVendor.add(vendorNm);
}
}
vendor = "";
if (replaceVendor.size() > 0) {
for (String reNm : replaceVendor) {
vendor += reNm + ",";
}
vuln.setVendor(vendor.substring(0, vendor.length()-1));
} else {
vuln.setVendor("");
}
replaceVendor.clear();
}
}
map.put("page", vulnerability.getCurPage());
map.put("total", vulnerability.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
@Cacheable(value="autocompleteVulnerabilityCache", key="{#root.methodName}")
public HashMap<String, Object> getVulnerabilityAutoComplete() {
HashMap<String, Object> map = new HashMap<String, Object>();
List<String> nameList = vulnerabilityMapper.selectVulnerabilityOSSNameAutoComplete();
List<String> cveIdList = vulnerabilityMapper.selectVulnerabilityCveIdAutoComplete();
map.put("nameList", nameList);
map.put("cveIdList", cveIdList);
return map;
}
@Override
public List<String> getVulnerabilityVersionAutoComplete(String name) {
List<String> versionList = vulnerabilityMapper.selectVulnerabilityOSSVersionAutoComplete(name);
return versionList;
}
@Override
public Map<String, Object> getVulnListByOssName(OssMaster bean) {
Map<String, Object> result = new HashMap<String, Object>();
boolean underscoreFlag = false;
if ("N/A".equals(bean.getOssVersion())) {
bean.setOssVersion("");
}
String key = (bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase();
String ossName = bean.getOssName();
String refOssName = "";
if (CoCodeManager.OSS_INFO_UPPER.containsKey(key)) {
OssMaster ossInfo = CoCodeManager.OSS_INFO_UPPER.get(key);
if (!ossInfo.getOssName().equals(ossInfo.getOssNameTemp())) {
refOssName = ossInfo.getOssNameTemp();
}
} else {
if (ossName.contains("_")) {
underscoreFlag = true;
String chkKey = (bean.getOssName().replaceAll("_", " ") + "_" + avoidNull(bean.getOssVersion())).toUpperCase();
if (CoCodeManager.OSS_INFO_UPPER.containsKey(chkKey)) {
OssMaster ossInfo = CoCodeManager.OSS_INFO_UPPER.get(chkKey);
if (!ossInfo.getOssName().equals(ossInfo.getOssNameTemp())) {
refOssName = ossInfo.getOssNameTemp();
} else {
ossName = bean.getOssName().replaceAll("_", " ");
}
}
}
}
List<Vulnerability> list = null;
String[] nicknameList = null;
int records = 0;
try {
nicknameList = ossService.getOssNickNameListByOssName(isEmpty(refOssName) ? ossName : refOssName);
if (underscoreFlag) {
if (nicknameList != null) {
List<String> nicknameList2 = new ArrayList<>();
nicknameList2.addAll(Arrays.asList(nicknameList));
nicknameList2.add(bean.getOssName());
nicknameList = nicknameList2.toArray(new String[nicknameList2.size()]);
} else {
nicknameList = new String[] {bean.getOssName()};
}
}
bean.setSchOssName(ossName);
bean.setOssName(!isEmpty(refOssName) ? refOssName : ossName);
bean.setOssNicknames(nicknameList);
records = vulnerabilityMapper.getVulnListByOssNameCnt(bean);
bean.setTotListSize(records);
list = vulnerabilityMapper.getVulnListByOssName(bean);
} catch (Exception e) {
log.error(e.getMessage());
}
list = checkVulnData(list, nicknameList);
if (bean.getVulnerabilityCheckFlag() != null) list = sortDataForVulnerabilityResolution(list);
result.put("page", bean.getCurPage());
result.put("total", bean.getTotBlockSize());
result.put("records", records); // total cnt๋ฅผ cveCnt์ ๋ด์๋๊ณ ๊ด๋ฆฌํจ.
result.put("rows", list);
return result;
}
private List<Vulnerability> sortDataForVulnerabilityResolution(List<Vulnerability> list) {
List<Vulnerability> vrFixedDataList = new ArrayList<>();
List<Vulnerability> vrNotFixedDataList = new ArrayList<>();
for (Vulnerability vuln : list) {
if (vuln.getVulnerabilityResolution() != null && vuln.getVulnerabilityResolution().equals("Fixed")) {
vrFixedDataList.add(vuln);
} else {
vrNotFixedDataList.add(vuln);
}
}
if (vrFixedDataList.isEmpty()) {
return list;
} else {
List<Vulnerability> sortedDataList = new ArrayList<>();
sortedDataList.addAll(vrNotFixedDataList);
sortedDataList.addAll(vrFixedDataList);
return sortedDataList;
}
}
public List<Vulnerability> checkVulnData(List<Vulnerability> list, String[] nicknameList){
List<Vulnerability> result = new ArrayList<Vulnerability>();
for (Vulnerability bean : list) {
bean.setOssNameAllSearchFlag(CoConstDef.FLAG_YES);
if (nicknameList != null) {
bean.setOssNicknames(nicknameList);
}
int vulnCnt = vulnerabilityMapper.checkVulnDataCnt(bean);
if (vulnCnt > 0) {
result.add(bean);
}
}
return result;
}
public void doSyncOSSNvdInfo() {
vulnerabilityMapper.updateOssRecheckVulnFlag();
List<String> notUsedOssList = new ArrayList<>();
Map<String, OssMaster> reCalcOssInfoMap = new HashMap<>();
Map<String, Map<String, OssMaster>> reCalcCommentsOssInfoMap = new HashMap<>();
Map<String, List<Map<String, Object>>> discoveredCommentsOssInfoMap = new HashMap<>();
List<String> _filteredNvdData = new ArrayList<>();
List<String> _prjMailList = new ArrayList<>();
List<String> _reCalcPrjMailList = new ArrayList<>();
List<String> _removeReCalcPrjMailList = new ArrayList<>();
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_BY_ID;
Map<String, String> ossInfoNamesMap = CoCodeManager.OSS_INFO_UPPER_NAMES;
Map<String, OssMaster> _notMatchedVendorProduct = new HashMap<>();
List<String> checkedOssList = new ArrayList<>();
List<Map<String, Object>> _nvdInfoDiffVendorList = new ArrayList<>();
boolean discoveredMailingFlag = false;
boolean hasNvdData = vulnerabilityMapper.selectNvdTotalCount() > 0;
T2CodeDtl codeDetail = codeMapper.getCodeDetail(CoConstDef.CD_VULNERABILITY_MAILING_SCORE, CoConstDef.CD_VULNERABILITY_MAILING_SCORE_STANDARD);
String standardScore = codeDetail.getCdDtlExp();
List<String> nvdInfoKeyList = new ArrayList<>();
List<String> nvdInfoValueList = null;
Map<String, List<String>> diffVendorList = new HashMap<>();
scheduler_log.info("doSyncOSSNvdInfo standard cvss score : " + standardScore);
// vendor-product matching
for (String ossKey : ossInfoMap.keySet()) {
OssMaster ossBean = ossInfoMap.get(ossKey);
ossBean.setOssVersion(avoidNull(ossBean.getOssVersion()));
ossBean.setStandardScore(Float.valueOf(standardScore));
List<Map<String, Object>> vendorProductInfoList = null;
if (!isEmpty(ossBean.getOssVersion())) {
vendorProductInfoList = vulnerabilityMapper.selectVendorProductInfo(ossBean);
if (vendorProductInfoList != null && !vendorProductInfoList.isEmpty()) {
List<Map<String, Object>> filteredNvdDataInfoList = filteredNvdData(_filteredNvdData, vendorProductInfoList, true);
if (filteredNvdDataInfoList != null && !filteredNvdDataInfoList.isEmpty()) {
List<Map<String, Object>> rtnNvdInfoSndMailList = insertDataForDiscoveredMailing(ossBean, standardScore, true);
Map<String, Object> map = filteredNvdDataInfoList.get(0);
updateVulnAndMailing(ossBean, map, standardScore, _prjMailList, _reCalcPrjMailList, notUsedOssList, reCalcOssInfoMap, reCalcCommentsOssInfoMap, discoveredCommentsOssInfoMap, rtnNvdInfoSndMailList);
String key = ((String) map.get("PRODUCT") + "_" + (String) map.get("VERSION") + "_" + (String) map.get("VENDOR") + "_" + (String) map.get("CVE_ID")).toUpperCase();
if (!_filteredNvdData.contains(key)) {
_filteredNvdData.add(key);
}
if (!diffVendorList.containsKey(ossBean.getOssName())) {
customDiffVendor(ossBean, nvdInfoKeyList, nvdInfoValueList, diffVendorList, ossInfoNamesMap);
}
} else {
_notMatchedVendorProduct.put(ossKey, ossBean);
}
} else {
_notMatchedVendorProduct.put(ossKey, ossBean);
}
} else {
vendorProductInfoList = vulnerabilityMapper.selectVendorProductInfoWithOurVer(ossBean);
if (vendorProductInfoList != null && !vendorProductInfoList.isEmpty()) {
List<Map<String, Object>> filteredNvdDataInfoList = filteredNvdData(_filteredNvdData, vendorProductInfoList, true);
if (filteredNvdDataInfoList != null && !filteredNvdDataInfoList.isEmpty()) {
List<Map<String, Object>> rtnNvdInfoSndMailList = insertDataForDiscoveredMailing(ossBean, standardScore, true);
Map<String, Object> map = filteredNvdDataInfoList.get(0);
updateVulnAndMailing(ossBean, map, standardScore, _prjMailList, _reCalcPrjMailList, notUsedOssList, reCalcOssInfoMap, reCalcCommentsOssInfoMap, discoveredCommentsOssInfoMap, rtnNvdInfoSndMailList);
String key = ((String) map.get("PRODUCT") + "_" + (String) map.get("VERSION") + "_" + (String) map.get("VENDOR") + "_" + (String) map.get("CVE_ID")).toUpperCase();
if (!_filteredNvdData.contains(key)) {
_filteredNvdData.add(key);
}
if (!diffVendorList.containsKey(ossBean.getOssName())) {
customDiffVendor(ossBean, nvdInfoKeyList, nvdInfoValueList, diffVendorList, ossInfoNamesMap);
}
} else {
_notMatchedVendorProduct.put(ossKey, ossBean);
}
} else {
_notMatchedVendorProduct.put(ossKey, ossBean);
}
}
}
if (_notMatchedVendorProduct != null && !_notMatchedVendorProduct.isEmpty()) {
for (String ossKey : _notMatchedVendorProduct.keySet()) {
OssMaster ossBean = _notMatchedVendorProduct.get(ossKey);
if (checkedOssList.contains(ossBean.getOssId())) {
continue;
}
checkedOssList.add(ossBean.getOssId());
ossBean.setOssVersion(avoidNull(ossBean.getOssVersion()));
ossBean.setStandardScore(Float.valueOf(standardScore));
boolean reCheckNVDInfo = false;
if (!isEmpty(ossBean.getOssVersion())) {
List<Map<String, Object>> nvdInfoList = vulnerabilityMapper.selectNvdInfo(ossBean);
if (nvdInfoList != null && !nvdInfoList.isEmpty()) {
List<Map<String, Object>> filteredNvdDataInfoList = filteredNvdData(_filteredNvdData, nvdInfoList, false);
if (filteredNvdDataInfoList != null && !filteredNvdDataInfoList.isEmpty()) {
List<Map<String, Object>> rtnNvdInfoSndMailList = insertDataForDiscoveredMailing(ossBean, standardScore, false);
Map<String, Object> map = filteredNvdDataInfoList.get(0);
updateVulnAndMailing(ossBean, map, standardScore, _prjMailList, _reCalcPrjMailList, notUsedOssList, reCalcOssInfoMap, reCalcCommentsOssInfoMap, discoveredCommentsOssInfoMap, rtnNvdInfoSndMailList);
} else {
// NVD ์ญ์ ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
reCheckNVDInfo = true;
}
} else {
// NVD ์ญ์ ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
reCheckNVDInfo = true;
}
} else {
Map<String, Object> nvdInfo = vulnerabilityMapper.selectNvdInfoWithOutVer(ossBean);
if (nvdInfo != null && !nvdInfo.isEmpty()) {
String key = ((String) nvdInfo.get("PRODUCT") + "_" + (String) nvdInfo.get("VERSION") + "_" + (String) nvdInfo.get("VENDOR") + "_" + (String) nvdInfo.get("CVE_ID")).toUpperCase();
if (!_filteredNvdData.contains(key)) {
List<Map<String, Object>> filteredNvdDataInfoList = new ArrayList<>();
filteredNvdDataInfoList.add(nvdInfo);
List<Map<String, Object>> rtnNvdInfoSndMailList = insertDataForDiscoveredMailing(ossBean, standardScore, false);
updateVulnAndMailing(ossBean, nvdInfo, standardScore, _prjMailList, _reCalcPrjMailList, notUsedOssList, reCalcOssInfoMap, reCalcCommentsOssInfoMap, discoveredCommentsOssInfoMap, rtnNvdInfoSndMailList);
} else {
// NVD ์ญ์ ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
reCheckNVDInfo = true;
}
} else {
// NVD ์ญ์ ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
reCheckNVDInfo = true;
}
}
// NVD ์ ๋ณด๋ ์์ง๋ง oss list์ nvd ์ ๋ณด๊ฐ ์ด๋ฏธ ์ค์ ๋์ด ์๋ ๊ฒฝ์ฐ
// NVD ์ฌ์ดํธ์์ Excluding ๋์์ ๊ฐ๋ฅ์ฑ์ด ๋๋ค (์ญ์ ๋จ)
if (reCheckNVDInfo) {
// ํน์ BATCH์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ฌ NVD_DATA_SCORE_V3 ํ
์ด๋ธ์ DATA ๊ฐ ๋ฑ๋ก๋์ง ์์ ๊ฒฝ์ฐ
// ๋ชจ๋ NVD DATA๊ฐ ์ญ์ ๋๋ ๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํด์ ๊ฑด์๊ฐ 0๊ฑด์ด์์ธ์ง ํ์ธํ๋ค.
if (hasNvdData && !isEmpty(ossBean.getCveId())) {
scheduler_log.info("Vulnerability deleteOssVulnInfo OSS ID : " + ossBean.getOssId());
// oss list์์ NVD ์ ๋ณด๋ฅผ ์ญ์ ํ๋ค.
ossBean.setCvssScoreTo("0");
ossBean.setCveIdTo("");
vulnerabilityMapper.insertNvdOssHis(ossBean);
vulnerabilityMapper.deleteOssVulnInfo(ossBean.getOssId());
BigDecimal bdOrgMasterScore = new BigDecimal(String.valueOf(ossBean.getCvssScore()));
// vulnerability mail > base score changed from 9.0 to 8.0
if (bdOrgMasterScore.compareTo(new BigDecimal(standardScore)) > -1) {
String[] nickNameList = ossMapper.checkNickNameRegOss(ossBean.getOssName()).toArray(new String[0]);
ossBean.setOssNames(nickNameList);
List<String> _prjList = vulnerabilityMapper.selectUsedVulnerabilityOssProject(ossBean);
if (_prjList != null && !_prjList.isEmpty()) {
_removeReCalcPrjMailList.addAll(_prjList);
}
reCalcOssInfoMap.put(ossBean.getOssName().toUpperCase()+"_"+ossBean.getOssVersion(), ossBean);
}
}
}
// check same product diff vendor
if (!reCheckNVDInfo && !diffVendorList.containsKey(ossBean.getOssName())) {
customDiffVendor(ossBean, nvdInfoKeyList, nvdInfoValueList, diffVendorList, ossInfoNamesMap);
}
}
}
if (!diffVendorList.isEmpty()) {
String vendor = "";
String cveId = "";
for (String diffVendorKey : diffVendorList.keySet()) {
List<String> diffVendor = diffVendorList.get(diffVendorKey);
diffVendor = diffVendor.stream().distinct().collect(Collectors.toList());
if (diffVendor != null && !diffVendor.isEmpty()) {
Map<String, Object> map = new HashMap<>();
for (int i=0; i < diffVendor.size(); i++) {
String vendorProduct = " (" + diffVendor.get(i).split("[|]")[0] + "-" + diffVendor.get(i).split("[|]")[1] + ")";
vendor += diffVendor.get(i).split("[|]")[0];
vendor += vendorProduct;
cveId += diffVendor.get(i).split("[|]")[2];
if (i < diffVendor.size()-1) {
vendor += "<br/>";
cveId += "<br/>";
}
}
map.put("product", diffVendorKey);
map.put("cveId", cveId);
map.put("vendor", vendor);
_nvdInfoDiffVendorList.add(map);
vendor = "";
cveId = "";
}
}
}
CoCodeManager.getInstance().refreshOssInfo();
int discoveredOssCnt = 0;
String securityComment;
if (_prjMailList != null && !_prjMailList.isEmpty()) {
discoveredMailingFlag = true;
List<String> prjMailList = new ArrayList<String>(new HashSet<String>(_prjMailList));
scheduler_log.info("Vulnerability prj COUNT : " + prjMailList.size());
for (String prjId : prjMailList) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT);
mailBean.setParamPrjId(prjId);
CoMailManager.getInstance().sendMail(mailBean);
// security tab comment history
securityComment = "";
if (discoveredCommentsOssInfoMap.containsKey(prjId)) {
List<Map<String, Object>> discoveredCommentsInfoList = discoveredCommentsOssInfoMap.get(prjId);
if (discoveredCommentsInfoList != null && !discoveredCommentsInfoList.isEmpty()) {
List<String> duplicatedOssNameList = new ArrayList<>();
securityComment += "<p><strong>Vulnerability discovered</strong>";
for (Map<String, Object> commentsInfo : discoveredCommentsInfoList) {
OssMaster om = ossInfoMap.get(commentsInfo.get("OSS_ID"));
String key = (om.getOssName() + "_" + avoidNull(om.getOssVersion(), "N/A") + "_" + (String) commentsInfo.get("CVE_ID")).toUpperCase();
if (!duplicatedOssNameList.contains(key)) {
securityComment += "<br />" + om.getOssName() + " (" + avoidNull(om.getOssVersion(), "N/A") + ") : " + CommonFunction.convertCveIdToLink((String) commentsInfo.get("CVE_ID"));
duplicatedOssNameList.add(key);
}
}
}
}
if (discoveredCommentsOssInfoMap.containsKey(prjId) && reCalcCommentsOssInfoMap.containsKey(prjId)) {
Map<String, OssMaster> reCalcCommentsInfo = reCalcCommentsOssInfoMap.get(prjId);
if (!MapUtils.isEmpty(reCalcCommentsInfo)) {
List<String> duplicatedOssNameList = new ArrayList<>();
securityComment += "<br /><br />";
securityComment += "<strong>Vulnerability recalculated</strong>";
for(String reCalcInfo : reCalcCommentsInfo.keySet() ){
OssMaster om = reCalcCommentsInfo.get(reCalcInfo);
String key = (om.getOssName() + "_" + avoidNull(om.getOssVersion(), "N/A") + "_" + om.getCveId()).toUpperCase();
if (!duplicatedOssNameList.contains(key)) {
securityComment += "<br />" + om.getOssName() + " (" + avoidNull(om.getOssVersion(), "N/A") + ") : " + CommonFunction.convertCveIdToLink(om.getCveId());
duplicatedOssNameList.add(key);
}
}
}
}
if (!isEmpty(securityComment)) {
securityComment += "</p>";
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_SECURITY_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents(securityComment);
commHisBean.setLoginUserName("oscAdmin");
commentService.registComment(commHisBean, false);
}
}
}
if (_reCalcPrjMailList != null && !_reCalcPrjMailList.isEmpty()) {
List<String> prjMailList = new ArrayList<String>(new HashSet<String>(_reCalcPrjMailList));
scheduler_log.info("Vulnerability risk recalculated prj COUNT : " + _reCalcPrjMailList.size());
for (String prjId : prjMailList) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED);
mailBean.setParamPrjId(prjId);
mailBean.setParamStandardScore(standardScore);
mailBean.setParamOssInfoMap(reCalcOssInfoMap);
CoMailManager.getInstance().sendMail(mailBean);
// security tab comment history
securityComment = "";
if (!discoveredCommentsOssInfoMap.containsKey(prjId) && reCalcCommentsOssInfoMap.containsKey(prjId)) {
Map<String, OssMaster> reCalcCommentsInfo = reCalcCommentsOssInfoMap.get(prjId);
if (!MapUtils.isEmpty(reCalcCommentsInfo)) {
securityComment += "<p><strong>Vulnerability recalculated</strong>";
for(String key : reCalcCommentsInfo.keySet() ){
OssMaster om = reCalcCommentsInfo.get(key);
securityComment += "<br />" + om.getOssName() + " (" + avoidNull(om.getOssVersion(), "N/A") + ") : " + CommonFunction.convertCveIdToLink(om.getCveId());
}
securityComment += "</p>";
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_SECURITY_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents(securityComment);
commHisBean.setLoginUserName("oscAdmin");
commentService.registComment(commHisBean, false);
}
}
}
}
if (_removeReCalcPrjMailList != null && !_removeReCalcPrjMailList.isEmpty()) {
List<String> prjMailList = new ArrayList<String>(new HashSet<String>(_removeReCalcPrjMailList));
scheduler_log.info("Vulnerability risk remove > recalculated prj COUNT : " + _removeReCalcPrjMailList.size());
for (String prjId : prjMailList) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED);
mailBean.setParamPrjId(prjId);
mailBean.setParamStandardScore(standardScore);
mailBean.setParamOssInfoMap(reCalcOssInfoMap);
CoMailManager.getInstance().sendMail(mailBean);
}
}
if (!notUsedOssList.isEmpty()) {
discoveredMailingFlag = true;
discoveredOssCnt = notUsedOssList.size();
try {
scheduler_log.info("Vulnerability notUsedOssList COUNT : " + notUsedOssList.size());
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_OSS);
mailBean.setParamOssKey(notUsedOssList);
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
scheduler_log.error(e.getMessage(), e);
}
}
if (reCalcOssInfoMap.keySet().size() > 0) {
try {
scheduler_log.info("Vulnerability reCalculated All COUNT : " + reCalcOssInfoMap.keySet().size());
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED_ALL);
ArrayList<String> keyList = new ArrayList<String>(reCalcOssInfoMap.keySet());
mailBean.setParamOssKey(keyList);
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
scheduler_log.error(e.getMessage(), e);
}
}
if (_nvdInfoDiffVendorList != null && _nvdInfoDiffVendorList.size() > 0) {
try {
scheduler_log.info("Vulnerability nvdInfoDiffVendorList COUNT : " + _nvdInfoDiffVendorList.size());
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_VULNERABILITY_NVDINFO_DIFF);
mailBean.setParamList(_nvdInfoDiffVendorList);
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
scheduler_log.error(e.getMessage(), e);
}
}
if (discoveredMailingFlag) {
scheduler_log.info("Vulnerability Discovered OSS COUNT : " + discoveredOssCnt);
try {
vulnerabilityMapper.updateOssDiscoveredSndEmail();
} catch (Exception e) {
scheduler_log.error(e.getMessage(), e);
}
}
}
private void customDiffVendor(OssMaster ossBean, List<String> nvdInfoKeyList, List<String> nvdInfoValueList, Map<String, List<String>> diffVendorList, Map<String, String> ossInfoNamesMap) {
List<Map<String, Object>> checkDiffVendor = vulnerabilityMapper.selectDiffVendorForProduct(ossBean);
List<Map<String, Object>> diffVendorProductList = checkDiffVendor.stream().filter(e -> !ossInfoNamesMap.containsKey((e.get("VENDOR") + "-" + e.get("PRODUCT")).toUpperCase())).collect(Collectors.toList());
if (diffVendorProductList != null && !diffVendorProductList.isEmpty()) {
nvdInfoValueList = new ArrayList<>();
String nvdInfoKey = "";
for (Map<String, Object> nvdInfo : diffVendorProductList) {
nvdInfoKey = ((String) nvdInfo.get("VENDOR") + "|" + (String) nvdInfo.get("PRODUCT")).toUpperCase();
if (!nvdInfoKeyList.contains(nvdInfoKey)) {
nvdInfoKeyList.add(nvdInfoKey);
nvdInfoValueList.add((String) nvdInfo.get("VENDOR") + "|" + (String) nvdInfo.get("PRODUCT") + "|" + (String) nvdInfo.get("CVE_ID"));
}
}
if (nvdInfoValueList.size() > 1) {
diffVendorList.put(ossBean.getOssName(), nvdInfoValueList);
}
nvdInfoValueList = null;
}
}
private List<Map<String, Object>> insertDataForDiscoveredMailing(OssMaster ossBean, String standardScore, boolean vendorProductFlag) {
List<Map<String, Object>> rtnNvdInfoSndMailList = new ArrayList<>();
List<Map<String, Object>> nvdInfoSndMailList = null;
if (vendorProductFlag) {
nvdInfoSndMailList = vulnerabilityMapper.selectVendorProductSndMailList(ossBean);
} else {
nvdInfoSndMailList = vulnerabilityMapper.selectNvdInfoSndMailList(ossBean);
}
ossBean.setSndMailCheckFlag(CoConstDef.FLAG_YES);
List<Map<String, Object>> discoveredMailSendList = vulnerabilityMapper.selectDiscoveredSndMailList(ossBean);
if (discoveredMailSendList != null && !discoveredMailSendList.isEmpty()) {
List<Map<String, Object>> deduplicatedMailingCheckList = nvdInfoSndMailList.stream()
.filter(e ->
discoveredMailSendList.stream()
.filter(o ->
((String) e.get("PRODUCT") + "|" + (String) e.get("VERSION") + "|" + (String) e.get("CVE_ID") + "|" + ((Float) e.get("CVSS_SCORE")).toString())
.equalsIgnoreCase(((String) o.get("PRODUCT") + "|" + (String) o.get("VERSION") + "|" + (String) o.get("CVE_ID") + "|" + ((Float) o.get("CVSS_SCORE")).toString()))
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
if (deduplicatedMailingCheckList != null && !deduplicatedMailingCheckList.isEmpty()) {
for (Map<String, Object> mailingInfo : deduplicatedMailingCheckList) {
mailingInfo.put("OSS_ID", ossBean.getOssId());
vulnerabilityMapper.insertOssDiscoveredSndEmail(mailingInfo);
rtnNvdInfoSndMailList.add(mailingInfo);
}
}
} else {
for (Map<String, Object> mailingInfo : nvdInfoSndMailList) {
mailingInfo.put("OSS_ID", ossBean.getOssId());
vulnerabilityMapper.insertOssDiscoveredSndEmail(mailingInfo);
rtnNvdInfoSndMailList.add(mailingInfo);
}
}
return rtnNvdInfoSndMailList;
}
private List<Map<String, Object>> filteredNvdData(List<String> _filteredNvdData, List<Map<String, Object>> nvdDataList, boolean fileCheckFlag) {
List<Map<String, Object>> filteredNvdDataList = new ArrayList<>();
if (fileCheckFlag) {
filteredNvdDataList.addAll(nvdDataList);
} else {
List<Map<String, Object>> checkNvdDataList = new ArrayList<>();
checkNvdDataList.addAll(nvdDataList);
for (Map<String, Object> info : checkNvdDataList) {
String checkKey = ((String) info.get("PRODUCT") + "_" + (String) info.get("VERSION") + "_" + (String) info.get("VENDOR") + "_" + (String) info.get("CVE_ID")).toUpperCase();
if (!_filteredNvdData.contains(checkKey)) {
filteredNvdDataList.add(info);
}
}
}
if (filteredNvdDataList != null && !filteredNvdDataList.isEmpty()) {
if (filteredNvdDataList.size() > 1) {
Collections.sort(filteredNvdDataList, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
if (new BigDecimal(o1.get("CVSS_SCORE").toString()).compareTo(new BigDecimal(o2.get("CVSS_SCORE").toString())) > 0) {
return -1;
}else {
return 1;
}
}
});
}
}
return filteredNvdDataList;
}
@Override
public Map<String, Object> getCveInfo(String cveId) {
return vulnerabilityMapper.getCveInfo(cveId);
}
private void updateVulnAndMailing(OssMaster ossBean, Map<String, Object> nvdInfo, String standardScore, List<String> _prjMailList, List<String> _reCalcPrjMailList, List<String> notUsedOssList,
Map<String, OssMaster> reCalcOssInfoMap, Map<String, Map<String, OssMaster>> reCalcCommentsOssInfoMap, Map<String, List<Map<String, Object>>> discoveredCommentsOssInfoMap, List<Map<String, Object>> rtnNvdInfoSndMailList) {
BigDecimal bdScore = new BigDecimal(String.valueOf(nvdInfo.get("CVSS_SCORE")));
BigDecimal bdOrgMasterScore = new BigDecimal(CommonFunction.avoidNull(ossBean.getCvssScore(), "0"));
String cveId = String.valueOf(nvdInfo.get("CVE_ID"));
// ํ์ฌ ๋ฑ๋ก๋์ด ์๋ score์ cve_id๊ฐ ์ผ์นํ์ง ์์ผ๋ฉด ์
๋ฐ์ดํธ
if ( !bdScore.equals(bdOrgMasterScore) || !cveId.equals(ossBean.getCveId())) {
scheduler_log.info("Vulnerability updateOssVulnInfo OSS ID : " + ossBean.getOssId());
ossBean.setCvssScoreTo(String.valueOf(nvdInfo.get("CVSS_SCORE")));
ossBean.setCveIdTo(String.valueOf(nvdInfo.get("CVE_ID")));
vulnerabilityMapper.insertNvdOssHis(ossBean);
OssMaster newNVD = new OssMaster();
newNVD.setOssId(ossBean.getOssId());
newNVD.setCvssScore(ossBean.getCvssScoreTo());
newNVD.setCveId(ossBean.getCveIdTo());
vulnerabilityMapper.updateOssVulnInfoNew(newNVD);
}
// score๊ฐ 7.0 ์ด์์ธ ๊ฒฝ์ฐ๋ง ๋ฉ์ผ์ ๋ฐ์ก
// ์ฒ์์ผ๋ก 9.0 ์ด์ Score๊ฐ ๋ฑ๋ก๋ ๊ฒฝ์ฐ (๊ธฐ์กด Score๊ฐ 9.0 ๋ฏธ๋ง์ด๊ณ NVD update score๊ฐ 9.0 ์ด์์ธ ๊ฒฝ์ฐ)
// vulnerability mail > base score changed from 9.0 to 8.0
// condition change > if the cvss score value matching ossName + ossVersion is 8.0 or higher (new or modify)
// if (bdScore.compareTo(new BigDecimal(standardScore)) > -1 && bdOrgMasterScore.compareTo(new BigDecimal(standardScore)) < 0) {
ossBean.setSndMailCheckFlag(CoConstDef.FLAG_NO);
if (vulnerabilityMapper.checkDiscoveredSndMailCnt(ossBean) > 0) {
String[] nickNameList = ossMapper.checkNickNameRegOss(ossBean.getOssName()).toArray(new String[0]);
ossBean.setOssNames(nickNameList);
List<String> _prjList = vulnerabilityMapper.selectUsedVulnerabilityOssProject(ossBean);
if (_prjList != null && !_prjList.isEmpty()) {
_prjMailList.addAll(_prjList);
for (String prj : _prjList) {
if (discoveredCommentsOssInfoMap.containsKey(prj)) {
List<Map<String, Object>> discoveredCommentsOssInfoList = discoveredCommentsOssInfoMap.get(prj);
discoveredCommentsOssInfoList.addAll(rtnNvdInfoSndMailList);
discoveredCommentsOssInfoMap.put(prj, discoveredCommentsOssInfoList);
} else {
discoveredCommentsOssInfoMap.put(prj, rtnNvdInfoSndMailList);
}
}
}
notUsedOssList.add(ossBean.getOssName().toUpperCase()+"_"+ossBean.getOssVersion());
}
// NVD Score๊ฐ 9.0 ๋ฏธ๋ง์ด๋ฉด์ ๊ธฐ์กด Score๊ฐ 9.0 ์ด์์ธ ๊ฒฝ์ฐ, Score๊ฐ ๋ณ๊ฒฝ๋์์์ ๋ฉ์ผ๋ก ํต์ง
// vulnerability mail > base score changed from 9.0 to 8.0
if (bdScore.compareTo(new BigDecimal(standardScore)) < 0 && bdOrgMasterScore.compareTo(new BigDecimal(standardScore)) > -1) {
String[] nickNameList = ossMapper.checkNickNameRegOss(ossBean.getOssName()).toArray(new String[0]);
ossBean.setOssNames(nickNameList);
List<String> _prjList = vulnerabilityMapper.selectUsedVulnerabilityOssProject(ossBean);
if (_prjList != null && !_prjList.isEmpty()) {
_reCalcPrjMailList.addAll(_prjList);
for (String prj : _prjList) {
Map<String, OssMaster> reCalcCommentsOssInfo = null;
if (reCalcCommentsOssInfoMap.containsKey(prj)) {
reCalcCommentsOssInfo = reCalcCommentsOssInfoMap.get(prj);
} else {
reCalcCommentsOssInfo = new HashMap<>();
}
reCalcCommentsOssInfo.put(ossBean.getOssName().toUpperCase()+"_"+ossBean.getOssVersion(), ossBean);
reCalcCommentsOssInfoMap.put(prj, reCalcCommentsOssInfo);
}
}
reCalcOssInfoMap.put(ossBean.getOssName().toUpperCase()+"_"+ossBean.getOssVersion(), ossBean);
}
}
@Override
public List<String> getPatchLinkForNvdData(String cveId) {
return vulnerabilityMapper.getPatchLinkForNvdData(cveId);
}
@Override
public List<Vulnerability> getSecurityVulnListByOssName(OssMaster bean) {
if ("N/A".equals(bean.getOssVersion()) || isEmpty(bean.getOssVersion())) {
bean.setOssVersion("-");
}
String securityStandardScore = codeMapper.getCodeDetail(CoConstDef.CD_SECURITY_VULNERABILITY_SCORE, CoConstDef.CD_SECURITY_VULNERABILITY_DETAIL_SCORE).getCdDtlExp();
List<Vulnerability> list = null;
String[] nicknameList = null;
List<String> convertNicknameList = null;
List<String> vendorProductSearchList = new ArrayList<>();
boolean convertFlag = false;
String ossName = null;
try {
nicknameList = ossService.getOssNickNameListByOssName(bean.getOssName());
if(nicknameList.length == 0) {
if (bean.getOssName().contains("_")) {
ossName = bean.getOssName();
bean.setOssName(bean.getOssName().replaceAll("_", " "));
}
nicknameList = ossService.getOssNickNameListByOssName(bean.getOssName());
}
if (bean.getOssName().contains("-")) {
vendorProductSearchList.add(bean.getOssName());
vendorProductSearchList.add(ossName);
}
if(nicknameList.length > 0) {
for (String nick : nicknameList) {
if (nick.contains(" ")) {
if (!convertFlag) {
convertNicknameList = new ArrayList<>();
convertFlag = true;
}
convertNicknameList.add(nick.replaceAll(" ", "_"));
}
if (nick.contains("-")) {
vendorProductSearchList.add(nick);
}
}
if (convertNicknameList != null && !convertNicknameList.isEmpty()) {
if (bean.getOssName().contains(" ")) convertNicknameList.add(bean.getOssName().replaceAll(" ", "_"));
convertNicknameList.addAll(Arrays.asList(nicknameList));
convertNicknameList = convertNicknameList.stream().distinct().collect(Collectors.toList());
nicknameList = convertNicknameList.toArray(new String[convertNicknameList.size()]);
} else {
if (bean.getOssName().contains(" ")) {
convertNicknameList = new ArrayList<>();
convertNicknameList.add(bean.getOssName().replaceAll(" ", "_"));
convertNicknameList.addAll(Arrays.asList(nicknameList));
convertNicknameList = convertNicknameList.stream().distinct().collect(Collectors.toList());
nicknameList = convertNicknameList.toArray(new String[convertNicknameList.size()]);
}
}
} else {
if (bean.getOssName().contains(" ")) {
nicknameList = new String[] {bean.getOssName().replaceAll(" ", "_")};
}
}
if (vendorProductSearchList != null && !vendorProductSearchList.isEmpty()) {
bean.setOssNicknameArr(vendorProductSearchList.toArray(new String[vendorProductSearchList.size()]));
} else {
bean.setOssNicknameArr(null);
}
bean.setOssNicknames(nicknameList);
bean.setSecurityStandardScore(Float.valueOf(securityStandardScore));
list = vulnerabilityMapper.getSecurityVulnListByOssName(bean);
list = list.stream().filter(CommonFunction.distinctByKey(e->e.getCveId()+e.getCvssScore())).sorted(Comparator.comparing(Vulnerability::getCvssScore).reversed()).collect(Collectors.toList());
} catch (Exception e) {
log.error(e.getMessage());
}
return list;
}
@Override
public List<Map<String, Object>> getCpeInfoAndRange(String cveId, String ossName) {
return vulnerabilityMapper.getCpeInfoAndRange(cveId, ossName);
}
@Override
public Vulnerability selectNotFixedCveInfo(OssMaster bean) {
if ("N/A".equals(bean.getOssVersion()) || isEmpty(bean.getOssVersion())) {
bean.setOssVersion("-");
}
Vulnerability vuln = null;
String[] nicknameList = null;
List<String> convertNicknameList = null;
List<String> vendorProductSearchList = new ArrayList<>();
boolean convertFlag = false;
String ossName = null;
try {
nicknameList = ossService.getOssNickNameListByOssName(bean.getOssName());
if(nicknameList.length == 0) {
if (bean.getOssName().contains("_")) {
ossName = bean.getOssName();
bean.setOssName(bean.getOssName().replaceAll("_", " "));
}
nicknameList = ossService.getOssNickNameListByOssName(bean.getOssName());
}
if (bean.getOssName().contains("-")) {
vendorProductSearchList.add(bean.getOssName());
vendorProductSearchList.add(ossName);
}
if(nicknameList.length > 0) {
for (String nick : nicknameList) {
if (nick.contains(" ")) {
if (!convertFlag) {
convertNicknameList = new ArrayList<>();
convertFlag = true;
}
convertNicknameList.add(nick.replaceAll(" ", "_"));
}
if (nick.contains("-")) {
vendorProductSearchList.add(nick);
}
}
if (convertNicknameList != null && !convertNicknameList.isEmpty()) {
if (bean.getOssName().contains(" ")) convertNicknameList.add(bean.getOssName().replaceAll(" ", "_"));
convertNicknameList.addAll(Arrays.asList(nicknameList));
convertNicknameList = convertNicknameList.stream().distinct().collect(Collectors.toList());
nicknameList = convertNicknameList.toArray(new String[convertNicknameList.size()]);
} else {
if (bean.getOssName().contains(" ")) {
convertNicknameList = new ArrayList<>();
convertNicknameList.add(bean.getOssName().replaceAll(" ", "_"));
convertNicknameList.addAll(Arrays.asList(nicknameList));
convertNicknameList = convertNicknameList.stream().distinct().collect(Collectors.toList());
nicknameList = convertNicknameList.toArray(new String[convertNicknameList.size()]);
}
}
} else {
if (bean.getOssName().contains(" ")) {
nicknameList = new String[] {bean.getOssName().replaceAll(" ", "_")};
}
}
if (vendorProductSearchList != null && !vendorProductSearchList.isEmpty()) {
bean.setOssNicknameArr(vendorProductSearchList.toArray(new String[vendorProductSearchList.size()]));
vuln = vulnerabilityMapper.selectNotFixedCveInfo(bean);
}
if (vuln == null) {
bean.setOssNicknames(nicknameList);
vuln = vulnerabilityMapper.selectNotFixedCveInfo(bean);
}
} catch (Exception e) {
log.error(e.getMessage());
}
return vuln;
}
@Override
public boolean getCpeMatchForCpeInfoCnt(Map<String, Object> paramMap) {
return vulnerabilityMapper.getCpeMatchForCpeInfoCnt(paramMap) > 0 ? true : false;
}
}
| 42,902 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProjectServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ProjectServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.base.Functions;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.OssNotice;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.T2Users;
import oss.fosslight.domain.UploadFile;
import oss.fosslight.domain.Vulnerability;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.T2UserMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.FileService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.ProjectService;
import oss.fosslight.service.VerificationService;
import oss.fosslight.service.VulnerabilityService;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
import oss.fosslight.validation.T2CoValidationConfig;
import oss.fosslight.validation.T2CoValidationResult;
import oss.fosslight.validation.custom.T2CoProjectValidator;
@Service
@Slf4j
public class ProjectServiceImpl extends CoTopComponent implements ProjectService{
// Service
@Autowired OssService ossService;
@Autowired VerificationService verificationService;
@Autowired FileService fileService;
@Autowired VulnerabilityService vulnerabilityService;
@Autowired CommentService commentService;
// Mapper
@Autowired ProjectMapper projectMapper;
@Autowired T2UserMapper userMapper;
@Autowired PartnerMapper partnerMapper;
@Autowired CodeMapper codeMapper;
@Override
@Cacheable(value="autocompleteProjectCache", key="{#root.methodName, #project?.creator, #project?.identificationStatus}")
public List<Project> getProjectNameList(Project project) {
return projectMapper.getProjectNameList(project);
}
@Override
@Cacheable(value="autocompleteProjectCache", key="{#root.methodName, #project?.creator, #project?.identificationStatus}")
public List<Project> getProjectIdList(Project project) {
return projectMapper.getProjectIdList(project);
}
@Override
@Cacheable(value="autocompleteProjectCache", key="{#root.methodName, #project?.creator}")
public List<Project> getProjectModelNameList() {
return projectMapper.getProjectModelNameList();
}
@Override
public String getReviewerList(String adminYn) {
String ldapFlag = CoCodeManager.getCodeExpString(CoConstDef.CD_SYSTEM_SETTING, CoConstDef.CD_LDAP_USED_FLAG);
List<T2Users> userList = userMapper.selectReviwer(adminYn, ldapFlag);
StringBuilder sb = new StringBuilder();
sb.append( " : " + ";");
for (T2Users user : userList) {
user.getUserId();
sb.append(user.getUserId() + ":" + user.getUserName() + ";");
}
return sb.toString();
}
@Override
public String getAdminUserList() {
List<T2Users> userList = userMapper.selectAdminUser();
StringBuilder sb = new StringBuilder();
sb.append( " : " + ";");
for (T2Users user : userList) {
user.getUserId();
sb.append(user.getUserId() + ":" + user.getUserName() + ";");
}
return sb.toString();
}
@Override
public Map<String, Object> getProjectList(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = null;
String standardScore = CoCodeManager.getCodeExpString(CoConstDef.CD_VULNERABILITY_MAILING_SCORE, CoConstDef.CD_VULNERABILITY_MAILING_SCORE_STANDARD);
try {
// OSS NAME์ผ๋ก ๊ฒ์ํ๋ ๊ฒฝ์ฐ NICK NAME์ ํฌํจํ๋๋ก ์ถ๊ฐ
if (!isEmpty(project.getOssName()) && CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(project.getOssName().toUpperCase())) {
String[] nickNames = ossService.getOssNickNameListByOssName(project.getOssName());
if (nickNames != null && nickNames.length > 0) {
project.setOssNickNames(nickNames);
}
}
int records = projectMapper.selectProjectTotalCount(project);
project.setTotListSize(records);
String ossId = project.getOssId();
if (!StringUtil.isEmpty(ossId)) {
list = projectMapper.selectUnlimitedOssComponentBomList(project);
} else {
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
if (CommonFunction.propertyFlagCheck("menu.bat.use.flag", CoConstDef.FLAG_NO)) {
project.setIdentificationSubStatusBat(CoConstDef.FLAG_NO);
}
list = projectMapper.selectProjectList(project);
if (list != null) {
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
identification.setMerge(CoConstDef.FLAG_NO);
List<String> customNvdMaxScoreInfoList = new ArrayList<>();
// ์ฝ๋๋ณํ์ฒ๋ฆฌ
for (Project bean : list) {
bean.setStandardScore(Float.valueOf(standardScore));
// DISTRIBUTION Android Flag
String androidFlag = CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equalsIgnoreCase(avoidNull(bean.getNoticeType())) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO;
bean.setAndroidFlag(androidFlag);
if (CoConstDef.FLAG_YES.equals(androidFlag)) {
bean.setNoticeTypeEtc(CommonFunction.tabTitleSubStr(CoConstDef.CD_PLATFORM_GENERATED, bean.getNoticeTypeEtc()));
}
// DISTRIBUTION_TYPE
bean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, bean.getDistributionType()));
// Project Status
bean.setStatus(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_STATUS, bean.getStatus()));
// Project priority
bean.setPriority(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, bean.getPriority()));
// Identification Status
bean.setIdentificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getIdentificationStatus()));
// Verification Status
bean.setVerificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getVerificationStatus()));
// Distribute Status
String distributionStatus = CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROCESS.equals(bean.getDestributionStatus())
? CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROGRESS : bean.getDestributionStatus();
bean.setDestributionStatus(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_STATUS, distributionStatus));
// DIVISION
bean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, bean.getDivision()));
if (!CoConstDef.FLAG_YES.equals(androidFlag)) {
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
} else {
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID);
}
if (getSecurityDataCntByProject(bean)) {
if (checkIfVulnerabilityResolutionIsFixed(bean)) {
bean.setSecCode("Fixed");
} else {
bean.setSecCode("NotFixed");
}
}
List<String> nvdMaxScoreInfoList = projectMapper.findIdentificationMaxNvdInfo(bean.getPrjId(), bean.getReferenceDiv());
List<String> nvdMaxScoreInfoList2 = projectMapper.findIdentificationMaxNvdInfoForVendorProduct(bean.getPrjId(), bean.getReferenceDiv());
if (nvdMaxScoreInfoList != null && !nvdMaxScoreInfoList.isEmpty()) {
nvdMaxScoreInfoList = nvdMaxScoreInfoList.stream().distinct().collect(Collectors.toList());
String conversionCveInfo = CommonFunction.checkNvdInfoForProduct(ossInfoMap, nvdMaxScoreInfoList);
if (conversionCveInfo != null) {
customNvdMaxScoreInfoList.add(conversionCveInfo);
}
}
if (nvdMaxScoreInfoList2 != null && !nvdMaxScoreInfoList2.isEmpty()) {
customNvdMaxScoreInfoList.addAll(nvdMaxScoreInfoList2);
}
if (customNvdMaxScoreInfoList != null && !customNvdMaxScoreInfoList.isEmpty()) {
String conversionCveInfo = CommonFunction.getConversionCveInfoForList(customNvdMaxScoreInfoList);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
bean.setCvssScore(conversionCveData[3]);
bean.setCveId(conversionCveData[4]);
bean.setVulnYn(CoConstDef.FLAG_YES);
}
}
customNvdMaxScoreInfoList.clear();
}
}
}
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
} catch (Exception e) {
log.error(e.getMessage());
}
return map;
}
private boolean checkIfVulnerabilityResolutionIsFixed(Project bean) {
return projectMapper.selectVulnerabilityResolutionSecurityListCnt(bean) > 0 ? false : true;
}
private boolean getSecurityDataCntByProject(Project project) {
return projectMapper.getSecurityDataCntByProject(project) > 0 ? true : false;
}
@Override
public Project getProjectDetail(Project project) {
String standardScore = CoCodeManager.getCodeExpString(CoConstDef.CD_VULNERABILITY_MAILING_SCORE, CoConstDef.CD_VULNERABILITY_MAILING_SCORE_STANDARD);
// master
project = projectMapper.selectProjectMaster(project);
// ์ด์ ์ ์์ฑ๋ ํ๋ก์ ํธ๋ฅผ ์ํด Default๋ฅผ ์ค์ ํ๋ค.
Map<String, Object> NoticeInfo = projectMapper.getNoticeType(project.getPrjId());
if (NoticeInfo == null) {
NoticeInfo = new HashMap<>();
}
project.setNoticeType(avoidNull((String) NoticeInfo.get("noticeType"), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL));
project.setNoticeTypeEtc(avoidNull((String) NoticeInfo.get("noticeTypeEtc")));
project.setAndroidFlag(CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equals(avoidNull(project.getNoticeType())) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
// watcher
List<Project> watcherList = projectMapper.selectWatchersList(project);
project.setWatcherList(watcherList);
// file
if (!isEmpty(project.getSrcCsvFileId())) {
project.setCsvFile(projectMapper.selectCsvFile(project.getSrcCsvFileId()));
}
if (!isEmpty(project.getDepCsvFileId())) {
project.setDepCsvFile(projectMapper.selectCsvFile(project.getDepCsvFileId()));
}
if (!isEmpty(project.getBinCsvFileId())) {
project.setBinCsvFile(projectMapper.selectCsvFile(project.getBinCsvFileId()));
}
if (!isEmpty(project.getBinBinaryFileId())) {
project.setBinBinaryFile(projectMapper.selectFileInfoById(project.getBinBinaryFileId()));
}
project.setAndroidCsvFile(projectMapper.selectAndroidCsvFile(project));
project.setAndroidNoticeFile(projectMapper.selectAndroidNoticeFile(project));
project.setAndroidResultFile(projectMapper.selectAndroidResultFile(project));
// button(์ญ์ /๋ณต์ฌ/์ ์ฅ) view ์ฌ๋ถ
if (CommonFunction.isAdmin()) {
project.setViewOnlyFlag(CoConstDef.FLAG_NO);
} else {
project.setViewOnlyFlag(projectMapper.selectViewOnlyFlag(project));
}
int resultCnt = projectMapper.getOssAnalysisDataCnt(project);
if (resultCnt > 0) {
Project analysisStatus = projectMapper.getOssAnalysisData(project);
project.setAnalysisStartDate(analysisStatus.getAnalysisStartDate());
project.setOssAnalysisStatus(analysisStatus.getOssAnalysisStatus());
}
if (project.getAndroidFlag().equals(CoConstDef.FLAG_YES)) {
project.setStandardScore(Float.valueOf(standardScore));
project.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID);
if (getSecurityDataCntByProject(project)) {
project.setSecCode(CoConstDef.FLAG_YES);
}
} else {
if (!project.getIdentificationSubStatusBom().equals("0")) {
project.setStandardScore(Float.valueOf(standardScore));
project.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
if (getSecurityDataCntByProject(project)) {
project.setSecCode(CoConstDef.FLAG_YES);
}
}
}
project.setStandardScore(null);
return project;
}
@Override
public Map<String, Object> getIdentificationGridList(ProjectIdentification identification) {
return getIdentificationGridList(identification, false);
}
@Override
public Map<String, Object> getIdentificationGridList(ProjectIdentification identification, boolean multiUIFlag) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<ProjectIdentification> list = null;
List<OssComponentsLicense> listLicense = null;
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
identification.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
if (CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST != null && !CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST.isEmpty()) {
identification.setRoleOutLicenseIdList(CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST);
}
boolean isLoadFromProject = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefPrjId());
if (isLoadFromProject) {
identification.setReferenceId(identification.getRefPrjId());
}
boolean isApplyFromBat = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefBatId());
if (isApplyFromBat) {
identification.setReferenceId(identification.getRefBatId());
}
// bom ์ผ์
if (CoConstDef.CD_DTL_COMPONENT_ID_BOM.equals(identification.getReferenceDiv())) {
Map<String, String> obligationTypeMergeMap = new HashMap<>();
String reqMergeFlag = identification.getMerge();
list = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(identification);;
if (notVersionList != null) {
list.addAll(notVersionList);
}
identification.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
list.sort(compare);
// For loading 3rd Party ID
ProjectIdentification thirdPartyOssListParam = new ProjectIdentification();
thirdPartyOssListParam.setReferenceId(identification.getReferenceId());
thirdPartyOssListParam.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
List<ProjectIdentification> thirdList = null;
Map<String, Object> thirdlistMap = getIdentificationGridList(thirdPartyOssListParam);
Map<String, String> thirdPartyNameListByOssMap = new HashMap<>();
String keySeparater = ":::";
if (thirdlistMap != null && (thirdlistMap.containsKey("mainData") || thirdlistMap.containsKey("rows"))) {
thirdList = (List<ProjectIdentification>) thirdlistMap.get(thirdlistMap.containsKey("mainData") ? "mainData" : "rows");
if (thirdList != null) {
for (ProjectIdentification bean : thirdList) {
if (CoConstDef.FLAG_NO.equals(avoidNull(bean.getExcludeYn(), CoConstDef.FLAG_NO))) {
String value = bean.getRefPartnerId();
if (value != null) {
String rowOssName = avoidNull(bean.getOssName()).toUpperCase();
String rowOssVersion = avoidNull(bean.getOssVersion()).toUpperCase();
String strKey = rowOssName + keySeparater + rowOssVersion + keySeparater;
if (isEmpty(rowOssName) || rowOssName.equals("-")) {
String rowOssLicense = avoidNull(bean.getLicenseName()).toUpperCase();
strKey = rowOssName + keySeparater + rowOssVersion + keySeparater + rowOssLicense;
}
thirdPartyNameListByOssMap.put(strKey, thirdPartyNameListByOssMap.containsKey(strKey) ? thirdPartyNameListByOssMap.get(strKey) + "," + value : value);
}
}
}
}
}
// bom merge ๋ฒํผ์ ํด๋ฆญํ๊ณ , ํ์๋์์ด ์์ ๊ฒฝ์ฐ, ๊ธฐ์กด์ ์ ์ฅ๋์ด ์๋ ๋ด์ฉ์ ์ทจ๋ํ๋ค.
// need check์ ์ ์ฅ๊ฐ์ ์ ์งํ๊ธฐ ์ํจ
if (CoConstDef.FLAG_YES.equals(reqMergeFlag) && list != null && !list.isEmpty()) {
identification.setMerge(CoConstDef.FLAG_NO);
List<ProjectIdentification> bomBeforeList = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> bomBeforeNotVersionList = projectMapper.selectBomList(identification);;
if (bomBeforeNotVersionList != null) {
bomBeforeList.addAll(bomBeforeNotVersionList);
}
identification.setOssVersionEmptyFlag(null);
bomBeforeList.sort(compare);
if (bomBeforeList != null) {
for (ProjectIdentification _orgIdentificationBean : bomBeforeList) {
obligationTypeMergeMap.put(_orgIdentificationBean.getRefComponentId(), _orgIdentificationBean.getObligationType());
}
}
}
Map<String, ProjectIdentification> mergeDepMap = new HashMap<>();
Map<String, ProjectIdentification> batMergeSrcMap = new HashMap<>();
Map<String, ProjectIdentification> batMergePartnerMap = new HashMap<>();
// convert max score
List<String> cvssScoreMaxList = new ArrayList<>();
List<String> cvssScoreMaxVendorProductList = new ArrayList<>();
Map<String, List<OssComponentsLicense>> bomLicenseMap = new HashMap<>();
List<OssComponentsLicense> bomLicenseList = projectMapper.selectBomLicenseList(identification);
for (OssComponentsLicense ocl : bomLicenseList) {
String key = ocl.getComponentId();
List<OssComponentsLicense> bomLicenses = null;
if (bomLicenseMap.containsKey(key)) {
bomLicenses = bomLicenseMap.get(ocl.getComponentId());
} else {
bomLicenses = new ArrayList<>();
}
bomLicenses.add(ocl);
bomLicenseMap.put(key, bomLicenses);
}
for (ProjectIdentification ll : list) {
ll.setLicenseId(CommonFunction.removeDuplicateStringToken(ll.getLicenseId(), ","));
ll.setLicenseName(CommonFunction.removeDuplicateStringToken(ll.getLicenseName(), ","));
ll.setCopyrightText(ll.getCopyrightText());
ll.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
if (bomLicenseMap.containsKey(ll.getComponentId())) {
ll.setOssComponentsLicenseList(bomLicenseMap.get(ll.getComponentId()));
ll.setObligationLicense(CoConstDef.FLAG_YES.equals(ll.getAdminCheckYn()) ? CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK : CommonFunction.checkObligationSelectedLicense(bomLicenseMap.get(ll.getComponentId())));
}
// listLicense = projectMapper.selectBomLicense(ll);
// ll.setOssComponentsLicenseList(listLicense);
// ll.setObligationLicense(CoConstDef.FLAG_YES.equals(ll.getAdminCheckYn()) ? CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK : CommonFunction.checkObligationSelectedLicense(listLicense));
if (CoConstDef.FLAG_YES.equals(reqMergeFlag)) {
if (obligationTypeMergeMap.containsKey(ll.getComponentId())) {
ll.setObligationType(obligationTypeMergeMap.get(ll.getComponentId()));
} else {
ll.setObligationType(ll.getObligationLicense());
}
}
// grouping ๋ file path๋ฅผ br tag๋ก ๋ณ๊ฒฝ
ll.setFilePath(CommonFunction.lineReplaceToBR(ll.getFilePath()));
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(ll.getReferenceDiv())) {
if (!batMergeSrcMap.containsKey(ll.getOssName().toUpperCase())) {
batMergeSrcMap.put(ll.getOssName().toUpperCase(), ll);
} else if (StringUtil.compareTo(ll.getOssVersion(), batMergeSrcMap.get(ll.getOssName().toUpperCase()).getOssVersion()) > 0) {
batMergeSrcMap.replace(ll.getOssName().toUpperCase(), ll);
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_PARTNER.equals(ll.getReferenceDiv())) {
if (!batMergePartnerMap.containsKey(ll.getOssName().toUpperCase())) {
batMergePartnerMap.put(ll.getOssName().toUpperCase(), ll);
} else if (StringUtil.compareTo(ll.getOssVersion(), batMergePartnerMap.get(ll.getOssName().toUpperCase()).getOssVersion()) > 0) {
batMergePartnerMap.replace(ll.getOssName().toUpperCase(), ll);
}
}
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (isEmpty(ll.getCveId())
&& isEmpty(ll.getOssVersion())
&& !isEmpty(ll.getCvssScoreMax())
&& !("-".equals(ll.getOssName()))){
String[] cvssScoreMax = ll.getCvssScoreMax().split("\\@");
ll.setCvssScore(cvssScoreMax[3]);
ll.setCveId(cvssScoreMax[4]);
}
// convert max score
if (ll.getCvssScoreMax() != null) {
cvssScoreMaxList.add(ll.getCvssScoreMax());
}
if (ll.getCvssScoreMax1() != null) {
cvssScoreMaxVendorProductList.add(ll.getCvssScoreMax1());
}
if (ll.getCvssScoreMax2() != null) {
cvssScoreMaxList.add(ll.getCvssScoreMax2());
}
if (ll.getCvssScoreMax3() != null) {
cvssScoreMaxVendorProductList.add(ll.getCvssScoreMax3());
}
String conversionCveInfo = CommonFunction.getConversionCveInfo(ll.getReferenceId(), ossInfoMap, ll, cvssScoreMaxVendorProductList, cvssScoreMaxList, true);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
ll.setCvssScore(conversionCveData[3]);
ll.setCveId(conversionCveData[4]);
ll.setVulnYn(CoConstDef.FLAG_YES);
}
cvssScoreMaxVendorProductList.clear();
cvssScoreMaxList.clear();
if (CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(ll.getRefDiv())) {
String _key = ll.getOssName() + "-" + avoidNull(ll.getOssVersion());
mergeDepMap.put(_key, ll);
}
}
// bat merget
// bat ๋ถ์ ๊ฒฐ๊ณผ ์ค์์ oss version์ด ๋ช
์๋์ง ์๊ณ , src ๋๋ 3rd party์ ๋์ผํ oss ๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
// bat ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ src ๋๋ 3rd party์ merge ํ๋ค.
List<ProjectIdentification> _list = new ArrayList<>();
List<String> adminCheckList = new ArrayList<>();
List<ProjectIdentification> groupList = null;
Map<String, List<ProjectIdentification>> srcSameLicenseMap = new HashMap<>();
List<String> egnoreList = new ArrayList<>();
for (ProjectIdentification ll : list) {
// ์ด๋ฏธ ์ถ๊ฐ๋ oss์ ๊ฒฝ์ฐ
if (egnoreList.contains(ll.getComponentId())) {
continue;
}
int addIdx = -1;
if (!isEmpty(ll.getOssName())) {
String mergeKey = ll.getOssName().toUpperCase();
// main oss๋ก ํ์๋๋ bat oss์ version์ด ๋ช
์๋์ด ์์ง ์์ ๊ฒฝ์ฐ
if (CoConstDef.CD_DTL_COMPONENT_ID_BAT.equals(ll.getReferenceDiv()) && isEmpty(ll.getMergePreDiv()) && isEmpty(ll.getOssVersion())) {
ProjectIdentification refBean = null;
if ( batMergeSrcMap.containsKey(mergeKey)) {
// bat => src
refBean = batMergeSrcMap.get(mergeKey);
// ์ค์ ๋ license๊ฐ ์์ดํ๊ณ , bat์ ๋์ผํ license๊ฐ src์ ์กด์ฌํ๋ค๋ฉด (์ต์์ ๋ฒ์ ์ด ์๋๊ฒฝ์ฐ)
// continueํ๊ณ ๋ค์ loop์์ merge
if (!CommonFunction.isSameLicense(refBean.getOssComponentsLicenseList(), ll.getOssComponentsLicenseList())) {
String ossNameAndVersion = findBatOssOtherVersionWithLicense(ll, refBean, list);
if (!isEmpty(ossNameAndVersion)) {
List<ProjectIdentification> _batList = null;
if (srcSameLicenseMap.containsKey(ossNameAndVersion)) {
_batList = srcSameLicenseMap.get(ossNameAndVersion);
_batList.add(ll);
srcSameLicenseMap.replace(ossNameAndVersion, _batList);
} else {
_batList = new ArrayList<>();
_batList.add(ll);
srcSameLicenseMap.put(ossNameAndVersion, _batList);
}
continue;
}
}
ll.setOssId(refBean.getOssId());
ll.setOssName(refBean.getOssName());
ll.setOssVersion(refBean.getOssVersion());
ll.setOssComponentsLicenseList(refBean.getOssComponentsLicenseList());
// ์์ ์ ๋ ฌ
addIdx = findOssAppendIndex(CoConstDef.CD_DTL_COMPONENT_ID_SRC, refBean.getComponentId(), list);
if (addIdx > -1) {
addIdx = addIdx +1;
ll.setGroupingColumn(refBean.getOssName() + refBean.getOssVersion());
}
} else if ( batMergePartnerMap.containsKey(mergeKey)) {
// 3rd => bat
refBean = batMergePartnerMap.get(mergeKey);
// 3rd์ ๊ฐ์ ๊ทธ๋ฃน์ผ๋ก ๋ฌถ์ฌ ์๋ ๋ชจ๋ oss list๋ฅผ ์ทจ๋
ll.setGroupingColumn(refBean.getOssName() + refBean.getOssVersion());
ll.setOssName(refBean.getOssName());
ll.setOssVersion(refBean.getOssVersion());
ll.setOssId(refBean.getOssId());
// bin ์ ๋๋ฝ๋ ์ ๋ณด๋ฅผ 3rd์ ์ฒซ๋ฒ์ฌ row์์ ์ฑ์ ๋ฃ๋๋ค.
// DOWNLOAD_LOCATION
if (isEmpty(ll.getDownloadLocation())) {
ll.setDownloadLocation(refBean.getDownloadLocation());
}
// HOMEPAGE
if (isEmpty(ll.getHomepage())) {
ll.setHomepage(refBean.getHomepage());
}
// license ์ ๋ณด
ll.setOssComponentsLicenseList(refBean.getOssComponentsLicenseList());
ll.setLicenseName(refBean.getLicenseName());
ll.setCopyrightText(refBean.getCopyrightText());
ll.setObligationLicense(refBean.getObligationLicense());
ll.setObligationType(refBean.getObligationType());
// 3rd party์ ์ฐ์ ์์๊ฐ ๊ฐ์ฅ ๋ฎ๊ธฐ ๋๋ฌธ์, ๋ณต์๊ฑด์ ์ทจ๋ํ๋ ๊ฒฝ์ฐ๋ ์์ง๋ง, ๊ธฐ๋ฅ ํ์ฅ์ ๊ณ ๋ คํด์ list ํ์ผ๋ก ๋ฐํ
groupList = findOssGroupList(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER, batMergePartnerMap.get(mergeKey).getOssName(), batMergePartnerMap.get(mergeKey).getOssVersion(), list);
if (groupList != null && !groupList.isEmpty()) {
for (ProjectIdentification _groupBean : groupList) {
egnoreList.add(_groupBean.getComponentId());
}
}
}
}
// 3rd party์ ๊ฒฝ์ฐ, bat์ ๋์ผํ oss๊ฐ ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐ (์ ๋ ฌ)
else if (CoConstDef.CD_DTL_COMPONENT_ID_PARTNER.equals(ll.getReferenceDiv()) && isEmpty(ll.getMergePreDiv()) ) {
if (existsBatOSS(ll.getOssName(), list)) {
continue;
}
}
}
// Set 3rd Party IDs
String rowOssName = avoidNull(ll.getOssName()).toUpperCase();
String rowOssVersion = avoidNull(ll.getOssVersion()).toUpperCase();
String strKey = rowOssName + keySeparater + rowOssVersion + keySeparater;
if (isEmpty(rowOssName) || rowOssName.equals("-")) {
String rowOssLicense = avoidNull(ll.getLicenseName()).toUpperCase();
strKey = rowOssName + keySeparater + rowOssVersion + keySeparater + rowOssLicense;
}
if (thirdPartyNameListByOssMap.containsKey(strKey)) {
ll.setRefPartnerId(thirdPartyNameListByOssMap.get(strKey));
}
// License Restriction ์ ์ฅ
ll.setRestriction(CommonFunction.setLicenseRestrictionListById(ll.getLicenseId()));
if (addIdx > -1) {
if (addIdx > _list.size() -1) {
_list.add(ll);
} else {
_list.add(addIdx, ll);
}
} else {
_list.add(ll);
if (groupList != null && !groupList.isEmpty()) {
_list.addAll(groupList);
}
}
if (CoConstDef.FLAG_YES.equals(ll.getAdminCheckYn())) {
adminCheckList.add(ll.getComponentId());
}
}
// src oss์ค์์ bat์ mergeํ ์ ์๋ ๋์ผํ oss์ ์ต์ version ์ธ ๋ผ์ด์ ์ค๊น์ง ๋์ผํ bat๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
if (!srcSameLicenseMap.isEmpty()) {
List<ProjectIdentification> _tmp = new ArrayList<>();
for (ProjectIdentification bean : _list) {
_tmp.add(bean);
String _key = bean.getOssName() + "-" + avoidNull(bean.getOssVersion());
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(bean.getReferenceDiv()) && srcSameLicenseMap.containsKey(_key)) {
for (ProjectIdentification _mergeBean : srcSameLicenseMap.get(_key)) {
_mergeBean.setOssId(bean.getOssId());
_mergeBean.setOssName(bean.getOssName());
_mergeBean.setOssVersion(bean.getOssVersion());
_mergeBean.setOssComponentsLicenseList(bean.getOssComponentsLicenseList());
_mergeBean.setGroupingColumn(bean.getGroupingColumn()); // ์์ ์ ๋ ฌ
_tmp.add(_mergeBean);
}
}
}
_list = _tmp;
}
map.put("rows", _list);
if (adminCheckList.size() > 0) {
map.put("adminCheckList", adminCheckList);
}
} else { // bom ์ธ ์๋ธ ๊ทธ๋ฆฌ๋
// bat oss list๋ฅผ ๋์
// ์ ๋ ฌ ์์๋ฅผ ๋ณ๊ฒฝํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_BAT.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_BAT.equals(identification.getReferenceDiv())) {
identification.setSortAndroidFlag(CoConstDef.FLAG_YES);
}
String loadToListComment = "";
if (!isEmpty(identification.getRefPrjId()) &&
(CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(identification.getReferenceDiv()) || CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(identification.getReferenceDiv()))) {
loadToListComment = "(From Prj " + identification.getRefPrjId() + ")";
}
HashMap<String, Object> subMap = new HashMap<String, Object>();
// src, bin, bin(android) ์ ๊ฒฝ์ฐ๋ง comment๋ฅผ ํฌํจํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(identification.getReferenceDiv())) {
identification.setIncCommentsFlag(CoConstDef.FLAG_YES);
}
list = projectMapper.selectIdentificationGridList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionOssComponentList = projectMapper.selectIdentificationGridList(identification);;
if (notVersionOssComponentList != null) {
list.addAll(notVersionOssComponentList);
}
identification.setOssVersionEmptyFlag(null);
list.sort(Comparator.comparing(ProjectIdentification::getComponentId));
if (list != null && !list.isEmpty()) {
List<String> cvssScoreMaxList = new ArrayList<>();
List<String> cvssScoreMaxVendorProductList = new ArrayList<>();
for (ProjectIdentification project : list){
String _test = project.getOssName().trim() + "_" + project.getOssVersion().trim();
String _test2 = project.getOssName().trim() + "_" + project.getOssVersion().trim() + ".0";
String licenseDiv = "";
if (CoCodeManager.OSS_INFO_UPPER.containsKey(_test.toUpperCase())){
licenseDiv = CoCodeManager.OSS_INFO_UPPER.get(_test.toUpperCase()).getLicenseDiv();
} else if (CoCodeManager.OSS_INFO_UPPER.containsKey(_test2.toUpperCase())){
licenseDiv = CoCodeManager.OSS_INFO_UPPER.get(_test2.toUpperCase()).getLicenseDiv();
}
project.setLicenseDiv(licenseDiv);
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (isEmpty(project.getCveId())
&& isEmpty(project.getOssVersion())
&& !isEmpty(project.getCvssScoreMax())
&& !("-".equals(project.getOssName()))){
String[] cvssScoreMax = project.getCvssScoreMax().split("\\@");
project.setCvssScore(cvssScoreMax[3]);
project.setCveId(cvssScoreMax[4]);
}
// convert max score
if (project.getCvssScoreMax() != null) {
cvssScoreMaxList.add(project.getCvssScoreMax());
}
if (project.getCvssScoreMax1() != null) {
cvssScoreMaxVendorProductList.add(project.getCvssScoreMax1());
}
if (project.getCvssScoreMax2() != null) {
cvssScoreMaxList.add(project.getCvssScoreMax2());
}
if (project.getCvssScoreMax3() != null) {
cvssScoreMaxVendorProductList.add(project.getCvssScoreMax3());
}
String conversionCveInfo = CommonFunction.getConversionCveInfo(project.getReferenceId(), ossInfoMap, project, cvssScoreMaxVendorProductList, cvssScoreMaxList, true);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
project.setCvssScore(conversionCveData[3]);
project.setCveId(conversionCveData[4]);
project.setVulnYn(CoConstDef.FLAG_YES);
}
cvssScoreMaxVendorProductList.clear();
cvssScoreMaxList.clear();
String comments = "";
if (!isEmpty(loadToListComment)) {
comments = loadToListComment;
if (!isEmpty(project.getComments())) {
comments += " " + project.getComments();
}
}
if (!isEmpty(comments)) project.setComments(comments);
if (CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(identification.getReferenceDiv())) project.setDependencies(avoidNull(project.getDependencies()));
}
ProjectIdentification param = new ProjectIdentification();
OssMaster ossParam = new OssMaster();
// components license ์ ๋ณด๋ฅผ ํ๋ฒ์ ๊ฐ์ ธ์จ๋ค
for (ProjectIdentification bean : list) {
param.addComponentIdList(bean.getComponentId());
if (!isEmpty(bean.getOssId())) {
ossParam.addOssIdList(bean.getOssId());
}
}
// oss id๋ก oss master์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค ์ ๋ณด๋ฅผ ์ทจ๋
Map<String, OssMaster> componentOssInfoMap = null;
if (ossParam.getOssIdList() != null && !ossParam.getOssIdList().isEmpty()) {
componentOssInfoMap = ossService.getBasicOssInfoListById(ossParam);
}
List<ProjectIdentification> licenseList = projectMapper.identificationSubGrid(param);
for (ProjectIdentification licenseBean : licenseList) {
for (ProjectIdentification bean : list) {
if (licenseBean.getComponentId().equals(bean.getComponentId())) {
// ์์ ๊ฐ๋ฅ ์ฌ๋ถ ์ด๊ธฐ์ค์
licenseBean.setEditable(CoConstDef.FLAG_YES);
bean.addComponentLicenseList(licenseBean);
break;
}
}
}
// license ์ ๋ณด ๋ฑ๋ก
for (ProjectIdentification bean : list) {
if (bean.getComponentLicenseList() != null) {
//String licenseText = "";
String licenseCopy = "";
// multi dual ๋ผ์ด์ ์ค์ ๊ฒฝ์ฐ, main row์ ํ์๋๋ license ์ ๋ณด๋ OSS List์ ๋ฑ๋ก๋์ด์ง ๋ผ์ด์ ์ค๋ฅผ ๊ธฐ์ค์ผ๋ก ํ์ํ๋ค.
// ossId๊ฐ ์๋ ๊ฒฝ์ฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก subGrid๋ก ๋ฑ๋ก๋ ์ ์๋ค
// ์ด์ง๊ฑฐ๋ฆฌ๋ฅผ ํ๋ ๋๋ฒ์งธ ์ด์ ๋, subgrid ์์ ์ฌ์ฉ์๊ฐ ์ถ๊ฐํ ๋ผ์ด์ ์ค์ oss ์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํจ
if (componentOssInfoMap == null) {
componentOssInfoMap = new HashMap<>();
}
OssMaster ossBean = componentOssInfoMap.get(bean.getOssId());
// Restriction ๋์์ ์ํด (BOM ์ธ ์ถ๊ฐ) License Id๋ฅผ ์ฝค๋ง ๊ตฌ๋ถ์ผ๋ก ๊ฒฉ๋ฉ
String strLicenseIds = "";
if (ossBean != null
&& CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())
&& ossBean.getOssLicenses() != null && !ossBean.getOssLicenses().isEmpty()) {
for (OssLicense ossLicenseBean : ossBean.getOssLicenses()) {
if (!isEmpty(ossLicenseBean.getOssCopyright())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + ossLicenseBean.getOssCopyright();
}
//์ญ์ ๋ถ๊ฐ ์ฒ๋ฆฌ
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
// license index ๊น์ง ๋น๊ตํ๋ ์ด์ ๋
// multi dual ํผ์ฉ์ธ ๊ฒฝ์ฐ, ๋์ผํ ๋ผ์ด์ ์ค๊ฐ ๋๋ฒ ๋ฑ๋ก ๋ ์ ์๊ธฐ ๋๋ฌธ
if (ossLicenseBean.getLicenseId().equals(licenseBean.getLicenseId())
&& ossLicenseBean.getOssLicenseIdx().equals(licenseBean.getRnum())) {
licenseBean.setEditable(CoConstDef.FLAG_NO);
break;
}
}
// Restriction ์ค์ ์ ์ํด license id ๊ฒฉ๋ฉ
if (!isEmpty(ossLicenseBean.getLicenseId())) {
strLicenseIds += (!isEmpty(strLicenseIds) ? "," : "") + ossLicenseBean.getLicenseId();
}
}
// ์ด์งํผ ์ฌ๊ธฐ์ ์ค์ ํ๋ ๋ผ์ด์ ์ค ์ด๋ฆ์ ์๋ฏธ๊ฐ ์์
if (bean.getComponentLicenseList() != null && bean.getComponentLicenseList().size() == 1 && bean.getComponentLicenseList().get(0) != null) {
bean.setLicenseName(bean.getComponentLicenseList().get(0).getLicenseName());
} else if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())) {
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
} else {
// TODO - ์ฌ๊ธฐ ์์ ํ๋ฉด ๋ ๊ฑฐ ๊ฐ์.. multiUIFlag
bean.setLicenseName(CommonFunction.makeLicenseExpression(ossBean.getOssLicenses()));
}
} else {
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
if (!isEmpty(licenseBean.getCopyrightText())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + licenseBean.getCopyrightText();
}
// Restriction ์ค์ ์ ์ํด license id ๊ฒฉ๋ฉ
if (!isEmpty(licenseBean.getLicenseId())) {
strLicenseIds += (!isEmpty(strLicenseIds) ? "," : "") + licenseBean.getLicenseId();
}
}
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
}
// Restriction ์ค์
if (!isEmpty(strLicenseIds)) {
bean.setRestriction(CommonFunction.setLicenseRestrictionListById(strLicenseIds));
}
// customBinary ์ค์
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(identification.getReferenceDiv())
|| CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(identification.getReferenceDiv())) {
bean.setCustomBinaryYn(CoConstDef.FLAG_YES);
}
// 3rd party์ ๊ฒฝ์ฐ obligation ์ฒ๋ฆฌ๋ฅผ ์ํด license์ ๋ฐ๋ฅธ obligation ์ค์ ์ ์ถ๊ฐ
if (CoConstDef.CD_DTL_COMPONENT_PARTNER.equals(identification.getReferenceDiv())) {
bean.setObligationLicense(CommonFunction.checkObligationSelectedLicense2(bean.getComponentLicenseList()));
if (isEmpty(bean.getObligationType())) {
bean.setObligationType(bean.getObligationLicense());
}
// need check ์ธ ๊ฒฝ์ฐ
if (CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK.equals(bean.getObligationLicense())) {
if (CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType())) {
bean.setNotify(CoConstDef.FLAG_YES);
bean.setSource(CoConstDef.FLAG_NO);
} else if (CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType())) {
bean.setNotify(CoConstDef.FLAG_YES);
bean.setSource(CoConstDef.FLAG_YES);
} else if (CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK_SELECTED.equals(bean.getObligationType())) {
bean.setNotify(CoConstDef.FLAG_NO);
bean.setSource(CoConstDef.FLAG_NO);
} else {
bean.setNotify("");
bean.setSource("");
}
}
}
// subGrid์ Item ์ถ์ถ์ ์ํด ๋ณ๋์ map์ผ๋ก ๊ตฌ์ฑํ๋ค.
// ๋ถ๋ชฌ์ component_id๋ฅผ key๋ก ๊ด๋ฆฌํ๋ค.
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
} else {
bean.setLicenseName("");
subMap.put(bean.getGridId(), new ArrayList<ProjectIdentification>());
}
// bat ๋ถ์ ๊ฒฐ๊ณผ์ ๊ฒฝ์ฐ
if (!isEmpty(bean.getBatPercentage()) || !isEmpty(bean.getBatStringMatchPercentage())) {
String batPercentageStr = avoidNull(bean.getBatStringMatchPercentage());
if (CoConstDef.BAT_MATCHED_STR.equalsIgnoreCase(avoidNull(bean.getBatPercentage()).trim())) {
batPercentageStr = CoConstDef.BAT_MATCHED_STR;
} else if (!isEmpty(bean.getBatPercentage())) {
batPercentageStr += " (" + bean.getBatPercentage() + ")";
}
bean.setBatStrPlus(batPercentageStr);
// Change bat grid result percentage (UI) Number only
if (!isEmpty(bean.getBatStringMatchPercentage())) {
bean.setBatStringMatchPercentageFloat(bean.getBatStringMatchPercentage().replace("%", "").trim());
}
}
// License Restriction ์ ์ฅ
bean.setRestriction(CommonFunction.setLicenseRestrictionList(bean.getComponentLicenseList()));
// comments๊ฐ null์ธ ๊ฒฝ์ฐ grid์์ ์์ ์ ์ ์ ๋์ง ์๊ธฐ ๋๋ฌธ์, ๊ณต๋ฐฑ์ผ๋ก ์นํํ๋ค.
bean.setComments(avoidNull(bean.getComments()));
}
// ๋ค๋ฅธ ํ๋ก์ ํธ์์ loadํ ๊ฒฝ์ฐ component id ์ด๊ธฐํ
if (isLoadFromProject || isApplyFromBat) {
subMap = new HashMap<>();
// refproject id + "p" + componentid ๋ก component_id๋ฅผ ์ฌ์์ฑ ํ๊ณ ,
// license ์ ๊ฒฝ์ฐ ์ฌ์ฑ์ํ component_id + ๊ธฐ์กด license grid_id์ component_license_id ๋ถ๋ถ์ ๊ฒฐํฉ
for (ProjectIdentification bean : list) {
if (isLoadFromProject) {
bean.setRefPrjId(identification.getRefPrjId());
} else if (isApplyFromBat) {
bean.setRefBatId(identification.getRefBatId());
}
String _compId = CoConstDef.GRID_NEWROW_DEFAULT_PREFIX;
if (isLoadFromProject) {
_compId += identification.getRefPrjId();
} else if (isApplyFromBat) {
_compId += identification.getRefBatId();
}
_compId += "p" + bean.getComponentId();
bean.setComponentId("");
bean.setGridId(_compId);
if (bean.getComponentLicenseList()!=null){
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
licenseBean.setComponentId("");
licenseBean.setGridId(_compId + "-"+ licenseBean.getComponentLicenseId());
}
}
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// ํธ์ง์ค์ธ data ๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ append ํ๋ค.
{
if (identification.getMainDataGridList() != null) {
for (ProjectIdentification bean : identification.getMainDataGridList()) {
if (bean.getComponentLicenseList() == null || bean.getComponentLicenseList().isEmpty()){
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(bean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : identification.getSubDataGridList()) {
for (ProjectIdentification comLicense : comLicenseList) {
if (bean.getComponentId().equals(comLicense.getComponentId())){
bean.addComponentLicenseList(comLicense);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
ProjectIdentification license = new ProjectIdentification();
license.setComponentId(bean.getComponentId());
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setCopyrightText(bean.getCopyrightText());
license.setExcludeYn(bean.getExcludeYn());
bean.addComponentLicenseList(license);
}
}
}
for (ProjectIdentification bean : identification.getMainDataGridList()) {
list.add(0, bean);
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// exclude row์ ์ฌ์ ๋ ฌ (๊ฐ์ฅ ๋ง์ง๋ง์ผ๋ก)
List<ProjectIdentification> newSortList = new ArrayList<>();
List<ProjectIdentification> excludeList = new ArrayList<>();
for (ProjectIdentification bean : list) {
if (CoConstDef.FLAG_YES.equals(bean.getExcludeYn())) {
excludeList.add(bean);
} else {
newSortList.add(bean);
}
}
newSortList.addAll(excludeList);
list = newSortList;
map.put("subData", subMap);
map.put("mainData", list);
}
return map;
}
private String findAddedOssCopyright(String ossId, String licenseId, String ossCopyright) {
if (!isEmpty(ossId) && !isEmpty(licenseId)) {
OssMaster bean = CoCodeManager.OSS_INFO_BY_ID.get(ossId);
if (bean != null) {
for (OssLicense license : bean.getOssLicenses()) {
if (licenseId.equals(license.getLicenseId()) && !isEmpty(license.getOssCopyright())) {
return license.getOssCopyright();
}
}
}
}
return ossCopyright;
}
/**
* BAT์ ๋์ผํ OSS, license๋ฅผ ๊ฐ์ง๋ SRC ์ ๋ณด๊ฐ ์๋์ง ํ์ธ
* @param ll
* @param refBean
* @param list
* @return
*/
private String findBatOssOtherVersionWithLicense(ProjectIdentification ll, ProjectIdentification refBean, List<ProjectIdentification> list) {
for (ProjectIdentification bean : list) {
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(bean.getReferenceDiv())
&& bean.getOssName().equals(refBean.getOssName())
&& !bean.getOssVersion().equals(refBean.getOssVersion())
&& bean.getOssName().equals(ll.getOssName())) {
if (CommonFunction.isSameLicense(bean.getOssComponentsLicenseList(), ll.getOssComponentsLicenseList())) {
return bean.getOssName() + "-" + avoidNull(bean.getOssVersion());
}
}
}
return null;
}
private int findOssAppendIndex(String type, String componentId, List<ProjectIdentification> list) {
int idx = 0;
for (ProjectIdentification bean : list) {
if (type.equals(bean.getReferenceDiv()) && componentId.equals(bean.getComponentId())) {
return idx;
}
idx++;
}
return -1;
}
private List<ProjectIdentification> findOssGroupList(String type, String ossName, String ossVersion, List<ProjectIdentification> list) {
String targetGroup = avoidNull(ossName) + avoidNull(ossVersion);
List<ProjectIdentification> groupList = new ArrayList<>();
for (ProjectIdentification bean : list) {
if (type.equals(bean.getReferenceDiv()) && targetGroup.equalsIgnoreCase(bean.getGroupingColumn())) {
groupList.add(bean);
}
}
return groupList;
}
private boolean existsBatOSS(String ossName, List<ProjectIdentification> list) {
for (ProjectIdentification bean : list) {
if (CoConstDef.CD_DTL_COMPONENT_ID_BAT.equals(bean.getReferenceDiv()) && isEmpty(bean.getMergePreDiv()) && isEmpty(bean.getOssVersion())
&& ossName.equalsIgnoreCase(bean.getOssName())) {
return true;
}
}
return false;
}
@Override
public Map<String, String> getCategoryCodeToJson(String code) {
Map<String, String> map = new LinkedHashMap<>();
try {
List<String> list = projectMapper.selectCategoryCode(code);
String[] arr;
for (String str : list) {
arr = str.split("\\|");
map.put(arr[0] + "|" + arr[1], arr[2]);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return map;
}
@Override
public Map<String, List<Project>> getModelList(String prjId) {
List<Project> modelList = projectMapper.selectModelList(prjId);
HashMap<String, List<Project>> map = new HashMap<>();
map.put("currentModelList", modelList);
map.put("rows", modelList); // export, project ๊ธฐ๋ณธ์ ๋ณด๋ฑ ๊ธฐ์กด์ ์ฐธ์กฐํ๊ณ ์๋ ์์ค๋ฅผ ์ํด rows๋ฅผ ์ ์ง
map.put("delModelList", projectMapper.selectDeleteModelList(prjId));
return map;
}
@Override
@Cacheable(value="autocompleteCache", key="#root.methodName")
public List<ProjectIdentification> getOssNames(ProjectIdentification identification) {
return projectMapper.getOssNames(identification);
}
@Override
public List<ProjectIdentification> getOssVersions(String ossName) {
return projectMapper.getOssVersions(ossName);
}
@Override
public OssNotice setCheckNotice(Project project) {
OssNotice notice = new OssNotice();
try {
String prjId = project.getPrjId();
notice = verificationService.selectOssNoticeOne(prjId);
if (isEmpty(notice.getCompanyNameFull())
&& isEmpty(notice.getDistributionSiteUrl())
&& isEmpty(notice.getEmail())
&& isEmpty(notice.getAppended())
&& CoConstDef.FLAG_NO.equals(notice.getEditNoticeYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditCompanyYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditDistributionSiteUrlYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditEmailYn())
&& CoConstDef.FLAG_NO.equals(notice.getHideOssVersionYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditAppendedYn())
&& (CoConstDef.CD_NOTICE_TYPE_GENERAL.equals(notice.getNoticeType())
|| CoConstDef.CD_NOTICE_TYPE_NA.equals(notice.getNoticeType()))){
// OSS_NOTICE์ OSS_NOTICE_NEW์ ์ ๋ณด๊ฐ ์์๊ฒฝ์ฐ default setting
notice.setEditNoticeYn(CoConstDef.FLAG_NO);
notice.setEditCompanyYn(CoConstDef.FLAG_YES);
notice.setEditDistributionSiteUrlYn(CoConstDef.FLAG_YES);
notice.setEditEmailYn(CoConstDef.FLAG_YES);
notice.setHideOssVersionYn(CoConstDef.FLAG_NO);
notice.setEditAppendedYn(CoConstDef.FLAG_NO);
notice.setPrjId(project.getPrjId());
String distributeType = avoidNull(project.getDistributeTarget(), CoConstDef.CD_DISTRIBUTE_SITE_SKS); // LGE, NA => LGE๋ก ํ๊ธฐ, SKS => SKS๋ก ํ๊ธฐํจ.
String distributeCode = CoConstDef.CD_DISTRIBUTE_SITE_SKS.equals(distributeType) ? CoConstDef.CD_NOTICE_DEFAULT_SKS : CoConstDef.CD_NOTICE_DEFAULT;
if (isEmpty(notice.getCompanyNameFull())) {
notice.setCompanyNameFull(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_FULLNAME));
}
if (isEmpty(notice.getDistributionSiteUrl())) {
notice.setDistributionSiteUrl(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_DISTRIBUTE_SITE));
}
if (isEmpty(notice.getEmail())) {
notice.setEmail(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_EMAIL));
}
if (isEmpty(notice.getAppended())){
notice.setAppended(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_APPENDED));
}
} else if (CoConstDef.FLAG_YES.equals(notice.getEditNoticeYn())
&& CoConstDef.CD_NOTICE_TYPE_GENERAL.equals(notice.getNoticeType())) {
} else {
if (!isEmpty(notice.getCompanyNameFull())){
notice.setEditCompanyYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getDistributionSiteUrl())){
notice.setEditDistributionSiteUrlYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getEmail())){
notice.setEditEmailYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getAppended())){
notice.setEditAppendedYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (CoConstDef.CD_NOTICE_TYPE_GENERAL_WITHOUT_OSS_VERSION.equals(project.getNoticeType())){
notice.setHideOssVersionYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return notice;
}
@Override
public Project getProjectBasicInfo(String prjId) {
Project param = new Project();
param.setPrjId(prjId);
return projectMapper.selectProjectMaster2(param);
}
@Transactional
@Override
public void registVerifyContents(Project project) {
projectMapper.updateVerifyContents(project);
}
@SuppressWarnings("unchecked")
@Override
public History work(Object param) {
History h = new History();
if (Project.class.equals(param.getClass())) {
Project vo = (Project) param;
Project prj = getProjectDetail(vo);
prj.setModelList(projectMapper.selectModelList(prj.getPrjId()));
h.sethKey(prj.getPrjId());
h.sethTitle(prj.getPrjName());
h.sethType(CoConstDef.EVENT_CODE_PROJECT);
h.setModifier(prj.getLoginUserName());
h.setModifiedDate(prj.getModifiedDate());
h.sethComment("");
h.sethData(prj);
} else {
List<ProjectIdentification> vo = (List<ProjectIdentification>) param;
List<ProjectIdentification> data = getBomListExcel(vo.get(0));
Project prj = new Project();
prj.setPrjId(data.get(0).getReferenceId());
prj = getProjectDetail(prj);
h.sethKey(prj.getPrjId());
h.sethTitle(prj.getPrjName());
h.sethType(CoConstDef.EVENT_CODE_BOM);
h.setModifier(prj.getLoginUserName());
h.setModifiedDate(prj.getModifiedDate());
h.sethComment("");
h.sethData(data);
}
return h;
}
@Override
public String getDivision(Project project) {
String result = "";
result = projectMapper.getDivision(project);
return result;
}
@Override
public void updateReviewer(Project project) {
projectMapper.updateReviewer(project);
}
@Transactional
@Override
public void updateReject(Project project) {
for (String prjId : project.getPrjIds()) {
project.setPrjId(prjId);
projectMapper.updateReject(project);
}
}
@Override
public String getCategoryCode(String code, String gubun) {
StringBuilder sb = new StringBuilder();
try {
List<String> list = projectMapper.selectCategoryCode(code);
String[] arr;
for (String str : list) {
arr = str.split("\\|");
if (CoConstDef.FLAG_YES.equals(gubun)) {
sb.append("<option value=\"" + arr[1] + "\">" + arr[2] + "</option>");
} else {
sb.append(arr[1] + ":" + arr[2] + ";");
}
}
return sb.toString();
} catch (Exception e) {
log.error(e.getMessage());
}
return sb.toString();
}
@Transactional
@Override
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
public void registProject(Project project) {
//copy ๊ฑด
if ("true".equals(project.getCopy())){
String oldId = project.getPrjId();
project.setPrjId(null);
project.setCopyPrjId(oldId);
project.setPublicYn(avoidNull(project.getPublicYn(), CoConstDef.FLAG_YES));
// project master
projectMapper.insertProjectMaster(project);
String prjId = project.getPrjId();
// notice type (packaging์์ project ๊ธฐ๋ณธ์ ๋ณด๋ก ์ด๋๋๋ฉด์ ์ถ๊ฐํด์ค์ผํจ
// verificationMapper์ insert๊ฐ ์์ง๋ง, ํ๋ก์ ํธ ๊ธฐ๋ณธ์ ๋ณด์์๋ notice type๋ง ๊ฒฐ์ ํ๊ธฐ ๋๋ฌธ์ ๋ณ๋๋ก project mapper์ ์ถ๊ฐ
OssNotice noticeParam = new OssNotice();
noticeParam.setPrjId(project.getPrjId());
noticeParam.setNoticeType(avoidNull(project.getNoticeType(), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL));
if (CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equals(project.getNoticeType())) {
noticeParam.setNoticeTypeEtc(project.getNoticeTypeEtc());
}
projectMapper.makeOssNotice(noticeParam);
// project model insert
if (project.getModelList().size() > 0) {
for (Project modelBean : project.getModelList()) {
modelBean.setPrjId(project.getPrjId());
modelBean.setModelName(modelBean.getModelName().trim().toUpperCase().replaceAll("\t", ""));
// copy ํ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ, ๋ฐฐํฌ์ฌ์ดํธ ์ฐ๋ ์ ๋ณด๋ ์ญ์ ํ๋ค.
// ์ญ์ ๋ ์ด๋ ฅ์ด ์๋ ๋ชจ๋ธ์ ์ถ๊ฐํ ํ์ ์์
if (CoConstDef.FLAG_YES.equals(modelBean.getDelYn())) {
continue;
}
modelBean.setModifier(null);
modelBean.setModifiedDate(null);
modelBean.setOsddSyncYn(null);
modelBean.setOsddSyncTime(null);
projectMapper.insertProjectModel(modelBean);
}
}
// project watcher insert
if (project.getWatchers()!= null) { // Project ์ ๊ท ๋ฑ๋ก๊ณผ ๋์ผํ๊ฒ watcher ์ถ๊ฐ
ArrayList<Map<String, String>> divisionList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> emailList = new ArrayList<Map<String, String>>();
String[] arr;
for (String watcher : project.getWatchers()) {
Map<String, String> m = new HashMap<String, String>();
arr = watcher.split("\\/");
if (!"Email".equals(arr[1])){
project.setPrjDivision(arr[0]);
if (arr.length > 1){
project.setPrjUserId(arr[1]);
}else{
project.setPrjUserId("");
}
project.setPrjEmail("");
m.put("division", project.getPrjDivision());
m.put("userId", project.getPrjUserId());
divisionList.add(m);
} else {
project.setPrjDivision("");
project.setPrjUserId("");
project.setPrjEmail(arr[0]);
m.put("email", project.getPrjEmail());
emailList.add(m);
}
List<Project> watcherList = projectMapper.selectWatchersCheck(project);
if (watcherList.size() == 0){
projectMapper.insertProjectWatcher(project);
}
}
project.setDivisionList(divisionList);
project.setEmailList(emailList);
projectMapper.deleteProjectWatcher(project);
}
//๋๋จธ์ง ํ๋ก์ ํธ ๋ง์คํฐ ํ
์ด๋ธ ์นดํผ
// Identification ๊ด๋ จ ์ ๋ณด๋ง Copyํ๋ค.
// uploadํ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ๋ ํ์ผ ์๋ฒ์ ์๋กญ๊ฒ ์ทจ๋ํ์ฌ ์ฌ๋ฑ๋กํ๋ค. ๋ฌผ๋ฆฌํ์ผ์ ๋ณต์ฌํ์ง ์๊ณ ๊ณต์ ํ๋ค.
project.setPrjId(oldId);
Project orgBean = projectMapper.selectProjectMaster2(project);
project.setPrjId(prjId);
{
Project newBean = new Project();
newBean.setPrjId(prjId);
newBean.setModifier(newBean.getLoginUserName());
if (!isEmpty(orgBean.getIdentificationStatus())) {
newBean.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
}
newBean.setIdentificationSubStatusPartner(orgBean.getIdentificationSubStatusPartner());
newBean.setIdentificationSubStatusDep(orgBean.getIdentificationSubStatusDep());
newBean.setIdentificationSubStatusSrc(orgBean.getIdentificationSubStatusSrc());
newBean.setIdentificationSubStatusBin(orgBean.getIdentificationSubStatusBin());
newBean.setIdentificationSubStatusAndroid(orgBean.getIdentificationSubStatusAndroid());
newBean.setIdentificationSubStatusBat(orgBean.getIdentificationSubStatusBat());
// distribute target์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ, ๋ง์คํฐ ์นดํ
๊ณ ๋ฆฌ๋ ๋ณต์ฌํ์ง ์๋๋ค.
if (!CoConstDef.CD_DTL_DISTRIBUTE_NA.equals(project.getDistributeTarget())
&& avoidNull(project.getDistributeTarget()).equals(orgBean.getDistributeTarget())) {
newBean.setDistributeMasterCategory(orgBean.getDistributeMasterCategory());
newBean.setDistributeName(orgBean.getDistributeName());
newBean.setDistributeSoftwareType(orgBean.getDistributeSoftwareType());
}
if (!avoidNull(project.getDistributionType()).equals(orgBean.getDistributionType())) {}
if (!isEmpty(orgBean.getSrcAndroidCsvFileId())) {
newBean.setSrcAndroidCsvFileId(fileService.copyFileInfo(orgBean.getSrcAndroidCsvFileId()));
}
if (!isEmpty(orgBean.getSrcAndroidNoticeFileId())) {
newBean.setSrcAndroidNoticeFileId(fileService.copyFileInfo(orgBean.getSrcAndroidNoticeFileId()));
}
if (!isEmpty(orgBean.getSrcAndroidResultFileId())) {
newBean.setSrcAndroidResultFileId(fileService.copyFileInfo(orgBean.getSrcAndroidResultFileId()));
}
// copy ์ distributeName ์ ๋ณต์ฌ ๋์ง ์๋๋ก ํ๋๊ทธ ์ถ๊ฐ
newBean.setCopyFlag(CoConstDef.FLAG_YES);
projectMapper.updateProjectMaster(newBean);
}
//identification-components
project.setOldId(oldId);
List<ProjectIdentification> components = projectMapper.selectOssComponentsList(project);
List<OssComponentsLicense> licenses;
int componentIdx = 1;
for (ProjectIdentification bean : components){
bean.setReferenceId(prjId);
bean.setReportFileId(null);
licenses = projectMapper.selectOssComponentsLicenseList(bean);
bean.setComponentIdx(String.valueOf(componentIdx++));
projectMapper.insertOssComponents(bean);
for (OssComponentsLicense licenseBean : licenses){
licenseBean.setComponentId(bean.getComponentId());
projectMapper.insertOssComponentsLicense(licenseBean);
}
}
// Project - 3rd ๋งคํ ์ ๋ณด ๋ณต์ฌ
List<PartnerMaster> partnerList = partnerMapper.selectThirdPartyMapList(oldId);
for (PartnerMaster bean : partnerList) {
bean.setPrjId(prjId);
partnerMapper.insertPartnerMapList(bean);
}
} else {
boolean isNew = isEmpty(project.getPrjId());
// ์ ๊ท ํ๋ก์ ํธ ์์ฑ์, Android model ์ ๊ฒฝ์ฐ, 3rd, src, bin Tab์ N/A ์ฒ๋ฆฌํ๋ค.
if (isNew && "A".equals(CoCodeManager.getCodeExpString(CoConstDef.CD_DISTRIBUTION_TYPE, project.getDistributionType())) ) {
project.setIdentificationSubStatusPartner(CoConstDef.FLAG_NO);
project.setIdentificationSubStatusSrc(CoConstDef.FLAG_NO);
project.setIdentificationSubStatusBin(CoConstDef.FLAG_NO);
project.setIdentificationSubStatusBat(CoConstDef.FLAG_NO);
}
// admin์ด ์๋๋ผ๋ฉด creator๋ฅผ ๋ณ๊ฒฝํ์ง ์๋๋ค.
if (!CommonFunction.isAdmin()) {
project.setCreator(null);
}
project.setPublicYn(avoidNull(project.getPublicYn(), CoConstDef.FLAG_YES));
// if complete value equals 'Y', set
if (!isNew) {
Project prjBean = projectMapper.selectProjectMaster(project);
if (prjBean != null) {
if (CoConstDef.FLAG_YES.equals(prjBean.getCompleteYn())) {
project.setCompleteYn(CoConstDef.FLAG_YES);
}
}
}
// project master
projectMapper.insertProjectMaster(project);
OssNotice noticeParam = new OssNotice();
noticeParam.setPrjId(project.getPrjId());
noticeParam.setNoticeType(avoidNull(project.getNoticeType(), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL));
if (CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equals(project.getNoticeType())) {
noticeParam.setNoticeTypeEtc(project.getNoticeTypeEtc());
}
projectMapper.makeOssNotice(noticeParam);
// delete model, watcher
projectMapper.deleteProjectModel(project);
// project model insert
if (project.getModelList().size() > 0) {
for (int i = 0; i < project.getModelList().size(); i++) {
project.getModelList().get(i).setPrjId(project.getPrjId());
projectMapper.insertProjectModel(project.getModelList().get(i));
}
}
Project result = projectMapper.getProjectBasicInfo(project);
if ("CONF".equals(result.getVerificationStatus())
&& isEmpty(result.getDestributionStatus())
&& CoConstDef.CD_DTL_DISTRIBUTE_NA.equals(project.getDistributeTarget())) {
projectMapper.updateProjectDistributionStatus(project.getPrjId(), CoConstDef.CD_DTL_DISTRIBUTE_NA);
} else if ("CONF".equals(result.getVerificationStatus())
&& CoConstDef.CD_DTL_DISTRIBUTE_NA.equals(result.getDestributionStatus())
&& !CoConstDef.CD_DTL_DISTRIBUTE_NA.equals(project.getDistributeTarget())) {
String distributionType = codeMapper.getCodeDetail(CoConstDef.CD_DISTRIBUTION_TYPE, result.getDistributionType()).getCdDtlExp();
if ("T".equalsIgnoreCase(avoidNull(distributionType))
|| (CoConstDef.FLAG_NO.equalsIgnoreCase(avoidNull(distributionType)) && verificationService.checkNetworkServer(result.getPrjId()))) {
projectMapper.updateProjectDistributionStatus(project.getPrjId(), CoConstDef.CD_DTL_DISTRIBUTE_NA);
} else {
projectMapper.updateProjectDistributionStatus(project.getPrjId(), null);
}
}
if (isNew) {
// project watcher insert
ArrayList<Map<String, String>> divisionList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> emailList = new ArrayList<Map<String, String>>();
if (project.getWatchers()!= null) {
String[] arr;
for (String watcher : project.getWatchers()) {
Map<String, String> m = new HashMap<String, String>();
arr = watcher.split("\\/");
if (!"Email".equals(arr[1])){
project.setPrjDivision(arr[0]);
if (arr.length > 1){
project.setPrjUserId(arr[1]);
}else{
project.setPrjUserId("");
}
project.setPrjEmail("");
m.put("division", project.getPrjDivision());
m.put("userId", project.getPrjUserId());
divisionList.add(m);
} else {
project.setPrjDivision("");
project.setPrjUserId("");
project.setPrjEmail(arr[0]);
m.put("email", project.getPrjEmail());
emailList.add(m);
}
List<Project> watcherList = projectMapper.selectWatchersCheck(project);
if (watcherList.size() == 0){
projectMapper.insertProjectWatcher(project);
}
}
}
project.setDivisionList(divisionList);
project.setEmailList(emailList);
projectMapper.deleteProjectWatcher(project);
}
}
}
@Transactional
@Override
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
public void deleteProject(Project project) {
if (projectMapper.checkProjectDistributeHis(project) > 0) {
projectMapper.deleteProjectDistributeHis(project);
}
projectMapper.deleteProjectModel(project);
projectMapper.deleteProjectWatcher(project);
projectMapper.deleteStatisticsMostUsedInfo(project);
projectMapper.deleteAddList(project);
projectMapper.deleteOssNotice(project.getPrjId());
projectMapper.deleteProjectMaster(project);
}
@Override
@Transactional
public void deleteProjectRefFiles(Project projectInfo) {
// delete identification files
deleteFiles(projectInfo.getCsvFile());
deleteFiles(projectInfo.getAndroidCsvFile());
deleteFiles(projectInfo.getAndroidNoticeFile());
deleteFiles(projectInfo.getAndroidResultFile());
deleteFiles(projectInfo.getBinCsvFile());
deleteFiles(projectInfo.getBinBinaryFile());
}
private void deleteFiles(List<T2File> list) {
if(list != null) {
for(T2File fileInfo : list) {
projectMapper.deleteFileBySeq(fileInfo);
fileService.deletePhysicalFile(fileInfo, null);
}
}
}
@Override
public Map<String, Object> getOssIdLicenses(ProjectIdentification identification) {
HashMap<String, Object> map = new HashMap<String, Object>();
try {
ProjectIdentification prjOssMaster = projectMapper.getOssId(identification);
List<ProjectIdentification> Licenselist = projectMapper.getLicenses(prjOssMaster);
if (Licenselist.size() != 0){
//excludeYn ์ฒดํฌํด์ฃผ๊ธฐ
Licenselist = CommonFunction.makeLicenseExcludeYn(Licenselist);
// multi/dual license์ธ ๊ฒฝ์ฐ ์ฐ์ฐ์ ํ๊ธฐ๋ก ๋ณ๊ฒฝ
prjOssMaster.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(Licenselist, ","));
}
map.put("prjOssMaster", prjOssMaster);
map.put("prjLicense", Licenselist);
} catch (Exception e) {
log.error(e.getMessage());
}
return map;
}
@Override
public void updateSubStatus(Project project) {
projectMapper.updateProjectSubStatus(project);
ProjectIdentification components = new ProjectIdentification();
components.setReferenceId(project.getPrjId());
components.setReferenceDiv(project.getReferenceDiv());
List<OssComponents> componentsLicense = projectMapper.selectComponentId(components);
for (OssComponents oc : componentsLicense) {
projectMapper.deleteOssComponentsLicense(oc);
}
projectMapper.deleteOssComponents(components);
}
@SuppressWarnings("unchecked")
@Override
@Transactional
public void registComponentsThird(String prjId, String identificationSubStatusPartner, List<OssComponents> ossComponentsList, List<PartnerMaster> thirdPartyList) {
// ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ์ทจ๋
Project prjBasicInfo = new Project();
prjBasicInfo.setPrjId(prjId);
prjBasicInfo = projectMapper.selectProjectMaster(prjBasicInfo);
// ํ๋ก์ ํธ ์ํ ์ ๋ณด ๋ณ๊ฒฝ
{
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(prjId);
projectSubStatus.setIdentificationSubStatusPartner((ossComponentsList.isEmpty() && thirdPartyList.isEmpty()) ? "X" : CoConstDef.FLAG_YES);
// ์ต์ด ์ ์ฅ์์๋ง ์ํ ๋ณ๊ฒฝ
// row count๊ฐ 0์ด์ด๋ ์ฌ์ฉ์๊ฐ ํ๋ฒ์ด๋ผ๋ ์ ์ฅํ๋ฉด progress ์ํ๋ก ์ธ์ง๋์ด์ผํจ
if (isEmpty(prjBasicInfo.getIdentificationStatus())) {
projectSubStatus.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
}
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectMapper.updateProjectMaster(projectSubStatus);
}
ossComponentsList = convertOssNickName3rd(ossComponentsList);
OssComponents compParam = new OssComponents();
compParam.setReferenceId(prjId);
Map<String, ProjectIdentification> orgOssMap = new HashMap<>();
// ๊ธฐ์กด ๋ฑ๋ก oss ์ ๋ณด ์ทจ๋
{
Map<String, Object> _map = getIdentificationThird(compParam);
List<ProjectIdentification> rows = (List<ProjectIdentification>) _map.get("rows");
if (rows != null) {
for (ProjectIdentification bean : rows) {
orgOssMap.put(bean.getComponentId(), bean);
}
}
}
List<OssComponents> updateList = new ArrayList<>();
List<OssComponents> insertFromPrjList = new ArrayList<>();
List<OssComponents> insertFromPartnerList = new ArrayList<>();
List<String> deleteList = new ArrayList<>();
// ์์๋๋ก ๋ฑ๋ก 1) update, 2) delete, 3)insert from project , 4) insert from 3rd
for (OssComponents bean : ossComponentsList) {
// ๊ธฐ์กด์ ๋ฑ๋ก๋์ด ์๋ ๊ฒฝ์ฐ๋ update
if (orgOssMap.containsKey(avoidNull(bean.getComponentId()))) {
// exclude ์ฌ๋ถ๋ง ์ฌ์ฉ
updateList.add(bean);
deleteList.add(bean.getComponentId());
} else {
if (!isEmpty(bean.getRefPrjId())) {
// ์ ๊ท ์ถ๊ฐ์ด๋ฉด์, ref ํ๋ก์ ํธ id๊ฐ ์์ผ๋ฉด
// componentsid + prjid + exclude ์ฌ๋ถ๋ง ์ฌ์ฉ
insertFromPrjList.add(bean);
} else {
// ์ ๊ท ์ถ๊ฐ์ด๋ฉด์, ref partner id๊ฐ ์์ผ๋ฉด (๊ฐ๋ณ๋ฑ๋ก์ ์๊ธฐ ๋๋ฌธ์ else๋ก์ฒ๋ฆฌ)
//componentsid + partnerid + exclude ์ฌ๋ถ๋ง ์ฌ์ฉ
insertFromPartnerList.add(bean);
}
}
}
// 1) update
for (OssComponents bean : updateList) {
projectMapper.updatePartnerOssList(bean);
}
// 2) delete
OssComponents param = new OssComponents();
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
param.setReferenceId(prjId);
param.setOssComponentsIdList(deleteList);
List<String> deleteComponentIds = projectMapper.getDeleteOssComponentsLicenseIds(param);
param.setOssComponentsIdList(deleteComponentIds);
if (deleteComponentIds.size() > 0){
projectMapper.deleteOssComponentsLicenseWithIds(param);
// deleteOssComponentsWithIds๋ not in ๊ฐ์ delete, deleteOssComponentsWithIds2๋ in ๊ฐ์ deleteํจ.
projectMapper.deleteOssComponentsWithIds2(param);
}
// 3) insert from project
for (OssComponents bean : insertFromPrjList) {
bean.setComponentId(bean.getRefComponentId());
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
bean.setReferenceId(prjId);
projectMapper.insertOssComponentsCopy(bean);
projectMapper.insertOssComponentsLicenseCopy(bean);
}
// 4) insert from 3rd part
for (OssComponents bean : insertFromPartnerList) {
bean.setComponentId(bean.getRefComponentId());
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
bean.setReferenceId(prjId);
projectMapper.insertOssComponentsCopy(bean);
projectMapper.insertOssComponentsLicenseCopy(bean);
}
Map<String, PartnerMaster> thirdPartyMap = new HashMap<>();
// ๊ธฐ์กด ๋ฑ๋ก 3rd Map ์ ๋ณด ์ทจ๋
{
Map<String, Object> _map = getThirdPartyMap(prjId);
if (_map != null) {
for (PartnerMaster bean : (List<PartnerMaster>) _map.get("rows")) {
thirdPartyMap.put(bean.getPartnerId(), bean);
}
}
}
List<PartnerMaster> thirdPartyUpdateList = new ArrayList<>();
List<PartnerMaster> thirdPartyInsertList = new ArrayList<>();
List<String> thirdPartyDeleteList = new ArrayList<>();
for (PartnerMaster bean : thirdPartyList) {
// ๊ธฐ์กด์ ๋ฑ๋ก๋์ด ์๋ ๊ฒฝ์ฐ๋ update
if (thirdPartyMap.containsKey(avoidNull(bean.getPartnerId()))) {
thirdPartyUpdateList.add(bean);
} else {
thirdPartyInsertList.add(bean);
}
}
Map<String, PartnerMaster> deleteCheckMap = new HashMap<>();
// 1) update
for (PartnerMaster bean : thirdPartyUpdateList) {
deleteCheckMap.put(bean.getPartnerId(), bean);
}
// 3) insert
for (PartnerMaster bean : thirdPartyInsertList) {
deleteCheckMap.put(bean.getPartnerId(), bean);
bean.setPrjId(prjId);
partnerMapper.insertPartnerMapList(bean);
}
for (String s : thirdPartyMap.keySet()) {
if (!deleteCheckMap.containsKey(s)) {
thirdPartyDeleteList.add(s);
}
}
// 2) delete
if (!thirdPartyDeleteList.isEmpty()) {
PartnerMaster thirdPartyDeleteParam = new PartnerMaster();
thirdPartyDeleteParam.setPrjId(prjId);
thirdPartyDeleteParam.setThirdPartyPartnerIdList(thirdPartyDeleteList);
partnerMapper.deletePartnerMapList(thirdPartyDeleteParam);
}
}
private List<OssComponents> convertOssNickName3rd(List<OssComponents> ossComponents) {
List<String> ossCheckParam = new ArrayList<>();
List<OssMaster> ossNickNameList = null;
Map<String, OssMaster> ossNickNameConvertMap = new HashMap<>();
for (OssComponents bean : ossComponents) {
String _ossName = avoidNull(bean.getOssName()).trim();
if (!isEmpty(_ossName) && !"-".equals(_ossName) && !ossCheckParam.contains(_ossName)) {
ossCheckParam.add(_ossName);
}
}
if (!ossCheckParam.isEmpty()) {
OssMaster param = new OssMaster();
param.setOssNames(ossCheckParam.toArray(new String[ossCheckParam.size()]));
ossNickNameList = projectMapper.checkOssNickName(param);
if (ossNickNameList != null) {
for (OssMaster bean : ossNickNameList) {
ossNickNameConvertMap.put(bean.getOssNickname().toUpperCase(), bean);
}
}
}
for (OssComponents bean : ossComponents) {
if (ossNickNameConvertMap.containsKey(avoidNull(bean.getOssName()).trim().toUpperCase())) {
bean.setOssName(ossNickNameConvertMap.get(avoidNull(bean.getOssName()).trim().toUpperCase()).getOssName());
}
// license nickname ์ฒดํฌ
if (!avoidNull(bean.getLicenseName()).contains(",")) {
String _licenseName = avoidNull(bean.getLicenseName()).trim();
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (_licenseName.equalsIgnoreCase(s)) {
bean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
return ossComponents;
}
/*
* ํ๋ก์ ํธ ๋ฐ์ดํฐ (Name, Version) ์ค๋ณต ์ฒดํฌ
*/
@Override
public boolean existProjectData(Project project) {
int result = projectMapper.selectDuplicatedProject(project);
return result > 0 ? true : false;
}
@Override
public void registSrcOss(List<ProjectIdentification> ossComponent, List<List<ProjectIdentification>> ossComponentLicense, Project project) {
registSrcOss(ossComponent, ossComponentLicense, project, CoConstDef.CD_DTL_COMPONENT_ID_SRC);
}
@Override
public void registDepOss(List<ProjectIdentification> ossComponent, List<List<ProjectIdentification>> ossComponentLicense, Project project) {
registSrcOss(ossComponent, ossComponentLicense, project, CoConstDef.CD_DTL_COMPONENT_ID_DEP);
}
@Override
@Transactional
public void registSrcOss(List<ProjectIdentification> ossComponent,
List<List<ProjectIdentification>> ossComponentLicense, Project project, String refDiv) {
// ํ๊ฑด๋ ์์์ ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N์ด๋ฉด N ๊ทธ์ธ null
if (ossComponent.size()==0){
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(project.getPrjId());
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(refDiv)) {
if (!StringUtil.isEmpty(project.getIdentificationSubStatusSrc())){
projectSubStatus.setIdentificationSubStatusSrc(project.getIdentificationSubStatusSrc());
} else {
projectSubStatus.setIdentificationSubStatusSrc("X");
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(refDiv)) {
if (!StringUtil.isEmpty(project.getIdentificationSubStatusBin())){
projectSubStatus.setIdentificationSubStatusBin(project.getIdentificationSubStatusBin());
} else {
projectSubStatus.setIdentificationSubStatusBin("X");
}
} else {
if (!StringUtil.isEmpty(project.getIdentificationSubStatusAndroid())){
projectSubStatus.setIdentificationSubStatusAndroid(project.getIdentificationSubStatusAndroid());
} else {
projectSubStatus.setIdentificationSubStatusAndroid("X");
}
}
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectSubStatus.setReferenceDiv(refDiv);
projectMapper.updateProjectMaster(projectSubStatus);
}
if (!CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(refDiv)) {
ossComponent = convertOssNickName(ossComponent);
}
ossComponentLicense = convertLicenseNickName(ossComponentLicense);
String refId = project.getReferenceId();
updateOssComponentList(project, refDiv, refId, ossComponent, ossComponentLicense);
// delete file
if (project.getCsvFile() != null && project.getCsvFile().size() > 0) {
deleteUploadFile(project, refDiv);
}
// ํ์ผ ๋ฑ๋ก
if (!isEmpty(project.getDepCsvFileId()) || !isEmpty(project.getSrcCsvFileId()) || !isEmpty(project.getSrcAndroidCsvFileId()) || !isEmpty(project.getSrcAndroidNoticeFileId()) || !isEmpty(project.getBinCsvFileId()) || !isEmpty(project.getBinBinaryFileId())){
projectMapper.updateFileId(project);
if (project.getCsvFileSeq() != null) {
for (int i = 0; i < project.getCsvFileSeq().size(); i++) {
projectMapper.updateFileBySeq(project.getCsvFileSeq().get(i));
}
}
}
// bin android ์ ๊ฒฝ์ฐ ๋ค๋ฅธ ํ๋ก์ ํธ์์ loadํ ์ ๋ณด๋ฅผ saveํ ๊ฒฝ์ฐ, notice html๊ณผ result text ์ ๋ณด๋ฅผ ๋ณ๊ฒฝํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(refDiv) && CoConstDef.FLAG_YES.equals(project.getLoadFromAndroidProjectFlag())) {
if (isEmpty(project.getSrcAndroidResultFileId())) {
project.setSrcAndroidResultFileId(null);
}
projectMapper.updateAndroidNoticeFileInfoWithLoadFromProject(project);
}
}
public void updateFileId(Project project) {
projectMapper.updateFileId(project);
}
private void deleteUploadFile(Project project, String refDiv) {
Project prjFileCheck = projectMapper.getProjectBasicInfo(project);
boolean fileDeleteCheckFlag = false;
if(CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(refDiv)) {
if(isEmpty(project.getDepCsvFileId()) && !isEmpty(prjFileCheck.getDepCsvFileId())) {
project.setDepCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(refDiv)) {
if (project.getCsvFileSeq().size() == 0 && !isEmpty(prjFileCheck.getSrcCsvFileId())) {
project.setSrcCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(refDiv)) {
if (isEmpty(project.getBinCsvFileId()) && !isEmpty(prjFileCheck.getBinCsvFileId())) {
project.setBinCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
if (isEmpty(project.getBinBinaryFileId()) && !isEmpty(prjFileCheck.getBinBinaryFileId())) {
project.setBinBinaryFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
} else {
if (isEmpty(project.getSrcAndroidCsvFileId()) && !isEmpty(prjFileCheck.getSrcAndroidCsvFileId())) {
project.setSrcAndroidCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
if (isEmpty(project.getSrcAndroidNoticeFileId()) && !isEmpty(prjFileCheck.getSrcAndroidNoticeFileId())) {
project.setSrcAndroidNoticeFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
if(isEmpty(project.getSrcAndroidNoticeXmlId()) && !isEmpty(prjFileCheck.getSrcAndroidNoticeXmlId())) {
project.setSrcAndroidNoticeXmlFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
}
if (project.getCsvFile() != null && project.getCsvFile().size() > 0) {
for (int i = 0; i < project.getCsvFile().size(); i++) {
projectMapper.deleteFileBySeq(project.getCsvFile().get(i));
fileService.deletePhysicalFile(project.getCsvFile().get(i), "Identification");
}
}
if (fileDeleteCheckFlag) {
projectMapper.updateFileId2(project);
}
}
@Override
@Transactional
public void registOss(List<ProjectIdentification> ossComponent,
List<List<ProjectIdentification>> ossComponentLicense, String refId, String refDiv) {
updateOssComponentList(new Project(), refDiv, refId, ossComponent, ossComponentLicense);
}
@Transactional
private void updateOssComponentList(Project project, String refDiv, String refId, List<ProjectIdentification> ossComponent,
List<List<ProjectIdentification>> ossComponentLicense) {
// ์ปดํฌ๋ํธ ๋ง์คํฐ ๋ผ์ด์ผ์ค ์ง์ฐ๊ธฐ
ProjectIdentification prj = new ProjectIdentification();
if (isEmpty(refId)) {
refId = project.getPrjId();
}
prj.setReferenceId(refId);
prj.setReferenceDiv(refDiv);
List<OssComponents> componentId = projectMapper.selectComponentId(prj);
for (int i = 0; i < componentId.size(); i++) {
projectMapper.deleteOssComponentsLicense(componentId.get(i));
}
if (!CoConstDef.CD_DTL_COMPONENT_BAT.equals(refDiv)) {
if (!ossComponent.isEmpty()) {
Project projectStatus = new Project();
projectStatus.setPrjId(refId);
projectStatus = projectMapper.selectProjectMaster(projectStatus);
// ์ต์ด ์ํ์ด๋ฉด PROG
if (StringUtil.isEmpty(projectStatus.getIdentificationStatus())) {
projectStatus.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
}
if (CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(refDiv)) {
if(!StringUtil.isEmpty(project.getIdentificationSubStatusDep())){
projectStatus.setIdentificationSubStatusDep(project.getIdentificationSubStatusDep());
} else {
projectStatus.setIdentificationSubStatusDep(CoConstDef.FLAG_YES);
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals(refDiv)) {
// ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N ์ด๋ฉด N ๊ทธ์ธ Y
if (!StringUtil.isEmpty(project.getIdentificationSubStatusSrc())){
projectStatus.setIdentificationSubStatusSrc(project.getIdentificationSubStatusSrc());
} else {
projectStatus.setIdentificationSubStatusSrc(CoConstDef.FLAG_YES);
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_BIN.equals(refDiv)) {
// ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N ์ด๋ฉด N ๊ทธ์ธ Y
if (!StringUtil.isEmpty(project.getIdentificationSubStatusBin())){
projectStatus.setIdentificationSubStatusBin(project.getIdentificationSubStatusBin());
} else {
projectStatus.setIdentificationSubStatusBin(CoConstDef.FLAG_YES);
}
} else {
// ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N ์ด๋ฉด N ๊ทธ์ธ Y
if (!StringUtil.isEmpty(project.getIdentificationSubStatusAndroid())){
projectStatus.setIdentificationSubStatusAndroid(project.getIdentificationSubStatusAndroid());
} else {
projectStatus.setIdentificationSubStatusAndroid(CoConstDef.FLAG_YES);
}
}
projectStatus.setModifier(projectStatus.getLoginUserName());
projectMapper.updateProjectMaster(projectStatus);
}
}
project.setReferenceDiv(refDiv);
project.setReferenceId(refId);
int ossComponentIdx = projectMapper.selectOssComponentMaxIdx(project);
//deleteRows
List<String> deleteRows = new ArrayList<String>();
Map<String, OssMaster> ossInfo = null;
if (CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(refDiv)) {
ossInfo = CoCodeManager.OSS_INFO_UPPER;
}
// ์ปดํฌ๋ํธ ๋ฑ๋ก
for (int i = 0; i < ossComponent.size(); i++) {
// SRC STATUS ๋ฑ๋ก
ProjectIdentification ossBean = ossComponent.get(i);
if (ossInfo != null) {
String key = (ossBean.getOssName()+"_"+ossBean.getOssVersion()).toUpperCase();
OssMaster bean = ossInfo.get(key);
if (bean != null && (!bean.getOssName().equals(bean.getOssNameTemp()))) {
ossBean.setRefOssName(bean.getOssNameTemp());
}
}
// oss_id๋ฅผ ๋ค์ ์ฐพ๋๋ค. (oss name๊ณผ oss id๊ฐ ์ผ์นํ์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ ์ ์์)
ossBean = CommonFunction.findOssIdAndName(ossBean);
if (isEmpty(ossBean.getOssId())) {
ossBean.setOssId(null);
}
String downloadLocationUrl = ossBean.getDownloadLocation();
String homepageUrl = ossBean.getHomepage();
if (!isEmpty(downloadLocationUrl)) {
if (downloadLocationUrl.endsWith("/")) {
ossBean.setDownloadLocation(downloadLocationUrl.substring(0, downloadLocationUrl.length()-1));
}
}
if (!isEmpty(homepageUrl)) {
if (homepageUrl.endsWith("/")) {
ossBean.setHomepage(homepageUrl.substring(0, homepageUrl.length()-1));
}
}
//update
if (!ossBean.getGridId().contains(CoConstDef.GRID_NEWROW_DEFAULT_PREFIX)){
//ossComponents ๋ฑ๋ก
// android project์ ๊ฒฝ์ฐ, bom ์ฒ๋ฆฌ๋ฅผ ํ์ง ์๊ธฐ ๋๋ฌธ์, bom save์์ ์ฒ๋ฆฌํ๋ obligation type์ ์ฌ๊ธฐ์ ์ค์ ํด์ผํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(refDiv)) {
List<OssComponentsLicense> _list = new ArrayList<>();
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())) {
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (ossBean.getComponentId().equals(comLicense.getComponentId())){
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if (isEmpty(comLicense.getLicenseName()) && isEmpty(comLicense.getLicenseText()) && isEmpty(comLicense.getOssCopyright())) {
continue;
}
_list.add(CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI));
}
}
}
} else {
_list.add(CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE));
}
ossBean.setObligationType(CommonFunction.checkObligationSelectedLicense(_list));
ossBean.setBomWithAndroidFlag(CoConstDef.FLAG_YES);
}
projectMapper.updateSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())){
List<String> duplicateLicense = new ArrayList<String>();
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (ossBean.getComponentId().equals(comLicense.getComponentId())){
if (!isEmpty(comLicense.getLicenseId()) && duplicateLicense.contains(comLicense.getLicenseId())) {
continue;
}
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if ((isEmpty(comLicense.getLicenseName())
&& isEmpty(comLicense.getLicenseText())
&& isEmpty(comLicense.getOssCopyright()))) {
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
projectMapper.registComponentLicense(license);
break;
}
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
duplicateLicense.add(comLicense.getLicenseId());
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
} else { //insert
//ossComponents ๋ฑ๋ก
String exComponentId = ossBean.getGridId();
ossBean.setReferenceId(refId);
ossBean.setReferenceDiv(refDiv);
// android project์ ๊ฒฝ์ฐ, bom ์ฒ๋ฆฌ๋ฅผ ํ์ง ์๊ธฐ ๋๋ฌธ์, bom save์์ ์ฒ๋ฆฌํ๋ obligation type์ ์ฌ๊ธฐ์ ์ค์ ํด์ผํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(refDiv)) {
List<OssComponentsLicense> _list = new ArrayList<>();
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())) {
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
String gridId = comLicense.getGridId();
if (isEmpty(gridId)) {
continue;
}
gridId = gridId.split("-")[0];
if (exComponentId.equals(comLicense.getComponentId())
|| exComponentId.equals(gridId)){
_list.add(CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI));
}
}
}
} else {
_list.add(CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE));
}
ossBean.setObligationType(CommonFunction.checkObligationSelectedLicense(_list));
ossBean.setBomWithAndroidFlag(CoConstDef.FLAG_YES);
}
// insert์ ๋งค๋ฒ max idx๋ฅผ select ํ๋ฉด
ossBean.setComponentIdx(Integer.toString(ossComponentIdx++));
projectMapper.insertSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())){
List<String> duplicateLicense = new ArrayList<String>();
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
String gridId = comLicense.getGridId();
if (isEmpty(gridId)) {
continue;
}
gridId = gridId.split("-")[0];
if (exComponentId.equals(comLicense.getComponentId()) || exComponentId.equals(gridId)){
if (!isEmpty(comLicense.getLicenseId()) && duplicateLicense.contains(comLicense.getLicenseId())) {
continue;
}
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if ((isEmpty(comLicense.getLicenseName())
&& isEmpty(comLicense.getLicenseText())
&& isEmpty(comLicense.getOssCopyright()))) {
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
projectMapper.registComponentLicense(license);
break;
}
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(ossBean.getComponentId());
duplicateLicense.add(comLicense.getLicenseName());
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { // ์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
// delete
OssComponents param = new OssComponents();
param.setReferenceDiv(refDiv);
param.setReferenceId(refId);
param.setOssComponentsIdList(deleteRows);
projectMapper.deleteOssComponentsWithIds(param);
}
@Transactional
private void addOssComponentByBinaryInfo(List<OssComponents> componentList, Map<String, List<Map<String, Object>>> binaryRegInfoMap) {
for (OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
String componentId = bean.getComponentId();
if (isEmpty(binaryName)) {
continue;
}
if (!binaryRegInfoMap.containsKey(binaryName)) {
continue;
}
List<Map<String, Object>> binaryInfoList = (List<Map<String, Object>>) binaryRegInfoMap.get(binaryName);
boolean addOssComponentFlag = false;
for (Map<String, Object> binaryInfo : binaryInfoList) {
if (binaryInfo.containsKey("ossName")) {
Map<String, OssMaster> ossInfo = CoCodeManager.OSS_INFO_UPPER;
String ossName = (String) binaryInfo.get("ossName");
String ossVersion = "";
String _binaryLicenseStr = "";
if (binaryInfo.containsKey("ossVersion")) {
ossVersion = (String) binaryInfo.get("ossVersion");
}
if (binaryInfo.containsKey("license")) {
_binaryLicenseStr = (String) binaryInfo.get("license");
}
String key = ossName + "_" + ossVersion;
OssMaster ossBean = ossInfo.get(key.toUpperCase());
boolean isEmptyOss = (ossBean == null || "-".equals(ossName));
// update๋ฅผ ์ํด
// ossmaster => projectIdentification ์ผ๋ก ๋ณํ
ProjectIdentification updateBean = new ProjectIdentification();
if (ossBean != null) {
if (!isEmptyOss) {
updateBean.setOssId(ossBean.getOssId());
}
updateBean.setOssName(isEmptyOss ? "-" : ossBean.getOssNameTemp()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(isEmptyOss ? ossVersion : ossBean.getOssVersion());
updateBean.setDownloadLocation(isEmptyOss ? "" : ossBean.getDownloadLocation());
updateBean.setHomepage(isEmptyOss ? "" : ossBean.getHomepage());
updateBean.setCopyrightText(isEmptyOss ? "" : ossBean.getCopyright());
} else {
updateBean.setOssId(null);
updateBean.setOssName(ossName); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(ossVersion);
updateBean.setDownloadLocation(null);
updateBean.setHomepage(null);
updateBean.setCopyrightText(null);
}
// ๊ธฐ์กด๊ฐ ์ ์ง
updateBean.setFilePath(bean.getFilePath());
updateBean.setExcludeYn(bean.getExcludeYn());
updateBean.setBinaryName(bean.getBinaryName());
updateBean.setBinaryNotice(bean.getBinaryNotice());
updateBean.setCustomBinaryYn(bean.getCustomBinaryYn());
// ํ๋์ binary์ ๋ํด์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ์ ์ฉ๋ ๊ฒฝ์ฐ, ์ต์ด ํ๋ฒ๋ง ์
๋ฐ์ดํธํ๊ณ ์ดํ๋ถํฐ๋ ์ ๊ท ๋ฑ๋กํ๋ค.
if (addOssComponentFlag) {
updateBean.setReferenceId(bean.getReferenceId());
updateBean.setReferenceDiv(bean.getReferenceDiv());
projectMapper.insertOssComponents(updateBean);
componentId = updateBean.getComponentId();
} else {
updateBean.setComponentId(componentId);
projectMapper.updateSrcOssList(updateBean);
addOssComponentFlag = true;
// ๊ธฐ์กด license ์ญ์
projectMapper.deleteOssComponentsLicense(bean);
}
List<String> selectedLicenseIdList = new ArrayList<>();
if (!isEmpty(_binaryLicenseStr)) {
for (String _licenseName : _binaryLicenseStr.split(",")) {
if (isEmpty(_licenseName)) {
continue;
}
_licenseName = _licenseName.trim();
String _licenseId = CommonFunction.getLicenseIdByName(_licenseName);
if (!isEmpty(_licenseId)) {
selectedLicenseIdList.add(_licenseId);
}
}
}
List<OssComponentsLicense> updateLicenseList = new ArrayList<>();
// oss name์ด ํ์ดํ์ด ์๋๋ผ๋ฉด, OSS List์ ๋ฑ๋ก๋ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ทจํฉ
if (!isEmptyOss) {
boolean hasSelectedLicense = false;
for (OssLicense license : ossBean.getOssLicenses()) {
OssComponentsLicense componentLicense = new OssComponentsLicense();
componentLicense.setComponentId(componentId);
componentLicense.setLicenseId(license.getLicenseId());
componentLicense.setLicenseName(license.getLicenseName());
// license text ์ค์ ์ ๋ถํ์ํจ
if (selectedLicenseIdList.contains(componentLicense.getLicenseId())) {
hasSelectedLicense = true;
componentLicense.setExcludeYn(CoConstDef.FLAG_NO);
}
updateLicenseList.add(componentLicense);
}
for (OssComponentsLicense license : updateLicenseList) {
if (hasSelectedLicense) {
license.setExcludeYn(avoidNull(license.getExcludeYn(), CoConstDef.FLAG_YES));
} else {
license.setExcludeYn(CoConstDef.FLAG_NO);
}
projectMapper.insertOssComponentsLicense(license);
}
} else {
// oss name์ด ํ์ดํ์ด๋ผ๋ฉด ๋ผ์ด์ ์ค binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ license๊ฐ ๋ณต์๊ฐ๋ก ๋ฑ๋ก๋์ด ์์ ์ ์์
OssComponentsLicense license = new OssComponentsLicense();
license.setExcludeYn(CoConstDef.FLAG_NO);
license.setComponentId(componentId);
// binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๊ฐ license master์ ๋ฑ๋ก๋์ด ์๋ค๋ฉด master ์ ๋ณด๋ฅผ ์ฌ์ฉ
if (!isEmpty(_binaryLicenseStr) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(_binaryLicenseStr.toUpperCase().trim())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_binaryLicenseStr.toUpperCase().trim());
license.setLicenseId(licenseMaster.getLicenseId());
license.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseName()));
} else {
// ๋ฑ๋ก๋์ด ์์ง ์๋ค๋ฉด, license name๋ง ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฌ์คํญ ์กด์ฌํ ์ ์์
license.setLicenseName(avoidNull(_binaryLicenseStr));
}
projectMapper.insertOssComponentsLicense(license);
}
}
}
}
}
@Transactional
private void addOssComponentByBinaryInfoAndroid(List<OssComponents> componentList, Map<String, List<Map<String, Object>>> binaryRegInfoMap) {
for (OssComponents bean : componentList) {
String binaryName = avoidNull(bean.getBinaryName());
if (binaryName.indexOf("/") > -1) {
binaryName = binaryName.substring(binaryName.lastIndexOf("/") + 1);
}
if (isEmpty(binaryName)) {
continue;
}
// ์ฌ์ฉ์๊ฐ ์
๋ ฅํ oss๊ฐ ์์ผ๋ฉด ์ค์ ํ์ง ์์
if (!isEmpty(bean.getOssName())) {
continue;
}
if (!binaryRegInfoMap.containsKey(binaryName)) {
continue;
}
List<Map<String, Object>> binaryInfoList = binaryRegInfoMap.get(binaryName);
boolean addOssComponentFlag = false;
for (Map<String, Object> binaryInfo : binaryInfoList) {
if (binaryInfo.containsKey("ossName")) {
Map<String, OssMaster> ossInfo = CoCodeManager.OSS_INFO_UPPER;
String ossName = (String) binaryInfo.get("ossName");
String ossVersion = "";
String _binaryLicenseStr = "";
if (binaryInfo.containsKey("ossVersion")) {
ossVersion = (String) binaryInfo.get("ossVersion");
}
if (binaryInfo.containsKey("license")) {
_binaryLicenseStr = (String) binaryInfo.get("license");
}
String key = ossName + "_" + ossVersion;
if ("-".equals(ossName) || ossInfo.containsKey(key.toUpperCase())) {
// oss name + version ์ด ์ผ์นํ๋ oss ๊ฐ ์กด์ฌํ๋ฉด, update ํ๋ค.
boolean isEmptyOss = "-".equals(ossName);
OssMaster ossBean = ossInfo.get(key.toUpperCase());
// update๋ฅผ ์ํด
// ossmaster => projectIdentification ์ผ๋ก ๋ณํ
ProjectIdentification updateBean = new ProjectIdentification();
if (!isEmptyOss) {
updateBean.setOssId(ossBean.getOssId());
}
updateBean.setOssName(isEmptyOss ? "-" : ossBean.getOssNameTemp()); // nick name์ผ๋ก ์ผ์นํ๋ ๊ฒฝ์ฐ๋ ์๊ธฐ๋๋ฌธ์, ์๋ณธ์ด๋ฆ์ ์ค์ (temp)
updateBean.setOssVersion(isEmptyOss ? ossVersion : ossBean.getOssVersion());
updateBean.setDownloadLocation(isEmptyOss ? "" : ossBean.getDownloadLocation());
updateBean.setHomepage(isEmptyOss ? "" : ossBean.getHomepage());
updateBean.setCopyrightText(isEmptyOss ? "" : ossBean.getCopyright());
// ๊ธฐ์กด๊ฐ ์ ์ง
updateBean.setFilePath(bean.getFilePath());
updateBean.setExcludeYn(bean.getExcludeYn());
updateBean.setBinaryName(bean.getBinaryName());
updateBean.setBinaryNotice(bean.getBinaryNotice());
updateBean.setCustomBinaryYn(bean.getCustomBinaryYn());
// ํ๋์ binary์ ๋ํด์ ์ฌ๋ฌ๊ฐ์ OSS๊ฐ ์ ์ฉ๋ ๊ฒฝ์ฐ, ์ต์ด ํ๋ฒ๋ง ์
๋ฐ์ดํธํ๊ณ ์ดํ๋ถํฐ๋ ์ ๊ท ๋ฑ๋กํ๋ค.
if (addOssComponentFlag) {
updateBean.setReferenceId(bean.getReferenceId());
updateBean.setReferenceDiv(bean.getReferenceDiv());
projectMapper.insertOssComponents(updateBean);
} else {
updateBean.setComponentId(bean.getComponentId());
projectMapper.updateSrcOssList(updateBean);
addOssComponentFlag = true;
// ๊ธฐ์กด license ์ญ์
projectMapper.deleteOssComponentsLicense(bean);
}
List<String> selectedLicenseIdList = new ArrayList<>();
if (!isEmpty(_binaryLicenseStr)) {
for (String _licenseName : _binaryLicenseStr.split(",")) {
if (isEmpty(_licenseName)) {
continue;
}
_licenseName = _licenseName.trim();
String _licenseId = CommonFunction.getLicenseIdByName(_licenseName);
if (!isEmpty(_licenseId)) {
selectedLicenseIdList.add(_licenseId);
}
}
}
List<OssComponentsLicense> updateLicenseList = new ArrayList<>();
// oss name์ด ํ์ดํ์ด ์๋๋ผ๋ฉด, OSS List์ ๋ฑ๋ก๋ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ทจํฉ
if (!isEmptyOss) {
boolean hasSelectedLicense = false;
for (OssLicense license : ossBean.getOssLicenses()) {
OssComponentsLicense componentLicense = new OssComponentsLicense();
componentLicense.setComponentId(bean.getComponentId());
componentLicense.setLicenseId(license.getLicenseId());
componentLicense.setLicenseName(license.getLicenseName());
// license text ์ค์ ์ ๋ถํ์ํจ
if (selectedLicenseIdList.contains(componentLicense.getLicenseId())) {
hasSelectedLicense = true;
componentLicense.setExcludeYn(CoConstDef.FLAG_NO);
}
updateLicenseList.add(componentLicense);
}
for (OssComponentsLicense license : updateLicenseList) {
if (hasSelectedLicense) {
license.setExcludeYn(avoidNull(license.getExcludeYn(), CoConstDef.FLAG_YES));
} else {
license.setExcludeYn(CoConstDef.FLAG_NO);
}
projectMapper.insertOssComponentsLicense(license);
}
} else {
// oss name์ด ํ์ดํ์ด๋ผ๋ฉด ๋ผ์ด์ ์ค binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๋ฅผ ๊ทธ๋๋ก ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ license๊ฐ ๋ณต์๊ฐ๋ก ๋ฑ๋ก๋์ด ์์ ์ ์์
OssComponentsLicense license = new OssComponentsLicense();
license.setExcludeYn(CoConstDef.FLAG_NO);
license.setComponentId(addOssComponentFlag ? updateBean.getComponentId() : bean.getComponentId());
// binary db์ ๋ฑ๋ก๋ license ์ ๋ณด๊ฐ license master์ ๋ฑ๋ก๋์ด ์๋ค๋ฉด master ์ ๋ณด๋ฅผ ์ฌ์ฉ
if (!isEmpty(_binaryLicenseStr) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(_binaryLicenseStr.toUpperCase().trim())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_binaryLicenseStr.toUpperCase().trim());
license.setLicenseId(licenseMaster.getLicenseId());
license.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseName()));
} else {
// ๋ฑ๋ก๋์ด ์์ง ์๋ค๋ฉด, license name๋ง ๋ฑ๋กํ๋ค.
// ์ด๋ฌํ ๊ฒฝ์ฐ๋ ์ฌ์คํญ ์กด์ฌํ ์ ์์
license.setLicenseName(avoidNull(_binaryLicenseStr));
}
projectMapper.insertOssComponentsLicense(license);
}
}
}
}
}
}
@Override
public Map<String, List<String>> nickNameValid(List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentLicenseList) {
List<String> ossNickNameCheckResult = new ArrayList<>();
List<String> licenseNickNameCheckResult = new ArrayList<>();
Map<String, List<String>> result = new HashMap<String, List<String>>();
List<String> ossCheckParam = new ArrayList<>();
List<String> licenseCheckParam = new ArrayList<>();
for (ProjectIdentification bean : ossComponentList) {
String _ossName = avoidNull(bean.getOssName()).trim();
int isAdminCheck = projectMapper.selectAdminCheckCnt(bean);
if (!isEmpty(_ossName) && !"-".equals(_ossName) && !ossCheckParam.contains(_ossName) && isAdminCheck < 1) {
ossCheckParam.add(_ossName);
}
if (CoConstDef.LICENSE_DIV_MULTI.equals(bean.getLicenseDiv())) {
// ์ฌ๊ธฐ์ ํ ํ์ ์์
} else {
String _licenseName = avoidNull(bean.getLicenseName()).trim();
if (!isEmpty(_licenseName) && !licenseCheckParam.contains(_licenseName)) {
licenseCheckParam.add(_licenseName);
}
}
}
// multi license์ ๊ฒฝ์ฐ nickname check๋์ ์ถ์ถ
for (List<ProjectIdentification> licenseList : ossComponentLicenseList) {
for (ProjectIdentification licenseBean : licenseList) {
String _licenseName = avoidNull(licenseBean.getLicenseName()).trim();
if (!isEmpty(_licenseName) && !licenseCheckParam.contains(_licenseName)) {
licenseCheckParam.add(_licenseName);
}
}
}
List<OssMaster> ossNickNameList = null;
if (!ossCheckParam.isEmpty()) {
OssMaster param = new OssMaster();
param.setOssNames(ossCheckParam.toArray(new String[ossCheckParam.size()]));
ossNickNameList = projectMapper.checkOssNickName(param);
if (ossNickNameList != null) {
for (OssMaster bean : ossNickNameList) {
String _disp = bean.getOssNickname() + " => " + bean.getOssName();
if (!ossNickNameCheckResult.contains(_disp)) {
ossNickNameCheckResult.add(_disp);
}
}
}
}
if (!licenseCheckParam.isEmpty()) {
for (String licenseName : licenseCheckParam) {
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (licenseName.equalsIgnoreCase(s)) {
String disp = licenseName + " => " + avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp());
if (!licenseNickNameCheckResult.contains(disp)) {
licenseNickNameCheckResult.add(disp);
break;
}
}
}
}
}
}
}
result.put("OSS", ossNickNameCheckResult);
result.put("LICENSE", licenseNickNameCheckResult);
return result;
}
@SuppressWarnings("unchecked")
@Override
@Transactional
public void registBom(String prjId, String merge, List<ProjectIdentification> projectIdentification, List<ProjectIdentification> checkGridBomList) {
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
List<ProjectIdentification> includeVulnInfoNewBomList = new ArrayList<>();
List<ProjectIdentification> includeVulnInfoOldBomList = new ArrayList<>();
List<String> cvssScoreMaxList = new ArrayList<>();
List<String> cvssScoreMaxVendorProductList = new ArrayList<>();
// ์ปดํฌ๋ํธ ์ญ์
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(prjId);
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
identification.setMerge(CoConstDef.FLAG_NO);
// ๊ธฐ์กด bom data get
List<ProjectIdentification> bomList = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(identification);;
if (notVersionList != null && !notVersionList.isEmpty()) {
bomList.addAll(notVersionList);
}
identification.setOssVersionEmptyFlag(null);
List<String> adminCheckComponentIds = new ArrayList<>();
List<String> removeAdminCheckComponentIds = new ArrayList<>();
for (ProjectIdentification bomGridData : checkGridBomList) {
for (String refComponentId : bomGridData.getRefComponentId().split(",")) {
removeAdminCheckComponentIds.add(refComponentId.trim());
}
}
if (bomList != null && !bomList.isEmpty()) {
for (ProjectIdentification pi : bomList) {
if (pi.getAdminCheckYn().equals(CoConstDef.FLAG_YES)) adminCheckComponentIds.add(pi.getRefComponentId());
// convert max score
if (pi.getCvssScoreMax() != null) {
cvssScoreMaxList.add(pi.getCvssScoreMax());
}
if (pi.getCvssScoreMax1() != null) {
cvssScoreMaxVendorProductList.add(pi.getCvssScoreMax1());
}
if (pi.getCvssScoreMax2() != null) {
cvssScoreMaxList.add(pi.getCvssScoreMax2());
}
if (pi.getCvssScoreMax3() != null) {
cvssScoreMaxVendorProductList.add(pi.getCvssScoreMax3());
}
String conversionCveInfo = CommonFunction.getConversionCveInfo(pi.getReferenceId(), ossInfoMap, pi, cvssScoreMaxVendorProductList, cvssScoreMaxList, false);
if (conversionCveInfo != null) {
String[] conversionCveInfoSplit = conversionCveInfo.split("\\@");
if (new BigDecimal(conversionCveInfoSplit[3]).compareTo(new BigDecimal("8.0")) > -1) {
includeVulnInfoOldBomList.add(pi);
}
}
cvssScoreMaxVendorProductList.clear();
cvssScoreMaxList.clear();
}
}
if (!removeAdminCheckComponentIds.isEmpty()) adminCheckComponentIds.removeAll(removeAdminCheckComponentIds);
List<OssComponents> componentId = projectMapper.selectComponentId(identification);
// ๊ธฐ์กด bom ์ ๋ณด๋ฅผ ๋ชจ๋ ๋ฌผ๋ฆฌ์ญ์ ํ๊ณ ๋ค์ ๋ฑ๋กํ๋ค.
if (componentId.size() > 0){
for (int i = 0; i < componentId.size(); i++) {
projectMapper.deleteOssComponentsLicense(componentId.get(i));
}
projectMapper.deleteOssComponents(identification);
}
identification.setMerge(merge);
identification.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
identification.setSaveBomFlag(CoConstDef.FLAG_YES); // file path ๋ฅผ groupping ํ์ง ์๊ณ , ๊ฐ๋ณ๋ก data ๋ฑ๋ก
Map<String, Object> mergeListMap = getIdentificationGridList(identification);
if (mergeListMap != null && mergeListMap.get("rows") != null) {
for (ProjectIdentification bean : (List<ProjectIdentification>)mergeListMap.get("rows")) {
bean.setRefDiv(bean.getReferenceDiv());
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
bean.setRefComponentId(bean.getComponentId());
if (adminCheckComponentIds.contains(bean.getRefComponentId())) {
bean.setAdminCheckYn(CoConstDef.FLAG_YES);
} else {
bean.setAdminCheckYn(CoConstDef.FLAG_NO);
}
bean.setPreObligationType(bean.getObligationType());
// ๊ทธ๋ฆฌ๋ ๋ฐ์ดํฐ ๋ฃ๊ธฐ
for (ProjectIdentification gridData : projectIdentification) {
// merge ๊ฒฐ๊ณผ (src/bat/3rd) ์ผ์
if (gridData.getRefComponentId().contains(bean.getRefComponentId())){
bean.setMergePreDiv(gridData.getMergePreDiv());
// BOM์ ์ด๊ธฐํ์๋ obligation์ ์ด๊ธฐ ๊ฐ์ผ๋ก ์ค์
// needs check์ ๊ฒฝ์ฐ๋ง ํ๋ฉด์์ ์
๋ ฅ๋ฐ๋๋ค.
if (CoConstDef.FLAG_YES.equals(gridData.getAdminCheckYn())) {
bean.setAdminCheckYn(gridData.getAdminCheckYn());
if (CoConstDef.FLAG_YES.equals(gridData.getSource())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
} else if (CoConstDef.FLAG_YES.equals(gridData.getNotify())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
} else if (CoConstDef.FLAG_NO.equals(gridData.getNotify()) && CoConstDef.FLAG_NO.equals(gridData.getSource())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK_SELECTED);
}
bean.setDownloadLocation(gridData.getDownloadLocation());
bean.setHomepage(gridData.getHomepage());
bean.setCopyrightText(gridData.getCopyrightText());
}
break;
}
}
bean = CommonFunction.findOssIdAndName(bean);
if (bean.getCvssScoreMax() != null) {
cvssScoreMaxList.add(bean.getCvssScoreMax());
}
if (bean.getCvssScoreMax1() != null) {
cvssScoreMaxVendorProductList.add(bean.getCvssScoreMax1());
}
if (bean.getCvssScoreMax2() != null) {
cvssScoreMaxList.add(bean.getCvssScoreMax2());
}
if (bean.getCvssScoreMax3() != null) {
cvssScoreMaxVendorProductList.add(bean.getCvssScoreMax3());
}
String conversionCveInfo = CommonFunction.getConversionCveInfo(bean.getReferenceId(), ossInfoMap, bean, cvssScoreMaxVendorProductList, cvssScoreMaxList, false);
if (conversionCveInfo != null) {
String[] conversionCveInfoSplit = conversionCveInfo.split("\\@");
if (new BigDecimal(conversionCveInfoSplit[3]).compareTo(new BigDecimal("8.0")) > -1) {
includeVulnInfoNewBomList.add(bean);
}
}
if(!isEmpty(bean.getCopyrightText())) {
String[] copyrights = bean.getCopyrightText().split("\\|");
String copyrightText = Arrays.stream(copyrights).distinct().collect(Collectors.joining("\n"));
bean.setCopyrightText(copyrightText);
}
// ์ปดํฌ๋ํธ ๋ง์คํฐ ์ธ์ํธ
projectMapper.registBomComponents(bean);
List<OssComponentsLicense> licenseList = CommonFunction.findOssLicenseIdAndName(bean.getOssId(), bean.getOssComponentsLicenseList());
for (OssComponentsLicense licenseBean : licenseList) {
licenseBean.setComponentId(bean.getComponentId());
projectMapper.registComponentLicense(licenseBean);
}
cvssScoreMaxVendorProductList.clear();
cvssScoreMaxList.clear();
}
}
// identification ๋์์ด ์์ด ์ฒ์ ์ ์ฅํ๋ ๊ฒฝ์ฐ
Project _tempPrjInfo = new Project();
_tempPrjInfo.setPrjId(prjId);
_tempPrjInfo = projectMapper.selectProjectMaster2(_tempPrjInfo);
if (isEmpty(_tempPrjInfo.getIdentificationStatus())) {
_tempPrjInfo.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
projectMapper.updateIdentifcationProgress(_tempPrjInfo);
}
// add or delete data containing vulnerability information among oss information
String securityComment = "";
List<ProjectIdentification> duplicatedNewVulnInfoList = null;
List<ProjectIdentification> duplicatedOldVulnInfoList = null;
if (!includeVulnInfoNewBomList.isEmpty()) {
duplicatedNewVulnInfoList = includeVulnInfoNewBomList.stream().filter(CommonFunction.distinctByKey(p -> p.getOssName()+p.getOssVersion())).collect(Collectors.toList());
}
if (!includeVulnInfoOldBomList.isEmpty()) {
duplicatedOldVulnInfoList = includeVulnInfoOldBomList.stream().filter(CommonFunction.distinctByKey(p -> p.getOssName()+p.getOssVersion())).collect(Collectors.toList());
}
if (duplicatedNewVulnInfoList != null && duplicatedOldVulnInfoList != null) {
List<ProjectIdentification> filteredAddVulnDataList = includeVulnInfoNewBomList
.stream()
.filter(bfList->
includeVulnInfoOldBomList
.stream()
.filter(afList ->
(bfList.getOssName() + "||" + bfList.getOssVersion()).equalsIgnoreCase(afList.getOssName() + "||" + afList.getOssVersion())
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
List<ProjectIdentification> filteredDelVulnDataList = includeVulnInfoOldBomList
.stream()
.filter(bfList->
includeVulnInfoNewBomList
.stream()
.filter(afList ->
(bfList.getOssName() + "||" + bfList.getOssVersion()).equalsIgnoreCase(afList.getOssName() + "||" + afList.getOssVersion())
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
if (filteredAddVulnDataList != null && !filteredAddVulnDataList.isEmpty()) {
securityComment += "<p><strong>Added vulnerabilities from Identification</strong>";
for (ProjectIdentification pi : filteredAddVulnDataList) {
securityComment += "<br />" + pi.getOssName() + " (" + avoidNull(pi.getOssVersion(), "N/A") + ")";
}
}
if (filteredDelVulnDataList != null && !filteredDelVulnDataList.isEmpty()) {
if (!securityComment.isEmpty()) securityComment += "<br /><br />";
securityComment += "<p><strong>Deleted vulnerabilities from Identification</strong>";
for (ProjectIdentification pi : filteredDelVulnDataList) {
securityComment += "<br />" + pi.getOssName() + " (" + avoidNull(pi.getOssVersion(), "N/A") + ")";
}
}
} else if (duplicatedNewVulnInfoList != null) {
securityComment += "<p><strong>Added vulnerabilities from Identification</strong>";
for (ProjectIdentification pi : duplicatedNewVulnInfoList) {
securityComment += "<br />" + pi.getOssName() + " (" + avoidNull(pi.getOssVersion(), "N/A") + ")";
}
} else if (duplicatedOldVulnInfoList != null) {
securityComment += "<p><strong>Deleted vulnerabilities from Identification</strong>";
for (ProjectIdentification pi : duplicatedOldVulnInfoList) {
securityComment += "<br />" + pi.getOssName() + " (" + avoidNull(pi.getOssVersion(), "N/A") + ")";
}
}
if (!isEmpty(securityComment)) {
securityComment += "</p>";
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_SECURITY_HIS);
commHisBean.setReferenceId(prjId);
commHisBean.setContents(securityComment);
commentService.registComment(commHisBean, false);
}
}
@Override
public void checkProjectReviewer(Project project) {
Project param = new Project();
param.setPrjId(project.getPrjId());
param = projectMapper.selectProjectMaster2(param);
//review ์ํ๋ก ๋ณ๊ฒฝ์ reviewer๊ฐ ์ค์ ๋์ด ์์ง ์์ ๊ฒฝ์ฐ, reviewer๋ ์
๋ฐ์ดํธ ํ๋ค.
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(project.getIdentificationStatus())) {
if (isEmpty(param.getReviewer())) {
param.setModifier(param.getLoginUserName());
param.setReviewer(param.getLoginUserName());
projectMapper.updateReviewer(param);
try {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_ADD);
mailBean.setToIds(new String[] {param.getLoginUserName()});
mailBean.setParamPrjId(project.getPrjId());
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
@Override
@Transactional
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
public Map<String, Object> updateProjectStatus(Project project) throws Exception {
Map<String, Object> resultMap = new HashMap<>();
String commentDiv = isEmpty(project.getReferenceDiv()) ? CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS
: project.getReferenceDiv();
String userComment = project.getUserComment();
String statusCode = project.getIdentificationStatus();
if (isEmpty(statusCode)) {
statusCode = project.getVerificationStatus();
}
String status = CoCodeManager.getCodeExpString(CoConstDef.CD_IDENTIFICATION_STATUS, statusCode);
String mailType = null;
log.info("statusCode : " + statusCode + "/ status : " + status);
log.debug("PARAM: " + "identificationStatus="+project.getIdentificationStatus());
log.debug("PARAM: " + "completeYn="+project.getCompleteYn());
// Identification confirm์ validation check ์ํ
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(project.getIdentificationStatus())) {
boolean isAndroidModel = false;
boolean isNetworkRestriction = false;
boolean hasSourceOss = false;
boolean hasNotificationOss = false;
Map<String, Object> map = null;
// confirm ์ ๋ค์ DB Data๋ฅผ ๊ฐ์ ธ์์ ์ฒดํฌํ๋ค.
ProjectIdentification param = new ProjectIdentification();
param.setReferenceId(project.getPrjId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
param.setMerge(CoConstDef.FLAG_NO);
map = getIdentificationGridList(param);
if (map != null && map.containsKey("rows") && !((List<ProjectIdentification>) map.get("rows")).isEmpty()) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_BOM_MERGE);
pv.setAppendix("bomList", (List<ProjectIdentification>) map.get("rows"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
// return validator result
if (!vr.isValid() && !vr.isAdminCheck((List<String>) map.get("adminCheckList"))) {
// return makeJsonResponseHeader(vr.getValidMessageMap());
resultMap.put("validMap", vr.getValidMessageMap());
return resultMap;
}
String networkRedistribution = CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, CoConstDef.CD_LICENSE_NETWORK_RESTRICTION);
for (ProjectIdentification _projectBean : (List<ProjectIdentification>) map.get("rows")) {
if (hasSourceOss && hasNotificationOss && isNetworkRestriction) {
break;
}
if (!hasNotificationOss) {
if (!CoConstDef.FLAG_YES.equals(_projectBean.getExcludeYn()) && ("10".equals(_projectBean.getObligationType()) || "11".equals(_projectBean.getObligationType()) )) {
hasNotificationOss = true;
}
}
if (!hasSourceOss) {
if ("11".equals(_projectBean.getObligationType())){
hasSourceOss = true;
}
}
if (!isNetworkRestriction) {
if (("10".equals(_projectBean.getObligationType()) || "11".equals(_projectBean.getObligationType())) && _projectBean.getRestriction().toUpperCase().contains(networkRedistribution.toUpperCase())) {
isNetworkRestriction = true;
}
}
}
}
Project prjInfo = null;
{
// ANDROID PROJECT์ธ ๊ฒฝ์ฐ
Project prjParam = new Project();
prjParam.setPrjId(project.getPrjId());
prjInfo = getProjectDetail(prjParam);
if (CoConstDef.FLAG_YES.equals(prjInfo.getAndroidFlag())
&& !CoConstDef.FLAG_NO.equals(prjInfo.getIdentificationSubStatusAndroid())
&& !CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA.equals(prjInfo.getIdentificationSubStatusAndroid())) {
param = new ProjectIdentification();
param.setReferenceId(project.getPrjId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID);
map = getIdentificationGridList(param);
if (map != null && map.containsKey("mainData")
&& !((List<ProjectIdentification>) map.get("mainData")).isEmpty()) {
isAndroidModel = true;
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_ANDROID);
pv.setAppendix("mainList", (List<ProjectIdentification>) map.get("mainData"));
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) map.get("subData"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
// return validator result
if (!vr.isValid()) {
// return makeJsonResponseHeader(false, getMessage("msg.project.android.valid"));
resultMap.put("androidMessage", getMessage("msg.project.android.valid"));
return resultMap;
}
}
}
}
if (CoConstDef.FLAG_YES.equals(prjInfo.getNetworkServerType())) {
if (!isNetworkRestriction) {
project.setSkipPackageFlag(CoConstDef.FLAG_YES);
project.setVerificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA);
project.setDestributionStatus(CoConstDef.CD_DTL_DISTRIBUTE_STATUS_NA);
}
} else {
if (isAndroidModel) {
project.setAndroidFlag(CoConstDef.FLAG_YES);
} else if (!hasNotificationOss) {
// Android model์ด ์๋๋ฉด์ bom ๋์์ด ์๋ ๊ฒฝ์ฐ
// package, distribute๋ฅผ N/A ์ฒ๋ฆฌํ๋ค.
project.setSkipPackageFlag(CoConstDef.FLAG_YES);
project.setVerificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA);
project.setDestributionStatus(CoConstDef.CD_DTL_DISTRIBUTE_STATUS_NA);
}
}
if (CoConstDef.CD_NOTICE_TYPE_NA.equals(prjInfo.getNoticeType())) {
if (!hasSourceOss) {
project.setSkipPackageFlag(CoConstDef.FLAG_YES);
project.setVerificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA);
project.setDestributionStatus(CoConstDef.CD_DTL_DISTRIBUTE_STATUS_NA);
}
}
project.setModifier(project.getLoginUserName());
updateProjectIdentificationConfirm(project);
// network server ์ด๋ฉด์ notice ์์ฑ ๋์์ด ์์ ๊ฒฝ์ฐ
if ( hasNotificationOss
&& CoConstDef.FLAG_NO.equals(avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_DISTRIBUTION_TYPE,
prjInfo.getDistributionType())).trim().toUpperCase())
&& verificationService.checkNetworkServer(prjInfo.getPrjId()) ) {
project.setSkipPackageFlag(CoConstDef.FLAG_YES);
project.setVerificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA);
project.setDestributionStatus(CoConstDef.CD_DTL_DISTRIBUTE_STATUS_NA);
updateIdentificationConfirmSkipPackaing(project);
hasNotificationOss = false;
}
// permissive๋ก๋ง ์ด๋ฃจ์ด์ ธ์๊ณ , notice type์ด ๊ธฐ๋ณธ์ธ ๊ฒฝ์ฐ, ๋ฐ๋ก packaging review์ํ๋ก
// ๋ณ๊ฒฝํ๋ค.
if ((!isAndroidModel && !hasNotificationOss)
|| (CoConstDef.FLAG_YES.equals(prjInfo.getNetworkServerType()) && !isNetworkRestriction) // Network service Only : yes ์ด์ง๋ง network restriction์ด ์๋ case
|| (CoConstDef.CD_NOTICE_TYPE_NA.equals(prjInfo.getNoticeType()) && !hasSourceOss)) { // OSS Notice๊ฐ N/A์ด๋ฉด์ packaging์ด ํ์ ์๋ ๊ฒฝ์ฐ
// do nothing
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY;
if (!isEmpty(avoidNull(userComment)) && (CoConstDef.FLAG_YES.equals(prjInfo.getNetworkServerType()) && !isNetworkRestriction)) {
userComment = avoidNull(userComment) + "<br />" + avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY));
} else {
userComment = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY));
}
} else {
String _tempComment;
if(isAndroidModel) {
mailType = CoConstDef.CD_MAIL_TYPE_BIN_PROJECT_IDENTIFICATION_CONF;
_tempComment = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_BIN_PROJECT_IDENTIFICATION_CONF));
} else {
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF;
_tempComment = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF));
}
userComment = avoidNull(userComment) + "<br />" + _tempComment;
}
} else if (!isEmpty(project.getCompleteYn())) {
// project complete ์
updateProjectMaster(project);
String _tempComment = "";
if (CoConstDef.FLAG_YES.equals(project.getCompleteYn())) {
_tempComment = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_PROJECT_COMPLETED));
userComment = avoidNull(userComment) + "<br />" + _tempComment;
}
// complete log ์ถ๊ฐ
commentDiv = CoConstDef.CD_DTL_COMMENT_PROJECT_HIS;
status = CoConstDef.FLAG_YES.equals(project.getCompleteYn()) ? "Completed" : "Reopened";
// complete mail ๋ฐ์ก
mailType = CoConstDef.FLAG_YES.equals(project.getCompleteYn()) ? CoConstDef.CD_MAIL_TYPE_PROJECT_COMPLETED : CoConstDef.CD_MAIL_TYPE_PROJECT_REOPENED;
} else if (!isEmpty(project.getDropYn())){
// project drop ์
updateProjectMaster(project);
String _tempComment = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TYPE_PROJECT_DROPPED));
userComment = avoidNull(userComment) + "<br />" + _tempComment;
// complete log ์ถ๊ฐ
commentDiv = CoConstDef.CD_DTL_COMMENT_PROJECT_HIS;
status = "Dropped";
// complete mail ๋ฐ์ก
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_DROPPED;
} else {
boolean ignoreValidation = CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(project.getIdentificationStatus())
|| CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(project.getVerificationStatus())
|| CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(project.getVerificationStatus());
boolean isIdentificationReject = false;
Project beforeInfo = getProjectDetail(project);
// Identification
// default -> request
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(project.getIdentificationStatus())
&& !CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(beforeInfo.getIdentificationStatus())) {
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REQ_REVIEW;
// Admin ์ฌ์ฉ์์ ๊ฒฝ์ฐ ์ค๋ฅ๊ฐ ์์ด๋ request review ๊ฐ๋ฅํ๋๋ก ์์
if (CommonFunction.isAdmin()) {
ignoreValidation = true;
}
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS.equals(project.getIdentificationStatus())) {
ignoreValidation = true;
isIdentificationReject = true;
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(beforeInfo.getIdentificationStatus())) {
// self reject
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_SELF_REJECT;
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW
.equals(beforeInfo.getIdentificationStatus())) {
// reject by review
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REJECT;
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM
.equals(beforeInfo.getIdentificationStatus())) {
// confirm to review
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CANCELED_CONF;
}
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(project.getVerificationStatus()) // Packaging
&& !CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(beforeInfo.getVerificationStatus())) {
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REQ_REVIEW;
//ignoreValidation = true;
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS.equals(project.getVerificationStatus())) {
ignoreValidation = true;
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(beforeInfo.getVerificationStatus())) {
// self reject
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_SELF_REJECT;
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(beforeInfo.getVerificationStatus())) {
// review -> reject
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REJECT;
} else if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(beforeInfo.getVerificationStatus())) {
mailType = CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CANCELED_CONF;
}
}
// ์ฌ์ฉ์๊ฐ rejectํ๋ ๊ฒฝ์ฐ๋ validation check ์ํํ์ง ์์
if (!ignoreValidation) {
// Identification Reqeust review์ธ ๊ฒฝ์ฐ, ํ์ ํญ๋ชฉ ์ฒดํฌ ์ถ๊ฐ
Map<String, Object> map = null;
// confirm ์ ๋ค์ DB Data๋ฅผ ๊ฐ์ ธ์์ ์ฒดํฌํ๋ค.
ProjectIdentification param = new ProjectIdentification();
param.setReferenceId(project.getPrjId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
param.setMerge(CoConstDef.FLAG_NO);
map = getIdentificationGridList(param);
if (map != null && map.containsKey("rows") && !((List<ProjectIdentification>) map.get("rows")).isEmpty()) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_BOM_MERGE);
pv.setValidLevel(pv.VALID_LEVEL_REQUEST);
pv.setAppendix("bomList", (List<ProjectIdentification>) map.get("rows"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
// return validator result
if (!vr.isValid()) {
if (!vr.isDiff()) {
// return makeJsonResponseHeader(false, null, vr.getValidMessageMap(), vr.getDiffMessageMap());
resultMap.put("diffMap", vr.getDiffMessageMap());
}
// return makeJsonResponseHeader(false, null, vr.getValidMessageMap());
resultMap.put("validMap", vr.getValidMessageMap());
return resultMap;
}
}
Project prjInfo = null;
{
// ANDROID PROJECT์ธ ๊ฒฝ์ฐ
Project prjParam = new Project();
prjParam.setPrjId(project.getPrjId());
prjInfo = getProjectDetail(prjParam);
if (CoConstDef.FLAG_YES.equals(prjInfo.getAndroidFlag())
&& !CoConstDef.FLAG_NO.equals(prjInfo.getIdentificationSubStatusAndroid())
&& !CoConstDef.CD_DTL_IDENTIFICATION_STATUS_NA.equals(prjInfo.getIdentificationSubStatusAndroid())) {
param = new ProjectIdentification();
param.setReferenceId(project.getPrjId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID);
map = getIdentificationGridList(param);
if (map != null && map.containsKey("mainData")
&& !((List<ProjectIdentification>) map.get("mainData")).isEmpty()) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_ANDROID);
pv.setAppendix("mainList", (List<ProjectIdentification>) map.get("mainData"));
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) map.get("subData"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
// return validator result
if (!vr.isValid()) {
// return makeJsonResponseHeader(false, getMessage("msg.project.android.valid"));
resultMap.put("androidMessage", getMessage("msg.project.android.valid"));
return resultMap;
}
}
}
}
}
project.setModifier(project.getLoginUserName());
project.setModifiedDate(project.getCreatedDate());
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(project.getIdentificationStatus())) {
checkProjectReviewer(project);
}
projectMapper.updateProjectMaster(project);
if (!isEmpty(project.getVerificationStatus())) {
verificationService.updateProjectAllowDownloadBitFlag(project);
}
}
resultMap.put("mailType", mailType);
resultMap.put("userComment", userComment);
resultMap.put("commentDiv", commentDiv);
resultMap.put("status", status);
return resultMap;
}
@Override
@Transactional
public void updateProjectIdentificationConfirm(Project project) {
Map<String, Object> map = null;
ProjectIdentification param = new ProjectIdentification();
param.setReferenceId(project.getPrjId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
param.setMerge(CoConstDef.FLAG_NO);
map = getIdentificationGridList(param);
if (map != null && map.containsKey("rows") && !((List<ProjectIdentification>) map.get("rows")).isEmpty()) {
for (ProjectIdentification bean : (List<ProjectIdentification>) map.get("rows")) {
String ossCopyright = findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright());
OssMaster oss = CoCodeManager.OSS_INFO_BY_ID.get(bean.getOssId());
if(oss != null) {
bean.setCopyrightText(avoidNull(oss.getCopyright()));
}
if (!isEmpty(ossCopyright)) {
String addCopyright = avoidNull(bean.getCopyrightText());
if (!isEmpty(bean.getCopyrightText())) {
addCopyright += "\n";
}
addCopyright += ossCopyright;
bean.setCopyrightText(addCopyright);
}
projectMapper.updateComponentsCopyrightInfo(bean);
}
}
// oss id ๋ฑ๋ก
projectMapper.updateComponentsOssId(project);
// downlaod location, homepage๋ฑ master ์ ๋ณด๋ก ์นํ
projectMapper.updateComponentsOssInfo(project);
// license id ๋ฑ๋ก
projectMapper.updateComponentsLicenseId(project);
// license id ๋ฑ๋ก ์ดํ์ license text, copyright ์ ๋ณด๋ฅผ confirm ์์ ์ oss master์ ๋ฑ๋ก๋์ด ์๋ ๊ธฐ์ค ์ ๋ณด๋ก ์
๋ฐ์ดํธ ํ๋ค.
projectMapper.updateComponentsLicenseInfo(project);
// ์ํ ๋ณ๊ฒฝ (packaging, distribute ์ด๊ธฐ์ ์์
์ด ์๊ธฐ ๋๋ฌธ์ ๊ณตํต service๋ฅผ ์ฌ์ฉํ์ง ์๊ณ confirm์ธ ๊ฒฝ์ฐ๋ง ๋ณ๋๋ก ์ถ๊ฐ)
projectMapper.updateIdentificationConfirm(project);
// Identification confirm์ OSS๊ฐ ๋ฑ๋ก๋์ง ์์ Tab์ ๋ํด์๋ N/A ์ฒ๋ฆฌ
projectMapper.updateProjectStatusWithComplete(project);
// packaging ์ด๋ฃจ ๋ถํฐ๋ reference_div = "50" ๋ง ์ฐธ์กฐํ ์ ์๋๋ก confirm ๋จ๊ณ์์ ๋์ notice ๋์ data๋ฅผ ๋ชจ๋ 50๋ฒ์ผ๋ก copyํ๋ค.
// ๊ธฐ์กด์ ๋ฑ๋ก๋ data๊ฐ ์์ ์ ์๊ธฐ ๋๋ฌธ์ ์ญ์ ํ ๋ฑ๋ก
{
// ๊ธฐ์กด์ ๋ฑ๋ก๋์ด ์๋ data๋ฅผ ์ญ์ ํ๊ธฐ ์ ์ path์ ๋ณด๋ฅผ ๋ค์ ๋งคํํด์ฃผ๊ธฐ ์ํด์ verify ๋์ ์ ๋ณด๋ฅผ ์ทจ๋ํ๋ค.
List<OssComponents> oldPackagingList = verificationService.getVerifyOssList(project);
Map<String, OssComponents> oldPackageInfoMap = new HashMap<>();
if (oldPackagingList != null && !oldPackagingList.isEmpty()) {
// key value ํ์์ผ๋ก
// key = ref + oss name + oss version + license name
for (OssComponents oldBean : oldPackagingList) {
if (!isEmpty(oldBean.getFilePath())) {
String key = oldBean.getReferenceDiv() + "|" + oldBean.getOssId() + "|" + oldBean.getLicenseName();
oldPackageInfoMap.put(key, oldBean);
}
}
}
// 1) packaging components delete ์ฒ๋ฆฌ
ProjectIdentification delParam = new ProjectIdentification();
delParam.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PACKAGING);
delParam.setReferenceId(project.getPrjId());
List<OssComponents> componentId = projectMapper.selectComponentId(delParam);
for (int i = 0; i < componentId.size(); i++) {
projectMapper.deleteOssComponentsLicense(componentId.get(i));
}
projectMapper.deleteOssComponents(delParam);
// 2) get bom list
ProjectIdentification bomParam = new ProjectIdentification();
bomParam.setReferenceId(project.getPrjId());
bomParam.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
bomParam.setMerge(CoConstDef.FLAG_NO);
bomParam.setNoticeFlag(CoConstDef.FLAG_YES); // notice ๋์๋ง ์ถ์ถํ๋ค. (obligation type์ด 10, 11)
bomParam.setSaveBomFlag(CoConstDef.FLAG_YES);
bomParam.setBomWithAndroidFlag(project.getAndroidFlag()); // android Project
List<ProjectIdentification> bomList = projectMapper.selectBomList(bomParam);
bomParam.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(bomParam);;
if (notVersionList != null) {
bomList.addAll(notVersionList);
}
bomParam.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
bomList.sort(compare);
// ์ผ๊ด ๋ฑ๋ก์ ์ํด ๋์ data์ component id ๋ง ์ถ์ถํ๋ค.
List<String> groupingList = new ArrayList<>(); // ๋ถํ์ํ row (์ค๋ณต) ๋ ๋ฏธ๋ฑ๋ก
List<String> componentList = new ArrayList<>();
if (bomList != null) {
for (ProjectIdentification bean : bomList) {
if (groupingList.contains(bean.getGroupingColumn())) {
continue;
}
if (CoConstDef.FLAG_YES.equals(bean.getAdminCheckYn()) && ("11".equals(bean.getObligationType()) || "10".equals(bean.getObligationType()))) {
componentList.add(bean.getComponentId()+"-"+bean.getAdminCheckYn());
}else {
componentList.add(bean.getComponentId());
}
}
}
// ์๋๋ก์ด๋ ๋ชจ๋ธ์ธ ๊ฒฝ์ฐ ์์ ์๋ ์์
if (!componentList.isEmpty()) {
for (String refComponentId : componentList) {
OssComponents copyParam = new OssComponents();
copyParam.setReferenceId(project.getPrjId());
copyParam.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PACKAGING);
copyParam.setExcludeYn(CoConstDef.FLAG_NO);
copyParam.setAndroidFlag(project.getAndroidFlag());
if (refComponentId.contains("-")) {
String[] ids = refComponentId.split("-");
copyParam.setRefComponentId(ids[0]);
copyParam.setAdminCheckYn(ids[1]);
}else {
copyParam.setRefComponentId(refComponentId);
}
projectMapper.insertOssComponentsCopy(copyParam);
projectMapper.insertOssComponentsLicenseCopy(copyParam);
}
}
if (oldPackageInfoMap != null && !oldPackageInfoMap.isEmpty()) {
List<OssComponents> afterPackagingList = verificationService.getVerifyOssList(project);
if (afterPackagingList != null && !afterPackagingList.isEmpty()) {
// key value ํ์์ผ๋ก
// key = ref + oss name + oss version + license name
for (OssComponents newBean : afterPackagingList) {
String key = newBean.getReferenceDiv() + "|" + newBean.getOssId() + "|" + newBean.getLicenseName();
if (oldPackageInfoMap.containsKey(key)) {
newBean.setFilePath(oldPackageInfoMap.get(key).getFilePath());
projectMapper.updateFilePath(newBean);
}
}
}
}
// StatisticsMostUsed > OssInfo INSERT
projectMapper.insertStatisticsMostUsedOssInfo(project);
// StatisticsMostUsed > LicenseInfo INSERT
projectMapper.insertStatisticsMostUsedLicenseInfo(project);
}
}
@Override
public void updateIdentificationConfirmSkipPackaing(Project project) {
projectMapper.updateIdentificationConfirm(project);
}
@Override
public void updateProjectMaster(Project project) {
projectMapper.updateProjectMaster(project);
if (CoConstDef.FLAG_YES.equals(project.getCompleteYn())) {
projectMapper.updateProjectStatusWithComplete(project);
}
}
@Override
public List<Project> getModelListExcel(Project project) {
String prjId = project.getPrjId();
List<Project> modelList = projectMapper.selectModelList(prjId);
return modelList;
}
@Transactional
@Override
public void registReadmeContent(Project project) {
projectMapper.updateReadmeContent(project);
}
@Override
public Map<String, Object> getPartnerList(PartnerMaster partnerMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
int records = 0;
List<PartnerMaster> list = new ArrayList<PartnerMaster>();
partnerMaster.setStatus("CONF");
if ("ROLE_USER".equals(partnerMaster.getLoginUserRole())){
records = partnerMapper.selectPartnerMasterTotalCountUser(partnerMaster);
partnerMaster.setTotListSize(records);
list = partnerMapper.selectPartnerListUser(partnerMaster);
}else{
records = partnerMapper.selectPartnerMasterTotalCount(partnerMaster);
partnerMaster.setTotListSize(records);
list = partnerMapper.selectPartnerList(partnerMaster);
}
map.put("page", partnerMaster.getCurPage());
map.put("total", partnerMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
public Map<String, Object> getIdentificationProject(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = null;
project.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM);
int records = projectMapper.selectProjectTotalCount(project);
project.setTotListSize(records);
String ossId = project.getOssId();
if (!StringUtil.isEmpty(ossId)) {
list = projectMapper.selectUnlimitedOssComponentBomList(project);
} else {
list = projectMapper.selectProjectList(project);
}
if (list != null) {
for (Project bean : list) {
// distribution type code ๋ณํ
if (!isEmpty(bean.getDistributionType())) {
bean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, bean.getDistributionType()));
}
}
}
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
@Transactional
public void registComponentsBat(String prjId, String identificationSubStatusBat, List<ProjectIdentification> ossComponents,
List<List<ProjectIdentification>> ossComponentsLicense, boolean prjYn) {
// ์ปดํฌ๋ํธ ๋ง์คํฐ ๋ผ์ด์ผ์ค ์ง์ฐ๊ธฐ
ProjectIdentification deleteparam = new ProjectIdentification();
deleteparam.setReferenceId(prjId);
deleteparam.setReferenceDiv(prjYn?CoConstDef.CD_DTL_COMPONENT_ID_BAT:CoConstDef.CD_DTL_COMPONENT_PARTNER_BAT); // 3rd ์ถ๊ฐ
List<OssComponents> componentsId = projectMapper.selectComponentId(deleteparam);
for (int j = 0; j < componentsId.size(); j++){
projectMapper.deleteOssComponentsLicense(componentsId.get(j));
}
// // ํ๊ฑด๋ ์์์ ํ๋ก์ ํธ ๋ง์คํฐ BAT ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N์ด๋ฉด N ๊ทธ์ธ null
if (ossComponents.size()==0 && prjYn){
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(prjId);
if (!StringUtil.isEmpty(identificationSubStatusBat)){
projectSubStatus.setIdentificationSubStatusBat(identificationSubStatusBat);
}else{
projectSubStatus.setIdentificationSubStatusBat("X");
}
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectSubStatus.setModifiedDate(projectSubStatus.getCreatedDate());
projectMapper.updateProjectMaster(projectSubStatus);
}
//deleteRows
List<String> deleteRows = new ArrayList<String>();
Project prjParam = new Project();
prjParam.setReferenceDiv(prjYn?"12":"20");
prjParam.setReferenceId(prjId);
int ossComponentIdx = projectMapper.selectOssComponentMaxIdx(prjParam);
// ์ปดํฌ๋ํธ ๋ฑ๋ก
for (int i = 0; i < ossComponents.size(); i++) {
ProjectIdentification ossBean = ossComponents.get(i);
// oss_id๋ฅผ ๋ค์ ์ฐพ๋๋ค. (oss name๊ณผ oss id๊ฐ ์ผ์นํ์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ ์ ์์)
ossBean = CommonFunction.findOssIdAndName(ossBean);
if (isEmpty(ossBean.getOssId())) {
ossBean.setOssId(null);
}
// BAT STATUS ๋ฑ๋ก
if (i==0 && prjYn){
Project projectStatus = new Project();
projectStatus.setPrjId(prjId);
projectStatus = projectMapper.selectProjectMaster(projectStatus);
// ์ต์ด ์ํ์ด๋ฉด PROG
if (StringUtil.isEmpty(projectStatus.getIdentificationStatus())) {
projectStatus.setIdentificationStatus("PROG");
}
// ํ๋ก์ ํธ ๋ง์คํฐ BAT ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N ์ด๋ฉด N ๊ทธ์ธ Y
if (!StringUtil.isEmpty(identificationSubStatusBat)) {
projectStatus.setIdentificationSubStatusBat(identificationSubStatusBat);
} else {
projectStatus.setIdentificationSubStatusBat(CoConstDef.FLAG_YES);
}
projectStatus.setModifier(projectStatus.getLoginUserName());
projectStatus.setModifiedDate(projectStatus.getCreatedDate());
projectMapper.updateProjectMaster(projectStatus);
}
//update
if (!StringUtil.contains(ossBean.getGridId(), CoConstDef.GRID_NEWROW_DEFAULT_PREFIX)){
//ossComponents ๋ฑ๋ก
projectMapper.updateSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if ("M".equals(ossBean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : ossComponentsLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (ossBean.getComponentId().equals(comLicense.getComponentId())){
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(comLicense.getComponentId());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(comLicense.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(comLicense.getLicenseName()));
} else {
license.setLicenseId(comLicense.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(comLicense.getLicenseName());
license.setLicenseText(comLicense.getLicenseText());
license.setCopyrightText(comLicense.getCopyrightText());
license.setExcludeYn(avoidNull(comLicense.getExcludeYn(), CoConstDef.FLAG_NO));
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else{ // ์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(ossBean.getComponentId());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(ossBean.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(ossBean.getLicenseName()));
} else {
license.setLicenseId(ossBean.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(ossBean.getLicenseName());
license.setLicenseText(ossBean.getLicenseText());
license.setCopyrightText(ossBean.getCopyrightText());
license.setExcludeYn(CoConstDef.FLAG_NO);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
} else { //insert
//ossComponents ๋ฑ๋ก
String exComponentId = ossBean.getGridId();
ossBean.setReferenceId(prjId);
ossBean.setReferenceDiv(prjYn?"12":"20"); // 3rd ์ถ๊ฐ
ossBean.setComponentIdx(Integer.toString(ossComponentIdx++));
projectMapper.insertSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if ("M".equals(ossBean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : ossComponentsLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (exComponentId.equals(comLicense.getComponentId())){
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(projectMapper.selectLastComponent());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(comLicense.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(comLicense.getLicenseName()));
} else {
license.setLicenseId(comLicense.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(comLicense.getLicenseName());
license.setLicenseText(comLicense.getLicenseText());
license.setCopyrightText(comLicense.getCopyrightText());
license.setExcludeYn(avoidNull(comLicense.getExcludeYn(), CoConstDef.FLAG_NO));
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(projectMapper.selectLastComponent());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(ossBean.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(ossBean.getLicenseName()));
} else {
license.setLicenseId(ossBean.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(ossBean.getLicenseName());
license.setLicenseText(ossBean.getLicenseText());
license.setCopyrightText(ossBean.getCopyrightText());
license.setExcludeYn(CoConstDef.FLAG_NO);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
//delete
OssComponents param = new OssComponents();
param.setReferenceDiv(prjYn ? CoConstDef.CD_DTL_COMPONENT_ID_BAT : CoConstDef.CD_DTL_COMPONENT_PARTNER);
param.setReferenceId(prjId);
param.setOssComponentsIdList(deleteRows);
projectMapper.deleteOssComponentsWithIds(param);
}
@Override
public Map<String, Object> getPartnerOssList(OssComponents ossComponents) {
HashMap<String, Object> map = new HashMap<String, Object>();
ossComponents.setReferenceDiv(avoidNull(ossComponents.getReferenceDiv(), CoConstDef.CD_DTL_COMPONENT_PARTNER));
List<OssComponents> list = projectMapper.getPartnerOssList(ossComponents);
for (OssComponents oc : list){
if (CoConstDef.FLAG_YES.equals(oc.getExcludeYn())){
ProjectIdentification PI = new ProjectIdentification();
PI.setComponentId(oc.getComponentId());
List<ProjectIdentification> subGridData = projectMapper.identificationSubGrid(PI);
if (!subGridData.isEmpty()) {
PI = subGridData.get(0);
oc.setLicenseName(PI.getLicenseName());
oc.setLicenseText(PI.getLicenseText());
oc.setCopyrightText(PI.getCopyrightText());
}
}
}
map.put("rows", list);
return map;
}
@Override
public List<ProjectIdentification> getBomListExcel(ProjectIdentification bom) {
bom.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
List<ProjectIdentification> list = projectMapper.selectBomList(bom);
bom.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(bom);;
if (notVersionList != null) {
list.addAll(notVersionList);
}
bom.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
list.sort(compare);
Map<String, List<OssComponentsLicense>> bomLicenseMap = new HashMap<>();
List<OssComponentsLicense> bomLicenseList = projectMapper.selectBomLicenseList(bom);
for (OssComponentsLicense ocl : bomLicenseList) {
String key = ocl.getComponentId();
List<OssComponentsLicense> bomLicenses = null;
if (bomLicenseMap.containsKey(key)) {
bomLicenses = bomLicenseMap.get(ocl.getComponentId());
} else {
bomLicenses = new ArrayList<>();
}
bomLicenses.add(ocl);
bomLicenseMap.put(key, bomLicenses);
}
List<ProjectIdentification> result = new ArrayList<>();
List<OssComponentsLicense> license = null;
String licenseId = "";
String licenseName = "";
String licenseText = "";
String copyrightText = "";
// ๋์ ์ปดํฌ๋ํธ ์ถ์ถ
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getComponentId() != null) {
// ์ปดํฌ๋ํธ ๋ผ์ด์ผ์ค ์กฐํ
list.get(i).setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
if (bomLicenseMap.containsKey(list.get(i).getComponentId())) {
license = bomLicenseMap.get(list.get(i).getComponentId());
for (int j = 0; j < license.size(); j++){
if (j == 0) {
licenseId = license.get(j).getLicenseId();
licenseName = license.get(j).getLicenseName();
licenseText = license.get(j).getLicenseText();
copyrightText = license.get(j).getCopyrightText();
} else {
licenseId = licenseId + ","+license.get(j).getLicenseId();
licenseName = licenseName + ","+license.get(j).getLicenseName();
licenseText = licenseText + ","+license.get(j).getLicenseText();
copyrightText = copyrightText + ","+license.get(j).getCopyrightText();
}
}
list.get(i).setLicenseId(licenseId);
list.get(i).setLicenseName(licenseName);
list.get(i).setLicenseText(licenseText);
list.get(i).setCopyrightText(copyrightText);
}
// license = projectMapper.selectBomLicense(list.get(i));
// for (int j = 0; j < license.size(); j++){
// if (j == 0) {
// licenseId = license.get(j).getLicenseId();
// licenseName = license.get(j).getLicenseName();
// licenseText = license.get(j).getLicenseText();
// copyrightText = license.get(j).getCopyrightText();
// } else {
// licenseId = licenseId + ","+license.get(j).getLicenseId();
// licenseName = licenseName + ","+license.get(j).getLicenseName();
// licenseText = licenseText + ","+license.get(j).getLicenseText();
// copyrightText = copyrightText + ","+license.get(j).getCopyrightText();
// }
// }
//
// list.get(i).setLicenseId(licenseId);
// list.get(i).setLicenseName(licenseName);
// list.get(i).setLicenseText(licenseText);
// list.get(i).setCopyrightText(copyrightText);
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (isEmpty(list.get(i).getCveId())
&& isEmpty(list.get(i).getOssVersion())
&& !isEmpty(list.get(i).getCvssScoreMax())
&& !("-".equals(list.get(i).getOssName()))) {
String[] cvssScoreMax = list.get(i).getCvssScoreMax().split("\\@");
list.get(i).setCvssScore(cvssScoreMax[0]);
list.get(i).setCveId(cvssScoreMax[1]);
}
result.add(list.get(i));
}
}
return result;
}
@Override
public Map<String, Object> getIdentificationProjectSearch(ProjectIdentification projectIdentification) {
HashMap<String, Object> map = new HashMap<String, Object>();
Project project = new Project();
project.setSrcAndroidNoticeFileId(projectIdentification.getAndroidNoticeFileId());
project.setSrcAndroidResultFileId(projectIdentification.getAndroidResultFileId());
List<ProjectIdentification> list = projectMapper.getIdentificationProjectSearch(projectIdentification);
project.setAndroidNoticeFile(projectMapper.selectAndroidNoticeFile(project));
project.setAndroidResultFile(projectMapper.selectAndroidResultFile(project));
map.put("rows", list);
map.put("project", project);
return map;
}
@Override
public Map<String, Object> getIdentificationThird(OssComponents ossComponents) {
HashMap<String, Object> map = new HashMap<String, Object>();
ossComponents.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
List<ProjectIdentification> list = projectMapper.getPartnerOssListValidation(ossComponents);
for (ProjectIdentification oc : list){
ProjectIdentification PI = new ProjectIdentification();
PI.setComponentId(oc.getComponentId());
List<ProjectIdentification> subGridData = projectMapper.identificationSubGrid(PI);
if (CoConstDef.FLAG_YES.equals(oc.getExcludeYn())) {
if (subGridData != null && !subGridData.isEmpty()) {
PI = subGridData.get(0);
oc.setLicenseName(PI.getLicenseName());
oc.setLicenseText(PI.getLicenseText());
oc.setCopyrightText(PI.getCopyrightText());
oc.addComponentLicenseList(PI);
}
} else {
if (subGridData != null && !subGridData.isEmpty()) {
for (ProjectIdentification subGrid : subGridData) {
if (subGrid.getComponentId().equals(oc.getComponentId())) {
oc.addComponentLicenseList(subGrid);
}
}
}
}
}
Map<String, Object> subMap = new HashMap<>();
for (ProjectIdentification oc : list){
if (oc.getComponentLicenseList() != null && !oc.getComponentLicenseList().isEmpty()) {
subMap.put(oc.getGridId(), oc.getComponentLicenseList());
}
}
T2CoProjectValidator pv = new T2CoProjectValidator();
if (list != null) {
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_PARTNER);
// main grid
pv.setAppendix("mainList", list);
pv.setAppendix("subListMap", subMap);
T2CoValidationResult vr = pv.validate(new HashMap<>());
// return validator result
// Identification, 3rd Party ์ OSS Table ์ ๋ ฌ ์์ ๋ณ๊ฒฝ - Restriction ์ถ๊ฐ
map.put("rows", CommonFunction.identificationSortByValidInfo(list, vr.getValidMessageMap(), vr.getDiffMessageMap(), vr.getInfoMessageMap(), false, true));
if (!vr.isValid()) {
map.put("validData", vr.getValidMessageMap());
}
if (!vr.isDiff()) {
map.put("diffData", vr.getDiffMessageMap());
}
if (vr.hasInfo()) {
map.put("infoData", vr.getInfoMessageMap());
}
}
return map;
}
@Override
@Cacheable(value="autocompleteProjectCache", key="{#root.methodName, #project?.creator}")
public List<Project> getProjectVersionList(Project project) {
return projectMapper.getProjectVersionList(project);
}
@Override
public Map<String, Object> applySrcAndroidModel(List<ProjectIdentification> reportData, List<String> noticeBinaryList) throws IOException {
Map<String, Object> resultMap = new HashMap<>();
Map<String, String> validMap = new HashMap<>();
if (noticeBinaryList != null) {
for (ProjectIdentification bean : reportData) {
String binaryNm = bean.getBinaryName();
String binaryNameWithoutPath = binaryNm;
if (binaryNm.indexOf("/") > -1) {
if (!binaryNm.endsWith("/")) {
binaryNameWithoutPath = binaryNm.substring(binaryNm.lastIndexOf("/") + 1);
}
}
bean.setBinaryNotice("nok");
if (noticeBinaryList.contains(binaryNameWithoutPath)) {
bean.setBinaryNotice("ok");
} else {
try {
ArrayList<String> apex_name_to_search = new ArrayList<String>();
Pattern pattern = Pattern.compile("apex/([^/]+)/");
Matcher matcher = pattern.matcher(binaryNm);
while (matcher.find()) {
String apex_name = matcher.group(1);
if (!apex_name.isEmpty()) {
apex_name_to_search.add(apex_name + ".apex");
apex_name_to_search.add(apex_name + ".capex");
apex_name_to_search.add(apex_name + "_compressed.apex");
apex_name_to_search.add(apex_name + "-uncompressed.apex");
}
break;
}
for (String apex_search : apex_name_to_search) {
if (noticeBinaryList.contains(apex_search)) {
bean.setBinaryNotice("ok");
break;
}
}
} catch (Exception e) {
log.debug(e.getMessage());
}
}
}
} else {
for (ProjectIdentification bean : reportData) {
bean.setBinaryNotice("nok");
}
}
resultMap.put("reportData", reportData);
if (!validMap.isEmpty()) {
resultMap.put("validData", validMap);
}
return resultMap;
}
@Override
public List<UploadFile> selectAndroidFileDetail(Project project) {
List<T2File> file = projectMapper.selectAndroidCsvFile(project);
UploadFile param = new UploadFile();
param.setFileName(file.get(0).getLogiNm());
List<UploadFile> result = new ArrayList<UploadFile>();
result.add(param);
return result;
}
@Override
public Map<String, Object> getOssIdCheck(ProjectIdentification projectIdentification) {
ProjectIdentification ossIdInfo = projectMapper.getOssId(projectIdentification);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("ossIdInfo", ossIdInfo);
return map;
}
@Override
public String checkChangedIdentification(String prjId, List<ProjectIdentification> partyData,
List<ProjectIdentification> srcData, List<List<ProjectIdentification>> srcSubData,
List<ProjectIdentification> binData, List<List<ProjectIdentification>> binSubData,
String applicableParty, String applicableSrc, String applicableBin) {
// ํ์ฌ DB์ ๋ฑ๋ก๋์ด ์๋ ์ ๋ณด์ CLIENT์์ ๋์ด์จ ์ ๋ณด๋ฅผ SORT ํ ํ ๋ฌธ์์ด๋ก ๋น๊ตํ๋ค.
// TRIM, ๋์๋ฌธ์๋ฅผ ๋ฌด์ํ๊ณ , ์ฃผ์ ์นผ๋ผ๋ง ๋น๊ตํ๋ค.
List<String> dbInfoList = projectMapper.checkChangedIdentification(prjId);
Project projectInfo = new Project();
projectInfo.setPrjId(prjId);
projectInfo = projectMapper.selectProjectMaster2(projectInfo);
List<String> dbPartnerList = new ArrayList<>();
List<String> dbSrcList = new ArrayList<>();
List<String> dbBinList = new ArrayList<>();
List<String> partnerList = null;
List<String> srcList = null;
List<String> binList = null;
// LICENSE NAME์ผ๋ก ๋น๊ต์ SHORT IDENTIFIER๋ก ์ค์ ๋ ๊ฒฝ์ฐ ์๋ฌ๋ก ํ๋จํ๋ ์ค๋ฅ ๋์์ ์ํด ๋๊ฐ์ง ํจํด์ผ๋ก ์ฒดํฌ
List<String> partnerList2 = null;
List<String> srcList2 = null;
List<String> binList2 = null;
boolean partnerUseFlag = CoConstDef.FLAG_NO.equals(applicableParty);
boolean srcUseFlag = CoConstDef.FLAG_NO.equals(applicableSrc);
boolean binUseFlag = CoConstDef.FLAG_NO.equals(applicableBin);
boolean dbPartnerUseFlag = CoConstDef.FLAG_NO.equals(projectInfo.getIdentificationSubStatusPartner());
boolean dbSrcUseFlag = CoConstDef.FLAG_NO.equals(projectInfo.getIdentificationSubStatusSrc());
boolean dbBinUseFlag = CoConstDef.FLAG_NO.equals(projectInfo.getIdentificationSubStatusBin());
if (partnerUseFlag != dbPartnerUseFlag) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_PARTNER)});
} else if (srcUseFlag != dbSrcUseFlag) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_SRC)});
} else if (binUseFlag != dbBinUseFlag) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_BIN)});
}
if (dbInfoList != null && !dbInfoList.isEmpty()) {
for (String key : dbInfoList) {
key = key.toUpperCase();
if (!dbPartnerUseFlag && key.startsWith(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER)) {
// 3rd์ ๊ฒฝ์ฐ ๋ผ์ด์ ์ค๋ฅผ ๋ฌด์ํ๊ณ key๋ฅผ ์์ฑํ๊ธฐ ๋๋ฌธ์ ์ค๋ณต๋๋ ๊ฒฝ์ฐ๊ฐ ์์
if (!dbPartnerList.contains(key)) {
dbPartnerList.add(key);
}
} else if (!dbSrcUseFlag && key.startsWith(CoConstDef.CD_DTL_COMPONENT_ID_SRC)) {
dbSrcList.add(key);
} else if (!dbBinUseFlag && key.startsWith(CoConstDef.CD_DTL_COMPONENT_ID_BIN)) {
dbBinList.add(key);
}
}
}
// ํ๋ฉด์ ๋ณด ๋น๊ต key๋ก convert
// 3rd party์ ๊ฒฝ์ฐ๋ ํธ์ง์ด ๋ถ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ ๋ผ์ด์ ์ค ์ ๋ณด๋ฅผ ์ ์ธํ๊ณ ๋น๊ตํ๋ค.
if (!partnerUseFlag && partyData != null) {
partnerList = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER, partyData, null);
partnerList2 = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER, partyData, null, true);
}
if (!srcUseFlag && srcData != null && srcSubData != null) {
srcList = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_SRC, srcData, srcSubData);
srcList2 = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_SRC, srcData, srcSubData, true);
}
if (!binUseFlag && binData != null && binSubData != null) {
binList = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_BIN, binData, binSubData);
binList2 = makeCompareKey(CoConstDef.CD_DTL_COMPONENT_ID_BIN, binData, binSubData, true);
}
if (partnerList == null) {
partnerList = new ArrayList<>();
partnerList2 = new ArrayList<>();
}
if (srcList == null) {
srcList = new ArrayList<>();
srcList2 = new ArrayList<>();
}
if (binList == null) {
binList = new ArrayList<>();
binList2 = new ArrayList<>();
}
// 1) ๊ฑด์ ๋น๊ต
// 2) ๊ฑด์๊ฐ ๋์ผํ๊ธฐ ๋๋ฌธ์ sortํ text ๋น๊ต
if (partnerList.size() != dbPartnerList.size() || !compareList(partnerList, partnerList2, dbPartnerList)) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_PARTNER)});
} else if (srcList.size() != dbSrcList.size() || !compareList(srcList, srcList2, dbSrcList)) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_SRC)});
} else if (binList.size() != dbBinList.size() || !compareList(binList, binList2, dbBinList)) {
return getMessage("msg.project.checke.changed", new String[]{CoCodeManager.getCodeString(CoConstDef.CD_COMPONENT_DIVISION, CoConstDef.CD_DTL_COMPONENT_ID_BIN)});
}
return null;
}
private boolean compareList(List<String> list, List<String> list2, List<String> dbList) {
if (list.size() != dbList.size()) {
return false;
}
Collections.sort(list);
Collections.sort(list2);
Collections.sort(dbList);
for (int i=0; i<list.size(); i++) {
if (!list.get(i).equalsIgnoreCase(dbList.get(i)) && !list2.get(i).equalsIgnoreCase(dbList.get(i))) {
return false;
}
}
return true;
}
private List<String> makeCompareKey(String type, List<ProjectIdentification> data, List<List<ProjectIdentification>> subData) {
return makeCompareKey(type, data, subData, false);
}
private List<String> makeCompareKey(String type, List<ProjectIdentification> data, List<List<ProjectIdentification>> subData, boolean convertShortLicenseName) {
List<String> list = new ArrayList<>();
if (data != null) {
for (ProjectIdentification bean : data) {
if (CoConstDef.CD_DTL_COMPONENT_ID_PARTNER.equals(type)) {
String key = type;
key += "|" + avoidNull(bean.getOssName()).trim();
key += "|" + avoidNull(bean.getOssVersion()).trim();
key += "|" + avoidNull(bean.getRefPartnerId()).trim();
key += "|" + avoidNull(bean.getExcludeYn(), CoConstDef.FLAG_NO);
key = key.toUpperCase();
if (!list.contains(key)) {
list.add(key);
}
} else if (subData != null) {
if (CoConstDef.LICENSE_DIV_SINGLE.equals(avoidNull(bean.getLicenseDiv(), CoConstDef.LICENSE_DIV_SINGLE))) {
String key = type;
key += "|" + avoidNull(bean.getOssName()).trim();
key += "|" + avoidNull(bean.getOssVersion()).trim();
key += "|" + avoidNull(convertLicenseShortName(bean.getLicenseName(), convertShortLicenseName)).trim();
key += "|" + avoidNull(bean.getExcludeYn(), CoConstDef.FLAG_NO);
key += "|" + CoConstDef.FLAG_NO;
key = key.toUpperCase();
list.add(key);
} else {
if (bean.getComponentLicenseList() != null) {
for (ProjectIdentification license : bean.getComponentLicenseList()) {
String key = type;
key += "|" + avoidNull(bean.getOssName()).trim();
key += "|" + avoidNull(bean.getOssVersion()).trim();
key += "|" + avoidNull(convertLicenseShortName(license.getLicenseName(), convertShortLicenseName)).trim();
key += "|" + avoidNull(bean.getExcludeYn(), CoConstDef.FLAG_NO);
key += "|" + avoidNull(license.getExcludeYn(), CoConstDef.FLAG_NO);
key = key.toUpperCase();
list.add(key);
}
} else {
String key = type;
key += "|" + avoidNull(bean.getOssName()).trim();
key += "|" + avoidNull(bean.getOssVersion()).trim();
key += "|" + avoidNull("").trim();
key += "|" + avoidNull(bean.getExcludeYn(), CoConstDef.FLAG_NO);
key += "|" + CoConstDef.FLAG_NO;
key = key.toUpperCase();
list.add(key);
}
}
}
}
}
return list;
}
/**
* ๋ผ์ด์ ์ค ๋ช
์นญ์ ๊ธฐ์ค์ผ๋ก short identifier์ธ ๊ฒฝ์ฐ ์ ์๋ช
์นญ์, ์ ์๋ช
์นญ(๋๋ ๋๋ค์)์ด๋ฉด์, short identifier๊ฐ ์ค์ ๋์ด ์๋ ๊ฒฝ์ฐ๋ short identifier๋ฅผ ๋ฐํํ๋ค.
* ๊ทธ์ธ ๊ฒฝ์ฐ๋ ๊ทธ๋๋ก ๋ฐํ
* @param licenseName
* @param convertShortLicenseName
* @return
*/
private String convertLicenseShortName(String licenseName, boolean convertShortLicenseName) {
if (convertShortLicenseName && !isEmpty(licenseName)) {
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(licenseName.toUpperCase())) {
LicenseMaster master = CoCodeManager.LICENSE_INFO_UPPER.get(licenseName.toUpperCase());
if (master != null) {
// ํ์ฌ ๋ผ์ด์ ์ค ๋ช
์ด short identifier ์ด๋ฉด ์ ์ ๋ช
์นญ์ ๋ฐํ
if (licenseName.equals(master.getShortIdentifier())) {
licenseName = master.getLicenseNameTemp();
} else if (!isEmpty(master.getShortIdentifier())) {
// ํ์ฌ ๋ผ์ด์ ์ค ๋ช
์ด ์ ์ ๋ช
์นญ (๋๋ ๋๋ค์) ์ธ ๊ฒฝ์ฐ short identifier๋ฅผ ๋ฐํ
licenseName = master.getShortIdentifier();
}
}
}
}
return avoidNull(licenseName).trim();
}
// private List<ProjectIdentification> findLicense(String gridId, List<List<ProjectIdentification>> componentLicenseList) {
// List<ProjectIdentification> licenseList = new ArrayList<>();
// if (componentLicenseList != null && !componentLicenseList.isEmpty()) {
// boolean breakFlag = false;
// for (List<ProjectIdentification> list : componentLicenseList) {
// for (ProjectIdentification bean : list) {
// String key = gridId;
// if (bean.getGridId().startsWith(key)) {
// licenseList.add(bean);
// breakFlag = true;
// }
// }
// if (breakFlag) {
// break;
// }
// }
// }
// return licenseList;
// }
@Override
public Map<String, Map<String, String>> getProjectDownloadExpandInfo(Project param) {
Map<String, Map<String, String>> resultMap = new HashMap<>();
if (param.getPrjIdList() != null && !param.getPrjIdList().isEmpty()) {
List<Map<String, String>> list = projectMapper.getProjectDownloadExpandInfo(param);
if (list != null) {
for (Map<String, String> map : list) {
resultMap.put(String.valueOf(map.get("PRJ_ID")), map);
}
}
}
return resultMap;
}
@Override
public void cancelFileDel(Project project) {
if (project.getCsvFile() != null) {
for (int i = 0; i < project.getCsvFile().size(); i++) {
projectMapper.deleteFileBySeq(project.getCsvFile().get(i));
}
}
}
@Override
public List<OssComponents> selectOssComponentsListByComponentIds(OssComponents param) {
return projectMapper.selectOssComponentsListByComponentIds(param);
}
@Override
public Map<String, Object> getFileInfo(ProjectIdentification identification) {
HashMap<String, Object> map = new HashMap<String, Object>();
Project project = new Project();
project.setSrcAndroidCsvFileId(identification.getAndroidCsvFileId());
project.setSrcAndroidNoticeFileId(identification.getAndroidNoticeFileId());
project.setSrcAndroidResultFileId(identification.getAndroidResultFileId());
project.setAndroidCsvFile(projectMapper.selectAndroidCsvFile(project));
project.setAndroidNoticeFile(projectMapper.selectAndroidNoticeFile(project));
project.setAndroidResultFile(projectMapper.selectAndroidResultFile(project));
map.put("project", project);
return map;
}
@Override
public Map<String, Object> get3rdMapList(Project project) {
List<PartnerMaster> list = new ArrayList<PartnerMaster>();
list = partnerMapper.select3rdMapList(project);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("rows", list);
return map;
}
private Map<String, Object> getThirdPartyMap(String prjId) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<PartnerMaster> list = partnerMapper.selectThirdPartyMapList(prjId);
map.put("rows", list);
return map;
}
@Override
public List<Project> getWatcherList(Project project) {
List<Project> watcherList = projectMapper.selectWatchersList(project);
return watcherList;
}
/**
* oss Nickname convert
* @param ossComponentList
* @return
*/
@Override
public List<ProjectIdentification> convertOssNickName(List<ProjectIdentification> ossComponentList) {
List<String> ossCheckParam = new ArrayList<>();
List<OssMaster> ossNickNameList = null;
Map<String, OssMaster> ossNickNameConvertMap = new HashMap<>();
for (ProjectIdentification bean : ossComponentList) {
String _ossName = avoidNull(bean.getOssName()).trim();
int isAdminCheck = projectMapper.selectAdminCheckCnt(bean);
if (!isEmpty(_ossName) && !"-".equals(_ossName) && !ossCheckParam.contains(_ossName) && isAdminCheck < 1) {
ossCheckParam.add(_ossName);
}
}
if (!ossCheckParam.isEmpty()) {
OssMaster param = new OssMaster();
param.setOssNames(ossCheckParam.toArray(new String[ossCheckParam.size()]));
ossNickNameList = projectMapper.checkOssNickName(param);
if (ossNickNameList != null) {
for (OssMaster bean : ossNickNameList) {
ossNickNameConvertMap.put(bean.getOssNickname().toUpperCase(), bean);
}
}
}
for (ProjectIdentification bean : ossComponentList) {
if (ossNickNameConvertMap.containsKey(avoidNull(bean.getOssName()).trim().toUpperCase())) {
bean.setOssName(ossNickNameConvertMap.get(avoidNull(bean.getOssName()).trim().toUpperCase()).getOssName());
}
// license nickname ์ฒดํฌ
if (CoConstDef.LICENSE_DIV_SINGLE.equals(bean.getLicenseDiv())) {
String _licenseName = avoidNull(bean.getLicenseName()).trim();
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (_licenseName.equalsIgnoreCase(s)) {
bean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
return ossComponentList;
}
@Override
public List<List<ProjectIdentification>> convertLicenseNickName(
List<List<ProjectIdentification>> ossComponentLicenseList) {
if (ossComponentLicenseList != null) {
for (List<ProjectIdentification> licenseList : ossComponentLicenseList) {
for (ProjectIdentification licenseBean : licenseList) {
String _licenseName = avoidNull(licenseBean.getLicenseName()).trim();
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (_licenseName.equalsIgnoreCase(s)) {
licenseBean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
}
return ossComponentLicenseList;
}
@Override
public String addWatcher(Project project) {
String addWatcher = "";
if (!isEmpty(project.getPrjEmail())) {
if (projectMapper.existsWatcherByEmail(project) == 0) { // ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
projectMapper.insertWatcher(project); // watcher ์ถ๊ฐ
// email ๋ฐ์ก
try {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_INVATED);
mailBean.setParamPrjId(project.getPrjId());
mailBean.setParamUserId(project.getLoginUserName());
mailBean.setParamEmail(project.getPrjEmail());
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
} else {
if (projectMapper.existsWatcherByUser(project) == 0) { // ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
if (projectMapper.existsWatcherByUserDivistion(project) > 0) { // ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ user division ์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ
projectMapper.updateWatcherDivision(project);
} else {
projectMapper.insertWatcher(project); // watcher ์ถ๊ฐ
}
}
}
if (!isEmpty(project.getPrjUserId())) {
T2Users userInfo = new T2Users();
userInfo.setUserId(project.getPrjUserId());
userInfo = userMapper.getUser(userInfo);
addWatcher = project.getPrjDivision() + "/" + userInfo.getUserId();
} else {
addWatcher = project.getPrjEmail();
}
return addWatcher;
}
@Override
public void removeWatcher(Project project) {
projectMapper.removeWatcher(project);
}
@Override
public List<Project> copyWatcher(Project project) {
return projectMapper.copyWatcher(project);
}
@Override
public boolean existsWatcher(Project project) {
boolean result = false;
int i = projectMapper.existsWatcher(project);
if (i > 0){
result = true;
}
return result;
}
/**
* ๋ถ์๊ฒฐ๊ณผ์ ๋ค์ด๋ก๋ 3rd party ๋ช
์นญ ๋ฐํ
*/
@Override
public String getPartnerFormatName(String partnerId, boolean onlyName) {
if (!isEmpty(partnerId)) {
PartnerMaster param = new PartnerMaster();
param.setPartnerId(partnerId);
param = partnerMapper.selectPartnerMaster(param);
if (param != null) {
if (onlyName) {
return avoidNull(param.getPartnerName());
} else {
return "(" + partnerId + ") " + avoidNull(param.getPartnerName());
}
}
}
return "";
}
// project model update
@Override
public void insertProjectModel(Project project) {
projectMapper.updateDistributeTarget(project);
projectMapper.deleteProjectModel(project);
if (project.getModelList().size() > 0) {
for (Project bean : project.getModelList()) {
bean.setPrjId(project.getPrjId());
bean.setModelName(bean.getModelName().trim().toUpperCase().replaceAll("\t", ""));
projectMapper.insertProjectModel(bean);
}
}
}
@Override
public void updatePublicYn(Project project) {
projectMapper.updatePublicYn(project);
}
@Override
public Map<String, Object> getProjectToAddList(OssComponents ossComponents) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<PartnerMaster> list = partnerMapper.getProjectToAddList(ossComponents);
map.put("rows", list);
return map;
}
@Override
public Map<String, Object> getAddList(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = projectMapper.selectAddList(project);
map.put("rows", list);
return map;
}
@Override
public boolean existsAddList(Project project) {
boolean result = false;
int i = projectMapper.existsAddList(project);
if (i > 0){
projectMapper.deleteAddList(project);
result = true;
}
return result;
}
@Override
public void insertAddList(List<Project> project) {
for (Project p : project){
projectMapper.insertAddList(p);
}
}
@Override
public Map<String, Object> identificationSubGrid(ProjectIdentification identification) {
HashMap<String, Object> map = new HashMap<String, Object>();
try {
List<ProjectIdentification> list = projectMapper.identificationSubGrid(identification);
map.put("rows", list);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return map;
}
@Override
public List<ProjectIdentification> setMergeGridData(List<ProjectIdentification> gridData) {
List<ProjectIdentification> tempData = new ArrayList<ProjectIdentification>();
List<ProjectIdentification> resultGridData = new ArrayList<ProjectIdentification>();
String groupColumn = "";
boolean ossNameEmptyFlag = false;
for (ProjectIdentification info : gridData) {
if (isEmpty(groupColumn)) {
groupColumn = info.getOssName() + "-" + info.getOssVersion();
}
if ("-".equals(groupColumn)) {
if ("NA".equals(info.getLicenseType())) {
ossNameEmptyFlag = true;
}
}
if (groupColumn.equals(info.getOssName() + "-" + info.getOssVersion()) // ๊ฐ์ groupColumn์ด๋ฉด ๋ฐ์ดํฐ๋ฅผ ์์
&& !("-".equals(info.getOssName())
&& !"NA".equals(info.getLicenseType()))
&& !ossNameEmptyFlag) { // ๋จ, OSS Name: - ์ด๋ฉด์, License Type: Proprietary์ด ์๋ ๊ฒฝ์ฐ Row๋ฅผ ํฉ์น์ง ์์.
tempData.add(info);
} else { // ๋ค๋ฅธ grouping
setMergeData(tempData, resultGridData);
groupColumn = info.getOssName() + "-" + info.getOssVersion();
tempData.clear();
tempData.add(info);
}
ossNameEmptyFlag = false; // ์ด๊ธฐํ
}
setMergeData(tempData, resultGridData); // bom data์ loop๊ฐ ๋๋ฌ์ง๋ง tempData์ ๊ฐ์ด ์๋ค๋ฉด ํด๋น ๊ฐ๋ merge๋ฅผ ํจ.
return resultGridData;
}
public static void setMergeData(List<ProjectIdentification> tempData, List<ProjectIdentification> resultGridData){
if (tempData.size() > 0) {
Collections.sort(tempData, new Comparator<ProjectIdentification>() {
@Override
public int compare(ProjectIdentification o1, ProjectIdentification o2) {
if (o1.getLicenseName().length() >= o2.getLicenseName().length()) { // license name์ด ๊ฐ์ผ๋ฉด bomList์กฐํํด์จ ์์ ๊ทธ๋๋ก ์ ์งํจ. license name์ด ๋ค๋ฅด๋ฉด ์์๋ณ๊ฒฝ
return 1;
}else {
return -1;
}
}
});
ProjectIdentification rtnBean = null;
for (ProjectIdentification temp : tempData) {
if (rtnBean == null) {
rtnBean = temp;
if (!isEmpty(rtnBean.getCopyrightText())) {
List<String> rtnBeanCopyrights = Arrays.asList(rtnBean.getCopyrightText().split("\\n"));
String mergedCopyrightText = rtnBeanCopyrights.stream().distinct().collect(Collectors.joining("\n"));
rtnBean.setCopyrightText(mergedCopyrightText);
}
continue;
}
String key = temp.getOssName() + "-" + temp.getLicenseType();
if ("--NA".equals(key)) {
if (!rtnBean.getLicenseName().contains(temp.getLicenseName())) {
resultGridData.add(rtnBean);
rtnBean = temp;
continue;
}
}
// ๋์ผํ oss name๊ณผ version์ผ ๊ฒฝ์ฐ license ์ ๋ณด๋ฅผ ์ค๋ณต์ ๊ฑฐํ์ฌ merge ํจ.
for (String licenseName : temp.getLicenseName().split(",")) {
boolean equalFlag = false;
for (String rtnLicenseName : rtnBean.getLicenseName().split(",")) {
if (rtnLicenseName.equals(licenseName)) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
rtnBean.setLicenseName(rtnBean.getLicenseName() + "," + licenseName);
}
}
if (!isEmpty(temp.getCopyrightText())) {
List<String> mergedCopyrights = new ArrayList<>();
if (!isEmpty(rtnBean.getCopyrightText())) {
mergedCopyrights.addAll(Arrays.asList(rtnBean.getCopyrightText().split("\\n")));
}
if (!isEmpty(rtnBean.getCopyrightText())) {
mergedCopyrights.addAll(Arrays.asList(temp.getCopyrightText().split("\\n")));
}
if (mergedCopyrights != null && !mergedCopyrights.isEmpty()) {
String mergedCopyrightText = mergedCopyrights.stream().distinct().collect(Collectors.joining("\n"));
rtnBean.setCopyrightText(mergedCopyrightText);
}
}
List<OssComponentsLicense> rtnComponentLicenseList = new ArrayList<OssComponentsLicense>();
for (OssComponentsLicense list : temp.getOssComponentsLicenseList()) {
int equalsItemList = (int) rtnBean.getOssComponentsLicenseList()
.stream()
.filter(e -> list.getLicenseName().equals(e.getLicenseName())) // ๋์ผํ licenseName์ filter
.collect(Collectors.toList()) // return์ list๋ก๋ณํ
.size(); // ํด๋น list์ size
if (equalsItemList == 0) {
rtnComponentLicenseList.add(list);
}
}
rtnBean.getOssComponentsLicenseList().addAll(rtnComponentLicenseList);
if (!rtnBean.getRefComponentId().contains(temp.getRefComponentId())) {
rtnBean.setRefComponentId(rtnBean.getRefComponentId() + "," + temp.getRefComponentId());
}
if (!rtnBean.getRefDiv().contains(temp.getRefDiv())) {
rtnBean.setRefDiv(rtnBean.getRefDiv() + "," + temp.getRefDiv());
}
if (!isEmpty(temp.getRestriction())) {
for (String restriction : temp.getRestriction().split("\\n")) {
if (!isEmpty(restriction) && !rtnBean.getRestriction().contains(restriction)) {
if (!isEmpty(rtnBean.getRestriction())) {
rtnBean.setRestriction(rtnBean.getRestriction() + "\\n" + restriction);
} else {
rtnBean.setRestriction(restriction);
}
}
}
}
// ํน์ tab์ ํด๋น Data๊ฐ ๊ณต๋์ด๊ณ , ๋ค๋ฅธ tab์ ํด๋น Data๊ฐ ๊ฐ์ด ์์ฑ๋์ด ์์ ๊ฒฝ์ฐ ์ฒซ๋ฒ์งธ ๋ฐ๊ฒฌ๋๋ data๋ฅผ ๋ฃ์ด์ค. (๋์ downloadLocation, homepage, copyrightText)
if (isEmpty(rtnBean.getDownloadLocation())) {
if (!isEmpty(temp.getDownloadLocation())) {
rtnBean.setDownloadLocation(temp.getDownloadLocation());
}
}
if (isEmpty(rtnBean.getHomepage())) {
if (!isEmpty(temp.getHomepage())) {
rtnBean.setHomepage(temp.getHomepage());
}
}
if (isEmpty(rtnBean.getCopyrightText())) {
if (!isEmpty(temp.getCopyrightText())) {
rtnBean.setCopyrightText(temp.getCopyrightText());
}
}
if (CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(temp.getObligationType())){
rtnBean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
rtnBean.setObligationLicense(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
rtnBean.setPreObligationType(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
} else if (CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(temp.getObligationType())
&& ("").equals(avoidNull(rtnBean.getObligationType(), ""))){
rtnBean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
rtnBean.setObligationLicense(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
rtnBean.setPreObligationType(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
}
if (isEmpty(rtnBean.getDependencies())) {
if (!isEmpty(temp.getDependencies())) {
rtnBean.setDependencies(temp.getDependencies());
}
}
}
resultGridData.add(rtnBean);
}
}
@Override
public List<ProjectIdentification> setMergeGridDataByAndroid(List<ProjectIdentification> gridData) {
List<ProjectIdentification> resultGridData = null;
Map<String, ProjectIdentification> resultGridDataMap = new HashMap<>();
String groupKey = "";
for (ProjectIdentification grid : gridData) {
groupKey = (grid.getOssName() + "_" + avoidNull(grid.getOssVersion())).toUpperCase();
if (!resultGridDataMap.containsKey(groupKey)) {
resultGridDataMap.put(groupKey, grid);
} else {
ProjectIdentification bean = resultGridDataMap.get(groupKey);
for (String licenseName : grid.getLicenseName().split(",")) {
boolean equalFlag = false;
for (String rtnLicenseName : bean.getLicenseName().split(",")) {
if (rtnLicenseName.trim().equals(licenseName.trim())) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
bean.setLicenseName((bean.getLicenseName() + "," + licenseName).trim());
}
}
resultGridDataMap.put(groupKey, bean);
}
}
if (!resultGridDataMap.isEmpty()) {
resultGridData = new ArrayList<>(resultGridDataMap.values());
}
return resultGridData;
}
@SuppressWarnings("unchecked")
@Override
public String checkValidData(Map<String, Object> map) {
List<ProjectIdentification> mainData = (List<ProjectIdentification>) map.get("mainData");
Map<String, Object> validData = (Map<String, Object>) map.get("validData");
Map<String, Object> diffData = (Map<String, Object>) map.get("diffData");
String validMsg = null;
int emptyBinaryPathCnt = 0;
int errCnt = 0;
int diffCnt = 0;
if (mainData != null) {
emptyBinaryPathCnt = mainData.stream()
.filter(c -> isEmpty(c.getBinaryName()))
.collect(Collectors.toList())
.size();
}
if (validData != null) {
errCnt = validData.keySet().stream()
.filter(c -> c.toUpperCase().contains("OSS_NAME")
|| c.toUpperCase().contains("OSS_VERSION")
|| c.toUpperCase().contains("LICENSE_NAME"))
.collect(Collectors.toList())
.size();
}
if (diffData != null) {
Map<String, Object> diffDataMap = new HashMap<String, Object>();
for (String key : diffData.keySet()) {
if (key.toUpperCase().contains("LICENSENAME")) {
String diffMsg = (String) diffData.get(key);
if (!diffMsg.contains("Declared")) {
diffDataMap.put(key, diffData.get(key));
}
} else {
diffDataMap.put(key, diffData.get(key));
}
}
if (!diffDataMap.isEmpty()) {
diffCnt = diffDataMap.keySet()
.stream()
.filter(c -> c.toUpperCase().contains("OSSNAME")
|| c.toUpperCase().contains("OSSVERSION")
|| c.toUpperCase().contains("LICENSENAME"))
.collect(Collectors.toList())
.size();
}
}
// OSS Name, OSS Version, License์ Warning message(๋นจ๊ฐ์, ํ๋์)๊ฐ ์๋ Row ๋๋ Binary Name์ด ๊ณต๋์ธ Row
if (emptyBinaryPathCnt > 0 || errCnt > 0 ) {
validMsg = "You can download NOTICE only if there is no warning message in OSS Name, OSS Version, License or Binary Name is not null.";
}
// ์ถ๋ ฅํ Binary๊ฐ ์๋ ๊ฒฝ์ฐ(= ์ถ๋ ฅ ์กฐ๊ฑด์ ํด๋นํ๋ Row๊ฐ ์๋ ๊ฒฝ์ฐ)
if (mainData.size() == 0 || diffData.size() == 0) {
validMsg = "There is no binary that meets the conditions for creating NOTICE.";
}
return validMsg;
}
@Override
public String makeNoticeFileContents(Map<String, Object> paramMap) {
Map<String, List<ProjectIdentification>> resultData = getMergedBinaryData(paramMap);
Map<String, Object> model = new HashMap<String, Object>();
model.put("templateURL", CoCodeManager.getCodeExpString(CoConstDef.CD_NOTICE_DEFAULT, CoConstDef.CD_DTL_SUPPLMENT_NOTICE_HTML_TEMPLATE));
model.put("noticeData", resultData);
return CommonFunction.VelocityTemplateToString(model);
}
@Override
public String makeZipFileId(Map<String, Object> paramMap, Project project) {
String fileId = "";
String filePath = CommonFunction.emptyCheckProperty("common.public_supplement_notice_path", "/supplement_notice") + "/" + project.getPrjId();
File dir = new File(filePath);
if (dir.exists()) { // ์ ์ฒด ์ญ์ ์์ฉก( html file์ ์ ์ธํจ)
for (File item : dir.listFiles()) {
if (!item.isDirectory() && item.getName().contains(".html")){
item.delete();
} else if (item.isDirectory()) {
CommonFunction.removeAll(item); // ํ์ํด๋, file ์ ์ฒด ์ญ์
}
}
}
String LicensesfilePath = filePath + "/needtoadd-notice/LICENSES";
dir = new File(LicensesfilePath);
dir.mkdirs();
Map<String, List<ProjectIdentification>> mergedBinaryData = getMergedBinaryData(paramMap);
List<String> ObligationNoticeLicenseList = new ArrayList<String>();
for (List<ProjectIdentification> bean : mergedBinaryData.values()) { // Licenses proc
for (ProjectIdentification p : bean) {
for (String licenseName : p.getLicenseName().split(",")) {
if (!ObligationNoticeLicenseList.contains(licenseName)) {
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_UPPER.get(licenseName.toUpperCase());
if (CoConstDef.FLAG_YES.equals(licenseBean.getObligationNotificationYn())) {
String LICENSEFileName = avoidNull(licenseBean.getShortIdentifier(), "");
if (isEmpty(LICENSEFileName)) {
LICENSEFileName = "LicenseRef-"+licenseBean.getLicenseName().replaceAll("\\(", "-").replaceAll("\\)", "").replaceAll(" ", "-").replaceAll("--", "-");
}
FileUtil.writeFile(LicensesfilePath, LICENSEFileName+".txt", licenseBean.getLicenseText());
ObligationNoticeLicenseList.add(licenseName);
}
}
}
}
}
String binaryDirPath = filePath + "/needtoadd-notice";
for (String binaryPath : mergedBinaryData.keySet()) { // Binary proc
Map<String, Object> model = new HashMap<String, Object>();
model.put("templateURL", CoCodeManager.getCodeExpString(CoConstDef.CD_NOTICE_DEFAULT, CoConstDef.CD_DTL_SUPPLMENT_NOTICE_TXT_TEMPLATE));
model.put("noticeData", mergedBinaryData.get(binaryPath));
String contents = CommonFunction.VelocityTemplateToString(model);
for (String path : binaryPath.split(",")) {
String fileName = "";
String binaryFilePath = binaryDirPath;
if (path.contains("/")) {
File f = new File(binaryFilePath + "/" + path);
fileName = f.getName();
File parentFile = f.getParentFile();
if (parentFile != null) {
binaryFilePath = parentFile.toString();
f = new File(binaryFilePath);
f.mkdirs(); // path์ ์ฒด์ directory ์์ฑ
} else {
fileName = path;
}
} else {
fileName = path;
}
FileUtil.writeFile(binaryFilePath, fileName, contents);
}
}
try {
String zipFileName = "needtoadd-notice_"+CommonFunction.getCurrentDateTime("yyMMdd")+".zip";
FileUtil.zip(binaryDirPath, filePath, zipFileName, null);
fileId = fileService.registFileDownload(filePath, zipFileName, zipFileName);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return fileId;
}
@Override
public String makeSupplementFileId(String contents, Project project) {
String fileName = CommonFunction.getNoticeFileName(project.getPrjId(), project.getPrjName(), project.getPrjVersion(), "needtoadd-notice", DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN), "html");
String filePath = CommonFunction.emptyCheckProperty("common.public_supplement_notice_path", "/supplement_notice") + "/" + project.getPrjId();
String fileId = "";
File fileDir = new File(filePath);
if (fileDir.exists()) {
for (File f : fileDir.listFiles()) {
if (f.getName().contains(".html")) {
if (f.delete()) {
log.debug(filePath + "/" + f.getName() + " is delete success.");
} else {
log.debug(filePath + "/" + f.getName() + " is delete failed.");
}
}
}
}
if (FileUtil.writeFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
fileId = fileService.registFileDownload(filePath, fileName, fileName);
}
return fileId;
}
@SuppressWarnings("unchecked")
public Map<String, List<ProjectIdentification>> getMergedBinaryData(Map<String, Object> paramMap){
List<ProjectIdentification> mainData = (List<ProjectIdentification>) paramMap.get("mainData");
Map<String, Object> diffData = (Map<String, Object>) paramMap.get("diffData");
String ruleMsg = (String) T2CoValidationConfig.getInstance().getRuleAllMap().get("BINARY_NOTICE.NOTICE_PERMISSIVE.MSG");
List<String> gridIdList = diffData.entrySet()
.stream()
.filter(c -> ((String) c.getValue()).equals(ruleMsg))
.map(c -> ((String) c.getKey()).split("\\.")[1])
.collect(Collectors.toList());
mainData = mainData.stream()
.filter(c -> gridIdList.contains(c.getGridId()))
.sorted(Comparator.comparing((ProjectIdentification p) -> p.getBinaryName()))
.collect(Collectors.toList());
Map<String, List<ProjectIdentification>> binaryMergeData = new HashMap<String, List<ProjectIdentification>>();
Map<String, String> binaryOssKeyMap = new HashMap<String, String>();
for (ProjectIdentification bean : mainData) {
List<ProjectIdentification> _list = new ArrayList<>();
String _oldKey = null;
String key = bean.getOssName() + "|" + bean.getOssVersion() + "|" + bean.getLicenseName();
String licenseName = "";
if (binaryMergeData.containsKey(bean.getBinaryName())) { // binaryPath ๊ธฐ์ค์ผ๋ก merge
_list = binaryMergeData.get(bean.getBinaryName());
_oldKey = binaryOssKeyMap.get(bean.getBinaryName());
if (_list != null) {
for (ProjectIdentification license : bean.getComponentLicenseList()) {
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_UPPER.get(license.getLicenseName().toUpperCase());
license.setLicenseText(avoidNull(licenseBean.getLicenseText()));
license.setAttribution(avoidNull(licenseBean.getAttribution()));
license.setObligationType(CoConstDef.FLAG_YES.equals(licenseBean.getObligationNotificationYn()) ? CoConstDef.CD_DTL_OBLIGATION_NOTICE : "");
if (CoConstDef.FLAG_YES.equals(licenseBean.getObligationNotificationYn())) {
if (!isEmpty(licenseName)) {
licenseName += ",";
}
licenseName += license.getLicenseName();
}
}
OssMaster ossBean = CoCodeManager.OSS_INFO_UPPER.get((bean.getOssName() +"_"+ avoidNull(bean.getOssVersion())).toUpperCase());
bean.setAttribution(avoidNull(ossBean.getAttribution()));
bean.setLicenseName(licenseName);
_list.add(bean);
binaryMergeData.replace(bean.getBinaryName(), _list);
String str = CommonFunction.mergedString(_oldKey, key, _oldKey.compareTo(key), ",");
binaryOssKeyMap.put(bean.getBinaryName(), str);
}
} else {
for (ProjectIdentification license : bean.getComponentLicenseList()) {
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_UPPER.get(license.getLicenseName().toUpperCase());
license.setLicenseText(avoidNull(licenseBean.getLicenseText()));
license.setAttribution(avoidNull(licenseBean.getAttribution()));
license.setObligationType(CoConstDef.FLAG_YES.equals(licenseBean.getObligationNotificationYn()) ? CoConstDef.CD_DTL_OBLIGATION_NOTICE : "");
if (CoConstDef.FLAG_YES.equals(licenseBean.getObligationNotificationYn())) {
if (!isEmpty(licenseName)) {
licenseName += ",";
}
licenseName += license.getLicenseName();
}
}
OssMaster ossBean = CoCodeManager.OSS_INFO_UPPER.get((bean.getOssName() +"_"+ avoidNull(bean.getOssVersion())).toUpperCase());
bean.setAttribution(ossBean != null ? avoidNull(ossBean.getAttribution()) : "");
bean.setLicenseName(licenseName);
_list.add(bean);
binaryMergeData.put(bean.getBinaryName(), _list);
binaryOssKeyMap.put(bean.getBinaryName(), key);
}
}
Map<String, List<ProjectIdentification>> resultData = new HashMap<String, List<ProjectIdentification>>();
List<String> valuesList = binaryOssKeyMap.values().stream().distinct().collect(Collectors.toList());
Map<String, String> collect = valuesList.stream()
.collect(Collectors.toMap(Functions.identity(), v -> binaryOssKeyMap.entrySet().stream()
.filter(entry -> Objects.equals(v, entry.getValue()))
.map(Map.Entry<String, String>::getKey)
.reduce("", (s1, s2) -> isEmpty(s1) ? s2 : s1 + "," + s2)));
for (String binaryNameList : collect.values()) {
for (String binaryName : binaryMergeData.keySet()) {
int matchCnt = Arrays.asList(binaryNameList.split(",")).stream().filter(s -> s.equals(binaryName)).collect(Collectors.toList()).size();
if (matchCnt > 0) {
resultData.put(binaryNameList, binaryMergeData.get(binaryName));
break;
}
}
}
return resultData;
}
@SuppressWarnings("unchecked")
@Override
public List<Map<String, String>> getBomCompare(List<ProjectIdentification> beforeBomList, List<ProjectIdentification> afterBomList, String flag)
throws Exception {
Map<String, Object> addList = new HashMap<String, Object>();
Map<String, Object> deleteList = new HashMap<String, Object>();
List<Map<String, String>> returnList = new ArrayList<Map<String, String>>();
// bom compare ๋์ ์ถ์ถ ํ๊ธฐ ์ ์ ์์ ์ผ์นํ๋ ๋์์ ์ ์ธํ๊ณ ์ฒ๋ฆฌํจ ?
// bflist loop -> aflist์ ossname & oss version์ด ์์ ์ผ์นํ๋ ๋์์ ์ ๊ฑฐํจ.
// aflist loop -> bflist์ ossname & oss version์ด ์์ ์ผ์นํ๋ ๋์์ ์ ๊ฑฐํจ.
// ์ดํ delete / change / add ๋์ ์ถ์ถํจ.
List<ProjectIdentification> filteredBeforeBomList = beforeBomList
.stream()
.filter(bfList->
afterBomList
.stream()
.filter(afList ->
(bfList.getOssName() + "||" + bfList.getOssVersion() + "||" + getLicenseNameSort(bfList.getLicenseName().trim()))
.equalsIgnoreCase(afList.getOssName() + "||" + afList.getOssVersion() + "||" + getLicenseNameSort(afList.getLicenseName().trim()))
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
filteredBeforeBomList = filteredBeforeBomList.stream().filter(e -> !isEmpty(e.getOssName()) && !e.getOssName().equals("-")).collect(Collectors.toList());
List<ProjectIdentification> filteredAfterBomList = afterBomList
.stream()
.filter(afList->
beforeBomList
.stream()
.filter(bfList ->
(afList.getOssName() + "||" + afList.getOssVersion() + "||" + getLicenseNameSort(afList.getLicenseName().trim()))
.equalsIgnoreCase(bfList.getOssName() + "||" + bfList.getOssVersion() + "||" + getLicenseNameSort(bfList.getLicenseName().trim()))
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
filteredAfterBomList = filteredAfterBomList.stream().filter(e -> !isEmpty(e.getOssName()) && !e.getOssName().equals("-")).collect(Collectors.toList());
// status > add
int addchk = 0;
for (ProjectIdentification after : filteredAfterBomList) {
String ossName = after.getOssName();
int addTargetCnt = filteredBeforeBomList.stream().filter(before -> (before.getOssName()).equals(ossName)).collect(Collectors.toList()).size();
if (addTargetCnt == 0) {
Map<String, String> addMap = new HashMap<String, String>();
String afterossname = after.getOssName();
String version = avoidNull(after.getOssVersion(), "");
if (!version.equals("")) {
afterossname += " (" + version + ")";
}
String afterlicense = after.getLicenseName();
if (flag.equals("list")) {
afterossname = changeStyle("add", afterossname);
afterlicense = changeStyle("add", getLicenseNameSort(afterlicense.trim()));
}
addMap.put("status", "add");
addMap.put("beforeossname", "");
addMap.put("beforelicense", "");
addMap.put("afterossname", afterossname);
addMap.put("afterlicense", afterlicense);
addList.put(getCompareKey(after), addMap);
addchk++;
}
}
if (addchk > 0) {
for (String key : addList.keySet()) {
returnList.add((Map<String, String>) addList.get(key));
}
}
// status > delete
int deletechk = 0;
for (ProjectIdentification before : filteredBeforeBomList) {
String ossName = before.getOssName();
List<ProjectIdentification> afterList = filteredAfterBomList.stream().filter(after -> (after.getOssName()).equals(ossName)).collect(Collectors.toList());
if (afterList.size() == 0) {
Map<String, String> deleteMap = new HashMap<String, String>();
String beforeossname = before.getOssName();
String version = avoidNull(before.getOssVersion(), "");
if (!version.equals("")) {
beforeossname += " (" + version + ")";
}
String beforelicense = before.getLicenseName();
if (flag.equals("list")) {
beforeossname = changeStyle("delete", beforeossname);
beforelicense = changeStyle("delete", getLicenseNameSort(beforelicense.trim()));
}
deleteMap.put("status", "delete");
deleteMap.put("beforeossname", beforeossname);
deleteMap.put("beforelicense", beforelicense);
deleteMap.put("afterossname", "");
deleteMap.put("afterlicense", "");
deleteList.put(getCompareKey(before), deleteMap);
deletechk++;
}
}
if (deletechk > 0) {
for (String key : deleteList.keySet()) {
returnList.add((Map<String, String>) deleteList.get(key));
}
}
// status > change
int changechk = 0;
if (filteredBeforeBomList.size() > 0 && filteredAfterBomList.size() > 0) {
List<ProjectIdentification> beforeBomResult = new ArrayList<ProjectIdentification>();
int chk = 0;
for (ProjectIdentification beforeBomCheckVO : filteredBeforeBomList) {
ProjectIdentification addBeforeBomVO = new ProjectIdentification();
addBeforeBomVO.setOssName(beforeBomCheckVO.getOssName());
if (avoidNull(beforeBomCheckVO.getOssVersion(), "").equals("")) {
addBeforeBomVO.setOssVersion(beforeBomCheckVO.getOssName());
}else {
addBeforeBomVO.setOssVersion(beforeBomCheckVO.getOssName() + "("+ beforeBomCheckVO.getOssVersion() + ")");
}
addBeforeBomVO.setLicenseName(getLicenseNameSort(avoidNull(beforeBomCheckVO.getLicenseName().trim(), "N/A")));
if (beforeBomResult.size() > 0) {
for (int j=0; j<beforeBomResult.size(); j++) {
ProjectIdentification piVO = beforeBomResult.get(j);
if (addBeforeBomVO.getOssName().equals(piVO.getOssName())) {
ProjectIdentification changePIVO = new ProjectIdentification();
changePIVO.setOssName(piVO.getOssName());
changePIVO.setOssVersion(ossCheck("ossName", piVO.getOssVersion(), piVO.getLicenseName(), addBeforeBomVO.getOssVersion(), addBeforeBomVO.getLicenseName()));
changePIVO.setLicenseName(ossCheck("licenseName", piVO.getOssVersion(), piVO.getLicenseName(), addBeforeBomVO.getOssVersion(), addBeforeBomVO.getLicenseName()));
beforeBomResult.add(changePIVO);
beforeBomResult.remove(j);
chk++;
}
}
}
if (chk == 0) {
beforeBomResult.add(addBeforeBomVO);
}
chk = 0;
}
List<ProjectIdentification> afterBomResult = new ArrayList<ProjectIdentification>();
for (ProjectIdentification afterBomCheckVO : filteredAfterBomList) {
ProjectIdentification addAfterBomVO = new ProjectIdentification();
addAfterBomVO.setOssName(afterBomCheckVO.getOssName());
if (avoidNull(afterBomCheckVO.getOssVersion(), "").equals("")) {
addAfterBomVO.setOssVersion(afterBomCheckVO.getOssName());
}else {
addAfterBomVO.setOssVersion(afterBomCheckVO.getOssName() + "(" + avoidNull(afterBomCheckVO.getOssVersion(), "N/A") + ")");
}
addAfterBomVO.setLicenseName(getLicenseNameSort(avoidNull(afterBomCheckVO.getLicenseName().trim(), "N/A")));
if (afterBomResult.size() > 0) {
for (int j=0; j<afterBomResult.size(); j++) {
ProjectIdentification piVO = afterBomResult.get(j);
if (addAfterBomVO.getOssName().equals(piVO.getOssName())) {
ProjectIdentification changePIVO = new ProjectIdentification();
changePIVO.setOssName(addAfterBomVO.getOssName());
changePIVO.setOssVersion(ossCheck("ossName", piVO.getOssVersion(), piVO.getLicenseName(), addAfterBomVO.getOssVersion(), addAfterBomVO.getLicenseName()));
changePIVO.setLicenseName(ossCheck("licenseName", piVO.getOssVersion(), piVO.getLicenseName(), addAfterBomVO.getOssVersion(), addAfterBomVO.getLicenseName()));
afterBomResult.add(changePIVO);
afterBomResult.remove(j);
chk++;
}
}
}
if (chk == 0) {
afterBomResult.add(addAfterBomVO);
}
chk = 0;
}
for (ProjectIdentification beforeResult : beforeBomResult) {
for (ProjectIdentification afterResult : afterBomResult) {
if (beforeResult.getOssName().equals(afterResult.getOssName())) {
if (!beforeResult.getOssVersion().equals(afterResult.getOssVersion()) || !beforeResult.getLicenseName().equals(afterResult.getLicenseName())) {
Map<String, String> map = new HashMap<String, String>();
map.put("status", "change");
if (flag.equals("list")) {
map.put("beforeossname", changeStyle("change", beforeResult.getOssVersion()));
map.put("beforelicense", changeStyle("change", beforeResult.getLicenseName()));
map.put("afterossname", changeStyle("change", afterResult.getOssVersion()));
map.put("afterlicense", changeStyle("change", afterResult.getLicenseName()));
}else {
map.put("beforeossname", beforeResult.getOssVersion());
map.put("beforelicense", beforeResult.getLicenseName());
map.put("afterossname", afterResult.getOssVersion());
map.put("afterlicense", afterResult.getLicenseName());
}
returnList.add(map);
changechk++;
}
}
}
}
}
if (addchk == 0 && deletechk == 0 && changechk == 0) {
Map<String, String> map = new HashMap<String, String>();
map.put("status", "Same");
returnList.add(map);
}
return returnList;
}
private String getCompareKey(ProjectIdentification param) {
return (param.getOssName() + "|" + avoidNull(param.getOssVersion(), "") + "|" + param.getLicenseName()).toLowerCase();
}
private static String changeStyle(String flag, String text) {
String returnVal = "";
if (flag.equals("delete")){
returnVal = "<span style=\"background-color:#FFCCCC;\">" + text + "</span>";
}else if (flag.equals("change") || flag.equals("add")){
returnVal = "<span style=\"background-color:yellow\">" + text + "</span>";
}
return returnVal;
}
private String getLicenseNameSort(String licenseName) {
String sortedValue = "";
String splitLicenseNm[] = licenseName.split(",");
Arrays.sort(splitLicenseNm);
for (int i=0; i< splitLicenseNm.length; i++) {
sortedValue += splitLicenseNm[i];
if (i<splitLicenseNm.length-1) {
sortedValue += ", ";
}
}
return sortedValue;
}
private String ossCheck(String flag, String ossNameVersion, String ossLicenseName, String ossNameVersion2, String ossLicenseName2) {
String splitOssNameVersion[] = ossNameVersion.split("/");
int count = splitOssNameVersion.length;
if (flag.equals("ossName")) {
int cnt = 0;
for (int i=0; i<count; i++) {
if (splitOssNameVersion[i].trim().equals(ossNameVersion2)) {
cnt++;
}
}
if (cnt > 0) {
return ossNameVersion;
} else {
return ossNameVersion + " / " + ossNameVersion2;
}
} else {
String licenseNmArr1[] = ossLicenseName.split(" / ");
int chk = 0;
boolean chkFlag = false;
if (count == licenseNmArr1.length) {
chkFlag = true;
for (int i=0; i<count; i++) {
if (splitOssNameVersion[i].trim().equals(ossNameVersion2)) {
List<String> mergeList = new ArrayList<>();
List<String> licenseNmChk1 = Arrays.asList(licenseNmArr1[i].split(","));
List<String> licenseNmChk2 = Arrays.asList(ossLicenseName2.split(","));
for (String chk1 : licenseNmChk1) {
boolean equalsFlag = false;
for (String chk2 : licenseNmChk2) {
if (chk1.trim().equalsIgnoreCase(chk2.trim())) {
equalsFlag = true;
break;
}
}
if (!equalsFlag) {
for (String chk2 : licenseNmChk2) {
mergeList.add(chk2.trim());
}
mergeList.add(chk1.trim());
}
}
if (mergeList.size() > 0) {
mergeList = mergeList.stream().distinct().collect(Collectors.toList());
String str = "";
for (int j=0; j<mergeList.size(); j++) {
str += mergeList.get(j);
if (j < mergeList.size()-1) {
str += ", ";
}
}
licenseNmArr1[i] = str;
chk++;
}
}
}
}
if (chk > 0 || chkFlag) {
String strMerge = "";
for (int i=0; i<licenseNmArr1.length; i++) {
strMerge += licenseNmArr1[i];
if (i<licenseNmArr1.length-1) {
strMerge += " / ";
}
}
int cnt = 0;
for (int i=0; i<count; i++) {
if (splitOssNameVersion[i].trim().equals(ossNameVersion2)) {
cnt++;
}
}
if (cnt == 0) {
return strMerge + " / " + ossLicenseName2;
} else {
return strMerge;
}
} else {
return ossLicenseName + " / " + ossLicenseName2;
}
}
}
@Override
public void deleteStatisticsMostUsedInfo(Project project) {
projectMapper.deleteStatisticsMostUsedInfo(project);
}
@SuppressWarnings("unchecked")
@Override
@Transactional
public void addPartnerData(Project project) {
{
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(project.getPrjId());
projectSubStatus.setIdentificationSubStatusPartner(CoConstDef.FLAG_YES);
// ์ต์ด ์ ์ฅ์์๋ง ์ํ ๋ณ๊ฒฝ
// row count๊ฐ 0์ด์ด๋ ์ฌ์ฉ์๊ฐ ํ๋ฒ์ด๋ผ๋ ์ ์ฅํ๋ฉด progress ์ํ๋ก ์ธ์ง๋์ด์ผํจ
if (isEmpty(project.getIdentificationStatus())) {
projectSubStatus.setIdentificationStatus(CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
}
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectMapper.updateProjectMaster(projectSubStatus);
}
OssComponents component = new OssComponents();
component.setReferenceId(project.getRefPartnerId());
component.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
// select partner Data
Map<String, Object> resultMap = getPartnerOssList(component);
List<OssComponents> partnerList = (List<OssComponents>) resultMap.get("rows");
partnerList = convertOssNickName3rd(partnerList);
// Identification > 3rd Party Tab Insert
for (OssComponents bean : partnerList) {
bean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER);
bean.setReferenceId(project.getPrjId());
bean.setRefPartnerId(project.getRefPartnerId());
projectMapper.insertOssComponentsCopy(bean);
projectMapper.insertOssComponentsLicenseCopy(bean);
}
PartnerMaster partnerBean = new PartnerMaster();
partnerBean.setPrjId(project.getPrjId());
partnerBean.setPartnerId(project.getRefPartnerId());
// project - partner Map Insert
partnerMapper.insertPartnerMapList(partnerBean);
}
@Override
public void insertCopyConfirmStatusBomList(Project project, ProjectIdentification identification) {
List<ProjectIdentification> bomList = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(identification);;
if (notVersionList != null) {
bomList.addAll(notVersionList);
}
identification.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
bomList.sort(compare);
Map<String, List<OssComponentsLicense>> bomLicenseMap = new HashMap<>();
List<OssComponentsLicense> bomLicenseList = projectMapper.selectBomLicenseList(identification);
for (OssComponentsLicense ocl : bomLicenseList) {
String key = ocl.getComponentId();
List<OssComponentsLicense> bomLicenses = null;
if (bomLicenseMap.containsKey(key)) {
bomLicenses = bomLicenseMap.get(ocl.getComponentId());
} else {
bomLicenses = new ArrayList<>();
}
bomLicenses.add(ocl);
bomLicenseMap.put(key, bomLicenses);
}
for (ProjectIdentification pi : bomList) {
List<OssComponentsLicense> licenseList = null;
pi.setReferenceId(project.getPrjId());
if (bomLicenseMap.containsKey(pi.getComponentId())) {
licenseList = bomLicenseMap.get(pi.getComponentId());
}
// ์ปดํฌ๋ํธ ๋ง์คํฐ ์ธ์ํธ
projectMapper.registBomComponents(pi);
if (licenseList != null) {
for (OssComponentsLicense licenseBean : licenseList) {
licenseBean.setComponentId(pi.getComponentId());
projectMapper.registComponentLicense(licenseBean);
}
}
}
}
@Override
public List<String> getPackageFileList(Project project, String filePath) {
Project prj = getProjectBasicInfo(project.getCopyPrjId());
List<String> fileSeqs = new ArrayList<>();
if (!isEmpty(prj.getPackageFileId())) {
List<UploadFile> uploadFile = fileService.setReusePackagingFile(prj.getPackageFileId());
HashMap<String, Object> fileMap = new HashMap<>();
fileMap.put("prjId", project.getPrjId());
fileMap.put("refPrjId", project.getCopyPrjId());
fileMap.put("refFileSeq", prj.getPackageFileId());
fileMap.put("fileSeq", uploadFile.get(0).getRegistSeq());
boolean reuseCheck = verificationService.setReusePackagingFile(fileMap);
if (reuseCheck) {
fileSeqs.add(uploadFile.get(0).getRegistSeq());
}
if (!isEmpty(prj.getPackageFileId2())) {
List<UploadFile> file2 = fileService.setReusePackagingFile(prj.getPackageFileId2());
fileMap.put("refFileSeq", prj.getPackageFileId2());
fileMap.put("fileSeq", file2.get(0).getRegistSeq());
reuseCheck = verificationService.setReusePackagingFile(fileMap);
if (reuseCheck) {
fileSeqs.add(file2.get(0).getRegistSeq());
}
}
if (!isEmpty(prj.getPackageFileId3())) {
List<UploadFile> file3 = fileService.setReusePackagingFile(prj.getPackageFileId3());
fileMap.put("refFileSeq", prj.getPackageFileId3());
fileMap.put("fileSeq", file3.get(0).getRegistSeq());
reuseCheck = verificationService.setReusePackagingFile(fileMap);
if (reuseCheck) {
fileSeqs.add(file3.get(0).getRegistSeq());
}
}
}
return fileSeqs;
}
@Override
public List<ProjectIdentification> selectIdentificationGridList(ProjectIdentification identification) {
List<ProjectIdentification> list = projectMapper.selectIdentificationGridList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionOssComponentList = projectMapper.selectIdentificationGridList(identification);
if (notVersionOssComponentList != null) {
list.addAll(notVersionOssComponentList);
identification.setOssVersionEmptyFlag(null);
}
list.sort(Comparator.comparing(ProjectIdentification::getComponentId));
return list;
}
@Override
public void updateCopyConfirmStatusProjectStatus(Project project) {
projectMapper.updateCopyConfirmStatusProjectStatus(project);
}
@Override
public void copySrcAndroidNoticeFile(Project project) {
Project prj = getProjectBasicInfo(project.getCopyPrjId());
if (!isEmpty(prj.getSrcAndroidNoticeFileId())) {
String fileId = fileService.copyPhysicalFile(prj.getSrcAndroidNoticeFileId());
if (!isEmpty(fileId)) {
project.setSrcAndroidNoticeFileId(fileId);
projectMapper.updateFileId(project);
}
}
}
@Override
public Map<String, List<Project>> updateProjectDivision(Project project) {
Map<String, List<Project>> updateProjectDivMap = new HashMap<>();
List<Project> beforeBeanList = new ArrayList<>();
List<Project> afterBeanList = new ArrayList<>();
Project param = new Project();
String division = project.getPrjDivision();
String comment = "";
for (String prjId : project.getPrjIds()) {
param.setPrjId(prjId);
Project beforeBean = getProjectDetail(param);
if (!avoidNull(beforeBean.getDivision(), "").equals(division)) {
Project afterBean = getProjectDetail(param);
afterBean.setDivision(division);
projectMapper.updateProjectDivision(afterBean);
comment = CommonFunction.getDiffItemComment(beforeBean, afterBean);
afterBean.setUserComment(comment);
Map<String, List<Project>> modelMap = getModelList(prjId);
beforeBean.setModelList((List<Project>) modelMap.get("currentModelList"));
afterBean.setModelList((List<Project>) modelMap.get("currentModelList"));
if (afterBean.getWatcherList() != null && !afterBean.getWatcherList().isEmpty()) {
List<String> prjWatchers = afterBean.getWatcherList().stream().map(e -> e.getPrjDivision() + "/" + e.getPrjUserId()).collect(Collectors.toList());
afterBean.setWatchers(prjWatchers.toArray(new String[prjWatchers.size()]));
}
beforeBeanList.add(beforeBean);
afterBeanList.add(afterBean);
}
}
if (!beforeBeanList.isEmpty()) {
updateProjectDivMap.put("before", beforeBeanList);
}
if (!afterBeanList.isEmpty()) {
updateProjectDivMap.put("after", afterBeanList);
}
return updateProjectDivMap;
}
@Override
public void updateComment(Project project) {
projectMapper.updateComment(project);
}
@Override
public String checkOssNicknameList(ProjectIdentification identification) {
String referenceDivString = "";
List<ProjectIdentification> bomList = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(identification);;
if (notVersionList != null) {
bomList.addAll(notVersionList);
}
identification.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
bomList.sort(compare);
if (bomList != null) {
List<ProjectIdentification> checkList = bomList.stream()
.filter(obj -> {
String ossName = (avoidNull(obj.getOssName())).toUpperCase();
String compareOssName = (avoidNull(CoCodeManager.OSS_INFO_UPPER_NAMES.get(obj.getOssName().toUpperCase()))).toUpperCase();
String referenceDiv = obj.getReferenceDiv();
return CoConstDef.FLAG_NO.equals(obj.getAdminCheckYn()) && !isEmpty(compareOssName) && !ossName.equals(compareOssName) && !CoConstDef.CD_DTL_COMPONENT_ID_DEP.equals(referenceDiv);
}).collect(Collectors.toList());
if (checkList.size() > 0) {
for (ProjectIdentification row : checkList) {
if (CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(row.getOssName().toUpperCase())) {
switch(row.getReferenceDiv()) {
case CoConstDef.CD_DTL_COMPONENT_ID_PARTNER :
if (!referenceDivString.contains("3rd")) {
referenceDivString += "3rd" + ",";
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_SRC :
if (!referenceDivString.contains("SRC")) {
referenceDivString += "SRC" + ",";
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_BIN :
if (!referenceDivString.contains("BIN")) {
referenceDivString += "BIN" + ",";
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_ANDROID :
if (!referenceDivString.contains("ANDROID")) {
referenceDivString += "ANDROID" + ",";
}
break;
}
}
}
referenceDivString = referenceDivString.substring(0, referenceDivString.length()-1);
return getMessage("msg.project.error.bom.usenickname", new String[]{referenceDivString});
}
}
return null;
}
@Override
public void deleteUploadFile(Project project) {
Project prjInfo = projectMapper.getProjectBasicInfo(project);
boolean fileDeleteCheckFlag = false;
String physicalFilePath = "";
T2File fileInfo = null;
if (project.getReferenceDiv().equals(CoConstDef.CD_DTL_COMPONENT_ID_DEP) || project.getReferenceDiv().equals(CoConstDef.CD_DTL_COMPONENT_ID_SRC)
|| project.getReferenceDiv().equals(CoConstDef.CD_DTL_COMPONENT_ID_BIN) || project.getReferenceDiv().equals(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID)) {
physicalFilePath = "Identification";
}
if (project.getCsvFile() != null) {
for (int i = 0; i < project.getCsvFile().size(); i++) {
if (i == 0) {
fileInfo = fileService.selectFileInfo(project.getCsvFile().get(i).getFileSeq());
}
projectMapper.deleteFileBySeq(project.getCsvFile().get(i));
fileService.deletePhysicalFile(project.getCsvFile().get(i), physicalFilePath);
}
}
if (fileInfo != null) {
T2File fileInfo2 = fileService.selectFileInfoById(fileInfo.getFileId());
switch (project.getReferenceDiv()) {
case CoConstDef.CD_DTL_COMPONENT_ID_DEP:
if (fileInfo2 == null && prjInfo.getDepCsvFileId().equals(fileInfo.getFileId())) {
project.setDepCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_SRC:
if (fileInfo2 == null && prjInfo.getSrcCsvFileId().equals(fileInfo.getFileId())) {
project.setSrcCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_BIN:
if (fileInfo2 == null && prjInfo.getBinCsvFileId().equals(fileInfo.getFileId())) {
project.setBinCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
break;
case CoConstDef.CD_DTL_COMPONENT_ID_ANDROID:
if (fileInfo2 == null && prjInfo.getSrcAndroidCsvFileId().equals(fileInfo.getFileId())) {
project.setSrcAndroidCsvFileFlag(CoConstDef.FLAG_YES);
fileDeleteCheckFlag = true;
}
break;
default :
break;
}
}
if (fileDeleteCheckFlag) {
projectMapper.updateFileId2(project);
}
}
@Override
public Map<String, Object> getSecurityGridList(Project project) {
Map<String, Object> rtnMap = new HashMap<>();
List<OssComponents> totalList = new ArrayList<>();
List<OssComponents> fixedList = new ArrayList<>();
List<OssComponents> notFixedList = new ArrayList<>();
Map<String, Object> securityGridMap = new HashMap<>();
List<String> deduplicatedkey = new ArrayList<>();
List<String> checkOssNameList = new ArrayList<>();
List<ProjectIdentification> list = null;
OssMaster param = new OssMaster();
OssComponents oc = null;
OssComponents bean = null;
boolean activateFlag;
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(project.getPrjId());
Project prjInfo = projectMapper.selectProjectMaster2(project);
if (!prjInfo.getNoticeType().equals(CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED)) {
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
identification.setMerge(CoConstDef.FLAG_NO);
List<ProjectIdentification> bomList = projectMapper.selectBomList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionList = projectMapper.selectBomList(identification);;
if (notVersionList != null) {
bomList.addAll(notVersionList);
}
identification.setOssVersionEmptyFlag(null);
Comparator<ProjectIdentification> compare = Comparator
.comparing(ProjectIdentification::getLicenseTypeIdx)
.thenComparing(ProjectIdentification::getOssName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getOssVersion, (str1, str2) -> str2.compareTo(str1))
.thenComparing(ProjectIdentification::getLicenseName, Comparator.nullsFirst(Comparator.naturalOrder()))
.thenComparing(ProjectIdentification::getMergeOrder);
bomList.sort(compare);
list = bomList.stream().filter(CommonFunction.distinctByKey(p -> p.getOssName()+p.getOssVersion())).collect(Collectors.toList());
} else {
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_ANDROID);
List<ProjectIdentification> componentList = projectMapper.selectIdentificationGridList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionOssComponentList = projectMapper.selectIdentificationGridList(identification);;
if (notVersionOssComponentList != null) {
componentList.addAll(notVersionOssComponentList);
}
identification.setOssVersionEmptyFlag(null);
componentList.sort(Comparator.comparing(ProjectIdentification::getComponentId));
list = componentList.stream().filter(CommonFunction.distinctByKey(p -> p.getOssName()+p.getOssVersion())).collect(Collectors.toList());
}
int gridIdx = 1;
for (ProjectIdentification pi : list) {
activateFlag = false;
if (isEmpty(pi.getOssName()) || pi.getOssName().equals("-") || pi.getExcludeYn().equals(CoConstDef.FLAG_YES)) continue;
param.setOssName(avoidNull(pi.getRefOssName(), pi.getOssName()));
param.setOssVersion(pi.getOssVersion());
List<Vulnerability> vulnList = vulnerabilityService.getSecurityVulnListByOssName(param);
if (vulnList != null && !vulnList.isEmpty()) {
List<OssComponents> securityDatalist = projectMapper.getSecurityDataList(pi);
if (securityDatalist != null && !securityDatalist.isEmpty()) {
for (OssComponents oss : securityDatalist) {
String key = (oss.getOssName() + "_" + oss.getOssVersion() + "_" + oss.getCveId() + "_" + oss.getCvssScore()).toUpperCase();
securityGridMap.put(key, oss);
}
}
if (vulnList != null && !vulnList.isEmpty() && isEmpty(pi.getOssVersion())) {
activateFlag = true;
vulnList = vulnList.stream().sorted(Comparator.comparing(Vulnerability::getCvssScore).reversed()).collect(Collectors.toList());
List<Vulnerability> convertVulnList = new ArrayList<>();
convertVulnList.add(vulnList.get(0));
vulnList = convertVulnList;
}
for (Vulnerability vuln : vulnList) {
String key = (pi.getOssName() + "_" + pi.getOssVersion() + "_" + vuln.getCveId() + "_" + vuln.getCvssScore()).toUpperCase();
if (!deduplicatedkey.contains(key)) {
deduplicatedkey.add(key);
if (securityGridMap.containsKey(key)) {
bean = (OssComponents) securityGridMap.get(key);
}
if (activateFlag) checkOssNameList.add(pi.getOssName());
oc = new OssComponents();
oc.setGridId("jqg_sec_" + project.getPrjId() + "_" + String.valueOf(gridIdx));
oc.setOssId(pi.getOssId());
oc.setOssName(pi.getOssName());
oc.setOssVersion(pi.getOssVersion());
if (!activateFlag) {
oc.setCveId(vuln.getCveId());
oc.setCvssScore(vuln.getCvssScore());
oc.setPublDate(vuln.getPublDate());
}
oc.setVulnerabilityResolution("Unresolved");
if (bean != null) {
oc.setVulnerabilityResolution(bean.getVulnerabilityResolution());
}
if (oc.getVulnerabilityResolution().equals("Fixed")) {
fixedList.add(oc);
} else {
notFixedList.add(oc);
}
totalList.add(oc);
bean = null;
gridIdx++;
}
}
}
}
checkOssNameList = checkOssNameList.stream().distinct().collect(Collectors.toList());
String warningMsg = getMessage("msg.project.security.check.version");
boolean checkDataFlag = false;
if (!checkOssNameList.isEmpty()) {
checkDataFlag = true;
warningMsg += "<br/><br/>";
for (int i=0; i < checkOssNameList.size(); i++) {
warningMsg += "- " + checkOssNameList.get(i);
if (i < checkOssNameList.size()-1) {
warningMsg += "<br/>";
}
}
}
if (checkDataFlag) {
rtnMap.put("msg", warningMsg);
}
rtnMap.put("totalList", totalList);
rtnMap.put("fixedList", fixedList);
rtnMap.put("notFixedList", notFixedList);
return rtnMap;
}
@SuppressWarnings("unchecked")
@Override
@Transactional
public void registSecurity(String prjId, String tabName, List<OssComponents> ossComponents) {
try {
List<OssComponents> updateNvdDataList = new ArrayList<>();
Map<String, OssComponents> securityGridMap = new HashMap<>();
List<OssComponents> deleteDataList = new ArrayList<>();
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(prjId);
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
identification.setMerge(CoConstDef.FLAG_NO);
Map<String, Object> bomObj = getIdentificationGridList(identification);
List<ProjectIdentification> bomList = (List<ProjectIdentification>) bomObj.get("rows");
for (ProjectIdentification pi : bomList) {
if (pi.getOssName().equals("-")) continue;
List<OssComponents> securityDatalist = projectMapper.getSecurityDataList(pi);
if (securityDatalist != null) {
for (OssComponents oss : securityDatalist) {
String key = (oss.getOssName() + "_" + oss.getOssVersion() + "_" + oss.getCveId()).toUpperCase();
securityGridMap.put(key, oss);
}
}
}
for (OssComponents oc : ossComponents) {
String key = (oc.getOssName() + "_" + oc.getOssVersion() + "_" + oc.getCveId()).toUpperCase();
if (securityGridMap.containsKey(key)) {
if (avoidNull(securityGridMap.get(key).getVulnerabilityResolution(), "").equals("Fixed") && !avoidNull(oc.getVulnerabilityResolution(), "").equals("Fixed")) {
updateNvdDataList.add(oc);
} else if (!avoidNull(securityGridMap.get(key).getVulnerabilityResolution(), "").equals("Fixed") && avoidNull(oc.getVulnerabilityResolution(), "").equals("Fixed")) {
updateNvdDataList.add(oc);
}
deleteDataList.add(oc);
} else {
if (avoidNull(oc.getVulnerabilityResolution(), "").equals("Fixed")) {
updateNvdDataList.add(oc);
}
}
}
if (!deleteDataList.isEmpty()) {
for (OssComponents oc : deleteDataList) {
oc.setReferenceId(prjId);
projectMapper.deleteSecurityData(oc);
}
}
for (OssComponents oc : ossComponents) {
oc.setReferenceId(prjId);
projectMapper.insertSecurityData(oc);
}
if (updateNvdDataList != null && !updateNvdDataList.isEmpty()) {
for (OssComponents oc : updateNvdDataList) {
OssMaster om = new OssMaster();
om.setOssName(oc.getOssName());
om.setOssVersion(avoidNull(oc.getOssVersion()).isEmpty() ? "-" : oc.getOssVersion());
Vulnerability vuln = vulnerabilityService.selectNotFixedCveInfo(om);
if (vuln != null) {
om.setCveId(vuln.getCveId());
om.setCvssScore(vuln.getCvssScore());
om.setVulnSummary(vuln.getVulnSummary());
} else {
om.setCveId(null);
}
projectMapper.updateCveInfoForNotFixedOssInfo(om);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@Override
public Map<String, Object> getExportDataForSBOMInfo(OssNotice ossNotice) {
Map<String, Object> model = new HashMap<String, Object>();
String prjName = "";
String prjVersion = "";
String prjId = "";
String distributeSite = "";
int dashSeq = 0;
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = projectMapper.getProjectBasicInfo(project);
if (project != null){
if (isEmpty(prjName)) {
prjName = project.getPrjName();
}
if (isEmpty(prjId)) {
prjId = project.getPrjId();
}
if (isEmpty(prjVersion)) {
prjVersion = project.getPrjVersion();
}
if (isEmpty(distributeSite)) {
distributeSite = project.getDistributeTarget();
}
}
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(ossNotice.getPrjId());
List<OssComponents> ossComponentList = projectMapper.selectOssComponentsSbomList(identification);
// TYPE๋ณ ๊ตฌ๋ถ
Map<String, OssComponents> noticeInfo = new HashMap<>();
Map<String, OssComponents> srcInfo = new HashMap<>();
Map<String, OssComponents> notObligationInfo = new HashMap<>();
OssMaster om = new OssMaster();
OssComponents ossComponent;
for (OssComponents bean : ossComponentList) {
if (isEmpty(bean.getOssName()) || isEmpty(bean.getLicenseName())) continue;
om.setOssNames(new String[] {bean.getOssName()});
List<OssMaster> ossList = projectMapper.checkOssNickName(om);
if (ossList != null && !ossList.isEmpty()) {
om = ossList.get(0);
OssMaster ossInfo = CoCodeManager.OSS_INFO_BY_ID.get(om.getOssId());
if (ossInfo != null) {
String copyright = ossInfo.getCopyright();
String homepage = ossInfo.getHomepage();
if (isEmpty(bean.getCopyrightText()) && !isEmpty(copyright)) {
bean.setCopyrightText(copyright);
}
if (isEmpty(bean.getHomepage()) && !isEmpty(homepage)) {
bean.setHomepage(homepage);
}
}
}
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
// type
boolean isDisclosure = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType());
boolean isNotice = CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType());
if (CoConstDef.CD_DTL_NOTICE_TYPE_ACCOMPANIED.equals(ossNotice.getNoticeType())) {
isDisclosure = true;
}
boolean addDisclosure = isDisclosure && srcInfo.containsKey(componentKey);
boolean addNotice = !isDisclosure && noticeInfo.containsKey(componentKey);
boolean addNotObligation = notObligationInfo.containsKey(componentKey);
if (addDisclosure) {
ossComponent = srcInfo.get(componentKey);
} else if (addNotice) {
ossComponent = noticeInfo.get(componentKey);
} else if (addNotObligation) {
ossComponent = notObligationInfo.get(componentKey);
} else {
ossComponent = bean;
}
// ๋ผ์ด์ ์ค ์ ๋ณด ์์ฑ
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
// ํ๋์ oss์ ๋ํด์ ๋์ผํ LICENSE๊ฐ ๋ณต์ ํ์๋๋ ํ์
// ์ผ๋จ ์ฌ๊ธฐ์ ๋ง๋๋ค. (์ฟผ๋ฆฌ๊ฐ ์๋ชป๋ ๊ฑด์ง, DATA๊ฐ ๊ผฌ์ด๋๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์)
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
if (CoConstDef.FLAG_NO.equals(ossComponent.getAdminCheckYn())) {
bean.setOssCopyright(findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright()));
// multi license ์ถ๊ฐ copyright
if (!isEmpty(bean.getOssCopyright())) {
String addCopyright = avoidNull(ossComponent.getCopyrightText());
if (!isEmpty(ossComponent.getCopyrightText())) {
addCopyright += "\r\n";
}
addCopyright += bean.getOssCopyright();
ossComponent.setCopyrightText(addCopyright);
}
}
}
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else if (isNotice) {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
} else {
if (addNotObligation) {
notObligationInfo.replace(componentKey, ossComponent);
} else {
notObligationInfo.put(componentKey, ossComponent);
}
}
}
List<OssComponents> addOssComponentList = projectMapper.selectOssComponentsListClassAppend(identification);
if (addOssComponentList != null) {
for (OssComponents bean : addOssComponentList) {
if (isEmpty(bean.getLicenseName())) continue;
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(bean.getOssComponentsLicense(), license)) {
bean.addOssComponentsLicense(license);
}
boolean disclosureFlag = false;
boolean noticeFlag = false;
switch(CommonFunction.checkObligationSelectedLicense(bean.getOssComponentsLicense())){
case CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE:
srcInfo.put(componentKey, bean);
disclosureFlag = true;
break;
case CoConstDef.CD_DTL_OBLIGATION_NOTICE:
noticeInfo.put(componentKey, bean);
noticeFlag = true;
break;
}
if (!disclosureFlag && !noticeFlag) {
notObligationInfo.put(componentKey, bean);
}
}
}
boolean isTextNotice = "text".equals(ossNotice.getFileType());
Map<String, String> ossAttributionMap = new HashMap<>();
// ๊ฐํ์ฒ๋ฆฌ ๋ฐ velocity์ฉ list ์์ฑ
List<OssComponents> noticeList = new ArrayList<>();
for (OssComponents bean : noticeInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
noticeList.add(bean);
}
Collections.sort(noticeList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> srcList = new ArrayList<>();
for (OssComponents bean : srcInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
srcList.add(bean);
}
Collections.sort(srcList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> notObligationList = new ArrayList<>();
for (OssComponents bean : notObligationInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
notObligationList.add(bean);
}
Collections.sort(notObligationList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
model.put("noticeObligationList", noticeList);
model.put("disclosureObligationList", srcList);
model.put("notObligationList", notObligationList);
model.put("addOssComponentList", addOssComponentList);
return model;
}
private boolean checkLicenseDuplicated(List<OssComponentsLicense> ossComponentsLicense, OssComponentsLicense license) {
if (ossComponentsLicense != null) {
if (!isEmpty(license.getLicenseId())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseId().equals(license.getLicenseId())) {
return true;
}
}
} else if (isEmpty(license.getLicenseId()) && !isEmpty(license.getLicenseName())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseName().equals(license.getLicenseName())) {
return true;
}
}
}
}
return false;
}
@SuppressWarnings("unchecked")
@Override
public boolean checkReqEntrySecurity(Project project, String tabMenu) {
boolean reqEntryFlag = false;
Map<String, Object> result = getSecurityGridList(project);
switch (tabMenu) {
case "fixed" :
if (result.containsKey("fixedList")) {
List<OssComponents> fixedList = (List<OssComponents>) result.get("fixedList");
fixedList = fixedList.stream().filter(e -> e.getOssVersion().isEmpty()
|| (e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityPatchLink())))
|| (!e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityComments())))
|| e.getVulnerabilityResolution().equals("Unresolved")).collect(Collectors.toList());
if (!fixedList.isEmpty()) {
reqEntryFlag = true;
}
}
break;
case "notfixed" :
if (result.containsKey("notFixedList")) {
List<OssComponents> notFixedList = (List<OssComponents>) result.get("notFixedList");
notFixedList = notFixedList.stream().filter(e -> isEmpty(avoidNull(e.getOssVersion()))
|| (e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityPatchLink())))
|| (!e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityComments())))
|| e.getVulnerabilityResolution().equals("Unresolved")).collect(Collectors.toList());
if (!notFixedList.isEmpty()) {
reqEntryFlag = true;
}
}
break;
default :
if (result.containsKey("totalList")) {
List<OssComponents> totalList = (List<OssComponents>) result.get("totalList");
totalList = totalList.stream().filter(e -> e.getOssVersion().isEmpty()
|| (e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityPatchLink())))
|| (!e.getVulnerabilityResolution().equals("Fixed") && isEmpty(avoidNull(e.getSecurityComments())))
|| e.getVulnerabilityResolution().equals("Unresolved")).collect(Collectors.toList());
if (!totalList.isEmpty()) {
reqEntryFlag = true;
}
}
break;
}
return reqEntryFlag;
}
@Override
public void copySecurityDataForProject(Project project) {
boolean copyFlag = projectMapper.copySecurityDataForProjectCnt(project) > 0 ? true : false;
if (copyFlag) projectMapper.copySecurityDataForProject(project);
}
@Override
public Map<String, Object> checkSelectDownloadFile(Project project) {
Map<String, Object> resMap = new HashMap<>();
boolean emptyCheckFlag = false;
if (project.getReferenceDiv().equals(CoConstDef.CD_DTL_COMPONENT_ID_BOM)) {
List<ProjectIdentification> list = projectMapper.checkSelectDownloadFileForBOM(project);
if (list != null) {
for (ProjectIdentification bean : list) {
if (!bean.getLicenseTypeIdx().equals("1")) continue;
if (isEmpty(bean.getOssName()) || isEmpty(bean.getLicenseName())) {
emptyCheckFlag = true;
break;
}
}
}
} else {
List<OssComponents> list = projectMapper.checkSelectDownloadFile(project);
if (list != null) {
for (OssComponents oss : list) {
if (isEmpty(oss.getOssName()) || isEmpty(oss.getLicenseName())) {
emptyCheckFlag = true;
break;
}
}
}
}
if (emptyCheckFlag) {
resMap.put("isValid", false);
} else {
resMap.put("isValid", true);
}
return resMap;
}
@Override
public List<OssComponents> getDependenciesDataList(Project project) {
return projectMapper.getDependenciesDataList(project);
}
}
| 261,225 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiVulnerabilityServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiVulnerabilityServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import oss.fosslight.repository.ApiVulnerabilityMapper;
import oss.fosslight.service.ApiOssService;
import oss.fosslight.service.ApiVulnerabilityService;
import oss.fosslight.util.StringUtil;
@Service
public class ApiVulnerabilityServiceImpl implements ApiVulnerabilityService {
/** The api oss mapper. */
@Autowired Environment env;
@Autowired ApiVulnerabilityMapper apiVulnerabilityMapper;
@Autowired ApiOssService apiOssService;
public List<Map<String, Object>> selectNvdList(String product, String version, String id){
Map<String, Object> paramMap = new HashMap<String, Object>();
String[] nicknameList = apiOssService.getOssNickNameListByOssName(product);
paramMap.put("ossName", product);
paramMap.put("ossVersion", version);
paramMap.put("cveId", id);
paramMap.put("ossNicknames", nicknameList);
if (!StringUtil.isEmpty(product) && product.contains(" ")) {
paramMap.put("underbarOssName", product.replaceAll(" ", "_"));
}
List<Map<String, Object>> nvdList = apiVulnerabilityMapper.selectNvdList(paramMap);
List<String> duplicatedStr = new ArrayList<String>();
List<Map<String, Object>> duplicatedNvdList = new ArrayList<Map<String, Object>>();
for (Map<String, Object> nvd : nvdList) {
String s = (String) nvd.get("cveId");
if (!duplicatedStr.contains(s)) {
duplicatedStr.add(s);
duplicatedNvdList.add(nvd);
}
}
return duplicatedNvdList;
}
public List<Map<String, Object>> selectMaxScoreNvdInfo(String product, String version){
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("ossName", product);
paramMap.put("ossVersion", version);
paramMap.put("host", env.getProperty("server.domain"));
if (product.contains(" ")) {
paramMap.put("underbarOssName", product.replaceAll(" ", "_"));
}
return apiVulnerabilityMapper.selectMaxScoreNvdInfo(paramMap);
}
}
| 2,343 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiPartnerServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiPartnerServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.repository.ApiPartnerMapper;
import oss.fosslight.service.ApiPartnerService;
@Service
@Slf4j
public class ApiPartnerServiceImpl implements ApiPartnerService {
@Autowired ApiPartnerMapper apiPartnerMapper;
@Override
public Map<String, Object> getPartnerMasterList(Map<String, Object> paramMap){
Map<String, Object> result = new HashMap<String, Object>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
int partnerCnt = apiPartnerMapper.selectPartnerMasterCount(paramMap);
if (partnerCnt > 0) {
list = apiPartnerMapper.selectPartnerMaster(paramMap);
}
result.put("content", list);
result.put("record", partnerCnt);
return result;
}
@Override
public boolean existPartnertCnt(Map<String, Object> paramMap) {
return apiPartnerMapper.existPartnertCnt(paramMap) > 0 ? true : false;
}
@Override
public boolean existLdapUserToEmail(String email) {
boolean ldapCheckFlag = false;
try {
LdapTemplate ldapTemplate = new LdapTemplate(makeLdapContextSource());
ldapTemplate.afterPropertiesSet();
@SuppressWarnings({ "unchecked", "rawtypes" })
List<String[]> result = ldapTemplate.search(query().where("mail").is(email), new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
return new String[]{(String)attrs.get("mail").get(), (String)attrs.get("displayname").get()};
}
});
if (result != null && !result.isEmpty()) ldapCheckFlag = true;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return ldapCheckFlag;
}
private LdapContextSource makeLdapContextSource() {
String LDAP_SEARCH_DOMAIN = CoCodeManager.getCodeExpString(CoConstDef.CD_LOGIN_SETTING, CoConstDef.CD_LDAP_DOMAIN);
String LDAP_SEARCH_ID = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_ID);
String LDAP_SEARCH_PW = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_PW);
LdapContextSource contextSource = new LdapContextSource();
try {
contextSource.setUrl(CoConstDef.AD_LDAP_LOGIN.LDAP_SERVER_URL.getValue());
contextSource.setBase("OU=LGE Users, DC=LGE, DC=NET");
contextSource.setUserDn(LDAP_SEARCH_ID+LDAP_SEARCH_DOMAIN);
contextSource.setPassword(LDAP_SEARCH_PW);
CommonFunction.setSslWithCert();
contextSource.afterPropertiesSet();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return contextSource;
}
@Override
public boolean existsWatcherByEmail(String partnerId, String email) {
return apiPartnerMapper.existsWatcherByEmail(partnerId, email) > 0 ? false : true;
}
@Override
public void insertWatcher(Map<String, Object> paramMap) {
apiPartnerMapper.insertWatcher(paramMap);
}
} | 3,722 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2UserServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/T2UserServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.api.advice.CSigninFailedException;
import oss.fosslight.api.advice.CUserNotFoundException;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.config.AppConstBean;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2Authorities;
import oss.fosslight.domain.T2Roles;
import oss.fosslight.domain.T2Users;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.T2AuthoritiesMapper;
import oss.fosslight.repository.T2RolesMapper;
import oss.fosslight.repository.T2UserMapper;
import oss.fosslight.service.FileService;
import oss.fosslight.service.T2UserService;
import oss.fosslight.util.JwtUtil;
import oss.fosslight.util.StringUtil;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
/**
* The Class T2UserServiceImpl.
*/
@Service("userService")
@Slf4j
public class T2UserServiceImpl implements T2UserService {
@Autowired Environment env;
// Service
@Autowired FileService fileService;
// Mapper
@Autowired T2UserMapper userMapper;
@Autowired T2AuthoritiesMapper authMapper;
@Autowired T2RolesMapper roleMapper;
@Autowired ProjectMapper projectMapper;
@Autowired PartnerMapper partnerMapper;
@Override
public List<T2Users> getAllUsers(T2Users t2Users) {
return userMapper.getAllUsers(t2Users);
}
@Override
public T2Users getUser(T2Users user) {
return userMapper.getUser(user);
}
@Override
public T2Users getUserAndAuthorities(T2Users user) {
user = userMapper.getUser(user);
user.setAuthoritiesList(authMapper.selectAuthoritiesByUser(user));
return user;
}
@Override
public JsonObject selectDuplicateId(String userId) {
int resultCount = userMapper.selectDuplicateId(userId);
String dupl = resultCount == 0 ? "ok" : "no";
JsonObject result = new JsonObject();
result.addProperty("result", dupl);
return result;
}
@Transactional
@Override
public int addNewUsers(T2Users t2Users) {
int result = 0;
t2Users.setCreatedDateCurrentTime();
// 1. ์ฌ์ฉ์ ๋ฑ๋ก
result = userMapper.insertUsers(t2Users);
// 2. ์ฌ์ฉ์ ๊ธฐ๋ณธ ๊ถํ ๋ถ์ฌ
// 2-1. ๊ธฐ๋ณธ ๊ถํ์ด Table์ ๋ฑ๋ก๋์ด์๋์ง ํ์ธํ์ฌ ์์ ๊ฒฝ์ฐ Insertํ๋ค.
// AppConstBean.SECURITY_ROLE_DEFAULT
T2Roles defaultRole = new T2Roles();
defaultRole.setAuthority(AppConstBean.SECURITY_ROLE_DEFAULT);
defaultRole = roleMapper.getRoles(defaultRole);
if (defaultRole== null){
defaultRole = new T2Roles();
defaultRole.setupDefaultRoleData();
roleMapper.insertRoles(defaultRole);
}
// 2-2. ์ฌ์ฉ์์ ๊ธฐ๋ณธ ๊ถํ์ ๋ฑ๋กํด์ค๋ค.
T2Authorities t2Authorities = new T2Authorities();
t2Authorities.setUserId(t2Users.getUserId());
t2Authorities.setAuthority(AppConstBean.SECURITY_ROLE_DEFAULT);
authMapper.insertAuthorities(t2Authorities);
// watcher invated ์ฌ๋ถ ์ฒดํฌ
try {
List<Project> prjList = null;
List<PartnerMaster> partnerList = null;
// List<Map<String, Object>> batList = null;
if (CommonFunction.propertyFlagCheck("menu.project.use.flag", CoConstDef.FLAG_YES)) {
// project watcher ์ด๋์ฌ๋ถ
prjList = projectMapper.getWatcherListByEmail(t2Users.getEmail());
userMapper.updateProjectWatcherUserInfo(t2Users);
}
if (CommonFunction.propertyFlagCheck("menu.partner.use.flag", CoConstDef.FLAG_YES)) {
partnerList = partnerMapper.getWatcherListByEmail(t2Users.getEmail());
userMapper.updatePartnerWatcherUserInfo(t2Users);
}
if (prjList != null) {
// ์งํ์ค์ธ ํ๋ก์ ํธ์ ๋ํด์ creator์์ธ ๋ฉ์ผ์ ๋ฐ์ก
for (Project bean : prjList) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED);
mailBean.setParamPrjId(bean.getPrjId());
mailBean.setParamUserId(t2Users.getUserId());
CoMailManager.getInstance().sendMail(mailBean);
}
}
if (partnerList != null) {
// ์งํ์ค์ธ ํ๋ก์ ํธ์ ๋ํด์ creator์์ธ ๋ฉ์ผ์ ๋ฐ์ก
for (PartnerMaster bean : partnerList) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED);
mailBean.setParamPartnerId(bean.getPartnerId());
mailBean.setParamUserId(t2Users.getUserId());
CoMailManager.getInstance().sendMail(mailBean);
}
}
// if (batList != null) {
// // ์งํ์ค์ธ ํ๋ก์ ํธ์ ๋ํด์ creator์์ธ ๋ฉ์ผ์ ๋ฐ์ก
// for (Map<String, Object> bean : batList) {
// String batId = (String) bean.get("baId");
// CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_REGISTED);
// mailBean.setParamBatId(batId);
// mailBean.setParamUserId(t2Users.getUserId());
//
// CoMailManager.getInstance().sendMail(mailBean);
// }
// }
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
@Override
public int changEnabled(T2Users t2Users) {
String enabled = t2Users.getEnabled() == "true" ? "1" : "2";
t2Users.setEnabled(enabled);
// ์ฌ์ฉ์ฌ๋ถ ๋ณ๊ฒฝ
return userMapper.changeEnabled(t2Users);
}
@Override
public int updateUsers(T2Users t2Users) {
return userMapper.updateUsers(t2Users);
}
@Override
public int modifyUserRoles(T2Users t2Users) {
// 0. ์ฌ์ฉ์ ID๊ฐ ์์ ๊ฒฝ์ฐ 0 ๋ฆฌํด
if (null == t2Users.getUserId() || t2Users.getUserId().trim().equals("")) {
return 0;
}
// 1. ์ฌ์ฉ์์ ๋ชจ๋ ์ญํ ์ญ์
authMapper.deleteAuthoritiesByUserId(t2Users);
// 2. ๋ชจ๋ ์ฌ์ฉ์๊ฐ ๊ฐ์ง๊ณ ์๋ ๊ธฐ๋ณธ ๊ถํ ์ถ๊ฐ
T2Roles defaultRole = new T2Roles();
defaultRole.setupDefaultRoleData();
T2Authorities authority = new T2Authorities();
authority.setAuthority(defaultRole.getAuthority());
authority.setUserId(t2Users.getUserId());
authMapper.insertAuthorities(authority);
// 3. ์ฌ์ฉ์์ ์ญํ 1๊ฑด์ฉ ๋ฑ๋ก
List<T2Authorities> userAuthorityList = t2Users.getAuthoritiesList();
if (null != userAuthorityList){
for (T2Authorities authorityItem: userAuthorityList){
authorityItem.setUserId(t2Users.getUserId());
authMapper.insertAuthorities(authorityItem);
}
}
return 1;
}
@SuppressWarnings("serial")
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return new UserDetails() {
@Override
public boolean isEnabled() {
return false;
}
@Override
public boolean isCredentialsNonExpired() {
return false;
}
@Override
public boolean isAccountNonLocked() {
return false;
}
@Override
public boolean isAccountNonExpired() {
return false;
}
@Override
public String getUsername() {
return null;
}
@Override
public String getPassword() {
return null;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
};
}
@Override
public String getPassword(T2Users user) {
T2Users result = userMapper.getPassword(user);
if (result != null) {
return result.getPassword();
}
return null;
}
/**
* ์ ์ ๋ชฉ๋ก ์กฐํ
*/
@Override
public Map<String,Object> getUserList(T2Users t2Users){
HashMap<String, Object> map = new HashMap<String, Object>();
int records = userMapper.selectUserTotalCount(t2Users);
t2Users.setCurPage(t2Users.getPage());
t2Users.setPageListSize(t2Users.getRows());
t2Users.setTotListSize(records);
List<T2Users> userList = new ArrayList<T2Users>();
userList = userMapper.selectParamUserList(t2Users);
map.put("page", t2Users.getPage());
map.put("total", t2Users.getTotBlockSize());
map.put("records", records);
map.put("rows", userList);
return map;
}
/**
* ์ ์ ์ ์ฅ
*/
@Override
@Transactional
public void setUser(T2Users vo) throws Exception {
vo.setCreator(vo.getUserId());
vo.setModifier(vo.getUserId());
userMapper.insertUsers(vo);
userMapper.insertAuthority(vo);
}
@Override
public void modUser(List<T2Users> vo) {
for (int i = 0;i<vo.size();i++) {
vo.get(i).setModifier(vo.get(i).getUserId());
vo.get(i).setPassword("");
if (vo.get(i).getDivision().trim().equals("")){
vo.get(i).setDivision(CoConstDef.CD_USER_DIVISION_EMPTY);
}
userMapper.updateUsers(vo.get(i));
if ("V".equals(vo.get(i).getAuthority())) {
vo.get(i).setAuthority("ROLE_ADMIN");
userMapper.updateAuthorities(vo.get(i));
} else {
vo.get(i).setAuthority("ROLE_USER");
userMapper.updateAuthorities(vo.get(i));
}
// statisticsMostUsed > div_no value update
userMapper.updateStatisticsMostUsedInfo(vo.get(i));
}
}
@Override
public List<T2Users> getAuthorityUsers(String authority) {
return userMapper.getAuthorityUsers(authority);
}
@Override
public List<T2Users> getUserListExcel() throws Exception {
List<T2Users> result = userMapper.selectUserList();
for (int i = 0; i< result.size(); i++){
String userId = result.get(i).getUserId();
String userAuth = userMapper.selectAuthority(userId);
if ("ROLE_ADMIN".equals(userAuth)){
userAuth = "V";
} else {
userAuth = "";
}
result.get(i).setAuthority(userAuth);
}
return result;
}
@Override
public boolean checkDuplicateId(T2Users vo) {
String duplicate = userMapper.checkDuplicateId(vo);
boolean result;
if ("DUPLICATE".equals(duplicate)) {
result = true;
} else {
result = false;
}
return result;
}
@Override
public List<T2Users> getReviwer() {
String ldapFlag = CoCodeManager.getCodeExpString(CoConstDef.CD_SYSTEM_SETTING, CoConstDef.CD_LDAP_USED_FLAG);
return userMapper.selectReviwer(CoConstDef.FLAG_YES, ldapFlag);
}
@Override
public List<T2Users> selectAllUsers() {
return userMapper.selectUserList();
}
@Override
public List<T2Users> getAllUsersDivision() {
return userMapper.selectAllUsersDivision();
}
@Override
public boolean checkAdAccounts(Map<String, String> userInfo, String idKey, String pwKey, String filter) {
boolean isAuthenticated = false;
String userId = (String) userInfo.get(idKey);
String userPw = (String) userInfo.get(pwKey);
String ldapDomain = CoCodeManager.getCodeExpString(CoConstDef.CD_LOGIN_SETTING, CoConstDef.CD_LDAP_DOMAIN);
try {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(CoConstDef.AD_LDAP_LOGIN.LDAP_SERVER_URL.getValue());
contextSource.setBase("OU=LGE Users,DC=LGE,DC=NET");
contextSource.setUserDn(userId+ldapDomain);
contextSource.setPassword(userPw);
CommonFunction.setSslWithCert();
contextSource.afterPropertiesSet();
if (StringUtil.isEmpty(filter)) {
filter = userId;
}
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
@SuppressWarnings({ "unchecked", "rawtypes" })
List<String[]> result = ldapTemplate.search(query().where("mail").is(filter), new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
return new String[]{(String)attrs.get("mail").get(), (String)attrs.get("displayname").get()};
}
});
if(result != null && result.size() > 0) {
isAuthenticated = true;
for(int i=0;i<result.size();i++) {
String email = result.get(i)[0];
if (!StringUtil.isEmpty(email)) {
userInfo.put("EMAIL", email);
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return isAuthenticated;
}
@Override
public List<T2Users> checkEmail(String email) {
return userMapper.selectCheckEmail(email);
}
@Override
public List<T2Users> getUserListByName(String name) {
return userMapper.getUserListByName(name);
}
/**
* Gets the login user info.
*
* @return the login user info
*/
@Override
public T2Users getLoginUserInfo() {
T2Users bean = new T2Users();
bean.setUserId(bean.getLoginUserName());
return userMapper.getUser(bean);
}
@Override
public boolean isLeavedMember(String userId) {
T2Users param = new T2Users();
param.setUserId(userId);
T2Users bean = userMapper.getUser(param);
return bean == null || CoConstDef.FLAG_NO.equals(bean.getUseYn());
}
/**
* Check api user auth.
* API ์์ฒญ์ ์ฌ์ฉ์ ID, ํจ์ค์๋ ์ธ์ฆ ์ฒ๋ฆฌ
* ์ธ์ฆ์ฑ๊ณต์ธ ๊ฒฝ์ฐ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ฐํํ๋ค.
* ์ธ์ฆ์คํจ์ธ ๊ฒฝ์ฐ ๊ฒฐ๊ณผ๋ฅผ return ํ์ง ์๊ณ Exception์ฒ๋ฆฌํ๋ค.
*
* @param id the id
* @param password the password
* @return the t 2 users
*/
@Override
public T2Users checkApiUserAuth(String _token) {
T2Users params = new T2Users();
params.setToken(_token);
params = getUser(params); // ๋ฑ๋ก๋ token ์ฌ๋ถ ํ์ธ
if (params == null) {
// ๋ฏธ๋ฑ๋ก token
throw new CUserNotFoundException();
}
// Token ์ธ์ฆ
if (checkToken(params, _token)) { // ์ถ์ถ๋ USER ์ ๋ณด๋ก ๋์ผํ token์ด ์์ฑ์ด ๋๋์ง ํ์ธ.
return getUserAndAuthorities(params);
} else {
throw new CSigninFailedException();
}
}
@Override
public T2Users changeSession(String userId) {
T2Users params = new T2Users();
params.setUserId(userId);
params = getUser(params);
if (params == null) {
throw new CUserNotFoundException();
}
return setSession(params);
}
private T2Users setSession(T2Users params) {
List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
T2Users getUser = getUserAndAuthorities(params);
for (T2Authorities auth : getUser.getAuthoritiesList()) {
roles.add(new SimpleGrantedAuthority(auth.getAuthority()));
}
Authentication authentication = new UsernamePasswordAuthenticationToken(params.getUserId(), null, roles);
SecurityContextHolder.getContext().setAuthentication(authentication);
return getUser;
}
/**
* @param T2Users
* @return success Flag
* */
@Override
@Transactional
public boolean procToken(T2Users vo) {
try {
if (CoConstDef.CD_TOKEN_CREATE_TYPE.equals(vo.getTokenType())) {
if (StringUtil.isEmpty(vo.getExpireDate())) {
vo.setExpireDate(CoConstDef.CD_TOKEN_END_DATE);
}
String expireDate = CommonFunction.removeSpecialChar(vo.getExpireDate(), 8);
JwtUtil jwt = new JwtUtil(env.getProperty("token.secret.key") + expireDate);
String tokenKey = jwt.createToken(vo.getUserId(), vo.getEmail());
vo.setToken(tokenKey);
}
if (!StringUtil.isEmpty(vo.getToken())) {
int successCnt = userMapper.procToken(vo);
return successCnt != 1 ? false : true;
}
return false;
} catch (Exception e) {
log.error(e.getMessage());
return false;
}
}
private boolean checkToken(T2Users vo, String _token) {
String expireDate = CommonFunction.removeSpecialChar(vo.getExpireDate(), 8);
JwtUtil jwt = new JwtUtil(env.getProperty("token.secret.key") + expireDate);
String tokenKey = jwt.createToken(vo.getUserId(), vo.getEmail());
return _token.equals(tokenKey);
}
public boolean checkPassword(String rawPassword, T2Users bean) {
T2Users userInfo = userMapper.getPassword(bean);
if (userInfo == null) {
return false;
}
String encPassword = userInfo.getPassword();
return rawPassword.equals(encPassword) || new BCryptPasswordEncoder().matches(rawPassword, encPassword);
}
@Override
public boolean existUserIdOrEmail(String userId) {
return userMapper.existUserIdOrEmail(userId) > 0;
}
@Override
public int updateUserNameDivision(T2Users userInfo) {
HashMap<String, Object> info = new HashMap<String, Object>();
info.put("sessUserInfo", userInfo);
SecurityContext sec = SecurityContextHolder.getContext();
AbstractAuthenticationToken auth = (AbstractAuthenticationToken)sec.getAuthentication();
auth.setDetails(info);
return userMapper.updateUserNameDivision(userInfo);
}
private Hashtable<String, String> makeLdapProperty() {
String LDAP_SEARCH_DOMAIN = CoCodeManager.getCodeExpString(CoConstDef.CD_LOGIN_SETTING, CoConstDef.CD_LDAP_DOMAIN);
String LDAP_SEARCH_ID = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_ID);
String LDAP_SEARCH_PW = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_PW);
Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put(Context.INITIAL_CONTEXT_FACTORY, CoConstDef.AD_LDAP_LOGIN.INITIAL_CONTEXT_FACTORY.getValue());
properties.put(Context.PROVIDER_URL, CoConstDef.AD_LDAP_LOGIN.LDAP_SERVER_URL.getValue());
properties.put(Context.SECURITY_AUTHENTICATION, "simple");
properties.put(Context.SECURITY_PRINCIPAL, LDAP_SEARCH_ID + LDAP_SEARCH_DOMAIN);
properties.put(Context.SECURITY_CREDENTIALS, LDAP_SEARCH_PW);
return properties;
}
private LdapContextSource makeLdapContextSource() {
String LDAP_SEARCH_DOMAIN = CoCodeManager.getCodeExpString(CoConstDef.CD_LOGIN_SETTING, CoConstDef.CD_LDAP_DOMAIN);
String LDAP_SEARCH_ID = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_ID);
String LDAP_SEARCH_PW = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_PW);
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(CoConstDef.AD_LDAP_LOGIN.LDAP_SERVER_URL.getValue());
contextSource.setBase("OU=LGE Users,DC=LGE,DC=NET");
contextSource.setUserDn(LDAP_SEARCH_ID+LDAP_SEARCH_DOMAIN);
contextSource.setPassword(LDAP_SEARCH_PW);
return contextSource;
}
public String[] checkUserInfo(T2Users userInfo) {
return checkUserInfo(userInfo, makeLdapContextSource());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private String[] checkUserInfo(T2Users userInfo, LdapContextSource contextSource) {
String[] result = new String[3];
String userId = !StringUtil.isEmptyTrimmed(userInfo.getUserId()) ? userInfo.getUserId() : userInfo.getCreator();
String ldapSearchID = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_ID);
try {
CommonFunction.setSslWithCert();
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
if(ldapTemplate.authenticate("", String.format("(cn=%s)", ldapSearchID), contextSource.getPassword())) {
List<String[]> searchResult = ldapTemplate.search(query().where("cn").is(userId), new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
return new String[]{(String)attrs.get("mail").get(), (String)attrs.get("displayname").get()};
}
});
if(searchResult != null && searchResult.size() > 0) {
int cnt = 1;
for(int i=0;i<searchResult.size();i++) {
String email = searchResult.get(i)[0];
String displayName = searchResult.get(i)[1];
if (StringUtil.isEmptyTrimmed(displayName)) {
result[0] = email.split("@")[0];
} else{
result[0] = displayName.replaceAll("\\("+email+"\\)", "").trim();
}
if (!StringUtil.isEmptyTrimmed(userInfo.getEmail())) {
if (email.equals(userInfo.getEmail().trim())) {
result[1] = email;
result[2] = String.valueOf(cnt);
break;
} else {
result[1] = "";
result[2] = String.valueOf(cnt);
}
} else {
result[1] = email;
result[2] = String.valueOf(cnt++);
}
}
}
}
return result;
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
@Override
public T2Users checkApiUserAuthAndSetSession(String _token) {
T2Users params = new T2Users();
params.setToken(_token);
params = getUser(params);
if (params == null) {
throw new CUserNotFoundException();
}
if (checkToken(params, _token)) {
List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
T2Users getUser = getUserAndAuthorities(params);
for (T2Authorities auth : getUser.getAuthoritiesList()) {
roles.add(new SimpleGrantedAuthority(auth.getAuthority()));
}
Authentication authentication = new UsernamePasswordAuthenticationToken(params.getUserId(), null, roles);
SecurityContextHolder.getContext().setAuthentication(authentication);
return getUser;
} else {
throw new CSigninFailedException();
}
}
@Override
public boolean isAdmin(String _token) {
T2Users params = new T2Users();
params.setToken(_token);
params = getUser(params);
if (params == null) {
throw new CUserNotFoundException();
}
if (params.getAuthority().equals("ROLE_ADMIN")) {
return true;
}
return false;
}
}
| 23,206 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CacheServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/CacheServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.repository.LicenseMapper;
import oss.fosslight.service.CacheService;
@Service
public class CacheServiceImpl implements CacheService {
@Autowired LicenseMapper licenseMapper;
@Override
@Cacheable(value="licenseInfoCache")
public Set<String> getLicenseNames() {
Set<String> list = licenseMapper.getLicenseNames();
list.addAll(licenseMapper.getLicenseShortNames());
list.addAll(licenseMapper.getLicenseNickNames());
return list;
}
@Override
@Cacheable(value="licenseInfoCache", key="{#licenseName}")
public LicenseMaster getLicenseInfo(String licenseName) {
return licenseMapper.getLicenseInfoWithName(licenseName);
}
@Override
@Cacheable(value="licenseInfoCache")
public Set<String> getLicenseUpperNames() {
Set<String> list = new HashSet<>();
for (String s : getLicenseNames()) {
list.add(s.toUpperCase());
}
return list;
}
@Override
@Cacheable(value="licenseInfoCache", key="{#licenseId}")
public LicenseMaster getLicenseInfoById(String licenseId) {
return licenseMapper.getLicenseInfoWithId(licenseId);
}
}
| 1,518 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
VulnerabilityHistoryServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/VulnerabilityHistoryServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.VulnerabilityHistory;
import oss.fosslight.repository.VulnerabilityHistoryMapper;
import oss.fosslight.service.VulnerabilityHistoryService;
@Service
public class VulnerabilityHistoryServiceImpl extends CoTopComponent implements VulnerabilityHistoryService {
//Mapper
@Autowired VulnerabilityHistoryMapper vulnerabilityHistoryMapper;
@Override
public Map<String, Object> getVulnerabilityHistoryList(VulnerabilityHistory vulnerabilityHistory) {
Map<String, Object> map = null;
String filterCondition = CommonFunction.getFilterToString(vulnerabilityHistory.getFilters());
if (!isEmpty(filterCondition)) {
vulnerabilityHistory.setFilterCondition(filterCondition);
}
int records = vulnerabilityHistoryMapper.selectVulnerabilityHistoryTotalCount(vulnerabilityHistory);
if (records > 0) {
vulnerabilityHistory.setTotListSize(records);
// Grid paging ์ฒ๋ฆฌ๋ฅผ ์ํ ๊ธฐ๋ณธ param ์ค์ Map ์์ฑ(๋ฐ๋์ totlistsize๋ฅผ set ํ๊ณ ๋์ ์์ฑํด์ผํจ)
map = getGridPagerMap(vulnerabilityHistory);
map.put("rows", vulnerabilityHistoryMapper.selectVulnerabilityHistoryList(vulnerabilityHistory));
}
// TODO - ๊ฒํ ํ์ํจ.
return map == null ? new HashMap<String, Object>() : map;
}
}
| 1,686 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryDataHistoryServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/BinaryDataHistoryServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.BinaryAnalysisResult;
import oss.fosslight.repository.BinaryDataHistoryMapper;
import oss.fosslight.service.BinaryDataHistoryService;
@Service
public class BinaryDataHistoryServiceImpl extends CoTopComponent implements BinaryDataHistoryService {
@Autowired BinaryDataHistoryMapper binaryDataHistoryMapper;
@Override
public Map<String, Object> getBinaryDataHistoryList(BinaryAnalysisResult bean) {
Map<String, Object> map = null;
Map<String, String> exceptionMap = new HashMap<>();
exceptionMap.put("binaryName", "fileName");
exceptionMap.put("filePath", "pathName");
exceptionMap.put("tlsh", "tlshCheckSum");
exceptionMap.put("parentname", "parentName");
exceptionMap.put("platformname", "platformName");
exceptionMap.put("platformversion", "platformVersion");
exceptionMap.put("updatedate", "updateDate");
exceptionMap.put("createddate", "createdDate");
String filterCondition = CommonFunction.getFilterToString(bean.getFilters(), null, exceptionMap);
if (!isEmpty(filterCondition)) {
bean.setFilterCondition(filterCondition);
}
int records = binaryDataHistoryMapper.selectBinaryDataHistoryTotalCount(bean);
if (records > 0) {
bean.setTotListSize(records);
map = getGridPagerMap(bean);
map.put("rows", binaryDataHistoryMapper.selectBinaryDataHistoryList(bean));
}
return map == null ? new HashMap<String, Object>() : map;
}
}
| 1,855 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
DashboardServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/DashboardServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.repository.DashboardMapper;
import oss.fosslight.repository.OssMapper;
import oss.fosslight.service.DashboardService;
@Service("DashboardService")
public class DashboardServiceImpl extends CoTopComponent implements DashboardService {
//Mapper
@Autowired DashboardMapper dashboardMapper;
@Autowired OssMapper ossMapper;
@Override
public Map<String, Object> getDashboardJobsList(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("loginUserName", loginUserName());
paramMap.put("loginUserRole", loginUserRole());
paramMap.put("projectFlag", CommonFunction.getProperty("menu.project.use.flag"));
paramMap.put("partnerFlag", CommonFunction.getProperty("menu.partner.use.flag"));
int records = dashboardMapper.selectDashboardJobsTotalCount(paramMap);
project.setTotListSize(records);
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", records);
List<Project> list = dashboardMapper.selectDashboardJobsList(paramMap);
// TODO bin ๋ณ๊ฒฝ > ???
if (list != null) {
// ์ฝ๋๋ณํ์ฒ๋ฆฌ
for (Project bean : list) {
bean.setStatus( CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_STATUS, bean.getStatus()));
// Project priority
bean.setPriority(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, bean.getPriority()));
}
}
map.put("rows", list);
return map;
}
@Override
public Map<String, Object> getDashboardCommentsList(CommentsHistory commentsHistory) {
HashMap<String, Object> map = new HashMap<String, Object>();
Map<String, Object> paramMap = new HashMap<String, Object>();
List<String> referenceDivList = new ArrayList<>();
boolean projectFlag = CommonFunction.propertyFlagCheck("menu.project.use.flag", CoConstDef.FLAG_YES);
boolean partnerFlag = CommonFunction.propertyFlagCheck("menu.partner.use.flag", CoConstDef.FLAG_YES);
if (projectFlag) {
referenceDivList.add(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
referenceDivList.add(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
referenceDivList.add(CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_HIS);
referenceDivList.add(CoConstDef.CD_DTL_COMMENT_PROJECT_HIS);
}
if (partnerFlag) {
referenceDivList.add(CoConstDef.CD_DTL_COMMENT_PARTNER_HIS);
}
paramMap.put("loginUserName", loginUserName());
paramMap.put("loginUserRole", loginUserRole());
paramMap.put("referenceDivList", referenceDivList);
int records = dashboardMapper.selectDashboardCommentsTotalCount(paramMap);
commentsHistory.setTotListSize(records);
map.put("page", commentsHistory.getCurPage());
map.put("total", commentsHistory.getTotBlockSize());
map.put("records", records);
map.put("rows", dashboardMapper.selectDashboardCommentsList(paramMap));
return map;
}
@Override
public Map<String, Object> getDashboardOssList(OssMaster ossMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
int records = dashboardMapper.selectDashboardOssTotalCount(ossMaster);
ossMaster.setTotListSize(records);
List<OssMaster> ossList = dashboardMapper.selectDashboardOssList(ossMaster);
for (OssMaster item : ossList) {
if (CoCodeManager.OSS_INFO_BY_ID.containsKey(item.getOssId())) {
item.setLicenseName(CommonFunction.makeLicenseExpression(CoCodeManager.OSS_INFO_BY_ID.get(item.getOssId()).getOssLicenses()));
}
}
map.put("page", ossMaster.getCurPage());
map.put("total", ossMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", ossList);
return map;
}
@Override
public Map<String, Object> getDashboardLicenseList(LicenseMaster licenseMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
int records = dashboardMapper.selectDashboardLicenseTotalCount(licenseMaster);
licenseMaster.setTotListSize(records);
map.put("page", licenseMaster.getCurPage());
map.put("total", licenseMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", dashboardMapper.selectDashboardLicenseList(licenseMaster));
return map;
}
@Override
public void readConfirmAll(CommentsHistory commentsHistory) {
dashboardMapper.readConfirmAll(commentsHistory);
}
}
| 5,601 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiCodeServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiCodeServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.repository.ApiCodeMapper;
import oss.fosslight.service.ApiCodeService;
@Service
public class ApiCodeServiceImpl implements ApiCodeService {
@Autowired ApiCodeMapper apiCodeMapper;
public List<Map<String, Object>> getCodeList(String codeType, String detailValue){
String cdNo = "";
switch(codeType.toUpperCase()) { // code ๋ฒํธ ๋ถ๋ฅ
case "DIV":
cdNo = CoConstDef.CD_USER_DIVISION;
break;
case "OS":
cdNo = CoConstDef.CD_OS_TYPE;
break;
case "DSTT":
cdNo = CoConstDef.CD_DISTRIBUTION_TYPE;
break;
case "DSTS":
cdNo = CoConstDef.CD_DISTRIBUTE_CODE;
break;
case "NOTI":
cdNo = CoConstDef.CD_NOTICE_TYPE;
break;
case "NP":
cdNo = CoConstDef.CD_PLATFORM_GENERATED;
break;
case "PRI":
cdNo = CoConstDef.CD_PROJECT_PRIORITY;
break;
default:
cdNo = null; // ๋์ฌ ์ ์๋ case
break;
}
return apiCodeMapper.selectCodeList(cdNo, detailValue);
}
} | 1,401 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SelfCheckServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/SelfCheckServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.apache.commons.lang.StringEscapeUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.OssNotice;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.Vulnerability;
import oss.fosslight.repository.CommentMapper;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.repository.LicenseMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.SelfCheckMapper;
import oss.fosslight.repository.T2UserMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.FileService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.SelfCheckService;
import oss.fosslight.service.VerificationService;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
@Service
@Slf4j
public class SelfCheckServiceImpl extends CoTopComponent implements SelfCheckService {
//SERVICE
@Autowired FileService fileService;
@Autowired OssService ossService;
@Autowired VerificationService verificationService;
@Autowired CommentService commentService;
//MAPPER
@Autowired ProjectMapper projectMapper;
@Autowired T2UserMapper userMapper;
@Autowired PartnerMapper partnerMapper;
@Autowired FileMapper fileMapper;
@Autowired SelfCheckMapper selfCheckMapper;
@Autowired LicenseMapper licenseMapper;
@Autowired CommentMapper commentMapper;
@Autowired Environment env;
private String JDBC_DRIVER;
private String DB_URL;
private String USERNAME;
private String PASSWORD;
@PostConstruct
public void setResourcePathPrefix(){
JDBC_DRIVER = env.getRequiredProperty("spring.datasource.driver-class-name");
DB_URL = env.getRequiredProperty("spring.datasource.url");
if (!DB_URL.startsWith("jdbc:mariadb")) DB_URL = "jdbc:mariadb://" + DB_URL;
USERNAME = env.getRequiredProperty("spring.datasource.username");
PASSWORD = env.getRequiredProperty("spring.datasource.password");
}
private static String NOTICE_PATH = CommonFunction.emptyCheckProperty("selfcheck.notice.path", "/selfcheck/notice");
private static String EXPORT_TEMPLATE_PATH = CommonFunction.emptyCheckProperty("export.template.path", "/template");
@Override
public Map<String, Object> getProjectList(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = null;
try {
int records = selfCheckMapper.selectProjectTotalCount(project);
project.setTotListSize(records);
String ossId = project.getOssId();
if (!StringUtil.isEmpty(ossId)) {
list = selfCheckMapper.selectUnlimitedOssComponentBomList(project);
} else {
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
list = selfCheckMapper.selectProjectList(project);
if (list != null) {
List<String> customNvdMaxScoreInfoList = new ArrayList<>();
// ์ฝ๋๋ณํ์ฒ๋ฆฌ
for (Project bean : list) {
// DISTRIBUTION Android Flag
// ์ด์๋ก ์ธํด android project๊ฐ ์ข๋ ์ธ๋ถํ ๋์ด android project๊ธฐ์ค์ด ๋ณ๊ฒฝ๋จ. ๋จ selfcheck์์๋ ํด๋น ๊ธฐ์ค์ด ํ์ ์์์ผ๋ก ํ๋จ์ด ๋์ด ์ฃผ์์ฒ๋ฆฌํจ.
// DISTRIBUTION_TYPE
bean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, bean.getDistributionType()));
// Project Status
bean.setStatus( CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_STATUS, bean.getStatus()));
// Identification Status
bean.setIdentificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getIdentificationStatus()));
// Verification Status
bean.setVerificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getVerificationStatus()));
// Distribute Status
bean.setDestributionStatus(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_STATUS, bean.getDestributionStatus()));
// DIVISION
bean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, bean.getDivision()));
//OS_TYPE
if ("999".equals(bean.getOsType())){
bean.setOsType(bean.getOsTypeEtc());
}else{
bean.setOsType(CoCodeManager.getCodeString(CoConstDef.CD_OS_TYPE, bean.getOsType()));
}
List<String> nvdMaxScoreInfoList = selfCheckMapper.findIdentificationMaxNvdInfo(bean.getPrjId());
List<String> nvdMaxScoreInfoList2 = selfCheckMapper.findIdentificationMaxNvdInfoForVendorProduct(bean.getPrjId());
if (nvdMaxScoreInfoList != null && !nvdMaxScoreInfoList.isEmpty()) {
String conversionCveInfo = CommonFunction.checkNvdInfoForProduct(ossInfoMap, nvdMaxScoreInfoList);
if (conversionCveInfo != null) {
customNvdMaxScoreInfoList.add(conversionCveInfo);
}
}
if (nvdMaxScoreInfoList2 != null && !nvdMaxScoreInfoList2.isEmpty()) {
customNvdMaxScoreInfoList.addAll(nvdMaxScoreInfoList2);
}
if (customNvdMaxScoreInfoList != null && !customNvdMaxScoreInfoList.isEmpty()) {
String conversionCveInfo = CommonFunction.getConversionCveInfoForList(customNvdMaxScoreInfoList);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
bean.setCvssScore(conversionCveData[3]);
bean.setCveId(conversionCveData[4]);
bean.setVulnYn(CoConstDef.FLAG_YES);
}
customNvdMaxScoreInfoList.clear();
}
}
}
}
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
} catch (Exception e) {
log.debug(e.getMessage());
}
return map;
}
@Override
public Project getProjectDetail(Project project) {
// master
project = selfCheckMapper.selectProjectMaster(project);
project.setDestributionName(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, project.getDistributionType()));
//OS_TYPE
if (!"999".equals(project.getOsType())){
project.setOsTypeEtc(CoCodeManager.getCodeString(CoConstDef.CD_OS_TYPE, project.getOsType()));
}
// watcher
List<Project> watcherList = selfCheckMapper.selectWatchersList(project);
project.setWatcherList(watcherList);
// file
project.setCsvFile(selfCheckMapper.selectCsvFile(project));
return project;
}
@Override
public Map<String, Object> getIdentificationGridList(ProjectIdentification identification) {
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
HashMap<String, Object> map = new HashMap<String, Object>();
List<ProjectIdentification> list = null;
List<String> unconfirmedLicenseList = new ArrayList<>();
identification.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
boolean isLoadFromProject = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefPrjId());
if (isLoadFromProject) {
identification.setReferenceId(identification.getRefPrjId());
}
boolean isApplyFromBat = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefBatId());
if (isApplyFromBat) {
identification.setReferenceId(identification.getRefBatId());
}
HashMap<String, Object> subMap = new HashMap<String, Object>();
list = selfCheckMapper.selectIdentificationGridList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionOssComponentList = selfCheckMapper.selectIdentificationGridList(identification);;
if (notVersionOssComponentList != null) {
list.addAll(notVersionOssComponentList);
}
identification.setOssVersionEmptyFlag(null);
list.sort(Comparator.comparing(ProjectIdentification::getComponentIdx));
if (list != null && !list.isEmpty()) {
List<String> cvssScoreMaxList = new ArrayList<>();
List<String> cvssScoreMaxVendorProductList = new ArrayList<>();
ProjectIdentification param = new ProjectIdentification();
param.setReferenceDiv(identification.getReferenceDiv());
param.setReferenceId(identification.getReferenceId());
OssMaster ossParam = new OssMaster();
// components license ์ ๋ณด๋ฅผ ํ๋ฒ์ ๊ฐ์ ธ์จ๋ค
for (ProjectIdentification bean : list) {
param.addComponentIdList(bean.getComponentId());
if (!isEmpty(bean.getOssId())) {
ossParam.addOssIdList(bean.getOssId());
}
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (isEmpty(bean.getCveId())
&& isEmpty(bean.getOssVersion())
&& !isEmpty(bean.getCvssScoreMax())
&& !("-".equals(bean.getOssName()))){
String[] cvssScoreMax = bean.getCvssScoreMax().split("\\@");
bean.setCvssScore(cvssScoreMax[0]);
bean.setCveId(cvssScoreMax[1]);
}
// convert max score
if (bean.getCvssScoreMax() != null) {
cvssScoreMaxList.add(bean.getCvssScoreMax());
}
if (bean.getCvssScoreMax1() != null) {
cvssScoreMaxVendorProductList.add(bean.getCvssScoreMax1());
}
if (bean.getCvssScoreMax2() != null) {
cvssScoreMaxList.add(bean.getCvssScoreMax2());
}
if (bean.getCvssScoreMax3() != null) {
cvssScoreMaxVendorProductList.add(bean.getCvssScoreMax3());
}
String conversionCveInfo = CommonFunction.getConversionCveInfo(bean.getReferenceId(), ossInfoMap, bean, cvssScoreMaxVendorProductList, cvssScoreMaxList, false);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
bean.setCvssScore(conversionCveData[3]);
bean.setCveId(conversionCveData[4]);
bean.setVulnYn(CoConstDef.FLAG_YES);
}
cvssScoreMaxVendorProductList.clear();
cvssScoreMaxList.clear();
}
// oss id๋ก oss master์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค ์ ๋ณด๋ฅผ ์ทจ๋
Map<String, OssMaster> componentOssInfoMap = null;
if (ossParam.getOssIdList() != null && !ossParam.getOssIdList().isEmpty()) {
componentOssInfoMap = ossService.getBasicOssInfoListById(ossParam);
}
List<ProjectIdentification> licenseList = selfCheckMapper.identificationSubGrid(param);
Map<String, List<ProjectIdentification>> reconstLicenseList = new HashMap<>();
List<ProjectIdentification> reconstAddComponentLicenseList = null;
String licenseComponentId = "";
for (ProjectIdentification liObj : licenseList) {
if (!licenseComponentId.equals(liObj.getComponentId())) {
licenseComponentId = liObj.getComponentId();
reconstAddComponentLicenseList = new ArrayList<>();
} else {
reconstAddComponentLicenseList = (List<ProjectIdentification>) reconstLicenseList.get(licenseComponentId);
}
reconstAddComponentLicenseList.add(liObj);
reconstLicenseList.put(licenseComponentId, reconstAddComponentLicenseList);
}
for (ProjectIdentification bean : list) {
if (reconstLicenseList.containsKey(bean.getComponentId())) {
List<ProjectIdentification> reconstLicense = (List<ProjectIdentification>) reconstLicenseList.get(bean.getComponentId());
if (reconstLicense != null) {
for (ProjectIdentification reLi : reconstLicense) {
bean.addComponentLicenseList(reLi);
if (!unconfirmedLicenseList.contains(avoidNull(reLi.getLicenseName()))) {
if (CoConstDef.FLAG_NO.equals(bean.getExcludeYn())
&& isEmpty(reLi.getLicenseId())) {
unconfirmedLicenseList.add(reLi.getLicenseName());
}
}
}
}
}
}
reconstLicenseList.clear();
if (reconstAddComponentLicenseList != null) reconstAddComponentLicenseList.clear();
// license ์ ๋ณด ๋ฑ๋ก
for (ProjectIdentification bean : list) {
if (bean.getComponentLicenseList()!=null){
String licenseCopy = "";
// multi dual ๋ผ์ด์ ์ค์ ๊ฒฝ์ฐ, main row์ ํ์๋๋ license ์ ๋ณด๋ OSS List์ ๋ฑ๋ก๋์ด์ง ๋ผ์ด์ ์ค๋ฅผ ๊ธฐ์ค์ผ๋ก ํ์ํ๋ค.
// ossId๊ฐ ์๋ ๊ฒฝ์ฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก subGrid๋ก ๋ฑ๋ก๋ ์ ์๋ค
// ์ด์ง๊ฑฐ๋ฆฌ๋ฅผ ํ๋ ๋๋ฒ์งธ ์ด์ ๋, subgrid ์์ ์ฌ์ฉ์๊ฐ ์ถ๊ฐํ ๋ผ์ด์ ์ค์ oss ์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํจ
if (componentOssInfoMap == null) {
componentOssInfoMap = new HashMap<>();
}
OssMaster ossBean = componentOssInfoMap.get(bean.getOssId());
if (ossBean != null
&& CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())
&& ossBean.getOssLicenses() != null && !ossBean.getOssLicenses().isEmpty()) {
for (OssLicense ossLicenseBean : ossBean.getOssLicenses()) {
if (!isEmpty(ossLicenseBean.getOssCopyright())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + ossLicenseBean.getOssCopyright();
}
//์ญ์ ๋ถ๊ฐ ์ฒ๋ฆฌ
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
// license index ๊น์ง ๋น๊ตํ๋ ์ด์ ๋
// multi dual ํผ์ฉ์ธ ๊ฒฝ์ฐ, ๋์ผํ ๋ผ์ด์ ์ค๊ฐ ๋๋ฒ ๋ฑ๋ก ๋ ์ ์๊ธฐ ๋๋ฌธ
if (ossLicenseBean.getLicenseId().equals(licenseBean.getLicenseId())
&& ossLicenseBean.getOssLicenseIdx().equals(licenseBean.getRnum())) {
licenseBean.setEditable(CoConstDef.FLAG_NO);
break;
}
}
}
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
} else {
// license text๋ ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ค์ ํ ํ์๋ ์์
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
if (!isEmpty(licenseBean.getCopyrightText())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + licenseBean.getCopyrightText();
}
}
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
}
bean.setLicenseNameExistsYn(CommonFunction.existsLicenseName(bean.getComponentLicenseList()) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
bean.setLicenseUserGuideStr(CommonFunction.checkLicenseUserGuide(bean.getComponentLicenseList()));
bean.setLicenseUserGuideYn(isEmpty(bean.getLicenseUserGuideStr()) ? CoConstDef.FLAG_NO : CoConstDef.FLAG_YES);
bean.setRestriction(CommonFunction.setLicenseRestrictionList(bean.getComponentLicenseList()));
// subGrid์ Item ์ถ์ถ์ ์ํด ๋ณ๋์ map์ผ๋ก ๊ตฌ์ฑํ๋ค.
// ๋ถ๋ชฌ์ component_id๋ฅผ key๋ก ๊ด๋ฆฌํ๋ค.
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
// ๋ค๋ฅธ ํ๋ก์ ํธ์์ loadํ ๊ฒฝ์ฐ component id ์ด๊ธฐํ
if (isLoadFromProject || isApplyFromBat) {
subMap = new HashMap<>();
// refproject id + "p" + componentid ๋ก component_id๋ฅผ ์ฌ์์ฑ ํ๊ณ ,
// license ์ ๊ฒฝ์ฐ ์ฌ์ฑ์ํ component_id + ๊ธฐ์กด license grid_id์ component_license_id ๋ถ๋ถ์ ๊ฒฐํฉ
for (ProjectIdentification bean : list) {
if (isLoadFromProject) {
bean.setRefPrjId(identification.getRefPrjId());
} else if (isApplyFromBat) {
bean.setRefBatId(identification.getRefBatId());
}
String _compId = CoConstDef.GRID_NEWROW_DEFAULT_PREFIX;
if (isLoadFromProject) {
_compId += identification.getRefPrjId();
} else if (isApplyFromBat) {
_compId += identification.getRefBatId();
}
_compId += "p" + bean.getComponentId();
bean.setComponentId("");
bean.setGridId(_compId);
if (bean.getComponentLicenseList()!=null){
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
licenseBean.setComponentId("");
licenseBean.setGridId(_compId + "-"+ licenseBean.getComponentLicenseId());
}
}
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// ํธ์ง์ค์ธ data ๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ append ํ๋ค.
{
if (identification.getMainDataGridList() != null) {
for (ProjectIdentification bean : identification.getMainDataGridList()) {
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(bean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : identification.getSubDataGridList()) {
for (ProjectIdentification comLicense : comLicenseList) {
if (bean.getComponentId().equals(comLicense.getComponentId())){
bean.addComponentLicenseList(comLicense);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
ProjectIdentification license = new ProjectIdentification();
license.setComponentId(bean.getComponentId());
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setCopyrightText(bean.getCopyrightText());
license.setExcludeYn(bean.getExcludeYn());
bean.addComponentLicenseList(license);
}
}
for (ProjectIdentification bean : identification.getMainDataGridList()) {
list.add(0, bean);
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// exclude row์ ์ฌ์ ๋ ฌ (๊ฐ์ฅ ๋ง์ง๋ง์ผ๋ก)
List<ProjectIdentification> newSortList = new ArrayList<>();
List<ProjectIdentification> excludeList = new ArrayList<>();
for (ProjectIdentification bean : list) {
if (CoConstDef.FLAG_YES.equals(bean.getExcludeYn())) {
excludeList.add(bean);
} else {
newSortList.add(bean);
}
}
newSortList.addAll(excludeList);
list = newSortList;
map.put("subData", subMap);
map.put("mainData", list);
map.put("unconfirmedLicenseList", unconfirmedLicenseList);
return map;
}
@Transactional
@Override
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
public void registProject(Project project) {
boolean isNew = isEmpty(project.getPrjId());
// admin์ด ์๋๋ผ๋ฉด creator๋ฅผ ๋ณ๊ฒฝํ์ง ์๋๋ค.
if (!CommonFunction.isAdmin()) {
project.setCreator(null);
}
// project master
selfCheckMapper.insertProjectMaster(project);
// oss notice
OssNotice noticeParam = new OssNotice();
noticeParam.setPrjId(project.getPrjId());
noticeParam.setNoticeType(avoidNull(project.getNoticeType(), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL));
if (CoConstDef.CD_NOTICE_TYPE_PLATFORM_GENERATED.equals(project.getNoticeType())) {
noticeParam.setNoticeTypeEtc(project.getNoticeTypeEtc());
}
selfCheckMapper.makeOssNotice(noticeParam);
// project watcher insert
ArrayList<Map<String, String>> divisionList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> emailList = new ArrayList<Map<String, String>>();
if (isNew) {
if (project.getWatchers()!= null) {
String[] arr;
for (String watcher : project.getWatchers()) {
Map<String, String> m = new HashMap<String, String>();
arr = watcher.split("\\/");
if (!"Email".equals(arr[1])){
project.setPrjDivision(arr[0]);
if (arr.length > 1){
project.setPrjUserId(arr[1]);
}else{
project.setPrjUserId("");
}
project.setPrjEmail("");
m.put("division", project.getPrjDivision());
m.put("userId", project.getPrjUserId());
divisionList.add(m);
}else{
project.setPrjDivision("");
project.setPrjUserId("");
project.setPrjEmail(arr[0]);
m.put("email", project.getPrjEmail());
emailList.add(m);
}
List<Project> watcherList = selfCheckMapper.selectWatchersCheck(project);
if (watcherList.size() == 0){
selfCheckMapper.insertProjectWatcher(project);
}
}
}
project.setDivisionList(divisionList);
project.setEmailList(emailList);
selfCheckMapper.deleteProjectWatcher(project);
}
}
@Transactional
@Override
@CacheEvict(value="autocompleteProjectCache", allEntries=true)
public void deleteProject(Project project) {
// project master
selfCheckMapper.deleteProjectMaster(project);
}
@Override
@Transactional
public void registSrcOss(List<ProjectIdentification> ossComponent, List<List<ProjectIdentification>> ossComponentLicense, Project project) {
registSrcOss(ossComponent, ossComponentLicense, project, CoConstDef.CD_DTL_SELF_COMPONENT_ID);
}
@Override
@Transactional
public void registSrcOss(List<ProjectIdentification> ossComponent,
List<List<ProjectIdentification>> ossComponentLicense, Project project, String refDiv) {
// ์ปดํฌ๋ํธ ๋ง์คํฐ ๋ผ์ด์ผ์ค ์ง์ฐ๊ธฐ
ProjectIdentification prj = new ProjectIdentification();
prj.setReferenceId(project.getPrjId());
prj.setReferenceDiv(refDiv);
List<OssComponents> componentId = selfCheckMapper.selectComponentId(prj);
deletePreparedStatement(componentId);
// for (int i = 0; i < componentId.size(); i++) {
// selfCheckMapper.deleteOssComponentsLicense(componentId.get(i));
// }
// ํ๊ฑด๋ ์์์ ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N์ด๋ฉด N ๊ทธ์ธ null
if (ossComponent.size()==0){
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(project.getPrjId());
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectSubStatus.setReferenceDiv(refDiv);
selfCheckMapper.updateProjectMaster(projectSubStatus);
}
ossComponent = convertOssNickName(ossComponent);
ossComponentLicense = convertLicenseNickName(ossComponentLicense);
Map<String, List<ProjectIdentification>> reconstOssComponentLicenseList = new HashMap<>();
List<ProjectIdentification> reconstAddOssComponentLicenseList = null;
String licenseComponentId = "";
for (List<ProjectIdentification> ocList : ossComponentLicense) {
for (ProjectIdentification pi : ocList) {
licenseComponentId = isEmpty(pi.getComponentId()) ? pi.getGridId() : pi.getComponentId();
reconstAddOssComponentLicenseList = new ArrayList<>();
if (reconstOssComponentLicenseList.containsKey(licenseComponentId)) {
reconstAddOssComponentLicenseList = (List<ProjectIdentification>) reconstOssComponentLicenseList.get(licenseComponentId);
}
reconstAddOssComponentLicenseList.add(pi);
reconstOssComponentLicenseList.put(licenseComponentId, reconstAddOssComponentLicenseList);
}
}
//deleteRows
List<String> deleteRows = new ArrayList<String>();
List<ProjectIdentification> updateOssComponentList = new ArrayList<>();
List<ProjectIdentification> insertOssComponentList = new ArrayList<>();
List<OssComponentsLicense> insertOssComponentLicenseList = new ArrayList<>();
String ossInfoKey = "";
int componentIdx = Integer.parseInt(selfCheckMapper.selectComponentIdx(prj));
// ์ปดํฌ๋ํธ ๋ฑ๋ก
for (int i = 0; i < ossComponent.size(); i++) {
String downloadLocation = ossComponent.get(i).getDownloadLocation();
if (downloadLocation.endsWith("/")) {
ossComponent.get(i).setDownloadLocation(downloadLocation.substring(0, downloadLocation.length()-1));
}
int componentLicenseId = 1;
//update
if (!StringUtil.contains(ossComponent.get(i).getGridId(), CoConstDef.GRID_NEWROW_DEFAULT_PREFIX)){
//ossComponents ๋ฑ๋ก
// selfCheckMapper.updateSrcOssList(ossComponent.get(i));
updateOssComponentList.add(ossComponent.get(i));
deleteRows.add(ossComponent.get(i).getComponentIdx());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossComponent.get(i).getLicenseDiv())){
if (reconstOssComponentLicenseList.containsKey(ossComponent.get(i).getComponentId())) {
List<ProjectIdentification> comLicenseList = (List<ProjectIdentification>) reconstOssComponentLicenseList.get(ossComponent.get(i).getComponentId());
for (ProjectIdentification comLicense : comLicenseList) {
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
license.setComponentLicenseId(String.valueOf(componentLicenseId));
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
// selfCheckMapper.registComponentLicense(license);
insertOssComponentLicenseList.add(license);
componentLicenseId++;
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossComponent.get(i), CoConstDef.LICENSE_DIV_SINGLE);
license.setComponentLicenseId(String.valueOf(componentLicenseId));
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
// selfCheckMapper.registComponentLicense(license);
insertOssComponentLicenseList.add(license);
}
} else { // insert
//ossComponents ๋ฑ๋ก
String exComponentId = ossComponent.get(i).getGridId();
//component_idx key
// String componentIdx = selfCheckMapper.selectComponentIdx(prj);
ossComponent.get(i).setReferenceId(project.getPrjId());
ossComponent.get(i).setReferenceDiv(refDiv);
ossComponent.get(i).setComponentIdx(String.valueOf(componentIdx));
String _componentId = ossComponent.get(i).getReferenceId() + "-" + ossComponent.get(i).getReferenceDiv() + "-" + ossComponent.get(i).getComponentIdx();
ossInfoKey = (ossComponent.get(i).getOssName() +"_"+ avoidNull(ossComponent.get(i).getOssVersion())).toUpperCase();
if (CoCodeManager.OSS_INFO_UPPER.containsKey(ossInfoKey)) {
OssMaster ossInfo = CoCodeManager.OSS_INFO_UPPER.get(ossInfoKey);
ossComponent.get(i).setObligationType(ossInfo.getObligationType());
}
// selfCheckMapper.insertSrcOssList(ossComponent.get(i));
insertOssComponentList.add(ossComponent.get(i));
deleteRows.add(String.valueOf(componentIdx));
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossComponent.get(i).getLicenseDiv())){
if (reconstOssComponentLicenseList.containsKey(exComponentId)) {
List<ProjectIdentification> comLicenseList = (List<ProjectIdentification>) reconstOssComponentLicenseList.get(exComponentId);
for (ProjectIdentification comLicense : comLicenseList) {
// null point
if (isEmpty(comLicense.getGridId())) {
continue;
}
String gridId = comLicense.getGridId().split("-")[0];
if (exComponentId.equals(comLicense.getComponentId())
|| exComponentId.equals(gridId)){
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(_componentId);
license.setComponentLicenseId(String.valueOf(componentLicenseId));
insertOssComponentLicenseList.add(license);
// selfCheckMapper.registComponentLicense(license);
}
componentLicenseId++;
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossComponent.get(i), CoConstDef.LICENSE_DIV_SINGLE);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
license.setComponentId(_componentId);
license.setComponentLicenseId(String.valueOf(componentLicenseId));
insertOssComponentLicenseList.add(license);
// selfCheckMapper.registComponentLicense(license);
}
componentIdx++;
}
}
{
updatePreparedStatement(updateOssComponentList, insertOssComponentList, insertOssComponentLicenseList);
}
{
Project _ossidUpdateParam = new Project();
_ossidUpdateParam.setPrjId(project.getPrjId());
_ossidUpdateParam.setReferenceDiv(refDiv);
selfCheckMapper.updateComponentsOssId(_ossidUpdateParam);
// license id ๋ฑ๋ก
selfCheckMapper.updateComponentsLicenseId(_ossidUpdateParam);
}
//delete
OssComponents param = new OssComponents();
param.setReferenceDiv(refDiv);
param.setReferenceId(project.getPrjId());
param.setOssComponentsIdList(deleteRows);
selfCheckMapper.deleteOssComponentsWithIds(param);
// delete file
if (project.getCsvFile() != null && project.getCsvFile().size() > 0) {
for (int i = 0; i < project.getCsvFile().size(); i++) {
selfCheckMapper.deleteFileBySeq(project.getCsvFile().get(i));
fileService.deletePhysicalFile(project.getCsvFile().get(i), "SELF");
}
}
// ํ์ผ ๋ฑ๋ก
if (!isEmpty(project.getSrcCsvFileId())){
selfCheckMapper.updateFileId(project);
if (project.getCsvFileSeq() != null) {
for (int i = 0; i < project.getCsvFileSeq().size(); i++) {
selfCheckMapper.updateFileBySeq(project.getCsvFileSeq().get(i));
}
}
}
{
// vulnerability max score๋ฅผ ์ ์ฅ
double max_cvss_score = 0;
String max_vuln_ossName = null;
String max_vuln_ossVersion = null;
List<ProjectIdentification> _ossList = selfCheckMapper.selectIdentificationGridList(prj);
if (_ossList != null) {
for (ProjectIdentification targetBean : _ossList) {
if (targetBean != null && !CoConstDef.FLAG_YES.equals(targetBean.getExcludeYn()) && !isEmpty(targetBean.getCvssScore())) {
double _currentSccore = Double.parseDouble(targetBean.getCvssScore());
if (Double.compare(_currentSccore, max_cvss_score) > 0) {
max_cvss_score = _currentSccore;
max_vuln_ossName = targetBean.getOssName();
max_vuln_ossVersion = targetBean.getOssVersion();
}
}
}
}
Project vnlnUpdBean = new Project();
if (!isEmpty(max_vuln_ossName)) {
vnlnUpdBean.setOssName(max_vuln_ossName);
vnlnUpdBean.setOssVersion(avoidNull(max_vuln_ossVersion));
if (max_vuln_ossName.contains(" ")) {
vnlnUpdBean.setOssNameTemp(max_vuln_ossName.replaceAll(" ", "_"));
}
vnlnUpdBean = selfCheckMapper.getMaxVulnByOssName(vnlnUpdBean);
}
vnlnUpdBean.setUpdVuln(CoConstDef.FLAG_YES);
vnlnUpdBean.setPrjId(project.getPrjId());
vnlnUpdBean.setModifier(vnlnUpdBean.getLoginUserName());
selfCheckMapper.updateProjectMaster(vnlnUpdBean);
}
}
private void updatePreparedStatement(List<ProjectIdentification> updateOssComponentList, List<ProjectIdentification> insertOssComponentList, List<OssComponentsLicense> insertOssComponentLicenseList) {
Connection conn = null;
PreparedStatement stmt = null;
PreparedStatement stmt2 = null;
PreparedStatement stmt3 = null;
String query = "";
try{
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
int idx = 1;
if (updateOssComponentList != null && updateOssComponentList.size() > 0) {
query = "UPDATE PRE_OSS_COMPONENTS SET OSS_ID = (CASE WHEN ? = '' THEN NULL ELSE ? END), OSS_NAME = ?, OSS_VERSION = REPLACE(?, 'N/A',''), FILE_PATH = ?, DOWNLOAD_LOCATION = ?, HOMEPAGE = ?, COPYRIGHT = ?, EXCLUDE_YN = ?, OBLIGATION_TYPE = ?"
+ " WHERE REFERENCE_ID = ? AND REFERENCE_DIV = ? AND COMPONENT_IDX = ?";
stmt = conn.prepareStatement(query);
for (ProjectIdentification item : updateOssComponentList) {
stmt.setString(1, item.getOssId());
stmt.setString(2, item.getOssId());
stmt.setString(3, item.getOssName());
stmt.setString(4, item.getOssVersion());
stmt.setString(5, item.getFilePath());
stmt.setString(6, item.getDownloadLocation());
stmt.setString(7, item.getHomepage());
stmt.setString(8, item.getCopyrightText());
stmt.setString(9, item.getExcludeYn());
stmt.setString(10, item.getObligationType());
stmt.setString(11, item.getReferenceId());
stmt.setString(12, item.getReferenceDiv());
stmt.setString(13, item.getComponentIdx());
stmt.addBatch();
stmt.clearParameters();
if ((idx % 1000) == 0) {
stmt.executeBatch();
stmt.clearBatch();
conn.commit();
}
idx++;
}
stmt.executeBatch() ;
conn.commit();
}
if (insertOssComponentList != null && insertOssComponentList.size() > 0) {
query = "INSERT INTO PRE_OSS_COMPONENTS (REFERENCE_ID, REFERENCE_DIV, COMPONENT_IDX, OSS_ID, OSS_NAME, OSS_VERSION, DOWNLOAD_LOCATION, HOMEPAGE, FILE_PATH, EXCLUDE_YN, COPYRIGHT, BINARY_NAME, BINARY_SIZE, BINARY_NOTICE, CUSTOM_BINARY_YN, REF_PARTNER_ID"
+ ", REF_PRJ_ID, REF_BAT_ID, REF_COMPONENT_ID, REPORT_FILE_ID, BAT_STRING_MATCH_PERCENTAGE, BAT_PERCENTAGE, BAT_SCORE, OBLIGATION_TYPE) "
+ "VALUES (?,?,?,(CASE WHEN ? = '' THEN NULL ELSE ? END),?, REPLACE(?, 'N/A',''),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
stmt2 = conn.prepareStatement(query);
idx = 1;
for (ProjectIdentification item : insertOssComponentList) {
stmt2.setString(1, item.getReferenceId());
stmt2.setString(2, item.getReferenceDiv());
stmt2.setString(3, item.getComponentIdx());
stmt2.setString(4, item.getOssId());
stmt2.setString(5, item.getOssId());
stmt2.setString(6, item.getOssName());
stmt2.setString(7, item.getOssVersion());
stmt2.setString(8, item.getDownloadLocation());
stmt2.setString(9, item.getHomepage());
stmt2.setString(10, item.getFilePath());
stmt2.setString(11, item.getExcludeYn());
stmt2.setString(12, item.getCopyrightText());
stmt2.setString(13, isEmpty(item.getBinaryName()) ? null : item.getBinaryName());
stmt2.setString(14, isEmpty(item.getBinarySize()) ? null : item.getBinarySize());
stmt2.setString(15, isEmpty(item.getBinaryNotice()) ? null : item.getBinaryNotice());
stmt2.setString(16, isEmpty(item.getCustomBinaryYn()) ? null : item.getCustomBinaryYn());
stmt2.setString(17, isEmpty(item.getRefPartnerId()) ? null : item.getRefPartnerId());
stmt2.setString(18, isEmpty(item.getRefPrjId()) ? null : item.getRefPrjId());
stmt2.setString(19, isEmpty(item.getRefBatId()) ? null : item.getRefBatId());
stmt2.setString(20, isEmpty(item.getRefComponentId()) ? null : item.getRefComponentId());
stmt2.setString(21, isEmpty(item.getReportFileId()) ? null : item.getReportFileId());
stmt2.setString(22, isEmpty(item.getBatStringMatchPercentage()) ? null : item.getBatStringMatchPercentage());
stmt2.setString(23, isEmpty(item.getBatPercentage()) ? null : item.getBatPercentage());
stmt2.setString(24, isEmpty(item.getBatScore()) ? null : item.getBatScore());
stmt2.setString(25, item.getObligationType());
stmt2.addBatch();
stmt2.clearParameters();
if ((idx % 1000) == 0) {
stmt2.executeBatch();
stmt2.clearBatch();
conn.commit();
}
idx++;
}
stmt2.executeBatch() ;
conn.commit();
}
if (insertOssComponentLicenseList != null && insertOssComponentLicenseList.size() > 0) {
query = "INSERT INTO PRE_OSS_COMPONENTS_LICENSE (COMPONENT_ID, COMPONENT_LICENSE_IDX, LICENSE_ID, LICENSE_NAME, COPYRIGHT_TEXT, EXCLUDE_YN) VALUES (?,?,?,?,?,'N');";
stmt3 = conn.prepareStatement(query);
idx = 1;
for (OssComponentsLicense item : insertOssComponentLicenseList) {
stmt3.setString(1, item.getComponentId());
stmt3.setString(2, item.getComponentLicenseId());
stmt3.setString(3, item.getLicenseId());
stmt3.setString(4, item.getLicenseName());
stmt3.setString(5, item.getCopyrightText());
stmt3.addBatch();
stmt3.clearParameters();
if ((idx % 1000) == 0) {
stmt3.executeBatch();
stmt3.clearBatch();
conn.commit();
}
idx++;
}
stmt3.executeBatch() ;
conn.commit();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException se) {}
try{
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException se) {}
try{
if (stmt3 != null) {
stmt3.close();
}
} catch(SQLException se) {}
if (conn != null) {
try {
conn.rollback();
conn.close();
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
} finally {
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException e) {}
try {
if (stmt2 != null) {
stmt2.close();
}
} catch(SQLException e) {}
try{
if (stmt3 != null) {
stmt3.close();
}
} catch(SQLException e) {}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e) {}
}
}
private void deletePreparedStatement(List<OssComponents> componentIdList) {
Connection conn = null;
PreparedStatement stmt = null;
String query = "DELETE FROM PRE_OSS_COMPONENTS_LICENSE WHERE COMPONENT_ID = ?";
try{
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
conn.setAutoCommit(false);
stmt = conn.prepareStatement(query);
int idx = 1;
for (OssComponents item : componentIdList) {
stmt.setString(1, item.getComponentId());
stmt.addBatch();
stmt.clearParameters();
if ((idx % 1000) == 0) {
stmt.executeBatch();
stmt.clearBatch();
conn.commit();
}
idx++;
}
stmt.executeBatch() ;
conn.commit();
} catch (Exception e) {
log.error(e.getMessage(), e);
try{
if (stmt != null) {
stmt.close();
}
} catch(SQLException e1) {}
if (conn != null) {
try {
conn.rollback();
conn.close();
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch(SQLException e) {}
try{
if (conn != null) {
conn.close();
}
} catch(SQLException e) {}
}
}
private List<ProjectIdentification> convertOssNickName(List<ProjectIdentification> ossComponentList) {
List<String> ossCheckParam = new ArrayList<>();
List<OssMaster> ossNickNameList = null;
Map<String, OssMaster> ossNickNameConvertMap = new HashMap<>();
String ossInfoKey = "";
for (ProjectIdentification bean : ossComponentList) {
String _ossName = avoidNull(bean.getOssName()).trim();
if ("N/A".equals(bean.getOssVersion())) {
bean.setOssVersion("");
}
ossInfoKey = (bean.getOssName().trim() + "_" + avoidNull(bean.getOssVersion()).trim()).toUpperCase();
OssMaster masterBean = CoCodeManager.OSS_INFO_UPPER.get(ossInfoKey);
if (masterBean != null) {
bean.setOssId(masterBean.getOssId());
bean.setOssName(masterBean.getOssName());
}
if (!isEmpty(_ossName) && !"-".equals(_ossName) && !ossCheckParam.contains(_ossName)) {
ossCheckParam.add(_ossName);
}
if (!isEmpty(ossInfoKey)) {
ossInfoKey = "";
}
}
if (!ossCheckParam.isEmpty()) {
OssMaster param = new OssMaster();
param.setOssNames(ossCheckParam.toArray(new String[ossCheckParam.size()]));
ossNickNameList = projectMapper.checkOssNickName(param);
if (ossNickNameList != null) {
for (OssMaster bean : ossNickNameList) {
ossNickNameConvertMap.put(bean.getOssNickname().toUpperCase(), bean);
}
}
}
for (ProjectIdentification bean : ossComponentList) {
if (ossNickNameConvertMap.containsKey(avoidNull(bean.getOssName()).trim().toUpperCase())) {
bean.setOssName(ossNickNameConvertMap.get(avoidNull(bean.getOssName()).trim().toUpperCase()).getOssName());
}
// license nickname ์ฒดํฌ
if (CoConstDef.LICENSE_DIV_SINGLE.equals(bean.getLicenseDiv())) {
String _licenseName = avoidNull(bean.getLicenseName()).trim();
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (_licenseName.equalsIgnoreCase(s)) {
bean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
return ossComponentList;
}
private List<List<ProjectIdentification>> convertLicenseNickName(
List<List<ProjectIdentification>> ossComponentLicenseList) {
if (ossComponentLicenseList != null) {
for (List<ProjectIdentification> licenseList : ossComponentLicenseList) {
for (ProjectIdentification licenseBean : licenseList) {
String _licenseName = avoidNull(licenseBean.getLicenseName()).trim();
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if (licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for (String s : licenseMaster.getLicenseNicknameList()) {
if (_licenseName.equalsIgnoreCase(s)) {
licenseBean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
}
return ossComponentLicenseList;
}
@Override
public List<Vulnerability> getAllVulnListWithProject(String prjId) {
// ์ฑ๋ฅ ์ด์๋ก nickname ์กฐ๊ฑด์ ๋ถ๋ฆฌํ์ฌ 2๋ฒ ์ฟผ๋ฆฌํ java ์์ merge ํ๋ ๋ฐฉ์์ผ๋ก ๋ณ๊ฒฝ
List<Vulnerability> list = new ArrayList<>();
Map<String, Vulnerability> duplCheck = new HashMap<>();
Project param = new Project();
param.setPrjId(prjId);
List<String> vulnList = selfCheckMapper.getAllVulnList(param);
List<Vulnerability> list1 = selfCheckMapper.getAllVulnListWithProject(param);
if (list1 != null) {
for (Vulnerability bean : list1) {
if (vulnList.contains(bean.getProduct())) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
}
List<Vulnerability> list2 = selfCheckMapper.getAllVulnListWithProjectByNickName(param);
if (list2 != null) {
for (Vulnerability bean : list2) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
List<Vulnerability> list3 = selfCheckMapper.getAllVulnListWithProject2(param);
if (list3 != null) {
for (Vulnerability bean : list3) {
if (vulnList.contains(bean.getProduct())) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
}
List<Vulnerability> list4 = selfCheckMapper.getAllVulnListWithProjectByNickName2(param);
if (list4 != null) {
for (Vulnerability bean : list4) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
List<Vulnerability> list5 = selfCheckMapper.getAllVulnListWithProject3(param);
if (list3 != null) {
for (Vulnerability bean : list5) {
if (vulnList.contains(bean.getProduct())) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
}
List<Vulnerability> list6 = selfCheckMapper.getAllVulnListWithProjectByNickName3(param);
if (list4 != null) {
for (Vulnerability bean : list6) {
String key = avoidNull(avoidNull(bean.getVendor()) + "_" + avoidNull(bean.getProduct()) + "_" + avoidNull(bean.getVersion()) + "_" + bean.getCveId());
if (!duplCheck.containsKey(key)) {
duplCheck.put(key, bean);
}
}
}
// sort by key
Map<String, Vulnerability> sortMap = new TreeMap<>(duplCheck);
list.addAll(sortMap.values());
return list;
}
@Override
public void addWatcher(Project project) {
if (!isEmpty(project.getPrjEmail())) {
// ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
if (selfCheckMapper.existsWatcherByEmail(project) == 0) {
// watcher ์ถ๊ฐ
selfCheckMapper.insertWatcher(project);
// email ๋ฐ์ก
// try {
// CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_SELFCHECK_PROJECT_WATCHER_INVATED);
// mailBean.setParamPrjId(project.getPrjId());
// mailBean.setParamUserId(project.getLoginUserName());
// mailBean.setParamEmail(project.getPrjEmail());
//
// CoMailManager.getInstance().sendMail(mailBean);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// }
}
} else {
// ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
if (selfCheckMapper.existsWatcherByUser(project) == 0) {
// watcher ์ถ๊ฐ
selfCheckMapper.insertWatcher(project);
}
}
}
@Override
public void removeWatcher(Project project) {
selfCheckMapper.removeWatcher(project);
}
@Override
public List<Project> copyWatcher(Project project) {
return selfCheckMapper.copyWatcher(project);
}
@Override
public boolean existsWatcher(Project project) {
boolean result = false;
int i = selfCheckMapper.existsWatcher(project);
if (i > 0){
result = true;
}
return result;
}
@Override
public OssNotice setCheckNotice(Project project) {
OssNotice notice = new OssNotice();
try {
String prjId = project.getPrjId();
notice = selectOssNoticeOne(prjId);
if (isEmpty(notice.getCompanyNameFull())
&& isEmpty(notice.getDistributionSiteUrl())
&& isEmpty(notice.getEmail())
&& isEmpty(notice.getAppended())
&& CoConstDef.FLAG_NO.equals(notice.getEditNoticeYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditCompanyYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditDistributionSiteUrlYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditEmailYn())
&& CoConstDef.FLAG_NO.equals(notice.getHideOssVersionYn())
&& CoConstDef.FLAG_NO.equals(notice.getEditAppendedYn())
&& (CoConstDef.CD_NOTICE_TYPE_GENERAL.equals(notice.getNoticeType())
|| CoConstDef.CD_NOTICE_TYPE_NA.equals(notice.getNoticeType()))){
// OSS_NOTICE์ OSS_NOTICE_NEW์ ์ ๋ณด๊ฐ ์์๊ฒฝ์ฐ default setting
notice.setEditNoticeYn(CoConstDef.FLAG_NO);
notice.setEditCompanyYn(CoConstDef.FLAG_YES);
notice.setEditDistributionSiteUrlYn(CoConstDef.FLAG_YES);
notice.setEditEmailYn(CoConstDef.FLAG_YES);
notice.setHideOssVersionYn(CoConstDef.FLAG_NO);
notice.setEditAppendedYn(CoConstDef.FLAG_NO);
notice.setPrjId(project.getPrjId());
String distributeType = avoidNull(project.getDistributeTarget(), CoConstDef.CD_DISTRIBUTE_SITE_SKS); // LGE, NA => LGE๋ก ํ๊ธฐ, SKS => SKS๋ก ํ๊ธฐํจ.
String distributeCode = CoConstDef.CD_DISTRIBUTE_SITE_SKS.equals(distributeType) ? CoConstDef.CD_NOTICE_DEFAULT_SKS : CoConstDef.CD_NOTICE_DEFAULT;
if (isEmpty(notice.getCompanyNameFull())) {
notice.setCompanyNameFull(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_FULLNAME));
}
if (isEmpty(notice.getDistributionSiteUrl())) {
notice.setDistributionSiteUrl(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_DISTRIBUTE_SITE));
}
if (isEmpty(notice.getEmail())) {
notice.setEmail(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_EMAIL));
}
if (isEmpty(notice.getAppended())){
notice.setAppended(CoCodeManager.getCodeExpString(distributeCode, CoConstDef.CD_DTL_NOTICE_DEFAULT_APPENDED));
}
} else if (CoConstDef.FLAG_YES.equals(notice.getEditNoticeYn())
&& CoConstDef.CD_NOTICE_TYPE_GENERAL.equals(notice.getNoticeType())) {
} else {
if (!isEmpty(notice.getCompanyNameFull())){
notice.setEditCompanyYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getDistributionSiteUrl())){
notice.setEditDistributionSiteUrlYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getEmail())){
notice.setEditEmailYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (!isEmpty(notice.getAppended())){
notice.setEditAppendedYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
if (CoConstDef.CD_NOTICE_TYPE_GENERAL_WITHOUT_OSS_VERSION.equals(project.getNoticeType())){
notice.setHideOssVersionYn(CoConstDef.FLAG_YES);
notice.setEditNoticeYn(CoConstDef.FLAG_YES);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return notice;
}
@Override
public OssNotice selectOssNoticeOne(String prjId) {
Project project = new Project();
project.setPrjId(prjId);
return selfCheckMapper.selectOssNoticeOne(project);
}
@Override
public List<OssComponents> getVerifyOssList(Project projectMaster) {
List<OssComponents> componentList = selfCheckMapper.selectVerifyOssList(projectMaster);
if (componentList != null && !componentList.isEmpty() && componentList.get(0) == null) {
componentList = new ArrayList<>();
}
return componentList;
}
@Override
public Map<String, Object> getVerificationOne(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
Project prj = selfCheckMapper.selectProjectMaster(project);
String comment = prj != null ? prj.getComment() : null;
String content = commentMapper.getContent(comment);
OssNotice ossNotice = selfCheckMapper.selectOssNoticeOne(project);
map.put("data", prj);
map.put("commentText", content);
map.put("notice", ossNotice);
return map;
}
@Override
public Project getProjectBasicInfo(String prjId) {
Project param = new Project();
param.setPrjId(prjId);
return selfCheckMapper.selectProjectMaster2(param);
}
@Override
public boolean getNoticeHtmlFile(OssNotice ossNotice) throws IOException {
return getNoticeHtmlFile(ossNotice, null);
}
@Override
public boolean getNoticeHtmlFile(OssNotice ossNotice, String contents) throws IOException {
Project prjInfo = getProjectBasicInfo(ossNotice.getPrjId());
// OSS Notice๊ฐ N/A์ด๋ฉด ๊ณ ์ง๋ฌธ์ ์์ฑํ์ง ์๋๋ค.
if (CoConstDef.CD_NOTICE_TYPE_NA.equals(prjInfo.getNoticeType())) {
return true;
}
prjInfo.setUseCustomNoticeYn(!isEmpty(contents) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
contents = avoidNull(contents, getNoticeHtml(ossNotice));
return getNoticeVelocityTemplateFile(contents, prjInfo);
}
@Override
public String getNoticeHtml(OssNotice ossNotice) throws IOException {
// Convert Map to Apache Velocity Template
return CommonFunction.VelocityTemplateToString(getNoticeHtmlInfo(ossNotice));
}
private boolean getNoticeVelocityTemplateFile(String contents, Project project) {
boolean procResult = true;
try {
// file path and name ์ค์
// ํ์ผ path : <upload_home>/notice/
// ํ์ผ๋ช
: ์์: ํ๋ก์ ํธID_yyyyMMdd\
String filePath = NOTICE_PATH + "/" + project.getPrjId();
// ์ด์ ์ ์์ฑ๋ ํ์ผ์ ๋ชจ๋ ์ญ์ ํ๋ค.
Path rootPath = Paths.get(filePath);
if (rootPath.toFile().exists()) {
for (String _fName : rootPath.toFile().list()) {
Files.deleteIfExists(rootPath.resolve(_fName));
T2File file = new T2File();
file.setLogiNm(_fName);
file.setLogiPath(filePath);
int returnSuccess = fileMapper.updateFileDelYnByFilePathNm(file);
if (returnSuccess > 0){
log.debug(filePath + "/" + _fName + " is delete success.");
}else{
log.debug(filePath + "/" + _fName + " is delete failed.");
}
}
}
String fileName = CommonFunction.getNoticeFileName("Self-Check_"+project.getPrjId(), project.getPrjName(), project.getPrjVersion(), CommonFunction.getCurrentDateTime("yyMMdd"), "html");
if (oss.fosslight.util.FileUtil.writeFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
String FileSeq = fileService.registFileWithFileName(filePath, fileName);
// project ์ ๋ณด ์
๋ฐ์ดํธ
Project projectParam = new Project();
projectParam.setPrjId(project.getPrjId());
projectParam.setNoticeFileId(FileSeq);
projectParam.setUseCustomNoticeYn(StringUtil.nvl(project.getUseCustomNoticeYn(),CoConstDef.FLAG_NO));
selfCheckMapper.updateNoticeFileInfo(projectParam);
} else {
procResult = false;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
procResult = false;
}
return procResult;
}
public Map<String, Object> getNoticeHtmlInfo(OssNotice ossNotice) {
Map<String, Object> model = new HashMap<String, Object>();
String noticeType = "";
String prjName = "";
String prjVersion = "";
String prjId = "";
String distributeSite = "";
int dashSeq = 0;
boolean hideOssVersionFlag = CoConstDef.FLAG_YES.equals(ossNotice.getHideOssVersionYn());
// NETWORK SERVER ์ฌ๋ถ๋ฅผ ์ฒดํฌํ๋ค.
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = selfCheckMapper.getProjectBasicInfo(project);
if (project != null){
if (isEmpty(prjName)) {
prjName = project.getPrjName();
}
if (isEmpty(prjId)) {
prjId = project.getPrjId();
}
if (isEmpty(prjVersion)) {
prjVersion = project.getPrjVersion();
}
if (isEmpty(distributeSite)) {
distributeSite = project.getDistributeTarget();
}
}
List<OssComponents> ossComponentList = selfCheckMapper.selectVerificationNotice(ossNotice);
// TYPE๋ณ ๊ตฌ๋ถ
Map<String, OssComponents> noticeInfo = new HashMap<>();
Map<String, OssComponents> srcInfo = new HashMap<>();
Map<String, OssComponentsLicense> licenseInfo = new HashMap<>();
Map<String, List<String>> componentCopyright = new HashMap<>();
Map<String, List<String>> componentAttribution = new HashMap<>();
OssComponents ossComponent;
String ossInfoUpperKey = "";
for (OssComponents bean : ossComponentList) {
ossInfoUpperKey = (bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase();
if (CoCodeManager.OSS_INFO_UPPER.containsKey(ossInfoUpperKey) && isEmpty(bean.getHomepage())) {
bean.setHomepage(CoCodeManager.OSS_INFO_UPPER.get(ossInfoUpperKey).getHomepage());
}
String componentKey = (hideOssVersionFlag
? bean.getOssName()
: bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
// type
boolean isDisclosure = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType());
// 2017.05.16 add by yuns start
// obligation์ ํน์ ํ ์ ์๋ oss๋ bom์ merge ๋๋๋ก ์์ ํ๋ฉด์, identification confirm์ refDiv๊ฐ '50'(๊ณ ์ง๋์)์ obligation์ ํน์ ํ ์ ์๋ oss๋ ํฌํจ๋์ด ๋ฑ๋ก๋์ด
// confirm ์ฒ๋ฆฌ์์ obligation์ด ๊ณ ์ง์๋ฌด๊ฐ ์๊ฑฐ๋ ์์ค์ฝ๋ ๊ณต๊ฐ์๋ฌด๊ฐ ์๋ ๊ฒฝ์ฐ๋ง '50'์ผ๋ก copy๋๋๋ก ์์ ํ์์ผ๋, ์ฌ๊ธฐ์ ํ๋ฒ๋ ํํฐ๋งํจ
boolean isNotice = CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType());
if (!isDisclosure && !isNotice) {
continue;
}
// 2017.07.05
// Accompanied with source code ์ ๊ฒฝ์ฐ
// ์์ค๊ณต๊ฐ์ฌ๋ถ์ ์๊ด์์ด ๋ชจ๋ ์์ค๊ณต๊ฐ๊ฐ ํ์ํ oss table์ ํ์
if (CoConstDef.CD_DTL_NOTICE_TYPE_ACCOMPANIED.equals(ossNotice.getNoticeType())) {
isDisclosure = true;
}
// 2017.05.16 add by yuns end
boolean addDisclosure = isDisclosure && srcInfo.containsKey(componentKey);
boolean addNotice = !isDisclosure && noticeInfo.containsKey(componentKey);
if (addDisclosure) {
ossComponent = srcInfo.get(componentKey);
} else if (addNotice) {
ossComponent = noticeInfo.get(componentKey);
} else {
ossComponent = bean;
}
if (hideOssVersionFlag) {
List<String> copyrightList = componentCopyright.containsKey(componentKey)
? (List<String>) componentCopyright.get(componentKey)
: new ArrayList<>();
List<String> attributionList = componentAttribution.containsKey(componentKey)
? (List<String>) componentAttribution.get(componentKey)
: new ArrayList<>();
if (!isEmpty(bean.getCopyrightText())) {
for (String copyright : bean.getCopyrightText().split("\n")) {
copyrightList.add(copyright);
}
}
if (!isEmpty(bean.getOssAttribution())) {
attributionList.add(bean.getOssAttribution());
}
// ๋ผ์ด์ ์ค ์ ๋ณด ์์ฑ
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
}
String ossCopyright = findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright());
// multi license ์ถ๊ฐ copyright
if (!isEmpty(ossCopyright)) {
for (String copyright : ossCopyright.split("\n")) {
copyrightList.add(copyright);
}
}
// ์ค๋ณต์ ๊ฑฐ
copyrightList = copyrightList.stream()
.filter(CommonFunction.distinctByKey(c -> avoidNull(c).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setCopyrightText(String.join("\r\n", copyrightList));
componentCopyright.put(componentKey, copyrightList);
attributionList = attributionList.stream()
.filter(CommonFunction.distinctByKey(a -> avoidNull(a).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setOssAttribution(String.join("\r\n", attributionList));
componentAttribution.put(componentKey, attributionList);
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(license.getLicenseName(), license);
}
} else {
// ๋ผ์ด์ ์ค ์ ๋ณด ์์ฑ
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
// ํ๋์ oss์ ๋ํด์ ๋์ผํ LICENSE๊ฐ ๋ณต์ ํ์๋๋ ํ์
// ์ผ๋จ ์ฌ๊ธฐ์ ๋ง๋๋ค. (์ฟผ๋ฆฌ๊ฐ ์๋ชป๋ ๊ฑด์ง, DATA๊ฐ ๊ผฌ์ด๋๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์)
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
// OSS์ Copyright text๋ฅผ ์์ ํ์์์๋ Packaging > Notice Preview์ ์
๋ฐ์ดํธ ์ ๋จ.
// MULTI LICENSE๋ฅผ ๊ฐ์ง๋ oss์ ๊ฐ๋ณ๋ก ์ถ๊ฐ๋ copyright์ ๊ฒฝ์ฐ, Identification Confirm์์ DB์ ์
๋ฐ์ดํธํ ์ ๋ณด๋ฅผ ๊ธฐ์ค์ผ๋ก ์ถ์ถ๋๊ธฐ ๋๋ฌธ์, preview ๋จ๊ณ์์ ์ค๋ฅ๊ฐ ๋ฐ๊ฒฌ๋์ด ์์ ํ์ฌ๋ ๋ฐ์๋์ง ์๋๋ค
// verification๋จ๊ณ์์์ oss_component_license๋ oss_license์ license๋ฑ๋ก ์๋ฒ์ ๊ฐ์ง๊ณ ์์ง ์๊ธฐ ๋๋ฌธ์ (exclude๋ license๋ ์ด๊ดํ์ง ์์)
// ์ฌ๊ธฐ์ oss id์ license id๋ฅผ ์ด์ฉํ์ฌ ์ฐพ๋๋ค.
// ๋์ดํ ๋ผ์ด์ ์ค๋ฅผ or ๊ตฌ๋ถ์ผ๋ก ์ฌ๋ฌ๋ฒ ์ ์ํ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ ์ ์์ผ๋, ๋์ผํ oss์ ๋์ผํ license์ ๊ฒฝ์ฐ ๊ฐ์ copyright๋ฅผ ์ถ๊ฐํ๋ค๋ ์ ์ ํ์ ์ ์ฉํจ (์ด๋ถ๋ถ์์ ์ถ๊ฐ์ ์ธ ์ด์๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ ๋์๋ฐฉ๋ฒ์ด ๋ณต์กํด์ง)
bean.setOssCopyright(findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright()));
// multi license ์ถ๊ฐ copyright
if (!isEmpty(bean.getOssCopyright())) {
String addCopyright = avoidNull(ossComponent.getCopyrightText());
if (!isEmpty(ossComponent.getCopyrightText())) {
addCopyright += "\r\n";
}
addCopyright += bean.getOssCopyright();
ossComponent.setCopyrightText(addCopyright);
}
}
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(license.getLicenseName(), license);
}
}
}
// copyleft์ ์กด์ฌํ ๊ฒฝ์ฐ notice์์๋ ์ถ๋ ฅํ์ง ์๊ณ copyleft๋ก mergeํจ.
if (hideOssVersionFlag) {
Map<String, OssComponents> hideOssVersionMergeNoticeInfo = new HashMap<>();
Set<String> noticeKeyList = noticeInfo.keySet();
for (String key : noticeKeyList) {
if (!srcInfo.containsKey(key)) {
hideOssVersionMergeNoticeInfo.put(key, noticeInfo.get(key));
}
}
noticeInfo = hideOssVersionMergeNoticeInfo;
}
// CLASS ํ์ผ๋ง ๋ฑ๋กํ ๊ฒฝ์ฐ ๋ผ์ด์ ์ค ์ ๋ณด๋ง ์ถ๊ฐํ๋ค.
// OSS NAME์ ํ์ดํ ('-') ์ผ๋ก ๋ฑ๋กํ ๊ฒฝ์ฐ (๊ณ ์ง๋ฌธ๊ตฌ์ ๋ผ์ด์ ์ค๋ง ์ถ๊ฐ)
List<OssComponents> addOssComponentList = selfCheckMapper.selectVerificationNoticeClassAppend(ossNotice);
if (addOssComponentList != null) {
ossComponent = null;
Map<String, List<String>> addOssComponentCopyright = new HashMap<>();
for (OssComponents bean : addOssComponentList) {
String componentKey = (hideOssVersionFlag
? bean.getOssName()
: bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
List<String> copyrightList = addOssComponentCopyright.containsKey(componentKey)
? (List<String>) addOssComponentCopyright.get(componentKey)
: new ArrayList<>();
if (!isEmpty(bean.getCopyrightText())) {
for (String copyright : bean.getCopyrightText().split("\n")) {
copyrightList.add(copyright);
}
}
boolean addSrcInfo = srcInfo.containsKey(componentKey);
boolean addNoticeInfo = noticeInfo.containsKey(componentKey);
if (addSrcInfo) {
ossComponent = srcInfo.get(componentKey);
} else if (addNoticeInfo) {
ossComponent = noticeInfo.get(componentKey);
} else {
ossComponent = bean;
}
if ("-".equals(bean.getOssName()) || !CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(bean.getOssName().toUpperCase())
|| !CoCodeManager.OSS_INFO_UPPER.containsKey((bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase())) {
if (!isEmpty(bean.getDownloadLocation()) && isEmpty(bean.getHomepage())) {
ossComponent.setHomepage(bean.getDownloadLocation());
}
}
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
}
copyrightList = copyrightList.stream()
.filter(CommonFunction.distinctByKey(c -> avoidNull(c).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setCopyrightText(String.join("\r\n", copyrightList));
addOssComponentCopyright.put(componentKey, copyrightList);
switch(CommonFunction.checkObligationSelectedLicense(ossComponent.getOssComponentsLicense())){
case CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE:
if (hideOssVersionFlag) {
if (!srcInfo.containsKey(componentKey)) {
srcInfo.put(componentKey, ossComponent);
}
} else {
srcInfo.put(componentKey, ossComponent);
}
break;
case CoConstDef.CD_DTL_OBLIGATION_NOTICE:
if (hideOssVersionFlag) {
if (!noticeInfo.containsKey(componentKey)) {
noticeInfo.put(componentKey, ossComponent);
}
} else {
noticeInfo.put(componentKey, ossComponent);
}
break;
}
if (!licenseInfo.containsKey(license.getLicenseName())) {
licenseInfo.put(componentKey, license);
}
}
}
boolean isTextNotice = "text".equals(ossNotice.getFileType());
Map<String, String> ossAttributionMap = new HashMap<>();
// ๊ฐํ์ฒ๋ฆฌ ๋ฐ velocity์ฉ list ์์ฑ
List<OssComponents> noticeList = new ArrayList<>();
List<String> deduplicationList = new ArrayList<>();
for (OssComponents bean : noticeInfo.values()) {
String key = (bean.getOssName() + "_" + bean.getOssVersion() + "_" + bean.getLicenseName() + "_" + bean.getCopyrightText()).toUpperCase();
if (deduplicationList.contains(key)) continue;
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
noticeList.add(bean);
deduplicationList.add(key);
}
Collections.sort(noticeList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> srcList = new ArrayList<>();
for (OssComponents bean : srcInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
srcList.add(bean);
}
Collections.sort(srcList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponentsLicense> licenseList = new ArrayList<>();
List<OssComponentsLicense> licenseListUrls = new ArrayList<>(); //simple version์ฉ
List<OssComponentsLicense> attributionList = new ArrayList<>();
List<String> ossAttributionList = new ArrayList<>();
// ์ ๋ ฌ
TreeMap<String, OssComponentsLicense> licenseTreeMap = new TreeMap<>( licenseInfo );
for (OssComponentsLicense bean : licenseTreeMap.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
}
// ๋ฐฐํฌ์ฌ์ดํธ license text url
licenseList.add(bean);
if (CoConstDef.FLAG_YES.equals(ossNotice.getSimpleNoticeFlag())) {
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_BY_ID.get(bean.getLicenseId());
if (licenseBean != null) {
// String simpleLicenseFileName = !isEmpty(licenseBean.getShortIdentifier()) ? licenseBean.getShortIdentifier() : licenseBean.getLicenseNameTemp();
// String distributeUrl = CoCodeManager.getCodeExpString(CoConstDef.CD_DISTRIBUTE_CODE, CoConstDef.CD_DTL_DISTRIBUTE_LGE);
// simpleLicenseFileName = simpleLicenseFileName.replaceAll(" ", "_").replaceAll("/", "_") + ".html";
// distributeUrl += "/license/" + simpleLicenseFileName;
boolean distributionFlag = CommonFunction.propertyFlagCheck("distribution.use.flag", CoConstDef.FLAG_YES);
licenseBean.setDomain(ossNotice.getDomain());
bean.setWebpage(CommonFunction.makeLicenseInternalUrl(licenseBean, distributionFlag));
licenseListUrls.add(bean);
}
}
if (!isEmpty(bean.getAttribution())) {
bean.setAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getAttribution()))));
attributionList.add(bean);
}
}
TreeMap<String, String> ossAttributionTreeMap = new TreeMap<>( ossAttributionMap );
ossAttributionList.addAll(ossAttributionTreeMap.values());
// ๋ฐฐํฌ ์ฌ์ดํธ ๊ตฌ๋ถ์ ๋ฐ๋ผ ์ฐธ์กฐ ์ฝ๋๊ฐ ๋ฌ๋ผ์ง
String noticeInfoCode = CoConstDef.CD_DTL_DISTRIBUTE_SKS.equals(avoidNull(distributeSite, CoConstDef.CD_DTL_DISTRIBUTE_LGE)) ? CoConstDef.CD_NOTICE_DEFAULT_SKS : CoConstDef.CD_NOTICE_DEFAULT;
noticeType = avoidNull(ossNotice.getNoticeType(), CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL);
String companyNameFull = ossNotice.getCompanyNameFull();
String distributionSiteUrl = ossNotice.getDistributionSiteUrl();
String email = ossNotice.getEmail();
String appendedContentsTEXT = ossNotice.getAppendedTEXT();
String appendedContents = ossNotice.getAppended();
if (!isEmpty(distributionSiteUrl) && !(distributionSiteUrl.startsWith("http://") || distributionSiteUrl.startsWith("https://") || distributionSiteUrl.startsWith("ftp://"))) {
distributionSiteUrl = "http://" + distributionSiteUrl;
}
model.put("noticeType", noticeType);
model.put("noticeTitle", CommonFunction.getNoticeFileName("Self-Check_"+prjId, prjName, prjVersion, CommonFunction.getCurrentDateTime("yyMMdd"), ossNotice.getFileType()));
model.put("companyNameFull", companyNameFull);
model.put("distributionSiteUrl", distributionSiteUrl);
model.put("email", email);
model.put("noticeObligationSize", noticeList.size());
model.put("disclosureObligationSize", srcList.size());
model.put("noticeObligationList", noticeList);
model.put("disclosureObligationList", srcList);
/* ui ๊ฐ์ ๋ฒ์ ์ผ๋ก ์ ๊ท ์ถ๊ฐ๋ flag */
model.put("editNoticeYn", ossNotice.getEditNoticeYn());
model.put("editCompanyYn", ossNotice.getEditCompanyYn());
model.put("editDistributionSiteUrlYn", ossNotice.getEditDistributionSiteUrlYn());
model.put("editEmailYn", ossNotice.getEditEmailYn());
model.put("hideOssVersionYn", ossNotice.getHideOssVersionYn());
model.put("editAppendedYn", ossNotice.getEditAppendedYn());
/*//ui ๊ฐ์ ๋ฒ์ ์ผ๋ก ์ ๊ท ์ถ๊ฐ๋ flag */
if (CoConstDef.FLAG_YES.equals(ossNotice.getSimpleNoticeFlag())) {
model.put("licenseListUrls", licenseListUrls);
} else {
model.put("licenseList", licenseList);
}
model.put("attributionList", attributionList.isEmpty() ? null : attributionList);
model.put("ossAttributionList", ossAttributionList.isEmpty() ? null : ossAttributionList);
if ("text".equals(ossNotice.getFileType())){
model.put("appended", avoidNull(appendedContentsTEXT, "").replaceAll(" ", " "));
} else {
model.put("appended", appendedContents);
}
if ("text".equals(ossNotice.getFileType())){
model.put("templateURL", CoCodeManager.getCodeExpString(noticeInfoCode, CoConstDef.CD_DTL_SELFCHECK_NOTICE_TEXT_TEMPLATE));
} else {
model.put("templateURL", CoCodeManager.getCodeExpString(noticeInfoCode, CoConstDef.CD_DTL_SELFCHECK_NOTICE_DEFAULT_TEMPLATE));
}
model.put("addOssComponentList", addOssComponentList);
model.put("isSimpleNotice", avoidNull(ossNotice.getIsSimpleNotice(), CoConstDef.FLAG_NO));
return model;
}
private boolean checkLicenseDuplicated(List<OssComponentsLicense> ossComponentsLicense, OssComponentsLicense license) {
if (ossComponentsLicense != null) {
if (!isEmpty(license.getLicenseId())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseId().equals(license.getLicenseId())) {
return true;
}
}
} else if (isEmpty(license.getLicenseId()) && !isEmpty(license.getLicenseName())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseName().equals(license.getLicenseName())) {
return true;
}
}
}
}
return false;
}
public int allowDownloadMultiFlagToBitFlag(Project project) {
int bitFlag = 1;
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadNoticeHTMLYn())) {
bitFlag |= CoConstDef.FLAG_A;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadNoticeTextYn())) {
bitFlag |= CoConstDef.FLAG_B;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleHTMLYn())) {
bitFlag |= CoConstDef.FLAG_C;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSimpleTextYn())) {
bitFlag |= CoConstDef.FLAG_D;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXSheetYn())) {
bitFlag |= CoConstDef.FLAG_E;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXRdfYn())) {
bitFlag |= CoConstDef.FLAG_F;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXTagYn())) {
bitFlag |= CoConstDef.FLAG_G;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXJsonYn())) {
bitFlag |= CoConstDef.FLAG_H;
}
if (CoConstDef.FLAG_YES.equals(project.getAllowDownloadSPDXYamlYn())) {
bitFlag |= CoConstDef.FLAG_I;
}
return bitFlag;
}
private String findAddedOssCopyright(String ossId, String licenseId, String ossCopyright) {
if (!isEmpty(ossId) && !isEmpty(licenseId)) {
OssMaster bean = CoCodeManager.OSS_INFO_BY_ID.get(ossId);
if (bean != null) {
for (OssLicense license : bean.getOssLicenses()) {
if (licenseId.equals(license.getLicenseId()) && !isEmpty(license.getOssCopyright())) {
return license.getOssCopyright();
}
}
}
}
return ossCopyright;
}
@Override
public String getNoticeHtmlFileForPreview(OssNotice ossNotice) throws IOException {
Project prjInfo = getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag());
}
private String getNoticeVelocityTemplateFileForPreview(String contents, Project project, String fileType, String simpleFlag) throws IOException {
return getNoticeVelocityTemplateFileForPreview(contents, project, fileType, simpleFlag, false);
}
private String getNoticeVelocityTemplateFileForPreview(String contents, Project project, String fileType, String simpleFlag, boolean isConfirm) throws IOException {
String fileId = "";
String filePath = "";
String fileName = "";
// Text ํ์ OSS ๊ณ ์ง๋ฌธ ์์ฑ ์ ๊ฐํ๋ฌธ์ ๋ณ๊ฒฝ
// System.getProperty("line.separator") => "\n" => "\r\n" ๋ณ๊ฒฝ
String line = "\r\n";
if (fileType == "text"){
fileId = "";
filePath = NOTICE_PATH + ( isConfirm ? "/" : "/preview/") + project.getPrjId();
fileName = (CoConstDef.FLAG_YES.equals(simpleFlag) ? "simple_" : "") + CommonFunction.getNoticeFileName("Self-Check_"+project.getPrjId(), project.getPrjName(), project.getPrjVersion(), ( isConfirm ? CommonFunction.getCurrentDateTime("yyMMdd") : DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN) ), fileType);
contents = contents.replace("\n", line).replace(",)", ")").replace("<br>", line).replace("©", "ยฉ").replace(""", "\"").replace("<", "<").replace(">", ">").replace("'", "\'");
} else {
fileId = "";
filePath = NOTICE_PATH + ( isConfirm ? "/" : "/preview/") + project.getPrjId();
fileName = (CoConstDef.FLAG_YES.equals(simpleFlag) ? "simple_" : "") + CommonFunction.getNoticeFileName("Self-Check_"+project.getPrjId(), project.getPrjName(), project.getPrjVersion(), ( isConfirm ? CommonFunction.getCurrentDateTime("yyMMdd") : DateUtil.getCurrentDateTime(DateUtil.DATE_HMS_PATTERN) ), fileType);
// custom edit๋ฅผ ์ฌ์ฉํ๊ณ , packaging confirm ์ธ ๊ฒฝ์ฐ ์ด๋ฉด์ simple์ธ ๊ฒฝ์ฐ
// license text ๋ถ๋ถ๋ง ๋ค์ ๋ณ๊ฒฝํ๋ค.
if (isConfirm && CoConstDef.FLAG_YES.equals(simpleFlag) && CoConstDef.FLAG_YES.equals(project.getUseCustomNoticeYn())) {
// ์ด๋ฏธ ์์ฑ๋ ๊ณ ์ง๋ฌธ๊ตฌ ํ์ผ์ ๋ด์ฉ์ ๊ฐ์ ธ์จ๋ค.
T2File defaultNoticeFileInfo = fileService.selectFileInfo(project.getNoticeFileId());
if (defaultNoticeFileInfo != null) {
File noticeFile = new File(defaultNoticeFileInfo.getLogiPath() + "/" + defaultNoticeFileInfo.getLogiNm());
if (noticeFile.exists()) {
Document doc = Jsoup.parse(noticeFile, "UTF8");
Document doc2 = Jsoup.parse(contents);
doc.select("body > p.bdTop.license").remove();
doc.select("body").append(doc2.select("body > p.bdTop.license").toString());
doc.select("body").append(doc2.select("body > ul.bdTop2.license").toString());
contents = doc.toString();
}
}
}
}
if (FileUtil.writeFile(filePath, fileName, contents)) {
// ํ์ผ ๋ฑ๋ก
fileId = fileService.registFileDownload(filePath, fileName, fileName);
}
return fileId;
}
@Override
public String getNoticeTextFileForPreview(OssNotice ossNotice) throws IOException {
Project prjInfo = getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag());
}
@Override
public String getNoticeTextFileForPreview(OssNotice ossNotice, boolean isConfirm) throws IOException {
Project prjInfo = getProjectBasicInfo(ossNotice.getPrjId());
return getNoticeVelocityTemplateFileForPreview(getNoticeHtml(ossNotice), prjInfo, ossNotice.getFileType(), ossNotice.getSimpleNoticeFlag(), isConfirm);
}
@Override
@Transactional
public void registOssNotice(OssNotice ossNotice) throws Exception {
if (CoConstDef.FLAG_YES.equals(ossNotice.getEditNoticeYn())){
selfCheckMapper.insertOssNotice(ossNotice);
} else {
selfCheckMapper.updateOssNotice(ossNotice);
}
}
@Override
public List<OssComponents> setMergeGridData(List<OssComponents> gridData) {
List<OssComponents> tempData = new ArrayList<OssComponents>();
List<OssComponents> resultGridData = new ArrayList<OssComponents>();
String groupColumn = "";
final Comparator<OssComponents> comp = Comparator.comparing((OssComponents o) -> o.getOssName()+"|"+o.getOssVersion());
gridData = gridData.stream().sorted(comp).collect(Collectors.toList());
for (OssComponents info : gridData) {
if (isEmpty(groupColumn)) {
groupColumn = info.getOssName() + "-" + info.getOssVersion();
}
if (groupColumn.equals(info.getOssName() + "-" + info.getOssVersion()) // ๊ฐ์ groupColumn์ด๋ฉด ๋ฐ์ดํฐ๋ฅผ ์์
&& !("-".equals(info.getOssName())
&& !"NA".equals(info.getLicenseType()))) { // ๋จ, OSS Name: - ์ด๋ฉด์, License Type: Proprietary์ด ์๋ ๊ฒฝ์ฐ Row๋ฅผ ํฉ์น์ง ์์.
tempData.add(info);
} else { // ๋ค๋ฅธ grouping
setMergeData(tempData, resultGridData);
groupColumn = info.getOssName() + "-" + info.getOssVersion();
tempData.clear();
tempData.add(info);
}
}
setMergeData(tempData, resultGridData);
return resultGridData;
}
public static void setMergeData(List<OssComponents> tempData, List<OssComponents> resultGridData){
if (tempData.size() > 0) {
Collections.sort(tempData, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents o1, OssComponents o2) {
if (o1.getLicenseName().length() >= o2.getLicenseName().length()) {
return 1;
}else {
return -1;
}
}
});
OssComponents rtnBean = null;
for (OssComponents temp : tempData) {
if (rtnBean == null) {
rtnBean = temp;
continue;
}
String key = temp.getOssName() + "-" + temp.getLicenseType();
if ("--NA".equals(key)) {
if (!rtnBean.getLicenseName().contains(temp.getLicenseName())) {
resultGridData.add(rtnBean);
rtnBean = temp;
continue;
}
}
for (String licenseName : temp.getLicenseName().split(",")) {
boolean equalFlag = false;
for (String rtnLicenseName : rtnBean.getLicenseName().split(",")) {
if (rtnLicenseName.equals(licenseName)) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
rtnBean.setLicenseName(rtnBean.getLicenseName() + "," + licenseName);
}
}
}
resultGridData.add(rtnBean);
}
}
@SuppressWarnings("unchecked")
@Override
public History work(Object param) {
// ๋ฏธ์ฌ์ฉ
return new History();
}
@Override
public boolean existProjectData(Project project){
int result = selfCheckMapper.selectDuplicatedProject(project);
return result > 0 ? true : false;
}
@Override
public Map<String, Object> getExportDataForSBOMInfo(OssNotice ossNotice) {
Map<String, Object> model = new HashMap<String, Object>();
String prjName = "";
String prjVersion = "";
String prjId = "";
String distributeSite = "";
int dashSeq = 0;
Project project = new Project();
project.setPrjId(ossNotice.getPrjId());
project = selfCheckMapper.getProjectBasicInfo(project);
if (project != null){
if (isEmpty(prjName)) {
prjName = project.getPrjName();
}
if (isEmpty(prjId)) {
prjId = project.getPrjId();
}
if (isEmpty(prjVersion)) {
prjVersion = project.getPrjVersion();
}
if (isEmpty(distributeSite)) {
distributeSite = project.getDistributeTarget();
}
}
List<OssComponents> ossComponentList = selfCheckMapper.selectVerificationNotice(ossNotice);
// TYPE๋ณ ๊ตฌ๋ถ
Map<String, OssComponents> noticeInfo = new HashMap<>();
Map<String, OssComponents> srcInfo = new HashMap<>();
Map<String, OssComponents> notObligationInfo = new HashMap<>();
OssComponents ossComponent;
String ossInfoUpperKey = "";
for (OssComponents bean : ossComponentList) {
if (bean.getOssName().isEmpty() || isEmpty(bean.getLicenseName())) continue;
ossInfoUpperKey = (bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase();
if (CoCodeManager.OSS_INFO_UPPER.containsKey(ossInfoUpperKey) && isEmpty(bean.getHomepage())) {
bean.setHomepage(CoCodeManager.OSS_INFO_UPPER.get(ossInfoUpperKey).getHomepage());
}
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
boolean isDisclosure = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType());
boolean isNotice = CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType());
if (CoConstDef.CD_DTL_NOTICE_TYPE_ACCOMPANIED.equals(ossNotice.getNoticeType())) {
isDisclosure = true;
}
boolean addDisclosure = srcInfo.containsKey(componentKey);
boolean addNotice = noticeInfo.containsKey(componentKey);
boolean addNotObligation = notObligationInfo.containsKey(componentKey);
if (addDisclosure) {
ossComponent = srcInfo.get(componentKey);
} else if (addNotice) {
ossComponent = noticeInfo.get(componentKey);
} else if (addNotObligation) {
ossComponent = notObligationInfo.get(componentKey);
} else {
ossComponent = bean;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
bean.setOssCopyright(findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright()));
if (!isEmpty(bean.getOssCopyright())) {
String addCopyright = avoidNull(ossComponent.getCopyrightText());
if (!isEmpty(ossComponent.getCopyrightText())) {
addCopyright += "\r\n";
}
addCopyright += bean.getOssCopyright();
ossComponent.setCopyrightText(addCopyright);
}
}
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else if (isNotice) {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
} else {
if (addNotObligation) {
notObligationInfo.replace(componentKey, ossComponent);
} else {
notObligationInfo.put(componentKey, ossComponent);
}
}
}
List<OssComponents> addOssComponentList = selfCheckMapper.selectVerificationNoticeClassAppend(ossNotice);
if (addOssComponentList != null) {
ossComponent = null;
Map<String, List<String>> addOssComponentCopyright = new HashMap<>();
for (OssComponents bean : addOssComponentList) {
if (isEmpty(bean.getLicenseName())) continue;
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
List<String> copyrightList = addOssComponentCopyright.containsKey(componentKey)
? (List<String>) addOssComponentCopyright.get(componentKey)
: new ArrayList<>();
if (!isEmpty(bean.getCopyrightText())) {
for (String copyright : bean.getCopyrightText().split("\n")) {
copyrightList.add(copyright);
}
}
boolean addSrcInfo = srcInfo.containsKey(componentKey);
boolean addNoticeInfo = noticeInfo.containsKey(componentKey);
boolean addNotObligationInfo = notObligationInfo.containsKey(componentKey);
if (addSrcInfo) {
ossComponent = srcInfo.get(componentKey);
} else if (addNoticeInfo) {
ossComponent = noticeInfo.get(componentKey);
} else if (addNotObligationInfo) {
ossComponent = notObligationInfo.get(componentKey);
} else {
ossComponent = bean;
}
if ("-".equals(bean.getOssName()) || !CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(bean.getOssName().toUpperCase())
|| !CoCodeManager.OSS_INFO_UPPER.containsKey((bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase())) {
if (!isEmpty(bean.getDownloadLocation()) && isEmpty(bean.getHomepage())) {
ossComponent.setHomepage(bean.getDownloadLocation());
}
}
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
}
copyrightList = copyrightList.stream()
.filter(CommonFunction.distinctByKey(c -> avoidNull(c).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setCopyrightText(String.join("\r\n", copyrightList));
addOssComponentCopyright.put(componentKey, copyrightList);
boolean disclosureFlag = false;
boolean noticeFlag = false;
switch(CommonFunction.checkObligationSelectedLicense(ossComponent.getOssComponentsLicense())){
case CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE:
srcInfo.put(componentKey, ossComponent);
disclosureFlag = true;
break;
case CoConstDef.CD_DTL_OBLIGATION_NOTICE:
noticeInfo.put(componentKey, ossComponent);
noticeFlag = true;
break;
}
if (!disclosureFlag && !noticeFlag) {
notObligationInfo.put(componentKey, ossComponent);
}
}
}
boolean isTextNotice = "text".equals(ossNotice.getFileType());
Map<String, String> ossAttributionMap = new HashMap<>();
// ๊ฐํ์ฒ๋ฆฌ ๋ฐ velocity์ฉ list ์์ฑ
List<OssComponents> noticeList = new ArrayList<>();
List<String> deduplicationList = new ArrayList<>();
for (OssComponents bean : noticeInfo.values()) {
String key = (bean.getOssName() + "_" + bean.getOssVersion() + "_" + bean.getLicenseName() + "_" + bean.getCopyrightText()).toUpperCase();
if (deduplicationList.contains(key)) continue;
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
noticeList.add(bean);
deduplicationList.add(key);
}
Collections.sort(noticeList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> srcList = new ArrayList<>();
for (OssComponents bean : srcInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
srcList.add(bean);
}
Collections.sort(srcList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> notObligationList = new ArrayList<>();
for (OssComponents bean : notObligationInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
notObligationList.add(bean);
}
Collections.sort(notObligationList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
model.put("noticeObligationList", noticeList);
model.put("disclosureObligationList", srcList);
model.put("notObligationList", notObligationList);
model.put("addOssComponentList", addOssComponentList);
return model;
}
@Override
public Map<String, Object> checkSelectDownloadFile(Project project) {
Map<String, Object> resMap = new HashMap<>();
boolean emptyCheckFlag = false;
List<OssComponents> list = selfCheckMapper.checkSelectDownloadFile(project);
for (OssComponents oss : list) {
if (isEmpty(oss.getOssName()) || isEmpty(oss.getLicenseName())) {
emptyCheckFlag = true;
break;
}
}
if (emptyCheckFlag) {
resMap.put("isValid", false);
} else {
resMap.put("isValid", true);
}
return resMap;
}
@Override
public boolean checkUserPermissions(Project project, String userId) {
boolean checkFlag = false;
if (project.getWatcherList() != null) {
for (Project prj : project.getWatcherList()) {
if (prj.getPrjUserId().equals(userId)) {
checkFlag = true;
break;
}
}
}
if (project.getCreator().equals(userId)) {
checkFlag = true;
}
return checkFlag;
}
}
| 100,717 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SearchServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/SearchServiceImpl.java | /*
* Copyright (c) 2021 Suram Kim
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.SearchType;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.Vulnerability;
import oss.fosslight.repository.SearchMapper;
import oss.fosslight.service.LicenseService;
import oss.fosslight.service.SearchService;
import oss.fosslight.util.StringUtil;
@Service
@Slf4j
public class SearchServiceImpl extends CoTopComponent implements SearchService {
@Autowired LicenseService licenseService;
@Autowired SearchMapper searchMapper;
@Override
public void saveOssSearchFilter(OssMaster ossMaster, String userId) {
String stringjson = new Gson().toJson(ossMaster);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.OSS.getName());
}
@Override
public OssMaster getOssSearchFilter(String userId) {
String filterString = searchMapper.selectOssSearchFilter(userId);
if (filterString == null) {
return null;
}
return new Gson().fromJson(filterString, OssMaster.class);
}
@Override
public void saveProjectSearchFilter(Project project, String userId) {
String stringjson = new Gson().toJson(project);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.PROJECT.getName());
}
@Override
public Project getProjectSearchFilter(String userId) {
String filterString = searchMapper.selectProjectSearchFilter(userId);
if (filterString == null) {
return null;
}
return (Project) makeSearchFilterObject(filterString, SearchType.PROJECT.getName());
}
@SuppressWarnings("unchecked")
private Object makeSearchFilterObject(String filterString, String searchType) {
Object obj = new Object();
ObjectMapper mapper = new ObjectMapper();
Map<String, String> map = new HashMap<>();
try {
map = mapper.readValue(filterString, Map.class);
} catch (JsonProcessingException e) {
log.error(e.getMessage());
}
if (searchType.equals(SearchType.PROJECT.getName())) {
Project project = new Project();
for (String key : map.keySet()) {
String value = map.get(key);
if (!isEmpty(value)) {
switch (key) {
case "prjId" : project.setPrjId(value);
break;
case "prjName" : project.setPrjName(value);
break;
case "schStartDate" : project.setSchStartDate(value);
break;
case "schEndDate" : project.setSchEndDate(value);
break;
case "prjDivision" : project.setPrjDivision(value);
break;
case "creator" : project.setCreator(value);
break;
case "reviewer" : project.setReviewer(value);
break;
case "watchers" : project.setWatchers(new String[] {value});
break;
case "distributionType" : project.setDistributionType(value);
break;
case "networkServerType" : project.setNetworkServerType(value);
break;
case "modelName" : project.setModelName(value );
break;
case "statuses" : project.setStatuses(value);
break;
case "priority" : project.setPriority(value);
break;
case "publicYn" : project.setPublicYn(value);
break;
default : break;
}
}
}
obj = project;
} else {
PartnerMaster partner = new PartnerMaster();
for (String key : map.keySet()) {
String value = map.get(key);
if (!isEmpty(value)) {
switch (key) {
case "partnerId" : partner.setPartnerId(value);
break;
case "partnerName" : partner.setPartnerName(value);
break;
case "softwareName" : partner.setSoftwareName(value);
break;
case "softwareVersion" : partner.setSoftwareVersion(value);
break;
case "division" : partner.setDivision(value);
break;
case "createdDate1" : partner.setCreatedDate1(value);
break;
case "createdDate2" : partner.setCreatedDate2(value);
break;
case "creator" : partner.setCreator(value);;
break;
case "reviewer" : partner.setReviewer(value);
break;
case "watchers" : partner.setWatchers(new String[] {value});
break;
case "status" : partner.setStatus(value);
break;
case "publicYn" : partner.setPublicYn(value);
break;
default : break;
}
}
}
obj = partner;
}
return obj;
}
@Override
public void saveLicenseSearchFilter(LicenseMaster licenseMaster, String userId) {
try {
if (isEmpty(licenseMaster.getLicenseNameAllSearchFlag())) {
licenseMaster.setLicenseNameAllSearchFlag(CoConstDef.FLAG_NO);
}
licenseMaster.setTotListSize(licenseService.selectLicenseMasterTotalCount(licenseMaster));
} catch(Exception e) {
log.error(e.getMessage(), e);
}
String stringjson = new Gson().toJson(licenseMaster);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.LICENSE.getName());
}
@Override
public LicenseMaster getLicenseSearchFilter(String userId) {
String filterString = searchMapper.selectLicenseSearchFilter(userId);
if (filterString == null) {
return null;
}
return new Gson().fromJson(filterString, LicenseMaster.class);
}
@Override
public void saveSelfCheckSearchFilter(Project project, String userId) {
String stringjson = new Gson().toJson(project);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.SELF_CHECK.getName());
}
@Override
public Project getSelfCheckSearchFilter(String userId) {
String filterString = searchMapper.selectSelfCheckSearchFilter(userId);
if (filterString == null) {
return null;
}
return new Gson().fromJson(filterString, Project.class);
}
@Override
public void savePartnerSearchFilter(PartnerMaster partnerMaster, String userId) {
String stringjson = new Gson().toJson(partnerMaster);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.THIRD_PARTY.getName());
}
@Override
public void saveVulnerabilitySearchFilter(Vulnerability vulnerability, String userId) {
String stringjson =new Gson().toJson(vulnerability);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.VULNERABILITY.getName());
}
@Override
public PartnerMaster getPartnerSearchFilter(String userId) {
String filterString = searchMapper.selectPartnerSearchFilter(userId);
if (filterString == null) {
return null;
}
return (PartnerMaster) makeSearchFilterObject(filterString, SearchType.THIRD_PARTY.getName());
}
@Override
public Object getSearchFilter(String type, String userId) {
String jsonString = searchMapper.selectSearchFilter(type, userId);
Class<?> resultClass = null;
if (!StringUtil.isBlank(jsonString)) {
switch (SearchType.valueOf(type)) {
case LICENSE:
resultClass = LicenseMaster.class;
break;
case OSS:
resultClass = OssMaster.class;
break;
case PROJECT:
resultClass = Project.class;
break;
case THIRD_PARTY:
resultClass = PartnerMaster.class;
break;
case SELF_CHECK:
resultClass = Project.class;
break;
}
} else{
return null;
}
if (SearchType.valueOf(type).equals(SearchType.PROJECT)) {
return makeSearchFilterObject(jsonString, SearchType.PROJECT.getName());
} else if (SearchType.valueOf(type).equals(SearchType.THIRD_PARTY)) {
return makeSearchFilterObject(jsonString, SearchType.THIRD_PARTY.getName());
} else {
return new Gson().fromJson(jsonString, resultClass);
}
}
@Override
public void saveSearchFilter(Map<String, Object> params, String userId) {
String type = (String)params.get("defaultSearchType");
params.remove("defaultSearchType");
switch (SearchType.valueOf(type)) {
case LICENSE:
case OSS:
params.put("defaultSearchFlag", hasSearchCondition(params));
break;
default:
break;
}
String stringjson = new Gson().toJson(params);
searchMapper.upsertSearchFilter(stringjson, userId, SearchType.valueOf(type).getName());
}
private String hasSearchCondition(Map<String, Object> params) {
for (Object obj : params.values()) {
if (obj instanceof String) {
if (!StringUtil.isEmpty((String)obj)) {
return "Y";
}
}
}
return "N";
}
@Override
public History work(Object param) {
return null;
}
}
| 9,619 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
PartnerServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/PartnerServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.History;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.PartnerWatcher;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.T2Users;
import oss.fosslight.validation.custom.T2CoProjectValidator;
import oss.fosslight.repository.CommentMapper;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.service.FileService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.PartnerService;
import oss.fosslight.service.ProjectService;
import oss.fosslight.util.StringUtil;
import oss.fosslight.validation.T2CoValidationResult;
@Service
@Slf4j
public class PartnerServiceImpl extends CoTopComponent implements PartnerService {
// Service
@Autowired ProjectService projectService;
@Autowired FileService fileService;
@Autowired OssService ossService;
// Mapper
@Autowired PartnerMapper partnerMapper;
@Autowired CommentMapper commentMapper;
@Autowired FileMapper fileMapper;
@Autowired ProjectMapper projectMapper;
@Override
@Cacheable(value="autocompletePartnerCache", key="{#root.methodName, #partnerMaster?.creator, #partnerMaster?.status}")
public List<PartnerMaster> getPartnerNameList(PartnerMaster partnerMaster) {
return partnerMapper.getPartnerNameList(partnerMaster);
}
@Override
public PartnerMaster getPartnerMasterOne(PartnerMaster partnerMaster) {
PartnerMaster result = new PartnerMaster();
//ํํธ๋ ๋ง์คํฐ
result = partnerMapper.selectPartnerMaster(partnerMaster);
result.setCommentText(commentMapper.getContent(result.getComment()));
//ํํธ๋ ์์ณ
List<PartnerWatcher> watcher = partnerMapper.selectPartnerWatcher(partnerMaster);
if (watcher != null){
result.setPartnerWatcher(watcher);
}
String partnerId = "3rd_" + result.getPartnerId();
int resultCnt = partnerMapper.getOssAnalysisDataCnt(partnerId);
if (resultCnt > 0) {
PartnerMaster analysisStatus = partnerMapper.getOssAnalysisData(partnerId);
result.setAnalysisStartDate(analysisStatus.getAnalysisStartDate());
result.setOssAnalysisStatus(analysisStatus.getOssAnalysisStatus());
}
return result;
}
@Override
@Transactional
public Map<String, Object> getPartnerMasterList(PartnerMaster partnerMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
int records = partnerMapper.selectPartnerMasterTotalCount(partnerMaster);
partnerMaster.setTotListSize(records);
List<PartnerMaster> list = partnerMapper.selectPartnerList(partnerMaster);
if (list != null) {
Map<String, OssMaster> ossInfoMap = CoCodeManager.OSS_INFO_UPPER;
List<String> customNvdMaxScoreInfoList = new ArrayList<>();
for (PartnerMaster bean : list) {
List<String> nvdMaxScoreInfoList = projectMapper.findIdentificationMaxNvdInfo(bean.getPartnerId(), CoConstDef.CD_DTL_COMPONENT_PARTNER);
List<String> nvdMaxScoreInfoList2 = projectMapper.findIdentificationMaxNvdInfoForVendorProduct(bean.getPartnerId(), CoConstDef.CD_DTL_COMPONENT_PARTNER);
if (nvdMaxScoreInfoList != null && !nvdMaxScoreInfoList.isEmpty()) {
String conversionCveInfo = CommonFunction.checkNvdInfoForProduct(ossInfoMap, nvdMaxScoreInfoList);
if (conversionCveInfo != null) {
customNvdMaxScoreInfoList.add(conversionCveInfo);
}
}
if (nvdMaxScoreInfoList2 != null && !nvdMaxScoreInfoList2.isEmpty()) {
customNvdMaxScoreInfoList.addAll(nvdMaxScoreInfoList2);
}
if (customNvdMaxScoreInfoList != null && !customNvdMaxScoreInfoList.isEmpty()) {
String conversionCveInfo = CommonFunction.getConversionCveInfoForList(customNvdMaxScoreInfoList);
if (conversionCveInfo != null) {
String[] conversionCveData = conversionCveInfo.split("\\@");
bean.setCvssScore(conversionCveData[3]);
bean.setCveId(conversionCveData[4]);
bean.setVulnYn(CoConstDef.FLAG_YES);
}
customNvdMaxScoreInfoList.clear();
}
}
}
map.put("page", partnerMaster.getCurPage());
map.put("total", partnerMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
@Transactional
public Map<String, Object> getPartnerStatusList(PartnerMaster partnerMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
int records = 0;
List<PartnerMaster> list = new ArrayList<PartnerMaster>();
records = partnerMapper.selectPartnerStatusTotalCountUser(partnerMaster);
partnerMaster.setTotListSize(records);
list = partnerMapper.selectPartnerStatusUser(partnerMaster);
map.put("page", partnerMaster.getCurPage());
map.put("total", partnerMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
@Cacheable(value="autocompletePartnerCache", key="{#root.methodName, #partnerMaster?.creator, #partnerMaster?.status}")
public List<PartnerMaster> getPartnerSwNmList(PartnerMaster partnerMaster) {
List<PartnerMaster> partnerList = partnerMapper.getPartnerSwNmList(partnerMaster);
return partnerList;
}
@Override
public List<T2Users> getUserList(T2Users t2Users) {
List<T2Users> result = new ArrayList<T2Users>();
result = partnerMapper.getUserList(t2Users);
return result;
}
@Override
@CacheEvict(value="autocompletePartnerCache", allEntries=true)
public int updateReviewer(PartnerMaster vo) {
int result = 0;
result = partnerMapper.updateReviewer(vo);
return result;
}
@Override
public History work(Object param) {
History h = new History();
PartnerMaster vo = (PartnerMaster) param;
PartnerMaster data = getPartnerMasterOne(vo);
h.sethKey(data.getPartnerId());
h.sethTitle(data.getPartnerName());
h.sethType(CoConstDef.EVENT_CODE_PARTNER);
h.setModifier(data.getCreator());
h.setModifiedDate(data.getCreatedDate());
h.sethComment("");
h.sethData(data);
return h;
}
@Override
public List<PartnerMaster> getPartnerDuplication(PartnerMaster partner) {
return partnerMapper.selectPartnerDuplication(partner);
}
@Override
@Transactional
@CacheEvict(value="autocompletePartnerCache", allEntries=true)
public void registPartnerMaster(PartnerMaster partnerMaster, List<ProjectIdentification> ossComponents, List<List<ProjectIdentification>> ossComponentsLicense) {
//ํํธ๋ ๋ง์คํฐ ํ
์ด๋ธ
if (partnerMaster.getPartnerId() != null) {
// admin์ด ์๋๋ผ๋ฉด creator๋ฅผ ๋ณ๊ฒฝํ์ง ์๋๋ค.
if (!CommonFunction.isAdmin()) {
partnerMaster.setCreator(null);
}
} else {
partnerMaster.setCreator(partnerMaster.getLoginUserName());
}
boolean isNew = isEmpty(partnerMaster.getPartnerId());
partnerMaster.setModifier(partnerMaster.getLoginUserName());
partnerMaster.setCreatedDateCurrentTime();
partnerMaster.setModifiedDate(partnerMaster.getCreatedDate());
partnerMaster.setPublicYn(avoidNull(partnerMaster.getPublicYn(), CoConstDef.FLAG_YES));
partnerMapper.registPartnerMaster(partnerMaster);
String[] delDocumentsFile = partnerMaster.getDelDocumentsFile().split(",");
if (delDocumentsFile.length > 0){
for (String fileSeq : delDocumentsFile){
if (!isEmpty(fileSeq)) {
T2File delFile = new T2File();
delFile.setFileSeq(fileSeq);
delFile.setGubn("A");
fileMapper.updateFileDelYnKessan(delFile);
fileService.deletePhysicalFile(delFile, "PARTNER");
}
}
}
PartnerMaster beforePartner = partnerMapper.selectPartnerMaster(partnerMaster);
if (beforePartner != null) {
if (!isEmpty(beforePartner.getConfirmationFileId())) {
if (partnerMaster.getConfirmationFileId() == null || !partnerMaster.getConfirmationFileId().equals(beforePartner.getConfirmationFileId())) {
T2File delFile = new T2File();
delFile.setFileSeq(beforePartner.getConfirmationFileId());
fileService.deletePhysicalFile(delFile, "PARTNER");
}
}
if (!isEmpty(beforePartner.getOssFileId())) {
if (partnerMaster.getOssFileId() == null || !partnerMaster.getOssFileId().equals(beforePartner.getOssFileId())) {
T2File delFile = new T2File();
delFile.setFileSeq(beforePartner.getOssFileId());
fileService.deletePhysicalFile(delFile, "PARTNER");
}
}
}
//delete License
ProjectIdentification deleteparam = new ProjectIdentification();
deleteparam.setReferenceId(partnerMaster.getPartnerId());
deleteparam.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
List<OssComponents> componentsId = projectMapper.selectComponentId(deleteparam);
for (int j = 0; j < componentsId.size(); j++){
projectMapper.deleteOssComponentsLicense(componentsId.get(j));
}
ossComponents = projectService.convertOssNickName(ossComponents);
ossComponentsLicense = projectService.convertLicenseNickName(ossComponentsLicense);
for (ProjectIdentification bean : ossComponents) {
bean.setObligationType(bean.getObligationLicense());
bean.setBomWithAndroidFlag(CoConstDef.FLAG_YES);
if (CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK.equals(bean.getObligationLicense())) {
if (CoConstDef.FLAG_YES.equals(bean.getSource())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
} else if (CoConstDef.FLAG_YES.equals(bean.getNotify())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
} else if (CoConstDef.FLAG_NO.equals(bean.getNotify()) && CoConstDef.FLAG_NO.equals(bean.getSource())) {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK_SELECTED);
} else {
bean.setObligationType(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK);
}
}
}
//oss insert
//deleteRows
List<String> deleteRows = new ArrayList<String>();
Project prjParam = new Project();
prjParam.setReferenceDiv("20");
prjParam.setReferenceId(partnerMaster.getPartnerId());
int ossComponentIdx = projectMapper.selectOssComponentMaxIdx(prjParam);
// ์ปดํฌ๋ํธ ๋ฑ๋ก
for (int i = 0; i < ossComponents.size(); i++) {
ProjectIdentification bean = ossComponents.get(i);
// oss_id๋ฅผ ๋ค์ ์ฐพ๋๋ค. (oss name๊ณผ oss id๊ฐ ์ผ์นํ์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ ์ ์์)
bean = CommonFunction.findOssIdAndName(bean);
if (isEmpty(bean.getOssId())) {
bean.setOssId(null);
}
String downloadLocationUrl = bean.getDownloadLocation();
String homepageUrl = bean.getHomepage();
if (!isEmpty(downloadLocationUrl)) {
if (downloadLocationUrl.endsWith("/")) {
bean.setDownloadLocation(downloadLocationUrl.substring(0, downloadLocationUrl.length()-1));
}
}
if (!isEmpty(homepageUrl)) {
if (homepageUrl.endsWith("/")) {
bean.setHomepage(homepageUrl.substring(0, homepageUrl.length()-1));
}
}
//update
if (!StringUtil.contains(bean.getGridId(), CoConstDef.GRID_NEWROW_DEFAULT_PREFIX)){
//ossComponents ๋ฑ๋ก
projectMapper.updateSrcOssList(bean);
deleteRows.add(bean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if ("M".equals(bean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : ossComponentsLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (bean.getComponentId().equals(comLicense.getComponentId())){
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(comLicense.getComponentId());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(comLicense.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(comLicense.getLicenseName()));
} else {
license.setLicenseId(comLicense.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(comLicense.getLicenseName());
license.setLicenseText(comLicense.getLicenseText());
license.setCopyrightText(comLicense.getCopyrightText());
license.setExcludeYn(avoidNull(comLicense.getExcludeYn(), CoConstDef.FLAG_NO));
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(bean.getComponentId());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(bean.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(bean.getLicenseName()));
} else {
license.setLicenseId(bean.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setCopyrightText(bean.getCopyrightText());
license.setExcludeYn(CoConstDef.FLAG_NO);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
} else { //insert
//ossComponents ๋ฑ๋ก
String exComponentId = bean.getGridId();
bean.setReferenceId(partnerMaster.getPartnerId());
bean.setReferenceDiv("20");
bean.setComponentIdx(Integer.toString(ossComponentIdx++));
projectMapper.insertSrcOssList(bean);
deleteRows.add(bean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if ("M".equals(bean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : ossComponentsLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
String gridId = comLicense.getGridId();
if (isEmpty(gridId)) {
continue;
}
gridId = gridId.split("-")[0];
if (exComponentId.equals(comLicense.getComponentId())
|| exComponentId.equals(gridId)){
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(projectMapper.selectLastComponent());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(comLicense.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(comLicense.getLicenseName()));
} else {
license.setLicenseId(comLicense.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(comLicense.getLicenseName());
license.setLicenseText(comLicense.getLicenseText());
license.setCopyrightText(comLicense.getCopyrightText());
license.setExcludeYn(comLicense.getExcludeYn());
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = new OssComponentsLicense();
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(projectMapper.selectLastComponent());
// ๋ผ์ด์ผ์ค ID ์ค์
if (StringUtil.isEmpty(bean.getLicenseId())) {
license.setLicenseId(CommonFunction.getLicenseIdByName(bean.getLicenseName()));
} else {
license.setLicenseId(bean.getLicenseId());
}
// ๊ธฐํ ์ค์
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setCopyrightText(bean.getCopyrightText());
license.setExcludeYn(CoConstDef.FLAG_NO);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
{
PartnerMaster _ossidUpdateParam = new PartnerMaster();
_ossidUpdateParam.setPartnerId(partnerMaster.getPartnerId());
partnerMapper.updateComponentsOssId(_ossidUpdateParam);
}
//delete
OssComponents param = new OssComponents();
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
param.setReferenceId(partnerMaster.getPartnerId());
param.setOssComponentsIdList(deleteRows);
projectMapper.deleteOssComponentsWithIds(param);
// delete and insert
if (isNew) {
// partner watcher insert
ArrayList<Map<String, String>> divisionList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> emailList = new ArrayList<Map<String, String>>();
if (partnerMaster.getWatchers()!= null) {
String[] arr;
for (String watcher : partnerMaster.getWatchers()) {
Map<String, String> m = new HashMap<String, String>();
arr = watcher.split("\\/");
if (!"Email".equals(arr[1])) {
partnerMaster.setParDivision(arr[0]);
if (arr.length > 1){
partnerMaster.setParUserId(arr[1]);
}else{
partnerMaster.setParUserId("");
}
partnerMaster.setParEmail("");
m.put("division", partnerMaster.getParDivision());
m.put("userId", partnerMaster.getParUserId());
divisionList.add(m);
} else {
partnerMaster.setParDivision("");
partnerMaster.setParUserId("");
partnerMaster.setParEmail(arr[0]);
m.put("email", partnerMaster.getParEmail());
emailList.add(m);
}
List<PartnerMaster> watcherList = partnerMapper.selectWatchersCheck(partnerMaster);
if (watcherList.size() == 0){
partnerMapper.registPartnerWatcher(partnerMaster);
}
}
}
partnerMaster.setDivisionList(divisionList);
partnerMaster.setEmailList(emailList);
partnerMapper.deleteWatcher(partnerMaster);
}
}
@Override
@CacheEvict(value="autocompletePartnerCache", allEntries=true)
public void deletePartnerMaster(PartnerMaster partnerMaster) {
//partnerMaster
partnerMapper.deleteMaster(partnerMaster);
//partnerWatcher
partnerMapper.deleteWatcher(partnerMaster);
//partnerComment
CommentsHistory param = new CommentsHistory();
param.setReferenceId(partnerMaster.getPartnerId());
param.setReferenceDiv("20");
commentMapper.deleteCommentByReferenceId(param);
//ossComponents
List<OssComponents> componentId = partnerMapper.selectComponentId(partnerMaster.getPartnerId());
for (int i = 0; i<componentId.size(); i++){
partnerMapper.deleteOssComponentsLicense(componentId.get(i));
}
partnerMapper.deleteOssComponents(partnerMaster.getPartnerId());
}
@Override
@Transactional
public void updatePartnerConfirm(PartnerMaster partnerMaster) {
// oss id ๋ฑ๋ก
Project project = new Project();
project.setPrjId(partnerMaster.getPartnerId());
project.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
projectMapper.updateComponentsOssId(project);
// license id ๋ฑ๋ก
projectMapper.updateComponentsLicenseId(project);
projectMapper.updateComponentsLicenseInfo(project);
// ์ํ ๋ณ๊ฒฝ
changeStatus(partnerMaster, false);
}
@Override
@CacheEvict(value="autocompletePartnerCache", allEntries=true)
public void changeStatus(PartnerMaster partnerMaster, boolean isCoReviewer) {
CoMail mailBean = null;
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(partnerMaster.getStatus())) {
PartnerMaster orgPartnerMaster = partnerMapper.selectPartnerMaster(partnerMaster);
if (isEmpty(orgPartnerMaster.getReviewer()) && !isCoReviewer) {
partnerMaster.setReviewer(partnerMaster.getLoginUserName());
mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_CHANGED);
mailBean.setToIds(new String[] {partnerMaster.getLoginUserName()});
mailBean.setParamPartnerId(partnerMaster.getPartnerId());
}
}
partnerMapper.changeStatus(partnerMaster);
if (mailBean != null) {
try {
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
@Override
@Cacheable(value="autocompletePartnerCache", key="{#root.methodName, #partnerMaster?.creator, #partnerMaster?.status}")
public List<PartnerMaster> getPartnerSwVerList(PartnerMaster partnerMaster) {
return partnerMapper.getPartnerSwVerList(partnerMaster);
}
@Override
public String checkViewOnly(String partnerId) {
String rtnFlag = CoConstDef.FLAG_NO;
if (!CommonFunction.isAdmin()) {
PartnerMaster param = new PartnerMaster();
param.setPartnerId(partnerId);
if (partnerMapper.checkWatcherAuth(param) == 0) {
rtnFlag = CoConstDef.FLAG_YES;
}
}
return rtnFlag;
}
@Override
public void addWatcher(PartnerMaster project) {
if (!isEmpty(project.getParEmail())) {
// ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
if (partnerMapper.existsWatcherByEmail(project) == 0) {
// watcher ์ถ๊ฐ
partnerMapper.insertWatcher(project);
// email ๋ฐ์ก
try {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_INVATED);
mailBean.setParamPartnerId(project.getPartnerId());
mailBean.setParamUserId(project.getLoginUserName());
mailBean.setParamEmail(project.getParEmail());
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
} else {
// ์ด๋ฏธ ์ถ๊ฐ๋ watcher ์ฒดํฌ
if (partnerMapper.existsWatcherByUser(project) == 0) {
if (partnerMapper.existsWatcherByUserDivistion(project) > 0) {
partnerMapper.updateWatcherDivision(project);
} else {
// watcher ์ถ๊ฐ
partnerMapper.insertWatcher(project);
}
}
}
}
@Override
public void removeWatcher(PartnerMaster project) {
partnerMapper.removeWatcher(project);
}
@Override
public List<PartnerMaster> copyWatcher(PartnerMaster project){
return partnerMapper.copyWatcher(project);
}
@Override
public List<String> getInvateWatcherList(String prjId) {
return partnerMapper.getInvateWatcherList(prjId);
}
@Override
public void updatePublicYn(PartnerMaster partner) {
partnerMapper.updatePublicYn(partner);
}
@Override
public boolean existsWatcher(PartnerMaster project) {
boolean result = false;
int i = partnerMapper.existsWatcher(project);
if (i > 0){
result = true;
}
return result;
}
@Override
public Map<String, Object> getPartnerValidationList(PartnerMaster partnerMaster) {
return getPartnerValidationList(partnerMaster, false);
}
@Override
public Map<String, Object> getPartnerValidationList(PartnerMaster partnerMaster, boolean coReview){
ProjectIdentification prjBean = new ProjectIdentification();
prjBean.setReferenceId(partnerMaster.getPartnerId());
prjBean.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
Map<String, Object> partnerList = projectService.getIdentificationGridList(prjBean, true);
PartnerMaster partnerInfo = new PartnerMaster();
T2CoProjectValidator pv = new T2CoProjectValidator();
if (prjBean.getPartnerId() == null){
partnerInfo.setPartnerId(prjBean.getReferenceId());
}else{
partnerInfo.setPartnerId(prjBean.getPartnerId());
}
partnerInfo = getPartnerMasterOne(partnerInfo);
if (partnerInfo != null) {
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_PARTNER);
// main grid
pv.setAppendix("mainList", (List<ProjectIdentification>) partnerList.get("mainData"));
// sub grid
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) partnerList.get("subData"));
if ((CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REQUEST.equals(partnerInfo.getStatus())
|| CoConstDef.CD_DTL_IDENTIFICATION_STATUS_REVIEW.equals(partnerInfo.getStatus()))
&& (CommonFunction.isAdmin() || coReview)) {
pv.setCheckForAdmin(true);
}
T2CoValidationResult vr = pv.validate(new HashMap<>());
if (!vr.isValid() || !vr.isDiff() || vr.hasInfo()) {
partnerList.replace("mainData", CommonFunction.identificationSortByValidInfo(
(List<ProjectIdentification>) partnerList.get("mainData"), vr.getValidMessageMap(), vr.getDiffMessageMap(), vr.getInfoMessageMap(), false, true));
if (!vr.isValid()) {
partnerList.put("validData", vr.getValidMessageMap());
}
if (!vr.isDiff()) {
partnerList.put("diffData", vr.getDiffMessageMap());
}
if (vr.hasInfo()) {
partnerList.put("infoData", vr.getInfoMessageMap());
}
}
}
return partnerList;
}
public Map<String, Object> getFilterdList(Map<String, Object> paramMap){
Map<String, Object> resultMap = new HashMap<String, Object>();
List<ProjectIdentification> mainData = (List<ProjectIdentification>) paramMap.get("mainData");
Map<String, String> errorMap = (Map<String, String>) paramMap.get("validData");
List<String> duplicateList = new ArrayList<>();
List<String> componentIdList = new ArrayList<>();
if (errorMap != null) {
for (ProjectIdentification prjBean : mainData) {
String checkKey = prjBean.getOssName() + "_" + prjBean.getOssVersion();
// ์ค๋ณต๋ oss Info๋ ์ ์ธํจ.
if (duplicateList.contains(checkKey)) {
continue;
}
String componentId = prjBean.getComponentId();
String ossNameErrorMsg = errorMap.containsKey("ossName."+componentId) ? errorMap.get("ossName."+componentId) : "";
String ossVersionErrorMsg = errorMap.containsKey("ossVersion."+componentId) ? errorMap.get("ossVersion."+componentId) : "";
if (ossNameErrorMsg.indexOf("Unconfirmed") > -1
|| ossVersionErrorMsg.indexOf("Unconfirmed") > -1) {
duplicateList.add(checkKey);
componentIdList.add(componentId);
}
}
}
resultMap.put("componentIdList", componentIdList);
resultMap.put("isValid", true);
return resultMap;
}
public Map<String, Object> getIdentificationGridList(ProjectIdentification identification) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<ProjectIdentification> list = null;
identification.setRoleOutLicense(CoCodeManager.CD_ROLE_OUT_LICENSE);
boolean isLoadFromProject = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefPrjId());
if (isLoadFromProject) {
identification.setReferenceId(identification.getRefPrjId());
}
boolean isApplyFromBat = isEmpty(identification.getReferenceId()) && !isEmpty(identification.getRefBatId());
if (isApplyFromBat) {
identification.setReferenceId(identification.getRefBatId());
}
HashMap<String, Object> subMap = new HashMap<String, Object>();
list = projectMapper.selectIdentificationGridList(identification);
identification.setOssVersionEmptyFlag(CoConstDef.FLAG_YES);
List<ProjectIdentification> notVersionOssComponentList = projectMapper.selectIdentificationGridList(identification);;
if (notVersionOssComponentList != null) {
list.addAll(notVersionOssComponentList);
identification.setOssVersionEmptyFlag(null);
}
list.sort(Comparator.comparing(ProjectIdentification::getComponentId));
if (list != null && !list.isEmpty()) {
ProjectIdentification param = new ProjectIdentification();
param.setReferenceDiv(identification.getReferenceDiv());
param.setReferenceId(identification.getReferenceId());
OssMaster ossParam = new OssMaster();
// components license ์ ๋ณด๋ฅผ ํ๋ฒ์ ๊ฐ์ ธ์จ๋ค
for (ProjectIdentification bean : list) {
param.addComponentIdList(bean.getComponentId());
if (!isEmpty(bean.getOssId())) {
ossParam.addOssIdList(bean.getOssId());
}
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (isEmpty(bean.getCveId())
&& isEmpty(bean.getOssVersion())
&& !isEmpty(bean.getCvssScoreMax())
&& !("-".equals(bean.getOssName()))){
String[] cvssScoreMax = bean.getCvssScoreMax().split("\\@");
bean.setCvssScore(cvssScoreMax[0]);
bean.setCveId(cvssScoreMax[1]);
}
}
// oss id๋ก oss master์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค ์ ๋ณด๋ฅผ ์ทจ๋
Map<String, OssMaster> componentOssInfoMap = null;
if (ossParam.getOssIdList() != null && !ossParam.getOssIdList().isEmpty()) {
componentOssInfoMap = ossService.getBasicOssInfoListById(ossParam);
}
List<ProjectIdentification> licenseList = projectMapper.identificationSubGrid(param);
for (ProjectIdentification licenseBean : licenseList) {
for (ProjectIdentification bean : list) {
if (licenseBean.getComponentId().equals(bean.getComponentId())) {
// ์์ ๊ฐ๋ฅ ์ฌ๋ถ ์ด๊ธฐ์ค์
licenseBean.setEditable(CoConstDef.FLAG_YES);
bean.addComponentLicenseList(licenseBean);
break;
}
}
}
// license ์ ๋ณด ๋ฑ๋ก
for (ProjectIdentification bean : list) {
if (bean.getComponentLicenseList()!=null){
String licenseCopy = "";
// multi dual ๋ผ์ด์ ์ค์ ๊ฒฝ์ฐ, main row์ ํ์๋๋ license ์ ๋ณด๋ OSS List์ ๋ฑ๋ก๋์ด์ง ๋ผ์ด์ ์ค๋ฅผ ๊ธฐ์ค์ผ๋ก ํ์ํ๋ค.
// ossId๊ฐ ์๋ ๊ฒฝ์ฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก subGrid๋ก ๋ฑ๋ก๋ ์ ์๋ค
// ์ด์ง๊ฑฐ๋ฆฌ๋ฅผ ํ๋ ๋๋ฒ์งธ ์ด์ ๋, subgrid ์์ ์ฌ์ฉ์๊ฐ ์ถ๊ฐํ ๋ผ์ด์ ์ค์ oss ์ ๋ฑ๋ก๋์ด ์๋ ๋ผ์ด์ ์ค๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํจ
if (componentOssInfoMap == null) {
componentOssInfoMap = new HashMap<>();
}
OssMaster ossBean = componentOssInfoMap.get(bean.getOssId());
if (ossBean != null
&& CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())
&& ossBean.getOssLicenses() != null && !ossBean.getOssLicenses().isEmpty()) {
for (OssLicense ossLicenseBean : ossBean.getOssLicenses()) {
if (!isEmpty(ossLicenseBean.getOssCopyright())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + ossLicenseBean.getOssCopyright();
}
//์ญ์ ๋ถ๊ฐ ์ฒ๋ฆฌ
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
// license index ๊น์ง ๋น๊ตํ๋ ์ด์ ๋
// multi dual ํผ์ฉ์ธ ๊ฒฝ์ฐ, ๋์ผํ ๋ผ์ด์ ์ค๊ฐ ๋๋ฒ ๋ฑ๋ก ๋ ์ ์๊ธฐ ๋๋ฌธ
if (ossLicenseBean.getLicenseId().equals(licenseBean.getLicenseId())
&& ossLicenseBean.getOssLicenseIdx().equals(licenseBean.getRnum())) {
licenseBean.setEditable(CoConstDef.FLAG_NO);
break;
}
}
}
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
} else {
// license text๋ ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ค์ ํ ํ์๋ ์์
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
if (!isEmpty(licenseBean.getCopyrightText())) {
licenseCopy += (!isEmpty(licenseCopy) ? "\r\n" : "") + licenseBean.getCopyrightText();
}
}
bean.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(bean.getComponentLicenseList(), ","));
}
bean.setLicenseNameExistsYn(CommonFunction.existsLicenseName(bean.getComponentLicenseList()) ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
bean.setLicenseUserGuideStr(CommonFunction.checkLicenseUserGuide(bean.getComponentLicenseList()));
bean.setLicenseUserGuideYn(isEmpty(bean.getLicenseUserGuideStr()) ? CoConstDef.FLAG_NO : CoConstDef.FLAG_YES);
bean.setRestriction(CommonFunction.setLicenseRestrictionList(bean.getComponentLicenseList()));
// subGrid์ Item ์ถ์ถ์ ์ํด ๋ณ๋์ map์ผ๋ก ๊ตฌ์ฑํ๋ค.
// ๋ถ๋ชฌ์ component_id๋ฅผ key๋ก ๊ด๋ฆฌํ๋ค.
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
// ๋ค๋ฅธ ํ๋ก์ ํธ์์ loadํ ๊ฒฝ์ฐ component id ์ด๊ธฐํ
if (isLoadFromProject || isApplyFromBat) {
subMap = new HashMap<>();
// refproject id + "p" + componentid ๋ก component_id๋ฅผ ์ฌ์์ฑ ํ๊ณ ,
// license ์ ๊ฒฝ์ฐ ์ฌ์ฑ์ํ component_id + ๊ธฐ์กด license grid_id์ component_license_id ๋ถ๋ถ์ ๊ฒฐํฉ
for (ProjectIdentification bean : list) {
if (isLoadFromProject) {
bean.setRefPrjId(identification.getRefPrjId());
} else if (isApplyFromBat) {
bean.setRefBatId(identification.getRefBatId());
}
String _compId = CoConstDef.GRID_NEWROW_DEFAULT_PREFIX;
if (isLoadFromProject) {
_compId += identification.getRefPrjId();
} else if (isApplyFromBat) {
_compId += identification.getRefBatId();
}
_compId += "p" + bean.getComponentId();
bean.setComponentId("");
bean.setGridId(_compId);
if (bean.getComponentLicenseList()!=null){
for (ProjectIdentification licenseBean : bean.getComponentLicenseList()) {
licenseBean.setComponentId("");
licenseBean.setGridId(_compId + "-"+ licenseBean.getComponentLicenseId());
}
}
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// ํธ์ง์ค์ธ data ๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ append ํ๋ค.
{
if (identification.getMainDataGridList() != null) {
for (ProjectIdentification bean : identification.getMainDataGridList()) {
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(bean.getLicenseDiv())){
for (List<ProjectIdentification> comLicenseList : identification.getSubDataGridList()) {
for (ProjectIdentification comLicense : comLicenseList) {
if (bean.getComponentId().equals(comLicense.getComponentId())){
bean.addComponentLicenseList(comLicense);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
ProjectIdentification license = new ProjectIdentification();
license.setComponentId(bean.getComponentId());
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setCopyrightText(bean.getCopyrightText());
license.setExcludeYn(bean.getExcludeYn());
bean.addComponentLicenseList(license);
}
}
for (ProjectIdentification bean : identification.getMainDataGridList()) {
list.add(0, bean);
subMap.put(bean.getGridId(), bean.getComponentLicenseList());
}
}
}
// exclude row์ ์ฌ์ ๋ ฌ (๊ฐ์ฅ ๋ง์ง๋ง์ผ๋ก)
List<ProjectIdentification> newSortList = new ArrayList<>();
List<ProjectIdentification> excludeList = new ArrayList<>();
for (ProjectIdentification bean : list) {
if (CoConstDef.FLAG_YES.equals(bean.getExcludeYn())) {
excludeList.add(bean);
} else {
newSortList.add(bean);
}
}
newSortList.addAll(excludeList);
list = newSortList;
map.put("subData", subMap);
map.put("mainData", list);
return map;
}
@Override
public int updateDivision(String partnerId, String division) {
return partnerMapper.updateDivision(partnerId, division);
}
@Override
public Map<String, List<PartnerMaster>> updatePartnerDivision(PartnerMaster partnerMaster) {
Map<String, List<PartnerMaster>> updatePartnerDivMap = new HashMap<>();
List<PartnerMaster> beforeBeanList = new ArrayList<>();
List<PartnerMaster> afterBeanList = new ArrayList<>();
PartnerMaster param = new PartnerMaster();
String division = partnerMaster.getParDivision();
String comment = "";
for (String partnerId : partnerMaster.getPartnerIds()) {
param.setPartnerId(partnerId);
PartnerMaster beforeBean = getPartnerMasterOne(param);
if (!avoidNull(beforeBean.getDivision(), "").equals(division)) {
PartnerMaster afterBean = getPartnerMasterOne(param);
afterBean.setDivision(division);
partnerMapper.updateDivision(partnerId, division);
comment = CommonFunction.getDiffItemCommentPartner(beforeBean, afterBean);
afterBean.setUserComment(comment);
beforeBeanList.add(beforeBean);
afterBeanList.add(afterBean);
}
}
if (!beforeBeanList.isEmpty()) {
updatePartnerDivMap.put("before", beforeBeanList);
}
if (!afterBeanList.isEmpty()) {
updatePartnerDivMap.put("after", afterBeanList);
}
return updatePartnerDivMap;
}
@Override
public void updateDescription(PartnerMaster partnerMaster){
partnerMapper.updateDescription(partnerMaster);
}
@Override
@Cacheable(value="autocompletePartnerCache", key="{#root.methodName, #partnerMaster?.creator, #partnerMaster?.status}")
public List<PartnerMaster> getPartnerIdList(PartnerMaster partnerMaster) {
return partnerMapper.getPartnerIdList(partnerMaster);
}
@Override
public Map<String, Object> getExportDataForSbomInfo(PartnerMaster partner) {
Map<String, Object> model = new HashMap<String, Object>();
int dashSeq = 0;
List<OssComponents> ossComponentList = partnerMapper.selectOssComponentsSbomList(partner);
// TYPE๋ณ ๊ตฌ๋ถ
Map<String, OssComponents> noticeInfo = new HashMap<>();
Map<String, OssComponents> srcInfo = new HashMap<>();
Map<String, OssComponents> notObligationInfo = new HashMap<>();
OssComponents ossComponent;
String ossInfoUpperKey = "";
for (OssComponents bean : ossComponentList) {
if (isEmpty(bean.getOssName()) || isEmpty(bean.getLicenseName())) continue;
ossInfoUpperKey = (bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase();
if (CoCodeManager.OSS_INFO_UPPER.containsKey(ossInfoUpperKey) && isEmpty(bean.getHomepage())) {
bean.setHomepage(CoCodeManager.OSS_INFO_UPPER.get(ossInfoUpperKey).getHomepage());
}
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
boolean isDisclosure = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(bean.getObligationType());
boolean isNotice = CoConstDef.CD_DTL_OBLIGATION_NOTICE.equals(bean.getObligationType());
boolean addDisclosure = srcInfo.containsKey(componentKey);
boolean addNotice = noticeInfo.containsKey(componentKey);
boolean addNotObligation = notObligationInfo.containsKey(componentKey);
if (addDisclosure) {
ossComponent = srcInfo.get(componentKey);
} else if (addNotice) {
ossComponent = noticeInfo.get(componentKey);
} else if (addNotObligation) {
ossComponent = notObligationInfo.get(componentKey);
} else {
ossComponent = bean;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
bean.setOssCopyright(findAddedOssCopyright(bean.getOssId(), bean.getLicenseId(), bean.getOssCopyright()));
if (!isEmpty(bean.getOssCopyright())) {
String addCopyright = avoidNull(ossComponent.getCopyrightText());
if (!isEmpty(ossComponent.getCopyrightText())) {
addCopyright += "\r\n";
}
addCopyright += bean.getOssCopyright();
ossComponent.setCopyrightText(addCopyright);
}
}
if (isDisclosure) {
if (addDisclosure) {
srcInfo.replace(componentKey, ossComponent);
} else {
srcInfo.put(componentKey, ossComponent);
}
} else if (isNotice) {
if (addNotice) {
noticeInfo.replace(componentKey, ossComponent);
} else {
noticeInfo.put(componentKey, ossComponent);
}
} else {
if (addNotObligation) {
notObligationInfo.replace(componentKey, ossComponent);
} else {
notObligationInfo.put(componentKey, ossComponent);
}
}
}
List<OssComponents> addOssComponentList = partnerMapper.selectOssComponentsSbomListClassAppend(partner);
if (addOssComponentList != null) {
ossComponent = null;
Map<String, List<String>> addOssComponentCopyright = new HashMap<>();
for (OssComponents bean : addOssComponentList) {
if (isEmpty(bean.getLicenseName())) continue;
String componentKey = (bean.getOssName() + "|" + bean.getOssVersion()).toUpperCase();
List<String> copyrightList = addOssComponentCopyright.containsKey(componentKey)
? (List<String>) addOssComponentCopyright.get(componentKey)
: new ArrayList<>();
if (!isEmpty(bean.getCopyrightText())) {
for (String copyright : bean.getCopyrightText().split("\n")) {
copyrightList.add(copyright);
}
}
boolean addSrcInfo = srcInfo.containsKey(componentKey);
boolean addNoticeInfo = noticeInfo.containsKey(componentKey);
boolean addNotObligationInfo = notObligationInfo.containsKey(componentKey);
if (addSrcInfo) {
ossComponent = srcInfo.get(componentKey);
} else if (addNoticeInfo) {
ossComponent = noticeInfo.get(componentKey);
} else if (addNotObligationInfo) {
ossComponent = notObligationInfo.get(componentKey);
} else {
ossComponent = bean;
}
if ("-".equals(bean.getOssName()) || !CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(bean.getOssName().toUpperCase())
|| !CoCodeManager.OSS_INFO_UPPER.containsKey((bean.getOssName() + "_" + avoidNull(bean.getOssVersion())).toUpperCase())) {
if (!isEmpty(bean.getDownloadLocation()) && isEmpty(bean.getHomepage())) {
ossComponent.setHomepage(bean.getDownloadLocation());
}
}
if ("-".equals(bean.getOssName())) {
componentKey += dashSeq++;
}
OssComponentsLicense license = new OssComponentsLicense();
license.setLicenseId(bean.getLicenseId());
license.setLicenseName(bean.getLicenseName());
license.setLicenseText(bean.getLicenseText());
license.setAttribution(bean.getAttribution());
if (!checkLicenseDuplicated(ossComponent.getOssComponentsLicense(), license)) {
ossComponent.addOssComponentsLicense(license);
}
copyrightList = copyrightList.stream()
.filter(CommonFunction.distinctByKey(c -> avoidNull(c).trim().toUpperCase()))
.collect(Collectors.toList());
ossComponent.setCopyrightText(String.join("\r\n", copyrightList));
addOssComponentCopyright.put(componentKey, copyrightList);
boolean disclosureFlag = false;
boolean noticeFlag = false;
switch(CommonFunction.checkObligationSelectedLicense(ossComponent.getOssComponentsLicense())){
case CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE:
srcInfo.put(componentKey, ossComponent);
disclosureFlag = true;
break;
case CoConstDef.CD_DTL_OBLIGATION_NOTICE:
noticeInfo.put(componentKey, ossComponent);
noticeFlag = true;
break;
}
if (!disclosureFlag && !noticeFlag) {
notObligationInfo.put(componentKey, ossComponent);
}
}
}
boolean isTextNotice = true;
Map<String, String> ossAttributionMap = new HashMap<>();
// ๊ฐํ์ฒ๋ฆฌ ๋ฐ velocity์ฉ list ์์ฑ
List<OssComponents> noticeList = new ArrayList<>();
for (OssComponents bean : noticeInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
noticeList.add(bean);
}
Collections.sort(noticeList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> srcList = new ArrayList<>();
for (OssComponents bean : srcInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
srcList.add(bean);
}
Collections.sort(srcList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
List<OssComponents> notObligationList = new ArrayList<>();
for (OssComponents bean : notObligationInfo.values()) {
if (isTextNotice) {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.unescapeHtml(avoidNull(bean.getOssAttribution()))));
} else {
bean.setCopyrightText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getCopyrightText()))));
bean.setLicenseText(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getLicenseText()))));
bean.setOssAttribution(CommonFunction.lineReplaceToBR(StringEscapeUtils.escapeHtml(avoidNull(bean.getOssAttribution()))));
}
if (!isEmpty(bean.getOssAttribution()) && !ossAttributionMap.containsKey(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()))) {
ossAttributionMap.put(avoidNull(bean.getOssName()) + "_" + avoidNull(bean.getOssVersion()), avoidNull(bean.getOssName(), "") + "__" + bean.getOssAttribution());
}
if (!isEmpty(bean.getOssName())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
}
notObligationList.add(bean);
}
Collections.sort(notObligationList, new Comparator<OssComponents>() {
@Override
public int compare(OssComponents oc1, OssComponents oc2) {
return oc1.getOssName().toUpperCase().compareTo(oc2.getOssName().toUpperCase());
}
});
model.put("noticeObligationList", noticeList);
model.put("disclosureObligationList", srcList);
model.put("notObligationList", notObligationList);
model.put("addOssComponentList", addOssComponentList);
return model;
}
private boolean checkLicenseDuplicated(List<OssComponentsLicense> ossComponentsLicense, OssComponentsLicense license) {
if (ossComponentsLicense != null) {
if (!isEmpty(license.getLicenseId())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseId().equals(license.getLicenseId())) {
return true;
}
}
} else if (isEmpty(license.getLicenseId()) && !isEmpty(license.getLicenseName())) {
for (OssComponentsLicense bean : ossComponentsLicense) {
if (bean.getLicenseName().equals(license.getLicenseName())) {
return true;
}
}
}
}
return false;
}
private String findAddedOssCopyright(String ossId, String licenseId, String ossCopyright) {
if (!isEmpty(ossId) && !isEmpty(licenseId)) {
OssMaster bean = CoCodeManager.OSS_INFO_BY_ID.get(ossId);
if (bean != null) {
for (OssLicense license : bean.getOssLicenses()) {
if (licenseId.equals(license.getLicenseId()) && !isEmpty(license.getOssCopyright())) {
return license.getOssCopyright();
}
}
}
}
return ossCopyright;
}
@Override
public Map<String, Object> checkSelectDownloadFile(PartnerMaster partnerMaster) {
Map<String, Object> resMap = new HashMap<>();
boolean emptyCheckFlag = false;
List<OssComponents> list = partnerMapper.checkSelectDownloadFile(partnerMaster);
for (OssComponents oss : list) {
if (isEmpty(oss.getOssName()) || isEmpty(oss.getLicenseName())) {
emptyCheckFlag = true;
break;
}
}
if (emptyCheckFlag) {
resMap.put("isValid", false);
} else {
resMap.put("isValid", true);
}
return resMap;
}
}
| 51,733 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiBatServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiBatServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.service.ApiBatService;
import oss.fosslight.util.StringUtil;
@Service
@Slf4j
public class ApiBatServiceImpl implements ApiBatService {
private String JDBC_DRIVER;
private String DB_URL;
private String USERNAME;
private String PASSWORD;
@Resource private Environment env;
@PostConstruct
public void setResourcePathPrefix(){
JDBC_DRIVER = env.getProperty("bat.postgre.driver");
DB_URL = env.getProperty("bat.postgre.host");
USERNAME = env.getProperty("bat.postgre.username");
PASSWORD = env.getProperty("bat.postgre.password");
}
@Override
public List<Map<String, Object>> getBatList(Map<String, Object> paramMap) {
List<Map<String, Object>> contents = new ArrayList<Map<String, Object>>();
//๋ฐ์ดํฐ ๋ฒ ์ด์ค ์ ์
Connection conn = null;
Statement stmt = null;
ResultSet totalRs = null;
ResultSet rs = null;
try{
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD);
stmt = conn.createStatement();
String strWhere = " WHERE 1 = 1 ";
{
String fileName = (String) paramMap.get("fileName");
if (!StringUtil.isEmpty(fileName)) {
strWhere += " AND UPPER(filename) LIKE UPPER('%" + fileName + "%') ";
}
String tlsh = (String) paramMap.get("tlsh");
if (!StringUtil.isEmpty(tlsh)){
strWhere += " AND UPPER(tlshchecksum) = UPPER('" + tlsh + "') ";
}
String checksum = (String) paramMap.get("checksum");
if (!StringUtil.isEmpty(checksum)){
strWhere += " AND UPPER(checksum) = UPPER('" + checksum + "') ";
}
String platformName = (String) paramMap.get("platformName");
if (!StringUtil.isEmpty(platformName)) {
strWhere += " AND UPPER(platformname) LIKE UPPER('%"+ platformName +"%') ";
}
String platformVersion = (String) paramMap.get("platformVersion");
if (!StringUtil.isEmpty(platformVersion)) {
strWhere += " AND UPPER(platformversion) LIKE UPPER('"+ platformVersion +"%') ";
}
String sourcePath = (String) paramMap.get("sourcePath");
if (!StringUtil.isEmpty(sourcePath)) {
strWhere += " AND UPPER(ossname) LIKE UPPER('%"+ sourcePath +"%') ";
}
}
String sql = "SELECT filename, pathname, checksum, tlshchecksum, ossname, ossversion, license, ";
sql += "parentname, platformname, platformversion, TO_CHAR(updatedate, 'YYYY-MM-DD') as updatedate FROM lgematching ";
sql += strWhere;
rs = stmt.executeQuery(sql);
while (rs.next()) {
Map<String, Object> batData = new HashMap<String, Object>();
batData.put("binaryFileName", rs.getString("filename"));
batData.put("path", rs.getString("pathname"));
batData.put("ossName", rs.getString("ossname"));
batData.put("ossVersion", rs.getString("ossversion"));
batData.put("license", rs.getString("license"));
batData.put("projectName", rs.getString("parentname"));
batData.put("checksum", rs.getString("checksum"));
batData.put("tlsh", rs.getString("tlshchecksum"));
batData.put("updateDate", rs.getString("updatedate"));
contents.add(batData);
}
CommonFunction.setOssDownloadLocation(contents);
} catch(Exception e) {
log.error(e.getMessage(), e);
} finally {
if (totalRs != null) {
try {
totalRs.close();
} catch (Exception e) {}
}
if (rs != null) {
try {
rs.close();
} catch (Exception e) {}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {}
}
}
return contents;
}
} | 4,477 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
LicenseServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/LicenseServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2CodeDtl;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.repository.LicenseMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.HistoryService;
import oss.fosslight.service.LicenseService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.T2UserService;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
@Service("licenseService")
@Slf4j
public class LicenseServiceImpl extends CoTopComponent implements LicenseService {
// Service
@Autowired T2UserService userService;
@Autowired OssService ossService;
@Autowired CommentService commentService;
@Autowired HistoryService historyService;
//Mapper
@Autowired LicenseMapper licenseMapper;
@Autowired CodeMapper codeMapper;
@Override
public History work(Object param) {
History h = new History();
LicenseMaster vo = (LicenseMaster) param;
LicenseMaster data = getLicenseMasterOne(vo);
data.setComment(vo.getComment());
h.sethKey(vo.getLicenseId());
h.sethTitle(vo.getLicenseName());
h.sethType(CoConstDef.EVENT_CODE_LICENSE);
h.setModifier(vo.getLoginUserName());
h.setModifiedDate(vo.getCreatedDate());
h.sethComment("");
h.sethData(data);
return h;
}
@Override
public int selectLicenseMasterTotalCount(LicenseMaster licenseMaster) {
return licenseMapper.selectLicenseMasterTotalCount(licenseMaster);
}
@Override
public Map<String,Object> getLicenseMasterList(LicenseMaster licenseMaster) {
// obligation type ๊ฒ์ ์กฐ๊ฑด ์ถ๊ฐ
if (!isEmpty(licenseMaster.getObligationType())) {
switch (licenseMaster.getObligationType()) {
case CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK:
licenseMaster.setObligationNeedsCheckYn(CoConstDef.FLAG_YES);
break;
case CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE:
licenseMaster.setObligationDisclosingSrcYn(CoConstDef.FLAG_YES);
break;
case CoConstDef.CD_DTL_OBLIGATION_NOTICE:
licenseMaster.setObligationNotificationYn(CoConstDef.FLAG_YES);
break;
case CoConstDef.CD_DTL_OBLIGATION_NONE:
// "NONE"์ ๊ฒฝ์ฐ๋ ์ฟผ๋ฆฌ ์กฐ๊ฑด์ ์ ์ง์ ๋ฑ๋ก
break;
default:
break;
}
}
if (licenseMaster.getRestrictions() != null) {
String restrictions = licenseMaster.getRestrictions();
if (!isEmpty(restrictions)){
String[] arrRestrictions = restrictions.split(",");
licenseMaster.setArrRestriction(arrRestrictions);
}
}
HashMap<String, Object> map = new HashMap<String, Object>();
int records = licenseMapper.selectLicenseMasterTotalCount(licenseMaster);
licenseMaster.setTotListSize(records);
List<LicenseMaster> list = licenseMapper.selectLicenseList(licenseMaster);
for (LicenseMaster item : list){
if (!isEmpty(item.getRestriction())){
item.setRestriction(CommonFunction.setLicenseRestrictionList(item.getRestriction()));
}
}
map.put("page", licenseMaster.getCurPage());
map.put("total", licenseMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
public LicenseMaster getLicenseMasterOne(LicenseMaster licenseMaster) {
licenseMaster = licenseMapper.selectLicenseOne(licenseMaster);
List<LicenseMaster> licenseNicknameList = licenseMapper.selectLicenseNicknameList(licenseMaster);
List<String> nickNames = new ArrayList<>();
for (LicenseMaster bean : licenseNicknameList) {
nickNames.add(bean.getLicenseNickname());
}
List<LicenseMaster> licenseWebPageList = licenseMapper.selectLicenseWebPageList(licenseMaster);
List<String> webPage = new ArrayList<>();
for (LicenseMaster bean : licenseWebPageList) {
webPage.add(bean.getWebpage());
}
// ์ผ๋ฐ user ํ๋ฉด ์ผ ๊ฒฝ์ฐ restriction์ full name์ผ๋ก ํ๋ฉด ์ถ๋ ฅ
// admin ํ๋ฉด ์ผ ๊ฒฝ์ฐ restriction code๋ฅผ ์ฌ์ฉํ์ฌ ์ฒดํฌ๋ฐ์ค๋ก ๊ตฌ์ฑ
if (!"ROLE_ADMIN".equals(loginUserRole())) {
if (licenseMaster.getRestriction() != null) {
T2CodeDtl t2CodeDtl = new T2CodeDtl();
List<T2CodeDtl> t2CodeDtlList = new ArrayList<>();
t2CodeDtl.setCdNo(CoConstDef.CD_LICENSE_RESTRICTION);
try {
t2CodeDtlList = codeMapper.selectCodeDetailList(t2CodeDtl);
} catch (Exception e) {
log.error(e.getMessage());
}
List<String> restrictionList = Arrays.asList(licenseMaster.getRestriction().split(","));
String restrictionStr = "";
for (T2CodeDtl item: t2CodeDtlList){
if (restrictionList.contains(item.getCdDtlNo())) {
restrictionStr += (!isEmpty(restrictionStr) ? ", " : "") + item.getCdDtlNm();
}
}
licenseMaster.setRestriction(restrictionStr);
}
}
licenseMaster.setLicenseNicknames(nickNames.toArray(new String[nickNames.size()]));
licenseMaster.setWebpages(webPage.toArray(new String[webPage.size()]));
return licenseMaster;
}
@Override
public List<OssMaster> checkExistsUsedOss(String licenseId) {
return licenseMapper.checkExistsUsedOss(licenseId);
}
@Override
public LicenseMaster checkExistsLicense(LicenseMaster param) {
LicenseMaster bean = licenseMapper.checkExistsLicense(param);
if (bean != null && !isEmpty(bean.getLicenseId())) {
return bean;
}
return null;
}
@Override
public List<LicenseMaster> getLicenseMasterListExcel(LicenseMaster license) {
List<LicenseMaster> result = licenseMapper.selectLicenseList(license);
if (result != null) {
for (LicenseMaster bean : result) {
if (CoCodeManager.LICENSE_INFO_BY_ID.containsKey(bean.getLicenseId())) {
LicenseMaster master = CoCodeManager.LICENSE_INFO_BY_ID.get(bean.getLicenseId());
bean.setLicenseNicknameList(master.getLicenseNicknameList());
bean.setRestrictionStr(master.getRestrictionStr());
}
}
}
return result;
}
@Transactional
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
public int deleteLicenseMaster(LicenseMaster licenseMaster) {
licenseMapper.deleteLicenseNickname(licenseMaster);
licenseMapper.deleteLicenseWebPages(licenseMaster);
return licenseMapper.deleteLicenseMaster(licenseMaster);
}
@Override
public void deleteDistributeLicense(LicenseMaster bean, boolean distributionFlag) {
if (bean != null && !isEmpty(bean.getLicenseName())) {
String fileName = bean.getShortIdentifier();
String result = null;
if (isEmpty(fileName)) {
fileName = bean.getLicenseName();
}
result = "";
log.info("OSDD license update result : " + avoidNull(result));
}
if (avoidNull(bean.getRestriction()).contains(CoConstDef.CD_LICENSE_NETWORK_RESTRICTION)){
registNetworkServerLicense(bean.getLicenseId(), "DEL");
}
}
@Override
public void registNetworkServerLicense(String licenseId, String type) {
String CD_DTL_NO = licenseMapper.existNetworkServerLicense(licenseId);
switch(type){
case "NEW":
licenseMapper.insertNetworkServerLicense(licenseId);
break;
case "INS":
if (isEmpty(CD_DTL_NO)){
licenseMapper.insertNetworkServerLicense(licenseId);
}
break;
case "DEL":
if (!isEmpty(CD_DTL_NO)){
licenseMapper.deleteNetworkServerLicense(licenseId);
}
break;
default:
break;
}
}
@Override
public List<OssMaster> updateOssLicenseType(String licenseId) {
// license type์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ oss์ license type์ด ํจ๊ป ๋ณ๊ฒฝ๋์ด์ผํจ
// ๊ธฐ์กด license ๋ฅผ ์ฌ์ฉํ๋ ํ๋ก์ ํธ ๋ชฉ๋ก์ ๋ฉ์ผ ๋ด์ฉ์ ํฌํจํ๋ ๊ฒ์, license type์ด ๋ณ๊ฒฝ๋ oss๋ฅผ ํฌํจํ๋ ํ๋ก์ ํธ ๋ชฉ๋ก์ ํ์ํ๋ ๊ฒ์ผ๋ก ๋ณ๊ฒฝ
List<OssMaster> changedLicenseTypeOssList = new ArrayList<>();
// ํด๋น license๋ฅผ ์ฌ์ฉํ๋ oss ๋ชฉ๋ก ์ทจ๋
List<String> ossList = licenseMapper.getOssListWithLicenseForTypeCheck(licenseId);
// ์ต์ข
์ ์ผ๋ก ๋ผ์ด์ ์ค ํ์
์ด ๋ณ๊ฒฝ๋ oss ๋ชฉ๋ก ์ฐ์ถ
if (ossList != null) {
for (String ossId : ossList) {
OssMaster ossBean = ossService.getOssInfo(ossId, false);
String orgOssLicenseType = ossBean.getLicenseType();
String orgOssObligationType = ossBean.getObligationType();
// license type ๋ณ๊ฒฝ ์ฌ๋ถ ์ฒดํฌ
ossService.checkOssLicenseAndObligation(ossBean);
if (!orgOssLicenseType.equals(ossBean.getLicenseType())) {
// oss์ license type๊ณผ obligation์ ๋ณ๊ฒฝํ๋ค.
ossService.updateLicenseTypeAndObligation(ossBean);
ossBean.setOrgLicenseType(orgOssLicenseType);
ossBean.setOrgObligationType(orgOssObligationType);
changedLicenseTypeOssList.add(ossBean);
}
}
}
return changedLicenseTypeOssList;
}
@Transactional
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
public String registLicenseMaster(LicenseMaster licenseMaster) {
String[] licenseNicknames = licenseMaster.getLicenseNicknames();
String licenseId = licenseMaster.getLicenseId();
if (StringUtil.isEmpty(licenseId)){
licenseMaster.setCreator(licenseMaster.getLoginUserName());
}
licenseMaster.setModifier(licenseMaster.getLoginUserName());
// trim ์ฒ๋ฆฌ
licenseMaster.setLicenseName(licenseMaster.getLicenseName().trim());
if (StringUtil.isEmpty(licenseId)){
licenseMapper.insertLicenseMaster(licenseMaster);
} else {
licenseMapper.updateLicenseMaster(licenseMaster);
}
registLicenseWebPage(licenseMaster); // license_webpage table data insert
/*
* 1. ๋ผ์ด์ผ์ค ๋๋ค์ ์ญ์
* 2. ๋ผ์ด์ผ์ค ๋๋ค์ ์ฌ๋ฑ๋ก
*/
licenseMapper.deleteLicenseNickname(licenseMaster);
if (licenseNicknames != null){
for (String nickName : licenseNicknames){
if (!isEmpty(nickName)) {
licenseMaster.setLicenseNickname(nickName.trim());
licenseMapper.insertLicenseNickname(licenseMaster);
}
}
}
//์ฝ๋ฉํธ ๋ฑ๋ก
if (!isEmpty(licenseMaster.getComment())) {
CommentsHistory param = new CommentsHistory();
param.setReferenceId(licenseMaster.getLicenseId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_LICENSE);
param.setContents(licenseMaster.getComment());
commentService.registComment(param);
}
// code refresh
CoCodeManager.getInstance().refreshLicenseInfo();
return licenseMaster.getLicenseId();
}
@Override
public boolean distributeLicense(String licenseId, boolean distributionFlag) {
boolean SuccessType = false;
LicenseMaster licenseBean = CoCodeManager.LICENSE_INFO_BY_ID.get(licenseId);
if (licenseBean == null) {
log.error("LICENSE INFO IS NULL, LICENSE ID = " + avoidNull(licenseId));
} else {
String contents = makeLicenseInfoHtml(licenseBean);
String fileName = !isEmpty(licenseBean.getShortIdentifier()) ? licenseBean.getShortIdentifier() : licenseBean.getLicenseNameTemp();
fileName = fileName.replaceAll(" ", "_").replaceAll("/", "_") + ".html";
if (!isEmpty(contents)) {
String filePath = CommonFunction.appendProperty("root.dir", "internal.url.dir.path");
FileUtil.writeFile(filePath, fileName, contents);
SuccessType = true;
} else {
log.error("OSDD DISTRIBUTE LCIENSE info is null");
SuccessType = false;
}
}
return SuccessType;
}
private String makeLicenseInfoHtml(LicenseMaster bean) {
Map<String, Object> model = new HashMap<>();
model.put("licenseName", bean.getLicenseNameTemp());
if (!isEmpty(bean.getShortIdentifier())) {
model.put("shortIdentifier", bean.getShortIdentifier());
}
if (!isEmpty(bean.getWebpage())) {
model.put("webPage", bean.getWebpage());
}
model.put("licenseText", CommonFunction.lineReplaceToBR(bean.getLicenseText()));
model.put("templateURL", "/template/notice/license.html");
return CommonFunction.VelocityTemplateToString(model);
}
@Override
@Cacheable(value="autocompleteCache", key="#root.methodName")
public List<LicenseMaster> getLicenseNameList() {
List<LicenseMaster> list = licenseMapper.selectLicenseNameList();
if (list != null) {
for (LicenseMaster bean : list) {
if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationNeedsCheckYn()))) {
bean.setObligationCode(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK);
} else if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationDisclosingSrcYn()))) {
bean.setObligationCode(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
} else if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationNotificationYn()))) {
bean.setObligationCode(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
}
}
}
return list;
}
@Override
public void sendLicenseTypeChangedMail(String licenseId, LicenseMaster beforeBean, LicenseMaster afterBean, String comment) {
// OSS๋ฅผ ์ฐธ์กฐํ๊ณ ์๋ ํ๋ก์ ํธ ๊ด๋ จ์์๊ฒ ๋ฉ์ผ ๋ฐ์ก
// ๋์ผ๋ฉ์ผ ์์ ์ ๋ฐฉ์งํ๊ธฐ์ํด ๋ณ๊ฒฝ ๋ด์ฉ + ํ๋ก์ ํธ ๋ฆฌ์คํธ ํ์์ผ๋ก ๋ฐ์กํ๊ธฐ ์ํด, ์ฌ์ฉ์ ๊ฐ๋ณ ๋ฐ์กํ๋ค.
// ๊ด๋ จ์๋ค ๋ชจ๋ ์ทจ๋
List<Project> prjList = licenseMapper.getLicenseChangeForUserList(licenseId);
if (prjList != null) {
// ์์ ์ ๋์ ์ถ์ถ (ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ํจ๊ป ๋๊ธด๋ค)
Map<String, Map<String, Project>> sendInfoMap = new HashMap<>();
for (Project bean : prjList) {
Map<String, Project> _info = null;
if (!isEmpty(bean.getCreator())) {
_info = sendInfoMap.get(bean.getCreator());
if (_info == null) {
_info = new HashMap<>();
}
if (!_info.containsKey(bean.getPrjId())) {
_info.put(bean.getPrjId(), bean);
if (sendInfoMap.containsKey(bean.getCreator())) {
sendInfoMap.replace(bean.getCreator(), _info);
} else {
sendInfoMap.put(bean.getCreator(), _info);
}
}
}
if (!isEmpty(bean.getReviewer())) {
_info = sendInfoMap.get(bean.getReviewer());
if (_info == null) {
_info = new HashMap<>();
}
if (!_info.containsKey(bean.getPrjId())) {
_info.put(bean.getPrjId(), bean);
if (sendInfoMap.containsKey(bean.getReviewer())) {
sendInfoMap.replace(bean.getReviewer(), _info);
} else {
sendInfoMap.put(bean.getReviewer(), _info);
}
}
}
if (!isEmpty(bean.getPrjUserId())) {
_info = sendInfoMap.get(bean.getPrjUserId());
if (_info == null) {
_info = new HashMap<>();
}
if (!_info.containsKey(bean.getPrjId())) {
_info.put(bean.getPrjId(), bean);
if (sendInfoMap.containsKey(bean.getPrjUserId())) {
sendInfoMap.replace(bean.getPrjUserId(), _info);
} else {
sendInfoMap.put(bean.getPrjUserId(), _info);
}
}
}
}
// sendInfoMap ๊ฑด์ (์ฌ๋์) ๋งํผ ๋ฐ์ก
for (String userId : sendInfoMap.keySet()) {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE_TYPE);
mailBean.setToIds(new String[]{userId});
List<Project> tempList = new ArrayList<>();
Map<String, Project> prjInfo = sendInfoMap.get(userId);
for (String prjId : prjInfo.keySet()) {
tempList.add(prjInfo.get(prjId));
}
mailBean.setParamPrjList(tempList);
mailBean.setComment(comment);
mailBean.setCompareDataBefore(beforeBean);
mailBean.setCompareDataAfter(afterBean);
CoMailManager.getInstance().sendMail(mailBean);
}
}
}
@Override
public void registLicenseWebPage(LicenseMaster licenseMaster) {
if (licenseMapper.existsLicenseWebPages(licenseMaster) > 0){
licenseMapper.deleteLicenseWebPages(licenseMaster);
}
int idx = 0;
String[] webPages = licenseMaster.getWebpages();
if (webPages != null){
for (String url : webPages){
if (!isEmpty(url)){ // ๊ณต๋ฐฑ์ downloadLocation์ saveํ์ง ์์.
LicenseMaster master = new LicenseMaster();
master.setLicenseId(licenseMaster.getLicenseId());
master.setWebpage(url);
master.setSortOrder(Integer.toString(++idx));
licenseMapper.insertLicenseWebPages(master);
}
}
}
}
@Override
public String webPageStringFormat(String[] webpagesList) {
String webpages = "";
for (String webpage : webpagesList) {
webpages += webpage+",";
}
if (!("").equals(webpages)) {
webpages = webpages.substring(0, webpages.length()-1);
}
return webpages;
}
@Override
public LicenseMaster getLicenseId(LicenseMaster licenseMaster) {
return CoCodeManager.LICENSE_INFO_UPPER.get(licenseMaster.getLicenseName().toUpperCase());
}
/**
* for return err message
* */
@Override
public Map<String, Object> getLicenseDataMap(String gridId, boolean status, String msg) {
Map<String, Object> licenseDataMap = new HashMap<>();
licenseDataMap.put("gridId", gridId);
licenseDataMap.put("status", status);
licenseDataMap.put("msg", msg);
return licenseDataMap;
}
@Override
public Map<String, Object> saveLicense(LicenseMaster licenseMaster) {
String resCd="00"; //๋น์ ์
String result="";
LicenseMaster beforeBean = null;
LicenseMaster afterBean = null;
HashMap<String,Object> resMap = new HashMap<>();
String licenseId = licenseMaster.getLicenseId();
boolean isNew = isEmpty(licenseId);
boolean isChangeName = false;
boolean distributionFlag = CommonFunction.propertyFlagCheck("distribution.use.flag", CoConstDef.FLAG_YES);
List<OssMaster> typeChangeOssIdList = null;
if(!isNew) {
beforeBean = getLicenseMasterOne(licenseMaster);
System.out.println("beforeBean = " + beforeBean);
}
// webpages์ด n๊ฑด์ผ๋ 0๋ฒ์งธ ๊ฐ์ oss Master๋ก ์ ์ฅ.
String[] webpages = licenseMaster.getWebpages();
if(webpages != null){
if(webpages.length >= 1){
for(String url : webpages){
if(!isEmpty(url)){
licenseMaster.setWebpage(url); // ๋ฑ๋ก๋ url ์ค ๊ณต๋ฐฑ์ ์ ์ธํ ๋๋จธ์ง์์ ์ฒซ๋ฒ์งธ url์ ๋ง๋๊ฒ ๋๋ฉด ๋ฑ๋ก์ ํจ.
break;
}
}
}
} else if(webpages == null){
licenseMaster.setWebpage("");
}
result = registLicenseMaster(licenseMaster);
if(!isNew) {
afterBean = getLicenseMasterOne(licenseMaster);
// licnese type์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ, ํด๋น ๋ผ์ด์ ์ค๋ฅผ ์ฌ์ฉํ๋ oss์ license type์ ์ฌํ์ธ ํ๋ค.
if(!avoidNull(beforeBean.getLicenseType()).equals(avoidNull(afterBean.getLicenseType()))) {
typeChangeOssIdList = updateOssLicenseType(result);
}
isChangeName = !beforeBean.getLicenseName().equalsIgnoreCase(afterBean.getLicenseName());
}
// ์ฑ๊ธํค ์ ๋ณด refresh
resCd="10"; //์ ์
putSessionObject("defaultLoadYn", true); // ํ๋ฉด ๋ก๋ ์ default๋ก ๋ฆฌ์คํธ ์กฐํ ์ฌ๋ถ flag
try{
History h = work(licenseMaster);
h.sethAction(isEmpty(licenseId) ? CoConstDef.ACTION_CODE_INSERT : CoConstDef.ACTION_CODE_UPDATE);
historyService.storeData(h);
}catch(Exception e){
log.error(e.getMessage(), e);
}
// osdd ์ฐ๋
boolean successType = false;
try {
if(isNew) {
successType = distributeLicense(result, distributionFlag);
} else if(beforeBean != null && afterBean != null) {
if(!avoidNull(beforeBean.getLicenseName()).equals(afterBean.getLicenseName())
|| !avoidNull(beforeBean.getShortIdentifier()).equals(afterBean.getShortIdentifier())
|| !avoidNull(beforeBean.getLicenseText()).equals(afterBean.getLicenseText())) {
successType = distributeLicense(result, distributionFlag);
} else {
successType = true; // license > update ์ผ ๊ฒฝ์ฐ์ internal url ์์ฑ๊ณผ ์๊ด์๋ ํญ๋ชฉ์ด update๋ ๊ฒฝ์ฐ๋ comment๋ฅผ ๋จ๊ธฐ์ง ์์.
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
CoMail mailBean = new CoMail(isNew ? CoConstDef.CD_MAIL_TYPE_LICENSE_REGIST : isChangeName ? CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME : CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE);
mailBean.setParamLicenseId(result);
String comment = licenseMaster.getComment();
if(!successType) { // internal url ์์ฑ ์คํจ์ comment ๋จ๊น
comment += (isEmpty(comment) ? "" : "<br>") + "[Error] An error occurred when creating an internal URL file.";
}
mailBean.setComment(comment);
if(!isNew) {
mailBean.setParamOssList(typeChangeOssIdList);
// code convert
if(beforeBean != null) {
beforeBean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, beforeBean.getLicenseType()));
beforeBean.setObligation(CommonFunction.makeLicenseObligationStr(beforeBean.getObligationNotificationYn(), beforeBean.getObligationDisclosingSrcYn(), beforeBean.getObligationNeedsCheckYn()));
beforeBean.setModifiedDate(DateUtil.dateFormatConvert(beforeBean.getModifiedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
beforeBean.setModifier(CoMailManager.getInstance().makeUserNameFormat(beforeBean.getModifier()));
beforeBean.setDescription(CommonFunction.lineReplaceToBR(beforeBean.getDescription()));
beforeBean.setLicenseText(CommonFunction.lineReplaceToBR(beforeBean.getLicenseText()));
beforeBean.setAttribution(CommonFunction.lineReplaceToBR(beforeBean.getAttribution()));
if(beforeBean.getWebpages().length > 0) beforeBean.setWebpage(webPageStringFormat(beforeBean.getWebpages()));
}
if(afterBean != null) {
afterBean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, afterBean.getLicenseType()));
afterBean.setObligation(CommonFunction.makeLicenseObligationStr(afterBean.getObligationNotificationYn(), afterBean.getObligationDisclosingSrcYn(), afterBean.getObligationNeedsCheckYn()));
afterBean.setModifiedDate(DateUtil.dateFormatConvert(afterBean.getModifiedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
afterBean.setModifier(CoMailManager.getInstance().makeUserNameFormat(afterBean.getModifier()));
afterBean.setDescription(CommonFunction.lineReplaceToBR(afterBean.getDescription()));
afterBean.setLicenseText(CommonFunction.lineReplaceToBR(afterBean.getLicenseText()));
afterBean.setAttribution(CommonFunction.lineReplaceToBR(afterBean.getAttribution()));
if(afterBean.getWebpages().length > 0) afterBean.setWebpage(webPageStringFormat(afterBean.getWebpages()));
}
mailBean.setCompareDataBefore(beforeBean);
mailBean.setCompareDataAfter(afterBean);
}
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try{
// RESTRICTION(2) => Network Redistribution
String netWorkRestriction = CoConstDef.CD_LICENSE_NETWORK_RESTRICTION;
if(isNew) {
if(licenseMaster.getRestriction().contains(netWorkRestriction)){
registNetworkServerLicense(licenseMaster.getLicenseId(), "NEW");
}
} else {
String type = "";
if(beforeBean.getRestriction().contains(netWorkRestriction) && afterBean.getRestriction().contains(netWorkRestriction)){
type = "";
}else if(beforeBean.getRestriction().contains(netWorkRestriction) && !afterBean.getRestriction().contains(netWorkRestriction)){
type = "DEL";
}else if(!beforeBean.getRestriction().contains(netWorkRestriction) && afterBean.getRestriction().contains(netWorkRestriction)){
type = "INS";
}
registNetworkServerLicense(licenseMaster.getLicenseId(), type);
}
} catch (Exception e){
}
resMap.put("resCd", resCd);
resMap.put("licenseId", result);
return resMap;
}
@Override
public void deleteLicenseMasterForRestriction(LicenseMaster licenseMaster) {
List<LicenseMaster> delRestrictionLicenseList = licenseMapper.selectLicenseList(licenseMaster);
if (delRestrictionLicenseList != null && !delRestrictionLicenseList.isEmpty()) {
List<String> delRestrictionList = Arrays.asList(licenseMaster.getArrRestriction());
for (LicenseMaster lm : delRestrictionLicenseList) {
String restrictions = lm.getRestriction();
String customRestriction = "";
for (String restriction : restrictions.split(",")) {
if (!delRestrictionList.contains(restriction)) {
customRestriction += restriction + ",";
}
}
if (!customRestriction.isEmpty()) customRestriction = customRestriction.substring(0, customRestriction.length()-1);
lm.setRestriction(customRestriction);
licenseMapper.updateLicenseMasterForRestriction(lm);
}
}
}
}
| 25,867 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProcessGuideServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ProcessGuideServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.domain.ProcessGuide;
import oss.fosslight.repository.ProcessGuideMapper;
import oss.fosslight.service.ProcessGuideService;
@Service
public class ProcessGuideServiceImpl extends CoTopComponent implements ProcessGuideService{
@Autowired ProcessGuideMapper processGuideMapper;
/**
* ์ฝ๋ ๋ชฉ๋ก ์กฐํ
*/
@Override
public Map<String, Object> getProcessGuideList(ProcessGuide vo) throws Exception {
Map<String, Object> map = null;
int records = processGuideMapper.selectProcessGuideTotalCount(vo);
if (records > 0) {
vo.setTotListSize(records);
// Grid paging ์ฒ๋ฆฌ๋ฅผ ์ํ ๊ธฐ๋ณธ param ์ค์ Map ์์ฑ(๋ฐ๋์ totlistsize๋ฅผ set ํ๊ณ ๋์ ์์ฑํด์ผํจ)
map = getGridPagerMap(vo);
List<ProcessGuide> processGuideList = processGuideMapper.selectProcessGuideList(vo);
map.put("rows", processGuideList);
}
return map == null ? new HashMap<String, Object>() : map;
}
@Override
public void setProcessGuide(ProcessGuide vo) throws Exception {
processGuideMapper.updateProcessGuide(vo);
}
@Override
public Map<String, Object> getProcessGuide(ProcessGuide vo) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
int records = processGuideMapper.selectProcessGuideCount(vo);
if (records > 0) {
ProcessGuide guide = processGuideMapper.selectProcessGuide(vo);
if (guide != null) {
map.put("processGuide", guide);
}
}
return map;
}
}
| 1,894 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ComplianceServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ComplianceServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.Project;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.service.ComplianceService;
@Service
@Slf4j
public class ComplianceServiceImpl implements ComplianceService {
@Autowired
ProjectMapper projectMapper;
@Override
public Map<String, Object> getModelList(Project project) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<Project> list = new ArrayList<Project>();
try {
project.setModelFlag(CoConstDef.FLAG_NO);
List<Project> projectNameList = projectMapper.selectModelInfoList(project);
if (projectNameList != null && projectNameList.size() > 0) {
list.addAll(projectNameList);
}
project.setModelFlag(CoConstDef.FLAG_YES);
List<Project> modelNameList = projectMapper.selectModelInfoList(project);
if (modelNameList != null && modelNameList.size() > 0) {
list.addAll(modelNameList);
}
list = list.stream()
.filter(CommonFunction.distinctByKey(p -> p.getModelName()+"-"+p.getPrjId()))
.collect(Collectors.toList());
for (String modelName : project.getModelListInfo()) {
int duplicateCnt = list.stream()
.filter(p -> modelName.equals(p.getModelName()))
.collect(Collectors.toList())
.size();
if (duplicateCnt == 0) {
Project prj = new Project();
prj.setModelName(modelName);
list.add(prj);
}
}
if (list != null) {
final Comparator<Project> comp = Comparator.comparing((Project p) -> p.getModelName());
list = list.stream().sorted(comp).collect(Collectors.toList());
// ์ฝ๋๋ณํ์ฒ๋ฆฌ
for (Project bean : list) {
// DISTRIBUTION_TYPE
bean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, bean.getDistributionType()));
// Project Status - delay ๊ธฐ๋ฅ์ด ์ญ์ ๋จ. ๊ธฐ์กด์๋ delay๋ฅผ ํ์ํ์ง ์์์ผ๋ฏ๋ก priority๋ ํ์ํ์ง ์๊ฒ ์ฒ๋ฆฌํจ.
bean.setStatus( CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_STATUS, bean.getStatus()));
// Project priority
bean.setPriority(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, bean.getPriority())); // ์ฌ์ฉ์ ํ์ง ์์ง๋ง ๊ฐ์ ์ ์ฅํด๋ .
// Identification Status
bean.setIdentificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getIdentificationStatus()));
// Verification Status
bean.setVerificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getVerificationStatus()));
// Distribute Status
String distributionStatus = CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROCESS.equals(bean.getDestributionStatus())
? CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROGRESS : bean.getDestributionStatus();
bean.setDestributionStatus(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_STATUS, distributionStatus));
// DIVISION
bean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, bean.getDivision()));
}
}
map.put("page", project.getCurPage());
map.put("total", project.getTotBlockSize());
map.put("records", list.size());
map.put("rows", list);
} catch(Exception e) {
log.debug(e.getMessage());
}
return map;
}
}
| 3,952 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiFileServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiFileServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.UploadFile;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.service.ApiFileService;
import oss.fosslight.util.CompressUtil;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
@Service("ApiFileService")
@Slf4j
public class ApiFileServiceImpl implements ApiFileService {
@Autowired FileMapper fileMapper;
@Override
public UploadFile uploadFile(MultipartFile mFile){
return uploadFile(mFile, null, null);
}
@Override
public UploadFile uploadFile(MultipartFile mFile, String filePath){
return uploadFile(mFile, filePath, null);
}
@Override
public UploadFile uploadFile(MultipartFile mFile, String filePath, String oldFileId) {
boolean uploadSucc = false;
String fileId = "";
if (oldFileId != null) {
fileId = oldFileId;
} else {
fileId = StringUtil.avoidNull(fileMapper.getFileId(), "1");//max+1 file Id ๊ฐ์ ธ์ด 20160524 ms-kwon
}
int indexNum = 0;
UploadFile upFile = new UploadFile();
T2File registFile = new T2File();
if (StringUtil.isEmpty(mFile.getOriginalFilename())) {
throw new RuntimeException("File Name is empty");
}
if (mFile.getSize() <= 0) {
throw new RuntimeException("File Size is 0");
}
String originalFileName = mFile.getOriginalFilename(); //Original File name
// originalFileName์ ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
log.debug("File upload OriginalFileName : " + originalFileName);
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("/") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
if (originalFileName.indexOf("\\") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("\\") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
String uploadFilePath = "";
String uploadThumbFilePath = "";
try {
if (StringUtil.isEmpty(filePath)) {
uploadFilePath = CommonFunction.emptyCheckProperty("upload.path", "/upload");
uploadThumbFilePath = CommonFunction.emptyCheckProperty("image.path", "/image");
} else {
uploadFilePath = filePath;
uploadThumbFilePath = filePath + "/" + "thumb";
File packagingFile = new File(filePath);
if (!packagingFile.exists()) {
packagingFile.mkdirs();
}
}
} catch(Exception e) {
log.error("file upload path(get properties) : " + e.getMessage());
}
UUID randomUUID = UUID.randomUUID();
File file = new File(uploadFilePath+"/"+randomUUID+"."+fileExt);
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName("");
upFile.setSize(mFile.getSize());
upFile.setFilePath(uploadFilePath);
upFile.setFileName(randomUUID+"."+fileExt);
upFile.setFileExt(fileExt);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(randomUUID+"."+fileExt);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(randomUUID+"_thumb."+fileExt);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(mFile.getSize()+"");
try {
registFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
upFile.setRegistSeq(registFile(registFile));
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
if (mFile.getSize()!=0) { //File Null Check
if (! file.exists()) { //๊ฒฝ๋ก์์ ํ์ผ์ด ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ
try {
if (file.getParentFile() != null && file.getParentFile().mkdirs()) { //๊ฒฝ๋ก์ ํด๋นํ๋ ๋๋ ํ ๋ฆฌ๋ค์ ์์ฑ
boolean upSucc = file.createNewFile(); //์ดํ ํ์ผ ์์ฑ
if (!upSucc) {
uploadSucc=false;
}
}
}
catch (IOException e) {
log.error("file upload create error : " + e.getMessage());
uploadSucc=false;
}
}
uploadSucc = FileUtil.transferTo(mFile, file);
upFile.setUploadSucc(uploadSucc);
}
return upFile;
}
@Override
public Map<String, UploadFile> uploadNoticeXMLFile(MultipartFile mFile, String prjId) {
Map<String, UploadFile> result = new HashMap<String, UploadFile>();
String fileId = StringUtil.avoidNull(fileMapper.getFileId(), "1");
int indexNum = 0;
UploadFile upFile = new UploadFile();
T2File registFile = new T2File();
boolean uploadSucc = true;
String fileName = mFile.getOriginalFilename();
if (StringUtil.isEmpty(mFile.getOriginalFilename())) {
throw new RuntimeException("File Name is empty");
}
if (mFile.getSize() <= 0) {
throw new RuntimeException("File Size is 0");
}
String originalFileName = mFile.getOriginalFilename(); //Original File name
// originalFileName์ ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
log.debug("File upload OriginalFileName : " + originalFileName);
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("/") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
if (originalFileName.indexOf("\\") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("\\") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
String uploadFilePath = "";
String uploadThumbFilePath = "";
try {
uploadFilePath = CommonFunction.emptyCheckProperty("android.upload.path", "/upload/android_notice")+ "/" + prjId;
uploadThumbFilePath = CommonFunction.emptyCheckProperty("image.path", "/image")+ "/" + prjId + "/thumb";
} catch(Exception e) {
log.error("file upload path(get properties) : " + e.getMessage());
}
UUID randomUUID = UUID.randomUUID();
File file = new File(uploadFilePath+"/"+randomUUID+"."+fileExt);
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName(fileName);
upFile.setSize(mFile.getSize());
upFile.setFilePath(uploadFilePath);
upFile.setFileName(randomUUID+"."+fileExt);
upFile.setFileExt(fileExt);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(randomUUID+"."+fileExt);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(randomUUID+"_thumb."+fileExt);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(mFile.getSize()+"");
try {
registFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
upFile.setRegistSeq(registFile(registFile));
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
if (mFile.getSize()!=0){ //File Null Check
if (! file.exists()){ //๊ฒฝ๋ก์์ ํ์ผ์ด ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ
try {
if (file.getParentFile() != null && file.getParentFile().mkdirs()){ //๊ฒฝ๋ก์ ํด๋นํ๋ ๋๋ ํ ๋ฆฌ๋ค์ ์์ฑ
boolean upSucc = file.createNewFile(); //์ดํ ํ์ผ ์์ฑ
if (!upSucc){
uploadSucc=false;
}
}
}
catch (IOException e) {
log.error("file upload create error : " + e.getMessage());
uploadSucc=false;
}
}
uploadSucc = FileUtil.transferTo(mFile, file);
upFile.setUploadSucc(uploadSucc);
}
result.put("noticeXML", upFile); // zip, xml, tar.gz file
try {
File convertHTMLFile = null;
if ("XML".equals(fileExt.toUpperCase())) {
convertHTMLFile = CommonFunction.convertXMLToHTML(file, false);
} else if ("ZIP".equals(fileExt.toUpperCase())) {
FileUtil.decompress(uploadFilePath + "/" + file.getName(), uploadFilePath + "/" + randomUUID);
convertHTMLFile = CommonFunction.convertXMLToHTML(new File(uploadFilePath + "/" + randomUUID), true);
} else if ("TAR.GZ".equals(fileExt.toUpperCase())) {
CompressUtil.decompressTarGZ(file, uploadFilePath + "/" + randomUUID);
convertHTMLFile = CommonFunction.convertXMLToHTML(new File(uploadFilePath + "/" + randomUUID), true);
}
if (convertHTMLFile != null) {
long convertHTMLFileSize = convertHTMLFile.length();
if (convertHTMLFileSize > 0){
UploadFile convertNoticeFile = new UploadFile();
String convertFileId = fileMapper.getFileId();
String convertNoticeFileName = "Notice-"+prjId+"_"+DateUtil.getCurrentDateTime(DateUtil.DATE_PATTERN)+".html";
convertNoticeFile.setOriginalFilename(convertNoticeFileName);
convertNoticeFile.setInputName(convertNoticeFileName);
convertNoticeFile.setSize(convertHTMLFileSize);
convertNoticeFile.setFilePath(uploadFilePath + "/" + randomUUID);
convertNoticeFile.setFileName(convertHTMLFile.getName());
convertNoticeFile.setFileExt("html");
convertNoticeFile.setIndexNum(indexNum+1);
convertNoticeFile.setRegistFileId(convertFileId);
convertNoticeFile.setContentType("text/html");
/** DB Regist Setting **/
T2File registConvertHTML = new T2File();
registConvertHTML.setFileId(convertFileId);
registConvertHTML.setOrigNm(convertNoticeFileName);
registConvertHTML.setLogiNm(convertHTMLFile.getName());
registConvertHTML.setLogiPath(uploadFilePath + "/" + randomUUID);
registConvertHTML.setLogiThumbNm(StringUtil.avoidNull(convertHTMLFile.getName(), "").replace(".html", "_thumb.html"));
registConvertHTML.setLogiThumbPath(uploadFilePath + "/" + randomUUID + "/thumb");
registConvertHTML.setExt("html");
registConvertHTML.setSize(Long.toString(convertHTMLFileSize));
registFile.setContentType("text/html");
convertNoticeFile.setRegistSeq(registFile(registConvertHTML));
convertNoticeFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
result.put("noticeHTML", convertNoticeFile);
}
}
return result;
} catch (Throwable e) {
log.debug(e.getMessage());
}
return null; // ๋ณํ ์คํจํ case
}
//ํ์ผ DB ๋ฑ๋ก
public String registFile(T2File file) {
int result = fileMapper.insertFile(file);
if (result<=0){
return null;
}
return file.getFileSeq();
}
}
| 12,345 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CodeServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/CodeServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.T2Code;
import oss.fosslight.domain.T2CodeDtl;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.service.CodeService;
import oss.fosslight.service.LicenseService;
@Service
public class CodeServiceImpl extends CoTopComponent implements CodeService {
@Autowired CodeMapper codeMapper;
@Autowired LicenseService licenseService;
/**
* ์ฝ๋ ๋ชฉ๋ก ์กฐํ
*/
@Override
public Map<String, Object> getCodeList(T2Code vo) throws Exception {
Map<String, Object> map = null;
int records = codeMapper.selectCodeTotalCount(vo);
if (records > 0) {
vo.setTotListSize(records);
map = getGridPagerMap(vo);
map.put("rows", codeMapper.selectCodeList(vo));
}
return map == null ? new HashMap<String, Object>() : map;
}
/**
* ์ฝ๋์์ธ ๋ชฉ๋ก ์กฐํ
*/
@Override
public ArrayList<T2CodeDtl> getCodeDetailList(T2CodeDtl vo) throws Exception {
ArrayList<T2CodeDtl> codeDetailList = codeMapper.selectCodeDetailList(vo);
if (codeDetailList.size() > 0){
for (T2CodeDtl t2CodeDtl : codeDetailList) {
if (isGithubTokenCodeDtl(t2CodeDtl)) {
t2CodeDtl.setCdDtlExp("");
}
t2CodeDtl.setCdDtlNoOrign(t2CodeDtl.getCdDtlNo());
}
}
return codeDetailList;
}
private boolean isGithubTokenCodeDtl(T2CodeDtl t2CodeDtl) {
return isExternalServiceCodeNo(t2CodeDtl.getCdNo()) && isGithubTokenCodeDtlNo(t2CodeDtl.getCdDtlNo());
}
/**
* ์ฝ๋ ์ ์ฅ
*/
// @CacheEvict(value="autocompleteCache", allEntries=true)
@Transactional
@Override
public void setCode(T2Code vo) throws Exception {
// ์ถ๊ฐ
if (CoConstDef.GRID_OPERATION_ADD.equals(vo.getOper())) {
codeMapper.insertCode(vo);
} else if (CoConstDef.GRID_OPERATION_EDIT.equals(vo.getOper())) { // ์์
codeMapper.updateCode(vo);
} else { // ์ญ์
codeMapper.deleteCodeDetailAll(vo);
codeMapper.deleteCode(vo);
}
}
@Override
public boolean isExists(T2Code vo) {
return codeMapper.selectCodeTotalCount(vo) > 0;
}
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
@Transactional
public void setCodeDetails(List<T2CodeDtl> dtlList, String cdNo) throws Exception {
// if code_no equals CD_USER_DIVISION value, after code_detail_name and detain_no check, division_no update
if (CoConstDef.CD_USER_DIVISION.equals(cdNo)) {
T2CodeDtl codeDtlVO = new T2CodeDtl();
codeDtlVO.setCdNo(cdNo);
List<T2CodeDtl> beforeCodeDetailList = codeMapper.selectCodeDetailList(codeDtlVO);
List<T2CodeDtl> filteredCodeDetailList = beforeCodeDetailList
.stream()
.filter(before->
dtlList
.stream()
.filter(after->
(before.getCdDtlNm()).equalsIgnoreCase(after.getCdDtlNm()) && before.getUseYn().equals(after.getUseYn()) && !before.getCdDtlNo().equals(after.getCdDtlNo())).collect(Collectors.toList()).size() > 0
).collect(Collectors.toList());
List<T2CodeDtl> filteredAfterCodeDetailList = dtlList
.stream()
.filter(before->
beforeCodeDetailList
.stream()
.filter(after->
(before.getCdDtlNm()).equalsIgnoreCase(after.getCdDtlNm()) && before.getUseYn().equals(after.getUseYn()) && !before.getCdDtlNo().equals(after.getCdDtlNo())).collect(Collectors.toList()).size() > 0
).collect(Collectors.toList());
// update division_no value of statistics_MostUsed table
for (T2CodeDtl cdDtl : filteredCodeDetailList) {
for (T2CodeDtl cdDtlAfter : filteredAfterCodeDetailList) {
if (cdDtl.getCdDtlNm().equalsIgnoreCase(cdDtlAfter.getCdDtlNm())) {
T2CodeDtl codeDtl = new T2CodeDtl();
codeDtl.setCdDtlNo(cdDtl.getCdDtlNo());
codeDtl.setCdDtlNoNew(cdDtlAfter.getCdDtlNo());
codeMapper.updateStatisticsMostUsed(codeDtl);
}
}
}
}
List<String> delRestrictionList = null;
if (CoConstDef.CD_LICENSE_RESTRICTION.equals(cdNo)) {
T2CodeDtl param = new T2CodeDtl();
param.setCdNo(cdNo);
List<T2CodeDtl> codeDetailList = codeMapper.selectCodeDetailList(param);
if (codeDetailList != null && !codeDetailList.isEmpty()) {
delRestrictionList = codeDetailList
.stream()
.filter(e ->
dtlList
.stream()
.filter(a ->
(a.getCdDtlNo() + "|" + a.getCdDtlNm()).equalsIgnoreCase(e.getCdDtlNo() + "|" + e.getCdDtlNm())
).collect(Collectors.toList()).size() == 0
).map(b -> b.getCdDtlNo())
.collect(Collectors.toList());
}
}
if (isExternalServiceCodeNo(cdNo) && hasGithubTokenCodeDtl(dtlList)) {
// 1. ๊ธฐ์กด github token๊ฐ ๋ณด๊ด
T2CodeDtl githubTokenDtl = codeMapper.getCodeDetail(cdNo, CoConstDef.CD_DTL_GITHUB_TOKEN);
// 2. ์ฝ๋ ์์ธ ์ ์ฒด ์ญ์
T2Code codeVo = new T2Code();
codeVo.setCdNo(cdNo);
codeMapper.deleteCodeDetailAll(codeVo);
// 3. ์ ์ฒด ์์ธ ์ฝ๋ ์ฌ๋ฑ๋ก(์ถ๊ฐ / ๋ณ๊ฒฝ / ์ญ์ )
for (T2CodeDtl codeDtl : dtlList) {
if (isGithubTokenCodeDtlNo(codeDtl.getCdDtlNo()) && codeDtl.getCdDtlExp().isEmpty()) {
codeMapper.insertCodeDetail(githubTokenDtl);
} else {
codeMapper.insertCodeDetail(codeDtl);
}
}
} else {
// 1. ์ฝ๋ ์์ธ ์ ์ฒด ์ญ์
T2Code codeVo = new T2Code();
codeVo.setCdNo(cdNo);
codeMapper.deleteCodeDetailAll(codeVo);
// 2. ์ ์ฒด ์์ธ ์ฝ๋ ์ฌ๋ฑ๋ก(์ถ๊ฐ / ๋ณ๊ฒฝ / ์ญ์ )
for (T2CodeDtl vo : dtlList) {
codeMapper.insertCodeDetail(vo);
}
}
// delete license restriction information
if (delRestrictionList != null && !delRestrictionList.isEmpty()) {
LicenseMaster licenseMaster = new LicenseMaster();
licenseMaster.setArrRestriction(delRestrictionList.toArray(new String[delRestrictionList.size()]));
licenseService.deleteLicenseMasterForRestriction(licenseMaster);
}
}
private boolean isGithubTokenCodeDtlNo(String cdDtlNo) {
return cdDtlNo.equals(CoConstDef.CD_DTL_GITHUB_TOKEN);
}
private boolean isExternalServiceCodeNo(String cdNo) {
return cdNo.equals(CoConstDef.CD_EXTERNAL_SERVICE_SETTING);
}
private boolean hasGithubTokenCodeDtl(List<T2CodeDtl> dtlList) {
return dtlList.stream()
.anyMatch(codeDtl -> codeDtl.getCdDtlNo().equals(CoConstDef.CD_DTL_GITHUB_TOKEN));
}
@Override
@Cacheable(value="autocompleteCache", key="#root.methodName")
public List<T2Code> getcodeList(T2Code t2Code) {
List<T2Code> result = codeMapper.getCodeList(t2Code);
return result;
}
@Override
@Cacheable(value="autocompleteCache", key="#root.methodName")
public List<T2Code> getcodeNmList(T2Code t2Code) {
List<T2Code> result = codeMapper.getCodeNmList(t2Code);
return result;
}
} | 7,465 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CommentServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/CommentServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.repository.CommentMapper;
import oss.fosslight.service.CommentService;
import oss.fosslight.util.StringUtil;
@Service
public class CommentServiceImpl implements CommentService {
@Autowired CommentMapper commentMapper;
@Override
public List<CommentsHistory> getCommentListHis(CommentsHistory bean) {
List<CommentsHistory> commentsHistoryList = commentMapper.getCommentListHis(bean);
for (CommentsHistory commentsHistory : commentsHistoryList) {
commentMapper.updateHistoryReadYn(commentsHistory);
}
return commentsHistoryList;
}
@Override
public String getUserComment(CommentsHistory bean) {
return commentMapper.getUserComment(bean);
}
@Override
@Transactional
public CommentsHistory registComment(CommentsHistory commentsHistory) {
return registComment(commentsHistory, true);
}
@Override
@Transactional
public CommentsHistory registComment(CommentsHistory bean, boolean deleteUserComment) {
boolean isNew = StringUtil.isEmpty(bean.getCommId());
if (!StringUtil.isEmpty(bean.getContents()) || !StringUtil.isEmpty(bean.getStatus())){
commentMapper.registComment(bean);
}
boolean isPartner = CoConstDef.CD_DTL_COMMENT_PARTNER_HIS.equals(bean.getReferenceDiv());
if (deleteUserComment && isNew && (CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS.equals(bean.getReferenceDiv())
|| CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS.equals(bean.getReferenceDiv())
|| CoConstDef.CD_DTL_COMMENT_PARTNER_HIS.equals(bean.getReferenceDiv())
|| CoConstDef.CD_DTL_COMMENT_PROJECT_HIS.equals(bean.getReferenceDiv()))) {
switch (bean.getReferenceDiv()) {
case CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICATION_USER);
break;
case CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_USER);
break;
case CoConstDef.CD_DTL_COMMENT_PROJECT_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PROJECT_USER);
break;
case CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_USER);
break;
case CoConstDef.CD_DTL_COMMENT_PARTNER_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_USER);
break;
default:
break;
}
if (!StringUtil.isEmpty(bean.getReferenceDiv())) {
commentMapper.deleteCommentUserTemp(bean);
}
}
if (CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_ADDED_COMMENT.equals(bean.getMailType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_ADDED_COMMENT.equals(bean.getMailType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_ADDED_COMMENT.equals(bean.getMailType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_ADDED_COMMENT.equals(bean.getMailType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_ADDED_COMMENT.equals(bean.getMailType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REQUESTTOOPEN_COMMENT.equals(bean.getMailType())) {
CoMail mailBean = new CoMail(bean.getMailType());
if (isPartner) {
mailBean.setParamPartnerId(bean.getReferenceId());
} else {
mailBean.setParamPrjId(bean.getReferenceId());
}
mailBean.setComment(bean.getContents());
if (CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS.equals(bean.getReferenceDiv())) {
mailBean.setStage("Identificaiton");
} else if (CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS.equals(bean.getReferenceDiv())) {
mailBean.setStage("Packaging");
} else if (CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_HIS.equals(bean.getReferenceDiv())) {
mailBean.setStage("Distribution");
}
mailBean.setReceiveFlag(bean.getMailSendType());
if (!StringUtil.isEmpty(bean.getContents())){//comment ๋ด์ฉ์ด ์์์๋ง ๋ฉ์ผ ๋ฐ์ก
CoMailManager.getInstance().sendMail(mailBean);
}
}
return commentMapper.getCommentInfo(bean.getCommId());
}
@Override
public List<CommentsHistory> getCommentList(CommentsHistory commentsHistory){
List<CommentsHistory> result = commentMapper.getCommentList(commentsHistory);
return result;
}
@Override
@Transactional
public int deleteComment(CommentsHistory commentsHistory) {
int result = 0;
result = commentMapper.deleteComment(commentsHistory);
return result;
}
@Override
public int updateComment(CommentsHistory bean) {
return updateComment(bean, true);
}
@Override
public int updateComment(CommentsHistory bean, boolean emailSendFlag) {
CommentsHistory before = commentMapper.getCommentInfo(bean.getCommId());
int rtn = commentMapper.updateComment(bean);
if (emailSendFlag) {
if (rtn > 0 && bean.getReferenceDiv() != null) {
boolean isPartner = false;
String paramOssId = null;
String paramLicenseId = null;
switch (bean.getReferenceDiv()) {
case CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICATION_USER);
bean.setMailType(CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_MODIFIED_COMMENT);
break;
case CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_USER);
bean.setMailType(CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_MODIFIED_COMMENT);
break;
case CoConstDef.CD_DTL_COMMENT_PROJECT_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PROJECT_USER);
bean.setMailType(CoConstDef.CD_MAIL_TYPE_PROJECT_MODIFIED_COMMENT);
break;
case CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_DISTRIBUTION_USER);
bean.setMailType(CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_MODIFIED_COMMENT);
break;
case CoConstDef.CD_DTL_COMMENT_PARTNER_HIS:
bean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_USER);
bean.setMailType(CoConstDef.CD_MAIL_TYPE_PARTER_MODIFIED_COMMENT);
isPartner = true;
break;
case CoConstDef.CD_DTL_COMMENT_LICENSE:
bean.setMailType(CoConstDef.CD_MAIL_TYPE_LICENSE_MODIFIED_COMMENT);
paramLicenseId = bean.getReferenceId();
break;
case CoConstDef.CD_DTL_COMMENT_OSS:
bean.setMailType(CoConstDef.CD_MAIL_TYPE_OSS_MODIFIED_COMMENT);
paramOssId = bean.getReferenceId();
break;
default:
return rtn;
}
CoMail mailBean = new CoMail(bean.getMailType());
mailBean.setParamExpansion1(before.getContents());
mailBean.setParamExpansion2(bean.getContents());
mailBean.setComment(bean.getContents());
mailBean.setReceiveFlag(bean.getMailSendType());
if (isPartner) {
mailBean.setParamPartnerId(bean.getReferenceId());
} else if (!StringUtil.isEmpty(paramLicenseId)) {
mailBean.setParamLicenseId(paramLicenseId);
} else if (!StringUtil.isEmpty(paramOssId)) {
mailBean.setParamOssId(paramOssId);
} else {
mailBean.setParamPrjId(bean.getReferenceId());
}
CoMailManager.getInstance().sendMail(mailBean);
}
}
return rtn;
}
@Override
public int getCommentListHisCnt(CommentsHistory bean) {
return commentMapper.getCommentListHisCnt(bean);
}
@Override
public List<CommentsHistory> getMoreCommentListHis(CommentsHistory bean) {
List<CommentsHistory> commentsHistoryList = commentMapper.getMoreCommentListHis(bean);
for (CommentsHistory commentsHistory : commentsHistoryList) {
commentMapper.updateHistoryReadYn(commentsHistory);
}
return commentsHistoryList;
}
@Override
public Map<String, Object> getCommnetInfo(String commId) {
HashMap<String, Object> map = new HashMap<String, Object>();
CommentsHistory commentsHistory = commentMapper.getCommentInfo(commId);
map.put("info", commentsHistory);
return map;
}
}
| 8,576 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/OssServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.CoMail;
import oss.fosslight.domain.CoMailManager;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssAnalysis;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssLicense;
import oss.fosslight.domain.OssMaster;
import oss.fosslight.domain.PartnerMaster;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.T2Users;
import oss.fosslight.domain.Vulnerability;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.repository.OssMapper;
import oss.fosslight.repository.PartnerMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.T2UserMapper;
import oss.fosslight.repository.VulnerabilityMapper;
import oss.fosslight.service.*;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.StringUtil;
import oss.fosslight.validation.T2CoValidationConfig;
import oss.fosslight.validation.T2CoValidationResult;
import oss.fosslight.validation.custom.T2CoProjectValidator;
@Service
@Slf4j
public class OssServiceImpl extends CoTopComponent implements OssService {
// Service
@Autowired CommentService commentService;
@Autowired HistoryService historyService;
@Autowired ProjectService projectService;
@Autowired PartnerService partnerService;
@Autowired VerificationService verificationService;
@Autowired SelfCheckService selfCheckService;
@Autowired AutoFillOssInfoService autoFillOssInfoService;
// Mapper
@Autowired OssMapper ossMapper;
@Autowired T2UserMapper userMapper;
@Autowired FileMapper fileMapper;
@Autowired ProjectMapper projectMapper;
@Autowired PartnerMapper partnerMapper;
@Autowired VulnerabilityMapper vulnerabilityMapper;
@Override
public Map<String,Object> getOssMasterList(OssMaster ossMaster) {
// ๊ธฐ๊ฐ ๊ฒ์ ์กฐ๊ฑด
if (!isEmpty(ossMaster.getcEndDate())) {
ossMaster.setcEndDate(DateUtil.addDaysYYYYMMDD(ossMaster.getcEndDate(), 1));
}
if (!isEmpty(ossMaster.getmEndDate())) {
ossMaster.setmEndDate(DateUtil.addDaysYYYYMMDD(ossMaster.getmEndDate(), 1));
}
if (isEmpty(ossMaster.getOssNameAllSearchFlag())) {
ossMaster.setOssNameAllSearchFlag(CoConstDef.FLAG_NO);
}
if (isEmpty(ossMaster.getLicenseNameAllSearchFlag())) {
ossMaster.setLicenseNameAllSearchFlag(CoConstDef.FLAG_NO);
}
if (isEmpty(ossMaster.getHomepageAllSearchFlag())) {
ossMaster.setHomepageAllSearchFlag(CoConstDef.FLAG_NO);
}
HashMap<String, Object> map = new HashMap<String, Object>();
ossMaster.setCveIdText();
int records = ossMapper.selectOssMasterTotalCount(ossMaster);
ossMaster.setTotListSize(records);
ArrayList<OssMaster> newList = new ArrayList<>();
List<OssMaster> list = ossMapper.selectOssList(ossMaster);
String orgOssName = ossMaster.getOssName();
List<String> multiOssList = ossMapper.selectMultiOssList(ossMaster);
multiOssList.replaceAll(String::toUpperCase);
for (OssMaster oss : list){
if (multiOssList.contains(oss.getOssName().toUpperCase())) {
ossMaster.setOssId(oss.getOssId());
ossMaster.setOssName(oss.getOssName());
List<OssMaster> subList = ossMapper.selectOssSubList(ossMaster);
newList.addAll(subList);
} else {
newList.add(oss);
}
}
ossMaster.setOssName(orgOssName);
// license name ์ฒ๋ฆฌ
if (newList != null && !newList.isEmpty()) {
OssMaster param = new OssMaster();
for (OssMaster bean : newList) {
param.addOssIdList(bean.getOssId());
}
List<OssLicense> licenseList = ossMapper.selectOssLicenseList(param);
for (OssLicense licenseBean : licenseList) {
for (OssMaster bean : newList) {
if (licenseBean.getOssId().equals(bean.getOssId())) {
bean.addOssLicense(licenseBean);
break;
}
}
}
for (OssMaster bean : newList) {
if (bean.getOssLicenses() != null && !bean.getOssLicenses().isEmpty()) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(bean.getOssLicenses()));
}
// group by key ์ค์ grid ์์์ ๋์๋ฌธ์ ๊ตฌ๋ถ๋์ด ๋๋ฌธ์๋ก ๋ชจ๋ ์นํํ์ฌ ๊ทธ๋ฃนํ
bean.setGroupKey(bean.getOssName().toUpperCase());
// NICK NAME ICON ํ์
if (CoConstDef.FLAG_YES.equals(ossMaster.getSearchFlag())) {
bean.setOssName(StringUtil.replaceHtmlEscape(bean.getOssName()));
if (!isEmpty(bean.getOssNickname())) {
bean.setOssName("<span class='iconSet nick'>Nick</span> " + bean.getOssName());
} else {
bean.setOssName("<span class='iconSet nick dummy'></span> " + bean.getOssName());
}
}
}
}
map.put("page", ossMaster.getCurPage());
map.put("total", ossMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", newList);
return map;
}
@Override
@Cacheable(value="autocompleteCache", key="#root.methodName")
public List<OssMaster> getOssNameList() {
return ossMapper.selectOssNameList();
}
@Override
public String[] getOssNickNameListByOssName(String ossName) {
List<String> nickList = new ArrayList<>();
if (!isEmpty(ossName)) {
OssMaster param = new OssMaster();
param.setOssName(ossName);
List<OssMaster> list = ossMapper.selectOssNicknameList(param);
if (list != null) {
for (OssMaster bean : list) {
if (!isEmpty(bean.getOssNickname()) && !nickList.contains(bean.getOssNickname())) {
nickList.add(bean.getOssNickname());
}
}
}
}
return nickList.toArray(new String[nickList.size()]);
}
@Override
public Map<String, Object> getOssLicenseList(OssMaster ossMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<OssLicense> list = ossMapper.selectOssLicenseList(ossMaster);
if (!CommonFunction.isAdmin() && list != null) {
for (OssLicense license : list) {
if (!isEmpty(license.getOssCopyright())) {
license.setOssCopyright(CommonFunction.lineReplaceToBR( StringUtil.replaceHtmlEscape( license.getOssCopyright() )));
}
}
}
map.put("rows", list);
return map;
}
@Override
public List<Vulnerability> getOssVulnerabilityList(Vulnerability vulnParam) {
return ossMapper.getOssVulnerabilityList(vulnParam);
}
@Override
public OssMaster getOssMasterOne(OssMaster ossMaster) {
ossMaster = ossMapper.selectOssOne(ossMaster);
List<OssMaster> ossNicknameList = ossMapper.selectOssNicknameList(ossMaster);
List<OssMaster> ossDownloadLocation = ossMapper.selectOssDownloadLocationList(ossMaster);
List<OssLicense> ossLicenses = ossMapper.selectOssLicenseList(ossMaster); // declared License
List<OssMaster> ossDetectedLicense = ossMapper.selectOssDetectedLicenseList(ossMaster); // detected License
String totLicenseTxt = CommonFunction.makeLicenseExpression(ossLicenses);
ossMaster.setTotLicenseTxt(totLicenseTxt);
StringBuilder sb = new StringBuilder();
for (OssMaster ossNickname : ossNicknameList){
sb.append(ossNickname.getOssNickname()).append(",");
}
String[] ossNicknames = new String(sb).split("[,]");
sb = new StringBuilder(); // ์ด๊ธฐํ
if (ossDownloadLocation != null && !ossDownloadLocation.isEmpty()) {
for (OssMaster location : ossDownloadLocation) {
sb.append(location.getDownloadLocation()).append(",");
}
}else {
sb.append(ossMaster.getDownloadLocation());
}
String[] ossDownloadLocations = new String(sb).split("[,]");
sb = new StringBuilder(); // ์ด๊ธฐํ
for (OssMaster licenseInfo : ossDetectedLicense) {
sb.append(licenseInfo.getLicenseName()).append(",");
}
String[] detectedLicenses = new String(sb).split("[,]");
ossMaster.setOssNicknames(ossNicknames);
ossMaster.setDownloadLocations(ossDownloadLocations);
ossMaster.setOssLicenses(ossLicenses);
ossMaster.setDetectedLicenses(Arrays.asList(detectedLicenses));
return ossMaster;
}
@Override
public Map<String, Object> getOssPopupList(OssMaster ossMaster) {
HashMap<String, Object> map = new HashMap<String, Object>();
ossMaster.setOssName(CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getOssId()).getOssName());
int records = ossMapper.selectOssPopupTotalCount(ossMaster);
ossMaster.setTotListSize(records);
List<OssMaster> list = ossMapper.selectOssPopupList(ossMaster);
map.put("page", ossMaster.getCurPage());
map.put("total", ossMaster.getTotBlockSize());
map.put("records", records);
map.put("rows", list);
return map;
}
@Override
public OssMaster getOssInfo(String ossId, boolean isMailFormat) {
return getOssInfo(ossId, null, isMailFormat);
}
@Override
public OssMaster getOssInfo(String ossId, String ossName, boolean isMailFormat) {
OssMaster param = new OssMaster();
Map<String, OssMaster> map = new HashMap<String, OssMaster>();
if (!isEmpty(ossId)) {
param.addOssIdList(ossId);
map = isMailFormat ? getBasicOssInfoListByIdOnTime(param) : getBasicOssInfoListById(param);
}
if (!isEmpty(ossName)) {
param.setOssName(ossName);
map = getNewestOssInfoOnTime(param);
}
if (map != null) {
// nickname ์ ๋ณด ์ทจ๋
for (OssMaster bean : map.values()) {
param.setOssName(bean.getOssName());
List<OssMaster> nickNameList = ossMapper.selectOssNicknameList(param);
if (nickNameList != null && !nickNameList.isEmpty()) {
List<String> nickNames = new ArrayList<>();
for (OssMaster nickNameBean : nickNameList) {
if (!isEmpty(nickNameBean.getOssNickname())) {
nickNames.add(nickNameBean.getOssNickname());
}
}
bean.setOssNicknames(nickNames.toArray(new String[nickNames.size()]));
}
List<OssMaster> detectedLicenseList = ossMapper.selectOssDetectedLicenseList(bean);
if (detectedLicenseList.size() > 0) {
String detectedLicense = "";
for (OssMaster ossBean : detectedLicenseList) {
if (!isEmpty(detectedLicense)) {
detectedLicense += ", ";
}
detectedLicense += ossBean.getLicenseName();
}
bean.addDetectedLicense(detectedLicense);
}
param.setOssId(ossId);
List<OssMaster> ossDownloadLocation = ossMapper.selectOssDownloadLocationList(param);
if (ossDownloadLocation.size() > 0) {
StringBuilder sb = new StringBuilder();
for (OssMaster location : ossDownloadLocation) {
sb.append(location.getDownloadLocation()).append(",");
}
String[] ossDownloadLocations = new String(sb).split("[,]");
bean.setDownloadLocations(ossDownloadLocations);
}
if (isMailFormat) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(bean.getOssLicenses()));
bean.setOssLicenses(CommonFunction.changeLicenseNameToShort(bean.getOssLicenses()));
// code ๋ณ๊ฒฝ
if (!isEmpty(bean.getLicenseDiv())) {
// multi license ํ์ ์ฌ๋ถ ํ๋จ์ ์ํด์ ์ฝ๋ํ์๋ช
๋ณํ ์ด์ ์ ๊ฐ์ด ํ์ํจ
bean.setMultiLicenseFlag(bean.getLicenseDiv());
bean.setLicenseDiv(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_DIV, bean.getLicenseDiv()));
}
if (!isEmpty(bean.getLicenseType())) {
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, bean.getLicenseType()));
}
if (!isEmpty(bean.getObligationType())) {
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, bean.getObligationType()));
}
// ๋ ์ง ํ์
if (!isEmpty(bean.getModifiedDate())) {
bean.setModifiedDate(DateUtil.dateFormatConvert(bean.getModifiedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
if (!isEmpty(bean.getModifier())) {
bean.setModifier(CoMailManager.getInstance().makeUserNameFormat(bean.getModifier()));
}
if (!isEmpty(bean.getCreatedDate())) {
bean.setCreatedDate(DateUtil.dateFormatConvert(bean.getCreatedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
if (!isEmpty(bean.getCreator())) {
bean.setCreator(CoMailManager.getInstance().makeUserNameFormat(bean.getCreator()));
}
bean.setAttribution(CommonFunction.lineReplaceToBR(bean.getAttribution()));
bean.setSummaryDescription(CommonFunction.lineReplaceToBR(bean.getSummaryDescription()));
bean.setCopyright(CommonFunction.lineReplaceToBR(bean.getCopyright()));
}
return bean;
}
}
return null;
}
private Map<String, OssMaster> getBasicOssInfoListByIdOnTime(OssMaster ossMaster) {
List<OssMaster> list = ossMapper.getBasicOssInfoListById(ossMaster);
return makeBasicOssInfoMap(list, true, false);
}
private Map<String, OssMaster> makeBasicOssInfoMap(List<OssMaster> list, boolean useId, boolean useUpperKey) {
Map<String, OssMaster> map = new HashMap<>();
for (OssMaster bean : list) {
OssMaster targetBean = null;
String key = useId ? bean.getOssId() : bean.getOssName() +"_"+ avoidNull(bean.getOssVersion());
if (useUpperKey) {
key = key.toUpperCase();
}
if (map.containsKey(key)) {
targetBean = map.get(key);
} else {
targetBean = bean;
}
OssLicense subBean = new OssLicense();
subBean.setOssId(bean.getOssId());
subBean.setLicenseId(bean.getLicenseId());
subBean.setLicenseName(bean.getLicenseName());
subBean.setLicenseType(bean.getLicenseType());
subBean.setOssLicenseIdx(bean.getOssLicenseIdx());
subBean.setOssLicenseComb(bean.getOssLicenseComb());
subBean.setOssLicenseText(bean.getOssLicenseText());
subBean.setOssCopyright(bean.getOssCopyright());
// oss์ license type์ license์ license type ์ ์ฉ ์ดํ์ set
bean.setLicenseType(bean.getOssLicenseType());
targetBean.addOssLicense(subBean);
if (map.containsKey(key)) {
map.replace(key, targetBean);
} else {
map.put(key, targetBean);
}
}
return map;
}
@Override
public History work(Object param) {
History h = new History();
OssMaster vo = (OssMaster) param;
OssMaster data = getOssMasterOne(vo);
data.setComment(vo.getComment());
h.sethKey(vo.getOssId());
h.sethTitle(vo.getOssName());
h.sethType(CoConstDef.EVENT_CODE_OSS);
h.setModifier(vo.getLoginUserName());
h.setModifiedDate(vo.getCreatedDate());
h.sethComment("");
h.sethData(data);
return h;
}
@SuppressWarnings("unchecked")
@Override
@Transactional
public void deleteOssWithVersionMerege(OssMaster ossMaster) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
String chagedOssName = CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getNewOssId()).getOssName();
String beforOssName = CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getOssId()).getOssName();
// ๋์ผํ oss์์ ์ด๋ํ๋ ๊ฒฝ์ฐ, nick name์ ๋ณ๋๋ก ๋ฑ๋กํ์ง ์์
OssMaster beforeBean = getOssInfo(ossMaster.getOssId(), false);
// ์ญ์ ๋์ OSS ๋ชฉ๋ก ์ทจ๋
Map<String, Object> rowMap = ossMergeCheckList(ossMaster);
List<OssMaster> rowList = (List<OssMaster>) rowMap.get("rows");
List<Map<String, OssMaster>> mailBeanList = new ArrayList<>();
// ๋ฉ์ผ ๋ฐ์ก์ ์ํ data ์ทจ๋( ๋ฉ์ผ ํ์์ ์ํด ๋ค์ DB Select )
for (OssMaster bean : rowList) {
if (!isEmpty(bean.getMergeStr())) {
// ์ค์ ๋ก ์ญ์ ์ฒ๋ฆฌ๋ ์ค๋ณต๋๋ OSS Version๋ง
if ("Duplicated".equalsIgnoreCase(bean.getMergeStr())) {
// mail ๋ฐ์ก์ ์ํด ์ญ์ ์ data ์ทจ๋
Map<String, OssMaster> mailDiffMap = new HashMap<>();
OssMaster tempBean1 = getOssInfo(bean.getDelOssId(), true);
List<String> ossNickNameList = new ArrayList<String>();
if (tempBean1.getOssNicknames() != null) {
tempBean1.setOssNickname(CommonFunction.arrayToString(tempBean1.getOssNicknames(), "<br>"));
for (String nickName : Arrays.asList(tempBean1.getOssNicknames())) {
ossNickNameList.add(nickName);
}
}
tempBean1.setOssId(bean.getDelOssId());
mailDiffMap.put("before", tempBean1);
OssMaster tempBean2 = getOssInfo(bean.getOssId(), true);
if (tempBean2.getOssNicknames() != null) {
for (String nickName : Arrays.asList(tempBean2.getOssNicknames())){
ossNickNameList.add(nickName);
}
}
ossNickNameList.add(beforOssName);
tempBean2.setOssNickname(CommonFunction.arrayToString(ossNickNameList.toArray(new String[ossNickNameList.size()]), "<br>"));
tempBean2.setOssNicknames(ossNickNameList.toArray(new String[ossNickNameList.size()]));
tempBean2.setOssName(chagedOssName);
mailDiffMap.put("after", tempBean2);
mailBeanList.add(mailDiffMap);
} else {
// ์ค์ ๋ก ์ญ์ ๋๋ ๊ฒ์ ์๋
// ์ด๋ฆ๋ง ๋ณ๊ฒฝํด์ ๋น๊ต ๋ฉ์ผ ๋ฐ์ก
Map<String, OssMaster> mailDiffMap = new HashMap<>();
OssMaster tempBean1 = getOssInfo(bean.getOssId(), true);
if (tempBean1.getOssNicknames() != null) {
tempBean1.setOssNickname(CommonFunction.arrayToString(tempBean1.getOssNicknames(), "<br>"));
}
tempBean1.setOssId(bean.getOssId());
mailDiffMap.put("before", tempBean1);
List<String> ossNickNameList = new ArrayList<String>();
OssMaster tempBean2 = (OssMaster) CommonFunction.copyObject(tempBean1, "OM");
OssMaster beforeBean1 = getOssInfo(ossMaster.getNewOssId(), false);
if (beforeBean1.getOssNicknames() != null) {
for (String nickName : Arrays.asList(beforeBean1.getOssNicknames())) {
ossNickNameList.add(nickName);
}
}
if (tempBean2.getOssNicknames() != null) {
for (String nickName : Arrays.asList(tempBean2.getOssNicknames())){
ossNickNameList.add(nickName);
}
}
ossNickNameList.add(beforOssName);
tempBean2.setOssNickname(CommonFunction.arrayToString(ossNickNameList.toArray(new String[ossNickNameList.size()]), "<br>"));
tempBean2.setOssNicknames(ossNickNameList.toArray(new String[ossNickNameList.size()]));
tempBean2.setOssName(chagedOssName);
mailDiffMap.put("after", tempBean2);
mailBeanList.add(mailDiffMap);
}
}
}
// ์ญ์ ์ฒ๋ฆฌ
for (OssMaster bean : rowList) {
if (!isEmpty(bean.getMergeStr())) {
boolean isDel = false;
OssMaster mergeBean = new OssMaster();
History h = null;
// ์ ๊ท version์ ๋ฑ๋ก์ด ํ์ํ ๊ฒฝ์ฐ
if ("Added".equalsIgnoreCase(bean.getMergeStr())) {
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_OSS);
historyBean.setReferenceId(bean.getOssId());
historyBean.setContents("OSS ์ผ๊ด ์ด๊ด ์ฒ๋ฆฌ์ ์ํด OSS Name์ด ๋ณ๊ฒฝ๋์์ต๋๋ค. <br/>" + "Before OSS Name : " + bean.getOssName() + "<br/>" + avoidNull(ossMaster.getComment()));
bean.setOssName(chagedOssName);
bean.setNewOssId(bean.getOssId()); // ์ญ์ ํ์ง ์๊ณ ์ด๋ฆ๋ง ๋ณ๊ฒฝํด์ ์ฌ์ฌ์ฉํ๋ค.
ossMapper.changeOssNameByDelete(bean);
// Version Flag Setting
updateLicenseDivDetail(bean);
commentService.registComment(historyBean);
mergeBean.setMergeOssId(bean.getOssId());
} else {
// Duplicated
bean.setNewOssId(bean.getOssId());
bean.setOssId(bean.getDelOssId());
h = work(bean);
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_OSS);
historyBean.setReferenceId(bean.getDelOssId());
historyBean.setContents("OSS ์ผ๊ด ์ด๊ด ์ฒ๋ฆฌ์ ์ํด "+bean.getOssName()+" ์ผ๋ก ์ด๊ด๋์์ต๋๋ค.<br/>" + avoidNull(ossMaster.getComment()));
commentService.registComment(historyBean);
historyBean.setReferenceId(bean.getOssId());
historyBean.setContents("OSS ์ผ๊ด ์ด๊ด ์ฒ๋ฆฌ์ ์ํด "+beforOssName+" ๊ณผ ๋ณํฉ๋์์ต๋๋ค.<br/>" + avoidNull(ossMaster.getComment()));
commentService.registComment(historyBean);
ossMapper.deleteOssLicenseFlag(bean.getOssId());
ossMapper.deleteOssLicense(bean);
ossMapper.deleteOssDownloadLocation(bean);
ossMapper.deleteOssMaster(bean);
mergeBean.setMergeOssId(bean.getNewOssId());
isDel = true;
}
//1. ๊ธฐ์กด OssId๋ฅผ ์ฌ์ฉ์ค์ธ ํ๋ก์ ํธ์ OssId , Version ๋ฅผ ์๋ก์ด OssId๋ก ๊ต์ฒด
if (isDel && h != null) {
try{
h.sethAction(CoConstDef.ACTION_CODE_DELETE);
historyService.storeData(h);
}catch(Exception e){
log.error(e.getMessage(), e);
}
}
mergeBean.setOssId(bean.getOssId());
mergeBean.setOssName(beforeBean.getOssName());
mergeBean.setMergeOssName(chagedOssName);
mergeBean.setOssVersion(bean.getOssVersion());
mergeBean.setMergeOssVersion(bean.getOssVersion());
mergeBean.setRegistMergeFlag("N");
ossNameMerge(mergeBean, chagedOssName, beforOssName);
}
}
OssMaster deleteNickParam = new OssMaster();
deleteNickParam.setOssName(beforOssName);
ossMapper.deleteOssNickname(deleteNickParam);
// nick name merge
// ์ผ๋จ ์ญ์ ๋ oss name์ nickname์ผ๋ก ์ถ๊ฐํ๋ค.
OssMaster nickMergeParam = new OssMaster();
nickMergeParam.setOssName(chagedOssName);
nickMergeParam.setOssNickname(beforOssName);
ossMapper.mergeOssNickname2(nickMergeParam);
if (beforeBean.getOssNicknames() != null) {
for (String nickName : beforeBean.getOssNicknames()) {
nickMergeParam.setOssNickname(nickName);
ossMapper.mergeOssNickname2(nickMergeParam);
}
}
CoCodeManager.getInstance().refreshOssInfo();
for (Map<String, OssMaster> mailInfoMap : mailBeanList) {
// ์ญ์ ๋์ OSS๋ฅผ ์ฌ์ฉ์ค์ธ ํ๋ก์ ํธ์ ๋ชฉ๋ก์ ์ฝ๋ฉํธ๋ก ๋จ๊ธด๋ค.
try {
String templateComemnt = makeTemplateComment(ossMaster.getComment(), mailInfoMap.get("before"), mailInfoMap.get("after"));
// ์ฌ์ฉ์ค์ธ ํ๋ก์ ํธ๊ฐ ์๋ ๊ฒฝ์ฐ๋ ์ฝ๋ฉํธ๋ฅผ ์ถ๊ฐ์์ผ๋ก ๋จ๊ธฐ์ง ์๋๋ค.
if (!isEmpty(templateComemnt)) {
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_OSS);
historyBean.setReferenceId(mailInfoMap.get("after").getOssId());
historyBean.setContents(templateComemnt);
commentService.registComment(historyBean);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
CoMail mailBean = new CoMail(CoConstDef.CD_MAIL_TYPE_OSS_RENAME);
mailBean.setCompareDataBefore(mailInfoMap.get("before"));
OssMaster afterOssMaster = (OssMaster) mailInfoMap.get("after");
afterOssMaster.setModifiedDate(DateUtil.getCurrentDateTime());
afterOssMaster.setModifier(CoMailManager.getInstance().makeUserNameFormat(loginUserName()));
mailBean.setCompareDataAfter(afterOssMaster);
mailBean.setParamOssId(mailInfoMap.get("before").getOssId());
mailBean.setComment(ossMaster.getComment());
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
private void ossNameMerge(OssMaster ossMaster, String changedOssName, String beforeOssName) {
String contents = "<p>The following OSS Name has been changed.</p>\r\n" +
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:600px;\">\r\n" +
" <tbody>\r\n" +
" <tr>\r\n" +
" <th>OSS Name(OSS Version) (Written before)</th>\r\n" +
" <th>OSS Name(OSS Version) (Changed)</th>\r\n" +
" </tr>\r\n" +
" <tr>\r\n" +
" <td style=\"text-align:center;\">"+ beforeOssName + " (" + avoidNull(ossMaster.getOssVersion(), "N/A") + ") </td>\r\n" +
" <td style=\"text-align:center;\">"+ changedOssName + " (" + avoidNull(ossMaster.getMergeOssVersion(), "N/A") + ") </td>\r\n" +
" </tr>\r\n" +
" </tbody>\r\n" +
"</table>";
// 3rdParty == 'CONF'
List<PartnerMaster> confirmPartnerList = ossMapper.getOssNameMergePartnerList(ossMaster);
if (confirmPartnerList.size() > 0) {
ossMaster.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
ossMapper.mergeOssName(ossMaster);
for (PartnerMaster pm : confirmPartnerList) {
// partner Comment Regist
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_HIS);
historyBean.setReferenceId(pm.getPartnerId());
historyBean.setStatus("OSS Name Changed");
historyBean.setContents(contents);
commentService.registComment(historyBean);
}
}
// Identification == 'CONF', verification
List<Project> confirmProjectList = ossMapper.getOssNameMergeProjectList(ossMaster);
if (confirmProjectList.size() > 0) {
ossMaster.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
ossMapper.mergeOssName(ossMaster);
for (Project prj : confirmProjectList) {
// Project > Identification comment regist
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceId(prj.getPrjId());
historyBean.setStatus("OSS Name Changed");
historyBean.setContents(contents);
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commentService.registComment(historyBean);
}
}
}
private String makeTemplateComment(String comment, OssMaster ossMasterBefore, OssMaster ossMasterAfter) {
Map<String, Object> convertDataMap = new HashMap<>();
// ์ฌ์ฉ์ค์ธ ํ๋ก์ ํธ๊ฐ ์๋ ๊ฒฝ์ฐ
// ๋ฉ์ผ ๋ฐ์ก์ ์ฌ์ฉ์ฌ๋ ์ฟผ๋ฆฌ์ ๋์ผ
List<Project> prjList = ossMapper.getOssChangeForUserList(ossMasterBefore);
if (prjList != null && !prjList.isEmpty()) {
for (Project prjBean : prjList) {
prjBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, prjBean.getDistributionType()));
prjBean.setCreator(makeUserNameFormatWithDivision(prjBean.getCreator()));
prjBean.setCreatedDate(CommonFunction.formatDateSimple(prjBean.getCreatedDate()));
prjBean.setReviewer(makeUserNameFormatWithDivision(prjBean.getReviewer()));
}
convertDataMap.put("projectList", prjList);
convertDataMap.put("comment", comment);
convertDataMap.put("modifierNm", makeUserNameFormat(loginUserName()));
convertDataMap.put("ossBeforeNm", makeOssNameFormat(ossMasterBefore));
convertDataMap.put("ossAftereNm", makeOssNameFormat(ossMasterAfter));
convertDataMap.put("templateURL", "/template/comment/ossRenamed.html");
return CommonFunction.VelocityTemplateToString(convertDataMap);
}
return null;
}
private String makeUserNameFormatWithDivision(String userId) {
String rtnVal = "";
T2Users userParam = new T2Users();
userParam.setUserId(userId);
T2Users userInfo = userMapper.getUser(userParam);
if (userInfo != null && !isEmpty(userInfo.getUserName())) {
if (!isEmpty(userInfo.getDivision())) {
String _division = CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, userInfo.getDivision());
if (!isEmpty(_division)) {
rtnVal += _division + " ";
}
}
rtnVal += userInfo.getUserName() + "(" + userId + ")";
}
return isEmpty(rtnVal) ? userId : rtnVal;
}
private String makeUserNameFormat(String userId) {
String rtn = userId;
T2Users param = new T2Users();
param.setUserId(userId);
T2Users userInfo = userMapper.getUser(param);
if (userInfo != null) {
rtn = avoidNull(userInfo.getUserName());
rtn += "(" + avoidNull(userInfo.getUserId()) + ")";
}
return rtn;
}
private String makeOssNameFormat(OssMaster bean) {
String rtnVal = "";
if (bean != null) {
rtnVal = avoidNull(bean.getOssName());
if (!isEmpty(bean.getOssVersion())) {
rtnVal += " (" + bean.getOssVersion() + ")";
}
}
return rtnVal;
}
@Override
public String[] checkNickNameRegOss(String ossName, String[] ossNicknames) {
List<String> rtnList = new ArrayList<>();
List<String> currntList = null;
if (ossNicknames != null && ossNicknames.length > 0) {
currntList = Arrays.asList(ossNicknames);
}
if (currntList == null) {
currntList = new ArrayList<>();
}
if (!isEmpty(ossName)) {
// oss name์ผ๋ก ๋ฑ๋ก๋ nick name์ด ์๋์ง ํ์ธ
List<String> _nickNames = ossMapper.checkNickNameRegOss(ossName);
if (_nickNames != null && !_nickNames.isEmpty()) {
for (String s : _nickNames) {
if (!isEmpty(s) && !currntList.contains(s)) {
rtnList.add(s);
}
}
}
}
return rtnList.toArray(new String[rtnList.size()]);
}
@Override
public String checkExistOssConf(String ossId) {
int resultCnt = 0;
boolean projectFlag = CommonFunction.propertyFlagCheck("menu.project.use.flag", CoConstDef.FLAG_YES);
boolean partnerFlag = CommonFunction.propertyFlagCheck("menu.partner.use.flag", CoConstDef.FLAG_YES);
if (projectFlag) {
resultCnt += ossMapper.checkExistOssConfProject(CoCodeManager.OSS_INFO_BY_ID.get(ossId));
}
if (partnerFlag) {
resultCnt += ossMapper.checkExistOssConfPartner(CoCodeManager.OSS_INFO_BY_ID.get(ossId));
}
return Integer.toString(resultCnt);
}
@Transactional
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
public String registOssMaster(OssMaster ossMaster) {
try {
String[] ossNicknames = ossMaster.getOssNicknames();
String ossId = ossMaster.getOssId();
boolean isNew = StringUtil.isEmpty(ossId);
OssMaster orgMasterInfo = null;
if (StringUtil.isEmpty(ossId)){
ossMaster.setCreator(ossMaster.getLoginUserName());
} else {
orgMasterInfo = new OssMaster();
orgMasterInfo.setOssId(ossId);
orgMasterInfo = getOssMasterOne(orgMasterInfo);
}
// oss name ๋๋ version์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ๋ง vulnerability recheck ๋์์ผ๋ก ์
๋ฐ์ดํธ ํ๋ค.
boolean vulnRecheck = false;
// ๋ณ๊ฒฝ์ oss name์ ํด๋นํ๋ oss_id ๋ชฉ๋ก์ ์ฐพ๋๋ค.
if (!isNew) {
OssMaster _orgBean = getOssInfo(ossId, false);
if (_orgBean != null && !isEmpty(_orgBean.getOssName())) {
if (!avoidNull(ossMaster.getOssName()).trim().equalsIgnoreCase(_orgBean.getOssName())
|| !avoidNull(ossMaster.getOssVersion()).trim().equalsIgnoreCase(avoidNull(_orgBean.getOssVersion()).trim())) {
vulnRecheck = true;
}
if (!avoidNull(ossMaster.getOssName()).trim().equalsIgnoreCase(_orgBean.getOssName())) {
// ๋ณ๊ฒฝ ์ oss name ์ ๋ฑ๋ก๋ nickname ์ญ์
_orgBean.setOssId(null);
List<OssMaster> beforeOssNameList = ossMapper.getOssListByName(_orgBean);
if (beforeOssNameList != null) {
int ossIdCnt = beforeOssNameList.stream().map(e -> e.getOssId()).distinct().collect(Collectors.toList()).size();
if (ossIdCnt == 1) {
ossMapper.deleteOssNickname(_orgBean);
}
}
}
}
}
if (vulnRecheck) {
ossMaster.setVulnRecheck(CoConstDef.FLAG_YES);
}
ossMaster.setModifier(ossMaster.getLoginUserName());
// trim์ฒ๋ฆฌ
ossMaster.setOssName(avoidNull(ossMaster.getOssName()).trim());
checkOssLicenseAndObligation(ossMaster);
ossMapper.insertOssMaster(ossMaster);
ossMapper.deleteOssLicense(ossMaster); // Declared, Detected License Delete ์ฒ๋ฆฌ
// v-Diff ์ฒดํฌ๋ฅผ ์ํด license list๋ฅผ ์์ฑ
List<OssLicense> list = ossMaster.getOssLicenses();
int ossLicenseDeclaredIdx = 0;
String licenseId = "";
for (OssLicense license : list) {
ossLicenseDeclaredIdx++;
licenseId = CommonFunction.getLicenseIdByName(license.getLicenseName());
OssMaster om = new OssMaster(
Integer.toString(ossLicenseDeclaredIdx)
, ossMaster.getOssId()
, licenseId
, license.getLicenseName()
, ossLicenseDeclaredIdx == 1 ? "" : license.getOssLicenseComb()//ossLicenseIdx๊ฐ 1์ผ๋ Comb ์
๋ ฅ์ํจ
, license.getOssLicenseText()
, license.getOssCopyright()
, ossMaster.getLicenseDiv()
);
ossMapper.insertOssLicenseDeclared(om);
}
// Detected License Insert / 20210806_Distinct Add
List<String> detectedLicenses = ossMaster.getDetectedLicenses().stream().distinct().collect(Collectors.toList());
if (detectedLicenses != null) {
int ossLicenseDetectedIdx = 0;
for (String detectedLicense : detectedLicenses) {
if (!isEmpty(detectedLicense)) {
LicenseMaster detectedLicenseInfo = CoCodeManager.LICENSE_INFO_UPPER.get(detectedLicense.toUpperCase().trim());
if (detectedLicenseInfo != null) {
OssMaster om = new OssMaster(
ossMaster.getOssId() // ossId
, detectedLicenseInfo.getLicenseId() // licenseId
, Integer.toString(++ossLicenseDetectedIdx) // ossLicenseIdx
);
ossMapper.insertOssLicenseDetected(om);
}
}
}
}
if (ossMaster.getOssLicenses() != null) {
for (OssLicense license : ossMaster.getOssLicenses()) {
// v-Diff check๋ฅผ ์ํด ๋ง์ฝ license id๊ฐ param Bean์ ์๋ ๊ฒฝ์ฐ, license id๋ฅผ ๋ฑ๋กํ๋ค.
if (isEmpty(license.getLicenseId())) {
if (CoCodeManager.LICENSE_INFO_UPPER.containsKey(license.getLicenseName().toUpperCase())) {
license.setLicenseId(CoCodeManager.LICENSE_INFO_UPPER.get(license.getLicenseName().toUpperCase()).getLicenseId());
}
}
}
}
/*
* 1. ๋ผ์ด์ผ์ค ๋๋ค์ ์ญ์
* 2. ๋ผ์ด์ผ์ค ๋๋ค์ ์ฌ๋ฑ๋ก
*/
if (CoConstDef.FLAG_YES.equals(ossMaster.getAddNicknameYn())) { //nickname์ clear&insert ํ์ง ์๊ณ , ์ค๋ณต์ ๊ฑฐ๋ฅผ ํ ๋๋จธ์ง nickname์ ๋ํด์๋ addํจ.
if (ossNicknames != null){
List<OssMaster> ossNicknameList = ossMapper.selectOssNicknameList(ossMaster);
for (String nickName : ossNicknames){
if (!isEmpty(nickName)) {
int duplicateCnt = ossNicknameList.stream().filter(o -> nickName.toUpperCase().equals(o.getOssNickname().toUpperCase())).collect(Collectors.toList()).size();
if (duplicateCnt == 0) {
OssMaster ossBean = new OssMaster();
ossBean.setOssName(ossMaster.getOssName());
ossBean.setOssNickname(nickName.trim());
ossMapper.insertOssNickname(ossBean);
}
}
}
}
} else { // nickname => clear&insert
if (ossNicknames != null) {
ossMapper.deleteOssNickname(ossMaster);
for (String nickName : ossNicknames){
if (!isEmpty(nickName)) {
ossMaster.setOssNickname(nickName.trim());
ossMapper.insertOssNickname(ossMaster);
}
}
} else {
ossMapper.deleteOssNickname(ossMaster);
}
}
//์ฝ๋ฉํธ ๋ฑ๋ก
if (!isEmpty(avoidNull(ossMaster.getComment()).trim())) {
CommentsHistory param = new CommentsHistory();
param.setReferenceId(ossMaster.getOssId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_OSS);
param.setContents(ossMaster.getComment());
commentService.registComment(param);
}
if (isNew || vulnRecheck) {
List<String> ossNameArr = new ArrayList<>();
ossNameArr.add(ossMaster.getOssName().trim());
if (ossMaster.getOssName().contains(" ")) {
ossNameArr.add(ossMaster.getOssName().replaceAll(" ", "_"));
}
if (ossNicknames != null) {
for (String s : ossNicknames) {
if (!isEmpty(s)) {
ossNameArr.add(s.trim());
}
}
}
OssMaster nvdParam = new OssMaster();
nvdParam.setOssNames(ossNameArr.toArray(new String[ossNameArr.size()]));
OssMaster nvdData = null;
if (!isEmpty(ossMaster.getOssVersion())) {
nvdParam.setOssVersion(ossMaster.getOssVersion());
nvdData = ossMapper.getNvdDataByOssName(nvdParam);
} else {
nvdData = ossMapper.getNvdDataByOssNameWithoutVer(nvdParam);
}
if (nvdData != null) {
ossMaster.setCvssScore(nvdData.getCvssScore());
ossMaster.setCveId(nvdData.getCveId());
ossMaster.setVulnDate(nvdData.getVulnDate());
ossMaster.setVulnYn(CoConstDef.FLAG_YES);
ossMapper.updateNvdData(ossMaster);
} else if (!isNew) {
OssMaster _orgBean = getOssInfo(ossId, false);
if (_orgBean != null && (CoConstDef.FLAG_YES.equals(_orgBean.getVulnYn()) || !isEmpty(_orgBean.getCvssScore()))) {
ossMaster.setVulnYn(CoConstDef.FLAG_NO);
ossMapper.updateNvdData(ossMaster);
}
}
}
// Version Flag Setting
updateLicenseDivDetail(ossMaster);
// download location์ด ์ฌ๋ฌ๊ฑด์ผ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด table์ ๋ณ๋๋ก ๊ด๋ฆฌํจ.
registOssDownloadLocation(ossMaster);
// Deactivate Flag Setting
if (isEmpty(ossMaster.getDeactivateFlag())) {
ossMaster.setDeactivateFlag(CoConstDef.FLAG_NO);
}
ossMapper.setDeactivateFlag(ossMaster);
// updated oss info, oss components > ossName update
if (!isNew && orgMasterInfo != null){
if (!orgMasterInfo.getOssName().equals(ossMaster.getOssName())) {
// oss name merge
ossMaster.setRegistMergeFlag("Y");
ossMaster.setMergeOssName(ossMaster.getOssName());
ossMaster.setOssName(orgMasterInfo.getOssName());
ossMaster.setMergeOssVersion(ossMaster.getOssVersion());
ossMaster.setOssVersion(orgMasterInfo.getOssVersion());
ossNameMerge(ossMaster, ossMaster.getMergeOssName(), orgMasterInfo.getOssName());
}
}
} catch (RuntimeException ex) {
log.error(ex.getMessage(), ex);
throw ex;
} catch (Exception ex2) {
log.error(ex2.getMessage(), ex2);
}
return ossMaster.getOssId();
}
@Override
public void registOssDownloadLocation(OssMaster ossMaster) {
if (ossMapper.existsOssDownloadLocation(ossMaster) > 0){
ossMapper.deleteOssDownloadLocation(ossMaster);
}
int idx = 0;
String[] downloadLocations = ossMaster.getDownloadLocations();
if (downloadLocations != null){
for (String url : downloadLocations){
if (!isEmpty(url)){ // ๊ณต๋ฐฑ์ downloadLocation์ saveํ์ง ์์.
OssMaster master = new OssMaster();
master.setOssId(ossMaster.getOssId());
master.setDownloadLocation(url);
master.setSortOrder(Integer.toString(++idx));
ossMapper.insertOssDownloadLocation(master);
}
}
}
}
@Override
public Map<String, Object> ossMergeCheckList(OssMaster ossMaster) {
Map<String, Object> map = new HashMap<String, Object>();
List<OssMaster> list1 = ossMapper.getBasicOssListByName(CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getOssId()).getOssName());
List<OssMaster> list2 = ossMapper.getBasicOssListByName(CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getNewOssId()).getOssName());
Map<String, OssMaster> mergeMap = new HashMap<>();
// ์ด๊ด ๋์ OSS ์ ๋ณด๋ฅผ ๋จผ์ ๊ฒฉ๋ฉํ๋ค.
for (OssMaster bean : list2) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(CoCodeManager.OSS_INFO_BY_ID.get(bean.getOssId()).getOssLicenses()));
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, bean.getLicenseType()));
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, bean.getObligationType()));
mergeMap.put(avoidNull(bean.getOssVersion(), "N/A").toUpperCase(), bean);
}
// ์ญ์ ๋์ OSS Version์ด ์ด๊ด ๋์ OSS ์ ์กด์ฌํ๋์ง ํ์ธ
for (OssMaster bean : list1) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(CoCodeManager.OSS_INFO_BY_ID.get(bean.getOssId()).getOssLicenses()));
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, bean.getLicenseType()));
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, bean.getObligationType()));
String verKey = avoidNull(bean.getOssVersion(), "N/A").toUpperCase();
// ์ด๋ฏธ ์กด์ฌํ๋ค๋ฉด
if (mergeMap.containsKey(verKey)) {
mergeMap.get(verKey).setMergeStr("Duplicated");
mergeMap.get(verKey).setDelOssId(bean.getOssId());
} else {
bean.setMergeStr("Added");
mergeMap.put(verKey, bean);
}
}
Map<String, OssMaster> treeMap = new TreeMap<>(mergeMap);
map.put("rows", new ArrayList<>(treeMap.values()));
return map;
}
@SuppressWarnings("unchecked")
@Transactional
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
public void deleteOssMaster(OssMaster ossMaster) {
OssMaster beforeBean = getOssInfo(ossMaster.getOssId(), false);
if (isEmpty(ossMaster.getOssName())) {
ossMaster.setOssName(beforeBean.getOssName());
}
// ๋ฐ๋ก ์ญ์ ์ผ ๊ฒฝ์ฐ( identification ์ํ๊ฐ conf์ธ ํ๋ก์ ํธ๊ฐ ์์์ )
if (CoConstDef.FLAG_NO.equals(avoidNull(ossMaster.getNewOssId(), CoConstDef.FLAG_NO))) {
//3. ๊ธฐ์กด์ Oss ์ญ์
//ossMapper.deleteOssNickname(ossMaster);
// ๋๋ค์์ ์ด๋ฆ์ผ๋ก ๋งคํ๋๊ธฐ ๋๋ฌธ์, ์ญ์ ํ์ ์ ๊ท ์ถ๊ฐ์ ์๋์ผ๋ก ์ค์ ๋๋ ๋ฌธ์ ๊ฐ ์์
// ์ญ์ ํ๋ oss ์ด๋ฆ์ผ๋ก ๊ณต์ ํ๋ ๋๋ค์์ด ๋์ด์ ์์ ๊ฒฝ์ฐ, ๋๋ค์๋ ์ญ์ ํ๋๋ก ์ถ๊ฐ
if (ossMapper.checkHasAnotherVersion(ossMaster) == 0) {
ossMapper.deleteOssNickname(ossMaster);
}
ossMapper.deleteOssLicense(ossMaster);
ossMapper.deleteOssLicenseDeclaredSync(ossMaster);
ossMapper.deleteOssLicenseDetectedSync(ossMaster);
updateLicenseDivDetail(ossMaster);
ossMapper.deleteOssDownloadLocation(ossMaster);
ossMapper.deleteOssMaster(ossMaster);
} else {
// ๋์ผํ oss์์ ์ด๋ํ๋ ๊ฒฝ์ฐ, nick name์ ๋ณ๋๋ก ๋ฑ๋กํ์ง ์์
OssMaster afterBean = getOssInfo(ossMaster.getNewOssId(), false);
if (!beforeBean.getOssName().toUpperCase().equals(afterBean.getOssName().toUpperCase())) {
//2. ๊ธฐ์กด Oss ์ Name ๊ณผ Nickname์ ํ์ฌ ์ ํํ Oss์ Nickname ์ ๋ณํฉ
ArrayList<String> nickNamesArray = new ArrayList<>();
Map<String, Object> map = ossMapper.selectOssNameMap(ossMaster);
String ossName = (String)map.get("ossName");
List<Map<String, String>> list = (List<Map<String, String>>) map.get("nicknameList");
nickNamesArray.add(ossName);
for (Map<String, String> nickMap : list){
nickNamesArray.addAll(new ArrayList<String>(nickMap.values()));
}
for (String nickname : nickNamesArray){
ossMaster.setOssNickname(nickname);
ossMapper.mergeOssNickname(ossMaster);
}
}
if (ossMapper.checkHasAnotherVersion(ossMaster) == 0) {
ossMapper.deleteOssNickname(ossMaster);
}
ossMapper.deleteOssLicense(ossMaster);
ossMapper.deleteOssLicenseDeclaredSync(ossMaster);
ossMapper.deleteOssLicenseDetectedSync(ossMaster);
ossMapper.deleteOssLicenseFlag(ossMaster.getOssId());
updateLicenseDivDetail(ossMaster);
ossMapper.deleteOssDownloadLocation(ossMaster);
ossMapper.deleteOssMaster(ossMaster);
}
}
@Override
public OssMaster checkExistsOss(OssMaster param) {
OssMaster bean = ossMapper.checkExistsOss(param);
if (bean != null && !isEmpty(bean.getOssId())) {
return bean;
}
return null;
}
@Override
public OssMaster checkExistsOssNickname(OssMaster param) {
OssMaster bean1 = ossMapper.checkExistsOssname(param);
if (bean1 != null && !isEmpty(bean1.getOssId())) {
return bean1;
}
OssMaster bean2 = ossMapper.checkExistsOssNickname(param);
if (bean2 != null && !isEmpty(bean2.getOssId())) {
return bean2;
}
if (!isEmpty(param.getOssId())) {
OssMaster bean3 = ossMapper.checkExistsOssNickname2(param);
if (bean3 != null) {
return bean3;
}
}
return null;
}
@Override
public OssMaster checkExistsOssNickname2(OssMaster param) {
OssMaster bean2 = ossMapper.checkExistsOssNickname(param);
if (bean2 != null && !isEmpty(bean2.getOssId())) {
return bean2;
}
return null;
}
@Override
public Map<String, OssMaster> getBasicOssInfoListById(OssMaster ossMaster) {
Map<String, OssMaster> resultMap = new HashMap<>();
if (CoCodeManager.OSS_INFO_BY_ID != null && ossMaster.getOssIdList() != null && !ossMaster.getOssIdList().isEmpty()) {
for (String ossId : ossMaster.getOssIdList()) {
if (CoCodeManager.OSS_INFO_BY_ID.containsKey(ossId)) {
resultMap.put(ossId, CoCodeManager.OSS_INFO_BY_ID.get(ossId));
}
}
}
return resultMap;
}
@Override
public List<OssMaster> getOssListByName(OssMaster bean) {
List<OssMaster> list = ossMapper.getOssListByName(bean);
if (list == null) {
list = new ArrayList<>();
}
// oss id๋ก ์ทจํฉ(๋ผ์ด์ ์ค ์ ๋ณด)
List<OssMaster> newList = new ArrayList<>();
Map<String, OssMaster> remakeMap = new HashMap<>();
OssMaster currentBean = null;
for (OssMaster ossBean : list) {
// name + version
if (!isEmpty(ossBean.getOssVersion())) {
ossBean.setOssNameVerStr(ossBean.getOssName() + " (" + ossBean.getOssVersion() + ")");
} else {
ossBean.setOssNameVerStr(ossBean.getOssName());
}
if (remakeMap.containsKey(ossBean.getOssId())) {
currentBean = remakeMap.get(ossBean.getOssId());
} else {
currentBean = ossBean;
if (!isEmpty(currentBean.getOssNickname())) {
currentBean.setOssNickname(currentBean.getOssNickname().replaceAll("\\|", "<br>"));
}
currentBean.setCopyright(CommonFunction.lineReplaceToBR(ossBean.getCopyright()));
currentBean.setSummaryDescription(CommonFunction.lineReplaceToBR(ossBean.getSummaryDescription()));
String detectedLicense = avoidNull(ossBean.getDetectedLicense());
List<String> detectedLicenseList = Arrays.asList(detectedLicense.split(","));
String resultDectedLicense = "";
String resultLicenseText = "";
if (!isEmpty(detectedLicense)) {
for (String dl : detectedLicenseList) {
LicenseMaster licenseMaster = null;
if (CoCodeManager.LICENSE_INFO.containsKey(dl)) {
licenseMaster = CoCodeManager.LICENSE_INFO.get(dl);
}
if (licenseMaster != null) {
resultDectedLicense += "<a href='javascript:void(0);' class='urlLink' onclick='showLicenseText(" + avoidNull(licenseMaster.getLicenseId()) + ");' >" + dl + "</a>";
resultLicenseText += "<div id='license_"+ avoidNull(licenseMaster.getLicenseId())+"' class='classLicenseText' style='display: none;'>"+CommonFunction.lineReplaceToBR(avoidNull(licenseMaster.getLicenseText()))+"</div>";
}
}
ossBean.setDetectedLicense(resultDectedLicense + resultLicenseText);
}
}
OssLicense licenseBean = new OssLicense();
licenseBean.setLicenseId(ossBean.getLicenseId());
licenseBean.setOssLicenseIdx(ossBean.getOssLicenseIdx());
licenseBean.setLicenseName(ossBean.getLicenseName());
licenseBean.setOssLicenseComb(ossBean.getOssLicenseComb());
licenseBean.setOssLicenseText(CommonFunction.lineReplaceToBR(ossBean.getOssLicenseText()));
licenseBean.setOssCopyright(CommonFunction.lineReplaceToBR(ossBean.getOssCopyright()));
currentBean.addOssLicense(licenseBean);
if (remakeMap.containsKey(ossBean.getOssId())) {
remakeMap.replace(ossBean.getOssId(), currentBean);
} else {
remakeMap.put(ossBean.getOssId(), currentBean);
}
}
for (OssMaster ossBean : remakeMap.values()) {
ossBean.setLicenseName(CommonFunction.makeLicenseExpression(ossBean.getOssLicenses(), !isEmpty(bean.getOssId())));
newList.add(ossBean);
}
return newList;
}
@Override
public void updateLicenseDivDetail(OssMaster master) {
if (master != null && !isEmpty(master.getOssId())) {
boolean multiLicenseFlag = false;
boolean dualLicenseFlag = false;
boolean vDiffFlag = false;
// Update multi / dual flag
OssMaster updateParam = new OssMaster();
// version ์ ๋ฐ๋ผ ๋ผ์ด์ ์ค๊ฐ ๋ฌ๋ผ์ง๋์ง ์ฒดํฌ (v-diff)
OssMaster param = new OssMaster();
List<String> ossNameList = new ArrayList<>();
ossNameList.add(master.getOssName());
String[] ossNames = new String[ossNameList.size()];
param.setOssNames(ossNameList.toArray(ossNames));
// oss name ๋๋ nick name์ผ๋ก ์ฐธ์กฐ ๊ฐ๋ฅํ oss ์ด๋ฆ๋ง์ผ๋ก ๊ฒ์ํ db ์ ๋ณด
Map<String, OssMaster> ossMap = getBasicOssInfoList(param);
// size๊ฐ 1๊ฐ์ธ ๊ฒฝ์ฐ๋ ์ฒ๋ฆฌํ ํ์ ์์
List<String> ossIdListByName = new ArrayList<>();
ossIdListByName.add(master.getOssId());
if (ossMap != null && ossMap.size() > 1) {
// ๋น๊ต๋์ key๋ฃฐ ๋จผ์ ์ค์
List<List<OssLicense>> andCombLicenseListStandard = new ArrayList<>();
List<List<OssLicense>> andCombLicenseListCompare = new ArrayList<>();
int idx = 0;
for (OssMaster _bean : ossMap.values()) {
if (!isEmpty(_bean.getOssId())) {
for (OssLicense license : _bean.getOssLicenses()) {
if ("AND".equalsIgnoreCase(license.getOssLicenseComb())) {
multiLicenseFlag = true;
}
if ("OR".equalsIgnoreCase(license.getOssLicenseComb())) {
dualLicenseFlag = true;
}
}
updateParam.setOssId(_bean.getOssId());
updateParam.setMultiLicenseFlag(multiLicenseFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
updateParam.setDualLicenseFlag(dualLicenseFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
ossMapper.updateOssLicenseFlag(updateParam);
updateParam = new OssMaster();
multiLicenseFlag = false;
dualLicenseFlag = false;
ossIdListByName.add(_bean.getOssId());
if (idx == 0) {
andCombLicenseListStandard = makeLicenseKeyList(_bean.getOssLicenses());
}else {
if (!vDiffFlag && _bean.getOssLicenses() != null) {
andCombLicenseListCompare = makeLicenseKeyList(_bean.getOssLicenses());
if (andCombLicenseListStandard.size() != andCombLicenseListCompare.size()) {
vDiffFlag = true;
}else {
if (!checkLicenseListVersionDiff(andCombLicenseListStandard, andCombLicenseListCompare)) {
vDiffFlag = true;
}
}
andCombLicenseListCompare = new ArrayList<>();
}
}
idx++;
}
}
} else {
String ossId = "";
if (ossMap != null) {
for (OssMaster _bean : ossMap.values()) {
if (!isEmpty(_bean.getOssId())) {
ossId = _bean.getOssId();
for (OssLicense license : _bean.getOssLicenses()) {
if ("AND".equalsIgnoreCase(license.getOssLicenseComb())) {
multiLicenseFlag = true;
}
if ("OR".equalsIgnoreCase(license.getOssLicenseComb())) {
dualLicenseFlag = true;
}
}
ossIdListByName.add(_bean.getOssId());
}
}
}else {
if (CoConstDef.LICENSE_DIV_MULTI.equals(master.getLicenseDiv())) {
ossId = master.getOssId();
for (OssLicense license : master.getOssLicenses()) {
if ("AND".equalsIgnoreCase(license.getOssLicenseComb())) {
multiLicenseFlag = true;
}
if ("OR".equalsIgnoreCase(license.getOssLicenseComb())) {
dualLicenseFlag = true;
}
}
}
}
if (ossId.isEmpty()) {
ossId = master.getOssId();
}
updateParam.setOssId(ossId);
updateParam.setMultiLicenseFlag(multiLicenseFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
updateParam.setDualLicenseFlag(dualLicenseFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
ossMapper.updateOssLicenseFlag(updateParam);
}
ossIdListByName = ossIdListByName.stream().distinct().collect(Collectors.toList());
updateParam.setOssIdList(ossIdListByName);
updateParam.setVersionDiffFlag(vDiffFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
ossMapper.updateOssLicenseVDiffFlag(updateParam);
}
}
private boolean checkLicenseListVersionDiff(List<List<OssLicense>> andCombLicenseListStandard, List<List<OssLicense>> andCombLicenseListCompare) {
List<String> standardKey = new ArrayList<>();
List<String> compareKey = new ArrayList<>();
String licenseId = "";
for (List<OssLicense> standardList : andCombLicenseListStandard) {
standardList.sort(Comparator.comparing(OssLicense::getLicenseId));
for (OssLicense ol : standardList) {
licenseId += ol.getLicenseId() + ",";
}
standardKey.add(licenseId.substring(0, licenseId.length()-1));
licenseId = "";
}
for (List<OssLicense> compareList : andCombLicenseListCompare) {
compareList.sort(Comparator.comparing(OssLicense::getLicenseId));
for (OssLicense ol : compareList) {
licenseId += ol.getLicenseId() + ",";
}
compareKey.add(licenseId.substring(0, licenseId.length()-1));
licenseId = "";
}
return standardKey.containsAll(compareKey);
}
@Override
public OssMaster getLastModifiedOssInfoByName(OssMaster bean) {
return ossMapper.getLastModifiedOssInfoByName(bean);
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> checkVdiff(Map<String, Object> reqMap) {
Map<String, Object> rtnMap = new HashMap<>();
boolean vDiffFlag = false;
// version ์ ๋ฐ๋ผ ๋ผ์ด์ ์ค๊ฐ ๋ฌ๋ผ์ง๋์ง ์ฒดํฌ (v-diff)
OssMaster param = new OssMaster();
String ossId = avoidNull((String) reqMap.get("ossId"));
String ossName = (String) reqMap.get("ossName");
String ossVersion = "";
if (reqMap.containsKey("ossVersion")) ossVersion = (String) reqMap.get("ossVersion");
List<OssLicense> license = (List<OssLicense>) reqMap.get("license");
String[] ossNames = new String[1];
ossNames[0] = ossName;
param.setOssNames(ossNames);
// oss name ๋๋ nick name์ผ๋ก ์ฐธ์กฐ ๊ฐ๋ฅํ oss ์ด๋ฆ๋ง์ผ๋ก ๊ฒ์ํ db ์ ๋ณด
Map<String, OssMaster> ossMap = getBasicOssInfoList(param);
// size๊ฐ 1๊ฐ์ธ ๊ฒฝ์ฐ๋ ์ฒ๋ฆฌํ ํ์ ์์
List<String> ossIdListByName = new ArrayList<>();
ossIdListByName.add(ossId);
if (ossMap != null && !ossMap.isEmpty()) {
// ๋น๊ต๋์ key๋ฃฐ ๋จผ์ ์ค์
String _key = makeLicenseIdKeyStr(license);
for (OssMaster _bean : ossMap.values()) {
if (!isEmpty(_bean.getOssId())) {
ossIdListByName.add(_bean.getOssId());
if (_bean.getOssLicenses() != null && !ossId.equals(_bean.getOssId())) {
if (!_key.equals(makeLicenseIdKeyStr(_bean.getOssLicenses()))) {
vDiffFlag = true;
break;
}
}
}
}
}
rtnMap.put("vFlag", vDiffFlag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO);
if (vDiffFlag && !isEmpty(ossVersion)) {
if (ossMapper.checkOssVersionDiff(ossName) == 0) {
List<String> firstVersionDiffList = new ArrayList<>();
for (String key : ossMap.keySet()) {
OssMaster om = ossMap.get(key);
firstVersionDiffList.add(om.getOssName() + " (" + om.getOssVersion() + ")|" + CommonFunction.makeLicenseExpression(om.getOssLicenses()));
}
rtnMap.put("resultData", firstVersionDiffList);
}
}
return rtnMap;
}
private List<List<OssLicense>> makeLicenseKeyList(List<OssLicense> list) {
List<List<OssLicense>> andCombLicenseList = new ArrayList<>();
for (OssLicense license : list) {
if (andCombLicenseList.isEmpty() || "OR".equals(license.getOssLicenseComb())) {
andCombLicenseList.add(new ArrayList<>());
}
andCombLicenseList.get(andCombLicenseList.size()-1).add(license);
}
return andCombLicenseList;
}
private String makeLicenseIdKeyStr(List<OssLicense> list) {
String rtnVal = "";
List<String> licenseIdList = new ArrayList<>();
if (list != null) {
for (OssLicense bean : list) {
licenseIdList.add(bean.getLicenseId());
}
}
Collections.sort(licenseIdList);
for (String s : licenseIdList) {
if (!isEmpty(rtnVal)) {
rtnVal += "-";
}
rtnVal += s;
}
return rtnVal;
}
@Override
public void checkOssLicenseAndObligation(OssMaster ossMaster) {
List<List<OssLicense>> orLicenseList = new ArrayList<>();
String currentType = null;
String currentObligation = null;
boolean isFirst = true;
List<OssLicense> andLicenseList = new ArrayList<>();
for (OssLicense license : ossMaster.getOssLicenses()) {
LicenseMaster master = CoCodeManager.LICENSE_INFO_UPPER.get(license.getLicenseName().toUpperCase());
master = master != null ? master : new LicenseMaster();
if (!isEmpty(master.getLicenseId()) && !license.getLicenseId().equals(master.getLicenseId())) {
license.setLicenseId(master.getLicenseId());
}
license.setLicenseType(master.getLicenseType());
// obligation ์ค์
if (CoConstDef.FLAG_YES.equals(avoidNull(master.getObligationNeedsCheckYn()))) {
license.setObligation(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK);
} else if (CoConstDef.FLAG_YES.equals(avoidNull(master.getObligationDisclosingSrcYn()))) {
license.setObligation(CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE);
} else if (CoConstDef.FLAG_YES.equals(avoidNull(master.getObligationNotificationYn()))) {
license.setObligation(CoConstDef.CD_DTL_OBLIGATION_NOTICE);
}
if (!isFirst && "OR".equalsIgnoreCase(license.getOssLicenseComb()) ) {
if (!andLicenseList.isEmpty()) {
orLicenseList.add(andLicenseList);
andLicenseList = new ArrayList<>();
andLicenseList.add(license);
}
andLicenseList = new ArrayList<>();
andLicenseList.add(license);
} else {
andLicenseList.add(license);
}
isFirst = false;
}
if (!andLicenseList.isEmpty()) {
orLicenseList.add(andLicenseList);
}
// or์ธ ๊ฒฝ์ฐ๋ Permissiveํ ๊ฑธ๋ก, and์ธ ๊ฒฝ์ฐ๋ Copyleft ๊ฐ ๊ฐํ ๊ฒ์ผ๋ก ํ์
for (List<OssLicense> andlicenseGroup : orLicenseList) {
OssLicense permissiveLicense = CommonFunction.getLicensePermissiveTypeLicense(andlicenseGroup);
if (permissiveLicense != null) {
switch (permissiveLicense.getLicenseType()) {
case CoConstDef.CD_LICENSE_TYPE_PMS:
currentType = CoConstDef.CD_LICENSE_TYPE_PMS;
currentObligation = CommonFunction.getObligationTypeWithAndLicense(andlicenseGroup);
break;
case CoConstDef.CD_LICENSE_TYPE_WCP:
if (!CoConstDef.CD_LICENSE_TYPE_PMS.equals(currentType)) {
currentType = CoConstDef.CD_LICENSE_TYPE_WCP;
currentObligation = CommonFunction.getObligationTypeWithAndLicense(andlicenseGroup);
}
break;
case CoConstDef.CD_LICENSE_TYPE_CP:
if (!CoConstDef.CD_LICENSE_TYPE_PMS.equals(currentType)
&& !CoConstDef.CD_LICENSE_TYPE_WCP.equals(currentType)) {
currentType = CoConstDef.CD_LICENSE_TYPE_CP;
currentObligation = CommonFunction.getObligationTypeWithAndLicense(andlicenseGroup);
}
break;
case CoConstDef.CD_LICENSE_TYPE_PF:
if (!CoConstDef.CD_LICENSE_TYPE_PMS.equals(currentType)
&& !CoConstDef.CD_LICENSE_TYPE_WCP.equals(currentType)
&& !CoConstDef.CD_LICENSE_TYPE_CP.equals(currentType)) {
currentType = CoConstDef.CD_LICENSE_TYPE_PF;
currentObligation = CommonFunction.getObligationTypeWithAndLicense(andlicenseGroup);
}
break;
case CoConstDef.CD_LICENSE_TYPE_NA:
if (isEmpty(currentType)) {
currentType = CoConstDef.CD_LICENSE_TYPE_NA;
currentObligation = CommonFunction.getObligationTypeWithAndLicense(andlicenseGroup);
}
break;
default:
break;
}
}
}
ossMaster.setLicenseType(currentType);
ossMaster.setObligationType(currentObligation);
}
@Override
public void updateLicenseTypeAndObligation(OssMaster ossBean) {
ossMapper.updateLicenseTypeAndObligation(ossBean);
}
@Override
public Map<String, Object> checkExistsOssDownloadLocation(OssMaster ossMaster) {
Map<String, Object> returnMap = new HashMap<String, Object>();
if (!isEmpty(ossMaster.getDownloadLocation())) {
List<String> checkOssNameUrl = CoCodeManager.getCodeNames(CoConstDef.CD_CHECK_OSS_NAME_URL);
int urlSearchSeq = -1;
int seq = 0;
try {
if (ossMaster.getDownloadLocation().contains(";")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().split(";")[0]);
}
for (String url : checkOssNameUrl) {
if (urlSearchSeq == -1 && ossMaster.getDownloadLocation().contains(url)) {
urlSearchSeq = seq;
break;
}
seq++;
}
String downloadLocationUrl = "";
if (ossMaster.getDownloadLocation().startsWith("git://")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().replace("git://", "https://"));
} else if (ossMaster.getDownloadLocation().startsWith("ftp://")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().replace("ftp://", "https://"));
} else if (ossMaster.getDownloadLocation().startsWith("svn://")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().replace("svn://", "https://"));
} else if (ossMaster.getDownloadLocation().startsWith("git@")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().replace("git@", "https://"));
}
if (ossMaster.getDownloadLocation().contains(".git")) {
if (ossMaster.getDownloadLocation().endsWith(".git")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().substring(0, ossMaster.getDownloadLocation().length()-4));
} else {
if (ossMaster.getDownloadLocation().contains("#")) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().substring(0, ossMaster.getDownloadLocation().indexOf("#")));
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().substring(0, ossMaster.getDownloadLocation().length()-4));
}
}
}
String[] downloadlocationUrlSplit = ossMaster.getDownloadLocation().split("/");
if (downloadlocationUrlSplit[downloadlocationUrlSplit.length-1].indexOf("#") > -1) {
ossMaster.setDownloadLocation(ossMaster.getDownloadLocation().substring(0, ossMaster.getDownloadLocation().indexOf("#")));
}
if (!ossMaster.getDownloadLocation().startsWith("http://") && !ossMaster.getDownloadLocation().startsWith("https://")) {
if (ossMaster.getDownloadLocation().contains("//")) {
ossMaster.setDownloadLocation("https://" + ossMaster.getDownloadLocation().split("//")[1]);
} else {
ossMaster.setDownloadLocation("https://" + ossMaster.getDownloadLocation());
}
}
if ( urlSearchSeq > -1 ) {
Pattern p = generatePattern(urlSearchSeq, ossMaster.getDownloadLocation());
Matcher m = p.matcher(ossMaster.getDownloadLocation());
while (m.find()) {
ossMaster.setDownloadLocation(m.group(0));
}
}
if (ossMaster.getDownloadLocation().startsWith("http://")
|| ossMaster.getDownloadLocation().startsWith("https://")) {
downloadLocationUrl = ossMaster.getDownloadLocation().split("//")[1];
}
if (downloadLocationUrl.startsWith("www.")) {
downloadLocationUrl = downloadLocationUrl.substring(5, downloadLocationUrl.length());
}
if (!isEmpty(downloadLocationUrl)) {
ossMaster.setDownloadLocation(downloadLocationUrl);
}
returnMap.put("downloadLocation", ossMapper.checkExistsOssDownloadLocation(ossMaster));
} catch (Exception e) {
log.error(e.getMessage());
}
}
return returnMap;
}
@Override
public Map<String, Object> checkExistsOssHomepage(OssMaster ossMaster) {
Map<String, Object> returnMap = new HashMap<String, Object>();
if (!isEmpty(ossMaster.getHomepage())) {
List<String> checkOssNameUrl = CoCodeManager.getCodeNames(CoConstDef.CD_CHECK_OSS_NAME_URL);
int urlSearchSeq = -1;
int seq = 0;
try {
if (ossMaster.getHomepage().contains(";")) {
ossMaster.setHomepage(ossMaster.getHomepage().split(";")[0]);
}
for (String url : checkOssNameUrl) {
if (urlSearchSeq == -1 && ossMaster.getHomepage().contains(url)) {
urlSearchSeq = seq;
break;
}
seq++;
}
String homepageUrl = "";
if (ossMaster.getHomepage().startsWith("git://")) {
ossMaster.setHomepage(ossMaster.getHomepage().replace("git://", "https://"));
} else if (ossMaster.getHomepage().startsWith("ftp://")) {
ossMaster.setHomepage(ossMaster.getHomepage().replace("ftp://", "https://"));
} else if (ossMaster.getHomepage().startsWith("svn://")) {
ossMaster.setHomepage(ossMaster.getHomepage().replace("svn://", "https://"));
} else if (ossMaster.getHomepage().startsWith("git@")) {
ossMaster.setHomepage(ossMaster.getHomepage().replace("git@", "https://"));
}
if (ossMaster.getHomepage().contains(".git")) {
if (ossMaster.getHomepage().endsWith(".git")) {
ossMaster.setHomepage(ossMaster.getHomepage().substring(0, ossMaster.getHomepage().length()-4));
} else {
if (ossMaster.getHomepage().contains("#")) {
ossMaster.setHomepage(ossMaster.getHomepage().substring(0, ossMaster.getHomepage().indexOf("#")));
ossMaster.setHomepage(ossMaster.getHomepage().substring(0, ossMaster.getHomepage().length()-4));
}
}
}
String[] homepageUrlSplit = ossMaster.getHomepage().split("/");
if (homepageUrlSplit[homepageUrlSplit.length-1].indexOf("#") > -1) {
ossMaster.setHomepage(ossMaster.getHomepage().substring(0, ossMaster.getHomepage().indexOf("#")));
}
if (!ossMaster.getHomepage().startsWith("http://") && !ossMaster.getHomepage().startsWith("https://")) {
if (ossMaster.getHomepage().contains("//")) {
ossMaster.setHomepage("https://" + ossMaster.getHomepage().split("//")[1]);
} else {
ossMaster.setHomepage("https://" + ossMaster.getHomepage());
}
}
if ( urlSearchSeq > -1 ) {
Pattern p = generatePattern(urlSearchSeq, ossMaster.getHomepage());
Matcher m = p.matcher(ossMaster.getHomepage());
while (m.find()) {
ossMaster.setHomepage(m.group(0));
}
}
if (ossMaster.getHomepage().startsWith("http://")
|| ossMaster.getHomepage().startsWith("https://")) {
homepageUrl = ossMaster.getHomepage().split("//")[1];
}
if (homepageUrl.startsWith("www.")) {
homepageUrl = homepageUrl.substring(5, homepageUrl.length());
}
if (!isEmpty(homepageUrl)) {
ossMaster.setHomepage(homepageUrl);
}
returnMap.put("homepage", ossMapper.checkExistsOssHomepage(ossMaster));
} catch (Exception e) {
log.error(e.getMessage());
}
}
return returnMap;
}
@Override
public Map<String, Object> checkExistsOssDownloadLocationWithOssName(OssMaster param) {
Map<String, Object> returnMap = new HashMap<String, Object>();
returnMap.put("downloadLocation", ossMapper.checkExistsOssDownloadLocationWithOssName(param));
return returnMap;
}
@Override
public Map<String, Object> checkExistsOssHomepageWithOssName(OssMaster param) {
Map<String, Object> returnMap = new HashMap<String, Object>();
returnMap.put("homepage", ossMapper.checkExistsOssHomepageWithOssName(param));
return returnMap;
}
@Override
public Map<String, OssMaster> getBasicOssInfoList(OssMaster ossMaster) {
return getBasicOssInfoList(ossMaster, false);
}
@Override
public Map<String, OssMaster> getBasicOssInfoList(OssMaster ossMaster, boolean useUpperKey) {
List<OssMaster> list = ossMapper.getBasicOssInfoList(ossMaster);
return makeBasicOssInfoMap(list, false, useUpperKey);
}
@Override
public int checkExistsOssByname(OssMaster bean) {
return ossMapper.checkExistsOssByname(bean);
}
private ProjectIdentification generateCheckOSSName(ProjectIdentification bean, Pattern p, List<String> androidPlatformList, String downloadlocationUrl) {
String checkName = "";
boolean isValid = false;
Matcher ossNameMatcher = p.matcher("https://" + downloadlocationUrl);
String[] android = null;
while (ossNameMatcher.find()) {
for (String list : androidPlatformList){
if (ossNameMatcher.group(3).contains(list)){
isValid = true;
android = list.split("/");
break;
}
}
if(!isValid) {
android = ossNameMatcher.group(3).split("/");
bean.setCheckOssList("I");
}
checkName = "android-";
for (String name : android) {
checkName += name + "-";
}
checkName = checkName.substring(0, checkName.length()-1);
}
bean.setCheckName(checkName);
return bean;
}
private String generateCheckOSSName(int urlSearchSeq, String downloadlocationUrl, Pattern p) {
String checkName = "";
String customDownloadlocationUrl = "";
if (downloadlocationUrl.contains("?")) {
customDownloadlocationUrl = downloadlocationUrl.split("[?]")[0];
} else {
customDownloadlocationUrl = downloadlocationUrl;
}
Matcher ossNameMatcher = p.matcher("https://" + customDownloadlocationUrl);
while (ossNameMatcher.find()){
switch(urlSearchSeq) {
case 0: // github
checkName = ossNameMatcher.group(3) + "-" + ossNameMatcher.group(4);
break;
case 1: // npm
case 6: // npm
checkName = "npm:" + ossNameMatcher.group(4);
if (checkName.contains(":@")) {
checkName += "/" + ossNameMatcher.group(5);
}
break;
case 2: // pypi
checkName = "pypi:" + ossNameMatcher.group(3);
break;
case 3: // maven
checkName = ossNameMatcher.group(3) + ":" + ossNameMatcher.group(4);
break;
case 4: // pub
checkName = "pub:" + ossNameMatcher.group(3);
break;
case 5: // cocoapods
checkName = "cocoapods:" + ossNameMatcher.group(3);
break;
case 8:
checkName = "nuget:" + ossNameMatcher.group(3);
break;
case 9:
checkName = "stackoverflow-" + ossNameMatcher.group(3);
break;
default:
break;
}
}
return checkName;
}
private String appendCheckOssName(List<OssMaster> ossNameList) {
String checkName = "";
for (OssMaster ossBean : ossNameList) {
if (!isEmpty(checkName)) {
checkName += "|";
}
checkName += ossBean.getOssName();
}
return checkName;
}
private Pattern generatePattern(int urlSearchSeq, String downloadlocationUrl) {
Pattern p = null;
switch(urlSearchSeq) {
case 0: // github
if (downloadlocationUrl.contains("www.")) {
downloadlocationUrl = downloadlocationUrl.replace("www.", "");
}
p = Pattern.compile("((http|https)://github.com/([^/]+)/([^/]+))");
break;
case 1: // npm
case 6: // npm
if (downloadlocationUrl.contains("/package/@")) {
p = Pattern.compile("((http|https)://npmjs.(org|com)/package/([^/]+)/([^/]+))");
}else {
p = Pattern.compile("((http|https)://npmjs.(org|com)/package/([^/]+))");
}
break;
case 2: // pypi
p = Pattern.compile("((http|https)://pypi.org/project/([^/]+))");
break;
case 3: // maven
p = Pattern.compile("((http|https)://mvnrepository.com/artifact/([^/]+)/([^/]+))");
break;
case 4: // pub
p = Pattern.compile("((http|https)://pub.dev/packages/([^/]+))");
break;
case 5: // cocoapods
p = Pattern.compile("((http|https)://cocoapods.org/pods/([^/]+))");
break;
case 7:
p = Pattern.compile("((http|https)://android.googlesource.com/platform/(.*))");
break;
case 8:
p = Pattern.compile("((http|https)://nuget.org/packages/([^/]+))");
break;
case 9:
p = Pattern.compile("((http|https)://stackoverflow.com/revisions/([^/]+)/([^/]+))");
break;
default:
p = Pattern.compile("(.*)");
break;
}
return p;
}
private ProjectIdentification downloadlocationFormatter(ProjectIdentification bean, int urlSearchSeq) {
if (urlSearchSeq == 0) {
if (bean.getDownloadLocation().startsWith("git://")) {
bean.setDownloadLocation(bean.getDownloadLocation().replace("git://", "https://"));
}
if (bean.getDownloadLocation().startsWith("git@")) {
bean.setDownloadLocation(bean.getDownloadLocation().replace("git@", "https://"));
}
if (bean.getDownloadLocation().contains(".git")) {
if (bean.getDownloadLocation().endsWith(".git")) {
bean.setDownloadLocation(bean.getDownloadLocation().substring(0, bean.getDownloadLocation().length()-4));
} else {
if (bean.getDownloadLocation().contains("#")) {
bean.setDownloadLocation(bean.getDownloadLocation().substring(0, bean.getDownloadLocation().indexOf("#")));
bean.setDownloadLocation(bean.getDownloadLocation().substring(0, bean.getDownloadLocation().length()-4));
}
}
}
}
String downloadlocationUrl = bean.getDownloadLocation();
String[] downloadlocationUrlSplit = downloadlocationUrl.split("/");
if (downloadlocationUrlSplit[downloadlocationUrlSplit.length-1].indexOf("#") > -1) {
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.indexOf("#"));
}
Pattern p = generatePattern(urlSearchSeq, downloadlocationUrl);
Matcher m = p.matcher(downloadlocationUrl);
while (m.find()) {
bean.setDownloadLocation(m.group(0));
}
if (bean.getDownloadLocation().startsWith("http://")
|| bean.getDownloadLocation().startsWith("https://")
|| bean.getDownloadLocation().startsWith("git://")
|| bean.getDownloadLocation().startsWith("ftp://")
|| bean.getDownloadLocation().startsWith("svn://")) {
downloadlocationUrl = bean.getDownloadLocation().split("//")[1];
}
if (downloadlocationUrl.startsWith("www.")) {
downloadlocationUrl = downloadlocationUrl.substring(4, downloadlocationUrl.length());
}
bean.setDownloadLocation(downloadlocationUrl);
return bean;
}
private List<String> getAndroidPlatformList(){
List<String> list = new ArrayList<String>();
Connection conn = Jsoup.connect("https://android.googlesource.com/platform/");
try{
Document document = conn.get();
Elements parsingDiv = document.getElementsByClass("RepoList-itemName");
for (Element element : parsingDiv) {
if (!element.text().equals("Name")){
list.add(element.text());
}
}
} catch(IOException e){
}
return list;
}
@Override
public Map<String, Object> getCheckOssNameAjax(ProjectIdentification paramBean, String targetName) {
Map<String, Object> resMap = new HashMap<>();
Map<String, Object> map = null;
List<ProjectIdentification> result = new ArrayList<ProjectIdentification>();
switch(targetName.toUpperCase()) {
case CoConstDef.CD_CHECK_OSS_SELF:
map = selfCheckService.getIdentificationGridList(paramBean);
break;
case CoConstDef.CD_CHECK_OSS_IDENTIFICATION:
map = projectService.getIdentificationGridList(paramBean);
break;
case CoConstDef.CD_CHECK_OSS_PARTNER:
map = partnerService.getIdentificationGridList(paramBean);
break;
}
// ์ค๊ฐ ์ ์ฅ์ ๊ธฐ๋ฅ ๋์์ ์ํด save์ ์ ํจ์ฑ ์ฒดํฌ๋ฅผ data load์๋ก ์ผ๊ด ๋ณ๊ฒฝ
if (map != null) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_SOURCE);
List<ProjectIdentification> mainData = (List<ProjectIdentification>) map.get("mainData");
pv.setAppendix("mainList", mainData);
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) map.get("subData"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
if (!vr.isValid()) {
Map<String, String> validMap = vr.getValidMessageMap();
result.addAll(checkOssNameData(mainData, validMap, null));
resMap.put("validMap", validMap);
}
if(!vr.isDiff()){
Map<String, String> diffMap = vr.getDiffMessageMap();
result.addAll(checkOssNameData(mainData, null, diffMap));
resMap.put("diffMap", diffMap);
}
result.addAll(checkOssNameData(mainData, null, null));
}
if(result.size() > 0) {
result = checkOssName(result);
List<ProjectIdentification> valid = new ArrayList<ProjectIdentification>();
List<ProjectIdentification> invalid = new ArrayList<ProjectIdentification>();
for(ProjectIdentification prj : result){
if(prj.getCheckOssList().equals("I")){
invalid.add(prj);
} else{
valid.add(prj);
}
}
resMap.put("list", Stream.concat(valid.stream(), invalid.stream())
.collect(Collectors.toList()));
}
return resMap;
}
@Override
public Map<String, Object> getCheckOssLicenseAjax(ProjectIdentification paramBean, String targetName) {
Map<String, Object> resMap = new HashMap<>();
Map<String, Object> map = null;
List<ProjectIdentification> result = new ArrayList<ProjectIdentification>();
switch(targetName.toUpperCase()) {
case CoConstDef.CD_CHECK_OSS_SELF:
map = selfCheckService.getIdentificationGridList(paramBean);
break;
case CoConstDef.CD_CHECK_OSS_IDENTIFICATION:
map = projectService.getIdentificationGridList(paramBean);
break;
case CoConstDef.CD_CHECK_OSS_PARTNER:
map = partnerService.getIdentificationGridList(paramBean);
break;
}
// intermediate storage function correspondence : validation check when loading data
if (map != null) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_SOURCE);
List<ProjectIdentification> mainData = (List<ProjectIdentification>) map.get("mainData");
pv.setAppendix("mainList", mainData);
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) map.get("subData"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
if (!vr.isValid()) {
Map<String, String> validMap = vr.getValidMessageMap();
result.addAll(autoFillOssInfoService.checkOssLicenseData(mainData, validMap, null));
resMap.put("validMap", validMap);
}
if (!vr.isDiff()){
Map<String, String> diffMap = vr.getDiffMessageMap();
result.addAll(autoFillOssInfoService.checkOssLicenseData(mainData, null, diffMap));
resMap.put("diffMap", diffMap);
}
}
if (result.size() > 0) {
Map<String, Object> data = autoFillOssInfoService.checkOssLicense(result);
resMap.put("list", data.get("checkedData"));
resMap.put("error", data.get("error"));
}
return resMap;
}
@Override
public List<ProjectIdentification> checkOssName(List<ProjectIdentification> list){
List<ProjectIdentification> result = new ArrayList<ProjectIdentification>();
List<String> checkOssNameUrl = CoCodeManager.getCodeNames(CoConstDef.CD_CHECK_OSS_NAME_URL);
int urlSearchSeq = -1;
List<String> androidPlatformList = getAndroidPlatformList();
// oss name๊ณผ download location์ด ๋์ผํ oss์ componentId๋ฅผ ๋ฌถ์ด์ List<ProjectIdentification>์ ๋ง๋ฌ
list = list.stream()
.collect(Collectors.groupingBy(oss -> oss.getOssName() + "-" + oss.getDownloadLocation()))
.values().stream()
.map(ossList -> {
ProjectIdentification uniqueOss = ossList.stream().distinct().findFirst().get();
List<String> componentIds = ossList.stream().map(oss -> oss.getComponentId()).distinct().collect(Collectors.toList());
uniqueOss.setComponentIdList(componentIds);
return uniqueOss;
})
.collect(Collectors.toList());
for (ProjectIdentification bean : list) {
int seq = 0;
urlSearchSeq = -1;
if (isEmpty(bean.getDownloadLocation())) {
continue;
}
try {
boolean semicolonFlag = false;
String semicolonStr = "";
String downloadLocation = bean.getDownloadLocation();
if (bean.getDownloadLocation().contains(";")) {
semicolonFlag = true;
int idx = 0;
for (String smc : bean.getDownloadLocation().split(";")) {
if (idx > 0) {
semicolonStr += smc + ";";
}
idx++;
}
semicolonStr = semicolonStr.substring(0, semicolonStr.length()-1);
bean.setDownloadLocation(bean.getDownloadLocation().split(";")[0]);
}
for (String url : checkOssNameUrl) {
if (urlSearchSeq == -1 && bean.getDownloadLocation().contains(url)) {
urlSearchSeq = seq;
break;
}
seq++;
}
if ( urlSearchSeq > -1 ) {
if(urlSearchSeq == 10) { //pythonhosted
String name[] = bean.getDownloadLocation().split("/");
bean.setDownloadLocation(checkOssNameUrl.get(2) + name[name.length-2]);
}
bean = downloadlocationFormatter(bean, urlSearchSeq);
String downloadlocationUrl = bean.getDownloadLocation();
if (urlSearchSeq == 7) {
if (downloadlocationUrl.contains("+")) {
downloadlocationUrl = downloadlocationUrl.split("[+]")[0];
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.lastIndexOf("/"));
}
}
downloadlocationUrl = URLDecoder.decode(downloadlocationUrl);
Pattern p = generatePattern(urlSearchSeq, downloadlocationUrl);
int cnt = ossMapper.checkOssNameUrl2Cnt(bean);
if (cnt == 0) {
bean.setOssNickName(generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p));
String checkName = appendCheckOssName(ossMapper.checkOssNameTotal(bean));
if (!isEmpty(checkName)) {
bean.setCheckOssList("Y");
bean.setRecommendedNickname(generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p));
} else {
if (urlSearchSeq == 7) {
generateCheckOSSName(bean, p, androidPlatformList, downloadlocationUrl);
checkName = bean.getCheckName();
} else if (urlSearchSeq == 3 || urlSearchSeq == 5){
checkName = generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p);
} else {
String redirectlocationUrl = "";
try {
URL checkUrl = new URL("https://" + downloadlocationUrl);
HttpURLConnection oc = (HttpURLConnection) checkUrl.openConnection();
oc.setUseCaches(false);
oc.setConnectTimeout(1500);
if (200 == oc.getResponseCode()) {
ProjectIdentification url = new ProjectIdentification();
url.setDownloadLocation(oc.getURL().toString());
url = downloadlocationFormatter(url, urlSearchSeq);
if (url.getDownloadLocation().equals(downloadlocationUrl) || url.getDownloadLocation().equals(downloadlocationUrl + "/")) {
checkName = generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p);
} else {
redirectlocationUrl = oc.getURL().toString().split("//")[1];
bean.setDownloadLocation(redirectlocationUrl);
bean.setOssNickName(generateCheckOSSName(urlSearchSeq, redirectlocationUrl, p));
checkName = appendCheckOssName(ossMapper.checkOssNameTotal(bean));
if (!isEmpty(checkName)) {
bean.setCheckOssList("Y");
bean.setRecommendedNickname(generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p) + "|" + generateCheckOSSName(urlSearchSeq, redirectlocationUrl, p));
} else {
checkName = generateCheckOSSName(urlSearchSeq, redirectlocationUrl, p);
}
bean.setRedirectLocation(redirectlocationUrl);
}
} else {
checkName = generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p);
bean.setCheckOssList("I");
}
} catch (IOException e) {
checkName = generateCheckOSSName(urlSearchSeq, downloadlocationUrl, p);
bean.setCheckOssList("I");
}
}
}
if (!isEmpty(checkName)){
bean.setCheckName(checkName);
bean.setDownloadLocation(downloadLocation);
if (!bean.getOssName().equals(bean.getCheckName())) {
result.add(bean);
}
}
}
} else {
String downloadlocationUrl = "";
if (semicolonFlag) {
downloadlocationUrl = bean.getDownloadLocation().split(";")[0];
} else {
downloadlocationUrl = bean.getDownloadLocation();
}
if (downloadlocationUrl.startsWith("git@")) {
downloadlocationUrl = downloadlocationUrl.replace("git@", "");
}
if (downloadlocationUrl.startsWith("http://")
|| downloadlocationUrl.startsWith("https://")
|| downloadlocationUrl.startsWith("git://")
|| downloadlocationUrl.startsWith("ftp://")
|| downloadlocationUrl.startsWith("svn://")) {
downloadlocationUrl = downloadlocationUrl.split("//")[1];
}
if (downloadlocationUrl.startsWith("www.")) {
downloadlocationUrl = downloadlocationUrl.substring(4, downloadlocationUrl.length());
}
if (downloadlocationUrl.contains(".git")) {
if (downloadlocationUrl.endsWith(".git")) {
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.length()-4);
} else {
if (downloadlocationUrl.contains("#")) {
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.indexOf("#"));
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.length()-4);
}
}
}
String[] downloadlocationUrlSplit = downloadlocationUrl.split("/");
if (downloadlocationUrlSplit[downloadlocationUrlSplit.length-1].indexOf("#") > -1) {
downloadlocationUrl = downloadlocationUrl.substring(0, downloadlocationUrl.indexOf("#"));
}
bean.setDownloadLocation(downloadlocationUrl);
int cnt = ossMapper.checkOssNameUrl2Cnt(bean);
if (cnt == 0) {
List<OssMaster> ossNameList = ossMapper.checkOssNameUrl2(bean);
String checkName = "";
for (OssMaster ossBean : ossNameList) {
if (!isEmpty(checkName)) {
checkName += "|";
}
checkName += ossBean.getOssName();
}
if (!isEmpty(checkName)) {
bean.setCheckOssList("Y");
bean.setCheckName(checkName);
if (!bean.getOssName().equals(bean.getCheckName())) {
bean.setDownloadLocation(downloadLocation);
result.add(bean);
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage());
}
}
final Comparator<ProjectIdentification> comp = (p1, p2) -> Integer.compare(StringUtil.countMatches(p1.getCheckName(), ","), StringUtil.countMatches(p2.getCheckName(), ","));
// oss name๊ณผ registered oss name์ uniqueํ๊ฒ ์ถ๋ ฅ
List<ProjectIdentification> sortedData = result.stream().filter(CommonFunction.distinctByKey(p -> p.getOssName()+p.getCheckName())).sorted(comp).collect(Collectors.toList());
// oss name๊ณผ registered oss name์ด uniqueํ์ง ์๋ค๋ฉด ์ค๋ณต๋ data์ downloadlocation์ ์ ๋ถ ํฉ์ณ์ ์ถ๋ ฅํจ.
for (ProjectIdentification p : sortedData) {
String downloadLocation = result.stream()
.filter(e -> (e.getOssName()+e.getCheckName()).equals(p.getOssName()+p.getCheckName()))
.map(e -> e.getDownloadLocation())
.distinct()
.collect(Collectors.joining(","));
List<String> componentIds = result.stream()
.filter(e -> (e.getOssName()+e.getCheckName()).equals(p.getOssName()+p.getCheckName()))
.map(e -> e.getComponentIdList())
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
p.setDownloadLocation(downloadLocation);
p.setComponentIdList(componentIds);
}
return sortedData;
}
@Transactional
@Override
public Map<String, Object> saveOssCheckName(ProjectIdentification paramBean, String targetName) {
Map<String, Object> map = new HashMap<String, Object>();
try {
List<String> checkOssNameUrl = CoCodeManager.getCodeNames(CoConstDef.CD_CHECK_OSS_NAME_URL);
String[] downloadLocations = paramBean.getDownloadLocation().split("<br>");
// If there are multiple download paths > add
if (downloadLocations.length > 0) {
int updateCnt;
int urlSearchSeq;
int seq;
for (String downloadLocation : downloadLocations) {
updateCnt = 0;
urlSearchSeq = -1;
seq = 0;
paramBean.setDownloadLocation(downloadLocation);
for (String url : checkOssNameUrl) {
if (urlSearchSeq == -1 && downloadLocation.contains(url)) {
urlSearchSeq = seq;
break;
}
seq++;
}
if ( urlSearchSeq > -1 ) {
Pattern p = generatePattern(urlSearchSeq, downloadLocation);
Matcher m = p.matcher(downloadLocation);
while (m.find()) {
paramBean.setDownloadLocation(m.group(0));
}
}
List<String> componentIds = paramBean.getComponentIdList();
switch(targetName.toUpperCase()) {
case CoConstDef.CD_CHECK_OSS_SELF:
for (String componentId : componentIds) {
String[] gridId = componentId.split("-");
paramBean.setGridId(gridId[0]+"-"+gridId[1]);
paramBean.setComponentId(gridId[2]);
updateCnt += ossMapper.updateOssCheckNameBySelfCheck(paramBean);
}
break;
case CoConstDef.CD_CHECK_OSS_PARTNER:
for (String componentId : componentIds) {
paramBean.setComponentId(componentId);
updateCnt += ossMapper.updateOssCheckNameByPartner(paramBean);
}
if (updateCnt >= 1) {
String commentId = paramBean.getRefPrjId();
String checkOssNameComment = "";
String changeOssNameInfo = "<p>" + paramBean.getOssName() + " => " + paramBean.getCheckName() + "</p>";
CommentsHistory commentInfo = null;
if (isEmpty(commentId)) {
checkOssNameComment = messageSource.getMessage("msg.oss.changed.by.checkossname",null, LocaleContextHolder.getLocale());
checkOssNameComment += changeOssNameInfo;
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_HIS);
commHisBean.setReferenceId(paramBean.getReferenceId());
commHisBean.setContents(checkOssNameComment);
commentInfo = commentService.registComment(commHisBean, false);
} else {
commentInfo = (CommentsHistory) commentService.getCommnetInfo(commentId).get("info");
if (commentInfo != null) {
commentInfo = (CommentsHistory) commentService.getCommnetInfo(commentId).get("info");
if (commentInfo != null) {
if (!isEmpty(commentInfo.getContents())) {
checkOssNameComment = commentInfo.getContents();
checkOssNameComment += changeOssNameInfo;
commentInfo.setContents(checkOssNameComment);
commentService.updateComment(commentInfo, false);
}
}
}
}
if (commentInfo != null) {
map.put("commentId", commentInfo.getCommId());
}
}
break;
case CoConstDef.CD_CHECK_OSS_IDENTIFICATION:
for (String componentId : componentIds) {
paramBean.setComponentId(componentId);
updateCnt += ossMapper.updateOssCheckName(paramBean);
}
if (updateCnt >= 1) {
String commentId = paramBean.getReferenceId();
String checkOssNameComment = "";
String changeOssNameInfo = "<p>" + paramBean.getOssName() + " => " + paramBean.getCheckName() + "</p>";
CommentsHistory commentInfo = null;
if (isEmpty(commentId)) {
checkOssNameComment = messageSource.getMessage("msg.oss.changed.by.checkossname",null, LocaleContextHolder.getLocale());
checkOssNameComment += changeOssNameInfo;
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commHisBean.setReferenceId(paramBean.getRefPrjId());
commHisBean.setContents(checkOssNameComment);
commentInfo = commentService.registComment(commHisBean, false);
} else {
commentInfo = (CommentsHistory) commentService.getCommnetInfo(commentId).get("info");
if (commentInfo != null) {
if (!isEmpty(commentInfo.getContents())) {
checkOssNameComment = commentInfo.getContents();
checkOssNameComment += changeOssNameInfo;
commentInfo.setContents(checkOssNameComment);
commentService.updateComment(commentInfo, false);
}
}
}
if (commentInfo != null) {
map.put("commentId", commentInfo.getCommId());
}
}
break;
}
if (updateCnt >= 1) {
map.put("isValid", true);
map.put("returnType", "Success");
} else {
throw new Exception("update Cnt๊ฐ ๋น์ ์์ ์ธ ๊ฐ์.");
}
}
}
} catch (Exception e) {
log.error(e.getMessage());
map.put("isValid", false);
map.put("returnType", "");
}
return map;
}
@Transactional
@Override
// @CacheEvict(value="autocompleteCache", allEntries=true)
public Map<String, Object> saveOss(OssMaster ossMaster) {
String resCd = "00";
String result = null;
HashMap<String, Object> resMap = new HashMap<>();
/*Json String -> Json Object*/
String jsonString = ossMaster.getOssLicensesJson();
if (!isEmpty(jsonString)) {
Type collectionType = new TypeToken<List<OssLicense>>() {
}.getType();
List<OssLicense> list = checkLicenseId((List<OssLicense>) fromJson(jsonString, collectionType));
ossMaster.setOssLicenses(list);
}
String action = "";
String ossId = ossMaster.getOssId();
boolean isNew = StringUtil.isEmpty(ossId);
boolean isNewVersion = false; // ์๋ก์ด version์ ๋ฑ๋ก
boolean isChangedName = false;
boolean isDeactivateFlag = false;
boolean isActivateFlag = false;
OssMaster beforeBean = null;
OssMaster afterBean = null;
// downloadLocations์ด n๊ฑด์ผ๋ 0๋ฒ์งธ ๊ฐ์ oss Master๋ก ์ ์ฅ.
String[] downloadLocations = ossMaster.getDownloadLocations();
if (downloadLocations != null) {
if (downloadLocations.length >= 1) {
for (String url : downloadLocations) {
if (!isEmpty(url)) {
ossMaster.setDownloadLocation(url); // ๋ฑ๋ก๋ url ์ค ๊ณต๋ฐฑ์ ์ ์ธํ ๋๋จธ์ง์์ ์ฒซ๋ฒ์งธ url์ ๋ง๋๊ฒ ๋๋ฉด ๋ฑ๋ก์ ํจ.
break;
}
}
}
} else {
ossMaster.setDownloadLocation("");
}
if (!isEmpty(ossMaster.getHomepage())) {
if (ossMaster.getHomepage().endsWith("/")) {
String homepage = ossMaster.getHomepage();
ossMaster.setHomepage(homepage.substring(0, homepage.length() - 1));
} else {
ossMaster.setHomepage(ossMaster.getHomepage());
}
} else {
ossMaster.setHomepage("");
}
if (!isEmpty(ossMaster.getComment()) && !ossMaster.getComment().startsWith("<p>")) {
ossMaster.setComment(CommonFunction.lineReplaceToBR(ossMaster.getComment()));
}
Map<String, List<OssMaster>> updateOssNameVersionDiffMergeObject = null;
try {
History h;
if (("Y").equals(ossMaster.getOssCopyFlag())) {
ossMaster.setOssId(null);
isNew = true;
}
// OSS ์์
if (!isNew) {
beforeBean = getOssInfo(ossId, true);
if (CoConstDef.FLAG_YES.equals(ossMaster.getRenameFlag())) {
updateOssNameVersionDiffMergeObject = updateOssNameVersionDiff(ossMaster);
} else {
result = registOssMaster(ossMaster);
}
CoCodeManager.getInstance().refreshOssInfo();
action = CoConstDef.ACTION_CODE_UPDATE;
afterBean = getOssInfo(ossId, true);
if (CoConstDef.FLAG_YES.equals(ossMaster.getRenameFlag())) {
if (updateOssNameVersionDiffMergeObject != null) {
List<OssMaster> diffOssVersionMergeList = updateOssNameVersionDiffMergeObject.get("after");
if (diffOssVersionMergeList != null && diffOssVersionMergeList.size() > 0) {
afterBean.setOssNickname(diffOssVersionMergeList.get(0).getOssNickname());
afterBean.setOssNicknames(diffOssVersionMergeList.get(0).getOssNicknames());
}
}
}
if (!beforeBean.getOssName().equalsIgnoreCase(afterBean.getOssName())) {
isChangedName = true;
}
String beforeDeactivateFlag = avoidNull(beforeBean.getDeactivateFlag(), CoConstDef.FLAG_NO);
String afterDeactivateFlag = avoidNull(afterBean.getDeactivateFlag(), CoConstDef.FLAG_NO);
if (CoConstDef.FLAG_NO.equals(beforeDeactivateFlag)
&& CoConstDef.FLAG_YES.equals(afterDeactivateFlag)) {
isDeactivateFlag = true;
}
if (CoConstDef.FLAG_YES.equals(beforeDeactivateFlag)
&& CoConstDef.FLAG_NO.equals(afterDeactivateFlag)) {
isActivateFlag = true;
}
} else { // OSS ๋ฑ๋ก
// ๊ธฐ์กด์ ๋์ผํ ์ด๋ฆ์ผ๋ก ๋ฑ๋ก๋์ด ์๋ OSS Name์ธ ์ง ํ์ธ
isNewVersion = CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(ossMaster.getOssName().toUpperCase());
if (isNewVersion) {
ossMaster.setExistOssNickNames(getOssNickNameListByOssName(ossMaster.getOssName()));
}
ossId = registOssMaster(ossMaster);
CoCodeManager.getInstance().refreshOssInfo();
action = CoConstDef.ACTION_CODE_INSERT;
}
if (!CoConstDef.FLAG_YES.equals(ossMaster.getRenameFlag())) {
h = work(ossMaster);
h.sethAction(action);
historyService.storeData(h);
}
resCd = "10";
} catch (RuntimeException ex) {
log.error(ex.getMessage(), ex);
throw ex;
} catch (Exception e) {
log.error("OSS " + action + "Failed.", e);
log.error(e.getMessage(), e);
} finally {
resMap.put("ossMaster", ossMaster);
resMap.put("ossId", ossId);
resMap.put("isNew", isNew);
resMap.put("isNewVersion", isNewVersion);
resMap.put("isChangedName", isChangedName);
resMap.put("isDeactivateFlag", isDeactivateFlag);
resMap.put("isActivateFlag", isActivateFlag);
if (beforeBean != null) {
resMap.put("beforeBean", beforeBean);
}
if (afterBean != null) {
resMap.put("afterBean", afterBean);
}
if (updateOssNameVersionDiffMergeObject != null) {
resMap.put("updateOssNameVersionDiffMergeObject", updateOssNameVersionDiffMergeObject);
}
}
resMap.put("resCd", resCd);
return resMap;
}
@Transactional
@Override
public Map<String, Object> saveOssNickname(ProjectIdentification paramBean) {
Map<String, Object> map = new HashMap<String, Object>();
OssMaster ossMaster = new OssMaster();
ossMaster.setOssName(paramBean.getCheckName());
ossMaster.setOssNickname(paramBean.getOssName());
try {
if (isEmpty(ossMaster.getOssNickname())) {
throw new Exception(ossMaster.getOssName() + " -> NickName field is required.");
}
List<String> ossNameList = new ArrayList<>();
ossNameList.add(paramBean.getOssName());
String[] ossNames = new String[ossNameList.size()];
ossMaster.setOssNames(ossNameList.toArray(ossNames));
Map<String, OssMaster> ossMap = getBasicOssInfoList(ossMaster);
if (ossMap == null || ossMap.isEmpty()) {}else {
throw new Exception(paramBean.getOssName() + " -> OSS Name registered in OSS list.");
}
int insertCnt = ossMapper.insertOssNickname(ossMaster);
if (insertCnt == 1) {
map.put("isValid", true);
map.put("returnType", "Success");
} else {
throw new Exception("update Cnt๊ฐ ๋น์ ์์ ์ธ ๊ฐ์.");
}
} catch (Exception e) {
log.error(e.getMessage());
map.put("isValid", false);
map.put("returnType", e.getMessage());
}
return map;
}
public List<OssLicense> checkLicenseId(List<OssLicense> list) {
// license name๋ง ์๊ณ id๋ ์๋ ๊ฒฝ์ฐ๋ฅผ ์ฐํด license id๋ฅผ ์ฐพ๋๋ค.
// validation์์ license id๋ ํ์๋ก ๋์ด ์๊ธฐ๋๋ฌธ
if (list != null) {
for (OssLicense bean : list) {
if (isEmpty(bean.getLicenseId()) && CoCodeManager.LICENSE_INFO_UPPER.containsKey(bean.getLicenseNameEx().toUpperCase())) {
bean.setLicenseId(CoCodeManager.LICENSE_INFO_UPPER.get(bean.getLicenseNameEx().toUpperCase()).getLicenseId());
if (isEmpty(bean.getLicenseName())) {
bean.setLicenseName(CoCodeManager.LICENSE_INFO_UPPER.get(bean.getLicenseNameEx().toUpperCase()).getLicenseName());
}
}
}
}
return list;
}
@Transactional
@Override
public Map<String, Object> saveOssAnalysisList(OssMaster ossBean, String key) {
Map<String, Object> result = new HashMap<String, Object>();
try {
switch(key) {
case "VIEW":
String prjId = ossBean.getPrjId();
if (CoConstDef.CD_DTL_COMPONENT_PARTNER.equals(ossBean.getReferenceDiv())) {
prjId = "3rd_" + prjId;
}
int analysisListCnt = ossMapper.ossAnalysisListCnt(prjId, ossBean.getStartAnalysisFlag(), ossBean.getCsvComponentIdList());
if (analysisListCnt > 0) {
ossMapper.deleteOssAnalysisList(prjId);
}
if (ossBean.getComponentIdList().size() > 0) {
int insertCnt = ossMapper.insertOssAnalysisList(ossBean);
if (insertCnt <= 0) {
result.put("isValid", false);
result.put("returnType", "Failed");
}
}
break;
case "POPUP":
int updateCnt = ossMapper.updateOssAnalysisList(ossBean);
if (updateCnt != 1) {
result.put("isValid", false);
result.put("returnType", "Failed");
}
break;
}
} catch (Exception e) {
log.error(e.getMessage());
}
if (result.keySet().size() == 0) {
result.put("isValid", true);
result.put("returnType", "Success");
}
return result;
}
@Override
public Map<String, Object> getOssAnalysisList(OssMaster ossMaster) {
Map<String, Object> result = new HashMap<String, Object>();
List<OssAnalysis> list = null;
String prjId = ossMaster.getPrjId();
if (CoConstDef.CD_DTL_COMPONENT_PARTNER.equals(ossMaster.getReferenceDiv())) {
ossMaster.setPrjId("3rd_" + prjId);
}
if (CoConstDef.FLAG_YES.equals(ossMaster.getStartAnalysisFlag())) {
int records = ossMapper.ossAnalysisListCnt(ossMaster.getPrjId(), ossMaster.getStartAnalysisFlag(), ossMaster.getCsvComponentIdList());
ossMaster.setTotListSize(records);
list = ossMapper.selectOssAnalysisList(ossMaster);
result.put("page", ossMaster.getCurPage());
result.put("total", ossMaster.getTotBlockSize());
result.put("records", records);
}
if (!CoConstDef.FLAG_YES.equals(ossMaster.getStartAnalysisFlag())) {
list = ossMapper.selectOssAnalysisList(ossMaster);
CommonFunction.getAnalysisValidation(result, list);
}
result.put("rows", list);
return result;
}
@Override
public int getAnalysisListPage(int rows, String prjId) {
try {
return ossMapper.getAnalysisListPage(rows, prjId);
} catch (Exception e) {
return 1;
}
}
@Override
public Map<String, Object> startAnalysis(String prjId, String fileSeq, String userName){
Map<String, Object> resultMap = new HashMap<String, Object>();
T2File fileInfo = new T2File();
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
BufferedReader error = null;
Process process = null;
boolean isProd = "REAL".equals(avoidNull(CommonFunction.getProperty("server.mode")));
try {
oss_auto_analysis_log.info("ANALYSIS START PRJ ID : "+prjId+" ANALYSIS file ID : " + fileSeq);
fileInfo = fileMapper.selectFileInfo(fileSeq);
String EMAIL_VAL = ""; // reviewer์ loginUser์ email
String loginUserName = userName != null ? userName : loginUserName();
if (prjId.toUpperCase().indexOf("3RD") > -1){
EMAIL_VAL = partnerMapper.getReviewerEmail(prjId, loginUserName);
} else {
EMAIL_VAL = projectMapper.getReviewerEmail(prjId, loginUserName);
}
String analysisCommand = MessageFormat.format(CommonFunction.getProperty("autoanalysis.ssh.command"), (isProd ? "live" : "dev"), prjId, fileInfo.getLogiNm(), EMAIL_VAL, (isProd ? 0 : 1), (userName == null ? 0 : 1));
ProcessBuilder builder = new ProcessBuilder( "/bin/bash", "-c", analysisCommand );
builder.redirectErrorStream(true);
process = builder.start();
oss_auto_analysis_log.info("ANALYSIS Process PRJ ID : " + prjId + " command : " + analysisCommand);
is = process.getInputStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
int count = 0;
int interval = 1000; // 1 sec
int idleTime = Integer.parseInt(CoCodeManager.getCodeExpString(CoConstDef.CD_AUTO_ANALYSIS, CoConstDef.CD_IDLE_TIME));
Project prjInfo = new Project();
prjInfo.setPrjId(prjId);
// script๊ฐ success์ผ๋ status๋ฅผ progress๋ก ๋ณ๊ฒฝํจ.
OssMaster ossBean = new OssMaster();
ossBean.setPrjId(prjId);
ossBean.setCreator(loginUserName());
ossMapper.setOssAnalysisStatus(ossBean);
prjInfo = projectMapper.getOssAnalysisData(prjInfo);
resultMap.put("isValid", true);
resultMap.put("returnMsg", "Success");
resultMap.put("prjInfo", prjInfo);
Thread.sleep(interval);
/*while (!Thread.currentThread().isInterrupted()) {
if (count > idleTime) {
oss_auto_analysis_log.info("ANALYSIS TIMEOUT PRJ ID : " + prjId);
resultMap.put("isValid", false);
resultMap.put("returnMsg", "OSS auto analysis has not been completed yet.");
break;
}
String result = br.readLine();
oss_auto_analysis_log.info("OSS AUTO ANALYSIS READLINE : " + result);
if (result != null && result.toLowerCase().indexOf("start download oss") > -1) {
oss_auto_analysis_log.info("ANALYSIS START SUCCESS PRJ ID : " + prjId);
Project prjInfo = new Project();
prjInfo.setPrjId(prjId);
// script๊ฐ success์ผ๋ status๋ฅผ progress๋ก ๋ณ๊ฒฝํจ.
OssMaster ossBean = new OssMaster();
ossBean.setPrjId(prjId);
ossBean.setCreator(loginUserName());
ossMapper.setOssAnalysisStatus(ossBean);
prjInfo = projectMapper.getOssAnalysisData(prjInfo);
resultMap.put("isValid", true);
resultMap.put("returnMsg", "Success");
resultMap.put("prjInfo", prjInfo);
break;
}
count++;
Thread.sleep(interval);
}*/
// ์คํฌ๋ฆฝํธ ์ข
๋ฃ
} catch(NullPointerException npe) {
oss_auto_analysis_log.error("ANALYSIS ERR PRJ ID : " + prjId);
oss_auto_analysis_log.error(npe.getMessage(), npe);
resultMap.replace("isValid", false);
resultMap.replace("returnMsg", "script Error");
} catch (Exception e) {
oss_auto_analysis_log.error("ANALYSIS ERR PRJ ID : " + prjId);
oss_auto_analysis_log.error(e.getMessage(), e);
resultMap.replace("isValid", false);
resultMap.replace("returnMsg", "OSS auto analysis has not been completed yet.");
} finally {
if (br != null) {
try {
br.close();
} catch (Exception e2) {}
}
if (error != null) {
try {
error.close();
} catch (Exception e2) {}
}
if (isr != null) {
try {
isr.close();
} catch (Exception e2) {}
}
if (is != null) {
try {
is.close();
} catch (Exception e2) {}
}
if (error != null) {
try {
error.close();
} catch (Exception e2) {}
}
try {
if (process != null) {
oss_auto_analysis_log.info("Do OSS ANALYSIS Process Destry");
process.destroy();
}
} catch (Exception e2) {
oss_auto_analysis_log.error(e2.getMessage(), e2);
}
}
return resultMap;
}
@Override
public OssAnalysis getNewestOssInfo2(OssAnalysis bean) {
OssAnalysis ossNewistData = ossMapper.getNewestOssInfo2(bean);
if (ossNewistData != null) {
if (!isEmpty(ossNewistData.getDownloadLocationGroup())) {
String url = "";
String[] downloadLocationList = ossNewistData.getDownloadLocationGroup().split(",");
// master table์ download location์ด n๊ฑด์ธ ๊ฒฝ์ฐ์ ๋ํด ์ค๋ณต์ ๊ฑฐ๋ฅผ ์ถ๊ฐํจ.
String duplicateRemoveUrl = String.join(",", Arrays.asList(downloadLocationList)
.stream()
.filter(CommonFunction.distinctByKey(p -> p))
.collect(Collectors.toList()));
if (!isEmpty(duplicateRemoveUrl)) {
url = duplicateRemoveUrl;
}
ossNewistData.setDownloadLocation(url);
}
}
return ossNewistData;
}
@Override
public OssAnalysis getNewestOssInfo(OssAnalysis bean) {
OssAnalysis ossNewistData = ossMapper.getNewestOssInfo(bean);
if (ossNewistData != null) {
if (!isEmpty(ossNewistData.getDownloadLocationGroup())) {
String url = "";
String[] downloadLocationList = ossNewistData.getDownloadLocationGroup().split(",");
// master table์ download location์ด n๊ฑด์ธ ๊ฒฝ์ฐ์ ๋ํด ์ค๋ณต์ ๊ฑฐ๋ฅผ ์ถ๊ฐํจ.
String duplicateRemoveUrl = String.join(",", Arrays.asList(downloadLocationList)
.stream()
.filter(CommonFunction.distinctByKey(p -> p))
.collect(Collectors.toList()));
if (!isEmpty(duplicateRemoveUrl)) {
url = duplicateRemoveUrl;
}
ossNewistData.setDownloadLocation(url);
}
if (ossNewistData.getLicenseName() != null && !ossNewistData.getLicenseName().contains(" OR ")) {
ProjectIdentification prjOssMaster = new ProjectIdentification();
prjOssMaster.setOssId(ossNewistData.getOssId());
List<ProjectIdentification> Licenselist = projectMapper.getLicenses(prjOssMaster);
if (Licenselist.size() != 0){
Licenselist = CommonFunction.makeLicenseExcludeYn(Licenselist);
ossNewistData.setLicenseName(CommonFunction.makeLicenseExpressionIdentify(Licenselist, ","));
}
}
ossNewistData.setOssId(null);
}
return ossNewistData;
}
@Override
public Map<String,Object> updateAnalysisComplete(OssAnalysis bean) throws Exception {
Map<String, Object> resultMap = new HashMap<String, Object>();
int updateCnt = ossMapper.updateAnalysisComplete(bean);
if (updateCnt == 1) {
resultMap.put("isValid", true);
resultMap.put("returnMsg", "Success");
} else {
throw new Exception("Complete Failure");
}
return resultMap;
}
@Override
public OssAnalysis getAutoAnalysisSuccessOssInfo(String referenceOssId) {
return ossMapper.getAutoAnalysisSuccessOssInfo(referenceOssId);
}
@Override
public List<ProjectIdentification> checkOssNameData(List<ProjectIdentification> componentData, Map<String, String> validMap, Map<String, String> diffMap){
List<ProjectIdentification> resultData = new ArrayList<ProjectIdentification>();
Map<String, Object> ruleMap = T2CoValidationConfig.getInstance().getRuleAllMap();
if (validMap != null) {
for (String key : validMap.keySet()) {
if (key.toUpperCase().startsWith("OSSNAME")
&& (validMap.get(key).equals(ruleMap.get("OSS_NAME.UNCONFIRMED.MSG"))
|| validMap.get(key).equals(ruleMap.get("OSS_NAME.REQUIRED.MSG")))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
if (key.toUpperCase().startsWith("OSSVERSION") && validMap.get(key).equals(ruleMap.get("OSS_VERSION.UNCONFIRMED.MSG"))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
}
}
if (diffMap != null) {
for (String key : diffMap.keySet()) {
if (key.toUpperCase().startsWith("OSSNAME") && diffMap.get(key).equals(ruleMap.get("OSS_NAME.UNCONFIRMED.MSG"))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
if (key.toUpperCase().startsWith("OSSVERSION") && diffMap.get(key).equals(ruleMap.get("OSS_VERSION.UNCONFIRMED.MSG"))) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
if (key.toUpperCase().startsWith("DOWNLOADLOCATION") && diffMap.get(key).equals(ruleMap.get("DOWNLOAD_LOCATION.DIFFERENT.MSG"))) {
int duplicateRow = (int) resultData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList())
.size();
if (duplicateRow == 0) {
resultData.addAll((List<ProjectIdentification>) componentData
.stream()
.filter(e -> key.split("\\.")[1].equals(e.getComponentId())) // ๋์ผํ componentId์ filter
.collect(Collectors.toList()));
}
}
}
}
if (validMap == null && diffMap == null) {
resultData.addAll(componentData.stream().filter(e -> e.getOssName().equals("-")).collect(Collectors.toList()));
}
return resultData;
}
private Map<String, OssMaster> getNewestOssInfoOnTime(OssMaster ossMaster) {
List<OssMaster> list = ossMapper.getNewestOssInfoByOssMaster(ossMaster);
return makeBasicOssInfoMap(list, true, false);
}
@Override
public List<OssMaster> getOssListBySync(OssMaster bean) {
List<OssMaster> list = ossMapper.getOssListByName(bean);
if (list == null) {
list = new ArrayList<>();
}
// oss id๋ก ์ทจํฉ(๋ผ์ด์ ์ค ์ ๋ณด)
List<OssMaster> newList = new ArrayList<>();
Map<String, OssMaster> remakeMap = new HashMap<>();
OssMaster currentBean = null;
for (OssMaster ossBean : list) {
// name + version
if (!isEmpty(ossBean.getOssVersion())) {
ossBean.setOssNameVerStr(ossBean.getOssName() + " (" + ossBean.getOssVersion() + ")");
} else {
ossBean.setOssNameVerStr(ossBean.getOssName());
}
if (remakeMap.containsKey(ossBean.getOssId())) {
currentBean = remakeMap.get(ossBean.getOssId());
} else {
currentBean = ossBean;
if (!isEmpty(currentBean.getOssNickname())) {
currentBean.setOssNickname(currentBean.getOssNickname().replaceAll("\\|", "<br>"));
}
currentBean.setCopyright(CommonFunction.lineReplaceToBR(ossBean.getCopyright()));
currentBean.setSummaryDescription(CommonFunction.lineReplaceToBR(ossBean.getSummaryDescription()));
currentBean.setAttribution(CommonFunction.lineReplaceToBR(ossBean.getAttribution()));
}
List<OssMaster> ossDownloadLocation = ossMapper.selectOssDownloadLocationList(bean);
if (ossDownloadLocation.size() > 0) {
StringBuilder sb = new StringBuilder();
for (OssMaster location : ossDownloadLocation) {
sb.append(location.getDownloadLocation()).append(",");
}
String[] ossDownloadLocations = new String(sb).split("[,]");
currentBean.setDownloadLocations(ossDownloadLocations);
}
OssLicense licenseBean = new OssLicense();
licenseBean.setLicenseId(ossBean.getLicenseId());
licenseBean.setOssLicenseIdx(ossBean.getOssLicenseIdx());
licenseBean.setLicenseName(ossBean.getLicenseName());
licenseBean.setOssLicenseComb(ossBean.getOssLicenseComb());
licenseBean.setOssLicenseText(CommonFunction.lineReplaceToBR(ossBean.getOssLicenseText()));
licenseBean.setOssCopyright(CommonFunction.lineReplaceToBR(ossBean.getOssCopyright()));
currentBean.addOssLicense(licenseBean);
if (remakeMap.containsKey(ossBean.getOssId())) {
remakeMap.replace(ossBean.getOssId(), currentBean);
} else {
remakeMap.put(ossBean.getOssId(), currentBean);
}
}
for (OssMaster ossBean : remakeMap.values()) {
ossBean.setLicenseName(CommonFunction.makeLicenseExpression(ossBean.getOssLicenses()));
newList.add(ossBean);
}
return newList;
}
@Override
public List<String> getOssListSyncCheck(List<OssMaster> selectOssList, List<OssMaster> standardOssList) {
OssMaster standardOss = standardOssList.get(0);
OssMaster selectOss = selectOssList.get(0);
List<String> checkList = new ArrayList<String>();
if (!Arrays.equals(standardOss.getOssLicenses().toArray(), selectOss.getOssLicenses().toArray())) {
if (!standardOss.getLicenseName().equals(selectOss.getLicenseName())) {
checkList.add("Declared License");
}
}
if (!Arrays.equals(standardOss.getDetectedLicenses().toArray(), selectOss.getDetectedLicenses().toArray())) {
if (!standardOss.getDetectedLicense().equals(selectOss.getDetectedLicense())) {
checkList.add("Detected License");
}
}
if (!avoidNull(standardOss.getCopyright(), "").equals(avoidNull(selectOss.getCopyright(), ""))) {
checkList.add("Copyright");
}
if (standardOss.getDownloadLocations() != null) {
if (selectOss.getDownloadLocations() != null) {
if (!Arrays.equals(Arrays.asList(standardOss.getDownloadLocations()).toArray(), Arrays.asList(selectOss.getDownloadLocations()).toArray())) {
checkList.add("Download Location");
}
} else {
checkList.add("Download Location");
}
} else {
if (selectOss.getDownloadLocations() != null) {
checkList.add("Download Location");
}
}
if (!avoidNull(standardOss.getHomepage(), "").equals(avoidNull(selectOss.getHomepage(), ""))) {
checkList.add("Home Page");
}
if (!avoidNull(standardOss.getSummaryDescription(), "").equals(avoidNull(selectOss.getSummaryDescription(), ""))) {
checkList.add("Summary Description");
}
if (!avoidNull(standardOss.getAttribution(), "").equals(avoidNull(selectOss.getAttribution(), ""))) {
checkList.add("Attribution");
}
return checkList;
}
@Override
public void syncOssMaster(OssMaster ossMaster, boolean declaredLicenseCheckFlag, boolean detectedLicenseCheckFlag, boolean downloadLocationCheckFlag) {
ossMaster.setModifier(ossMaster.getLoginUserName());
checkOssLicenseAndObligation(ossMaster);
ossMapper.updateOssMasterSync(ossMaster);
if (declaredLicenseCheckFlag) {
ossMapper.deleteOssLicenseDeclaredSync(ossMaster);
List<OssLicense> list = ossMaster.getOssLicenses();
int ossLicenseDeclaredIdx = 0;
String licenseId = "";
for (OssLicense license : list) {
ossLicenseDeclaredIdx++;
licenseId = CommonFunction.getLicenseIdByName(license.getLicenseName());
OssMaster om = new OssMaster(
Integer.toString(ossLicenseDeclaredIdx)
, ossMaster.getOssId()
, licenseId
, license.getLicenseName()
, ossLicenseDeclaredIdx == 1 ? "" : license.getOssLicenseComb()
, license.getOssLicenseText()
, license.getOssCopyright()
, ossMaster.getLicenseDiv()
);
ossMapper.insertOssLicenseDeclared(om);
}
updateLicenseDivDetail(ossMaster);
}
if (detectedLicenseCheckFlag) {
ossMapper.deleteOssLicenseDetectedSync(ossMaster);
List<String> detectedLicenses = ossMaster.getDetectedLicenses().stream().distinct().collect(Collectors.toList());
if (detectedLicenses != null) {
int ossLicenseDetectedIdx = 0;
for (String detectedLicense : detectedLicenses) {
if (!isEmpty(detectedLicense)) {
LicenseMaster detectedLicenseInfo = CoCodeManager.LICENSE_INFO_UPPER.get(detectedLicense.toUpperCase());
OssMaster om = new OssMaster(
ossMaster.getOssId() // ossId
, detectedLicenseInfo.getLicenseId() // licenseId
, Integer.toString(++ossLicenseDetectedIdx) // ossLicenseIdx
);
ossMapper.insertOssLicenseDetected(om);
}
}
}
}
if (downloadLocationCheckFlag) {
registOssDownloadLocation(ossMaster);
}
if (!isEmpty(avoidNull(ossMaster.getComment()).trim())) {
CommentsHistory param = new CommentsHistory();
param.setReferenceId(ossMaster.getOssId());
param.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_OSS);
param.setContents(ossMaster.getComment());
commentService.registComment(param);
}
// Deactivate Flag Setting
if (isEmpty(ossMaster.getDeactivateFlag())) {
ossMaster.setDeactivateFlag(CoConstDef.FLAG_NO);
}
ossMapper.setDeactivateFlag(ossMaster);
}
@Override
public OssMaster makeEmailSendFormat(OssMaster bean) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(bean.getOssLicenses()));
bean.setOssLicenses(CommonFunction.changeLicenseNameToShort(bean.getOssLicenses()));
if (!isEmpty(bean.getLicenseDiv())) {
bean.setMultiLicenseFlag(bean.getLicenseDiv());
bean.setLicenseDiv(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_DIV, bean.getLicenseDiv()));
}
if (!isEmpty(bean.getLicenseType())) {
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, bean.getLicenseType()));
}
if (!isEmpty(bean.getObligationType())) {
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, bean.getObligationType()));
}
if (!isEmpty(bean.getModifiedDate())) {
bean.setModifiedDate(DateUtil.dateFormatConvert(bean.getModifiedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
if (!isEmpty(bean.getModifier())) {
bean.setModifier(CoMailManager.getInstance().makeUserNameFormat(bean.getModifier()));
}
bean.setAttribution(CommonFunction.lineReplaceToBR(bean.getAttribution()));
bean.setSummaryDescription(CommonFunction.lineReplaceToBR(bean.getSummaryDescription()));
bean.setCopyright(CommonFunction.lineReplaceToBR(bean.getCopyright()));
return bean;
}
@Override
public String checkOssVersionDiff(OssMaster ossMaster) {
boolean ossVersion_Flag = false;
boolean isNew = StringUtil.isEmpty(ossMaster.getOssId());
if (!isNew) {
OssMaster beforeOss = CoCodeManager.OSS_INFO_BY_ID.get(ossMaster.getOssId());
List<String> ossNameList = new ArrayList<>();
ossNameList.add(beforeOss.getOssName().trim());
String[] ossNames = new String[ossNameList.size()];
beforeOss.setOssNames(ossNameList.toArray(ossNames));
Map<String, OssMaster> beforeOssMap = getBasicOssInfoList(beforeOss);
ossNameList = new ArrayList<>();
ossNameList.add(ossMaster.getOssName().trim());
ossNames = new String[ossNameList.size()];
ossMaster.setOssNames(ossNameList.toArray(ossNames));
Map<String, OssMaster> afterOssMap = getBasicOssInfoList(ossMaster);
if ((afterOssMap == null || afterOssMap.isEmpty()) && beforeOssMap.size() > 1) {
ossVersion_Flag = true;
}
return ossVersion_Flag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO;
}else {
return ossVersion_Flag ? CoConstDef.FLAG_YES : CoConstDef.FLAG_NO;
}
}
@Transactional
@Override
public Map<String, List<OssMaster>> updateOssNameVersionDiff(OssMaster ossMaster) {
String beforeOssName = getOssInfo(ossMaster.getOssId(), false).getOssName();
String afterOssName = ossMaster.getOssName();
Map<String, List<OssMaster>> ossNameVersionDiffMergeObject = new HashMap<>();
List<OssMaster> beforeOssNameVersionBeanList = new ArrayList<OssMaster>();
List<OssMaster> afterOssNameVersionBeanList = new ArrayList<OssMaster>();
List<String> beforeOssNameVersionOssIdList = new ArrayList<String>();
OssMaster beforeOssNameVersionBean = null;
OssMaster afterOssNameVersionBean = null;
List<String> beforeOssNameList = new ArrayList<>();
beforeOssNameList.add(beforeOssName);
String[] beforeOssNames = new String[beforeOssNameList.size()];
ossMaster.setOssNames(beforeOssNameList.toArray(beforeOssNames));
Map<String, OssMaster> beforeOssMap = getBasicOssInfoList(ossMaster);
History history;
for (OssMaster om : beforeOssMap.values()) {
if (!ossMaster.getOssVersion().equals(om.getOssVersion())) {
beforeOssNameVersionOssIdList.add(om.getOssId());
beforeOssNameVersionBean = getOssInfo(om.getOssId(), true);
beforeOssNameVersionBeanList.add(beforeOssNameVersionBean);
}
if (!beforeOssName.equals(afterOssName)) {
om.setOssName(afterOssName);
ossMapper.changeOssNameByDelete(om);
history = work(om);
history.sethAction(CoConstDef.ACTION_CODE_UPDATE);
historyService.storeData(history);
}
}
ossMaster.setOssName(beforeOssName);
if (ossMaster.getOssNicknames() != null) {
ossMapper.deleteOssNickname(ossMaster);
ossMaster.setOssName(afterOssName);
for (String nickName : ossMaster.getOssNicknames()){
if (!isEmpty(nickName)) {
ossMaster.setOssNickname(nickName.trim());
ossMapper.insertOssNickname(ossMaster);
}
}
} else {
ossMapper.deleteOssNickname(ossMaster);
}
CoCodeManager.getInstance().refreshOssInfo();
for (String ossId : beforeOssNameVersionOssIdList) {
afterOssNameVersionBean = getOssInfo(ossId, true);
afterOssNameVersionBeanList.add(afterOssNameVersionBean);
}
if (beforeOssNameVersionBeanList != null && !beforeOssNameVersionBeanList.isEmpty()) {
beforeOssNameVersionBeanList = beforeOssNameVersionBeanList.stream()
.sorted(Comparator.comparing(OssMaster::getOssVersion, Comparator.nullsLast(Comparator.naturalOrder())))
.collect(Collectors.toList());
afterOssNameVersionBeanList = afterOssNameVersionBeanList.stream()
.sorted(Comparator.comparing(OssMaster::getOssVersion, Comparator.nullsLast(Comparator.naturalOrder())))
.collect(Collectors.toList());
}
ossNameVersionDiffMergeObject.put("before", beforeOssNameVersionBeanList);
ossNameVersionDiffMergeObject.put("after", afterOssNameVersionBeanList);
if (!beforeOssName.equals(afterOssName)) {
OssMaster param = new OssMaster();
param.setOssName(beforeOssName);
param.setOssVersion(null);
// 3rdParty == 'CONF'
List<PartnerMaster> confirmPartnerList = ossMapper.getOssNameMergePartnerList(param);
if (confirmPartnerList.size() > 0) {
param.setMergeOssName(afterOssName);
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_PARTNER);
for (PartnerMaster pm : confirmPartnerList) {
param.setPrjId(pm.getPartnerId());
List<OssComponents> confirmOssComponentsList = ossMapper.getConfirmOssComponentsList(param);
for (OssComponents oc : confirmOssComponentsList) {
param.setOssVersion(oc.getOssVersion());
try {
ossMapper.updateOssComponents(param);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
String contents = "<p>The following OSS Name has been changed.</p>\r\n" +
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:600px;\">\r\n" +
" <tbody>\r\n" +
" <tr>\r\n" +
" <th>OSS Name(OSS Version)</th>\r\n" +
" <th>OSS Name(OSS Version)</th>\r\n" +
" </tr>\r\n" +
" <tr>\r\n" +
" <td style=\"text-align:center;\">"+ beforeOssName + " ("+ avoidNull(oc.getOssVersion(), "N/A") +") </td>\r\n" +
" <td style=\"text-align:center;\">"+ afterOssName + " ("+ avoidNull(oc.getOssVersion(), "N/A") +") </td>\r\n" +
" </tr>\r\n" +
" </tbody>\r\n" +
"</table>";
// partner Comment Regist
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PARTNER_HIS);
historyBean.setReferenceId(pm.getPartnerId());
historyBean.setStatus("OSS Name Changed");
historyBean.setContents(contents);
commentService.registComment(historyBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
param.setOssVersion(null);
// Identification == 'CONF', verification
List<Project> confirmProjectList = ossMapper.getOssNameMergeProjectList(param);
if (confirmProjectList.size() > 0) {
param.setMergeOssName(afterOssName);
param.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_SRC);
for (Project prj : confirmProjectList) {
param.setPrjId(prj.getPrjId());
List<OssComponents> confirmOssComponentsList = ossMapper.getConfirmOssComponentsList(param);
for (OssComponents oc : confirmOssComponentsList) {
param.setOssVersion(oc.getOssVersion());
try {
ossMapper.updateOssComponents(param);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
String contents = "<p>The following OSS Name has been changed.</p>\r\n" +
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:600px;\">\r\n" +
" <tbody>\r\n" +
" <tr>\r\n" +
" <th>OSS Name(OSS Version) (Written before)</th>\r\n" +
" <th>OSS Name(OSS Version) (Changed)</th>\r\n" +
" </tr>\r\n" +
" <tr>\r\n" +
" <td style=\"text-align:center;\">"+ beforeOssName + " ("+ avoidNull(oc.getOssVersion(), "N/A") + ") </td>\r\n" +
" <td style=\"text-align:center;\">"+ afterOssName + " ("+ avoidNull(oc.getOssVersion(), "N/A") + ") </td>\r\n" +
" </tr>\r\n" +
" </tbody>\r\n" +
"</table>";
// Project > Identification comment regist
CommentsHistory historyBean = new CommentsHistory();
historyBean.setReferenceId(prj.getPrjId());
historyBean.setStatus("OSS Name Changed");
historyBean.setContents(contents);
historyBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commentService.registComment(historyBean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
}
return ossNameVersionDiffMergeObject;
}
@Override
public OssMaster getSaveSesstionOssInfoByName(OssMaster ossMaster) {
return ossMapper.getSaveSesstionOssInfoByName(ossMaster);
}
@Override
public List<Vulnerability> getOssVulnerabilityList2(OssMaster ossMaster) {
if (avoidNull(ossMaster.getCveId()).isEmpty() && avoidNull(ossMaster.getCvssScore()).isEmpty()) {
return null;
}
List<Vulnerability> list = null;
List<Vulnerability> convertList = new ArrayList<>();
if ("N/A".equals(ossMaster.getOssVersion()) || isEmpty(ossMaster.getOssVersion())) {
ossMaster.setOssVersion("-");
}
String[] nicknameList = null;
List<String> dashOssNameList = new ArrayList<>();
List<String> convertNameList = null;
boolean convertFlag = false;
try {
if (ossMaster.getOssName().contains(" ")) {
ossMaster.setOssNameTemp(ossMaster.getOssName().replaceAll(" ", "_"));
}
if (ossMaster.getOssName().contains("-")) {
dashOssNameList.add(ossMaster.getOssName());
}
nicknameList = getOssNickNameListByOssName(ossMaster.getOssName());
for (String nick : nicknameList) {
if (nick.contains("-")) {
dashOssNameList.add(nick);
}
if (nick.contains(" ")) {
if (!convertFlag) {
convertNameList = new ArrayList<>();
convertFlag = true;
}
convertNameList.add(nick.replaceAll(" ", "_"));
}
}
if (convertNameList != null) {
convertNameList.addAll(Arrays.asList(nicknameList));
ossMaster.setOssNicknames(convertNameList.toArray(new String[convertNameList.size()]));
} else {
ossMaster.setOssNicknames(nicknameList);
}
if (dashOssNameList.size() > 0) {
ossMaster.setDashOssNameList(dashOssNameList.toArray(new String[dashOssNameList.size()]));
}
list = ossMapper.getOssVulnerabilityList2(ossMaster);
} catch (Exception e) {
log.error(e.getMessage());
}
if (list != null) {
list = checkVulnData(list, ossMaster.getOssNicknames());
list = list.stream().filter(CommonFunction.distinctByKey(e -> e.getCveId())).collect(Collectors.toList());
int idx = 1;
for (Vulnerability vuln : list) {
if (idx > 5) break;
convertList.add(vuln);
idx++;
}
}
ossMaster.setOssNameTemp(null);
if (convertFlag) ossMaster.setOssNicknames(nicknameList);
return convertList;
}
private List<Vulnerability> checkVulnData(List<Vulnerability> list, String[] nicknameList) {
List<Vulnerability> result = new ArrayList<Vulnerability>();
for (Vulnerability bean : list) {
bean.setOssNameAllSearchFlag(CoConstDef.FLAG_YES);
if (nicknameList != null) {
bean.setOssNicknames(nicknameList);
}
int vulnCnt = vulnerabilityMapper.checkVulnDataCnt(bean);
if (vulnCnt > 0) {
result.add(bean);
}
}
return result;
}
@Override
public List<String> getOssNicknameListWithoutOwn(OssMaster ossMaster, List<String> checkList, List<String> duplicatedList) {
if (checkList != null && checkList.size() > 0) {
List<OssMaster> ossNameCheckList = ossMapper.selectOssNameList();
ossNameCheckList = ossNameCheckList.stream()
.filter(e -> checkList.stream().anyMatch(Predicate.isEqual(e.getOssName())))
.collect(Collectors.toList());
List<OssMaster> ossNicknameCheckList = ossMapper.selectOssNicknameListWithoutOwn(ossMaster);
ossNicknameCheckList = ossNicknameCheckList.stream()
.filter(e -> checkList.stream().anyMatch(Predicate.isEqual(e.getOssNickname())))
.collect(Collectors.toList());
if (ossNameCheckList != null && ossNameCheckList.size() > 0) {
for (OssMaster om : ossNameCheckList) {
if (duplicatedList.isEmpty() || !duplicatedList.contains(om.getOssName())) {
duplicatedList.add(om.getOssName());
}
}
}
if (ossNicknameCheckList != null && ossNicknameCheckList.size() > 0) {
for (OssMaster om : ossNicknameCheckList) {
if (duplicatedList.isEmpty() || !duplicatedList.contains(om.getOssNickname())) {
duplicatedList.add(om.getOssNickname());
}
}
}
}
return duplicatedList;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> sendMailForSaveOss(Map<String, Object> resMap) {
OssMaster ossMaster = (OssMaster) resMap.get("ossMaster");
String ossId = (String) resMap.get("ossId");
boolean isNew = (boolean) resMap.get("isNew");
boolean isNewVersion = (boolean) resMap.get("isNewVersion");
boolean isChangedName = (boolean) resMap.get("isChangedName");
boolean isDeactivateFlag = (boolean) resMap.get("isDeactivateFlag");
boolean isActivateFlag = (boolean) resMap.get("isActivateFlag");
Map<String, List<OssMaster>> updateOssNameVersionDiffMergeObject = null;
if (resMap.containsKey("updateOssNameVersionDiffMergeObject")) {
updateOssNameVersionDiffMergeObject = (Map<String, List<OssMaster>>) resMap.get(
"updateOssNameVersionDiffMergeObject");
}
String mailType = "";
if (CoConstDef.FLAG_YES.equals(ossMaster.getRenameFlag())) {
mailType = CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME;
} else if (isNew) {
mailType = isNewVersion
? CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION
: CoConstDef.CD_MAIL_TYPE_OSS_REGIST;
} else {
mailType = isChangedName
? CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME
: CoConstDef.CD_MAIL_TYPE_OSS_UPDATE;
if (isDeactivateFlag) {
mailType = CoConstDef.CD_MAIL_TYPE_OSS_DEACTIVATED;
}
if (isActivateFlag) {
mailType = CoConstDef.CD_MAIL_TYPE_OSS_ACTIVATED;
}
}
try {
CoMail mailBean = new CoMail(mailType);
mailBean.setParamOssId(ossId);
mailBean.setComment(ossMaster.getComment());
if (!isNew && !isDeactivateFlag) {
mailBean.setCompareDataBefore((OssMaster) resMap.get("beforeBean"));
mailBean.setCompareDataAfter((OssMaster) resMap.get("afterBean"));
} else if (isNewVersion) {
mailBean.setParamOssInfo(ossMaster);
}
if (CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(mailType)
|| CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(mailType)
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(mailType)) {
setVdiffInfoForSentMail(ossMaster.getOssName(), mailBean);
}
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error("Failed to send mail:" + e.getMessage());
}
if (!isNew && CoConstDef.FLAG_YES.equals(ossMaster.getRenameFlag())) {
if (updateOssNameVersionDiffMergeObject != null) {
List<OssMaster> beforeOssNameVersionMergeList = updateOssNameVersionDiffMergeObject.get("before");
List<OssMaster> afterOssNameVersionMergeList = updateOssNameVersionDiffMergeObject.get("after");
if (afterOssNameVersionMergeList != null) {
for (int i = 0; i < afterOssNameVersionMergeList.size(); i++) {
try {
mailType = CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME;
CoMail mailBean = new CoMail(mailType);
mailBean.setComment(ossMaster.getComment());
mailBean.setParamOssId(afterOssNameVersionMergeList.get(i).getOssId());
mailBean.setCompareDataBefore(beforeOssNameVersionMergeList.get(i));
mailBean.setCompareDataAfter(afterOssNameVersionMergeList.get(i));
CoMailManager.getInstance().sendMail(mailBean);
} catch (Exception e) {
log.error("Failed to send mail:" + e.getMessage());
}
}
}
}
}
putSessionObject("defaultLoadYn", true); // ํ๋ฉด ๋ก๋ ์ default๋ก ๋ฆฌ์คํธ ์กฐํ ์ฌ๋ถ flag
resMap.put("ossId", ossId);
return resMap;
}
public void setVdiffInfoForSentMail(String ossName, CoMail mailBean) {
List<Map<String, Object>> resultData = new ArrayList<>();
boolean vDiffFlag = ossMapper.checkOssVersionDiff(ossName) > 0 ? true : false;
if(vDiffFlag) {
OssMaster param = new OssMaster();
param.setOssNames(new String[] {ossName});
Map<String, OssMaster> ossMap = getBasicOssInfoList(param);
for (String key : ossMap.keySet()) {
OssMaster om = ossMap.get(key);
Map<String, Object> contentMap = new HashMap<>();
contentMap.put("ossNameInfo", om.getOssName() + " (" + om.getOssVersion() + ")");
contentMap.put("licenseInfo", CommonFunction.makeLicenseExpression(om.getOssLicenses()));
resultData.add(contentMap);
}
if (resultData != null && !resultData.isEmpty()) {
mailBean.setParamList(resultData);
} else {
mailBean.setParamList(new ArrayList<>());
}
}
}
@Override
public List<String> getDeactivateOssList() {
return ossMapper.getDeactivateOssList();
}
@Override
public Map<String, Object> getOssDataMap(String gridId, boolean status, String msg) {
Map<String, Object> ossDataMap = new HashMap<>();
ossDataMap.put("gridId", gridId);
ossDataMap.put("status", status);
ossDataMap.put("msg", msg);
return ossDataMap;
}
@Transactional
@Override
public Map<String, Object> saveOssURLNickname(ProjectIdentification paramBean) {
Map<String, Object> map = new HashMap<String, Object>();
OssMaster ossMaster = new OssMaster();
ossMaster.setOssName(paramBean.getCheckName());
List<String> checkOssNameUrl = CoCodeManager.getCodeNames(CoConstDef.CD_CHECK_OSS_NAME_URL);
int urlSearchSeq = -1;
int seq = 0;
for (String url : checkOssNameUrl) {
if (urlSearchSeq == -1 && paramBean.getDownloadLocation().contains(url)) {
urlSearchSeq = seq;
break;
}
seq++;
}
ProjectIdentification bean;
try {
for (String recommendedNickname : paramBean.getRecommendedNickname().split("\\|")) {
ossMaster.setOssNickname(recommendedNickname);
ossMapper.mergeOssNickname2(ossMaster);
}
if (urlSearchSeq > -1) {
bean = downloadlocationFormatter(paramBean, urlSearchSeq);
String downloadLocation = bean.getDownloadLocation();
String redirectLocation = bean.getRedirectLocation();
bean.setOssName(paramBean.getCheckName());
for (int i = 0; i < 2; i++) {
if (i == 0) {
bean.setDownloadLocation(downloadLocation);
} else {
bean.setDownloadLocation(redirectLocation);
}
if (ossMapper.checkOssNameUrl2Cnt(bean) == 0) {
Map<String, Object> data = ossMapper.getRecentlyModifiedOss(ossMaster);
ossMaster.setOssId(String.valueOf(data.get("OSS_ID")));
int cnt = Integer.parseInt(String.valueOf(data.get("CNT"))) + 1;
ossMaster.setSOrder(Integer.toString(cnt));
ossMaster.setDownloadLocation("https://" + bean.getDownloadLocation());
ossMapper.insertOssDownloadLocation(ossMaster);
}
}
}
map.put("isValid", true);
map.put("returnType", "Success");
} catch (Exception e) {
log.error(e.getMessage());
map.put("isValid", false);
map.put("returnType", e.getMessage());
}
return map;
}
@Override
public List<String> selectVulnInfoForOss(OssMaster ossMaster) {
return ossMapper.selectVulnInfoForOss(ossMaster);
}
@Override
public List<String> checkExistsVendorProductMatchOss(OssMaster ossMaster) {
return ossMapper.checkExistsVendorProductMatchOss(ossMaster);
}
@Override
public int checkOssVersionDiff(String ossName) {
return ossMapper.checkOssVersionDiff(ossName);
}
@Override
public boolean checkOssTypeForAnalysisResult(OssAnalysis ossAnalysis) {
boolean vDiffFlag = false;
OssMaster param = new OssMaster();
List<String> ossNameList = new ArrayList<>();
String ossName = ossAnalysis.getOssName();
String ossNameTemp = "";
boolean ossNameFlag = false;
if (CoCodeManager.OSS_INFO_UPPER_NAMES.containsKey(ossName.toUpperCase())) {
ossNameTemp = CoCodeManager.OSS_INFO_UPPER_NAMES.get(ossName.toUpperCase());
if (!isEmpty(ossNameTemp) && ossName.equalsIgnoreCase(ossNameTemp)) {
ossNameFlag = true;
}
}
if (ossNameFlag) {
ossNameList.add(ossName);
} else {
ossNameList.add(ossNameTemp);
}
String[] ossNames = new String[ossNameList.size()];
param.setOssNames(ossNameList.toArray(ossNames));
Map<String, OssMaster> ossMap = getBasicOssInfoList(param);
if (ossMap != null && ossMap.size() > 1) {
List<List<OssLicense>> andCombLicenseListStandard = new ArrayList<>();
List<List<OssLicense>> andCombLicenseListCompare = new ArrayList<>();
int idx = 0;
for (OssMaster _bean : ossMap.values()) {
if (!isEmpty(_bean.getOssId())) {
if (idx == 0) {
andCombLicenseListStandard = makeLicenseKeyList(_bean.getOssLicenses());
}else {
if (!vDiffFlag && _bean.getOssLicenses() != null) {
andCombLicenseListCompare = makeLicenseKeyList(_bean.getOssLicenses());
if (andCombLicenseListStandard.size() != andCombLicenseListCompare.size()) {
vDiffFlag = true;
break;
}else {
if (!checkLicenseListVersionDiff(andCombLicenseListStandard, andCombLicenseListCompare)) {
vDiffFlag = true;
break;
}
}
andCombLicenseListCompare = new ArrayList<>();
}
}
idx++;
}
}
}
return vDiffFlag;
}
@Override
public String getOssAnalysisStatus(String prjId) {
String status = ossMapper.getOssAnalysisStatus(prjId);
return status;
}
@Override
public void deleteOssAnalysis(String prjId) {
ossMapper.deleteOssAnalysis(prjId);
}
}
| 143,356 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
NoticeServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/NoticeServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.domain.Notice;
import oss.fosslight.repository.NoticeMapper;
import oss.fosslight.service.NoticeService;
@Service("NoticeService")
public class NoticeServiceImpl extends CoTopComponent implements NoticeService {
//Mapper
@Autowired NoticeMapper noticeMapper;
/**
* ์ฝ๋ ๋ชฉ๋ก ์กฐํ
*/
@Override
public Map<String, Object> getNoticeList(Notice vo) throws Exception {
Map<String, Object> map = null;
int records = noticeMapper.selectNoticeTotalCount(vo);
if (records > 0) {
vo.setTotListSize(records);
// Grid paging ์ฒ๋ฆฌ๋ฅผ ์ํ ๊ธฐ๋ณธ param ์ค์ Map ์์ฑ(๋ฐ๋์ totlistsize๋ฅผ set ํ๊ณ ๋์ ์์ฑํด์ผํจ)
map = getGridPagerMap(vo);
List<Notice> noticeList = noticeMapper.selectNoticeList(vo);
// ํ
๊ทธ ์นํ
if (noticeList != null) {
for (Notice item : noticeList) {
item.setReplaceNotice(item.getNotice().replaceAll("<br>", "\n\r"));
item.setReplaceNotice(item.getNotice().replaceAll("<(/)?([a-zA-Z]*)(\\\\s[a-zA-Z]*=[^>]*)?(\\\\s)*(/)?>", ""));
}
}
map.put("rows", noticeList);
}
return map == null ? new HashMap<String, Object>() : map;
}
@Override
public void setNotice(Notice vo) throws Exception {
if (CoConstDef.GRID_OPERATION_ADD.equals(vo.getOper())) { // ์ถ๊ฐ
noticeMapper.insertNotice(vo);
} else if (CoConstDef.GRID_OPERATION_EDIT.equals(vo.getOper())) { // ์์
noticeMapper.updateNotice(vo);
} else { // ์ญ์
noticeMapper.deleteNotice(vo);
}
}
@Override
public Map<String, Object> getPublishedNotice(Notice vo) throws Exception {
Map<String, Object> map = null;
int records = noticeMapper.selectPublishedNoticeCount(vo);
if (records > 0) {
List<Notice> noticeList = noticeMapper.selectPublishedNotice(vo);
map = getGridPagerMap(vo);
if (noticeList != null) {
map.put("noticeList", noticeList);
}
}
return map == null ? new HashMap<String, Object>() : map;
}
}
| 2,482 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
HistoryServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/HistoryServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.domain.History;
import oss.fosslight.repository.HistoryMapper;
import oss.fosslight.service.HistoryService;
@Service
public class HistoryServiceImpl extends CoTopComponent implements HistoryService {
@Autowired HistoryMapper hisotryMapper;
@Override
public void storeData(History history) {
history.sethData(toJson(history.gethData()));
hisotryMapper.insertHistoryData(history);
}
@Override
public History getData(History history){
return hisotryMapper.selectOneHistoryData(history);
}
@Override
public Map<String, Object> getList(History history) {
Map<String, Object> map = new HashMap<String, Object>();
history.setTotListSize(hisotryMapper.selectHistoryDataTotalCount(history));
List<History> hList = hisotryMapper.selectHistoryData(history);
map.put("pageInfo", history); // page: curPage, total: blockEnd, records: totListSize
map.put("rows", hList);
return map;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> getAsToBeHistoryDataByGrid(History history) {
History beData = hisotryMapper.selectOneHistoryData(history);
History asData = hisotryMapper.selectOneHistoryBeforeData(beData);
Map<String, Object> asMap = asData != null ? ((Map<String, Object>)fromJson((String) asData.gethData(), Map.class)) : null;
Map<String, Object> beMap = beData != null ? ((Map<String, Object>)fromJson((String) beData.gethData(), Map.class)) : null;
List<Map<String, Object>> mTbl = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> sTblList = new ArrayList<Map<String, Object>>();
// Data : dtlCd
// Param : String CD_NO
// Result : Vector [ String CD_DTL_NO, String CD_DTL_NM(Key), String CD_SUB_NO(Ref Entity) ]
int cnt = 1;
String cdNm = beData != null ? beData.gethType() : null;
for (String[] dtlCd : CoCodeManager.getValues(cdNm)){
Map<String, Object> dataMap = new HashMap<String, Object>();
// EXP : TYPE(String, Code, Array, Object) | NAME | CD_NO
String[] inf = CoCodeManager.getCodeExpString(cdNm, dtlCd[0]).split("\\|");
dataMap.put("no", cnt++);
dataMap.put("name", inf[1]);
Object asD_ = getDataForType(cdNm, dtlCd, asMap);
Object beD_ = getDataForType(cdNm, dtlCd, beMap);
// main data
if (asD_.getClass().equals(String.class) && beD_.getClass().equals(String.class)){
dataMap.put("as", asD_);
dataMap.put("be", beD_);
} else { // sub list data
dataMap.put("as", "-");
dataMap.put("be", "-");
Map<String, Object> sTblMap = new HashMap<String, Object>();
sTblMap.put("type", ((Map<String, Object>)asD_).get("type"));
sTblMap.put("colNames", ((Map<String, Object>)asD_).get("colNames"));
sTblMap.put("subAsList", ((Map<String, Object>)asD_).get("subList"));
sTblMap.put("subBeList", ((Map<String, Object>)beD_).get("subList"));
sTblList.add(sTblMap);
}
mTbl.add(dataMap);
}
Map<String, Object> asToBeMap = new HashMap<String, Object>();
asToBeMap.put("main", mTbl);
asToBeMap.put("sub", sTblList);
asToBeMap.put("asModifier", asData != null ? asData.getModifier() : "");
asToBeMap.put("beModifier", beData != null ? beData.getModifier() : "");
asToBeMap.put("asModifiedDate", asData != null ? asData.getModifiedDate() : "");
asToBeMap.put("beModifiedDate", beData != null ? beData.getModifiedDate() : "");
return asToBeMap;
}
// History Sub Method
@SuppressWarnings("unchecked")
public Object getDataForType(String cdNm, String[] dtlCd, Map<String, Object> dMap){
Object ret = null;
// EXP : TYPE(String, Code, Array, Object) | NAME | CD_NO
String[] inf = CoCodeManager.getCodeExpString(cdNm, dtlCd[0]).split("\\|");
if (inf[0].equals("String")) {
ret = dMap != null ? escapeSql(nvl((String)dMap.get(dtlCd[1]), "")) : "";
} else if (inf[0].equals("Code")) {
if ((dtlCd[1]).equals("obligation")){
ret = dMap != null ? (String)dMap.get("obligationType"): "";
}else{
ret = dMap != null ?nvl(CoCodeManager.getCodeString(inf[2], (String)dMap.get(dtlCd[1])), inf[2]) : "";
}
} else if (inf[0].equals("Array") && "999".equals(dtlCd[2])) {
List<String> asArr = dMap != null ? (ArrayList<String>)dMap.get(dtlCd[1]) : null;
ret = asArr != null && asArr.size() > 0 ? String.join("<br>", asArr) : "";
} else if (inf[0].equals("Array") && dtlCd[2] == null) {
List<String> asArr = dMap != null ? (ArrayList<String>)dMap.get(dtlCd[1]) : null;
ret = asArr != null && asArr.size() > 0 ? String.join(", ", asArr) : "";
} else if (inf[0].equals("Array") && dtlCd[2] != null) {
String sCdNm = dtlCd[2]; // CD_SUB_NO(Ref Entity)
HashMap<String, Object> sTblMap = new HashMap<String, Object>();
// colNames ์์ฑ
List<Map<String, Object>> colNames = new ArrayList<Map<String, Object>>();
// Param : String CD_NO
// Result : Vector&String [ String CD_DTL_NO, String CD_SUB_NO, String CD_DTL_NM, String CD_DTL_NM, String CD_DTL_EXP, String CD_ORDER ]
HashMap<String, Object> colInfo = new HashMap<String, Object>();
colInfo.put("key", "no");
colInfo.put("name", "no");
colInfo.put("order", "0");
colNames.add(colInfo);
for (String[] v : CoCodeManager.getAllValues(sCdNm)){
colInfo = new HashMap<String, Object>();
colInfo.put("key", v[2]);
colInfo.put("name", v[4].split("\\|")[1]);
colInfo.put("order", v[5]);
colNames.add(colInfo);
}
sTblMap.put("type", inf[1]); // model name
sTblMap.put("colNames", colNames); // list columns
// colModel ์์ฑ
List<Map<String, Object>> subList = new ArrayList<Map<String, Object>>();
if (dMap != null && dMap.get(dtlCd[1]) != null){
// sub list ์์ฑ
int sCnt = 1;
for (Map<String, Object> sMap : (List<Map<String, Object>>) dMap.get(dtlCd[1])){
Map<String, Object> sDataMap = new HashMap<String, Object>();
sDataMap.put("no", sCnt++);
// row data ์์ฑ
for (String[] sDtlCd : CoCodeManager.getValues(sCdNm)){
String[] sInf = CoCodeManager.getCodeExpString(sCdNm, sDtlCd[0]).split("\\|"); // EXP : TYPE(String, Code, Array, Object) | NAME | CD_NO
if (sInf[0].equals("String")){
sDataMap.put(sDtlCd[1], escapeSql(nvl((String)sMap.get(sDtlCd[1]))) );
}else if (sInf[0].equals("Code")){
sDataMap.put(sDtlCd[1], CoCodeManager.getCodeString(sInf[1], (String)sMap.get(sDtlCd[1])) );
}
}
subList.add(sDataMap);
}
}
sTblMap.put("subList", subList);
ret = sTblMap;
}
return ret;
}
public String escapeSql(String str){
return str == null ? "null" : String.format("%s", str.replace("'", "\\'").replace("\n", "\\n").replace("\r", "\\r").replace("\"", "\\\""));
}
} | 7,262 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiProjectServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiProjectServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.github.jsonldjava.shaded.com.google.common.reflect.TypeToken;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.common.ShellCommander;
import oss.fosslight.domain.CommentsHistory;
import oss.fosslight.domain.History;
import oss.fosslight.domain.LicenseMaster;
import oss.fosslight.domain.OssComponents;
import oss.fosslight.domain.OssComponentsLicense;
import oss.fosslight.domain.OssNotice;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.domain.UploadFile;
import oss.fosslight.repository.ApiFileMapper;
import oss.fosslight.repository.ApiOssMapper;
import oss.fosslight.repository.ApiProjectMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.service.ApiProjectService;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.FileService;
import oss.fosslight.service.HistoryService;
import oss.fosslight.service.ProjectService;
import oss.fosslight.service.ApiVulnerabilityService;
import oss.fosslight.util.ExcelUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
import oss.fosslight.util.YamlUtil;
import oss.fosslight.validation.T2CoValidationResult;
import oss.fosslight.validation.custom.T2CoProjectValidator;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
@Service
@Slf4j
public class ApiProjectServiceImpl extends CoTopComponent implements ApiProjectService {
@Autowired ApiProjectMapper apiProjectMapper;
@Autowired ProjectMapper projectMapper;
@Autowired ApiFileMapper apiFileMapper;
@Autowired FileService fileService;
@Autowired ProjectService projectService;
@Autowired CommentService commentService;
@Autowired ApiOssMapper apiOssMapper;
@Autowired ApiVulnerabilityService apiVulnerabilityService;
@Autowired HistoryService historyService;
HashMap<String, HashMap<String, Object>> OSS_INFO_UPPER = new HashMap<>();
HashMap<String, HashMap<String, Object>> OSS_INFO_BY_ID = new HashMap<>();
HashMap<String, HashMap<String, Object>> LICENSE_INFO = new HashMap<>();
HashMap<String, HashMap<String, Object>> LICENSE_INFO_UPPER = new HashMap<>();
HashMap<String, HashMap<String, Object>> LICENSE_INFO_BY_ID = new HashMap<>();
@Override
public Map<String, Object> selectProjectList(Map<String, Object> paramMap){
Map<String, Object> result = new HashMap<String, Object>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
int projectCnt = apiProjectMapper.selectProjectTotalCount(paramMap);
if (projectCnt > 0) {
list = apiProjectMapper.selectProject(paramMap);
for (Map<String, Object> map : list) {
String prjId = (String) map.get("prjId").toString();
String status = (String) map.get("status");
String distributionStatus = (String) map.get("distributionStatus");
distributionStatus = CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROCESS.equals(distributionStatus)
? CoConstDef.CD_DTL_DISTRIBUTE_STATUS_PROGRESS : distributionStatus;
String nvdMaxScore = apiProjectMapper.findIdentificationMaxNvdInfo(prjId);
map.put("DISTRIBUTION_TYPE", CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, (String) map.get("distributionType")));
map.put("NETWORK_SERVICE", (String) map.get("networkService"));
map.put("NOTICE", CoCodeManager.getCodeString(CoConstDef.CD_NOTICE_TYPE, (String) map.get("notice")));
map.put("NOTICE_PLATFORM", CoCodeManager.getCodeString(CoConstDef.CD_PLATFORM_GENERATED, (String) map.get("noticePlatform")));
map.put("PRIORITY", CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, (String) map.get("priority")));
map.put("STATUS",CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_STATUS, status));
map.put("IDENTIFICATION_STATUS", CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, (String) map.get("identificationStatus")));
map.put("VERIFICATION_STATUS", CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, (String) map.get("verificationStatus")));
map.put("DISTRIBUTION_STATUS", CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_STATUS, distributionStatus));
map.put("VULNERABILITY_SCORE", nvdMaxScore);
// map.put("MODEL_LIST", apiProjectMapper.selectModelList(prjId));
}
}
result.put("content", list);
result.put("record", projectCnt);
return result;
}
@SuppressWarnings("unchecked")
@Override
public boolean existProjectCnt(Map<String, Object> paramMap) {
String ossReportFlag = (String) paramMap.get("ossReportFlag");
List<String> prjIdList = (List<String>) paramMap.get("prjId");
if (prjIdList != null) {
if (isEmpty(ossReportFlag)) {
ossReportFlag = CoConstDef.FLAG_NO;
paramMap.put("ossReportFlag", ossReportFlag);
}
int records = apiProjectMapper.selectProjectCount(paramMap);
return records == prjIdList.size() ? true : false;
}
return false;
}
@SuppressWarnings("unchecked")
@Override
public boolean checkDistributionType(Map<String, Object> paramMap) {
List<String> prjIdList = (List<String>) paramMap.get("prjId");
int records = apiProjectMapper.checkDistributionType(paramMap);
return records == prjIdList.size() ? true : false;
}
@Override
public Map<String, Object> getSheetData(UploadFile ufile, String prjId, String readType, String[] sheet) {
return getSheetData(ufile, prjId, readType, sheet, false);
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> getSheetData(UploadFile ufile, String prjId, String readType, String[] sheet, boolean exactMatchFlag) {
Map<String, Object> result = new HashMap<String, Object>();
String errMsg = "";
List<OssComponents> reportData = new ArrayList<OssComponents>();
List<String> errMsgList = new ArrayList<>();
try {
if (!ExcelUtil.readReport(readType, true, sheet, ufile.getRegistSeq(), reportData, errMsgList, exactMatchFlag)) {
for (String s : errMsgList) { // error ์ฒ๋ฆฌ
if (isEmpty(s)) {
continue;
}
if (!isEmpty(errMsg)) {
errMsg += "<br/>";
}
errMsg += s;
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
errMsg = e.getMessage();
}
for (String s : errMsgList) {
if (isEmpty(s)) {
continue;
}
if (!isEmpty(errMsg)) {
errMsg += "<br/>";
}
errMsg += s;
}
if (isEmpty(errMsg)) {
// Excel file Data๋ฅผ duplicate Data์๋ํด mergeํ๊ณ reset & Load ํจ.
Map<String, Object> resultMap = CommonFunction.makeGridDataFromReport(null, null, null, reportData, ufile.getRegistSeq(), readType);
List<ProjectIdentification> OssComponents = (List<ProjectIdentification>) resultMap.get("mainData");
List<List<ProjectIdentification>> ossComponentsLicense = CommonFunction.setOssComponentLicense(OssComponents);
Map<String, Object> remakeComponentsMap = CommonFunction.remakeMutiLicenseComponents(OssComponents, ossComponentsLicense);
result.put("ossComponents", (List<ProjectIdentification>) remakeComponentsMap.get("mainList"));
result.put("ossComponentLicense", (List<List<ProjectIdentification>>) remakeComponentsMap.get("subList"));
} else {
result.put("errorMsg", errMsg);
}
return result;
}
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public Map<String, Object> readAndroidBuildImage(UploadFile ossReportBean, UploadFile noticeHtmlBean, UploadFile resultTxtBean){
Map<String, Object> result = new HashMap<String, Object>();
String errMsg = "";
List<OssComponents> reportData = new ArrayList<OssComponents>();
String[] sheet = new String[1];
List<String> errMsgList = new ArrayList<>();
String ossReportfileId = ossReportBean.getRegistFileId();
String resultFileId = "";
Map<String, Object> checkHeaderSheetName = new HashMap<String, Object>();
try {
if (resultTxtBean != null) {
resultFileId = resultTxtBean.getRegistFileId();
}
// 1) build image๋ฅผ ๊ธฐ์ค์ผ๋ก oss data mapping (๊ณตํต)
if (!ExcelUtil.readAndroidBuildImage("BIN (Android)", true, sheet, ossReportfileId, resultFileId, reportData, errMsgList, checkHeaderSheetName)) {
for (String s : errMsgList) { // error ์ฒ๋ฆฌ
if (isEmpty(s)) {
continue;
}
if (!isEmpty(errMsg)) {
errMsg += "<br/>";
}
errMsg += s;
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
for (String s : errMsgList) {
if (isEmpty(s)) {
continue;
}
if (!isEmpty(errMsg)) {
errMsg += "<br/>";
}
errMsg += s;
}
if (isEmpty(errMsg)) {
// result.text์ ์ํด ๋ณ๊ฒฝ๋ ๋ด์ฉ์ด ์์ ๊ฒฝ์ฐ ์ฌ์ฉ์ ํ์
// validator์์ session์ ๊ฒฉ๋ฉํ๋ค.
String resultTextChangeHisStr = "";
if (getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_ANDROID_CHANGED_RESULTTEXT, resultFileId)) != null) {
resultTextChangeHisStr = (String) getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_ANDROID_CHANGED_RESULTTEXT, resultFileId));
}
// license name์ด ๋ณ๊ฒฝ๋ ๋ด์ฉ์ด ์์ ๊ฒฝ์ฐ ์ฌ์ฉ์ ํ์
String licenseNameChangeHisStr = "";
if (getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_UPLOAD_REPORT_CHANGEDLICENSE, ossReportfileId)) != null) {
licenseNameChangeHisStr = (String) getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_UPLOAD_REPORT_CHANGEDLICENSE, ossReportfileId));
}
// notice html๊ณผ ๋น๊ต ๋ถ์
Map<String, Object> noticeCheckResultMap = null;
List<String> noticeBinaryList = null;
List<String> versionChangedList = null;
try {
String fullName = noticeHtmlBean.getFilePath() + "/" + noticeHtmlBean.getFileName();
if ("xml".equalsIgnoreCase(FilenameUtils.getExtension(noticeHtmlBean.getFileName()))) {
noticeBinaryList = CommonFunction.getAndroidNoticeBinaryXmlList(fullName);
} else {
noticeBinaryList = CommonFunction.getAndroidNoticeBinaryList(FileUtils.readFileToString(new File(fullName)));
}
Map<String, Object> convertObj = CommonFunction.convertToProjectIdentificationList(reportData, ossReportfileId);
noticeCheckResultMap = projectService.applySrcAndroidModel((List<ProjectIdentification>)convertObj.get("resultList"), noticeBinaryList);
if (convertObj.containsKey("versionChangeList")) {
versionChangedList = (List<String>) convertObj.get("versionChangeList");
}
} catch (IOException ioe) {
log.error(ioe.getMessage(), ioe);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
// validation
Map<String, Object> resultMap = CommonFunction.mergeGridAndReport(null, null,
(List<ProjectIdentification>) noticeCheckResultMap.get("reportData"), "BINADROID");
List<ProjectIdentification> OssComponents = (List<ProjectIdentification>) resultMap.get("mainData");
List<List<ProjectIdentification>> ossComponentsLicense = CommonFunction.setOssComponentLicense(OssComponents);
String systemChangeHisStr = "";
if (!isEmpty(resultTextChangeHisStr)) {
systemChangeHisStr = resultTextChangeHisStr;
}
if (!isEmpty(licenseNameChangeHisStr)) {
if (!isEmpty(systemChangeHisStr)) {
systemChangeHisStr += "<br><br>";
}
systemChangeHisStr += licenseNameChangeHisStr;
}
if (versionChangedList != null) {
String versionChangedStr = "<b>The following open source version below has been changed to a registered version</b><br><br>";
for (String s : versionChangedList) {
versionChangedStr += "<br>" + s;
}
putSessionObject(CommonFunction.makeSessionKey(loginUserName(), CoConstDef.SESSION_KEY_OSS_VERSION_CHANGED, ossReportfileId), versionChangedStr);
if (!isEmpty(systemChangeHisStr)) {
systemChangeHisStr += "<br><br>";
}
systemChangeHisStr += versionChangedStr;
}
result.put("ossComponents", OssComponents);
result.put("ossComponentLicense", ossComponentsLicense);
result.put("systemChangeHisStr", systemChangeHisStr);
} else {
result.put("errorMsg", errMsg);
}
return result;
}
@Override
public int getCreateProjectCnt(String userId) {
return apiProjectMapper.getCreateProjectCnt(userId);
}
@Transactional
@Override
public Map<String, Object> createProject(Map<String, Object> paramMap){
Map<String, Object> result = new HashMap<String, Object>();
int duplicateCnt = apiProjectMapper.checkProject(paramMap);
if (duplicateCnt == 0) {
apiProjectMapper.createProject(paramMap);
result.put("prjId", (String) paramMap.get("prjId").toString());
OssNotice noticeParam = new OssNotice();
noticeParam.setPrjId((String) paramMap.get("prjId").toString());
noticeParam.setNoticeType(CoConstDef.CD_DTL_NOTICE_TYPE_GENERAL);
projectMapper.makeOssNotice(noticeParam);
}
return result;
}
@Transactional
@Override
public int makeOssNotice(Map<String, Object> paramMap){
return apiProjectMapper.makeOssNotice(paramMap);
}
@SuppressWarnings("unchecked")
@Override
public List<Map<String, Object>> getBomList(String prjId){
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(prjId);
identification.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
identification.setMerge("N");
Map<String, Object> map = projectService.getIdentificationGridList(identification, true);
T2CoProjectValidator pv = new T2CoProjectValidator();
map.replace("rows", projectService.setMergeGridData((List<ProjectIdentification>) map.get("rows")));
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_BOM_MERGE);
pv.setAppendix("bomList", (List<ProjectIdentification>) map.get("rows"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
map.replace("rows", CommonFunction.identificationSortByValidInfo((List<ProjectIdentification>) map.get("rows"), vr.getValidMessageMap(), vr.getDiffMessageMap(), vr.getInfoMessageMap(), false, true));
List<ProjectIdentification> bomList = (List<ProjectIdentification>) map.get("rows");
List<Map<String, Object>> gridDataList = new ArrayList<>();
for (ProjectIdentification gridData : bomList) {
Map<String, Object> gridMap = new HashMap<>();
gridMap.put("ossName", avoidNull(gridData.getOssName()));
gridMap.put("ossVersion", avoidNull(gridData.getOssVersion()));
gridMap.put("licenseType", avoidNull(gridData.getLicenseType()));
gridMap.put("licenseName", avoidNull(gridData.getLicenseName()));
gridDataList.add(gridMap);
}
return gridDataList;
}
@Override
public List<Map<String, Object>> setMergeGridData(List<Map<String, Object>> list) {
List<Map<String, Object>> tempData = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> resultGridData = new ArrayList<Map<String, Object>>();
String groupColumn = "";
boolean ossNameEmptyFlag = false;
for (Map<String, Object> li : list) {
String ossName = (String) li.get("ossName");
String ossVersion = (String) li.get("ossVersion");
String licenseType = (String) li.get("licenseType");
if (isEmpty(groupColumn)) {
groupColumn = ossName + "-" + ossVersion;
}
if ("-".equals(groupColumn)) {
if ("NA".equals(licenseType)) {
ossNameEmptyFlag = true;
}
}
if (groupColumn.equals(ossName + "-" + ossVersion) // ๊ฐ์ groupColumn์ด๋ฉด ๋ฐ์ดํฐ๋ฅผ ์์
&& !("-".equals(ossName)
&& !"NA".equals(licenseType))
&& !ossNameEmptyFlag) { // ๋จ, OSS Name: - ์ด๋ฉด์, License Type: Proprietary์ด ์๋ ๊ฒฝ์ฐ Row๋ฅผ ํฉ์น์ง ์์.
tempData.add(li);
} else { // ๋ค๋ฅธ grouping
setMergeData(tempData, resultGridData);
groupColumn = ossName + "-" + ossVersion;
tempData.clear();
tempData.add(li);
}
ossNameEmptyFlag = false;
}
setMergeData(tempData, resultGridData); // bom data์ loop๊ฐ ๋๋ฌ์ง๋ง tempData์ ๊ฐ์ด ์๋ค๋ฉด ํด๋น ๊ฐ๋ merge๋ฅผ ํจ.
return resultGridData;
}
@SuppressWarnings("unchecked")
public static void setMergeData(List<Map<String, Object>> tempData, List<Map<String, Object>> resultGridData){
if (tempData.size() > 0) {
Collections.sort(tempData, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
if (((String) o1.get("licenseName")).length() >= ((String) o2.get("licenseName")).length()) { // license name์ด ๊ฐ์ผ๋ฉด bomList์กฐํํด์จ ์์ ๊ทธ๋๋ก ์ ์งํจ. license name์ด ๋ค๋ฅด๋ฉด ์์๋ณ๊ฒฝ
return 1;
}else {
return -1;
}
}
});
Map<String, Object> rtnBean = null;
for (Map<String, Object> temp : tempData) {
if (rtnBean == null) {
rtnBean = temp;
continue;
}
String tempLicenseName = (String) temp.get("licenseName");
String rtnLicenseName = (String) rtnBean.get("licenseName");
String key = (String) temp.get("ossName") + "-" + (String) temp.get("licenseType");
if ("--NA".equals(key)) {
if (!rtnLicenseName.contains(tempLicenseName)) {
resultGridData.add(rtnBean);
rtnBean = temp;
continue;
}
}
// ๋์ผํ oss name๊ณผ version์ผ ๊ฒฝ์ฐ license ์ ๋ณด๋ฅผ ์ค๋ณต์ ๊ฑฐํ์ฌ merge ํจ.
for (String tempStr : tempLicenseName.split(",")) {
boolean equalFlag = false;
for (String rtnStr : rtnLicenseName.split(",")) {
if (rtnStr.equals(tempStr)) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
rtnBean.replace("licenseName", rtnLicenseName + "," + tempStr);
}
}
if (temp.containsKey("ossComponentsLicenseList") && rtnBean.containsKey("ossComponentsLicenseList")) {
List<Map<String, Object>> rtnComponentLicenseList = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> tempOssComponentsLicenseList = (List<Map<String, Object>>) temp.get("ossComponentsLicenseList");
List<Map<String, Object>> rtnOssComponentsLicenseList = (List<Map<String, Object>>) rtnBean.get("ossComponentsLicenseList");
if (tempOssComponentsLicenseList != null) {
for (Map<String, Object> list : tempOssComponentsLicenseList) {
int equalsItemList = (int) rtnOssComponentsLicenseList
.stream()
.filter(e -> ((String) list.get("licenseName")).equals((String) e.get("licenseName"))) // ๋์ผํ licenseName์ filter
.collect(Collectors.toList()) // return์ list๋ก๋ณํ
.size(); // ํด๋น list์ size
if (equalsItemList == 0) {
rtnComponentLicenseList.add(list);
}
}
rtnOssComponentsLicenseList.addAll(rtnComponentLicenseList);
}
}
}
resultGridData.add(rtnBean);
}
}
public Map<String, Object> selectVerificationCheck(String prjId){
return apiProjectMapper.selectVerificationCheck(prjId);
}
public boolean updatePackageFile(Map<String, Object> paramMap) {
return apiProjectMapper.updatePackageFile(paramMap) > 0;
}
// Json Format: Yaml Format + Vulnerability
@Override
public Map<String, Object> getBomExportJson(String prjId) {
// Get Yaml Format
String type = CoConstDef.CD_DTL_COMPONENT_ID_BOM;
Project project = new Project();
project.setPrjId(prjId);
String dataStr = toJson(project);
Type projectType = new TypeToken<Project>(){}.getType();
Project projectBean = (Project) fromJson(dataStr, projectType);
ProjectIdentification _param = new ProjectIdentification();
_param.setReferenceDiv(type);
_param.setReferenceId(projectBean.getPrjId());
_param.setMerge(CoConstDef.FLAG_NO);
Map<String, Object> map = projectService.getIdentificationGridList(_param, true);
List<ProjectIdentification> list = (List<ProjectIdentification>) map.get("rows");
LinkedHashMap<String, List<Map<String, Object>>> resultYamlFormat = YamlUtil.checkYamlFormat(projectService.setMergeGridData(list), type);
Map<String, Object> resultMap = new HashMap<String, Object>();
// Integrate Yaml Format, Vulnerability
for (String resultYamlFormatKey: resultYamlFormat.keySet()){
List<Map<String, Object>> yamlFormatList = resultYamlFormat.get(resultYamlFormatKey);
for (Map<String, Object> yamlFormatMap: yamlFormatList) {
String version = (String) yamlFormatMap.get("version");
List<Map<String, Object>> maxScoreNvdInfoList = apiVulnerabilityService.selectMaxScoreNvdInfo(resultYamlFormatKey, version);
if (!maxScoreNvdInfoList.isEmpty()) {
Map<String, Object> maxScoreNvdInfoMap = apiVulnerabilityService.selectMaxScoreNvdInfo(resultYamlFormatKey, version).get(0);
yamlFormatMap.put("Vulnerability", maxScoreNvdInfoMap.get("cvssScore"));
}
}
resultMap.put(resultYamlFormatKey, yamlFormatList);
}
return resultMap;
}
@Override
public Map<String, Object> getBomCompare(List<Map<String, Object>> beforeBomList, List<Map<String, Object>> afterBomList){
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String, Object> addList = new HashMap<String, Object>();
Map<String, Object> deleteList = new HashMap<String, Object>();
Map<String, Object> changeList = new HashMap<String, Object>();
List<Map<String, Object>> filteredBeforeBomList = beforeBomList
.stream()
.filter(bfList -> afterBomList
.stream()
.filter(afList ->
((String) bfList.get("ossName") + "||" + (String) bfList.get("ossVersion") + "||" + getLicenseNameSort(((String) bfList.get("licenseName")).trim()))
.equalsIgnoreCase((String) afList.get("ossName") + "||" + (String) afList.get("ossVersion") + "||" + getLicenseNameSort(((String) afList.get("licenseName")).trim()))
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
filteredBeforeBomList = filteredBeforeBomList.stream().filter(e -> !isEmpty((String) e.get("ossName")) && !((String) e.get("ossName")).equals("-")).collect(Collectors.toList());
List<String> filteredBeforeOssNameList = filteredBeforeBomList.stream().map(e -> (String) e.get("ossName")).collect(Collectors.toList());
List<Map<String, Object>> filteredAfterBomList = afterBomList
.stream()
.filter(afList -> beforeBomList
.stream()
.filter(bfList ->
((String) afList.get("ossName") + "||" + (String) afList.get("ossVersion") + "||" + getLicenseNameSort(((String) afList.get("licenseName")).trim()))
.equalsIgnoreCase((String) bfList.get("ossName") + "||" + (String) bfList.get("ossVersion") + "||" + getLicenseNameSort(((String) bfList.get("licenseName")).trim()))
).collect(Collectors.toList()).size() == 0
).collect(Collectors.toList());
filteredAfterBomList = filteredAfterBomList.stream().filter(e -> !isEmpty((String) e.get("ossName")) && !((String) e.get("ossName")).equals("-")).collect(Collectors.toList());
List<String> filteredAfterOssNameList = filteredAfterBomList.stream().map(e -> (String) e.get("ossName")).collect(Collectors.toList());
// status > add
for (Map<String, Object> after : filteredAfterBomList) {
String ossName = (String) after.get("ossName");
if (!filteredBeforeOssNameList.contains(ossName)) {
Map<String, Object> addMap = new LinkedHashMap<String, Object>();
addMap.put("name", (String) after.get("ossName"));
addMap.put("version", avoidNull((String) after.get("ossVersion"), ""));
addMap.put("license", Arrays.asList(((String) after.get("licenseName")).split(",")));
addList.put(getCompareKey(after), addMap);
}
}
// status > delete
for (Map<String, Object> before : filteredBeforeBomList) {
String ossName = (String) before.get("ossName");
if (!filteredAfterOssNameList.contains(ossName)) {
Map<String, Object> deleteMap = new LinkedHashMap<String, Object>();
deleteMap.put("name", ossName);
deleteMap.put("version", avoidNull((String) before.get("ossVersion"), ""));
deleteMap.put("license", Arrays.asList(((String) before.get("licenseName")).split(",")));
deleteList.put(getCompareKey(before), deleteMap);
}
}
// status > change
if (!filteredBeforeBomList.isEmpty() && !filteredAfterBomList.isEmpty()) {
List<Map<String, Object>> deduplicatedBeforeBomList = new ArrayList<>();
List<Map<String, Object>> deduplicatedAfterBomList = new ArrayList<>();
boolean firstFlag = true;
boolean deduplicateFlag = false;
for (Map<String, Object> filteredBeforeBom : filteredBeforeBomList) {
String ossName = (String) filteredBeforeBom.get("ossName");
String ossVersion = (String) filteredBeforeBom.get("ossVersion");
String licenseName = (String) filteredBeforeBom.get("licenseName");
if (firstFlag) {
List<Map<String, Object>> addBeforeBomList = new ArrayList<>();
Map<String, Object> addBeforeBom = new LinkedHashMap<>();
Map<String, Object> addBeforeBom2 = new HashMap<>();
addBeforeBom.put("version", ossVersion);
addBeforeBom.put("license", Arrays.asList(licenseName.trim().split(",")));
addBeforeBomList.add(addBeforeBom);
addBeforeBom2.put(ossName, addBeforeBomList);
deduplicatedBeforeBomList.add(addBeforeBom2);
firstFlag = false;
} else {
for (Map<String, Object> deduplicatedBeforeBom : deduplicatedBeforeBomList) {
if (deduplicatedBeforeBom.containsKey(ossName)) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> orgValues = (List<Map<String, Object>>) deduplicatedBeforeBom.get(ossName);
Map<String, Object> addBeforeBom = new LinkedHashMap<>();
addBeforeBom.put("version", ossVersion);
addBeforeBom.put("license", Arrays.asList(licenseName.trim().split(",")));
orgValues.add(addBeforeBom);
deduplicatedBeforeBom.replace(ossName, orgValues);
deduplicateFlag = true;
}
}
if (!deduplicateFlag) {
List<Map<String, Object>> addBeforeBomList = new ArrayList<>();
Map<String, Object> addBeforeBom = new LinkedHashMap<>();
Map<String, Object> addBeforeBom2 = new HashMap<>();
addBeforeBom.put("version", ossVersion);
addBeforeBom.put("license", Arrays.asList(licenseName.trim().split(",")));
addBeforeBomList.add(addBeforeBom);
addBeforeBom2.put(ossName, addBeforeBomList);
deduplicatedBeforeBomList.add(addBeforeBom2);
}
deduplicateFlag = false;
}
}
for (Map<String, Object> filteredAfterBom : filteredAfterBomList) {
String ossName = (String) filteredAfterBom.get("ossName");
String ossVersion = (String) filteredAfterBom.get("ossVersion");
String licenseName = (String) filteredAfterBom.get("licenseName");
if (firstFlag) {
List<Map<String, Object>> addAfterBomList = new ArrayList<>();
Map<String, Object> addAfterBom = new LinkedHashMap<>();
Map<String, Object> addAfterBom2 = new HashMap<>();
addAfterBom.put("version", ossVersion);
addAfterBom.put("license", Arrays.asList(licenseName.trim().split(",")));
addAfterBomList.add(addAfterBom);
addAfterBom2.put(ossName, addAfterBomList);
deduplicatedAfterBomList.add(addAfterBom2);
firstFlag = false;
} else {
for (Map<String, Object> deduplicatedAfterBom : deduplicatedAfterBomList) {
if (deduplicatedAfterBom.containsKey(ossName)) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> orgValues = (List<Map<String, Object>>) deduplicatedAfterBom.get(ossName);
Map<String, Object> addBeforeBom = new LinkedHashMap<>();
addBeforeBom.put("version", ossVersion);
addBeforeBom.put("license", Arrays.asList(licenseName.trim().split(",")));
orgValues.add(addBeforeBom);
deduplicatedAfterBom.replace(ossName, orgValues);
deduplicateFlag = true;
}
}
if (!deduplicateFlag) {
List<Map<String, Object>> addAfterBomList = new ArrayList<>();
Map<String, Object> addAfterBom = new LinkedHashMap<>();
Map<String, Object> addAfterBom2 = new HashMap<>();
addAfterBom.put("version", ossVersion);
addAfterBom.put("license", Arrays.asList(licenseName.trim().split(",")));
addAfterBomList.add(addAfterBom);
addAfterBom2.put(ossName, addAfterBomList);
deduplicatedAfterBomList.add(addAfterBom2);
}
deduplicateFlag = false;
}
}
for (Map<String, Object> deduplicatedBeforeBom : deduplicatedBeforeBomList) {
for (String beforeKey : deduplicatedBeforeBom.keySet()) {
for (Map<String, Object> deduplicatedAfterBom : deduplicatedAfterBomList) {
for (String afterKey : deduplicatedAfterBom.keySet()) {
if (beforeKey.equalsIgnoreCase(afterKey)) {
Map<String, Object> changeMap = new LinkedHashMap<String, Object>();
changeMap.put("name", afterKey);
changeMap.put("prev", deduplicatedBeforeBom.get(beforeKey));
changeMap.put("now", deduplicatedAfterBom.get(afterKey));
changeList.put(afterKey, changeMap);
break;
}
}
}
}
}
}
// add, delete, change๊ฐ ๊ฐ์ด์์ผ๋ฉด ์์ ์ผ์นํ project๋ก ํ๋จ.
resultMap.put("add", addList.values());
resultMap.put("delete", deleteList.values());
resultMap.put("change", changeList.values());
return resultMap;
}
private String getLicenseNameSort(String licenseName) {
String sortedValue = "";
String splitLicenseNm[] = licenseName.trim().split(",");
Arrays.sort(splitLicenseNm);
for (int i=0; i< splitLicenseNm.length; i++) {
sortedValue += splitLicenseNm[i];
if (i<splitLicenseNm.length-1) {
sortedValue += ", ";
}
}
return sortedValue;
}
@Override
public Map<String, Object> selectModelList(Map<String, Object> paramMap){
Map<String, Object> result = new HashMap<String, Object>();
List<Map<String, Object>> list = apiProjectMapper.selectProject(paramMap);
List<Map<String, Object>> contents = new ArrayList<Map<String, Object>>();
for (Map<String, Object> map : list) {
Map<String, Object> modelMap = new HashMap<String, Object>();
String prjId = (String) map.get("prjId").toString();
List<Map<String, Object>> modelList = apiProjectMapper.selectModelList(prjId);
modelMap.put("prjId", prjId);
modelMap.put("modelList", modelList);
contents.add(modelMap);
}
result.put("records", list.size());
result.put("contents", contents);
return result;
}
private String getCompareKey(Map<String, Object> paramMap) {
return (((String) paramMap.get("ossName")) + "|" + avoidNull((String) paramMap.get("ossVersion"), "") + "|" + (String) paramMap.get("licenseName")).toLowerCase();
}
@Override
public List<Map<String, Object>> getVerifyOssList(Map<String, Object> project) {
List<Map<String, Object>> verifyFilePathList = apiProjectMapper.selectVerifyOssList(project);
if (verifyFilePathList != null && !verifyFilePathList.isEmpty() && verifyFilePathList.get(0) == null) {
verifyFilePathList = new ArrayList<>();
}
return verifyFilePathList;
}
@Override
public List<Map<String, Object>> serMergeGridData(List<Map<String, Object>> gridData) {
List<Map<String, Object>> tempData = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> resultGridData = new ArrayList<Map<String, Object>>();
boolean ossNameEmptyFlag = false;
String groupColumn = "";
final Comparator<Map<String, Object>> comp = Comparator.comparing((Map<String, Object> o) -> o.get("ossName")+"|"+ o.get("ossVersion"));
gridData = gridData.stream().sorted(comp).collect(Collectors.toList());
for (Map<String, Object> info : gridData) {
String ossName = (String) info.get("ossName");
String ossVersion = (String) info.get("ossVersion");
String licenseType = (String) info.get("licenseType");
if (isEmpty(groupColumn)) {
groupColumn = ossName + "-" + ossVersion;
}
if ("-".equals(groupColumn)) {
if ("NA".equals(licenseType)) {
ossNameEmptyFlag = true;
}
}
if (groupColumn.equals(ossName + "-" + ossVersion) // ๊ฐ์ groupColumn์ด๋ฉด ๋ฐ์ดํฐ๋ฅผ ์์
&& !("-".equals(ossName)
&& !"NA".equals(licenseType))
&& !ossNameEmptyFlag) { // ๋จ, OSS Name: - ์ด๋ฉด์, License Type: Proprietary์ด ์๋ ๊ฒฝ์ฐ Row๋ฅผ ํฉ์น์ง ์์.
tempData.add(info);
} else { // ๋ค๋ฅธ grouping
setVerifyMergeData(tempData, resultGridData);
groupColumn = ossName + "-" + ossVersion;
tempData.clear();
tempData.add(info);
}
ossNameEmptyFlag = false;
}
setVerifyMergeData(tempData, resultGridData);
return resultGridData;
}
private void setVerifyMergeData(List<Map<String, Object>> tempData, List<Map<String, Object>> resultGridData) {
if (tempData.size() > 0) {
Collections.sort(tempData, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
if (((String) o1.get("licenseName")).length() >= ((String) o2.get("licenseName")).length()) {
return 1;
}else {
return -1;
}
}
});
Map<String, Object> rtnBean = null;
for (Map<String, Object> temp : tempData) {
if (rtnBean == null) {
rtnBean = temp;
continue;
}
String ossName = (String) temp.get("ossName");
String licenseType = (String) temp.get("licenseType");
String licenseNameTemp = (String) temp.get("licenseName");
String licenseNameBean = (String) rtnBean.get("licenseName");
String key = ossName + "-" + licenseType;
if ("--NA".equals(key)) {
if (!licenseNameBean.contains(licenseNameTemp)) {
resultGridData.add(rtnBean);
rtnBean = temp;
continue;
}
}
for (String licenseName : licenseNameTemp.split(",")) {
boolean equalFlag = false;
for (String rtnLicenseName : licenseNameBean.split(",")) {
if (rtnLicenseName.equals(licenseName)) {
equalFlag = true;
break;
}
}
if (!equalFlag) {
rtnBean.put("licenseName", licenseNameBean + "," + licenseName);
}
}
}
resultGridData.add(rtnBean);
}
}
@SuppressWarnings("unchecked")
@Override
public String setClearFiles(Map<String, Object> map) {
String deleteComment = "";
String uploadComment = "";
String prjId = (String) map.get("prjId");
List<String> fileSeqs = (List<String>)map.get("fileSeqs");
List<Map<String, Object>> uploadFileInfos = new ArrayList<>();
File file = null;
Map<String, Object> prjParam = new HashMap<String, Object>();
prjParam.put("prjId", prjId);
ArrayList<String> newPackagingFileIdList = new ArrayList<String>();
newPackagingFileIdList.add(fileSeqs.size() > 0 ? fileSeqs.get(0) : null);
newPackagingFileIdList.add(fileSeqs.size() > 1 ? fileSeqs.get(1) : null);
newPackagingFileIdList.add(fileSeqs.size() > 2 ? fileSeqs.get(2) : null);
prjParam.put("packageFileId", newPackagingFileIdList.get(0));
prjParam.put("packageFileId2", newPackagingFileIdList.get(1));
prjParam.put("packageFileId3", newPackagingFileIdList.get(2));
for (String fileSeq : fileSeqs){
Map<String, Object> paramT2File = new HashMap<>();
paramT2File.put("fileSeq", fileSeq);
uploadFileInfos.add(apiFileMapper.getFileInfo(paramT2File));
}
String publicUrl = appEnv.getProperty("upload.path", "/upload");
String packagingUrl = appEnv.getProperty("packaging.path", "/upload/packaging") + "/" + prjId;
List<Map<String, Object>> result = apiFileMapper.selectPackagingFileInfo(prjId); // verifyํ file์ selectํจ.
if (result.size() > 0){
for (Map<String, Object> res : result){
String rtnFilePath = (String) res.get("logiPath");
String rtnFileName = (String) res.get("logiNm");
String rtnFileSeq = Integer.toString((int) res.get("fileSeq"));
if (publicUrl.equals(rtnFilePath)){
// selectํ filePath๊ฐ upload Dir ์ผ ๊ฒฝ์ฐ ํด๋น ํ์ผ๋ง ์ญ์ ํจ.
file = new File(rtnFilePath + "/" + rtnFileName);
int reuseCnt = apiFileMapper.getPackgingReuseCnt(rtnFileName);
if (reuseCnt == 0){
Map<String, Object> delFile = new HashMap<>();
delFile.put("fileSeq", rtnFileSeq);
delFile.put("gubn", "A");
int returnSuccess = apiFileMapper.updateFileDelYnKessan(delFile);
if (returnSuccess > 0) {
if (file.delete()){
log.debug(rtnFilePath + "/" + rtnFileName + " is delete success.");
} else {
log.debug(rtnFilePath + "/" + rtnFileName + " is delete failed.");
}
}
}
}
}
deleteFiles(packagingUrl, uploadFileInfos, prjId); // 'upload/packaging/#{prjId}' ์ Directory๊ฐ ์๋์ง ์ฒดํฌ ํ ์ญ์ ์ฒ๋ฆฌํจ.( ํ์ฌ๋ฑ๋กํ file์ ์ ์ธํ ๋๋จธ์ง๋ฅผ ์ญ์ธ์ฒ๋ฆฌ )
} else {
deleteFiles(packagingUrl, uploadFileInfos, prjId); // verify ํ file์ด ์์๊ฒฝ์ฐ packagingUrl๋ ๊ฐ์ด ๊ฒ์ฌํ์ฌ delete๋ฅผ ํจ.
}
// packaging File comment
try {
Map<String, Object> project = apiProjectMapper.selectProjectMaster(prjParam);
ArrayList<String> origPackagingFileIdList = new ArrayList<String>();
if (project.containsKey("packageFileId")) {
if (project.get("packageFileId") != null && !("").equals(Integer.toString((int) project.get("packageFileId")))){
origPackagingFileIdList.add(Integer.toString((int) project.get("packageFileId")));
}
}
if (project.containsKey("packageFileId2")) {
if (project.get("packageFileId2") != null && !("").equals(Integer.toString((int) project.get("packageFileId2")))){
origPackagingFileIdList.add(Integer.toString((int) project.get("packageFileId2")));
}
}
if (project.containsKey("packageFileId3")) {
if (project.get("packageFileId3") != null && !("").equals(Integer.toString((int) project.get("packageFileId3")))){
origPackagingFileIdList.add(Integer.toString((int) project.get("packageFileId3")));
}
}
int idx = 0;
for (String fileId : origPackagingFileIdList){
Map<String, Object> fileInfo = new HashMap<>();
if (!isEmpty(fileId) && !fileId.equals(newPackagingFileIdList.get(idx))){
//fileInfo.setFileSeq(fileId);
fileInfo = apiFileMapper.selectFileInfo(fileId);
deleteComment += "Packaging file, "+ (String) fileInfo.get("origNm") +", was deleted by "+loginUserName()+". <br>";
}
if (!isEmpty(newPackagingFileIdList.get(idx)) && !newPackagingFileIdList.get(idx).equals(fileId)){
//fileInfo.setFileSeq(newPackagingFileIdList.get(idx));
fileInfo = apiFileMapper.selectFileInfo(newPackagingFileIdList.get(idx));
oss.fosslight.domain.File resultFile = (oss.fosslight.domain.File) apiProjectMapper.selectVerificationFile(newPackagingFileIdList.get(idx));
if (CoConstDef.FLAG_YES.equals(resultFile.getReuseFlag())){
uploadComment += "Packaging file, "+ (String) fileInfo.get("origNm")+", was loaded from Project ID: "+resultFile.getRefPrjId()+" by "+loginUserName()+". <br>";
} else {
uploadComment += "Packaging file, "+ (String) fileInfo.get("origNm")+", was uploaded by "+loginUserName()+". <br>";
}
}
idx++;
}
} catch (Exception e) {
log.error(e.getMessage());
}
apiProjectMapper.updatePackagingReuseMap(prjParam);
return deleteComment + uploadComment;
}
private void deleteFiles(String url, List<Map<String, Object>> uploadFileInfos, String prjId) {
File file = new File(url);
ArrayList<String> LogiNms = new ArrayList<String>();
ArrayList<String> reuseNms = new ArrayList<String>();
for (Map<String, Object> uploadFileInfo : uploadFileInfos){
LogiNms.add((String) uploadFileInfo.get("logiNm"));
}
// ํ์ฌ proejct Packaging File ์ค ์ฌ์ฌ์ฉ์ค์ธ packaging File ์ด ์๋ค๋ฉด ์ ๊ฑฐ ๋ถ๊ฐ
List<Map<String, Object>> reusePackaging = apiFileMapper.getReusePackagingInfo();
for (Map<String, Object> reuse : reusePackaging){
reuseNms.add((String) reuse.get("logiNm"));
}
if (file.exists()){
for (File f : file.listFiles()){
String fileNm = f.getName();
if (!LogiNms.contains(fileNm)){
Map<String, Object> delFile = new HashMap<String, Object>();
delFile.put("logiPath", url);
delFile.put("logiNm", f.getName());
int returnSuccess = apiFileMapper.updateReuseChkFileDelYnByFilePathNm(delFile);
if (returnSuccess > 0 && !reuseNms.contains(fileNm)){
if (f.delete()){
log.debug(url + "/" + f.getName() + " is delete success.");
}else{
log.debug(url + "/" + f.getName() + " is delete failed.");
}
}
}
}
}
// ์ฌ์ฌ์ฉ์ ํ์๋ file์ค ๋ค๋ฅธ project์์๋ ์ฌ์ฌ์ฉ์ ํ์ง ์์ file ์๋์ง ํ์ธํ๊ณ ์ฌ์ฌ์ฉ์ ์ํ๋ค๋ฉด file ์ญ์ / ์ถํ reuseํ๋ ๋ค๋ฅธ project์์๋ reuseFlag๊ฐ N์ด ๋๋ฉด ์ง์ฐ๋ case์ด๋ฏ๋ก log๋ ๋จ๊ธฐ์ง ์์.
List<Map<String, Object>> reusePackagingFileList = apiFileMapper.getPackgingReuseCntToList(prjId);
for (Map<String, Object> reusePackagingFile : reusePackagingFileList){ // reuseCnt๊ฐ 0์ธ ๊ฐ๋ง ๋ถ๋ฌ์ค๊ณ ์ญ์ ์ฒ๋ฆฌ ํ hidden flag๋ฅผ Y๋ก ๋ณ๊ฒฝ ๊ทธ๋ฆฌ๊ณ ์ฌ๊ฒ์์ ์กฐํ ๋ถ๊ฐ์ํ๋ก ๋ง๋ฆ.
File reuseFile = new File((String) reusePackagingFile.get("logiPath"));
if (reuseFile.exists()){
for (File f : reuseFile.listFiles()){
if (((String) reusePackagingFile.get("logiNm")).equals(f.getName())){
Map<String, Object> delFile = new HashMap<>();
delFile.put("logiPath", reusePackagingFile.get("logiPath"));
delFile.put("logiNm", f.getName());
int returnSuccess = apiFileMapper.updateFileDelYnByFilePathNm(delFile);
String[] refPrjIds = ((String) reusePackagingFile.get("logiPath")).split("/");
String refPrjId = refPrjIds[refPrjIds.length-1];
String logiPath = (String) reusePackagingFile.get("logiPath");
String logiNm = f.getName();
apiFileMapper.setReusePackagingFileHidden(refPrjId, logiPath, logiNm);
if (returnSuccess > 0){
if (f.delete()){
log.debug(url + "/" + f.getName() + " is delete success.");
}else{
log.debug(url + "/" + f.getName() + " is delete failed.");
}
}
}
}
}
}
}
@Override
public boolean getChangedPackageFile(String prjId, List<String> fileSeqs) {
String packageFileId = fileSeqs.get(0);
String packageFileId2 = fileSeqs.size() > 1 ? fileSeqs.get(1) : null;
String packageFileId3 = fileSeqs.size() > 2 ? fileSeqs.get(2) : null;
int result = apiProjectMapper.checkPackagingFileId(prjId, packageFileId, packageFileId2, packageFileId3);
if (result > 0){
return false;
}else{
return true;
}
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> processVerification(Map<String, Object> map, Map<String, Object> file, Map<String, Object> project) {
String VERIFY_HOME_PATH = CommonFunction.emptyCheckProperty("verify.home.path", "/verify");
String VERIFY_BIN_PATH = CommonFunction.emptyCheckProperty("verify.bin.path", "/verify");
String VERIFY_PATH_OUTPUT = CommonFunction.emptyCheckProperty("verify.output.path", "/verify/output");
String VERIFY_PATH_DECOMP = CommonFunction.emptyCheckProperty("verify.decompress.path", "/verify/decompression");
HashMap<String, Object> resMap = new HashMap<>();
String resCd = "00";
String resMsg = "";
log.info("[API] VERIFY START PROJECT ID : " + (String)map.get("prjId"));
int allFileCount = 0;
String[] result = null;
String readmePath = "";
String exceptFileContent = "";
String prjId = (String)map.get("prjId");
String fileSeq = (String)map.get("fileSeq");
int packagingFileIdx = (int)map.get("packagingFileIdx");
List<String> fileSeqs = (List<String>)map.get("fileSeqs");
String filePath = "";
List<String> gridFilePaths = (List<String>)map.get("gridFilePaths");
List<String> gridComponentIds = (List<String>)map.get("gridComponentIds");
boolean isChangedPackageFile = (boolean)map.get("isChangedPackageFile");
String packagingComment = (String)map.get("packagingComment");
List<String> checkExceptionWordsList = CoCodeManager.getCodeNames(CoConstDef.CD_VERIFY_EXCEPTION_WORDS);
List<String> checkExceptionIgnoreWorksList = CoCodeManager.getCodeNames(CoConstDef.CD_VERIFY_IGNORE_WORDS);
Map<String, Object> prjInfo = null;
boolean doUpdate = true;
try {
// ํ๋ก์ ํธ ์ ๋ณด ์ทจ๋ (verification status ์ ๋ฐ๋ผ DB update ์ฌ๋ถ๋ฅผ ๊ฒฐ์
{
prjInfo = getProjectBasicInfo(prjId);
if (prjInfo != null && CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals((String) prjInfo.get("verificationStatus"))) {
doUpdate = false;
}
}
File chk_list_file = new File(VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list_"+packagingFileIdx);
if (!chk_list_file.exists()) {
isChangedPackageFile = true;
}
file.put("fileSeq" ,fileSeq);
file = apiFileMapper.getFileInfo(file);
filePath = (String) file.get("logiPath") + "/" + (String) file.get("logiNm");
log.debug("[API] VERIFY TARGET FILE : " + filePath);
if (packagingFileIdx == 1 && isChangedPackageFile) {
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "find " + VERIFY_PATH_OUTPUT + " -maxdepth 1 -name "+prjId+" -type d -exec rm -rf {} \\;"});
}
String exceptionWordsPatten = "proprietary\\|commercial";
if (checkExceptionWordsList != null && !checkExceptionWordsList.isEmpty()) {
exceptionWordsPatten = "";
for (String s : checkExceptionWordsList) {
if (!isEmpty(exceptionWordsPatten)) {
exceptionWordsPatten += "\\|";
}
exceptionWordsPatten += s;
}
}
log.info("[API] VERIFY prjName : " + prjInfo.get("prjName"));
log.info("[API] VERIFY OrigNm : " + file.get("origNm"));
String projectNm = ((String) prjInfo.get("prjName")).replace(" ", "@@");
if (prjInfo.containsKey("prjVersion") && prjInfo.get("prjVersion") != null && !("").equals((String) prjInfo.get("prjVersion"))){
projectNm +="_"+((String) prjInfo.get("prjVersion")).replace(" ", "@@");
}
projectNm +="_"+Integer.toString(packagingFileIdx)+"("+((String) file.get("origNm")).replace(" ", "@@")+")";
String commandStr = VERIFY_BIN_PATH+"/verify "+filePath+" "+prjId+" "+exceptionWordsPatten+" "+projectNm+" "+packagingFileIdx+" "+VERIFY_HOME_PATH;
log.info("[API] VERIFY COMMAND : " + commandStr);
log.info("[API] VERIFY START : " + prjId);
if (isChangedPackageFile){ // packageFile์ ๋ณ๊ฒฝํ์ง ์๊ณ ๋ค์ verifyํ ๊ฒฝ์ฐ ์๋ shellCommander๋ ์ค๋ณต ๋์ ํ์ง ์์.
ShellCommander.shellCommandWaitFor(commandStr);
}
log.info("[API] VERIFY END : " + prjId);
//STEP 2 : Verify ์งํํ ํน์ ์์น์ ํ์ผ๋ฆฌ์คํธ ์ถ๋ ฅ
//STEP 3 : ๊ฒฐ๊ณผ ๋ฌธ์์ด ๋ฆฌ์คํธ๊ฐ์ ๋ฐฐ์ด๋ก ๋ณํ
String chk_list_file_path = null;
if (packagingFileIdx == 1) {
chk_list_file_path = VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list_1";
} else {
chk_list_file_path = VERIFY_PATH_OUTPUT+"/"+prjId+"/verify_chk_list";
}
String verify_chk_list = CommonFunction.getStringFromFile(chk_list_file_path).replaceAll(VERIFY_PATH_DECOMP +"/"+ prjId + "/", "");
log.info("[API] VERIFY Read verify_chk_list END : " + prjId);
result = verify_chk_list.split(System.lineSeparator());
allFileCount = StringUtils.countMatches(verify_chk_list, "*");
// ์์ถ ํด์ ํ ๋๋ ํ ๋ฆฌ๋ฅผ ํฌํจํ์ฌ ์ํธ๋น๊ต ํ๊ธฐ ์ํด ์ ์ธํ ๋๋ ํ ๋ฆฌ ๋ช
์ถ์ถ
// ๋๋ฒ์งธ ๋๋ ํ ๋ฆฌ ๊น์ง ์นํํ ๋ฌธ์์ด ์ถ์ถ
log.debug("[API] file.getOrigNm() : " + file.get("origNm"));
log.debug("[API] file.getExt() : " + file.get("ext"));
String tempFileOrgName = (String) file.get("origNm");
String tempFileOrgExt = (String) file.get("ext");
log.debug("[API] lastIndexOf(file.getExt()) : " + tempFileOrgName.lastIndexOf(tempFileOrgExt));
String rePath = FilenameUtils.removeExtension(tempFileOrgName);
log.debug("[API] rePath : " + rePath);
if (rePath.indexOf(".tar") > -1){
rePath = rePath.substring(0, rePath.lastIndexOf(".tar"));
}
String decompressionDirName = "/" + rePath;
String packageFileName = rePath;
String decompressionRootPath = "";
// ์ฌ์ฉ์ ์
๋ ฅ๊ณผ packaging ํ์ผ์ ๋๋ ํ ๋ฆฌ ์ ๋ณด ๋น๊ต๋ฅผ ์ํด
// ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๊ฒฉ๋ฉ (dir or file n ame : count)
Map<String, Integer> deCompResultMap = new HashMap<>();
List<String> readmePathList = new ArrayList<String>();
if (result != null) {
boolean isFirst = true;
for (String s : result) {
if (!isEmpty(s) && !(s.contains("(") && s.contains(")"))) {
// packaging file name์ ๊ฒฝ์ฐ Path๋ก ์ธ์ํ์ง ๋ชปํ๋๋ก ์ฒ๋ฆฌํจ.
boolean isFile = s.endsWith("*");
s = s.replace(VERIFY_PATH_DECOMP +"/" + prjId + "/", "");
s = s.replaceAll("//", "/");
if (s.startsWith("/")) {
s = s.substring(1);
}
if (s.endsWith("*")) {
s = s.substring(0, s.length()-1);
}
if (s.endsWith("/")) {
s = s.substring(0, s.length() -1);
}
if (isFirst) {
// ์ฒซ๋ฒ์งธ path๋ฅผ ์์ถ์ ํผ ์ฒ๋ฒ์งธ dir๋ก ์ฌ์ฉ
decompressionRootPath = s;
isFirst = false;
}
int cnt = 0;
//ํ์ผ path์ธ ๊ฒฝ์ฐ, ์์ dir์ ํ์ผ count๋ฅผ +1 ํ๋ค.
if (isFile){
String _dir = s;
if (s.toUpperCase().indexOf("README") > -1) {
readmePathList.add(s);
}
if (s.indexOf("/") > -1) {
_dir = s.substring(0, s.lastIndexOf("/"));
}
if (deCompResultMap.containsKey(_dir)) {
cnt = deCompResultMap.get(_dir);
}
cnt++;
deCompResultMap.put(_dir, cnt);
}
deCompResultMap.put(s, 0);
}
}
}
List<String> paths = sortByValue(deCompResultMap);
for (String path : paths){
if (deCompResultMap.get(path) != null){
deCompResultMap = setAddFileCount(deCompResultMap, path, (int)deCompResultMap.get(path));
}
}
// ๊ฒฐ๊ณผ file path์ ๋ํด์ 4๊ฐ์ง ํ์ฉ ํจํด์ผ๋ก ๊ฒ์ฌํ๋ค.
Map<String, Integer> checkResultMap = new HashMap<>();
List<String> pathCheckList1 = new ArrayList<>();
List<String> pathCheckList2 = new ArrayList<>();
List<String> pathCheckList3 = new ArrayList<>();
List<String> pathCheckList4 = new ArrayList<>();
List<String> pathCheckList11 = new ArrayList<>();
List<String> pathCheckList21 = new ArrayList<>();
List<String> pathCheckList31 = new ArrayList<>();
List<String> pathCheckList41 = new ArrayList<>();
List<String> pathCheckList12 = new ArrayList<>();
List<String> pathCheckList22 = new ArrayList<>();
List<String> pathCheckList32 = new ArrayList<>();
List<String> pathCheckList42 = new ArrayList<>();
List<String> pathCheckList13 = new ArrayList<>();
List<String> pathCheckList23 = new ArrayList<>();
List<String> pathCheckList33 = new ArrayList<>();
List<String> pathCheckList43 = new ArrayList<>();
List<String> pathCheckList14 = new ArrayList<>();
List<String> pathCheckList24 = new ArrayList<>();
List<String> pathCheckList34 = new ArrayList<>();
List<String> pathCheckList44 = new ArrayList<>();
List<String> pathCheckList15 = new ArrayList<>();
List<String> pathCheckList25 = new ArrayList<>();
List<String> pathCheckList35 = new ArrayList<>();
List<String> pathCheckList45 = new ArrayList<>();
List<String> pathCheckList16 = new ArrayList<>();
List<String> pathCheckList26 = new ArrayList<>();
List<String> pathCheckList36 = new ArrayList<>();
List<String> pathCheckList46 = new ArrayList<>();
for (String path : deCompResultMap.keySet()) {
pathCheckList1.add(path);
pathCheckList2.add("/" + path);
pathCheckList3.add(path + "/");
pathCheckList4.add("/"+path + "/");
String replaceFilePath = path.substring(0, path.endsWith("*") ? path.length()-1 : path.length());
if (replaceFilePath.startsWith("/")) {
replaceFilePath = replaceFilePath.substring(1);
}
if (replaceFilePath.endsWith("/")) {
replaceFilePath = replaceFilePath.substring(0, replaceFilePath.length()-1);
}
pathCheckList11.add(replaceFilePath);
pathCheckList21.add("/" + replaceFilePath);
pathCheckList31.add(replaceFilePath + "/");
pathCheckList41.add("/"+replaceFilePath + "/");
String addRootDir = decompressionDirName + "/" + path;
if (addRootDir.startsWith("/")) {
addRootDir = addRootDir.substring(1);
}
if (addRootDir.endsWith("/")) {
addRootDir = addRootDir.substring(0, addRootDir.length()-1);
}
pathCheckList12.add(addRootDir);
pathCheckList22.add("/" + addRootDir);
pathCheckList32.add(addRootDir + "/");
pathCheckList42.add("/"+addRootDir + "/");
String addRootDirReplaceFilePath = decompressionDirName + "/" + path.substring(0, path.endsWith("*") ? path.length()-1 : path.length());
if (addRootDirReplaceFilePath.startsWith("/")) {
addRootDirReplaceFilePath = addRootDirReplaceFilePath.substring(1);
}
if (addRootDirReplaceFilePath.endsWith("/")) {
addRootDirReplaceFilePath = addRootDirReplaceFilePath.substring(0, addRootDirReplaceFilePath.length());
}
pathCheckList13.add(addRootDirReplaceFilePath);
pathCheckList23.add("/" + addRootDirReplaceFilePath);
pathCheckList33.add(addRootDirReplaceFilePath + "/");
pathCheckList43.add("/"+addRootDirReplaceFilePath + "/");
String replaceRootDir = path.replaceFirst(packageFileName, "").replaceAll("//", "/");
if (replaceRootDir.startsWith("/")) {
replaceRootDir = replaceRootDir.substring(1);
}
if (replaceRootDir.endsWith("/")) {
replaceRootDir = replaceRootDir.substring(0, replaceRootDir.length()-1);
}
pathCheckList14.add(replaceRootDir);
pathCheckList24.add("/" + replaceRootDir);
pathCheckList34.add(replaceRootDir + "/");
pathCheckList44.add("/"+replaceRootDir + "/");
String replaceRootDirReplaceFilePath = replaceRootDir;
if (replaceRootDirReplaceFilePath.endsWith("*")) {
replaceRootDirReplaceFilePath = replaceRootDirReplaceFilePath.substring(0, replaceRootDirReplaceFilePath.length()-1);
}
if (replaceRootDirReplaceFilePath.endsWith("/")) {
replaceRootDirReplaceFilePath = replaceRootDirReplaceFilePath.substring(0, replaceRootDirReplaceFilePath.length()-1);
}
pathCheckList15.add(replaceRootDirReplaceFilePath);
pathCheckList25.add("/" + replaceRootDirReplaceFilePath);
pathCheckList35.add(replaceRootDirReplaceFilePath + "/");
pathCheckList45.add("/"+replaceRootDirReplaceFilePath + "/");
String replaceDecomFileRootDir = path.replaceFirst(decompressionRootPath, "").replaceAll("//", "/");
if (replaceDecomFileRootDir.startsWith("/")) {
replaceDecomFileRootDir = replaceDecomFileRootDir.substring(1);
}
if (replaceDecomFileRootDir.endsWith("/")) {
replaceDecomFileRootDir = replaceDecomFileRootDir.substring(0, replaceDecomFileRootDir.length()-1);
}
pathCheckList16.add(replaceDecomFileRootDir);
pathCheckList26.add("/" + replaceDecomFileRootDir);
pathCheckList36.add(replaceDecomFileRootDir + "/");
pathCheckList46.add("/"+replaceDecomFileRootDir + "/");
}
// ํตํฉ Map ์ ๋ชจ๋ ํ์ฉ ํจํด์ ์ ์ฅ
int idx = 0;
for (String s : pathCheckList1) {
checkResultMap.put(s, deCompResultMap.containsKey(s) ? deCompResultMap.get(s) : 0);
checkResultMap.put(pathCheckList2.get(idx), deCompResultMap.containsKey(pathCheckList2.get(idx)) ? deCompResultMap.get(pathCheckList2.get(idx)) : 0);
checkResultMap.put(pathCheckList3.get(idx), deCompResultMap.containsKey(pathCheckList3.get(idx)) ? deCompResultMap.get(pathCheckList3.get(idx)) : 0);
checkResultMap.put(pathCheckList4.get(idx), deCompResultMap.containsKey(pathCheckList4.get(idx)) ? deCompResultMap.get(pathCheckList4.get(idx)) : 0);
checkResultMap.put(pathCheckList11.get(idx), deCompResultMap.containsKey(pathCheckList11.get(idx)) ? deCompResultMap.get(pathCheckList11.get(idx)) : 0);
checkResultMap.put(pathCheckList21.get(idx), deCompResultMap.containsKey(pathCheckList21.get(idx)) ? deCompResultMap.get(pathCheckList21.get(idx)) : 0);
checkResultMap.put(pathCheckList31.get(idx), deCompResultMap.containsKey(pathCheckList31.get(idx)) ? deCompResultMap.get(pathCheckList31.get(idx)) : 0);
checkResultMap.put(pathCheckList41.get(idx), deCompResultMap.containsKey(pathCheckList41.get(idx)) ? deCompResultMap.get(pathCheckList41.get(idx)) : 0);
checkResultMap.put(pathCheckList12.get(idx), deCompResultMap.containsKey(pathCheckList12.get(idx)) ? deCompResultMap.get(pathCheckList12.get(idx)) : 0);
checkResultMap.put(pathCheckList22.get(idx), deCompResultMap.containsKey(pathCheckList22.get(idx)) ? deCompResultMap.get(pathCheckList22.get(idx)) : 0);
checkResultMap.put(pathCheckList32.get(idx), deCompResultMap.containsKey(pathCheckList32.get(idx)) ? deCompResultMap.get(pathCheckList32.get(idx)) : 0);
checkResultMap.put(pathCheckList42.get(idx), deCompResultMap.containsKey(pathCheckList42.get(idx)) ? deCompResultMap.get(pathCheckList42.get(idx)) : 0);
checkResultMap.put(pathCheckList13.get(idx), deCompResultMap.containsKey(pathCheckList13.get(idx)) ? deCompResultMap.get(pathCheckList13.get(idx)) : 0);
checkResultMap.put(pathCheckList23.get(idx), deCompResultMap.containsKey(pathCheckList23.get(idx)) ? deCompResultMap.get(pathCheckList23.get(idx)) : 0);
checkResultMap.put(pathCheckList33.get(idx), deCompResultMap.containsKey(pathCheckList33.get(idx)) ? deCompResultMap.get(pathCheckList33.get(idx)) : 0);
checkResultMap.put(pathCheckList43.get(idx), deCompResultMap.containsKey(pathCheckList43.get(idx)) ? deCompResultMap.get(pathCheckList43.get(idx)) : 0);
checkResultMap.put(pathCheckList14.get(idx), deCompResultMap.containsKey(pathCheckList14.get(idx)) ? deCompResultMap.get(pathCheckList14.get(idx)) : 0);
checkResultMap.put(pathCheckList24.get(idx), deCompResultMap.containsKey(pathCheckList24.get(idx)) ? deCompResultMap.get(pathCheckList24.get(idx)) : 0);
checkResultMap.put(pathCheckList34.get(idx), deCompResultMap.containsKey(pathCheckList34.get(idx)) ? deCompResultMap.get(pathCheckList34.get(idx)) : 0);
checkResultMap.put(pathCheckList44.get(idx), deCompResultMap.containsKey(pathCheckList44.get(idx)) ? deCompResultMap.get(pathCheckList44.get(idx)) : 0);
checkResultMap.put(pathCheckList15.get(idx), deCompResultMap.containsKey(pathCheckList15.get(idx)) ? deCompResultMap.get(pathCheckList15.get(idx)) : 0);
checkResultMap.put(pathCheckList25.get(idx), deCompResultMap.containsKey(pathCheckList25.get(idx)) ? deCompResultMap.get(pathCheckList25.get(idx)) : 0);
checkResultMap.put(pathCheckList35.get(idx), deCompResultMap.containsKey(pathCheckList35.get(idx)) ? deCompResultMap.get(pathCheckList35.get(idx)) : 0);
checkResultMap.put(pathCheckList45.get(idx), deCompResultMap.containsKey(pathCheckList45.get(idx)) ? deCompResultMap.get(pathCheckList45.get(idx)) : 0);
String _tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList16.get(idx)), pathCheckList16.get(idx));
checkResultMap.put(pathCheckList16.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList26.get(idx)), pathCheckList26.get(idx));
checkResultMap.put(pathCheckList26.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList36.get(idx)), pathCheckList36.get(idx));
checkResultMap.put(pathCheckList36.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
_tmp = addDecompressionRootPath(decompressionRootPath, deCompResultMap.containsKey(pathCheckList46.get(idx)), pathCheckList46.get(idx));
checkResultMap.put(pathCheckList46.get(idx), deCompResultMap.containsKey(_tmp) ? deCompResultMap.get(_tmp) : 0);
idx ++;
}
int gridIdx = 0;
ArrayList<String> gValidIdxlist = new ArrayList<>();
HashMap<String,Object> gFileCountMap = new HashMap<>();
boolean separatorErrFlag = false;
log.info("[API] VERIFY Path Check START -----------------");
for (String gridPath : gridFilePaths){
if (!separatorErrFlag) {
separatorErrFlag = gridPath.contains("\\") ? true : false;
}
//์ฌ์ฉ์๊ฐ * ์
๋ ฅํ์๋
if (!gridPath.trim().equals("/*") && !gridPath.trim().equals("/")){
if (gridPath.endsWith("*")) {
gridPath = gridPath.substring(0, gridPath.length()-1);
}
if (gridPath.startsWith(".")) {
gridPath = gridPath.substring(1, gridPath.length());
}
// ์๋ค path๊ตฌ๋ถ ์ ๊ฑฐ
if (gridPath.endsWith("/")) {
gridPath = gridPath.substring(0, gridPath.length()-1);
}
if (gridPath.startsWith("/")) {
gridPath = gridPath.substring(1);
}
int gFileCount = 0;
/*
* SUB_STEP 1. verify ๊ฒฐ๊ณผ ๋ฐฐ์ด์ ๋ฐ์์จ grid filepath์ ๋น๊ตํ์ฌ ์ค์ ๋ก ๊ทธ path๊ฐ ์กด์ฌํ๋์ง ํ์ธํ
* ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ grid index ์ ์ฅ
*/
boolean resultFlag = false;
if (checkResultMap.containsKey(gridPath)) {
resultFlag = true;
gFileCount = checkResultMap.get(gridPath);
}
if (!resultFlag) {//path๊ฐ ์กด์ฌํ์ง์์ ๋
gValidIdxlist.add(gridComponentIds.get(gridIdx));
} else {//path๊ฐ ์กด์ฌํ ๋
// file์ ์ง์ ๋น๊ตํ๋ ๊ฒฝ์ฐ count๋์ง ์๊ธฐ ๋๋ฌธ์, 1๋ก ๊ณ ์
// resultFlag == true ์ธ๊ฒฝ์ฐ๋ ์กด์ฌํ๊ธฐ ํด๋น path or file ๋์์ด ์กด์ฌํ๋ค๋ ์๋ฏธ์ด๊ธฐ ๋๋ฌธ์ 0์ด ๋ ์ ์๋ค.
if (gFileCount == 0) {
gFileCount = 1;
}
gFileCountMap.put(gridComponentIds.get(gridIdx), Integer.toString(gFileCount));
}
} else {
gFileCountMap.put(gridComponentIds.get(gridIdx), Integer.toString(allFileCount));
}
gridIdx++;
}
log.info("[API] VERIFY Path Check END -----------------");
//STEP 4 : README ํ์ผ ์กด์ฌ ์ ๋ฌด ํ์ธ(README ์ฌ๋ฌ๊ฐ ์ผ๊ฒฝ์ฐ๋ ์๊ฐํด์ผํจ ---์ฐจํ)
// depth๊ฐ ๋ฎ์ readme ํ์ผ์ ๊ตฌํ๊ธฐ ์ํด sort
if (packagingFileIdx == 1){ // packageFile์์ readMe File์ ์ฒซ๋ฒ์งธ file์์๋ง ์ฐพ์.
// List<String> sortList = new ArrayList<>(deCompResultMap.keySet());
Collections.sort(readmePathList, new Comparator<String>() {
@Override
public int compare(String arg1, String arg2) {
if (arg1.split("\\/").length > arg2.split("\\/").length) {
return 1;
} else if (arg1.split("\\/").length < arg2.split("\\/").length) {
return -1;
} else {
return arg1.compareTo(arg2);
}
};
});
// String lastReadmeFilePath = "";
for (String r : readmePathList) {
String _upperPath = avoidNull(r).toUpperCase();
if (_upperPath.endsWith("/")) {
continue;
}
// String _currentReadmeFilePath = _upperPath.indexOf("/") < 0 ? _upperPath : _upperPath.substring(0,_upperPath.lastIndexOf("/"));
//
// if (!lastReadmeFilePath.equals(_currentReadmeFilePath)) {
// if (!isEmpty(readmePath)) {
// break;
// }
//
// lastReadmeFilePath = _currentReadmeFilePath;
// }
if (_upperPath.indexOf("/") > -1) {
_upperPath = _upperPath.substring(_upperPath.lastIndexOf("/"), _upperPath.length());
}
if (_upperPath.indexOf("README") > -1){
String _readmePath = r.replaceAll("\\n", "");
int afterDepthCnt = StringUtils.countMatches(_readmePath, "/");
int beforeDepthCnt = StringUtils.countMatches(readmePath, "/");
if (isEmpty(readmePath) || beforeDepthCnt > afterDepthCnt) {
readmePath = _readmePath;
}
}
}
}
String readmeFileName = "";
//STEP 6 : README ํ์ผ ๋ด์ฉ ์ถ๋ ฅ
if (!StringUtil.isEmpty(readmePath)){
if (readmePath.indexOf("*") > -1){
readmePath = readmePath.substring(0, readmePath.length()-1);
}
readmeFileName = readmePath;
if (readmeFileName.indexOf("/") > -1) {
readmeFileName = readmeFileName.substring(readmeFileName.lastIndexOf("/") + 1);
}
if (readmePath.indexOf(" ") > -1) {
log.info("do space replase ok");
readmePath = readmePath.replaceAll(" ", "*");
}
log.info("[API] readmePath : " + readmePath);
log.info("[API] readmeFileName : " + readmeFileName);
log.info("[API] VERIFY Copy Readme file START -----------------");
log.info("[API] VERIFY README MV PATH : " + VERIFY_PATH_DECOMP +"/" + prjId +"/" + readmePath);
if (isChangedPackageFile){
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "cp "+VERIFY_PATH_DECOMP +"/" + prjId +"/" + readmePath+ " " + VERIFY_PATH_OUTPUT +"/" + prjId +"/"});
}
log.info("[API] VERIFY Copy Readme file END -----------------");
}
//STEP 7 : README ํ์ผ ๋ด์ฉ DB ์ ์ ์ฅ
if (doUpdate && packagingFileIdx == 1) {
log.debug("[API] VERIFY readme ๋ฑ๋ก");
project.put("prjId", prjId);
project.put("readmeFileName", readmeFileName);
project.put("readmeYn", StringUtil.isEmpty(readmeFileName) ? CoConstDef.FLAG_NO : CoConstDef.FLAG_YES);
registReadmeContent(project);
log.debug("[API] VERIFY readme ๋ฑ๋ก ์๋ฃ");
}
//STEP 8 : Verify ๋์ ํ Except File Result DB ์ ์ฅ
log.info("[API] VERIFY Read exceptFileContent file START -----------------");
exceptFileContent = CommonFunction.getStringFromFile(VERIFY_PATH_OUTPUT +"/"+prjId+"/except_file_result", VERIFY_PATH_DECOMP +"/" + prjId +"/", checkExceptionWordsList, checkExceptionIgnoreWorksList);
log.info("[API] VERIFY Read exceptFileContent file END -----------------");
// 2017.03.23 yuns contents ์ฉ๋์ด ๋๋ฌด ์ปค์ DB๋ก ๊ด๋ฆฌํ์ง ์์ (flag๋ง ์ฒ๋ฆฌ, empty์ฌ๋ถ๋ก ์ฒดํฌํ๊ธฐ ๋๋ฌธ์ ๋ด์ฉ์ด ์์ ๊ฒฝ์ฐ "Y" ๋ง ๋ฑ๋ก
project.put("exceptFileContent", !isEmpty(exceptFileContent) ? CoConstDef.FLAG_YES : "");
project.put("verifyFileContent", !isEmpty(verify_chk_list) ? CoConstDef.FLAG_YES : "");
if (doUpdate) {
registVerifyContents(project);
}
log.debug("[API] VERIFY ํ์ผ๋ด์ฉ ๋ฑ๋ก ์๋ฃ");
// ์๋ฒ ๋๋ ํ ๋ฆฌ๋ฅผ replaceํ ๋ด์ฉ์ผ๋ก ์๋ก์ด ํ์ผ๋ก ๋ค์ ์ด๋ค.
if (!isEmpty(exceptFileContent)) {
log.info("[API] VERIFY writhFile exceptFileContent file START -----------------");
FileUtil.writeFile(VERIFY_PATH_OUTPUT +"/" + prjId, CoConstDef.PACKAGING_VERIFY_FILENAME_PROPRIETARY, exceptFileContent.replaceAll(VERIFY_PATH_DECOMP +"/" + prjId +"/", ""));
log.info("[API] VERIFY writhFile exceptFileContent file END -----------------");
}
if (!isEmpty(verify_chk_list)) {
log.info("[API] VERIFY writhFile verify_chk_list file START -----------------");
FileUtil.writeFile(VERIFY_PATH_OUTPUT +"/" + prjId, CoConstDef.PACKAGING_VERIFY_FILENAME_FILE_LIST, verify_chk_list.replaceAll(VERIFY_PATH_DECOMP +"/" + prjId +"/", ""));
log.info("[API] VERIFY writhFile verify_chk_list file END -----------------");
}
resCd="10";
if (separatorErrFlag) {
resMsg = getMessage("verify.path.error");
} else {
resMsg= getMessage(gValidIdxlist.isEmpty() ? "msg.common.success" : "msg.common.valid");
}
resMap.put("verifyValid", gValidIdxlist);
resMap.put("verifyValidMsg", "path not found.");
resMap.put("fileCounts", gFileCountMap);
resMap.put("verifyReadme", readmeFileName);
resMap.put("verifyCheckList", !isEmpty(verify_chk_list) ? CoConstDef.FLAG_YES : "");
resMap.put("verifyProprietary", !isEmpty(exceptFileContent) ? CoConstDef.FLAG_YES : "");
//path not found.๊ฐ 1๊ฑด์ด๋ผ๋ ์์ผ๋ฉด status_verify_yn์ flag๋ N์ผ๋ก ์ ์ฅํจ.
// packagingFileId, filePath๋ 1๋ฒ๋ง ์ ์ฅํ๋ฉฐ, gValidIdxlist์ ๊ฐ๋๋ฌธ์ ๋ง์ง๋ง fileSeq์ผ๋ ์ ์ฅํจ.
if (doUpdate && packagingFileIdx == fileSeqs.size()) {
// verify ๋ฒํผ ํด๋ฆญ์ file path๋ฅผ ์ ์ฅํ๋ค.
if (gridComponentIds != null && !gridComponentIds.isEmpty()) {
int seq = 0;
for (String s : gridComponentIds){
Map<String, Object> param = new HashMap<>();
param.put("componentId", s);
param.put("filePath", gridFilePaths.get(seq++));
apiProjectMapper.updateVerifyFilePath(param);
}
}
{
Map<String, Object> prjParam = new HashMap<>();
prjParam.put("prjId", prjId);
prjParam.put("packageFileId", fileSeqs.get(0));
if (prjInfo.containsKey("destributionStatus") && prjInfo.get("destributionStatus") != null && !("").equals(prjInfo.get("destributionStatus"))){
prjParam.put("statusVerifyYn", "C");
} else {
prjParam.put("statusVerifyYn", CoConstDef.FLAG_YES);
}
apiProjectMapper.updatePackageFile2(prjParam);
}
CommentsHistory commHisBean = new CommentsHistory();
commHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_PACKAGING_HIS);
commHisBean.setReferenceId(prjId); commHisBean.setContents(packagingComment);
commentService.registComment(commHisBean);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
resCd="20";
resMsg="process failed. (server error)";
} finally {
try {
if (isChangedPackageFile){
ShellCommander.shellCommandWaitFor(new String[]{"/bin/bash", "-c", "find " + VERIFY_PATH_DECOMP + " -maxdepth 1 -name "+prjId+" -type d -exec rm -rf {} \\;"});
}
log.info("[API] VERIFY delete decomp file END -----------------");
} catch (Exception e2) {
log.error(e2.getMessage(), e2);
}
}
resMap.put("resCd", resCd);
resMap.put("resMsg", resMsg);
log.debug("[API] verify ์ฒ๋ฆฌ ์๋ฃ resCd : " + resCd);
log.debug("[API] verify ์ฒ๋ฆฌ ์๋ฃ resMsg : " + resMsg);
return resMap;
}
private void registVerifyContents(Map<String, Object> project) {
apiProjectMapper.updateVerifyContents(project);
}
private void registReadmeContent(Map<String, Object> project) {
apiProjectMapper.updateReadmeContent(project);
}
@Override
public Map<String, Object> getProjectBasicInfo(String prjId) {
Map<String, Object> param = new HashMap<>();
param.put("prjId", prjId);
return apiProjectMapper.selectProjectMaster2(param);
}
@Override
public void updateVerifyFileCount(ArrayList<String> fileCounts) {
for (String componentId : fileCounts){
Map<String, Object> param = new HashMap<>();
param.put("componentId", componentId);
param.put("verifyFileCount", " ");
apiProjectMapper.updateVerifyFileCount(param);
}
}
@Override
public void updateVerifyFileCount(HashMap<String, Object> fileCounts) {
for (String componentId : fileCounts.keySet()){
Map<String, Object> param = new HashMap<>();
param.put("componentId", componentId);
param.put("verifyFileCount", (String) fileCounts.get(componentId));
apiProjectMapper.updateVerifyFileCount(param);
}
}
private String addDecompressionRootPath(String path, boolean flag, String val) {
return flag ? val : path + "/" + val;
}
private Map<String, Integer> setAddFileCount(Map<String, Integer> deCompResultMap, String url, int fileCnt) {
try {
url = url.substring(0, url.lastIndexOf("/"));
int pFileCnt = deCompResultMap.get(url);
deCompResultMap.put(url, fileCnt + pFileCnt);
if (deCompResultMap.get(url.substring(0, url.lastIndexOf("/"))) != null){
setAddFileCount(deCompResultMap, url, fileCnt);
}
return deCompResultMap;
} catch (Exception e) {
return deCompResultMap;
}
}
private List<String> sortByValue(Map<String, Integer> map) throws Exception{
List<String> list = new ArrayList<String>();
list.addAll(map.keySet());
Collections.sort(list, new Comparator<Object>(){
public int compare(Object o1,Object o2){
int o1_depth = o1.toString().split("/").length;
int o2_depth = o2.toString().split("/").length;
return o1_depth-o2_depth;
}
});
return list;
}
@Override
public List<String> getPackageFileList(String prjId) {
Map<String, Object> packageFile = apiProjectMapper.selectPackageFileList(prjId);
List<String> packageFileList = new ArrayList<>();
if (packageFile.containsKey("packageFileId")) {
if (packageFile.get("packageFileId") != null && !("").equals(Integer.toString((int) packageFile.get("packageFileId")))) {
packageFileList.add(Integer.toString((int) packageFile.get("packageFileId")));
}
}
if (packageFile.containsKey("packageFileId2")) {
if (packageFile.get("packageFileId2") != null && !("").equals(Integer.toString((int) packageFile.get("packageFileId2")))) {
packageFileList.add(Integer.toString((int) packageFile.get("packageFileId2")));
}
}
if (packageFile.containsKey("packageFileId3")) {
if (packageFile.get("packageFileId3") != null && !("").equals(Integer.toString((int) packageFile.get("packageFileId3")))) {
packageFileList.add(Integer.toString((int) packageFile.get("packageFileId3")));
}
}
return packageFileList;
}
@SuppressWarnings("unchecked")
@Override
public void registBom(String prjId, String merge) {
loadOssInfo();
loadLicenseInfo();
// delete component
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("referenceId", (String) prjId);
paramMap.put("referenceDiv", (String) CoConstDef.CD_DTL_COMPONENT_ID_BOM);
paramMap.put("merge", (String) merge);
paramMap.put("roleOutLicense", (String) CoCodeManager.CD_ROLE_OUT_LICENSE);
paramMap.put("saveBomFlag", (String) CoConstDef.FLAG_YES);
List<String> componentId = apiProjectMapper.selectComponentId(paramMap);
// ๊ธฐ์กด bom ์ ๋ณด๋ฅผ ๋ชจ๋ ๋ฌผ๋ฆฌ์ญ์ ํ๊ณ ๋ค์ ๋ฑ๋กํ๋ค.
if (componentId.size() > 0){
for (int i = 0; i < componentId.size(); i++) {
apiProjectMapper.deleteOssComponentsLicense(componentId.get(i));
}
apiProjectMapper.deleteOssComponents(paramMap);
}
HashMap<String, Object> mergeListMap = getIdentificationGridList(paramMap);
if (mergeListMap != null && mergeListMap.get("rows") != null) {
for (HashMap<String, Object> bean : (List<HashMap<String, Object>>) mergeListMap.get("rows")) {
if ((bean.get("ossName") == null || "-".equals((String) bean.get("ossName")))) {
List<HashMap<String, Object>> ocll = (List<HashMap<String, Object>>) bean.get("ossComponentsLicenseList");
if (ocll.size() > 1) {
continue;
}
}
bean.put("refDiv", bean.get("referenceDiv"));
bean.put("referenceDiv", CoConstDef.CD_DTL_COMPONENT_ID_BOM);
bean.put("refComponentId", bean.get("componentId"));
bean.put("adminCheckYn", CoConstDef.FLAG_NO);
bean.put("preObligationType", bean.get("obligationType"));
if (bean.containsKey("licenseName")) {
if (((String) bean.get("licenseName")).contains("Other")) {
String licenseNm = (String) bean.get("licenseName");
}
}
bean = findOssIdAndName(bean);
String copyrightText = (String) bean.get("copyrightText");
if(!isEmpty(copyrightText)) {
String[] copyrights = copyrightText.split("\\|");
String customCopyrightText = Arrays.stream(copyrights).distinct().collect(Collectors.joining("\n"));
bean.put("copyrightText", customCopyrightText);
}
// ์ปดํฌ๋ํธ ๋ง์คํฐ ์ธ์ํธ
apiProjectMapper.registBomComponents(bean);
List<HashMap<String, Object>> licenseList = findOssLicenseIdAndName(bean);
if (licenseList.size() > 0) {
for (HashMap<String, Object> licenseBean : licenseList) {
licenseBean.put("componentId", bean.get("componentId"));
apiProjectMapper.registComponentLicense(licenseBean);
}
}
}
}
// identification ๋์์ด ์์ด ์ฒ์ ์ ์ฅํ๋ ๊ฒฝ์ฐ
Map<String, Object> _tempPrjInfo = new HashMap<>();
_tempPrjInfo.put("prjId", prjId);
_tempPrjInfo = apiProjectMapper.selectProjectMaster2(_tempPrjInfo);
if (_tempPrjInfo.get("identificationStatus") == null && ((String) _tempPrjInfo.get("identificationStatus")).trim().length() == 0) {
_tempPrjInfo.put("identificationStatus", CoConstDef.CD_DTL_IDENTIFICATION_STATUS_PROGRESS);
apiProjectMapper.updateIdentifcationProgress(_tempPrjInfo);
}
}
private void loadOssInfo() {
try {
List<HashMap<String, Object>> list = apiOssMapper.getOssInfoAll();
List<HashMap<String, Object>> listNick = apiOssMapper.getOssInfoAllWithNick();
List<HashMap<String, Object>> nickNameList = apiOssMapper.getOssAllNickNameList();
HashMap<String, String[]> nickNameMap = new HashMap<>();
HashMap<String, HashMap<String, Object>> _ossMap = new HashMap<>();
HashMap<String, String> _ossNamesMap = new HashMap<>();
if (nickNameList != null) {
for (Map<String, Object> bean : nickNameList) {
if (bean.get("ossNickname") != null) {
nickNameMap.put((String) bean.get("ossName"), ((String) bean.get("ossNickname")).split(","));
}
}
}
if (list != null) {
List<HashMap<String, Object>> licenseBeanList = new ArrayList<>();
for (HashMap<String, Object> bean : list) {
HashMap<String, Object> licenseBean = new HashMap<>();
HashMap<String, Object> targetBean = null;
String key = (String) bean.get("ossName") +"_"+ avoidNull((String) bean.get("ossVersion")); // oss name์ nick name์ผ๋ก ๊ฐ์ ธ์จ๋ค.
key = key.toUpperCase();
if (_ossMap.containsKey(key)) {
targetBean = _ossMap.get(key);
} else {
targetBean = bean;
if (nickNameMap.containsKey(targetBean.get("ossNameTemp"))) {
targetBean.put("ossNicknames", nickNameMap.get(targetBean.get("ossNameTemp")));
}
}
HashMap<String, Object> subBean = new HashMap<>();
subBean.put("ossId", bean.get("ossId"));
subBean.put("licenseId", bean.get("licenseId"));
subBean.put("licenseName", bean.get("licenseName"));
subBean.put("licenseType", bean.get("ossLicenseType"));
subBean.put("ossLicenseIdx", bean.get("ossLicenseIdx"));
subBean.put("ossLicenseComb", bean.get("ossLicenseComb"));
subBean.put("ossLicenseText", bean.get("ossLicenseText"));
subBean.put("ossCopyright", bean.get("ossCopyright"));
targetBean.put("licenseType", bean.get("ossLicenseType"));
licenseBean.put(key, subBean);
licenseBeanList.add(licenseBean);
targetBean.put("ossLicenses", makeOssLicense(key, licenseBeanList));
if (_ossMap.containsKey(key)) {
_ossMap.replace(key, targetBean);
} else {
_ossMap.put(key, targetBean);
}
if (!_ossNamesMap.containsKey(((String) bean.get("ossName")).toUpperCase())) {
_ossNamesMap.put(((String) bean.get("ossName")).toUpperCase(), (String) bean.get("ossName"));
}
}
}
HashMap<String, HashMap<String, Object>> _idMasterMap = new HashMap<>();
for (HashMap<String, Object> bean : _ossMap.values()) {
if (!_idMasterMap.containsKey(bean.get("ossId"))) {
_idMasterMap.put(Integer.toString((int) bean.get("ossId")), bean);
}
}
OSS_INFO_BY_ID = _idMasterMap;
if (listNick != null) {
for (HashMap<String, Object> bean : listNick) {
String key = (String) bean.get("ossName") +"_"+ avoidNull((String) bean.get("ossVersion")); // oss name์ nick name์ผ๋ก ๊ฐ์ ธ์จ๋ค.
String ossNickNameKey = ((String) bean.get("ossName")).toUpperCase();
if (!_ossNamesMap.containsKey(ossNickNameKey)) {
_ossNamesMap.put(ossNickNameKey, (String) bean.get("ossNameTemp"));
}
String sourceKey = ((String) bean.get("ossNameTemp") + "_" + avoidNull((String) bean.get("ossVersion"))).toUpperCase();
HashMap<String, Object> sourceBean = _ossMap.get(sourceKey);
bean.put("licenseDiv", sourceBean.get("licenseDiv"));
bean.put("downloadLocation", sourceBean.get("downloadLocation"));
bean.put("downloadLocationGroup", sourceBean.get("downloadLocationGroup"));
bean.put("homepage", sourceBean.get("homepage"));
bean.put("summaryDescription", sourceBean.get("summaryDescription"));
bean.put("attribution", sourceBean.get("attribution"));
bean.put("copyright", sourceBean.get("copyright"));
bean.put("cvssScore", sourceBean.get("cvssScore"));
bean.put("cveId", sourceBean.get("cveId"));
bean.put("vulnYn", sourceBean.get("vulnYn"));
bean.put("vulnRecheck", sourceBean.get("vulnRecheck"));
bean.put("vulnDate", sourceBean.get("vulnDate"));
bean.put("licenseType", sourceBean.get("licenseType"));
bean.put("ossLicenses", sourceBean.get("ossLicenses"));
bean.put("ossType", sourceBean.get("ossType"));
bean.put("multiLicenseFlag", sourceBean.get("multiLicenseFlag"));
bean.put("dualLicenseFlag", sourceBean.get("dualLicenseFlag"));
bean.put("versionDiffFlag", sourceBean.get("versionDiffFlag"));
_ossMap.put(key.toUpperCase(), bean);
}
}
if (!_ossMap.isEmpty()) {
OSS_INFO_UPPER = _ossMap;
}
} catch(Exception e) {
log.error(e.getMessage(), e);
}
}
@SuppressWarnings("unchecked")
private List<HashMap<String, Object>> makeOssLicense(String key, List<HashMap<String, Object>> licenseBeanList) {
List<HashMap<String, Object>> ossLicenses = new ArrayList<>();
for (HashMap<String, Object> license : licenseBeanList) {
if (license.containsKey(key)) {
ossLicenses.add((HashMap<String, Object>) license.get(key));
}
}
if (ossLicenses.size() > 1) {
Collections.sort(ossLicenses, new Comparator<HashMap<String, Object>>() {
@Override
public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
return Integer.toString((int) o1.get("ossLicenseIdx")).compareTo(Integer.toString((int) o2.get("ossLicenseIdx")));
}
});
}
return ossLicenses;
}
private void loadLicenseInfo() {
try {
List<HashMap<String, Object>> list = apiProjectMapper.getLicenseInfoInit();
List<HashMap<String, Object>> nickList = apiProjectMapper.getLicenseInfoInitNick();
if (list == null) {
throw new RuntimeException("SYSTEM ERR GET CODE LICENSE MASTER INFO");
}
HashMap<String, HashMap<String, Object>> license_info_map = new HashMap<>();
HashMap<String, HashMap<String, Object>> license_info_upper_map = new HashMap<>();
HashMap<String, HashMap<String, Object>> license_info_by_id_map = new HashMap<>();
for (HashMap<String, Object> vo : list) {
if (vo.containsKey("licenseNicknameStr")) {
List<String> licenseNicknameList = new ArrayList<String>();
for (String nick : ((String) vo.get("licenseNicknameStr")).split("\\|")) {
licenseNicknameList.add(nick);
}
vo.put("licenseNicknameList", licenseNicknameList);
}
if (vo.containsKey("restriction")) {
if (!("").equals((String) vo.get("restriction"))) {
vo.put("restrictionStr", licenseRestrictionList((String) vo.get("restriction")));
}
}
license_info_map.put((String) vo.get("licenseName"),vo);
license_info_upper_map.put(((String) vo.get("licenseName")).toUpperCase(),vo);
//SHORT_IDENTIFIER
if (vo.containsKey("shortIdentifier")) {
if (!("").equals(vo.get("shortIdentifier"))) {
if (!license_info_map.containsKey(vo.get("shortIdentifier"))) {
license_info_map.put((String) vo.get("shortIdentifier"), vo);
}
if (!license_info_upper_map.containsKey(((String) vo.get("shortIdentifier")).toUpperCase())) {
license_info_upper_map.put(((String) vo.get("shortIdentifier")).toUpperCase(), vo);
}
}
}
license_info_by_id_map.put(Integer.toString((int) vo.get("licenseId")), vo);
}
for (HashMap<String, Object> vo : nickList) {
HashMap<String, Object> sourceBean = license_info_by_id_map.get(Integer.toString((int) vo.get("licenseId")));
if (vo.containsKey("licenseNicknameList")) {
vo.put("licenseNicknameList", sourceBean.get("licenseNicknameList"));
}
if (vo.containsKey("restrictionStr")) {
vo.put("restrictionStr", sourceBean.get("restrictionStr"));
}
license_info_map.put((String) vo.get("licenseName"),vo);
license_info_upper_map.put(((String) vo.get("licenseName")).toUpperCase(),vo);
}
if (!license_info_map.isEmpty()) {
LICENSE_INFO = license_info_map;
}
if (!license_info_upper_map.isEmpty()) {
LICENSE_INFO_UPPER = license_info_upper_map;
}
if (!license_info_by_id_map.isEmpty()) {
LICENSE_INFO_BY_ID = license_info_by_id_map;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
private String licenseRestrictionList(String restrictionStr) {
String returnStr = "";
if (!isEmpty(restrictionStr)) {
String restrictionArr[] = restrictionStr.split(",");
List<String> restrictionList = new ArrayList<>();
for (int i = 0 ; i < restrictionArr.length ; i++){
restrictionList.add(restrictionArr[i]);
}
for (String str : restrictionList){
returnStr += (isEmpty(returnStr)?"":"\n") + CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, str.trim().toUpperCase());
}
}
return returnStr;
}
private HashMap<String, Object> getIdentificationGridList(Map<String, Object> paramMap) {
return getIdentificationGridList(paramMap, false);
}
@SuppressWarnings("unchecked")
private HashMap<String, Object> getIdentificationGridList(Map<String, Object> paramMap, boolean multiUIFlag) {
HashMap<String, Object> map = new HashMap<String, Object>();
List<HashMap<String, Object>> list = null;
List<HashMap<String, Object>> listLicense = null;
paramMap.put("roleOutLicense", CoCodeManager.CD_ROLE_OUT_LICENSE);
if (CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST != null && !CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST.isEmpty()) {
paramMap.put("roleOutLicenseIdList", CoCodeManager.CD_ROLE_OUT_LICENSE_ID_LIST);
}
if (CoConstDef.CD_DTL_COMPONENT_ID_BOM.equals((String) paramMap.get("referenceDiv"))) {
Map<String, String> obligationTypeMergeMap = new HashMap<>();
String reqMergeFlag = (String) paramMap.get("merge");
list = apiProjectMapper.selectMergeBomList(paramMap);
// bom merge ๋ฒํผ์ ํด๋ฆญํ๊ณ , ํ์๋์์ด ์์ ๊ฒฝ์ฐ, ๊ธฐ์กด์ ์ ์ฅ๋์ด ์๋ ๋ด์ฉ์ ์ทจ๋ํ๋ค.
// need check์ ์ ์ฅ๊ฐ์ ์ ์งํ๊ธฐ ์ํจ
if (CoConstDef.FLAG_YES.equals(reqMergeFlag) && list != null && !list.isEmpty()) {
paramMap.put("merge", CoConstDef.FLAG_NO);
List<HashMap<String, Object>> bomBeforeList = apiProjectMapper.selectMergeBomList(paramMap);
if (bomBeforeList != null) {
for (Map<String, Object> _orgIdentificationBean : bomBeforeList) {
obligationTypeMergeMap.put((String) _orgIdentificationBean.get("refComponentId"), (String) _orgIdentificationBean.get("obligationType"));
}
}
}
Map<String, Map<String, Object>> batMergeSrcMap = new HashMap<>();
Map<String, Map<String, Object>> batMergePartnerMap = new HashMap<>();
for (Map<String, Object> ll : list) {
ll.put("licenseId", CommonFunction.removeDuplicateStringToken((String) ll.get("licenseId"), ","));
ll.put("licenseName", CommonFunction.removeDuplicateStringToken((String) ll.get("licenseName"), ","));
ll.put("copyrightText", ll.get("copyrightText"));
ll.put("roleOutLicense", CoCodeManager.CD_ROLE_OUT_LICENSE);
listLicense = apiProjectMapper.selectBomLicense(Integer.toString((int) ll.get("componentId")));
ll.put("ossComponentsLicenseList", listLicense);
ll.put("obligationLicense", CoConstDef.FLAG_YES.equals(ll.get("adminCheckYn")) ? CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK : checkObligationSelectedLicense(listLicense));
if (CoConstDef.FLAG_YES.equals(reqMergeFlag)) {
if (obligationTypeMergeMap.containsKey(Integer.toString((int) ll.get("componentId")))) {
ll.put("obligationType", obligationTypeMergeMap.get(Integer.toString((int) ll.get("componentId"))));
} else {
ll.put("obligationType", ll.get("obligationLicense"));
}
}
// grouping ๋ file path๋ฅผ br tag๋ก ๋ณ๊ฒฝ
ll.put("filePath", lineReplaceToBR((String) ll.get("filePath")));
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals((String) ll.get("referenceDiv"))) {
if (!batMergeSrcMap.containsKey(((String) ll.get("ossName")).toUpperCase())) {
batMergeSrcMap.put(((String) ll.get("ossName")).toUpperCase(), ll);
} else if (StringUtil.compareTo(((String) ll.get("ossVersion")), (String) batMergeSrcMap.get(((String) ll.get("ossName")).toUpperCase()).get("ossVersion")) > 0) {
batMergeSrcMap.replace(((String) ll.get("ossName")).toUpperCase(), ll);
}
} else if (CoConstDef.CD_DTL_COMPONENT_ID_PARTNER.equals(((String) ll.get("referenceDiv")))) {
if (!batMergePartnerMap.containsKey(((String) ll.get("ossName")).toUpperCase())) {
batMergePartnerMap.put(((String) ll.get("ossName")).toUpperCase(), ll);
} else if (StringUtil.compareTo(((String) ll.get("ossVersion")), (String) batMergePartnerMap.get(((String) ll.get("ossName")).toUpperCase()).get("ossVersion")) > 0) {
batMergePartnerMap.replace(((String) ll.get("ossName").toString()), ll);
}
}
// oss Name์ ์์ฑํ๊ณ , oss Version์ ์์ฑํ์ง ์์ case๊ฒฝ์ฐ ํด๋น ๋ถ๊ธฐ๋ฌธ์์ ์ฒ๋ฆฌ
if (ll.get("cveId") == null
&& isEmpty((String) ll.get("ossVersion"))
&& !isEmpty((String) ll.get("cvssScoreMax"))
&& !("-".equals((String) ll.get("ossName")))){
String[] cvssScoreMax = ((String) ll.get("cvssScoreMax")).split("\\@");
ll.put("cvssScore", cvssScoreMax[0]);
ll.put("cveId", cvssScoreMax[1]);
}
// convert max score
if (ll.get("cvssScoreMax") != null || ll.get("cvssScoreMax1") != null || ll.get("cvssScoreMax2") != null
|| ll.get("cvssScoreMax3") != null || ll.get("cvssScoreMax4") != null || ll.get("cvssScoreMax5") != null) {
List<String> cvssScoreMaxList = new ArrayList<>();
if (ll.get("cvssScoreMax") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax"));
}
if (ll.get("cvssScoreMax1") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax1"));
}
if (ll.get("cvssScoreMax2") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax2"));
}
if (ll.get("cvssScoreMax3") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax3"));
}
if (ll.get("cvssScoreMax4") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax4"));
}
if (ll.get("cvssScoreMax5") != null) {
cvssScoreMaxList.add((String) ll.get("cvssScoreMax5"));
}
if (!cvssScoreMaxList.isEmpty()) {
String[] cvssScoreMaxString = null;
BigDecimal cvssScore = null;
BigDecimal cvssScoreMax = null;
String cveId = null;
for (String cvssScoreMaxStr : cvssScoreMaxList) {
cvssScoreMaxString = cvssScoreMaxStr.split("\\@");
if (cvssScoreMax != null) {
cvssScore = new BigDecimal(cvssScoreMaxString[0]);
if (cvssScoreMax.compareTo(cvssScore) == -1) {
cvssScoreMax = cvssScore;
cveId = cvssScoreMaxString[1];
}
} else {
cvssScoreMax = new BigDecimal(cvssScoreMaxString[0]);
cveId = cvssScoreMaxString[1];
}
}
if (cvssScoreMax != null) {
ll.put("cvssScore", (String.valueOf(cvssScoreMax)));
ll.put("vulnYn", CoConstDef.FLAG_YES);
ll.put("cveId", cveId);
}
}
} else {
ll.put("vulnYn", CoConstDef.FLAG_NO);
}
}
// bat merget
// bat ๋ถ์ ๊ฒฐ๊ณผ ์ค์์ oss version์ด ๋ช
์๋์ง ์๊ณ , src ๋๋ 3rd party์ ๋์ผํ oss ๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
// bat ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ src ๋๋ 3rd party์ merge ํ๋ค.
List<Map<String, Object>> _list = new ArrayList<>();
List<String> adminCheckList = new ArrayList<>();
List<Map<String, Object>> groupList = null;
Map<String, List<Map<String, Object>>> srcSameLicenseMap = new HashMap<>();
List<String> egnoreList = new ArrayList<>();
for (Map<String, Object> ll : list) {
// ์ด๋ฏธ ์ถ๊ฐ๋ oss์ ๊ฒฝ์ฐ
if (egnoreList.contains((Integer.toString((int) ll.get("componentId"))))) {
continue;
}
int addIdx = -1;
if ((String) ll.get("ossName") != null && !("").equals((String) ll.get("ossName"))) {
String mergeKey = ((String) ll.get("ossName")).toUpperCase();
// main oss๋ก ํ์๋๋ bat oss์ version์ด ๋ช
์๋์ด ์์ง ์์ ๊ฒฝ์ฐ
if (CoConstDef.CD_DTL_COMPONENT_ID_BAT.equals(((String) ll.get("referenceDiv"))) && (ll.get("mergePreDiv") == null && ("").equals((String) ll.get("mergePreDiv")))
&& (ll.get("ossVersion") == null && ("").equals((String) ll.get("ossVersion")))) {
Map<String, Object> refBean = null;
if ( batMergeSrcMap.containsKey(mergeKey)) {
// bat => src
refBean = batMergeSrcMap.get(mergeKey);
// ์ค์ ๋ license๊ฐ ์์ดํ๊ณ , bat์ ๋์ผํ license๊ฐ src์ ์กด์ฌํ๋ค๋ฉด (์ต์์ ๋ฒ์ ์ด ์๋๊ฒฝ์ฐ)
// continueํ๊ณ ๋ค์ loop์์ merge
if (!isSameLicense( (List<Map<String, Object>>) refBean.get("ossComponentsLicenseList"), (List<Map<String, Object>>) ll.get("ossComponentsLicenseList"))) {
String ossNameAndVersion = findBatOssOtherVersionWithLicense(ll, refBean, list);
if (!isEmpty(ossNameAndVersion)) {
List<Map<String, Object>> _batList = null;
if (srcSameLicenseMap.containsKey(ossNameAndVersion)) {
_batList = srcSameLicenseMap.get(ossNameAndVersion);
_batList.add(ll);
srcSameLicenseMap.replace(ossNameAndVersion, _batList);
} else {
_batList = new ArrayList<>();
_batList.add(ll);
srcSameLicenseMap.put(ossNameAndVersion, _batList);
}
continue;
}
}
ll.put("ossId", refBean.get("ossId"));
ll.put("ossName", refBean.get("ossName"));
ll.put("ossVersion", refBean.get("ossVersion"));
ll.put("ossComponentsLicenseList", refBean.get("ossComponentsLicenseList"));
// ์์ ์ ๋ ฌ
addIdx = findOssAppendIndex(CoConstDef.CD_DTL_COMPONENT_ID_SRC, refBean.get("componentId"), list);
if (addIdx > -1) {
addIdx = addIdx +1;
ll.put("groupingColumn", (String) refBean.get("ossName") + (String) refBean.get("ossVersion"));
}
} else if ( batMergePartnerMap.containsKey(mergeKey)) {
// 3rd => bat
refBean = batMergePartnerMap.get(mergeKey);
// 3rd์ ๊ฐ์ ๊ทธ๋ฃน์ผ๋ก ๋ฌถ์ฌ ์๋ ๋ชจ๋ oss list๋ฅผ ์ทจ๋
ll.put("groupingColumn", (String) refBean.get("ossName") + (String) refBean.get("ossVersion"));
ll.put("ossName", refBean.get("ossName"));
ll.put("ossVersion", refBean.get("ossVersion"));
ll.put("ossId", refBean.get("ossId"));
// bin ์ ๋๋ฝ๋ ์ ๋ณด๋ฅผ 3rd์ ์ฒซ๋ฒ์ฌ row์์ ์ฑ์ ๋ฃ๋๋ค.
// DOWNLOAD_LOCATION
if (ll.get("downloadLocation") == null) {
ll.put("downloadLocation", refBean.get("downloadLocation"));
}
// HOMEPAGE
if (ll.get("homepage") == null) {
ll.put("homepage", refBean.get("homepage"));
}
// license ์ ๋ณด
ll.put("ossComponentsLicenseList", refBean.get("ossComponentsLicenseList"));
ll.put("licenseName", refBean.get("licenseName"));
ll.put("copyrightText", refBean.get("copyrightText"));
ll.put("obligationLicense", refBean.get("obligationLicense"));
ll.put("obligationType", refBean.get("obligationType"));
// 3rd party์ ์ฐ์ ์์๊ฐ ๊ฐ์ฅ ๋ฎ๊ธฐ ๋๋ฌธ์, ๋ณต์๊ฑด์ ์ทจ๋ํ๋ ๊ฒฝ์ฐ๋ ์์ง๋ง, ๊ธฐ๋ฅ ํ์ฅ์ ๊ณ ๋ คํด์ list ํ์ผ๋ก ๋ฐํ
groupList = findOssGroupList(CoConstDef.CD_DTL_COMPONENT_ID_PARTNER, (String) batMergePartnerMap.get(mergeKey).get("ossName"), (String) batMergePartnerMap.get(mergeKey).get("ossVersion"), list);
if (groupList != null && !groupList.isEmpty()) {
for (Map<String, Object> _groupBean : groupList) {
egnoreList.add((String) _groupBean.get("componentId"));
}
}
}
}
// 3rd party์ ๊ฒฝ์ฐ, bat์ ๋์ผํ oss๊ฐ ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐ (์ ๋ ฌ)
else if (CoConstDef.CD_DTL_COMPONENT_ID_PARTNER.equals((String) ll.get("referenceDiv")) && isEmpty((String) ll.get("mergePreDiv")) ) {
if (existsBatOSS((String) ll.get("ossName"), list)) {
continue;
}
}
}
// License Restriction ์ ์ฅ
ll.put("restriction", licenseRestrictionListById((String) ll.get("licenseId")));
if (addIdx > -1) {
if (addIdx > _list.size() -1) {
_list.add(ll);
} else {
_list.add(addIdx, ll);
}
} else {
_list.add(ll);
if (groupList != null && !groupList.isEmpty()) {
_list.addAll(groupList);
}
}
if (CoConstDef.FLAG_YES.equals((String) ll.get("adminCheckYn"))) {
adminCheckList.add((String) ll.get("componentId"));
}
}
// src oss์ค์์ bat์ mergeํ ์ ์๋ ๋์ผํ oss์ ์ต์ version ์ธ ๋ผ์ด์ ์ค๊น์ง ๋์ผํ bat๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ
if (!srcSameLicenseMap.isEmpty()) {
List<Map<String, Object>> _tmp = new ArrayList<>();
for (Map<String, Object> bean : _list) {
_tmp.add(bean);
String _key = (String) bean.get("ossName") + "-" + avoidNull((String) bean.get("ossVersion"));
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals((String) bean.get("referenceDiv")) && srcSameLicenseMap.containsKey(_key)) {
for (Map<String, Object> _mergeBean : srcSameLicenseMap.get(_key)) {
_mergeBean.put("ossId", bean.get("ossId"));
_mergeBean.put("ossName", bean.get("ossName"));
_mergeBean.put("ossVersion", bean.get("ossVersion"));
_mergeBean.put("ossComponentsLicenseList", bean.get("ossComponentsLicenseList"));
_mergeBean.put("groupingColumn", bean.get("groupingColumn")); // ์์ ์ ๋ ฌ
_tmp.add(_mergeBean);
}
}
}
_list = _tmp;
}
map.put("rows", _list);
if (adminCheckList.size() > 0) {
map.put("adminCheckList", adminCheckList);
}
}
return map;
}
private String checkObligationSelectedLicense(List<HashMap<String, Object>> listLicense) {
String rtnVal = "";
if (listLicense != null) {
for (Map<String, Object> bean : listLicense) {
if (!CoConstDef.FLAG_YES.equals(bean.get("excludeYn"))) {
// ํ์ธ ๊ฐ๋ฅํ ๋ผ์ด์ ์ค ์ค์์๋ง obligation ๋์์ผ๋ก ํ๋ค.
if (bean.containsKey("licenseName")) {
if (LICENSE_INFO_UPPER.containsKey(((String) bean.get("licenseName")).toUpperCase())) {
Map<String, Object> license = LICENSE_INFO_UPPER.get(((String) bean.get("licenseName")).toUpperCase());
if (CoConstDef.FLAG_YES.equals(license.get("obligationNeedsCheckYn"))) {
return CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK;
} else if (CoConstDef.FLAG_YES.equals(license.get("obligationDisclosingSrcYn"))) {
rtnVal = CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE;
} else if (isEmpty(rtnVal) && CoConstDef.FLAG_YES.equals(license.get("obligationNotificationYn"))) {
rtnVal = CoConstDef.CD_DTL_OBLIGATION_NOTICE;
}
}
}
}
}
}
return rtnVal;
}
private static String lineReplaceToBR(String s) {
return avoidNull(s).replaceAll("\r\n", "<br>").replaceAll("\r", "<br>").replaceAll("\n", "<br>");
}
@SuppressWarnings("unchecked")
private String findBatOssOtherVersionWithLicense(Map<String, Object> ll, Map<String, Object> refBean, List<HashMap<String, Object>> list) {
for (Map<String, Object> bean : list) {
if (CoConstDef.CD_DTL_COMPONENT_ID_SRC.equals((String) bean.get("referenceDiv"))
&& ((String) bean.get("ossName")).equals((String) refBean.get("ossName"))
&& !((String) bean.get("ossVersion")).equals((String) refBean.get("ossVersion"))
&& ((String) bean.get("ossName")).equals((String) ll.get("ossName"))) {
if (isSameLicense((List<Map<String, Object>>) bean.get("ossComponentsLicenseList"), (List<Map<String, Object>>) ll.get("ossComponentsLicenseList"))) {
return (String) bean.get("ossName") + "-" + avoidNull((String) bean.get("ossVersion"));
}
}
}
return null;
}
@SuppressWarnings("unchecked")
private boolean isSameLicense(List<Map<String, Object>> list1, List<Map<String, Object>> list2) {
if (list1 == null && list2 == null) {
return false;
}
if ((list1 == null && list2 != null) || (list1 != null && list2 == null)) {
return false;
}
if (list1.size() != list2.size()) {
return false;
}
List<String> licenseNames = new ArrayList<>();
for (Map<String, Object> bean : list1) {
Map<String, Object> liMaster = LICENSE_INFO.get(bean.get("licenseName"));
if (liMaster == null) {
licenseNames.add(avoidNull((String) bean.get("licenseName")));
} else {
licenseNames.add((String) liMaster.get("licenseName"));
if (liMaster.containsKey("shortIdentifier")) {
licenseNames.add((String) liMaster.get("shortIdentifier"));
}
if (liMaster.containsKey("licenseNicknameList")) {
List<String> licenseNicknameList = (List<String>) liMaster.get("licenseNicknameList");
for (String ln : licenseNicknameList) {
licenseNames.add(ln);
}
}
}
}
for (Map<String, Object> bean : list2) {
if (bean.containsKey("licenseName")) {
if (!licenseNames.contains((String) bean.get("licenseName"))) {
return false;
}
}
}
return true;
}
private int findOssAppendIndex(String type, Object object, List<HashMap<String, Object>> list) {
int idx = 0;
for (Map<String, Object> bean : list) {
if (type.equals((String) bean.get("referenceDiv")) && ((String) object).equals(bean.get("componentId"))) {
return idx;
}
idx++;
}
return -1;
}
private List<Map<String, Object>> findOssGroupList(String type, String ossName, String ossVersion, List<HashMap<String, Object>> list) {
String targetGroup = avoidNull(ossName) + avoidNull(ossVersion);
List<Map<String, Object>> groupList = new ArrayList<>();
for (Map<String, Object> bean : list) {
if (type.equals((String) bean.get("referenceDiv")) && targetGroup.equalsIgnoreCase((String) bean.get("groupingColumn"))) {
groupList.add(bean);
}
}
return groupList;
}
private boolean existsBatOSS(String ossName, List<HashMap<String, Object>> list) {
for (Map<String, Object> bean : list) {
if (CoConstDef.CD_DTL_COMPONENT_ID_BAT.equals((String) bean.get("referenceDiv")) && isEmpty((String) bean.get("mergePreDiv")) && isEmpty((String) bean.get("ossVersion"))
&& ossName.equalsIgnoreCase((String) bean.get("ossName"))) {
return true;
}
}
return false;
}
private String licenseRestrictionListById(String licenseIdStr) {
String returnStr = "";
if (licenseIdStr != null) {
String restrictionStr = "";
String licenseIdArr[] = licenseIdStr.split(",");
for (int i = 0 ; i < licenseIdArr.length ; i++) {
Map<String, Object> license = LICENSE_INFO_BY_ID.get(licenseIdArr[i]);
if (license != null && license.containsKey("restriction") && !("").equals(license.get("restriction"))) {
restrictionStr += (isEmpty(restrictionStr)?"":",") + (String) license.get("restriction");
}
}
String restrictionArr[] = restrictionStr.split(",");
List<String> restrictionList = new ArrayList<>();
List<String> distinctList = new ArrayList<String>();
// String ๋ฐฐ์ด -> String ๋ฆฌ์คํธ
for (int i = 0 ; i < restrictionArr.length ; i++){
restrictionList.add(restrictionArr[i]);
}
// ์ค๋ณต ์ ๊ฑฐ
for (String str : restrictionList){
if (!distinctList.contains(str)) {
distinctList.add(str);
}
}
for (String str : distinctList){
if (!("").equals(str)) {
returnStr += (isEmpty(returnStr)?"":"\n") + CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, str.trim().toUpperCase());
}
}
}
return returnStr;
}
private HashMap<String, Object> findOssIdAndName(HashMap<String, Object> bean) {
if (bean != null && bean.containsKey("ossName")) {
if ("N/A".equals((String) bean.get("ossVersion"))) {
bean.put("ossVersion", "");
}
String findKey = ((String) bean.get("ossName")).trim() +"_";
if (bean.containsKey("ossVersion")) {
findKey = ((String) bean.get("ossVersion")).trim();
}
findKey = findKey.toUpperCase();
Map<String, Object> masterBean = OSS_INFO_UPPER.get(findKey);
if (masterBean != null) {
bean.put("ossId", masterBean.get("ossId"));
bean.put("ossName", masterBean.get("ossName"));
}
}
return bean;
}
@SuppressWarnings("unchecked")
private List<HashMap<String, Object>> findOssLicenseIdAndName(HashMap<String, Object> bean) {
List<HashMap<String, Object>> ossComponentsLicenseList = null;
List<HashMap<String, Object>> returnOssComponentsLicenseList = new ArrayList<>();
// ๋จผ์ license Id๋ ์ฐพ์์ ์์ผ๋ฉด ๋ชจ๋ ์ค์ ํ๋ค.
if (bean.containsKey("ossComponentsLicenseList")) {
ossComponentsLicenseList = (List<HashMap<String, Object>>) bean.get("ossComponentsLicenseList");
for (HashMap<String, Object> licenseBean : ossComponentsLicenseList) {
if (licenseBean.containsKey("licenseName")) {
HashMap<String, Object> licenseMaster = (HashMap<String, Object>) LICENSE_INFO_UPPER.get(avoidNull(((String) licenseBean.get("licenseName")), "").trim().toUpperCase());
if (licenseMaster != null) {
licenseBean.put("licenseId", licenseMaster.get("licenseId"));
if (licenseMaster.containsKey("shortIdentifier") && !("").equals(licenseMaster.get("shortIdentifier"))) {
licenseBean.put("licenseName", licenseMaster.get("shortIdentifier"));
}else {
licenseBean.put("licenseName", licenseMaster.get("licenseName"));
}
// OSS_LICENSE ์ ์ค์ ๊ฐ์ด ์๋ ๊ฒฝ์ฐ ์ฐ์ ์ผ๋ก ์ค์ ํ์ง๋ง, ์๋ ๊ฒฝ์ฐ license master๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค์ ํ๊ธฐ ๋๋ฌธ์ ์ผ๋จ ์ฌ๊ธฐ์๋ master๊ธฐ์ค์ผ๋ก ์ค์
licenseBean.put("licenseText", licenseMaster.get("licenseText"));
}
returnOssComponentsLicenseList.add(licenseBean);
}
}
}
// oss์์ ์ถ๊ฐ์ค์ ํ license text ๋ฐ oss copyright ์ค์
if (bean.containsKey("ossId")) {
HashMap<String, Object> ossMaster = (HashMap<String, Object>) OSS_INFO_BY_ID.get(Integer.toString((int) bean.get("ossId")));
if (ossMaster != null) {
// oss master์ ๋ฑ๋ก๋ licnese์์ ๊ธฐ์ค์ผ๋ก ์ฐพ๋๋ค (๊ธฐ๋ณธ์ ์ผ๋ก size๊ฐ ์ผ์น ํด์ผํจ, multi dual license์ ๊ฒฝ์ฐ)
if (ossMaster.containsKey("ossLicenses")) {
List<HashMap<String, Object>> ossLicensesList = (List<HashMap<String, Object>>) ossMaster.get("ossLicenses");
if (ossLicensesList != null && ossLicensesList.size() > 0) {
for (int i=0; i<ossLicensesList.size(); i++) {
HashMap<String, Object> ossLicense = ossLicensesList.get(i);
if (returnOssComponentsLicenseList.size() >= i+1
&& ossLicense.get("licenseId").equals(returnOssComponentsLicenseList.get(i).get("licenseId"))) {
// license text
// oss_license์ ์กด์ฌํ๋ ๊ฒฝ์ฐ๋ง ์ค์
if (ossLicense.containsKey("ossLicenseText") && ossLicense.get("ossLicenseText") != null && ((String) ossLicense.get("ossLicenseText")).length() > 0) {
returnOssComponentsLicenseList.get(i).put("licenseText", ossLicense.get("ossLicenseText"));
}
// oss copyright
if (ossLicense.containsKey("ossCopyright") && ossLicense.get("ossCopyright") != null && ((String) ossLicense.get("ossCopyright")).length() > 0) {
returnOssComponentsLicenseList.get(i).put("copyrightText", ossLicense.get("ossCopyright"));
}
}
}
}
}
}
}
return returnOssComponentsLicenseList;
}
@Override
public int existProjectCntBomCompare(Map<String, Object> paramMap) {
String ossReportFlag = (String) paramMap.get("ossReportFlag");
@SuppressWarnings("unchecked")
List<String> prjIdList = (List<String>) paramMap.get("prjId");
if (prjIdList != null) {
if (isEmpty(ossReportFlag)) {
ossReportFlag = CoConstDef.FLAG_NO;
paramMap.put("ossReportFlag", ossReportFlag);
}
return apiProjectMapper.selectProjectCount(paramMap);
}
return 0;
}
@Override
public boolean existLdapUserToEmail(String email) {
boolean ldapCheckFlag = false;
try {
LdapTemplate ldapTemplate = new LdapTemplate(makeLdapContextSource());
ldapTemplate.afterPropertiesSet();
@SuppressWarnings({ "unchecked", "rawtypes" })
List<String[]> result = ldapTemplate.search(query().where("mail").is(email), new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
return new String[]{(String)attrs.get("mail").get(), (String)attrs.get("displayname").get()};
}
});
if (result != null && !result.isEmpty()) ldapCheckFlag = true;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return ldapCheckFlag;
}
private LdapContextSource makeLdapContextSource() {
String LDAP_SEARCH_DOMAIN = CoCodeManager.getCodeExpString(CoConstDef.CD_LOGIN_SETTING, CoConstDef.CD_LDAP_DOMAIN);
String LDAP_SEARCH_ID = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_ID);
String LDAP_SEARCH_PW = CoCodeManager.getCodeExpString(CoConstDef.CD_LDAP_SEARCH_INFO, CoConstDef.CD_DTL_LDAP_SEARCH_PW);
LdapContextSource contextSource = new LdapContextSource();
try {
contextSource.setUrl(CoConstDef.AD_LDAP_LOGIN.LDAP_SERVER_URL.getValue());
contextSource.setBase("OU=LGE Users, DC=LGE, DC=NET");
contextSource.setUserDn(LDAP_SEARCH_ID+LDAP_SEARCH_DOMAIN);
contextSource.setPassword(LDAP_SEARCH_PW);
CommonFunction.setSslWithCert();
contextSource.afterPropertiesSet();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return contextSource;
}
@Override
public boolean existsWatcherByEmail(String prjId, String email) {
return apiProjectMapper.existsWatcherByEmail(prjId, email) > 0 ? false : true;
}
@Override
public void insertWatcher(Map<String, Object> paramMap) {
apiProjectMapper.insertWatcher(paramMap);
}
@Override
public Map<String, Object> selectProjectMaster(String prjId) {
Map<String, Object> param = new HashMap<>();
param.put("prjId", prjId);
return apiProjectMapper.selectProjectMaster(param);
}
@SuppressWarnings("unchecked")
@Override
public void getIdentificationGridList(String prjId, String code, List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentsLicenseList, List<Map<String, Object>> gridDataList) {
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(prjId);
identification.setReferenceDiv(code);
Map<String, Object> map = projectService.getIdentificationGridList(identification, true);
if (gridDataList != null) {
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_ANDROID);
pv.setAppendix("projectId", avoidNull(identification.getReferenceId()));
pv.setAppendix("mainList", (List<ProjectIdentification>) map.get("mainData"));
pv.setAppendix("subListMap", (Map<String, List<ProjectIdentification>>) map.get("subData"));
T2CoValidationResult vr = pv.validate(new HashMap<>());
map.replace("mainData", CommonFunction.identificationSortByValidInfo((List<ProjectIdentification>) map.get("mainData"), vr.getValidMessageMap(), vr.getDiffMessageMap(), vr.getInfoMessageMap(), false, true));
}
if (map.containsKey("mainData")) {
List<ProjectIdentification> gridDatas = (List<ProjectIdentification>) map.get("mainData");
if (gridDatas != null && !gridDatas.isEmpty()) {
if (gridDataList == null) {
List<List<ProjectIdentification>> gridDataLicenses = CommonFunction.setOssComponentLicense(gridDatas);
Map<String, Object> remakeComponentsMap = CommonFunction.remakeMutiLicenseComponents(gridDatas, gridDataLicenses);
ossComponentList.addAll((List<ProjectIdentification>) remakeComponentsMap.get("mainList"));
ossComponentsLicenseList.addAll((List<List<ProjectIdentification>>) remakeComponentsMap.get("subList"));
} else {
for (ProjectIdentification gridData : gridDatas) {
Map<String, Object> gridMap = new HashMap<>();
gridMap.put("ossName", avoidNull(gridData.getOssName()));
gridMap.put("ossVersion", avoidNull(gridData.getOssVersion()));
gridMap.put("licenseType", avoidNull(gridData.getLicenseType()));
gridMap.put("licenseName", avoidNull(gridData.getLicenseName()));
gridDataList.add(gridMap);
}
}
}
}
}
@Override
public void registDepOss(List<ProjectIdentification> ossComponent, List<List<ProjectIdentification>> ossComponentLicense, Project project, String refDiv) {
// ํ๊ฑด๋ ์์์ ํ๋ก์ ํธ ๋ง์คํฐ SRC ์ฌ์ฉ๊ฐ๋ฅ์ฌ๋ถ๊ฐ N์ด๋ฉด N ๊ทธ์ธ null
if(ossComponent.size()==0){
Project projectSubStatus = new Project();
projectSubStatus.setPrjId(project.getPrjId());
if(!StringUtil.isEmpty(project.getIdentificationSubStatusDep())){
projectSubStatus.setIdentificationSubStatusDep(project.getIdentificationSubStatusDep());
} else {
projectSubStatus.setIdentificationSubStatusDep("X");
}
projectSubStatus.setModifier(projectSubStatus.getLoginUserName());
projectSubStatus.setReferenceDiv(refDiv);
projectMapper.updateProjectMaster(projectSubStatus);
}
ossComponentLicense = convertLicenseNickName(ossComponentLicense);
String refId = project.getReferenceId();
updateOssComponentList(project, refDiv, refId, ossComponent, ossComponentLicense);
// ํ์ผ ๋ฑ๋ก
if(!isEmpty(project.getDepCsvFileId())){
projectMapper.updateFileId(project);
if(project.getCsvFileSeq() != null) {
for (int i = 0; i < project.getCsvFileSeq().size(); i++) {
projectMapper.updateFileBySeq(project.getCsvFileSeq().get(i));
}
}
}
}
private void updateOssComponentList(Project project, String refDiv, String refId, List<ProjectIdentification> ossComponent, List<List<ProjectIdentification>> ossComponentLicense) {
// ์ปดํฌ๋ํธ ๋ง์คํฐ ๋ผ์ด์ผ์ค ์ง์ฐ๊ธฐ
ProjectIdentification prj = new ProjectIdentification();
if(isEmpty(refId)) {
refId = project.getPrjId();
}
prj.setReferenceId(refId);
prj.setReferenceDiv(refDiv);
List<OssComponents> componentId = projectMapper.selectComponentId(prj);
for (int i = 0; i < componentId.size(); i++) {
projectMapper.deleteOssComponentsLicense(componentId.get(i));
}
if(!ossComponent.isEmpty()) {
Project projectStatus = new Project();
projectStatus.setPrjId(refId);
projectStatus = projectMapper.selectProjectMaster(projectStatus);
if(!StringUtil.isEmpty(project.getIdentificationSubStatusDep())){
projectStatus.setIdentificationSubStatusDep(project.getIdentificationSubStatusDep());
} else {
projectStatus.setIdentificationSubStatusDep(CoConstDef.FLAG_YES);
}
projectStatus.setModifier(projectStatus.getLoginUserName());
projectMapper.updateProjectMaster(projectStatus);
}
project.setReferenceDiv(refDiv);
project.setReferenceId(refId);
int ossComponentIdx = projectMapper.selectOssComponentMaxIdx(project);
//deleteRows
List<String> deleteRows = new ArrayList<String>();
// ์ปดํฌ๋ํธ ๋ฑ๋ก
for (int i = 0; i < ossComponent.size(); i++) {
// SRC STATUS ๋ฑ๋ก
ProjectIdentification ossBean = ossComponent.get(i);
// oss_id๋ฅผ ๋ค์ ์ฐพ๋๋ค. (oss name๊ณผ oss id๊ฐ ์ผ์นํ์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ ์ ์์)
ossBean = CommonFunction.findOssIdAndName(ossBean);
if (isEmpty(ossBean.getOssId())) {
ossBean.setOssId(null);
}
String downloadLocationUrl = ossBean.getDownloadLocation();
String homepageUrl = ossBean.getHomepage();
if (!isEmpty(downloadLocationUrl)) {
if (downloadLocationUrl.endsWith("/")) {
ossBean.setDownloadLocation(downloadLocationUrl.substring(0, downloadLocationUrl.length()-1));
}
}
if (!isEmpty(homepageUrl)) {
if (homepageUrl.endsWith("/")) {
ossBean.setHomepage(homepageUrl.substring(0, homepageUrl.length()-1));
}
}
//update
if (!ossBean.getGridId().contains(CoConstDef.GRID_NEWROW_DEFAULT_PREFIX)){
//ossComponents ๋ฑ๋ก
// android project์ ๊ฒฝ์ฐ, bom ์ฒ๋ฆฌ๋ฅผ ํ์ง ์๊ธฐ ๋๋ฌธ์, bom save์์ ์ฒ๋ฆฌํ๋ obligation type์ ์ฌ๊ธฐ์ ์ค์ ํด์ผํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(refDiv)) {
List<OssComponentsLicense> _list = new ArrayList<>();
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())) {
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (ossBean.getComponentId().equals(comLicense.getComponentId())){
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if (isEmpty(comLicense.getLicenseName()) && isEmpty(comLicense.getLicenseText()) && isEmpty(comLicense.getOssCopyright())) {
continue;
}
_list.add(CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI));
}
}
}
} else {
_list.add(CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE));
}
ossBean.setObligationType(CommonFunction.checkObligationSelectedLicense(_list));
ossBean.setBomWithAndroidFlag(CoConstDef.FLAG_YES);
}
projectMapper.updateSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())){
List<String> duplicateLicense = new ArrayList<String>();
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
if (ossBean.getComponentId().equals(comLicense.getComponentId())){
if (!isEmpty(comLicense.getLicenseId()) && duplicateLicense.contains(comLicense.getLicenseId())) {
continue;
}
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if ((isEmpty(comLicense.getLicenseName())
&& isEmpty(comLicense.getLicenseText())
&& isEmpty(comLicense.getOssCopyright()))) {
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
projectMapper.registComponentLicense(license);
break;
}
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
duplicateLicense.add(comLicense.getLicenseId());
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { //์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
} else { //insert
//ossComponents ๋ฑ๋ก
String exComponentId = ossBean.getGridId();
ossBean.setReferenceId(refId);
ossBean.setReferenceDiv(refDiv);
// android project์ ๊ฒฝ์ฐ, bom ์ฒ๋ฆฌ๋ฅผ ํ์ง ์๊ธฐ ๋๋ฌธ์, bom save์์ ์ฒ๋ฆฌํ๋ obligation type์ ์ฌ๊ธฐ์ ์ค์ ํด์ผํ๋ค.
if (CoConstDef.CD_DTL_COMPONENT_ID_ANDROID.equals(refDiv)) {
List<OssComponentsLicense> _list = new ArrayList<>();
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())) {
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
String gridId = comLicense.getGridId();
if (isEmpty(gridId)) {
continue;
}
gridId = gridId.split("-")[0];
if (exComponentId.equals(comLicense.getComponentId())
|| exComponentId.equals(gridId)){
_list.add(CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI));
}
}
}
} else {
_list.add(CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE));
}
ossBean.setObligationType(CommonFunction.checkObligationSelectedLicense(_list));
ossBean.setBomWithAndroidFlag(CoConstDef.FLAG_YES);
}
// insert์ ๋งค๋ฒ max idx๋ฅผ select ํ๋ฉด
ossBean.setComponentIdx(Integer.toString(ossComponentIdx++));
projectMapper.insertSrcOssList(ossBean);
deleteRows.add(ossBean.getComponentId());
//๋ฉํฐ๋ผ์ด์ผ์ค์ผ ๊ฒฝ์ฐ
if (CoConstDef.LICENSE_DIV_MULTI.equals(ossBean.getLicenseDiv())){
List<String> duplicateLicense = new ArrayList<String>();
for (List<ProjectIdentification> comLicenseList : ossComponentLicense) {
for (ProjectIdentification comLicense : comLicenseList) {
String gridId = comLicense.getGridId();
if (isEmpty(gridId)) {
continue;
}
gridId = gridId.split("-")[0];
if (exComponentId.equals(comLicense.getComponentId()) || exComponentId.equals(gridId)){
if (!isEmpty(comLicense.getLicenseId()) && duplicateLicense.contains(comLicense.getLicenseId())) {
continue;
}
// multi license oss์ license๋ฅผ ์ถ๊ฐํ ๊ฒฝ์ฐ, license ๋ช
์ ์
๋ ฅํ์ง ์์ ๊ฒฝ์ฐ๋ ๋ฌด์
if ((isEmpty(comLicense.getLicenseName())
&& isEmpty(comLicense.getLicenseText())
&& isEmpty(comLicense.getOssCopyright()))) {
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
projectMapper.registComponentLicense(license);
break;
}
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(comLicense, CoConstDef.LICENSE_DIV_MULTI);
// ์ปดํฌ๋ํธ ID ์ค์
license.setComponentId(ossBean.getComponentId());
duplicateLicense.add(comLicense.getLicenseName());
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
} else { // ์ฑ๊ธ๋ผ์ด์ผ์ค์ผ๊ฒฝ์ฐ
OssComponentsLicense license = CommonFunction.reMakeLicenseBean(ossBean, CoConstDef.LICENSE_DIV_SINGLE);
// ๋ผ์ด์ผ์ค ๋ฑ๋ก
projectMapper.registComponentLicense(license);
}
}
}
// delete
OssComponents param = new OssComponents();
param.setReferenceDiv(refDiv);
param.setReferenceId(refId);
param.setOssComponentsIdList(deleteRows);
projectMapper.deleteOssComponentsWithIds(param);
}
private List<List<ProjectIdentification>> convertLicenseNickName(List<List<ProjectIdentification>> ossComponentLicenseList) {
if(ossComponentLicenseList != null) {
for(List<ProjectIdentification> licenseList : ossComponentLicenseList) {
for (ProjectIdentification licenseBean : licenseList) {
String _licenseName = avoidNull(licenseBean.getLicenseName()).trim();
if(CoCodeManager.LICENSE_INFO_UPPER.containsKey(_licenseName.toUpperCase())) {
LicenseMaster licenseMaster = CoCodeManager.LICENSE_INFO_UPPER.get(_licenseName.toUpperCase());
if(licenseMaster.getLicenseNicknameList() != null && !licenseMaster.getLicenseNicknameList().isEmpty()) {
for(String s : licenseMaster.getLicenseNicknameList()) {
if(_licenseName.equalsIgnoreCase(s)) {
licenseBean.setLicenseName(avoidNull(licenseMaster.getShortIdentifier(), licenseMaster.getLicenseNameTemp()));
break;
}
}
}
}
}
}
}
return ossComponentLicenseList;
}
@Override
public void updateSubStatus(Map<String, Object> param) {
apiProjectMapper.updateProjectSubStatus(param);
List<String> componentIds = apiProjectMapper.selectComponentId(param);
for (String componentId : componentIds) {
apiProjectMapper.deleteOssComponentsLicense(componentId);
}
apiProjectMapper.deleteOssComponents(param);
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> getProcessSheetData(Map<String, Object> result, String prjId, String resetFlag, String registFileId, String userId,
String comment, String tabGubn, String sheetName, boolean sheetNamesEmptyFlag, boolean loopFlag, int sheetIdx) {
Map<String, Object> rtnMap = new HashMap<>();
String errorMsg = (String) result.get("errorMessage");
if (!isEmpty(errorMsg) && errorMsg.toUpperCase().startsWith("THERE ARE NO OSS LISTED")) {
rtnMap.put(CoConstDef.CD_OPEN_API_FILE_DATA_EMPTY_MESSAGE, CoCodeManager.getCodeString(CoConstDef.CD_OPEN_API_MESSAGE, CoConstDef.CD_OPEN_API_FILE_DATA_EMPTY_MESSAGE));
return rtnMap;
}
List<ProjectIdentification> ossComponents = (List<ProjectIdentification>) result.get("ossComponents");
ossComponents = (ossComponents != null ? ossComponents : new ArrayList<>());
List<List<ProjectIdentification>> ossComponentsLicense = (List<List<ProjectIdentification>>) result.get("ossComponentLicense");
if (ossComponents.isEmpty()) {
rtnMap.put(CoConstDef.CD_OPEN_API_FILE_DATA_EMPTY_MESSAGE, sheetNamesEmptyFlag ? getMessage("api.upload.file.sheet.no.match", new String[]{sheetName + "*"}) : getMessage("api.upload.file.sheet.no.match", new String[]{sheetName}));
return rtnMap;
}
if (!isEmpty(errorMsg)) {
rtnMap.put("errorMessage", errorMsg);
}
T2CoProjectValidator pv = new T2CoProjectValidator();
pv.setProcType(pv.PROC_TYPE_IDENTIFICATION_SOURCE);
pv.setValidLevel(pv.VALID_LEVEL_BASIC);
pv.setAppendix("mainList", ossComponents); // sub grid
pv.setAppendix("subList", ossComponentsLicense);
T2CoValidationResult vr = pv.validate(new HashMap<>());
if (!vr.isValid()) {
rtnMap.put("validError", "validError");
return rtnMap;
} else {
List<ProjectIdentification> ossComponentList = new ArrayList<>();
List<List<ProjectIdentification>> ossComponentsLicenseList = new ArrayList<>();
if (CoConstDef.FLAG_NO.equals(avoidNull(resetFlag)) || (loopFlag && sheetIdx > 0)) {
getIdentificationGridList(prjId, tabGubn.equals("DEP") ? CoConstDef.CD_DTL_COMPONENT_ID_DEP : CoConstDef.CD_DTL_COMPONENT_ID_SRC, ossComponentList, ossComponentsLicenseList, null);
}
ossComponentList.addAll(ossComponents);
ossComponentsLicenseList.addAll(ossComponentsLicense);
Project project = new Project();
project.setPrjId(prjId);
if (tabGubn.equals("DEP")) {
project.setDepCsvFileId(registFileId); // set file id
registDepOss(ossComponentList, ossComponentsLicenseList, project, CoConstDef.CD_DTL_COMPONENT_ID_DEP);
} else {
project.setSrcCsvFileId(registFileId); // set file id
projectService.registSrcOss(ossComponentList, ossComponentsLicenseList, project);
}
// oss name์ด nick name์ผ๋ก ๋ฑ๋ก๋์ด ์๋ ๊ฒฝ์ฐ, ์๋์นํ๋ Data๋ฅผ comment his์ ๋ฑ๋ก
try {
if (getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_NICKNAME_CHANGED, prjId, CoConstDef.CD_DTL_COMPONENT_ID_DEP)) != null) {
String changedLicenseName = (String) getSessionObject(CommonFunction.makeSessionKey(loginUserName(),
CoConstDef.SESSION_KEY_NICKNAME_CHANGED, prjId, CoConstDef.CD_DTL_COMPONENT_ID_DEP), true);
if (!isEmpty(changedLicenseName)) {
CommentsHistory commentHisBean = new CommentsHistory();
commentHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commentHisBean.setReferenceId(prjId);
commentHisBean.setExpansion1(tabGubn);
commentHisBean.setContents(changedLicenseName);
commentHisBean.setLoginUserName(userId);
commentService.registComment(commentHisBean, false);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
if (comment != null) {
CommentsHistory commentHisBean = new CommentsHistory();
commentHisBean.setReferenceDiv(CoConstDef.CD_DTL_COMMENT_IDENTIFICAITON_HIS);
commentHisBean.setReferenceId(prjId);
commentHisBean.setExpansion1(tabGubn);
commentHisBean.setContents(comment);
commentHisBean.setLoginUserName(userId);
commentService.registComment(commentHisBean, false);
}
try {
History h = new History();
h = projectService.work(project);
h.sethAction(CoConstDef.ACTION_CODE_UPDATE);
project = (Project) h.gethData();
h.sethEtc(project.etcStr());
historyService.storeData(h);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return rtnMap;
}
} | 135,556 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ApiSelfCheckServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/ApiSelfCheckServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.ProjectIdentification;
import oss.fosslight.repository.ApiSelfCheckMapper;
import oss.fosslight.service.ApiSelfCheckService;
import oss.fosslight.service.SelfCheckService;
@Service
public class ApiSelfCheckServiceImpl implements ApiSelfCheckService {
@Autowired SelfCheckService selfCheckService;
@Autowired ApiSelfCheckMapper apiSelfcheckMapper;
@Override
public int getCreateProjectCnt(String userId) {
return apiSelfcheckMapper.getCreateProjectCnt(userId);
}
@Transactional
@Override
public Map<String, Object> createSelfCheck(Map<String, Object> paramMap){
Map<String, Object> result = new HashMap<String, Object>();
apiSelfcheckMapper.createSelfCheck(paramMap);
Long prjId = (Long) paramMap.get("prjId");
result.put("prjId", prjId.toString());
return result;
}
@Override
public boolean existProjectCnt(Map<String, Object> paramMap) {
int records = apiSelfcheckMapper.selectProjectCount(paramMap);
return records == 1 ? true : false;
}
@Override
public Map<String, Object> selectProjectMaster(String prjId) {
return apiSelfcheckMapper.selectProjectMaster(prjId);
}
@SuppressWarnings("unchecked")
@Override
public void getIdentificationGridList(String prjId, String code, List<ProjectIdentification> ossComponentList, List<List<ProjectIdentification>> ossComponentsLicenseList) {
ProjectIdentification identification = new ProjectIdentification();
identification.setReferenceId(prjId);
identification.setReferenceDiv(code);
Map<String, Object> map = selfCheckService.getIdentificationGridList(identification);
if (map.containsKey("mainData")) {
List<ProjectIdentification> gridDatas = (List<ProjectIdentification>) map.get("mainData");
if (gridDatas != null && !gridDatas.isEmpty()) {
List<List<ProjectIdentification>> gridDataLicenses = CommonFunction.setOssComponentLicense(gridDatas);
Map<String, Object> remakeComponentsMap = CommonFunction.remakeMutiLicenseComponents(gridDatas, gridDataLicenses);
ossComponentList.addAll((List<ProjectIdentification>) remakeComponentsMap.get("mainList"));
ossComponentsLicenseList.addAll((List<List<ProjectIdentification>>) remakeComponentsMap.get("subList"));
}
}
}
@Override
public boolean existsWatcherByEmail(String prjId, String email) {
return apiSelfcheckMapper.existsWatcherByEmail(prjId, email) > 0 ? false : true;
}
@Override
public void insertWatcher(Map<String, Object> paramMap) {
apiSelfcheckMapper.insertWatcher(paramMap);
}
} | 3,000 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SystemConfigurationServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/SystemConfigurationServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.domain.T2CodeDtl;
import oss.fosslight.repository.CodeMapper;
import oss.fosslight.service.CodeService;
import oss.fosslight.service.SystemConfigurationService;
@Service
@Slf4j
public class SystemConfigurationServiceImpl extends CoTopComponent implements SystemConfigurationService {
// Service
@Autowired CodeService codeService;
// Mapper
@Autowired CodeMapper codeMapper;
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> saveConfiguration(Map<String, Object> configurationMap) throws Exception {
Map<String, Object> result = new HashMap<String, Object>();
String resCd = "10";
String resMsg = "Success";
// load detail code
T2CodeDtl systemSettingAuth = new T2CodeDtl(CoConstDef.CD_SYSTEM_SETTING);
List<T2CodeDtl> systemSettingAuthList = codeMapper.selectCodeDetailList(systemSettingAuth);
T2CodeDtl loginAuth = new T2CodeDtl(CoConstDef.CD_LOGIN_SETTING);
List<T2CodeDtl> loginAuthList = codeMapper.selectCodeDetailList(loginAuth);
// T2CodeDtl smtpAuth = new T2CodeDtl(CoConstDef.CD_SMTP_SETTING);
// List<T2CodeDtl> smtpAuthList = codeMapper.selectCodeDetailList(smtpAuth);
//
// T2CodeDtl externalServiceAuth = new T2CodeDtl(CoConstDef.CD_EXTERNAL_SERVICE_SETTING);
// List<T2CodeDtl> tokenAuthList = codeMapper.selectCodeDetailList(externalServiceAuth);
T2CodeDtl externalAnalysisAuth = new T2CodeDtl(CoConstDef.CD_EXTERNAL_ANALYSIS_SETTING);
List<T2CodeDtl> externalAnalysisAuthList = codeMapper.selectCodeDetailList(externalAnalysisAuth);
T2CodeDtl defaultTab = new T2CodeDtl(CoConstDef.CD_DEFAULT_TAB);
List<T2CodeDtl> defaultTabList = codeMapper.selectCodeDetailList(defaultTab);
T2CodeDtl projectDetail = new T2CodeDtl(CoConstDef.CD_PROJECT_DETAIL);
List<T2CodeDtl> projectDetailList = codeMapper.selectCodeDetailList(projectDetail);
// system auth setting
systemSettingAuthList.stream().map(c -> {
switch(c.getCdDtlNo()) {
case CoConstDef.CD_LDAP_USED_FLAG:
c.setCdDtlExp((String) configurationMap.get("loginFlag"));
break;
// case CoConstDef.CD_SMTP_USED_FLAG:
// c.setCdDtlExp((String) configurationMap.get("smtpFlag"));
//
// break;
// case CoConstDef.CD_EXTERNAL_SERVICE_USED_FLAG:
// c.setCdDtlExp((String) configurationMap.get("externalServiceFlag"));
//
// break;
case CoConstDef.CD_EXTERNAL_ANALYSIS_USED_FLAG:
c.setCdDtlExp((String) configurationMap.get("externalAnalysisFlag"));
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(systemSettingAuthList, CoConstDef.CD_SYSTEM_SETTING);
// login detail setting
Map<String, Object> loginDetailMap = (Map<String, Object>) configurationMap.get("loginDetail");
if (loginDetailMap != null) {
loginAuthList.stream().map(c -> {
switch (c.getCdDtlNo()) {
case CoConstDef.CD_LDAP_SERVER_URL:
c.setCdDtlExp((String) loginDetailMap.get(CoConstDef.CD_LDAP_SERVER_URL));
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(loginAuthList, CoConstDef.CD_LOGIN_SETTING);
}
// smtp detail setting
// Map<String, Object> smtpDetailMap = (Map<String, Object>) configurationMap.get("smtpDetail");
//
// if (smtpDetailMap != null) {
// smtpAuthList.stream().map(c -> {
// switch(c.getCdDtlNo()) {
// case CoConstDef.CD_SMTP_SERVICE_HOST:
// c.setCdDtlExp((String) smtpDetailMap.get(CoConstDef.CD_SMTP_SERVICE_HOST));
//
// break;
// case CoConstDef.CD_SMTP_EMAIL_ADDRESS:
// c.setCdDtlExp((String) smtpDetailMap.get(CoConstDef.CD_SMTP_EMAIL_ADDRESS));
//
// break;
// case CoConstDef.CD_SMTP_SERVICE_PORT:
// c.setCdDtlExp((String) smtpDetailMap.get(CoConstDef.CD_SMTP_SERVICE_PORT));
//
// break;
// case CoConstDef.CD_SMTP_SERVICE_ENCODING:
// c.setCdDtlExp((String) smtpDetailMap.get(CoConstDef.CD_SMTP_SERVICE_ENCODING));
//
// break;
// case CoConstDef.CD_SMTP_SERVICE_USERNAME:
// c.setCdDtlExp((String) smtpDetailMap.get(CoConstDef.CD_SMTP_SERVICE_USERNAME));
//
// break;
// case CoConstDef.CD_SMTP_SERVICE_PASSWORD:
// String _pw = (String) smtpDetailMap.get(CoConstDef.CD_SMTP_SERVICE_PASSWORD);
// if (!StringUtil.isEmpty(_pw)) {
// String _encPw = null;
// try {
// _encPw = CryptUtil.encryptAES256(_pw, CoConstDef.ENCRYPT_DEFAULT_SALT_KEY);
// } catch (Exception e) {
// log.error(e.getMessage());
// }
// if (!StringUtil.isEmpty(_encPw)) {
// c.setCdDtlExp(_encPw);
// }
// }
// break;
// }
//
// return c;
// }).collect(Collectors.toList());
//
// codeService.setCodeDetails(smtpAuthList, CoConstDef.CD_SMTP_SETTING);
// }
// External Service setting
// Map<String, Object> tokenDetailMap = (Map<String, Object>) configurationMap.get("externalServiceDetail");
//
// if (tokenDetailMap != null) {
// tokenAuthList.stream().map(c -> {
// switch (c.getCdDtlNo()) {
// case CoConstDef.CD_DTL_GITHUB_TOKEN:
// String token = (String) tokenDetailMap.get(CoConstDef.CD_DTL_GITHUB_TOKEN);
// if (!token.isEmpty()) {
// c.setCdDtlExp(token);
// }
// break;
// }
//
// return c;
// }).collect(Collectors.toList());
//
// codeService.setCodeDetails(tokenAuthList, CoConstDef.CD_EXTERNAL_SERVICE_SETTING);
// }
// External Analysis detail setting
Map<String, Object> externalAnalysisDetailMap = (Map<String, Object>) configurationMap.get("externalAnalysisDetail");
if (externalAnalysisDetailMap != null) {
externalAnalysisAuthList.stream().map(c -> {
switch(c.getCdDtlNo()) {
case CoConstDef.CD_DTL_FL_SCANNER_URL:
c.setCdDtlExp((String) externalAnalysisDetailMap.get(CoConstDef.CD_DTL_FL_SCANNER_URL));
break;
case CoConstDef.CD_DTL_ADMIN_TOKEN:
c.setCdDtlExp((String) externalAnalysisDetailMap.get(CoConstDef.CD_DTL_ADMIN_TOKEN));
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(externalAnalysisAuthList, CoConstDef.CD_EXTERNAL_ANALYSIS_SETTING);
}
// default tab Setting
defaultTabList.stream().map(c -> {
switch(c.getCdDtlNo()) {
case CoConstDef.CD_MENU_DASHBOARD:
c.setUseYn(CommonFunction.emptyCheckProperty("menu.dashboard.use.flag", CoConstDef.FLAG_NO));
break;
case CoConstDef.CD_MENU_PROJECT_LIST:
c.setUseYn(CommonFunction.emptyCheckProperty("menu.project.use.flag", CoConstDef.FLAG_NO));
break;
case CoConstDef.CD_MENU_PARTNER_LIST:
c.setUseYn(CommonFunction.emptyCheckProperty("menu.partner.use.flag", CoConstDef.FLAG_NO));
break;
case CoConstDef.CD_MENU_BAT_LIST:
c.setUseYn(CommonFunction.emptyCheckProperty("menu.bat.use.flag", CoConstDef.FLAG_NO));
break;
case CoConstDef.CD_MENU_BINARY_DB:
c.setUseYn(CommonFunction.emptyCheckProperty("menu.binarydb.use.flag", CoConstDef.FLAG_NO));
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(defaultTabList, CoConstDef.CD_DEFAULT_TAB);
Map<String, Object> projectDetailMap = (Map<String, Object>) configurationMap.get("projectDetail");
if (projectDetailMap != null) {
projectDetailList.stream().map(c -> {
switch(c.getCdDtlNo()) {
case CoConstDef.CD_AUTO_ANALYSIS_FLAG:
c.setCdDtlExp((String) projectDetailMap.get("autoAnalysisFlag"));
break;
case CoConstDef.CD_NOTICE_FLAG:
c.setCdDtlExp(CoConstDef.FLAG_YES);
configurationMap.put("noticeDetailCd", c.getCdSubNo());
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(projectDetailList, CoConstDef.CD_PROJECT_DETAIL);
}
String noticeDetailCd = (String) configurationMap.get("noticeDetailCd");
T2CodeDtl noticeDetail = new T2CodeDtl(noticeDetailCd);
List<T2CodeDtl> noticeDetailList = codeMapper.selectCodeDetailList(noticeDetail);
Map<String, Object> noticeDetailMap = (Map<String, Object>) configurationMap.get("noticeDetail");
if (noticeDetailMap != null) {
noticeDetailList.stream().map(c -> {
switch(c.getCdDtlNo()) {
case CoConstDef.CD_DTL_NOTICE_HTML:
c.setCdDtlExp(CoConstDef.FLAG_YES);
break;
case CoConstDef.CD_DTL_NOTICE_TEXT:
c.setCdDtlExp((String) noticeDetailMap.get(CoConstDef.CD_DTL_NOTICE_TEXT));
break;
case CoConstDef.CD_DTL_NOTICE_SPDX:
c.setCdDtlExp((String) noticeDetailMap.get(CoConstDef.CD_DTL_NOTICE_SPDX));
break;
}
return c;
}).collect(Collectors.toList());
codeService.setCodeDetails(noticeDetailList, noticeDetailCd);
}
Map<String, Object> externalDetailMap = (Map<String, Object>) configurationMap.get("externalDetail");
List<T2CodeDtl> externalList = new ArrayList<T2CodeDtl>();
if (externalDetailMap != null) {
int seq = 1;
for (String key : externalDetailMap.keySet()) {
T2CodeDtl externalItem = new T2CodeDtl();
Map<String, Object> value = (Map<String, Object>) externalDetailMap.get((String) key);
externalItem.setCdNo(CoConstDef.CD_EXTERNAL_LINK);
externalItem.setCdDtlNo((String) key);
externalItem.setCdDtlNm((String) value.get("urlKey"));
externalItem.setCdSubNo("");
externalItem.setCdDtlExp((String) value.get("urlValue"));
externalItem.setCdOrder(Integer.toString(seq++));
externalItem.setUseYn(CoConstDef.FLAG_YES);
externalList.add(externalItem);
}
codeService.setCodeDetails(externalList, CoConstDef.CD_EXTERNAL_LINK);
}
CoCodeManager.getInstance().refreshCodes();
result.put("resCd", resCd);
result.put("resMsg", resMsg);
return result;
}
} | 10,711 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
FileServiceImpl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/service/impl/FileServiceImpl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.service.impl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.config.AppConstBean;
import oss.fosslight.domain.Project;
import oss.fosslight.domain.T2File;
import oss.fosslight.domain.UploadFile;
import oss.fosslight.repository.FileMapper;
import oss.fosslight.repository.ProjectMapper;
import oss.fosslight.repository.VerificationMapper;
import oss.fosslight.service.FileService;
import oss.fosslight.util.CompressUtil;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.FileUtil;
import oss.fosslight.util.StringUtil;
@Service("fileService")
@Slf4j
@PropertySources(value = {@PropertySource(value=AppConstBean.APP_CONFIG_PROPERTIES_PATH)})
public class FileServiceImpl extends CoTopComponent implements FileService {
@Autowired FileMapper fileMapper;
@Autowired VerificationMapper verificationMapper;
@Autowired ProjectMapper projectMapper;
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile) {
return uploadFile(req, registFile, null);
}
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile, String inputFileName) {
return uploadFile(req,registFile,inputFileName,null);
}
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile, String inputFileName, String oldFileId) {
List<UploadFile> result = new ArrayList<UploadFile>();
MultipartHttpServletRequest multipartRequest = null;
/** S: ํ์ผ ์
๋ก๋ **/
try {
multipartRequest = (MultipartHttpServletRequest)req;
} catch(Exception e) {
log.debug("error : " + e.getMessage());
return result;
}
java.util.Iterator<String> fileNames = multipartRequest.getFileNames();
boolean sw = true;
String fileId = "";
if (oldFileId==null || "0".equals(oldFileId) || "".equals(oldFileId)){
fileId = fileMapper.getFileId();
if (fileId == null){
fileId = "1";
}
}else{
fileId = oldFileId;
}
int indexNum = 0;
while (fileNames.hasNext()){
UploadFile upFile = new UploadFile();
boolean uploadSucc = true;
String fileName = fileNames.next(); //input name
if (inputFileName != null){
String inputFileNameRe = inputFileName.replace("##]", "");
int st = fileName.indexOf("[");
int en = fileName.indexOf("]");
try{
indexNum = Integer.parseInt(fileName.substring(st+1, en));
}catch(Exception e){
log.error("[##] NumberFormat Exception : " + e.getMessage());
}
boolean isInput = fileName.startsWith(inputFileNameRe);
if (!isInput || inputFileName == null){
continue;
}
}
sw=false;
MultipartFile mFile = multipartRequest.getFile(fileName);
if (isEmpty(mFile.getOriginalFilename())) {
throw new RuntimeException("File Name is empty");
}
if (mFile.getSize() <= 0) {
throw new RuntimeException("File Size is 0");
}
String originalFileName = mFile.getOriginalFilename(); //Original File name
// originalFileName์ ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
log.debug("File upload OriginalFileName : " + originalFileName);
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("/") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
if (originalFileName.indexOf("\\") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("\\") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
String uploadFilePath = "";
String uploadThumbFilePath = "";
try {
uploadFilePath = appEnv.getProperty("upload.path", "/upload");
uploadThumbFilePath = appEnv.getProperty("image.path", "/image");
} catch(Exception e) {
log.error("file upload path(get properties) : " + e.getMessage());
}
UUID randomUUID = UUID.randomUUID();
File file = new File(uploadFilePath+"/"+randomUUID+"."+fileExt);
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName(fileName);
upFile.setSize(mFile.getSize());
upFile.setFilePath(uploadFilePath);
upFile.setFileName(randomUUID+"."+fileExt);
upFile.setFileExt(fileExt);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(randomUUID+"."+fileExt);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(randomUUID+"_thumb."+fileExt);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(mFile.getSize()+"");
try {
registFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
upFile.setRegistSeq(registFile(registFile));
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
if (mFile.getSize()!=0){ //File Null Check
if (! file.exists()){ //๊ฒฝ๋ก์์ ํ์ผ์ด ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ
try {
if (file.getParentFile().mkdirs()){ //๊ฒฝ๋ก์ ํด๋นํ๋ ๋๋ ํ ๋ฆฌ๋ค์ ์์ฑ
boolean upSucc = file.createNewFile(); //์ดํ ํ์ผ ์์ฑ
if (!upSucc){
uploadSucc=false;
}
}
}
catch (IOException e) {
log.error("file upload create error : " + e.getMessage());
uploadSucc=false;
}
}
uploadSucc = FileUtil.transferTo(mFile, file);
upFile.setUploadSucc(uploadSucc);
}
result.add(upFile);
}
if (sw){
result = null;
}
return result;
}
//ํ์ผ DB ๋ฑ๋ก
public String registFile(T2File file) {
int result = fileMapper.insertFile(file);
if (result <= 0){
return null;
}
return file.getFileSeq();
}
@Override
public T2File selectFileInfo(String fileSeq) {
T2File file = fileMapper.selectFileInfo(fileSeq);
return file;
}
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile, String inputFileName, boolean useRandomPath, String filePath) {
return uploadFile(req, registFile, inputFileName, "", useRandomPath, filePath);
}
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile, String inputFileName, String oldFileId, boolean useRandomPath, String filePath){
return uploadFile(req, registFile, inputFileName, "", useRandomPath, filePath, false);
}
@Override
public List<UploadFile> uploadFile(HttpServletRequest req, T2File registFile, String inputFileName, String oldFileId, boolean useRandomPath, String filePath, boolean isOrigFile) {
List<UploadFile> result = new ArrayList<UploadFile>();
MultipartHttpServletRequest multipartRequest = null;
try {
// request๊ฐ multipartRequest๊ฐ ์๋ ๊ฒฝ์ฐ.
multipartRequest = (MultipartHttpServletRequest)req;
} catch(Exception e) {
log.error("Request IS NOT a type of MultipartRequest : " + e.getMessage());
return result;
}
// request์์ ํ์ผ๋ช
๋ค์ ๊ฐ์ ธ์จ๋ค.
java.util.Iterator<String> fileNames = multipartRequest.getFileNames();
boolean sw = true;
String fileId = "";
//๊ตฌ fileId๊ฐ ์กด์ ํ๋ค๋ฉด ๊ตฌ fileId์ ๋ฃ์ด์ค๋ค
if (!isEmpty(oldFileId)){
fileId = oldFileId;
} else {
fileId = avoidNull(fileMapper.getFileId(), "1");
}
log.debug("Target fileId : " + fileId);
int indexNum = 0;
while (fileNames.hasNext()){
UploadFile upFile = new UploadFile();
registFile.setCreator(registFile.getCreator());
boolean uploadSucc = true;
String fileName = fileNames.next(); //input name
if (inputFileName != null){
String inputFileNameRe = inputFileName.replace("##]", "");
int st = fileName.indexOf("[");
int en = fileName.indexOf("]");
try {
indexNum = Integer.parseInt(fileName.substring(st+1, en));
} catch(Exception e) {
log.error("[##] NumberFormat Exception : " + e.getMessage());
}
log.debug("indexNum : " + indexNum + ", fileName : " + fileName);
boolean isInput = fileName.startsWith(inputFileNameRe);
if (!isInput || inputFileName == null){
continue;
}
}
sw=false;
MultipartFile mFile = multipartRequest.getFile(fileName);
if (isEmpty(mFile.getOriginalFilename())) {
throw new RuntimeException("File Name is empty");
}
if (mFile.getSize() <= 0) {
throw new RuntimeException("File Size is 0");
}
String originalFileName = avoidNull(registFile.getBeforeOrigNm(), mFile.getOriginalFilename()); //Original File name
// originalFileName์ ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
log.debug("File upload OriginalFileName : " + originalFileName);
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("/") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
if (originalFileName.indexOf("\\") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("\\") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
String uploadFilePath = "";
String uploadThumbFilePath = "";
try{
/* ํ์ผ ์ ์ฅ ๊ฒฝ๋ก ์ค์ hk-cho */
// 1) parameter๋ก filePath๊ฐ ๋์ด์ค์ง ์์์ ๊ฒฝ์ฐ Property์ ์๋ ๊ฒฝ๋ก์ ์ ์ฅ
if (StringUtil.isEmpty(filePath)) {
uploadFilePath = appEnv.getProperty("upload.path", "/upload");
uploadThumbFilePath = appEnv.getProperty("image.path", "/image");
} else { // 2) parameter๋ก filePath๊ฐ ๋์ด์์ ๊ฒฝ์ฐ ๋์ด์จ filePath์ ์ ์ฅ
uploadFilePath = filePath;
uploadThumbFilePath = filePath + "/" + "thumb";
}
log.debug("uploadFilePath : " + uploadFilePath);
} catch(Exception e) {
log.error("Wrong file upload path(get properties) : " + e.getMessage());
}
/* ๋๋ค ํ์ผ๋ช
์ฌ์ฉ ์ฌ๋ถ hk-cho */
String phyFileNm = originalFileName; // ์๋ฒ์ ์ ์ฅ๋ ๋ฌผ๋ฆฌ ํ์ผ๋ช
String thumbPhyFileNm = phyFileNm+"_thumb."+fileExt; // ์๋ฒ์ ์ ์ฅ๋ thumb ๋ฌผ๋ฆฌ ํ์ผ๋ช
if (useRandomPath){
UUID randomUUID = UUID.randomUUID();
phyFileNm = randomUUID+"."+fileExt;
thumbPhyFileNm = randomUUID+"_thumb."+fileExt;
}
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName(fileName);
upFile.setSize(mFile.getSize());
upFile.setFilePath(uploadFilePath);
upFile.setFileExt(fileExt);
upFile.setFileName(phyFileNm);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(phyFileNm);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(thumbPhyFileNm);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(mFile.getSize()+"");
try {
registFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
if (mFile.getSize()!=0){ //File Null Check
new File(filePath).mkdirs();
if (isOrigFile) {
uploadSucc = FileUtil.transferTo(mFile, new File(filePath + "/" + originalFileName));
} else {
uploadSucc = FileUtil.transferTo(mFile, new File(filePath + "/" + phyFileNm));
}
if (uploadSucc){
try {
String regiSeq = registFile(registFile);
upFile.setRegistSeq(regiSeq); //์๋ก์ถ๊ฐ๋ SEQ(primaryKey a.i)
upFile.setRegistFileId(fileId); //FileId(group๊ฐ๋
์ ์ปฌ๋ผ)
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
} catch(Exception e) {
log.error("file regist error : " + e.getMessage());
uploadSucc=false;
}
}
upFile.setUploadSucc(uploadSucc);
}
result.add(upFile);
}
if (sw){
result = null;
}
return result;
}
@Override
public String registFileWithFileName(String filePath, String fileName) {
T2File fileInfo = new T2File();
fileInfo.setFileId(fileMapper.getFileId());
fileInfo.setOrigNm(fileName);
fileInfo.setLogiNm(fileName);
fileInfo.setLogiPath(filePath);
fileInfo.setExt(FilenameUtils.getExtension(fileName));
try {
if (fileName.toLowerCase().endsWith(".tgz.gz")) {
fileInfo.setExt("tgz.gz");
} else if (fileName.toLowerCase().endsWith(".tar.bz2")) {
fileInfo.setExt("tar.bz2");
} else if (fileName.toLowerCase().endsWith(".tar.gz")) {
fileInfo.setExt("tar.gz");
}
} catch (Exception e) {
//TODO: handle exception
log.error("file regist error : " + e.getMessage());
}
fileInfo.setSize("1");
return registFile(fileInfo);
}
@Override
public String registFileDownload(String filePath, String fileName, String logiFileName) {
T2File fileInfo = new T2File();
fileInfo.setFileId(fileMapper.getFileId());
fileInfo.setGubn(CoConstDef.FILE_GUBUN_FILE_DOWNLOAD);
fileInfo.setOrigNm(fileName);
fileInfo.setLogiNm(logiFileName);
fileInfo.setLogiPath(filePath);
fileInfo.setExt(FilenameUtils.getExtension(fileName));
try {
if (avoidNull(fileName.toLowerCase()).endsWith(".tgz.gz")) {
fileInfo.setExt("tgz.gz");
} else if (avoidNull(fileName.toLowerCase()).endsWith(".tar.bz2")) {
fileInfo.setExt("tar.bz2");
} else if (avoidNull(fileName.toLowerCase()).endsWith(".tar.gz")) {
fileInfo.setExt("tar.gz");
}
} catch (Exception e) {
//TODO: handle exception
log.error("file regist error : " + e.getMessage());
}
fileInfo.setSize("1");
return registFile(fileInfo);
}
@Override
public T2File selectFileInfoById(String fileId) {
return fileMapper.selectFileInfoById(fileId);
}
@Override
public String copyFileInfo(String orgFileId) {
T2File fileInfo = new T2File();
fileInfo.setFileId(fileMapper.getFileId());
fileInfo.setOrgFileId(orgFileId);
fileMapper.copyFileInfo(fileInfo);
return fileInfo.getFileId();
}
@Override
public T2File selectFileInfoByLogiName(T2File bean) {
return fileMapper.selectFileInfoByName(bean);
}
//wgetUrl ํ์ผ upload
@Override
public List<UploadFile> uploadWgetFile(HttpServletRequest req, T2File registFile, Map<Object, Object> map, boolean isOrigFile) {
List<UploadFile> result = new ArrayList<UploadFile>();
log.debug("<-------- uploadWgetFile Start------->");
/** S: ํ์ผ ์
๋ก๋ **/
String url = (String) map.get("wgetUrl");
String filePath = (String) map.get("filePath");
String prjId = (String) map.get("prjId");
String uploadFilePath = "";
String uploadThumbFilePath = "";
boolean uploadSucc = true;
UploadFile upFile = new UploadFile();
if (StringUtil.isEmpty(filePath)){
try {
uploadFilePath = appEnv.getProperty("packaging.path", "/upload/packaging") + "/" + prjId;
uploadThumbFilePath = appEnv.getProperty("packaging.path", "/upload/packaging") + "/" + prjId + "/thumb";
File dir = new File(uploadFilePath);
if (!dir.exists()){
dir.mkdirs();
}
} catch(Exception e) {
log.error("file upload path(get properties) : " + e.getMessage());
}
} else {
uploadFilePath = filePath;
uploadThumbFilePath = filePath + File.separator + "thumb";
File dir = new File(filePath);
if (!dir.exists()) { //ํด๋ ์์ผ๋ฉด ํด๋ ์์ฑ
dir.mkdirs();
}
}
int ShellCommanderResult = 9;
int indexNum = 0;
// Url์ index ๋ค์ ๋ฌธ์์ด ๋ถํฐ ๋ถ๋ฆฌํ ์ ์ฅ
String originalFileName = avoidNull(url).trim();
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf('/') + 1);
}
int i = originalFileName.lastIndexOf('.');
// ๋ง์ง๋ง .๋ถํฐ ๋๋จธ์ง ๋ฌธ์์ด์ f์ ์ ์ฅ
String fileName = originalFileName.substring(0,i); //input name
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
UUID randomUUID = UUID.randomUUID();
log.info("WGET STart");
log.info("WGET URL : " + url);
log.info("WGET FileName : " + originalFileName);
log.info("WGET Save as File Name :" + randomUUID+"."+fileExt);
//์ฃผ์์์ ํ์ผ ๊ฐ์ ธ์ค๊ธฐ
// ๋คํธ์ํฌ ์ํฉ์ ๋ฐ๋ผ์ ๋์ฉ๋ ํ์ผ์ ์ ์์ ์ผ๋ก ๋ค์ด๋ก๋ ๋ฐ์ง ๋ชปํ๋ ํ์์ด ๋ฐ์ํ์ฌ (์ ์ถ) NIO ๋ฐฉ์์ผ๋ก ๋ณ๊ฒฝํจ
ReadableByteChannel readChannel = null;
FileChannel writeChannel = null;
FileOutputStream fileOS = null;
try {
readChannel = Channels.newChannel(new URL(url.replaceAll("\\s", "%20")).openStream());
if (isOrigFile) {
fileOS = new FileOutputStream(uploadFilePath+"/"+fileName+"."+fileExt);
} else {
fileOS = new FileOutputStream(uploadFilePath+"/"+randomUUID+"."+fileExt);
}
writeChannel = fileOS.getChannel();
writeChannel.transferFrom(readChannel, 0, Long.MAX_VALUE);
ShellCommanderResult = 0;
} catch (Exception e) {
log.error(e.getMessage());
ShellCommanderResult = -1;
} finally {
if (writeChannel != null) {
try {
writeChannel.close();
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
}
if (fileOS != null) {
try {
fileOS.close();
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
}
if (readChannel != null) {
try {
readChannel.close();
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
}
}
if (ShellCommanderResult == 0){
File getfile = new File(uploadFilePath+"/"+randomUUID+"."+fileExt);
long fileSize = getfile.length();
String fileId = "";
//fileId
fileId = avoidNull(fileMapper.getFileId(), "1");
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName(fileName);
upFile.setSize(fileSize);
upFile.setFilePath(uploadFilePath);
upFile.setFileName(randomUUID+"."+fileExt);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(fileExt);
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(randomUUID+"."+fileExt);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(randomUUID+"_thumb."+fileExt);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(fileSize+"");
try {
registFile.setContentType(fileExt);
} catch (Exception e) {}
upFile.setRegistSeq(registFile(registFile));
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
} else {
uploadSucc = false;
}
upFile.setUploadSucc(uploadSucc);
upFile.setWgetResult(ShellCommanderResult);
result.add(upFile);
return result;
}
@SuppressWarnings("unchecked")
@Override
public String setClearFiles(Map<Object, Object> map) {
String deleteComment = "";
String uploadComment = "";
String prjId = (String) map.get("prjId");
List<String> fileSeqs = (List<String>)map.get("fileSeqs");
List<T2File> uploadFileInfos = new ArrayList<T2File>();
File file = null;
Project prjParam = new Project();
prjParam.setPrjId(prjId);
ArrayList<String> newPackagingFileIdList = new ArrayList<String>();
newPackagingFileIdList.add(fileSeqs.size() > 0 ? fileSeqs.get(0) : null);
newPackagingFileIdList.add(fileSeqs.size() > 1 ? fileSeqs.get(1) : null);
newPackagingFileIdList.add(fileSeqs.size() > 2 ? fileSeqs.get(2) : null);
prjParam.setPackageFileId(newPackagingFileIdList.get(0));
prjParam.setPackageFileId2(newPackagingFileIdList.get(1));
prjParam.setPackageFileId3(newPackagingFileIdList.get(2));
for (String fileSeq : fileSeqs){
T2File paramT2File = new T2File();
paramT2File.setFileSeq(fileSeq);
uploadFileInfos.add(fileMapper.getFileInfo(paramT2File));
}
String publicUrl = appEnv.getProperty("upload.path", "/upload");
String packagingUrl = appEnv.getProperty("packaging.path", "/upload/packaging") + "/" + prjId;
List<T2File> result = fileMapper.selectPackagingFileInfo(prjId); // verifyํ file์ selectํจ.
T2File vulDOCFileInfo = fileMapper.selectPackagingVulDOCFileInfo(prjId);
if (result.size() > 0){
for (T2File res : result){
String rtnFilePath = res.getLogiPath();
String rtnFileName = res.getLogiNm();
String rtnFileSeq = res.getFileSeq();
if (publicUrl.equals(rtnFilePath)){
// selectํ filePath๊ฐ upload Dir ์ผ ๊ฒฝ์ฐ ํด๋น ํ์ผ๋ง ์ญ์ ํจ.
file = new File(rtnFilePath + "/" + rtnFileName);
for (String fileSeq : fileSeqs) {
if (file.exists() && !rtnFileSeq.equals(fileSeq)){
int reuseCnt = fileMapper.getPackgingReuseCnt(rtnFileName);
if (reuseCnt == 0){
T2File delFile = new T2File();
delFile.setFileSeq(rtnFileSeq);
delFile.setGubn("A");
int returnSuccess = fileMapper.updateFileDelYnKessan(delFile);
if (returnSuccess > 0) {
if (file.delete()){
log.debug(rtnFilePath + "/" + rtnFileName + " is delete success.");
} else {
log.debug(rtnFilePath + "/" + rtnFileName + " is delete failed.");
}
}
}
}
}
}
}
deleteFiles(packagingUrl, uploadFileInfos, prjId, vulDOCFileInfo); // 'upload/packaging/#{prjId}' ์ Directory๊ฐ ์๋์ง ์ฒดํฌ ํ ์ญ์ ์ฒ๋ฆฌํจ.( ํ์ฌ๋ฑ๋กํ file์ ์ ์ธํ ๋๋จธ์ง๋ฅผ ์ญ์ธ์ฒ๋ฆฌ )
} else {
deleteFiles(packagingUrl, uploadFileInfos, prjId, vulDOCFileInfo); // verify ํ file์ด ์์๊ฒฝ์ฐ packagingUrl๋ ๊ฐ์ด ๊ฒ์ฌํ์ฌ delete๋ฅผ ํจ.
}
// packaging File comment
try {
Project project = projectMapper.selectProjectMaster(prjParam);
ArrayList<String> origPackagingFileIdList = new ArrayList<String>();
origPackagingFileIdList.add(project.getPackageFileId());
origPackagingFileIdList.add(project.getPackageFileId2());
origPackagingFileIdList.add(project.getPackageFileId3());
int idx = 0;
for (String fileId : origPackagingFileIdList){
T2File fileInfo = new T2File();
if (!isEmpty(fileId) && !fileId.equals(newPackagingFileIdList.get(idx))){
//fileInfo.setFileSeq(fileId);
fileInfo = fileMapper.selectFileInfo(fileId);
deleteComment += "Packaging file, "+fileInfo.getOrigNm()+", was deleted by "+loginUserName()+". <br>";
}
if (!isEmpty(newPackagingFileIdList.get(idx)) && !newPackagingFileIdList.get(idx).equals(fileId)){
//fileInfo.setFileSeq(newPackagingFileIdList.get(idx));
fileInfo = fileMapper.selectFileInfo(newPackagingFileIdList.get(idx));
oss.fosslight.domain.File resultFile = verificationMapper.selectVerificationFile(newPackagingFileIdList.get(idx));
if (CoConstDef.FLAG_YES.equals(resultFile.getReuseFlag())){
uploadComment += "Packaging file, "+fileInfo.getOrigNm()+", was loaded from Project ID: "+resultFile.getRefPrjId()+" by "+loginUserName()+". <br>";
} else {
uploadComment += "Packaging file, "+fileInfo.getOrigNm()+", was uploaded by "+loginUserName()+". <br>";
}
}
idx++;
}
} catch (Exception e) {
log.error(e.getMessage());
}
verificationMapper.updatePackagingReuseMap(prjParam);
return deleteComment + uploadComment;
}
@Override
public void deleteFiles(String url, List<T2File> uploadFileInfos, String prjId, T2File vulDOCFileInfo) {
File file = new File(url);
ArrayList<String> LogiNms = new ArrayList<String>();
ArrayList<String> reuseNms = new ArrayList<String>();
for (T2File uploadFileInfo : uploadFileInfos){
LogiNms.add(uploadFileInfo.getLogiNm());
}
// ํ์ฌ proejct Packaging File ์ค ์ฌ์ฌ์ฉ์ค์ธ packaging File ์ด ์๋ค๋ฉด ์ ๊ฑฐ ๋ถ๊ฐ
List<T2File> reusePackaging = fileMapper.getReusePackagingInfo();
String vulDOCFileLogiNm = vulDOCFileInfo != null ? vulDOCFileInfo.getLogiNm() : "";
for (T2File reuse : reusePackaging){
reuseNms.add(reuse.getLogiNm());
}
if (file.exists()){
for (File f : file.listFiles()){
String fileNm = f.getName();
if (!isEmpty(vulDOCFileLogiNm) && vulDOCFileLogiNm.equalsIgnoreCase(fileNm)) continue;
if (!LogiNms.contains(fileNm)){
T2File delFile = new T2File();
delFile.setLogiPath(url);
delFile.setLogiNm(f.getName());
int returnSuccess = fileMapper.updateReuseChkFileDelYnByFilePathNm(delFile);
if (returnSuccess > 0 && !reuseNms.contains(fileNm)){
if (f.delete()){
log.debug(url + "/" + f.getName() + " is delete success.");
}else{
log.debug(url + "/" + f.getName() + " is delete failed.");
}
}
}
}
}
// ์ฌ์ฌ์ฉ์ ํ์๋ file์ค ๋ค๋ฅธ project์์๋ ์ฌ์ฌ์ฉ์ ํ์ง ์์ file ์๋์ง ํ์ธํ๊ณ ์ฌ์ฌ์ฉ์ ์ํ๋ค๋ฉด file ์ญ์ / ์ถํ reuseํ๋ ๋ค๋ฅธ project์์๋ reuseFlag๊ฐ N์ด ๋๋ฉด ์ง์ฐ๋ case์ด๋ฏ๋ก log๋ ๋จ๊ธฐ์ง ์์.
List<T2File> reusePackagingFileList = fileMapper.getPackgingReuseCntToList(prjId);
for (T2File reusePackagingFile : reusePackagingFileList){ // reuseCnt๊ฐ 0์ธ ๊ฐ๋ง ๋ถ๋ฌ์ค๊ณ ์ญ์ ์ฒ๋ฆฌ ํ hidden flag๋ฅผ Y๋ก ๋ณ๊ฒฝ ๊ทธ๋ฆฌ๊ณ ์ฌ๊ฒ์์ ์กฐํ ๋ถ๊ฐ์ํ๋ก ๋ง๋ฆ.
File reuseFile = new File(reusePackagingFile.getLogiPath());
if (reuseFile.exists()){
for (File f : reuseFile.listFiles()){
if (reusePackagingFile.getLogiNm().equals(f.getName())){
T2File delFile = new T2File();
delFile.setLogiPath(reusePackagingFile.getLogiPath());
delFile.setLogiNm(f.getName());
int returnSuccess = fileMapper.updateFileDelYnByFilePathNm(delFile);
String[] refPrjId = reusePackagingFile.getLogiPath().split("/");
fileMapper.setReusePackagingFileHidden(refPrjId[refPrjId.length-1], reusePackagingFile.getLogiPath(), f.getName());
if (returnSuccess > 0){
if (f.delete()){
log.debug(url + "/" + f.getName() + " is delete success.");
}else{
log.debug(url + "/" + f.getName() + " is delete failed.");
}
}
}
}
}
}
}
@Override
public List<UploadFile> setReusePackagingFile(String refFileSeq) {
List<UploadFile> result = new ArrayList<UploadFile>();
UploadFile upFile = new UploadFile();
String FileId = fileMapper.getFileId();
T2File file = selectFileInfo(refFileSeq);
file.setFileId(FileId);
file.setCreator(loginUserName());
fileMapper.insertFile(file);
file = selectFileInfoById(FileId);
upFile.setOriginalFilename(file.getOrigNm());
upFile.setSize(Long.parseLong(file.getSize()));
upFile.setFilePath(file.getLogiPath());
upFile.setFileName(file.getLogiNm());
upFile.setContentType(file.getExt());
upFile.setRegistSeq(file.getFileSeq());
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
result.add(upFile);
return result;
}
@Override
public List<UploadFile> uploadNoticeXMLFile(HttpServletRequest req, T2File registFile, String oldFileId, String prjId) {
List<UploadFile> result = new ArrayList<UploadFile>();
MultipartHttpServletRequest multipartRequest = null;
/** S: ํ์ผ ์
๋ก๋ **/
try {
multipartRequest = (MultipartHttpServletRequest)req;
} catch(Exception e) {
log.debug("error : " + e.getMessage());
return result;
}
java.util.Iterator<String> fileNames = multipartRequest.getFileNames();
boolean sw = true;
String fileId = "";
//๊ตฌ fileId๊ฐ ์กด์ ํ๋ค๋ฉด ๊ตฌ fileId์ ๋ฃ์ด์ค๋ค
if (oldFileId==null || "0".equals(oldFileId) || "".equals(oldFileId)){
fileId = fileMapper.getFileId();
if (fileId == null){
fileId = "1";
}
} else {
fileId = oldFileId;
}
int indexNum = 0;
while (fileNames.hasNext()){
UploadFile upFile = new UploadFile();
boolean uploadSucc = true;
String fileName = fileNames.next(); //input name
sw = false;
MultipartFile mFile = multipartRequest.getFile(fileName);
if (isEmpty(mFile.getOriginalFilename())) {
throw new RuntimeException("File Name is empty");
}
if (mFile.getSize() <= 0) {
throw new RuntimeException("File Size is 0");
}
String originalFileName = mFile.getOriginalFilename(); //Original File name
// originalFileName์ ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
log.debug("File upload OriginalFileName : " + originalFileName);
if (originalFileName.indexOf("/") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("/") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
if (originalFileName.indexOf("\\") > -1) {
originalFileName = originalFileName.substring(originalFileName.lastIndexOf("\\") + 1);
log.debug("File upload OriginalFileName Substring with File.separator : " + originalFileName);
}
String fileExt = FilenameUtils.getExtension(originalFileName);
if (originalFileName.toLowerCase().endsWith(".tgz.gz")) {
fileExt = "tgz.gz";
} else if (originalFileName.toLowerCase().endsWith(".tar.bz2")) {
fileExt = "tar.bz2";
} else if (originalFileName.toLowerCase().endsWith(".tar.gz")) {
fileExt = "tar.gz";
}
String uploadFilePath = "";
String uploadThumbFilePath = "";
try{
uploadFilePath = appEnv.getProperty("android.upload.path", "/upload/android_notice") + "/" + prjId;
uploadThumbFilePath = appEnv.getProperty("image.path", "/image") + "/" + prjId + "/thumb";
}catch(Exception e){
log.error("file upload path(get properties) : " + e.getMessage());
}
UUID randomUUID = UUID.randomUUID();
File file = new File(uploadFilePath+"/"+randomUUID+"."+fileExt);
/** Return Setting **/
upFile.setOriginalFilename(originalFileName);
upFile.setInputName(fileName);
upFile.setSize(mFile.getSize());
upFile.setFilePath(uploadFilePath);
upFile.setFileName(randomUUID+"."+fileExt);
upFile.setFileExt(fileExt);
upFile.setIndexNum(indexNum);
upFile.setRegistFileId(fileId);
try {
upFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
/** DB Regist Setting **/
registFile.setFileId(fileId);
registFile.setOrigNm(originalFileName);
registFile.setLogiNm(randomUUID+"."+fileExt);
registFile.setLogiPath(uploadFilePath);
registFile.setLogiThumbNm(randomUUID+"_thumb."+fileExt);
registFile.setLogiThumbPath(uploadThumbFilePath);
registFile.setExt(fileExt);
registFile.setSize(mFile.getSize()+"");
try {
registFile.setContentType(mFile.getContentType());
} catch (Exception e) {}
upFile.setRegistSeq(registFile(registFile));
upFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
if (mFile.getSize()!=0){ //File Null Check
if (! file.exists()){ //๊ฒฝ๋ก์์ ํ์ผ์ด ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ
try {
if (file.getParentFile().mkdirs()){ //๊ฒฝ๋ก์ ํด๋นํ๋ ๋๋ ํ ๋ฆฌ๋ค์ ์์ฑ
boolean upSucc = file.createNewFile(); //์ดํ ํ์ผ ์์ฑ
if (!upSucc){
uploadSucc=false;
}
}
}
catch (IOException e) {
log.error("file upload create error : " + e.getMessage());
uploadSucc=false;
}
}
uploadSucc = FileUtil.transferTo(mFile, file);
upFile.setUploadSucc(uploadSucc);
}
result.add(upFile);
try {
File convertHTMLFile = null;
if ("XML".equals(fileExt.toUpperCase())) {
convertHTMLFile = CommonFunction.convertXMLToHTML(file, false);
} else if ("ZIP".equals(fileExt.toUpperCase())) {
FileUtil.decompress(uploadFilePath + "/" + file.getName(), uploadFilePath + "/" + randomUUID);
convertHTMLFile = CommonFunction.convertXMLToHTML(new File(uploadFilePath + "/" + randomUUID), true);
} else if ("TAR.GZ".equals(fileExt.toUpperCase())) {
CompressUtil.decompressTarGZ(file, uploadFilePath + "/" + randomUUID);
convertHTMLFile = CommonFunction.convertXMLToHTML(new File(uploadFilePath + "/" + randomUUID), true);
}
if (convertHTMLFile != null) {
long convertHTMLFileSize = convertHTMLFile.length();
if (convertHTMLFileSize > 0){
UploadFile convertNoticeFile = new UploadFile();
String convertFileId = fileMapper.getFileId();
String convertNoticeFileName = "Notice-"+prjId+"_"+DateUtil.getCurrentDateTime(DateUtil.DATE_PATTERN)+".html";
convertNoticeFile.setOriginalFilename(convertNoticeFileName);
convertNoticeFile.setInputName(convertNoticeFileName);
convertNoticeFile.setSize(convertHTMLFileSize);
convertNoticeFile.setFilePath(uploadFilePath + "/" + randomUUID);
convertNoticeFile.setFileName(convertHTMLFile.getName());
convertNoticeFile.setFileExt("html");
convertNoticeFile.setIndexNum(indexNum+1);
convertNoticeFile.setRegistFileId(convertFileId);
convertNoticeFile.setContentType("text/html");
/** DB Regist Setting **/
T2File registConvertHTML = new T2File();
registConvertHTML.setFileId(convertFileId);
registConvertHTML.setOrigNm(convertNoticeFileName);
registConvertHTML.setLogiNm(convertHTMLFile.getName());
registConvertHTML.setLogiPath(uploadFilePath + "/" + randomUUID);
registConvertHTML.setLogiThumbNm(convertHTMLFile.getName().replace(".html", "_thumb.html"));
registConvertHTML.setLogiThumbPath(uploadFilePath + "/" + randomUUID + "/thumb");
registConvertHTML.setExt("html");
registConvertHTML.setSize(Long.toString(convertHTMLFileSize));
registFile.setContentType("text/html");
convertNoticeFile.setRegistSeq(registFile(registConvertHTML));
convertNoticeFile.setCreatedDate(CommonFunction.getCurrentDateTime(CoConstDef.DATABASE_FORMAT_DATE_ALL));
result.add(convertNoticeFile);
}
}
} catch (Throwable e) {
log.debug(e.getMessage());
}
}
if (sw){
result = null;
}
return result;
}
@Override
public void deletePhysicalFile(T2File file, String flag) {
String filePath = "";
boolean isAndroidNoticeFolder = false;
String folderPath = "";
if ("VERIFY".equalsIgnoreCase(flag)) {
filePath = file.getLogiPath() + "/" + file.getLogiNm();
}else {
T2File T2file = fileMapper.getFileInfo2(file);
filePath = T2file.getLogiPath() + "/" + T2file.getLogiNm();
if(T2file.getLogiPath().contains("android_notice") && T2file.getExt().equals("html")) {
isAndroidNoticeFolder = true;
folderPath = T2file.getLogiPath();
}
}
try {
FileOutputStream to = new FileOutputStream(filePath);
to.flush();
to.close();
if(isAndroidNoticeFolder) {
File folder = new File(folderPath);
while(folder.exists()) {
File[] folder_list = folder.listFiles();
for(int i = 0;i < folder_list.length; i++) {
folder_list[i].delete();
}
if(folder_list.length == 0 && folder.isDirectory()) {
folder.delete();
}
}
} else{
File LogiFile = new File(filePath);
if (LogiFile.exists()) {
LogiFile.delete();
}
}
} catch(Exception e) {
log.info(e.getMessage(), e);
}
}
@Override
public String copyPhysicalFile(String fileId) {
boolean fileCopyFlag = false;
String newFileId = fileMapper.getFileId();
List<T2File> orgFileInfoList = fileMapper.getFileInfoList(fileId);
for (T2File orgFile : orgFileInfoList) {
String baseFile = orgFile.getLogiPath() + "/" + orgFile.getLogiNm();
UUID randomUUID = UUID.randomUUID();
String copyFileName = randomUUID + "." + orgFile.getExt();
String newFile = orgFile.getLogiPath();
if (FileUtil.copyFile(baseFile, newFile, copyFileName)) {
T2File fileInfo = new T2File();
fileInfo.setFileId(newFileId);
fileInfo.setFileSeq(orgFile.getFileSeq());
fileInfo.setLogiNm(copyFileName);
fileMapper.insertCopyPhysicalFileInfo(fileInfo);
fileCopyFlag = true;
}else {
fileCopyFlag = false;
}
if (!fileCopyFlag) {
newFileId = null;
log.error("physical file copy error");
break;
}
}
return newFileId;
}
} | 38,615 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
AppTaskScheduler.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/scheduler/AppTaskScheduler.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.scheduler;
import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@Configuration
@EnableScheduling
public class AppTaskScheduler implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
}
@Bean(destroyMethod="shutdown")
public Executor taskScheduler() {
return new ThreadPoolTaskScheduler();
}
@Bean
public SchedulerWorkerTask schedulerWorkerTask(){
return new SchedulerWorkerTask();
}
} | 1,039 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
SchedulerWorkerTask.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/scheduler/SchedulerWorkerTask.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.scheduler;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.Scheduled;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.service.CommentService;
import oss.fosslight.service.MailService;
import oss.fosslight.service.NvdDataService;
import oss.fosslight.service.OssService;
import oss.fosslight.service.impl.VulnerabilityServiceImpl;
import oss.fosslight.util.FileUtil;
public class SchedulerWorkerTask extends CoTopComponent {
final static Logger log = LoggerFactory.getLogger("SCHEDULER_LOG");
@Autowired Environment env;
@Autowired MailService mailService;
@Autowired OssService ossService;
@Autowired CommentService commentService;
@Autowired VulnerabilityServiceImpl vulnerabilityService;
@Autowired NvdDataService nvdService;
boolean serverLoadFlag = false;
boolean distributionFlag = CommonFunction.propertyFlagCheck("distribution.use.flag", CoConstDef.FLAG_YES);
@PostConstruct
public void init() {
serverLoadFlag = true;
makeInternalLicense();
}
public void makeInternalLicense() {
String internalUrlDirPath = CommonFunction.appendProperty("root.dir", "internal.url.dir.path");
String fileNm = "internalLicense.zip";
Path copyPath = Paths.get(internalUrlDirPath);
if (!new File(internalUrlDirPath+"/"+fileNm).exists()) {
try (InputStream is = new ClassPathResource("/template/"+fileNm).getInputStream()) {
if (!Files.exists(copyPath)) {
Files.createDirectories(copyPath);
}
Files.copy(is, copyPath.resolve(fileNm));
FileUtil.decompress(internalUrlDirPath+"/"+fileNm, internalUrlDirPath);
} catch (IOException ioe) {
log.debug(ioe.getMessage());
} catch (Throwable e) {
log.debug(e.getMessage());
}
}
}
// ์๋ฒฝ 12์ ์ค์ผ์ค - CPE Dictionary, CVE Update Data Sync
@Scheduled(cron="${nvd.scheduled.cron.value}")
// @Scheduled(fixedDelay=1000)
public void nvdDataIfJob() {
String resCd = "";
try {
resCd = nvdService.executeNvdDataSync();
if (resCd == "00") {
vulnerabilityService.doSyncOSSNvdInfo();
log.info("nvdDataIfJob end");
} else {
log.error("executeNvdDataSync - resCd : " + resCd);
}
} catch (IOException ioe) {
log.error(ioe.getMessage() + " (resCd : " + resCd + ")", ioe);
}
}
// 0๋ถ ๋ถํฐ 5๋ถ ๋จ์ ์ค์ผ์ค - 30๋ถ์ด ์ง๋ ๋ฉ์ผ์ ์ญ์ ํ๋ค.
//@Scheduled(cron="0 5,10,15,20,25,30,35,40,45,50,55 * * * *")
public void sendMailRunTimeout(){
mailService.sendMailRunTimeout();
}
// 0๋ถ ๋ถํฐ 5๋ถ ๋จ์ ์ค์ผ์ค - 30๋ถ์ด ์ง๋ ๋ฉ์ผ์ ์ญ์ ํ๋ค.
//@Scheduled(cron="0 5,10,15,20,25,30,35,40,45,50,55 * * * *")
public void sendTempMail() {
mailService.sendTempMail();
}
}
| 3,405 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProcessGuide.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ProcessGuide.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
public class ProcessGuide extends ComBean implements Serializable {
private static final long serialVersionUID = -1474263356907429804L;
private String id;
private String pageTarget;
private String contents;
private String replaceContents;
private String url;
private String useYn;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPageTarget() {
return pageTarget;
}
public void setPageTarget(String pageTarget) {
this.pageTarget = pageTarget;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
public String getReplaceContents() {
return replaceContents;
}
public void setReplaceContents(String replaceContents) {
this.replaceContents = replaceContents;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
}
| 1,249 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CoCodeDtl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CoCodeDtl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
public class CoCodeDtl {
/** The cd dtl no. */
String cdDtlNo;
/** The cd sub no. */
String cdSubNo;
/** The cd dtl nm. */
String cdDtlNm;
/** The cd dtl nm. */
String cdDtlNm2;
/** The cd dtl exp. */
String cdDtlExp;
/** The prir seq. */
int cdOrder;
/** The use Flag. */
String useYn;
/**
* Instantiates a new co code dtl.
*
* @param cdDtlNo the Code Dtl No
* @param cdSubNo the Code Dtl Sub No
* @param cdDtlNm the Code Dtl Name
* @param cdDtlExp the Code Dtl Exp
* @param cdBit the Code Bit
* @param cdOrder the Code Order
* @param useYn the useYn
*/
public CoCodeDtl(String cdDtlNo, String cdSubNo, String cdDtlNm, String cdDtlNm2, String cdDtlExp, int cdOrder, String useYn)
{
this.cdDtlNo = cdDtlNo;
this.cdSubNo = cdSubNo;
this.cdDtlNm = cdDtlNm;
this.cdDtlNm2 = cdDtlNm2;
this.cdDtlExp = cdDtlExp;
this.cdOrder = cdOrder;
this.useYn = useYn;
}
}
| 1,227 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2CodeDtl.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2CodeDtl.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.List;
public class T2CodeDtl extends ComBean implements Serializable {
private static final long serialVersionUID = -3911799499686061439L;
private String cdNo; //์ฝ๋๋ฒํธ
private String cdDtlNo; //์์ธ์ฝ๋๋ฒํธ
private String cdSubNo; //์๋ธ์ฝ๋๋ฒํธ
private String cdDtlNm; //์์ธ์ฝ๋๋ช
private String cdDtlNm2; //์์ธ์ฝ๋๋ช
2
private String cdDtlExp; //์์ธ์ฝ๋์ค๋ช
private String cdOrder; //ํ์์
private String useYn; //์ฌ์ฉ์ฌ๋ถ
private String cdDtlNoOrign; // jqgrid์ ์์ ์ ๊ธฐ์กด ์์ธ์ฝ๋๋ฒํธ
private List<T2CodeDtl> newRowList;
private List<T2CodeDtl> modifyRowList;
private List<T2CodeDtl> deleteRowList;
private String cdDtlNoNew;
// ๊ธฐ๋ณธ์์ฑ์
public T2CodeDtl() {}
// default setting cdNo
public T2CodeDtl(String cdNo) {
setCdNo(cdNo);
}
// default setting cdNo, cdDtlNo
public T2CodeDtl(String cdNo, String cdDtlNo) {
setCdNo(cdNo);
setCdDtlNo(cdDtlNo);
}
public String getCdNo() {
return cdNo;
}
public void setCdNo(String cdNo) {
this.cdNo = cdNo;
}
public String getCdDtlNo() {
return cdDtlNo;
}
public void setCdDtlNo(String cdDtlNo) {
this.cdDtlNo = cdDtlNo;
}
public String getCdSubNo() {
return cdSubNo;
}
public void setCdSubNo(String cdSubNo) {
this.cdSubNo = cdSubNo;
}
public String getCdDtlNm() {
return cdDtlNm;
}
public void setCdDtlNm(String cdDtlNm) {
this.cdDtlNm = cdDtlNm;
}
public String getCdDtlNm2() {
return cdDtlNm2;
}
public void setCdDtlNm2(String cdDtlNm2) {
this.cdDtlNm2 = cdDtlNm2;
}
public String getCdDtlExp() {
return cdDtlExp;
}
public void setCdDtlExp(String cdDtlExp) {
this.cdDtlExp = cdDtlExp;
}
public String getCdOrder() {
return cdOrder;
}
public void setCdOrder(String cdOrder) {
this.cdOrder = cdOrder;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
public List<T2CodeDtl> getNewRowList() {
return newRowList;
}
public void setNewRowList(List<T2CodeDtl> newRowList) {
this.newRowList = newRowList;
}
public List<T2CodeDtl> getModifyRowList() {
return modifyRowList;
}
public void setModifyRowList(List<T2CodeDtl> modifyRowList) {
this.modifyRowList = modifyRowList;
}
public List<T2CodeDtl> getDeleteRowList() {
return deleteRowList;
}
public void setDeleteRowList(List<T2CodeDtl> deleteRowList) {
this.deleteRowList = deleteRowList;
}
public String getCdDtlNoOrign() {
return cdDtlNoOrign;
}
public void setCdDtlNoOrign(String cdDtlNoOrign) {
this.cdDtlNoOrign = cdDtlNoOrign;
}
public String getCdDtlNoNew() {
return cdDtlNoNew;
}
public void setCdDtlNoNew(String cdDtlNoNew) {
this.cdDtlNoNew = cdDtlNoNew;
}
}
| 3,030 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2File.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2File.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
public class T2File extends ComBean implements Serializable {
private static final long serialVersionUID = -5448637543126888136L;
private String fileSeq;
private String fileId;
private String gubn;
private String beforeOrigNm;
private String origNm;
private String logiNm;
private String logiPath;
private String logiThumbNm;
private String logiThumbPath;
private String ext;
private String size;
private String contentType;
private String orgFileId;
private String tabNm;
private String reuseCnt;
public T2File(String fileSeq) {
super();
this.fileSeq = fileSeq;
}
public T2File() {}
public String getFileSeq() {
return fileSeq;
}
public void setFileSeq(String fileSeq) {
this.fileSeq = fileSeq;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getGubn() {
return gubn;
}
public void setGubn(String gubn) {
this.gubn = gubn;
}
public String getBeforeOrigNm() {
return beforeOrigNm;
}
public void setBeforeOrigNm(String beforeOrigNm) {
if (beforeOrigNm != null) {
beforeOrigNm = beforeOrigNm.replaceAll("\t", "").trim();
}
this.beforeOrigNm = beforeOrigNm;
}
public String getOrigNm() {
return origNm;
}
public void setOrigNm(String origNm) {
if (origNm != null) {
origNm = origNm.replaceAll("\t", "").trim();
}
this.origNm = origNm;
}
public String getLogiNm() {
return logiNm;
}
public void setLogiNm(String logiNm) {
if (logiNm != null) {
logiNm = logiNm.replaceAll("\t", "").trim();
}
this.logiNm = logiNm;
}
public String getLogiPath() {
return logiPath;
}
public void setLogiPath(String logiPath) {
this.logiPath = logiPath;
}
public String getLogiThumbNm() {
return logiThumbNm;
}
public void setLogiThumbNm(String logiThumbNm) {
this.logiThumbNm = logiThumbNm;
}
public String getLogiThumbPath() {
return logiThumbPath;
}
public void setLogiThumbPath(String logiThumbPath) {
this.logiThumbPath = logiThumbPath;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getOrgFileId() {
return orgFileId;
}
public void setOrgFileId(String orgFileId) {
this.orgFileId = orgFileId;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getTabGubn() {
return tabNm;
}
public void setTabGubn(String tabNm) {
this.tabNm = tabNm;
}
public String getReuseCnt() {
return reuseCnt;
}
public void setReuseCnt(String reuseCnt) {
this.reuseCnt = reuseCnt;
}
}
| 3,059 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryMaster.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/BinaryMaster.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BinaryMaster extends ComBean implements Serializable{
private static final long serialVersionUID = -4375349371642376739L;
private String batId;
private String batStatus;
private String batExecTime;
private String softwareName;
private String softwareVersion;
private String partnerName;
private String binaryFileId;
private String reportFileId;
private String useYn;
private String createdDate1;
private String createdDate2;
private String fileName;
private String division;
private String prjId;
private String ossComponentsStr;
private String ossComponentsLicenseStr;
private String batResultCount;
private String batErrorMsg;
private String procId;
private String procStartTime;
private String userName;
private String divisionName;
// BAT_WATCHER
private String batDivision;
private String batDivisionName;
private String batUserId;
private String batUserName;
private String batEmail;
private String[] watchers;
private List<BinaryMaster> watcherList;
private ArrayList<Map<String, String>> divisionList;
private ArrayList<Map<String, String>> emailList;
private List<BatWatcher> batWatcher;
private String[] watcherDivision;
private String[] watcherUserId;
private String binaryFileName;
private String partnerId;
private String listKind;
private String listId;
public BinaryMaster(){}
//bat ๋ฑ๋ก์ฉ ์์ฑ์
public BinaryMaster(String batId, String registSeq) {
this.batId = batId;
this.binaryFileId = registSeq;
}
public String getBatId() {
return batId;
}
public void setBatId(String batId) {
this.batId = batId;
}
public String getBatExecTime() {
return batExecTime;
}
public void setBatExecTime(String batExecTime) {
this.batExecTime = batExecTime;
}
public String getPartnerName() {
return partnerName;
}
public void setPartnerName(String partnerName) {
this.partnerName = partnerName;
}
public String getBinaryFileId() {
return binaryFileId;
}
public void setBinaryFileId(String binaryFileId) {
this.binaryFileId = binaryFileId;
}
public String getReportFileId() {
return reportFileId;
}
public void setReportFileId(String reportFileId) {
this.reportFileId = reportFileId;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
public String getSoftwareName() {
return softwareName;
}
public void setSoftwareName(String softwareName) {
this.softwareName = softwareName;
}
public String getSoftwareVersion() {
return softwareVersion;
}
public void setSoftwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
}
public String getCreatedDate1() {
return createdDate1;
}
public void setCreatedDate1(String createdDate1) {
this.createdDate1 = createdDate1;
}
public String getCreatedDate2() {
return createdDate2;
}
public void setCreatedDate2(String createdDate2) {
this.createdDate2 = createdDate2;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getBatStatus() {
return batStatus;
}
public void setBatStatus(String batStatus) {
this.batStatus = batStatus;
}
public String getPrjId() {
return prjId;
}
public void setPrjId(String prjId) {
this.prjId = prjId;
}
public String getOssComponentsStr() {
return ossComponentsStr;
}
public void setOssComponentsStr(String ossComponentsStr) {
this.ossComponentsStr = ossComponentsStr;
}
public String getOssComponentsLicenseStr() {
return ossComponentsLicenseStr;
}
public void setOssComponentsLicenseStr(String ossComponentsLicenseStr) {
this.ossComponentsLicenseStr = ossComponentsLicenseStr;
}
public String getBatErrorMsg() {
return batErrorMsg;
}
public void setBatErrorMsg(String batErrorMsg) {
this.batErrorMsg = batErrorMsg;
}
public String getBatResultCount() {
return batResultCount;
}
public void setBatResultCount(String batResultCount) {
this.batResultCount = batResultCount;
}
public List<BatWatcher> getBatWatcher() {
return batWatcher;
}
public void addBatWatcher(String division, String userId) {
if (!isEmpty(division)) {
BatWatcher bean = new BatWatcher();
bean.setDivision(division);
bean.setUserId(userId);
bean.setBatId(this.batId);
if (this.batWatcher == null) {
this.batWatcher = new ArrayList<BatWatcher>();
}
this.batWatcher.add(bean);
}
}
public void setBatWatcher(List<BatWatcher> batWatcher) {
this.batWatcher = batWatcher;
}
public String[] getWatcherDivision() {
return watcherDivision != null ? watcherDivision.clone() : null;
}
public void setWatcherDivision(String[] watcherDivision) {
this.watcherDivision = watcherDivision != null ?
watcherDivision.clone() : null;
}
public String[] getWatcherUserId() {
return watcherUserId != null ? watcherUserId.clone() : null;
}
public void setWatcherUserId(String[] watcherUserId) {
this.watcherUserId = watcherUserId != null ?
watcherUserId.clone() : null;
}
public String getBinaryFileName() {
return binaryFileName;
}
public void setBinaryFileName(String binaryFileName) {
this.binaryFileName = binaryFileName;
}
public String getProcId() {
return procId;
}
public void setProcId(String procId) {
this.procId = procId;
}
//WATCHER
public String getBatDivision() {
return batDivision;
}
public void setBatDivision(String batDivision) {
this.batDivision = batDivision;
}
public String getBatDivisionName() {
return batDivisionName;
}
public void setBatDivisionName(String batDivisionName) {
this.batDivisionName = batDivisionName;
}
public String getBatUserId() {
return batUserId;
}
public void setBatUserId(String batUserId) {
this.batUserId = batUserId;
}
public String getBatUserName() {
return batUserName;
}
public void setBatUserName(String batUserName) {
this.batUserName = batUserName;
}
public String getBatEmail() {
return batEmail;
}
public void setBatEmail(String batEmail) {
this.batEmail = batEmail;
}
public String[] getWatchers() {
return watchers != null ? watchers.clone() : null;
}
public void setWatchers(String[] watchers) {
this.watchers = watchers != null ? watchers.clone() : null;
}
public List<BinaryMaster> getWatcherList() {
return watcherList;
}
public void setWatcherList(List<BinaryMaster> watcherList) {
this.watcherList = watcherList;
}
public ArrayList<Map<String, String>> getDivisionList() {
return divisionList;
}
public void setDivisionList(ArrayList<Map<String, String>> divisionList) {
this.divisionList = divisionList;
}
public ArrayList<Map<String, String>> getEmailList() {
return emailList;
}
public void setEmailList(ArrayList<Map<String, String>> emailList) {
this.emailList = emailList;
}
public String getPartnerId() {
return partnerId;
}
public void setPartnerId(String partnerId) {
this.partnerId = partnerId;
}
public String getListKind() {
return listKind;
}
public void setListKind(String listKind) {
this.listKind = listKind;
}
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
public String getProcStartTime() {
return procStartTime;
}
public void setProcStartTime(String procStartTime) {
this.procStartTime = procStartTime;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDivisionName() {
return divisionName;
}
public void setDivisionName(String divisionName) {
this.divisionName = divisionName;
}
} | 8,359 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssMaster.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssMaster.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.util.StringUtil;
public class OssMaster extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 702862084569729284L;
/** The group key. */
private String groupKey;
/** The ref oss id. */
private String refOssId;
/** The oss id. */
private String ossId;
/** The oss name. */
private String ossName;
/** ๊ฒ์์ฉ. */
private String schOssName;
/** The oss name With Version. */
private String ossNameVerStr;
/** The oss name temp. */
private String ossNameTemp;
/** The oss version. */
private String ossVersion;
/** The copyright. */
private String copyright;
/** The license div. */
private String licenseDiv;
/** The tot license txt. */
private String totLicenseTxt;
/** The download location. */
private String downloadLocation;
private String downloadLocationGroup;
/** The download location. */
private String[] downloadLocations;
private List<String> detectedLicenses;
/** The download location link format. */
private String downloadLocationLinkFormat;
/** The homepage. */
private String homepage;
/** The homepage link format. */
private String homepageLinkFormat;
/** The summary description. */
private String summaryDescription;
/** The oss type. */
private String ossType;
/** The cvss score. */
private String cvssScore;
/** The cvss score to. */
private String cvssScoreTo;
/** The cvss score icon. */
private String cvssScoreIcon;
/** The multi flag. */
private String multiFlag;
/** The cve id. */
private String cveId;
/** The cve id to. */
private String cveIdTo;
/** The new oss id. */
private String newOssId; //ossId ๋ณํฉ์ ์ํ ossId
private String delOssId;
/** OSS ์ญ์ ์ Merge ๊ฒฐ๊ณผ ํ์์ฉ. */
private String mergeStr;
/** The oss id list. */
private List<String> ossIdList;
/** The license id list. */
private List<String> licenseIdList;
/** The license comb list. */
private List<String> licenseCombList;
/** The license id. */
//OSS_LICENSE
private String licenseId;
/** The oss license idx. */
private String ossLicenseIdx;
/** The oss license comb. */
private String ossLicenseComb;
/** The oss license text. */
private String ossLicenseText;
/** The oss copyright. */
private String ossCopyright;
/** The copyrights. */
private String[] copyrights;
/** The oss licenses. */
private List<OssLicense> ossLicenses;
/** The oss licenses json. */
private String ossLicensesJson;
/** The oss nicknames. */
//OSS_NICKNAME
private String[] ossNicknames;
private String[] ossNicknameArr;
/** The oss nickname. */
private String ossNickname;
/** The license name. */
//LICENSE
private String licenseName;
/** The license type. */
private String ossLicenseType;
/** The license type. */
private String licenseType;
/** The obligation type. */
private String obligationType;
/** The license type. */
private String orgLicenseType;
/** The obligation type. */
private String orgObligationType;
/** The obligation. */
private String obligation;
/** The obligation checks. */
private String obligationChecks;
/** The c start date. */
//๋ ์ง๊ฒ์์กฐ๊ฑด
private String cStartDate; //์์ฑ์ผ(์์)
/** The c end date. */
private String cEndDate; //์์ฑ์ผ(๋)
/** The m start date. */
private String mStartDate; //์์ ์ผ(์์)
/** The m end date. */
private String mEndDate; //์์ ์ผ(๋)
/** The component id. */
//components
private String componentId;
/** The prj id. */
private String prjId;
/** The vuln summary. */
private String vulnSummary;
/** The cve cnt. */
private String cveCnt;
/** The comment. */
//comment ์ด๋ ฅ
private String comment;
/** The multi license flag. */
private String multiLicenseFlag;
/** The dual license flag. */
private String dualLicenseFlag;
/** The version diff flag. */
private String versionDiffFlag;
/** License Operation Expression. */
private String licenseOprExp;
/** ํ๋ฉด ๊ฒ์์ธ ๊ฒฝ์ฐ Y. */
private String searchFlag;
/** The oss names. */
private String[] ossNames;
/** oss license Name ๊ฒ์์ธ ๊ฒฝ์ฐ ์ต์์ ๋ฒ์ ์ฒดํฌ ์ฌ๋ถ . */
private String versionCheck;
/** vulnerability ์กฐํ ์กฐ๊ฑด. */
private String vulnType;
/** The vuln recheck. */
private String vulnRecheck;
/** The vuln date. */
private String vulnDate;
/** The vuln yn. */
private String vulnYn;
private List<Project> refProjectList;
/** The validationType. */
private String validationType;
/** The sOrder. */
private String sOrder;
private String publishedDate;
/** The attribution. */
private String attribution; //attribution
/** ์ผ๊ด๋ฑ๋ก ์ฒ๋ฆฌ์ ๋ฑ๋ก type */
private String regType;
/** The componentId List. */
private List<String> componentIdList;
private String ossNameAllSearchFlag;
private String ossTypeSearch;
private String licenseNameAllSearchFlag;
private String homepageAllSearchFlag;
private String startAnalysisFlag;
private String analysisYn;
private String completeYn;
private String addNicknameYn = "N";
private String referenceDiv;
private String deactivateFlag = "N";
private String[] ossIds;
private String syncRefOssId;
private String[] syncItem;
private String ossMergeReferenceId;
private String registMergeFlag;
private String mergeOssId;
private String mergeOssName;
private String mergeOssVersion;
private String renameFlag = "N";
private String ossCopyFlag = "N";
private String defaultSearchFlag;
private String[] existOssNickNames;
private List<String> declaredLicenses;
private String linkFlag = "N";
private int[] csvComponentIdList;
private String[] dashOssNameList;
private String[] conversionNameList;
private String cvssScoreMax;
private String cvssScoreMax1;
private String cvssScoreMax2;
private String cvssScoreMax3;
private String vulnerabilityCheckFlag;
private String sndMailCheckFlag;
private Float securityStandardScore;
private Float standardScore;
public int[] getCsvComponentIdList() {
return csvComponentIdList;
}
public void setCsvComponentIdList(int[] csvComponentIdList) {
this.csvComponentIdList = csvComponentIdList;
}
/**
* Instantiates a new oss master.
*/
public OssMaster() {
super();
}
/**
* Instantiates a new oss master.
*
* @param ossId the oss id
*/
public OssMaster(String ossId) {
super();
this.ossId = ossId;
}
public String getPublishedDate() {
return publishedDate;
}
public void setPublishedDate(String publishedDate) {
this.publishedDate = publishedDate;
}
/**
* Instantiates a new oss master.
*
* @param ossId the oss id
* @param licenseId the license id
* @param ossLicenseIdx the oss license idx
*/
public OssMaster(String ossId, String licenseId, String ossLicenseIdx) {
super();
this.ossId = ossId;
this.licenseId = licenseId;
this.ossLicenseIdx = ossLicenseIdx;
}
/**
* Instantiates a new oss master.
*
* @param ossLicenseIdx the oss license idx
* @param ossId the oss id
* @param licenseName the license name
* @param ossLicenseComb the oss license comb
* @param ossLicenseText the oss license text
* @param ossCopyright the oss copyright
* @param licenseDiv the license div
*/
public OssMaster(String ossLicenseIdx, String ossId, String licenseId, String licenseName, String ossLicenseComb, String ossLicenseText,
String ossCopyright, String licenseDiv) {
super();
this.ossLicenseIdx = ossLicenseIdx;
this.ossId = ossId;
this.licenseId = licenseId;
this.licenseName = licenseName;
this.ossLicenseComb = ossLicenseComb;
this.ossLicenseText = ossLicenseText;
this.ossCopyright = ossCopyright;
this.licenseDiv = licenseDiv;
}
/**
* Gets the oss id.
*
* @return the oss id
*/
public String getOssId() {
return ossId;
}
/**
* Sets the oss id.
*
* @param ossId the new oss id
*/
public void setOssId(String ossId) {
this.ossId = ossId;
}
/**
* Gets the oss name.
*
* @return the oss name
*/
public String getOssName() {
return ossName;
}
/**
* Sets the oss name.
*
* @param ossName the new oss name
*/
public void setOssName(String ossName) {
this.ossName = ossName;
}
/**
* Gets the oss version.
*
* @return the oss version
*/
public String getOssVersion() {
return ossVersion;
}
/**
* Sets the oss version.
*
* @param ossVersion the new oss version
*/
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
/**
* Gets the license div.
*
* @return the license div
*/
public String getLicenseDiv() {
return licenseDiv;
}
/**
* Sets the license div.
*
* @param licenseDiv the new license div
*/
public void setLicenseDiv(String licenseDiv) {
this.licenseDiv = licenseDiv;
}
/**
* Gets the tot license txt.
*
* @return the tot license txt
*/
public String getTotLicenseTxt() {
return totLicenseTxt;
}
/**
* Sets the tot license txt.
*
* @param totLicenseTxt the new tot license txt
*/
public void setTotLicenseTxt(String totLicenseTxt) {
this.totLicenseTxt = totLicenseTxt;
}
/**
* Gets the homepage.
*
* @return the homepage
*/
public String getHomepage() {
return CommonFunction.convertUrlLinkFormat(homepage);
}
/**
* Sets the homepage.
*
* @param homepage the new homepage
*/
public void setHomepage(String homepage) {
this.homepage = homepage;
}
/**
* Gets the summary description.
*
* @return the summary description
*/
public String getSummaryDescription() {
return summaryDescription;
}
/**
* Sets the summary description.
*
* @param summaryDescription the new summary description
*/
public void setSummaryDescription(String summaryDescription) {
this.summaryDescription = summaryDescription;
}
/**
* Gets the download location.
*
* @return the download location
*/
public String getDownloadLocation() {
return CommonFunction.convertUrlLinkFormat(downloadLocation);
}
/**
* Sets the download location.
*
* @param downloadLocation the new download location
*/
public void setDownloadLocation(String downloadLocation) {
this.downloadLocation = downloadLocation;
}
public String[] getDownloadLocations() {
return downloadLocations != null ? downloadLocations.clone() : null;
}
public void setDownloadLocations(String[] downloadLocations) {
this.downloadLocations = downloadLocations != null ?
downloadLocations.clone() : null;
}
/**
* Gets the license id.
*
* @return the license id
*/
public String getLicenseId() {
return licenseId;
}
/**
* Sets the license id.
*
* @param licenseId the new license id
*/
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
/**
* Gets the oss license idx.
*
* @return the oss license idx
*/
public String getOssLicenseIdx() {
return ossLicenseIdx;
}
/**
* Sets the oss license idx.
*
* @param ossLicenseIdx the new oss license idx
*/
public void setOssLicenseIdx(String ossLicenseIdx) {
this.ossLicenseIdx = ossLicenseIdx;
}
/**
* Gets the oss license comb.
*
* @return the oss license comb
*/
public String getOssLicenseComb() {
return ossLicenseComb;
}
/**
* Sets the oss license comb.
*
* @param ossLicenseComb the new oss license comb
*/
public void setOssLicenseComb(String ossLicenseComb) {
this.ossLicenseComb = ossLicenseComb;
}
/**
* Gets the oss license text.
*
* @return the oss license text
*/
public String getOssLicenseText() {
return ossLicenseText;
}
/**
* Sets the oss license text.
*
* @param ossLicenseText the new oss license text
*/
public void setOssLicenseText(String ossLicenseText) {
this.ossLicenseText = ossLicenseText;
}
/**
* Gets the oss copyright.
*
* @return the oss copyright
*/
public String getOssCopyright() {
return ossCopyright;
}
/**
* Sets the oss copyright.
*
* @param ossCopyright the new oss copyright
*/
public void setOssCopyright(String ossCopyright) {
this.ossCopyright = ossCopyright;
}
/**
* Gets the oss nickname.
*
* @return the oss nickname
*/
public String getOssNickname() {
return ossNickname;
}
/**
* Sets the oss nickname.
*
* @param ossNickname the new oss nickname
*/
public void setOssNickname(String ossNickname) {
this.ossNickname = ossNickname;
}
/**
* Gets the c start date.
*
* @return the c start date
*/
public String getcStartDate() {
return cStartDate;
}
/**
* Sets the c start date.
*
* @param cStartDate the new c start date
*/
public void setcStartDate(String cStartDate) {
this.cStartDate = cStartDate;
}
/**
* Gets the c end date.
*
* @return the c end date
*/
public String getcEndDate() {
return cEndDate;
}
/**
* Sets the c end date.
*
* @param cEndDate the new c end date
*/
public void setcEndDate(String cEndDate) {
this.cEndDate = cEndDate;
}
/**
* Gets the m start date.
*
* @return the m start date
*/
public String getmStartDate() {
return mStartDate;
}
/**
* Sets the m start date.
*
* @param mStartDate the new m start date
*/
public void setmStartDate(String mStartDate) {
this.mStartDate = mStartDate;
}
/**
* Gets the m end date.
*
* @return the m end date
*/
public String getmEndDate() {
return mEndDate;
}
/**
* Sets the m end date.
*
* @param mEndDate the new m end date
*/
public void setmEndDate(String mEndDate) {
this.mEndDate = mEndDate;
}
/**
* Gets the obligation.
*
* @return the obligation
*/
public String getObligation() {
return obligation;
}
/**
* Sets the obligation.
*
* @param obligation the new obligation
*/
public void setObligation(String obligation) {
this.obligation = obligation;
}
/**
* Gets the license type.
*
* @return the license type
*/
public String getLicenseType() {
return licenseType;
}
/**
* Sets the license type.
*
* @param licenseType the new license type
*/
public void setLicenseType(String licenseType) {
this.licenseType = licenseType;
}
/**
* Gets the license name.
*
* @return the license name
*/
public String getLicenseName() {
return licenseName;
}
/**
* Sets the license name.
*
* @param licenseName the new license name
*/
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
/**
* Gets the copyrights.
*
* @return the copyrights
*/
public String[] getCopyrights() {
return copyrights != null ? copyrights.clone() : null;
}
/**
* Sets the copyrights.
*
* @param copyrights the new copyrights
*/
public void setCopyrights(String copyrights) {
String[] copys = copyrights.split("\r\n");
if (copys[0].equals("") && copys.length == 1){
this.copyrights = null;
}else{
this.copyrights = copys;
}
}
/**
* Gets the oss licenses.
*
* @return the oss licenses
*/
public List<OssLicense> getOssLicenses() {
return ossLicenses;
}
/**
* Sets the oss licenses.
*
* @param ossLicenses the new oss licenses
*/
public void setOssLicenses(List<OssLicense> ossLicenses) {
this.ossLicenses = ossLicenses;
}
/**
* Gets the oss licenses json.
*
* @return the oss licenses json
*/
public String getOssLicensesJson() {
return ossLicensesJson;
}
/**
* Sets the oss licenses json.
*
* @param ossLicensesJson the new oss licenses json
*/
public void setOssLicensesJson(String ossLicensesJson) {
this.ossLicensesJson = ossLicensesJson;
}
/**
* Gets the obligation checks.
*
* @return the obligation checks
*/
public String getObligationChecks() {
return obligationChecks;
}
/**
* Sets the obligation checks.
*
* @param obligationChecks the new obligation checks
*/
public void setObligationChecks(String obligationChecks) {
this.obligationChecks = obligationChecks;
}
/**
* Gets the component id.
*
* @return the component id
*/
public String getComponentId() {
return componentId;
}
/**
* Sets the component id.
*
* @param componentId the new component id
*/
public void setComponentId(String componentId) {
this.componentId = componentId;
}
/**
* Gets the oss type.
*
* @return the oss type
*/
public String getOssType() {
return ossType;
}
/**
* Sets the oss type.
*
* @param ossType the new oss type
*/
public void setOssType(String ossType) {
if (ossType != null && ossType.length() == 3) {
String _rtn = "";
if ("1".equals(ossType.substring(0, 1))) {
_rtn += "M";
}
if ("1".equals(ossType.substring(1,2))) {
_rtn += "D";
}
if ("1".equals(ossType.substring(2, 3))) {
_rtn += "V";
}
ossType = _rtn;
}
this.ossType = ossType;
}
/**
* Gets the obligation type.
*
* @return the obligation type
*/
public String getObligationType() {
return obligationType;
}
/**
* Sets the obligation type.
*
* @param obligationType the new obligation type
*/
public void setObligationType(String obligationType) {
this.obligationType = obligationType;
}
/**
* Gets the comment.
*
* @return the comment
*/
public String getComment() {
return comment;
}
/**
* Sets the comment.
*
* @param comment the new comment
*/
public void setComment(String comment) {
this.comment = comment;
}
/**
* Adds the oss license.
*
* @param bean the bean
*/
public void addOssLicense(OssLicense bean) {
if (bean != null) {
if (this.ossLicenses == null) {
this.ossLicenses = new ArrayList<>();
}
this.ossLicenses.add(bean);
Collections.sort(this.ossLicenses, new Comparator<OssLicense>() {
@Override
public int compare(OssLicense o1, OssLicense o2) {
return o1.getOssLicenseIdx().compareTo(o2.getOssLicenseIdx());
}
});
}
}
/**
* Gets the cvss score.
*
* @return the cvss score
*/
public String getCvssScore() {
return cvssScore;
}
/**
* Sets the cvss score.
*
* @param cvssScore the new cvss score
*/
public void setCvssScore(String cvssScore) {
this.cvssScore = cvssScore;
setCvssScoreIcon();
}
/**
* Gets the cvss score icon.
*
* @return the cvss score icon
*/
public String getCvssScoreIcon() {
return cvssScoreIcon;
}
/**
* Sets the cvss score icon.
*/
public void setCvssScoreIcon() {
String convertCvssScore = cvssScore;
if (!StringUtil.isEmpty(convertCvssScore)){
if (convertCvssScore.indexOf("->") > -1) {
convertCvssScore = convertCvssScore.split("->")[1].trim();
}
if (Double.parseDouble(convertCvssScore) <= 3.9){
cvssScoreIcon = "L";
}else if (Double.parseDouble(convertCvssScore) <= 6.9){
cvssScoreIcon = "M";
}else if (Double.parseDouble(convertCvssScore) <= 10.0){
cvssScoreIcon = "H";
}
}
}
/**
* Gets the multi flag.
*
* @return the multi flag
*/
public String getMultiFlag() {
return multiFlag;
}
/**
* Sets the multi flag.
*
* @param multiFlag the new multi flag
*/
public void setMultiFlag(String multiFlag) {
this.multiFlag = multiFlag;
}
/**
* Gets the cve id.
*
* @return the cve id
*/
public String getCveId() {
return cveId;
}
/**
* Sets the cve id.
*
* @param cveId the new cve id
*/
public void setCveId(String cveId) {
this.cveId = cveId;
}
/**
* Sets the cve id text.
*/
public void setCveIdText() {
if (!StringUtil.isEmpty(cveId)){
if (cveId.indexOf("CVE-") == -1){
cveId = "CVE-"+cveId;
}
}
}
/**
* Gets the oss names.
*
* @return the oss names
*/
public String[] getOssNames() {
return ossNames != null ? ossNames.clone() : null;
}
/**
* Sets the oss names.
*
* @param ossNames the new oss names
*/
public void setOssNames(String[] ossNames) {
this.ossNames = ossNames != null ? ossNames.clone() : null;
}
/**
* Gets the new oss id.
*
* @return the new oss id
*/
public String getNewOssId() {
return newOssId;
}
/**
* Sets the new oss id.
*
* @param newOssId the new new oss id
*/
public void setNewOssId(String newOssId) {
this.newOssId = newOssId;
}
/**
* Gets the license opr exp.
*
* @return the license opr exp
*/
public String getLicenseOprExp() {
if (isEmpty(licenseOprExp) && this.ossLicenses != null && !this.ossLicenses.isEmpty()) {
return CommonFunction.makeLicenseExpression(getOssLicenses());
}
return licenseOprExp;
}
/**
* Sets the license opr exp.
*
* @param licenseOprExp the new license opr exp
*/
public void setLicenseOprExp(String licenseOprExp) {
this.licenseOprExp = licenseOprExp;
}
/**
* Gets the copyright.
*
* @return the copyright
*/
public String getCopyright() {
return copyright;
}
/**
* Sets the copyright.
*
* @param copyright the new copyright
*/
public void setCopyright(String copyright) {
this.copyright = copyright;
}
/**
* Gets the oss nicknames.
*
* @return the oss nicknames
*/
public String[] getOssNicknames() {
return ossNicknames != null ? ossNicknames.clone() : null;
}
/**
* Sets the oss nicknames.
*
* @param ossNicknames the new oss nicknames
*/
public void setOssNicknames(String[] ossNicknames) {
this.ossNicknames = ossNicknames != null ? ossNicknames.clone() : null;
}
/**
* Gets the oss id list.
*
* @return the oss id list
*/
public List<String> getOssIdList() {
return ossIdList;
}
/**
* Sets the oss id list.
*
* @param ossIdList the new oss id list
*/
public void setOssIdList(List<String> ossIdList) {
this.ossIdList = ossIdList;
}
/**
* Adds the oss id list.
*
* @param s the s
*/
public void addOssIdList(String s) {
if (this.ossIdList == null) {
this.ossIdList = new ArrayList<>();
}
if (!isEmpty(s) && !ossIdList.contains(s)) {
this.ossIdList.add(s);
}
}
/**
* Adds the license id list.
*
* @param s the s
*/
public void addLicenseIdList(String s) {
if (this.licenseIdList == null) {
this.licenseIdList = new ArrayList<>();
}
this.licenseIdList.add(s);
}
/**
* Gets the license id list.
*
* @return the license id list
*/
public List<String> getLicenseIdList() {
return licenseIdList;
}
/**
* Sets the license id list.
*
* @param licenseIdList the new license id list
*/
public void setLicenseIdList(List<String> licenseIdList) {
this.licenseIdList = licenseIdList;
}
/**
* Gets the ref oss id.
*
* @return the ref oss id
*/
public String getRefOssId() {
return refOssId;
}
/**
* Sets the ref oss id.
*
* @param refOssId the new ref oss id
*/
public void setRefOssId(String refOssId) {
this.refOssId = refOssId;
}
/**
* Adds the license comb list.
*
* @param s the s
*/
public void addLicenseCombList(String s) {
if (this.licenseCombList == null) {
this.licenseCombList = new ArrayList<>();
}
this.licenseCombList.add(s);
}
/**
* Gets the license comb list.
*
* @return the license comb list
*/
public List<String> getLicenseCombList() {
return licenseCombList;
}
/**
* Sets the license comb list.
*
* @param licenseCombList the new license comb list
*/
public void setLicenseCombList(List<String> licenseCombList) {
this.licenseCombList = licenseCombList;
}
/**
* Append oss type.
*
* @param s the s
*/
public void appendOssType(String s) {
if (this.ossType == null){
this.ossType="";
}
this.ossType += s;
}
/**
* Gets the prj id.
*
* @return the prj id
*/
public String getPrjId() {
return prjId;
}
/**
* Sets the prj id.
*
* @param prjId the new prj id
*/
public void setPrjId(String prjId) {
this.prjId = prjId;
}
/**
* Gets the vuln summary.
*
* @return the vuln summary
*/
public String getVulnSummary() {
return vulnSummary;
}
/**
* Sets the vuln summary.
*
* @param vulnSummary the new vuln summary
*/
public void setVulnSummary(String vulnSummary) {
this.vulnSummary = vulnSummary;
}
/**
* Gets the cve cnt.
*
* @return the cve cnt
*/
public String getCveCnt() {
return cveCnt;
}
/**
* Sets the cve cnt.
*
* @param cveCnt the new cve cnt
*/
public void setCveCnt(String cveCnt) {
this.cveCnt = cveCnt;
}
/**
* Sets the cvss score icon.
*
* @param cvssScoreIcon the new cvss score icon
*/
public void setCvssScoreIcon(String cvssScoreIcon) {
this.cvssScoreIcon = cvssScoreIcon;
}
/**
* Gets the group key.
*
* @return the group key
*/
public String getGroupKey() {
return groupKey;
}
/**
* Sets the group key.
*
* @param groupKey the new group key
*/
public void setGroupKey(String groupKey) {
this.groupKey = groupKey;
}
/**
* Gets the oss name temp.
*
* @return the oss name temp
*/
public String getOssNameTemp() {
return ossNameTemp;
}
/**
* Sets the oss name temp.
*
* @param ossNameTemp the new oss name temp
*/
public void setOssNameTemp(String ossNameTemp) {
this.ossNameTemp = ossNameTemp;
}
/**
* Gets the multi license flag.
*
* @return the multi license flag
*/
public String getMultiLicenseFlag() {
return multiLicenseFlag;
}
/**
* Sets the multi license flag.
*
* @param multiLicenseFlag the new multi license flag
*/
public void setMultiLicenseFlag(String multiLicenseFlag) {
this.multiLicenseFlag = multiLicenseFlag;
}
/**
* Gets the dual license flag.
*
* @return the dual license flag
*/
public String getDualLicenseFlag() {
return dualLicenseFlag;
}
/**
* Sets the dual license flag.
*
* @param dualLicenseFlag the new dual license flag
*/
public void setDualLicenseFlag(String dualLicenseFlag) {
this.dualLicenseFlag = dualLicenseFlag;
}
/**
* Gets the version diff flag.
*
* @return the version diff flag
*/
public String getVersionDiffFlag() {
return versionDiffFlag;
}
/**
* Sets the version diff flag.
*
* @param versionDiffFlag the new version diff flag
*/
public void setVersionDiffFlag(String versionDiffFlag) {
this.versionDiffFlag = versionDiffFlag;
}
/**
* Gets the search flag.
*
* @return the search flag
*/
public String getSearchFlag() {
return searchFlag;
}
/**
* Sets the search flag.
*
* @param searchFlag the new search flag
*/
public void setSearchFlag(String searchFlag) {
this.searchFlag = searchFlag;
}
/**
* Gets the version check.
*
* @return the version check
*/
public String getVersionCheck() {
return versionCheck;
}
/**
* Sets the version check.
*
* @param versionCheck the new version check
*/
public void setVersionCheck(String versionCheck) {
this.versionCheck = versionCheck;
}
/**
* Gets the oss name ver str.
*
* @return the oss name ver str
*/
public String getOssNameVerStr() {
return ossNameVerStr;
}
/**
* Sets the oss name ver str.
*
* @param ossNameVerStr the new oss name ver str
*/
public void setOssNameVerStr(String ossNameVerStr) {
this.ossNameVerStr = ossNameVerStr;
}
/**
* Gets the vuln type.
*
* @return the vuln type
*/
public String getVulnType() {
return vulnType;
}
/**
* Sets the vuln type.
*
* @param vulnType the new vuln type
*/
public void setVulnType(String vulnType) {
this.vulnType = vulnType;
}
/**
* Gets the oss license type.
*
* @return the ossLicenseType
*/
public String getOssLicenseType() {
return ossLicenseType;
}
/**
* Sets the oss license type.
*
* @param ossLicenseType the ossLicenseType to set
*/
public void setOssLicenseType(String ossLicenseType) {
this.ossLicenseType = ossLicenseType;
}
/**
* Gets the org license type.
*
* @return the orgLicenseType
*/
public String getOrgLicenseType() {
return orgLicenseType;
}
/**
* Sets the org license type.
*
* @param orgLicenseType the orgLicenseType to set
*/
public void setOrgLicenseType(String orgLicenseType) {
this.orgLicenseType = orgLicenseType;
}
/**
* Gets the org obligation type.
*
* @return the orgObligationType
*/
public String getOrgObligationType() {
return orgObligationType;
}
/**
* Sets the org obligation type.
*
* @param orgObligationType the orgObligationType to set
*/
public void setOrgObligationType(String orgObligationType) {
this.orgObligationType = orgObligationType;
}
/**
* Gets the vuln recheck.
*
* @return the vuln recheck
*/
public String getVulnRecheck() {
return vulnRecheck;
}
/**
* Sets the vuln recheck.
*
* @param vulnRecheck the new vuln recheck
*/
public void setVulnRecheck(String vulnRecheck) {
this.vulnRecheck = vulnRecheck;
}
/**
* Gets the download location link format.
*
* @return the download location link format
*/
public String getDownloadLocationLinkFormat() {
if (StringUtil.isEmpty(this.downloadLocationLinkFormat) && !StringUtil.isEmpty(this.downloadLocation)) {
if (this.downloadLocation.contains(",")){
String[] downloadLocations = this.downloadLocation.split(",");
String result = "";
for (int i = 0 ; i < downloadLocations.length ; i++){
if (i > 0){ result += "<br>"; }
result += "<a href='"+downloadLocations[i]+"' target='_blank'>" + downloadLocations[i] + "</a>";
}
return result;
}else{
return "<a href='"+this.downloadLocation+"' target='_blank'>" + this.downloadLocation + "</a>";
}
}
return downloadLocationLinkFormat;
}
/**
* Sets the download location link format.
*
* @param downloadLocationLinkFormat the new download location link format
*/
public void setDownloadLocationLinkFormat(String downloadLocationLinkFormat) {
this.downloadLocationLinkFormat = downloadLocationLinkFormat;
}
/**
* Gets the homepage link format.
*
* @return the homepage link format
*/
public String getHomepageLinkFormat() {
if (StringUtil.isEmpty(this.homepageLinkFormat) && !StringUtil.isEmpty(this.homepage)) {
return "<a href='"+this.homepage+"' target='_blank'>" + this.homepage + "</a>";
}
return homepageLinkFormat;
}
/**
* Sets the homepage link format.
*
* @param homepageLinkFormat the new homepage link format
*/
public void setHomepageLinkFormat(String homepageLinkFormat) {
this.homepageLinkFormat = homepageLinkFormat;
}
/**
* Gets the vuln date.
*
* @return the vuln date
*/
public String getVulnDate() {
return vulnDate;
}
/**
* Sets the vuln date.
*
* @param vulnDate the new vuln date
*/
public void setVulnDate(String vulnDate) {
this.vulnDate = vulnDate;
}
/**
* Gets the vuln yn.
*
* @return the vuln yn
*/
public String getVulnYn() {
return vulnYn;
}
/**
* Sets the vuln yn.
*
* @param vulnYn the new vuln yn
*/
public void setVulnYn(String vulnYn) {
this.vulnYn = vulnYn;
}
/**
* Gets the cvss score to.
*
* @return the cvss score to
*/
public String getCvssScoreTo() {
return cvssScoreTo;
}
/**
* Sets the cvss score to.
*
* @param cvssScoreTo the new cvss score to
*/
public void setCvssScoreTo(String cvssScoreTo) {
this.cvssScoreTo = cvssScoreTo;
}
/**
* Gets the cve id to.
*
* @return the cve id to
*/
public String getCveIdTo() {
return cveIdTo;
}
/**
* Sets the cve id to.
*
* @param cveIdTo the new cve id to
*/
public void setCveIdTo(String cveIdTo) {
this.cveIdTo = cveIdTo;
}
/**
* Gets the sch oss name.
*
* @return the sch oss name
*/
public String getSchOssName() {
return schOssName;
}
/**
* Sets the sch oss name.
*
* @param schOssName the new sch oss name
*/
public void setSchOssName(String schOssName) {
this.schOssName = schOssName;
}
/**
* Gets the merge str.
*
* @return the merge str
*/
public String getMergeStr() {
return mergeStr;
}
/**
* Sets the merge str.
*
* @param mergeStr the new merge str
*/
public void setMergeStr(String mergeStr) {
this.mergeStr = mergeStr;
}
public String getDelOssId() {
return delOssId;
}
public void setDelOssId(String delOssId) {
this.delOssId = delOssId;
}
public List<Project> getRefProjectList() {
return refProjectList;
}
public void setRefProjectList(List<Project> refProjectList) {
this.refProjectList = refProjectList;
}
public String getValidationType() {
return validationType;
}
public void setValidationType(String validationType) {
this.validationType = validationType;
}
public String getSOrder() {
return sOrder;
}
public void setSOrder(String sOrder) {
this.sOrder = sOrder;
}
public String getAttribution() {
return attribution;
}
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public String getRegType() {
return regType;
}
public void setRegType(String regType) {
this.regType = regType;
}
public String getDownloadLocationGroup() {
return downloadLocationGroup;
}
public void setDownloadLocationGroup(String downloadLocationGroup) {
// OSS๋ฅผ ์ญ์ ํ๋ฉด์ ๋ค๋ฅธ OSS๋ก rename์, "This oss has multiple version"์ด๋ผ ๋จ๋ฉฐ ์๋ฌ ๋ฐ์. / NullPointException
if (!isEmpty(downloadLocationGroup)){
this.downloadLocations = downloadLocationGroup.split(",");
}
this.downloadLocationGroup = downloadLocationGroup;
}
public String getOssNameAllSearchFlag() {
return ossNameAllSearchFlag;
}
public void setOssNameAllSearchFlag(String ossNameAllSearchFlag) {
this.ossNameAllSearchFlag = ossNameAllSearchFlag;
}
public String getLicenseNameAllSearchFlag() {
return licenseNameAllSearchFlag;
}
public void setLicenseNameAllSearchFlag(String licenseNameAllSearchFlag) {
this.licenseNameAllSearchFlag = licenseNameAllSearchFlag;
}
public String getHomepageAllSearchFlag() {
return homepageAllSearchFlag;
}
public void setHomepageAllSearchFlag(String homepageAllSearchFlag) {
this.homepageAllSearchFlag = homepageAllSearchFlag;
}
public String getOssTypeSearch() {
return ossTypeSearch;
}
public void setOssTypeSearch(String ossTypeSearch) {
this.ossTypeSearch = ossTypeSearch;
}
public List<String> getComponentIdList() {
return componentIdList;
}
public void setComponentIdList(List<String> componentIdList) {
this.componentIdList = componentIdList;
}
public String getStartAnalysisFlag() {
return startAnalysisFlag;
}
public void setStartAnalysisFlag(String startAnalysisFlag) {
this.startAnalysisFlag = startAnalysisFlag;
}
public String getAnalysisYn() {
return analysisYn;
}
public void setAnalysisYn(String analysisYn) {
this.analysisYn = analysisYn;
}
public String getCompleteYn() {
return completeYn;
}
public void setCompleteYn(String completeYn) {
this.completeYn = completeYn;
}
public String getAddNicknameYn() {
return addNicknameYn;
}
public void setAddNicknameYn(String addNicknameYn) {
this.addNicknameYn = addNicknameYn;
}
public void clearDetectLicense() {
this.detectedLicenses = new ArrayList<>();
}
public void setDetectedLicense(String detectedLicense) {
List<String> list = Arrays.asList(detectedLicense.split(","));
this.detectedLicenses = null; // clear
for (String s : list) {
if (!isEmpty(s)) {
this.addDetectedLicense(s.trim());
}
}
}
public List<String> getDetectedLicenses() {
return detectedLicenses == null
? new ArrayList<>()
: detectedLicenses;
}
public String getDetectedLicense() {
return detectedLicenses == null ? "" : String.join(",", detectedLicenses);
}
public void setDetectedLicenses(List<String> detectedLicenses) {
this.detectedLicenses = detectedLicenses;
}
public void addDetectedLicense(String s) {
if (this.detectedLicenses == null) {
this.detectedLicenses = new ArrayList<>();
}
this.detectedLicenses.add(s);
}
public String getReferenceDiv() {
return referenceDiv;
}
public void setReferenceDiv(String referenceDiv) {
this.referenceDiv = referenceDiv;
}
public String getDeactivateFlag() {
return deactivateFlag;
}
public void setDeactivateFlag(String deactivateFlag) {
this.deactivateFlag = deactivateFlag;
}
public String[] getOssIds() {
return ossIds != null ? ossIds.clone() : null;
}
public void setOssIds(String[] ossIds) {
this.ossIds = ossIds != null ? ossIds.clone() : null;
}
public String getSyncRefOssId() {
return syncRefOssId;
}
public void setSyncRefOssId(String syncRefOssId) {
this.syncRefOssId = syncRefOssId;
}
public String[] getSyncItem() {
return syncItem != null ? syncItem.clone() : null;
}
public void setSyncItem(String[] syncItem) {
this.syncItem = syncItem != null ? syncItem.clone() : null;
}
public String getOssMergeReferenceId() {
return ossMergeReferenceId;
}
public void setOssMergeReferenceId(String ossMergeReferenceId) {
this.ossMergeReferenceId = ossMergeReferenceId;
}
public String getRegistMergeFlag() {
return registMergeFlag;
}
public void setRegistMergeFlag(String registMergeFlag) {
this.registMergeFlag = registMergeFlag;
}
public String getMergeOssName() {
return mergeOssName;
}
public void setMergeOssName(String mergeOssName) {
this.mergeOssName = mergeOssName;
}
public String getMergeOssVersion() {
return mergeOssVersion;
}
public void setMergeOssVersion(String mergeOssVersion) {
this.mergeOssVersion = mergeOssVersion;
}
public String getMergeOssId() {
return mergeOssId;
}
public void setMergeOssId(String mergeOssId) {
this.mergeOssId = mergeOssId;
}
public String getOssCopyFlag() {
return ossCopyFlag;
}
public void setOssCopyFlag(String ossCopyFlag) {
this.ossCopyFlag = ossCopyFlag;
}
public String getDefaultSearchFlag() {
return defaultSearchFlag;
}
public void setDefaultSearchFlag(String defaultSearchFlag) {
this.defaultSearchFlag = defaultSearchFlag;
}
public List<String> getDeclaredLicenses() {
return declaredLicenses == null
? new ArrayList<>()
: declaredLicenses;
}
public String getDeclaredLicense() {
return declaredLicenses == null ? "" : String.join(",", declaredLicenses);
}
public void addDeclaredLicense(String s) {
if (this.declaredLicenses == null) {
this.declaredLicenses = new ArrayList<>();
}
this.declaredLicenses.add(s);
}
public void setDeclaredLicense(String declaredLicense) {
String[] list = declaredLicense.split(",");
this.declaredLicenses = null; // clear
for (String s : list) {
if (!isEmpty(s)) {
this.addDeclaredLicense(s.trim());
}
}
}
public String[] getExistOssNickNames() {
return existOssNickNames;
}
public void setExistOssNickNames(String[] existOssNickNames) {
this.existOssNickNames = existOssNickNames;
}
public String getRenameFlag() {
return renameFlag;
}
public void setRenameFlag(String renameFlag) {
this.renameFlag = renameFlag;
}
public String getLinkFlag() {
return linkFlag;
}
public void setLinkFlag(String linkFlag) {
this.linkFlag = linkFlag;
}
public String[] getDashOssNameList() {
return dashOssNameList;
}
public void setDashOssNameList(String[] dashOssNameList) {
this.dashOssNameList = dashOssNameList;
}
public String[] getOssNicknameArr() {
return ossNicknameArr;
}
public void setOssNicknameArr(String[] ossNicknameArr) {
this.ossNicknameArr = ossNicknameArr;
}
public String getCvssScoreMax() {
return cvssScoreMax;
}
public void setCvssScoreMax(String cvssScoreMax) {
this.cvssScoreMax = cvssScoreMax;
}
public String getCvssScoreMax1() {
return cvssScoreMax1;
}
public void setCvssScoreMax1(String cvssScoreMax1) {
this.cvssScoreMax1 = cvssScoreMax1;
}
public String getCvssScoreMax2() {
return cvssScoreMax2;
}
public void setCvssScoreMax2(String cvssScoreMax2) {
this.cvssScoreMax2 = cvssScoreMax2;
}
public String getCvssScoreMax3() {
return cvssScoreMax3;
}
public void setCvssScoreMax3(String cvssScoreMax3) {
this.cvssScoreMax3 = cvssScoreMax3;
}
public String[] getConversionNameList() {
return conversionNameList;
}
public void setConversionNameList(String[] conversionNameList) {
this.conversionNameList = conversionNameList;
}
public String getVulnerabilityCheckFlag() {
return vulnerabilityCheckFlag;
}
public void setVulnerabilityCheckFlag(String vulnerabilityCheckFlag) {
this.vulnerabilityCheckFlag = vulnerabilityCheckFlag;
}
public String getSndMailCheckFlag() {
return sndMailCheckFlag;
}
public void setSndMailCheckFlag(String sndMailCheckFlag) {
this.sndMailCheckFlag = sndMailCheckFlag;
}
public Float getSecurityStandardScore() {
return securityStandardScore;
}
public void setSecurityStandardScore(Float securityStandardScore) {
this.securityStandardScore = securityStandardScore;
}
public Float getStandardScore() {
return standardScore;
}
public void setStandardScore(Float standardScore) {
this.standardScore = standardScore;
}
}
| 43,597 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
GridBean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/GridBean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.util.ArrayList;
import java.util.List;
public class GridBean extends ComBean{
private static final long serialVersionUID = 1481189510461854682L;
private int result; // ์ฑ๊ณต,์คํจ ์ฝ๋ | ์ฑ๊ณต : 0
private int page; // ์ ํ ํ์ด์ง
private int records; // ํํ์ด์ง ํํ ๊ฐ์
private int totCnt; // ์ ์ฒด๊ธ์
private ArrayList<? extends ComBean> rowList;
private ComBean bean;
public GridBean() {}
public GridBean(ArrayList<? extends ComBean> list) {
this.rowList = list;
}
public GridBean(ComBean comBean) {
this.bean = comBean;
}
public GridBean(ArrayList<? extends ComBean> list, ComBean comBean) {
this.rowList = list;
this.bean = comBean;
}
public int getResult() {
return result;
}
public void setResult(int result) {
this.result = result;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getRecords() {
return records;
}
public void setRecords(int records) {
this.records = records;
}
public int getTotCnt() {
return totCnt;
}
public void setTotCnt(int totCnt) {
this.totCnt = totCnt;
}
public List<? extends ComBean> getRowList() {
return rowList;
}
public void setRows(ArrayList<? extends ComBean> rows) {
this.rowList = rows;
}
public ComBean getBean() {
return bean;
}
public void setBean(ComBean bean) {
this.bean = bean;
}
} | 1,665 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
PartnerWatcher.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/PartnerWatcher.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* The Class partnerMaster
*/
public class PartnerWatcher extends ComBean implements Serializable{
private static final long serialVersionUID = 5429990726160434346L;
private String partnerId;
private String division;
private String userId;
private String userName;
private String email;
public String getPartnerId() {
return partnerId;
}
public void setPartnerId(String partnerId) {
this.partnerId = partnerId;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "PartnerWatcher [partnerId=" + partnerId + ", division=" + division + ", userId=" + userId + "]";
}
} | 1,293 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssLicense.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssLicense.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
public class OssLicense extends ComBean implements Serializable {
private static final long serialVersionUID = -2514402041356425806L;
private String ossId; //OSS ์์ด๋
private String licenseDiv; //Single, Multi ๊ตฌ๋ถ
private String licenseId; //๋ผ์ด์ผ์คID
private String ossLicenseIdx; //๋ผ์ด์ผ์ค ์์
private String ossLicenseComb; //๋ผ์ด์ผ์ค
private String ossLicenseText; //๋ผ์ด์ผ์คText
private String ossCopyright; //๋ผ์ด์ผ์ค Copyright
private String licenseName; //๋ผ์ด์ผ์ค ์ด๋ฆ
private String licenseNameEx; //๋ผ์ด์ผ์ค ์ด๋ฆ
private String licenseType; //๋ผ์ด์ผ์ค ํ์
private String obligation;
private String obligationChecks; //Obligation Check ์ํ(๊ณ ์ง, ์์ค๊ณต๊ฐ, ์ฒดํฌ)
public String getOssId() {
return ossId;
}
public void setOssId(String ossId) {
this.ossId = ossId;
}
public String getLicenseDiv() {
return licenseDiv;
}
public void setLicenseDiv(String licenseDiv) {
this.licenseDiv = licenseDiv;
}
public String getLicenseId() {
return licenseId;
}
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
public String getOssLicenseIdx() {
return ossLicenseIdx;
}
public void setOssLicenseIdx(String ossLicenseIdx) {
this.ossLicenseIdx = ossLicenseIdx;
}
public String getOssLicenseComb() {
return ossLicenseComb;
}
public void setOssLicenseComb(String ossLicenseComb) {
this.ossLicenseComb = ossLicenseComb;
}
public String getOssLicenseText() {
return ossLicenseText;
}
public void setOssLicenseText(String ossLicenseText) {
this.ossLicenseText = ossLicenseText;
}
public String getOssCopyright() {
return ossCopyright;
}
public void setOssCopyright(String ossCopyright) {
this.ossCopyright = ossCopyright;
}
public String getLicenseName() {
return licenseName;
}
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
public String getLicenseType() {
return licenseType;
}
public void setLicenseType(String licenseType) {
this.licenseType = licenseType;
}
public String getObligation() {
return obligation;
}
public void setObligation(String obligation) {
this.obligation = obligation;
}
public String getObligationChecks() {
return obligationChecks;
}
public void setObligationChecks(String obligationChecks) {
this.obligationChecks = obligationChecks;
}
public String getLicenseNameEx() {
return licenseNameEx;
}
public void setLicenseNameEx(String licenseNameEx) {
this.licenseNameEx = licenseNameEx;
}
}
| 2,838 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssComponentsLicense.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssComponentsLicense.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
public class OssComponentsLicense extends ComBean implements Serializable {
private static final long serialVersionUID = 4907819340622537583L;
private String componentLicenseId;
private String componentId;
private String licenseId;
private String licenseName;
private String licenseText;
private String copyrightText;
private String excludeYn;
private String licensetype;
private String lastComponentsId;
private String editable;
private String attribution; //attribution
private String webpage;
private String obligationType;
private String ossId;
private String ossLicenseComb; //๋ผ์ด์ผ์ค
public String getComponentLicenseId() {
return componentLicenseId;
}
public void setComponentLicenseId(String componentLicenseId) {
this.componentLicenseId = componentLicenseId;
}
public String getComponentId() {
return componentId;
}
public void setComponentId(String componentId) {
this.componentId = componentId;
}
public String getLicenseId() {
return licenseId;
}
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
public String getLicenseName() {
return licenseName;
}
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
public String getLicenseText() {
return licenseText;
}
public void setLicenseText(String licenseText) {
this.licenseText = licenseText;
}
public String getCopyrightText() {
return copyrightText;
}
public void setCopyrightText(String copyrightText) {
this.copyrightText = copyrightText;
}
public String getExcludeYn() {
return excludeYn;
}
public void setExcludeYn(String excludeYn) {
this.excludeYn = excludeYn;
}
public String getLicensetype() {
return licensetype;
}
public void setLicensetype(String licensetype) {
this.licensetype = licensetype;
}
@Override
public String toString() {
return "OssComponentsLicense [componentLicenseId=" + componentLicenseId + ", componentId=" + componentId
+ ", licenseId=" + licenseId + ", licenseName=" + licenseName + ", licenseText=" + licenseText
+ ", copyrightText=" + copyrightText + ", excludeYn=" + excludeYn + "]";
}
public String getLastComponentsId() {
return lastComponentsId;
}
public void setLastComponentsId(String lastComponentsId) {
this.lastComponentsId = lastComponentsId;
}
public String getOssLicenseComb() {
return ossLicenseComb;
}
public void setOssLicenseComb(String ossLicenseComb) {
this.ossLicenseComb = ossLicenseComb;
}
public String getEditable() {
return editable;
}
public void setEditable(String editable) {
this.editable = editable;
}
public String getAttribution() {
return attribution;
}
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public String getObligationType() {
return obligationType;
}
public void setObligationType(String obligationType) {
this.obligationType = obligationType;
}
public String getOssId() {
return ossId;
}
public void setOssId(String ossId) {
this.ossId = ossId;
}
public String getWebpage() {
return webpage;
}
public void setWebpage(String webpage) {
this.webpage = webpage;
}
} | 3,449 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssComponents.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssComponents.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import oss.fosslight.common.CommonFunction;
public class OssComponents extends ComBean implements Serializable {
private static final long serialVersionUID = 4907819340622537583L;
private String componentId;
private String referenceId;
private String referenceDiv;
private String componentIdx; /* 2018-07-10 choye ์ถ๊ฐ */
private String ossId;
private String ossName;
private String ossVersion;
private String ossCopyright;
private String downloadLocation;
private String homepage;
private String excludeYn;
private String binaryName;
private String binarySize;
/** bin(android) ์ binary txtํ์ผ์ source code path ์ ๋ณด */
private String sourceCodePath;
private String binaryNotice;
private String customBinaryYn;
private String filePath;
private String mergePreDiv;
private String obligationType;
private String refPartnerId;
private String refPartnerName;
private String refPrjId;
private List<OssComponentsLicense> ossComponentsLicense;
private String vulnYn;
private String cvssScore;
private String cveId;
private String oldSystemFlag;
private String spdxIdentifier;
/** The check sum. */
private String batChecksum;
private String verifyFileCount;
private String batStringMatchPercentage;
private String batPercentage;
private String batScore;
// ossComponentsLicense
private String componentLicenseId;
private String licenseId;
private String licenseName;
private String licenseText;
private String licenseType;
private String copyrightText;
private String attribution; //attribution
private String ossAttribution; //attribution
private String prjName;
private String prjVersion;
private String prjId;
private String distributeTarget;
private List<String> ossComponentsIdList;
private String refComponentId;
private String checkSum;
private String tlsh;
private String comments;
private String guireportFlag = "N";
private String activateFlag;
/**
* son system final list report์ฉ
*/
private String reportKey;
/**
* son system final list ref ๋์
*/
private List<String> finalListRefList;
/**
* colspan
* @return
*/
private String rowspan;
private String adminCheckYn;
private String androidFlag;
private String ossNickName;
private String publDate;
private String vulnerabilityResolution;
private String vulnerabilityLink;
private String officialPatchLink;
private String securityPatchLink;
private String securityComments;
private String cpeName;
private String verStartEndRange;
private String cveIdTo;
private String cvssScoreTo;
private String dependencies;
public String getPublDate() {
return publDate;
}
public void setPublDate(String publDate) {
this.publDate = publDate;
}
public String getVulnerabilityResolution() {
return vulnerabilityResolution;
}
public void setVulnerabilityResolution(String vulnerabilityResolution) {
this.vulnerabilityResolution = vulnerabilityResolution;
}
public String getOfficialPatchLink() {
return officialPatchLink;
}
public void setOfficialPatchLink(String officialPatchLink) {
this.officialPatchLink = officialPatchLink;
}
public String getSecurityPatchLink() {
return securityPatchLink;
}
public void setSecurityPatchLink(String securityPatchLink) {
this.securityPatchLink = securityPatchLink;
}
public String getSecurityComments() {
return securityComments;
}
public void setSecurityComments(String securityComments) {
this.securityComments = securityComments;
}
/* 2018-07-10 choye ์ถ๊ฐ */
public String getComponentIdx() {
return componentIdx;
}
public void setComponentIdx(String componentIdx) {
this.componentIdx = componentIdx;
}
public String getReferenceId() {
return referenceId;
}
public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}
public String getReferenceDiv() {
return referenceDiv;
}
public void setReferenceDiv(String referenceDiv) {
this.referenceDiv = referenceDiv;
}
public String getComponentId() {
return componentId;
}
public void setComponentId(String componentId) {
this.componentId = componentId;
}
public String getOssId() {
return ossId;
}
public void setOssId(String ossId) {
this.ossId = ossId;
}
public String getOssName() {
return ossName;
}
public void setOssName(String ossName) {
this.ossName = ossName;
}
public String getOssVersion() {
return ossVersion;
}
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
public String getOssCopyright() {
return ossCopyright;
}
public void setOssCopyright(String ossCopyright) {
this.ossCopyright = ossCopyright;
}
public String getDownloadLocation() {
return CommonFunction.convertUrlLinkFormat(downloadLocation);
}
public void setDownloadLocation(String downloadLocation) {
this.downloadLocation = downloadLocation;
}
public String getHomepage() {
return CommonFunction.convertUrlLinkFormat(homepage);
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public String getExcludeYn() {
return excludeYn;
}
public void setExcludeYn(String excludeYn) {
this.excludeYn = excludeYn;
}
public String getBinaryName() {
return binaryName;
}
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
public String getBinarySize() {
return binarySize;
}
public void setBinarySize(String binarySize) {
this.binarySize = binarySize;
}
public String getBinaryNotice() {
return binaryNotice;
}
public void setBinaryNotice(String binaryNotice) {
this.binaryNotice = binaryNotice;
}
public List<OssComponentsLicense> getOssComponentsLicense() {
return ossComponentsLicense;
}
public void setOssComponentsLicense(List<OssComponentsLicense> ossComponentsLicense) {
this.ossComponentsLicense = ossComponentsLicense;
}
/**
* Adds the oss components license.
*
* @param ossComponentsLicense
* the oss components license
*/
public void addOssComponentsLicense(OssComponentsLicense ossComponentsLicense) {
if (ossComponentsLicense != null) {
if (this.ossComponentsLicense == null) {
this.ossComponentsLicense = new ArrayList<>();
}
this.ossComponentsLicense.add(ossComponentsLicense);
}
}
public String getComponentLicenseId() {
return componentLicenseId;
}
public void setComponentLicenseId(String componentLicenseId) {
this.componentLicenseId = componentLicenseId;
}
public String getLicenseId() {
return licenseId;
}
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
public String getLicenseName() {
return licenseName;
}
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
public String getLicenseText() {
return licenseText;
}
public void setLicenseText(String licenseText) {
this.licenseText = licenseText;
}
public String getCopyrightText() {
return copyrightText;
}
public void setCopyrightText(String copyrightText) {
this.copyrightText = copyrightText;
}
@Override
public String toString() {
return "OssComponents [componentId=" + componentId + ", referenceId=" + referenceId + ", referenceDiv="
+ referenceDiv + ", ossId=" + ossId + ", ossName=" + ossName + ", ossVersion=" + ossVersion
+ ", downloadLocation=" + downloadLocation + ", homepage=" + homepage + ", excludeYn=" + excludeYn
+ ", binaryName=" + binaryName + ", binarySize=" + binarySize + ", binaryNotice=" + binaryNotice
+ ", ossComponentsLicense=" + ossComponentsLicense + ", componentLicenseId=" + componentLicenseId
+ ", licenseId=" + licenseId + ", licenseName=" + licenseName + ", licenseText=" + licenseText
+ ", copyrightText=" + copyrightText + "]";
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getLicenseType() {
return licenseType;
}
public void setLicenseType(String licenseType) {
this.licenseType = licenseType;
}
public String getPrjName() {
return prjName;
}
public void setPrjName(String prjName) {
this.prjName = prjName;
}
public String getMergePreDiv() {
return mergePreDiv;
}
public void setMergePreDiv(String mergePreDiv) {
this.mergePreDiv = mergePreDiv;
}
public String getRefPartnerId() {
return refPartnerId;
}
public void setRefPartnerId(String refPartnerId) {
this.refPartnerId = refPartnerId;
}
public String getRefPrjId() {
return refPrjId;
}
public void setRefPrjId(String refPrjId) {
this.refPrjId = refPrjId;
}
public String getVulnYn() {
return vulnYn;
}
public void setVulnYn(String vulnYn) {
this.vulnYn = vulnYn;
}
public String getBatStringMatchPercentage() {
return batStringMatchPercentage;
}
public void setBatStringMatchPercentage(String batStringMatchPercentage) {
this.batStringMatchPercentage = batStringMatchPercentage;
}
public String getBatPercentage() {
return batPercentage;
}
public void setBatPercentage(String batPercentage) {
this.batPercentage = batPercentage;
}
public String getBatScore() {
return batScore;
}
public void setBatScore(String batScore) {
this.batScore = batScore;
}
public String getObligationType() {
return obligationType;
}
public void setObligationType(String obligationType) {
this.obligationType = obligationType;
}
public List<String> getOssComponentsIdList() {
return ossComponentsIdList;
}
public void setOssComponentsIdList(List<String> ossComponentsIdList) {
this.ossComponentsIdList = ossComponentsIdList;
}
public void addOssComponentsIdList(String s) {
if (this.ossComponentsIdList == null) {
this.ossComponentsIdList = new ArrayList<>();
}
if (!isEmpty(s)) {
this.ossComponentsIdList.add(s);
}
}
public String getRefComponentId() {
return refComponentId;
}
public void setRefComponentId(String refComponentId) {
this.refComponentId = refComponentId;
}
public List<String> getFinalListRefList() {
return finalListRefList;
}
public void setFinalListRefList(List<String> finalListRefList) {
this.finalListRefList = finalListRefList;
}
public String getReportKey() {
return reportKey;
}
public void setReportKey(String reportKey) {
this.reportKey = reportKey;
}
public String getRowspan() {
return rowspan;
}
public void setRowspan(String rowspan) {
this.rowspan = rowspan;
}
public String getVerifyFileCount() {
return verifyFileCount;
}
public void setVerifyFileCount(String verifyFileCount) {
this.verifyFileCount = verifyFileCount;
}
public String getPrjId() {
return prjId;
}
public void setPrjId(String prjId) {
this.prjId = prjId;
}
public String getPrjVersion() {
return prjVersion;
}
public void setPrjVersion(String prjVersion) {
this.prjVersion = prjVersion;
}
public String getDistributeTarget() {
return distributeTarget;
}
public void setDistributeTarget(String distributeTarget) {
this.distributeTarget = distributeTarget;
}
public String getBatChecksum() {
return batChecksum;
}
public void setBatChecksum(String batChecksum) {
this.batChecksum = batChecksum;
}
public String getCvssScore() {
return cvssScore;
}
public void setCvssScore(String cvssScore) {
this.cvssScore = cvssScore;
}
public String getCveId() {
return cveId;
}
public void setCveId(String cveId) {
this.cveId = cveId;
}
public String getCustomBinaryYn() {
return customBinaryYn;
}
public void setCustomBinaryYn(String customBinaryYn) {
this.customBinaryYn = customBinaryYn;
}
public String getAttribution() {
return attribution;
}
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public String getOssAttribution() {
return ossAttribution;
}
public void setOssAttribution(String ossAttribution) {
this.ossAttribution = ossAttribution;
}
public String getOldSystemFlag() {
return oldSystemFlag;
}
public void setOldSystemFlag(String oldSystemFlag) {
this.oldSystemFlag = oldSystemFlag;
}
public String getCheckSum() {
return checkSum;
}
public void setCheckSum(String checkSum) {
this.checkSum = checkSum;
}
public String getTlsh() {
return tlsh;
}
public void setTlsh(String tlsh) {
this.tlsh = tlsh;
}
/**
* @return the comments
*/
public String getComments() {
return comments;
}
/**
* @param comments the comments to set
*/
public void setComments(String comments) {
this.comments = comments;
}
public String getGuireportFlag() {
return guireportFlag;
}
public void setGuireportFlag(String guireportFlag) {
this.guireportFlag = guireportFlag;
}
public String getSourceCodePath() {
return sourceCodePath;
}
public void setSourceCodePath(String sourceCodePath) {
this.sourceCodePath = sourceCodePath;
}
public String getRefPartnerName() {
return refPartnerName;
}
public void setRefPartnerName(String refPartnerName) {
this.refPartnerName = refPartnerName;
}
public String getAdminCheckYn() {
return adminCheckYn;
}
public void setAdminCheckYn(String adminCheckYn) {
this.adminCheckYn = adminCheckYn;
}
public String getAndroidFlag() {
return androidFlag;
}
public void setAndroidFlag(String androidFlag) {
this.androidFlag = androidFlag;
}
public String getOssNickName() {
return ossNickName;
}
public void setOssNickName(String ossNickName) {
this.ossNickName = ossNickName;
}
public String getSpdxIdentifier() {
return spdxIdentifier;
}
public void setSpdxIdentifier(String spdxIdentifier) {
this.spdxIdentifier = spdxIdentifier;
}
public String getActivateFlag() {
return activateFlag;
}
public void setActivateFlag(String activateFlag) {
this.activateFlag = activateFlag;
}
public String getVulnerabilityLink() {
return vulnerabilityLink;
}
public void setVulnerabilityLink(String vulnerabilityLink) {
this.vulnerabilityLink = vulnerabilityLink;
}
public String getCpeName() {
return cpeName;
}
public void setCpeName(String cpeName) {
this.cpeName = cpeName;
}
public String getVerStartEndRange() {
return verStartEndRange;
}
public void setVerStartEndRange(String verStartEndRange) {
this.verStartEndRange = verStartEndRange;
}
public String getCveIdTo() {
return cveIdTo;
}
public void setCveIdTo(String cveIdTo) {
this.cveIdTo = cveIdTo;
}
public String getCvssScoreTo() {
return cvssScoreTo;
}
public void setCvssScoreTo(String cvssScoreTo) {
this.cvssScoreTo = cvssScoreTo;
}
public String getDependencies() {
return dependencies;
}
public void setDependencies(String dependencies) {
this.dependencies = dependencies;
}
} | 15,622 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
PartnerMaster.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/PartnerMaster.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* The Class partnerMaster.
*/
public class PartnerMaster extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -1540732220327083849L;
/** The partner id. */
private String partnerId;
/** The status. */
private String status;
private String[] arrStatuses;
/** The partner name. */
private String partnerName;
/** The software name. */
private String softwareName;
/** The software version. */
private String softwareVersion;
/** The delivery form. */
private String deliveryForm;
/** The public yn. */
private String publicYn;
/** The description. */
private String description;
/** The confirmation file id. */
private String confirmationFileId;
/** The oss file id. */
private String ossFileId;
private String binaryFileId;
/** The related DocumentFile file. */
private List<T2File> documentsFile; // Related documents ํ์ผ ๊ฐ์ฒด
private String documentsFileCnt;
private String documentsFileId;
private String delDocumentsFile;
/** The reviewer. */
private String reviewer;
/** The reviewer name. */
private String reviewerName;
/** The use yn. */
private String useYn;
/** The comment. */
private String comment;
/** The comment text. */
private String commentText;
/** The division. */
private String division;
/** The file name. */
private String fileName;
/** The file name 2. */
private String fileName2;
/** The oss name. */
//๊ฒ์
private String ossName;
/** The license name. */
private String licenseName;
/** The created date 1. */
private String createdDate1;
/** The created date 2. */
private String createdDate2;
/** The binary name. */
private String binaryName;
/** The par division. */
// PARTNER_WATCHER
private String parDivision;
/** The par division name. */
private String parDivisionName;
/** The par user id. */
private String parUserId;
/** The par user name. */
private String parUserName;
/** The par email. */
private String parEmail;
/** The watchers. */
private String[] watchers;
/** The watcher list. */
private List<PartnerMaster> watcherList;
/** The division list. */
private ArrayList<Map<String, String>> divisionList;
/** The email list. */
private ArrayList<Map<String, String>> emailList;
/** The watcher division. */
private String[] watcherDivision;
/** The watcher user id. */
private String[] watcherUserId;
/** The partner watcher. */
private List<PartnerWatcher> partnerWatcher;
/** The comments histroy. */
private List<CommentsHistory> commentsHistroy;
/** The oss components. */
private List<OssComponents> ossComponents;
/** The oss components str. */
private String ossComponentsStr;
/** The oss components license str. */
private String ossComponentsLicenseStr;
/** The user comment. */
private String userComment;
/** The component count. */
private String componentCount;
/** The prj id. */
private String prjId;
/** The third party partner id list. */
private List<String> thirdPartyPartnerIdList;
/** The view only flag. */
private String viewOnlyFlag;
/** list - prj(project), par(3rdparty), bat */
private String listKind;
/** listKind pair id */
private String listId;
private String modelFlag = "N";
private String userRole;
private String ossAnalysisStatus;
private String analysisStartDate;
private String ossVersion;
private String ossNameMergeFlag;
private String ignoreBinaryDbFlag = "N";
/** The vuln yn. */
private String vulnYn;
/** The cvss score. */
private String cvssScore;
/** The cve id. */
private String cveId;
private String[] partnerIds;
private ArrayList<Map<String, String>> changeWatcherList;
private String copyWatcherLocation;
/*
* Gets the partner id.
*
* @return the partner id
*/
public String getPartnerId() {
return partnerId;
}
/**
* Sets the partner id.
*
* @param partnerId the new partner id
*/
public void setPartnerId(String partnerId) {
this.partnerId = partnerId;
}
/**
* Gets the status.
*
* @return the status
*/
public String getStatus() {
return status;
}
/**
* Sets the status.
*
* @param status the new status
*/
public void setStatus(String status) {
this.status = status;
}
/**
* Gets the partner name.
*
* @return the partner name
*/
public String getPartnerName() {
return partnerName;
}
/**
* Sets the partner name.
*
* @param partnerName the new partner name
*/
public void setPartnerName(String partnerName) {
this.partnerName = partnerName;
}
/**
* Gets the software name.
*
* @return the software name
*/
public String getSoftwareName() {
return softwareName;
}
/**
* Sets the software name.
*
* @param softwareName the new software name
*/
public void setSoftwareName(String softwareName) {
this.softwareName = softwareName;
}
/**
* Gets the software version.
*
* @return the software version
*/
public String getSoftwareVersion() {
return softwareVersion;
}
/**
* Sets the software version.
*
* @param softwareVersion the new software version
*/
public void setSoftwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
}
/**
* Gets the delivery form.
*
* @return the delivery form
*/
public String getDeliveryForm() {
return deliveryForm;
}
/**
* Sets the delivery form.
*
* @param deliveryForm the new delivery form
*/
public void setDeliveryForm(String deliveryForm) {
this.deliveryForm = deliveryForm;
}
/**
* Gets the public yn.
*
* @return the public yn
*/
public String getPublicYn() {
return publicYn;
}
/**
* Sets the public yn.
*
* @param publicYn the new public yn
*/
public void setPublicYn(String publicYn) {
this.publicYn = publicYn;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the confirmation file id.
*
* @return the confirmation file id
*/
public String getConfirmationFileId() {
return confirmationFileId;
}
/**
* Sets the confirmation file id.
*
* @param confirmationFileId the new confirmation file id
*/
public void setConfirmationFileId(String confirmationFileId) {
this.confirmationFileId = confirmationFileId;
}
/**
* Gets the oss file id.
*
* @return the oss file id
*/
public String getOssFileId() {
return ossFileId;
}
/**
* Sets the oss file id.
*
* @param ossFileId the new oss file id
*/
public void setOssFileId(String ossFileId) {
this.ossFileId = ossFileId;
}
/**
* Gets the binary file id.
*
* @return the binary file id
*/
public String getBinaryFileId() {
return binaryFileId;
}
/**
* Sets the binary file id.
*
* @param binaryFileId the new binary file id
*/
public void setBinaryFileId(String binaryFileId) {
this.binaryFileId = binaryFileId;
}
/**
* Gets the reviewer.
*
* @return the reviewer
*/
public String getReviewer() {
return reviewer;
}
/**
* Sets the reviewer.
*
* @param reviewer the new reviewer
*/
public void setReviewer(String reviewer) {
this.reviewer = reviewer;
}
/**
* Gets the use yn.
*
* @return the use yn
*/
public String getUseYn() {
return useYn;
}
/**
* Sets the use yn.
*
* @param useYn the new use yn
*/
public void setUseYn(String useYn) {
this.useYn = useYn;
}
/**
* Gets the comment.
*
* @return the comment
*/
public String getComment() {
return comment;
}
/**
* Sets the comment.
*
* @param comment the new comment
*/
public void setComment(String comment) {
this.comment = comment;
}
/**
* Gets the division.
*
* @return the division
*/
public String getDivision() {
return division;
}
/**
* Sets the division.
*
* @param division the new division
*/
public void setDivision(String division) {
this.division = division;
}
/**
* Gets the oss name.
*
* @return the oss name
*/
public String getOssName() {
return ossName;
}
/**
* Sets the oss name.
*
* @param ossName the new oss name
*/
public void setOssName(String ossName) {
this.ossName = ossName;
}
/**
* Gets the license name.
*
* @return the license name
*/
public String getLicenseName() {
return licenseName;
}
/**
* Sets the license name.
*
* @param licenseName the new license name
*/
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
/**
* Gets the created date 1.
*
* @return the created date 1
*/
public String getCreatedDate1() {
return createdDate1;
}
/**
* Sets the created date 1.
*
* @param createdDate1 the new created date 1
*/
public void setCreatedDate1(String createdDate1) {
this.createdDate1 = createdDate1;
}
/**
* Gets the created date 2.
*
* @return the created date 2
*/
public String getCreatedDate2() {
return createdDate2;
}
/**
* Sets the created date 2.
*
* @param createdDate2 the new created date 2
*/
public void setCreatedDate2(String createdDate2) {
this.createdDate2 = createdDate2;
}
/**
* Gets the partner watcher.
*
* @return the partner watcher
*/
public List<PartnerWatcher> getPartnerWatcher() {
return partnerWatcher;
}
/**
* Sets the partner watcher.
*
* @param partnerWatcher the new partner watcher
*/
public void setPartnerWatcher(List<PartnerWatcher> partnerWatcher) {
this.partnerWatcher = partnerWatcher;
}
/**
* Gets the comments histroy.
*
* @return the comments histroy
*/
public List<CommentsHistory> getCommentsHistroy() {
return commentsHistroy;
}
/**
* Sets the comments histroy.
*
* @param commentsHistroy the new comments histroy
*/
public void setCommentsHistroy(List<CommentsHistory> commentsHistroy) {
this.commentsHistroy = commentsHistroy;
}
/**
* Gets the comment text.
*
* @return the comment text
*/
public String getCommentText() {
return commentText;
}
/**
* Sets the comment text.
*
* @param commentText the new comment text
*/
public void setCommentText(String commentText) {
this.commentText = commentText;
}
/**
* Gets the file name.
*
* @return the file name
*/
public String getFileName() {
return fileName;
}
/**
* Sets the file name.
*
* @param fileName the new file name
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* Gets the file name 2.
*
* @return the file name 2
*/
public String getFileName2() {
return fileName2;
}
/**
* Sets the file name 2.
*
* @param fileName2 the new file name 2
*/
public void setFileName2(String fileName2) {
this.fileName2 = fileName2;
}
/**
* Gets the oss components.
*
* @return the oss components
*/
public List<OssComponents> getOssComponents() {
return ossComponents;
}
/**
* Sets the oss components.
*
* @param ossComponents the new oss components
*/
public void setOssComponents(List<OssComponents> ossComponents) {
this.ossComponents = ossComponents;
}
/* (non-Javadoc)
* @see oss.fosslight.commons.components.bean.ComBean#toString()
*/
@Override
public String toString() {
return "PartnerMaster [partnerId=" + partnerId + ", status=" + status + ", partnerName=" + partnerName
+ ", softwareName=" + softwareName + ", softwareVersion=" + softwareVersion + ", deliveryForm="
+ deliveryForm + ", publicYn=" + publicYn + ", description=" + description + ", confirmationFileId="
+ confirmationFileId + ", ossFileId=" + ossFileId + ", reviewer=" + reviewer + ", useYn=" + useYn
+ ", comment=" + comment + ", commentText=" + commentText + ", division=" + division + ", fileName="
+ fileName + ", fileName2=" + fileName2 + ", ossName=" + ossName + ", licenseName=" + licenseName
+ ", createdDate1=" + createdDate1 + ", createdDate2=" + createdDate2 + ", partnerWatcher="
+ partnerWatcher + ", commentsHistroy=" + commentsHistroy + ", ossComponents=" + ossComponents
+ ", componentCount="+ componentCount +"]";
}
/**
* Gets the oss components str.
*
* @return the oss components str
*/
public String getOssComponentsStr() {
return ossComponentsStr;
}
/**
* Sets the oss components str.
*
* @param ossComponentsStr the new oss components str
*/
public void setOssComponentsStr(String ossComponentsStr) {
this.ossComponentsStr = ossComponentsStr;
}
/**
* Gets the oss components license str.
*
* @return the oss components license str
*/
public String getOssComponentsLicenseStr() {
return ossComponentsLicenseStr;
}
/**
* Sets the oss components license str.
*
* @param ossComponentsLicenseStr the new oss components license str
*/
public void setOssComponentsLicenseStr(String ossComponentsLicenseStr) {
this.ossComponentsLicenseStr = ossComponentsLicenseStr;
}
/**
* Gets the watcher division.
*
* @return the watcher division
*/
public String[] getWatcherDivision() {
return watcherDivision != null ? watcherDivision.clone() : null;
}
/**
* Sets the watcher division.
*
* @param watcherDivision the new watcher division
*/
public void setWatcherDivision(String[] watcherDivision) {
this.watcherDivision = watcherDivision != null ?
watcherDivision.clone() : null;
}
/**
* Gets the watcher user id.
*
* @return the watcher user id
*/
public String[] getWatcherUserId() {
return watcherUserId != null ? watcherUserId.clone() : null;
}
/**
* Sets the watcher user id.
*
* @param watcherUserId the new watcher user id
*/
public void setWatcherUserId(String[] watcherUserId) {
this.watcherUserId = watcherUserId != null ?
watcherUserId.clone() : null;
}
/**
* Gets the user comment.
*
* @return the user comment
*/
public String getUserComment() {
return userComment;
}
/**
* Sets the user comment.
*
* @param userComment the new user comment
*/
public void setUserComment(String userComment) {
this.userComment = userComment;
}
/**
* Gets the binary name.
*
* @return the binary name
*/
public String getBinaryName() {
return binaryName;
}
/**
* Sets the binary name.
*
* @param binaryName the new binary name
*/
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
/**
* Gets the component count.
*
* @return the component count
*/
public String getComponentCount() {
return componentCount;
}
/**
* Sets the component count.
*
* @param componentCount the new component count
*/
public void setComponentCount(String componentCount) {
this.componentCount = componentCount;
}
/**
* Gets the prj id.
*
* @return the prj id
*/
public String getPrjId() {
return prjId;
}
/**
* Sets the prj id.
*
* @param prjId the new prj id
*/
public void setPrjId(String prjId) {
this.prjId = prjId;
}
/**
* Gets the third party partner id list.
*
* @return the third party partner id list
*/
public List<String> getThirdPartyPartnerIdList() {
return thirdPartyPartnerIdList;
}
/**
* Sets the third party partner id list.
*
* @param thirdPartyPartnerIdList the new third party partner id list
*/
public void setThirdPartyPartnerIdList(List<String> thirdPartyPartnerIdList) {
this.thirdPartyPartnerIdList = thirdPartyPartnerIdList;
}
/**
* Gets the par division.
*
* @return the par division
*/
//WATCHER
public String getParDivision() {
return parDivision;
}
/**
* Sets the par division.
*
* @param parDivision the new par division
*/
public void setParDivision(String parDivision) {
this.parDivision = parDivision;
}
/**
* Gets the par division name.
*
* @return the par division name
*/
public String getParDivisionName() {
return parDivisionName;
}
/**
* Sets the par division name.
*
* @param parDivisionName the new par division name
*/
public void setParDivisionName(String parDivisionName) {
this.parDivisionName = parDivisionName;
}
/**
* Gets the par user id.
*
* @return the par user id
*/
public String getParUserId() {
return parUserId;
}
/**
* Sets the par user id.
*
* @param parUserId the new par user id
*/
public void setParUserId(String parUserId) {
this.parUserId = parUserId;
}
/**
* Gets the par user name.
*
* @return the par user name
*/
public String getParUserName() {
return parUserName;
}
/**
* Sets the par user name.
*
* @param parUserName the new par user name
*/
public void setParUserName(String parUserName) {
this.parUserName = parUserName;
}
/**
* Gets the par email.
*
* @return the par email
*/
public String getParEmail() {
return parEmail;
}
/**
* Sets the par email.
*
* @param parEmail the new par email
*/
public void setParEmail(String parEmail) {
this.parEmail = parEmail;
}
/**
* Gets the watchers.
*
* @return the watchers
*/
public String[] getWatchers() {
return watchers != null ? watchers.clone() : null;
}
/**
* Sets the watchers.
*
* @param watchers the new watchers
*/
public void setWatchers(String[] watchers) {
this.watchers = watchers != null ? watchers.clone() : null;
}
/**
* Gets the watcher list.
*
* @return the watcher list
*/
public List<PartnerMaster> getWatcherList() {
return watcherList;
}
/**
* Sets the watcher list.
*
* @param watcherList the new watcher list
*/
public void setWatcherList(List<PartnerMaster> watcherList) {
this.watcherList = watcherList;
}
/**
* Gets the division list.
*
* @return the division list
*/
public ArrayList<Map<String, String>> getDivisionList() {
return divisionList;
}
/**
* Sets the division list.
*
* @param divisionList the division list
*/
public void setDivisionList(ArrayList<Map<String, String>> divisionList) {
this.divisionList = divisionList;
}
/**
* Gets the email list.
*
* @return the email list
*/
public ArrayList<Map<String, String>> getEmailList() {
return emailList;
}
/**
* Sets the email list.
*
* @param emailList the email list
*/
public void setEmailList(ArrayList<Map<String, String>> emailList) {
this.emailList = emailList;
}
/**
* Gets the view only flag.
*
* @return the viewOnlyFlag
*/
public String getViewOnlyFlag() {
return viewOnlyFlag;
}
/**
* Sets the view only flag.
*
* @param viewOnlyFlag the viewOnlyFlag to set
*/
public void setViewOnlyFlag(String viewOnlyFlag) {
this.viewOnlyFlag = viewOnlyFlag;
}
/**
* Gets the reviewer name.
*
* @return the reviewer name
*/
public String getReviewerName() {
return reviewerName;
}
/**
* Sets the reviewer name.
*
* @param reviewerName the new reviewer name
*/
public void setReviewerName(String reviewerName) {
this.reviewerName = reviewerName;
}
public String[] getArrStatuses() {
return arrStatuses != null ? arrStatuses.clone() : null;
}
public void setArrStatuses(String[] arrStatuses) {
this.arrStatuses = arrStatuses != null ?
arrStatuses.clone() : null;
}
/**
* Gets the listKind.
*
* @return the listKind
*/
public String getListKind() {
return listKind;
}
/**
* Sets the listKind.
*
* @param listKind the new listKind
*/
public void setListKind(String listKind) {
this.listKind = listKind;
}
/**
* Gets the listId.
*
* @return the listId
*/
public String getListId() {
return listId;
}
/**
* Sets the listId.
*
* @param partnerId the new listId
*/
public void setListId(String listId) {
this.listId = listId;
}
public String getModelFlag() {
return modelFlag;
}
public void setModelFlag(String modelFlag) {
this.modelFlag = modelFlag;
}
public List<T2File> getDocumentsFile() {
return documentsFile;
}
public void setDocumentsFile(List<T2File> documentsFile) {
this.documentsFile = documentsFile;
}
public String getDocumentsFileId() {
return documentsFileId;
}
public void setDocumentsFileId(String documentsFileId) {
this.documentsFileId = documentsFileId;
}
public String getDocumentsFileCnt() {
return documentsFileCnt;
}
public void setDocumentsFileCnt(String documentsFileCnt) {
this.documentsFileCnt = documentsFileCnt;
}
public String getDelDocumentsFile() {
return delDocumentsFile;
}
public void setDelDocumentsFile(String delDocumentsFile) {
this.delDocumentsFile = delDocumentsFile;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public String getOssAnalysisStatus() {
return ossAnalysisStatus;
}
public void setOssAnalysisStatus(String ossAnalysisStatus) {
this.ossAnalysisStatus = ossAnalysisStatus;
}
public String getAnalysisStartDate() {
return analysisStartDate;
}
public void setAnalysisStartDate(String analysisStartDate) {
this.analysisStartDate = analysisStartDate;
}
public String getOssVersion() {
return ossVersion;
}
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
public String getOssNameMergeFlag() {
return ossNameMergeFlag;
}
public void setOssNameMergeFlag(String ossNameMergeFlag) {
this.ossNameMergeFlag = ossNameMergeFlag;
}
public String getIgnoreBinaryDbFlag() {
return ignoreBinaryDbFlag;
}
public void setIgnoreBinaryDbFlag(String ignoreBinaryDbFlag) {
this.ignoreBinaryDbFlag = ignoreBinaryDbFlag;
}
public String getVulnYn() {
return vulnYn;
}
public void setVulnYn(String vulnYn) {
this.vulnYn = vulnYn;
}
public String getCvssScore() {
return cvssScore;
}
public void setCvssScore(String cvssScore) {
this.cvssScore = cvssScore;
}
public String getCveId() {
return cveId;
}
public void setCveId(String cveId) {
this.cveId = cveId;
}
public String[] getPartnerIds() {
return partnerIds;
}
public void setPartnerIds(String[] partnerIds) {
this.partnerIds = partnerIds;
}
public ArrayList<Map<String, String>> getChangeWatcherList() {
return changeWatcherList;
}
public void setChangeWatcherList(ArrayList<Map<String, String>> changeWatcherList) {
this.changeWatcherList = changeWatcherList;
}
public String getCopyWatcherLocation() {
return copyWatcherLocation;
}
public void setCopyWatcherLocation(String copyWatcherLocation) {
this.copyWatcherLocation = copyWatcherLocation;
}
} | 24,218 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProjectWatcher.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ProjectWatcher.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* The Class batMaster.
*/
public class ProjectWatcher extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 5429990726160434346L;
/** The prj id. */
private String prjId;
/** The division. */
private String division;
/** The user id. */
private String userId;
/** The user id. */
private String userName;
/** The email. */
private String email;
/**
* Gets the user name.
*
* @return the user name
*/
public String getUserName() {
return userName;
}
/**
* Sets the user name.
*
* @param userName the new user name
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Gets the division.
*
* @return the division
*/
public String getDivision() {
return division;
}
/**
* Sets the division.
*
* @param division the new division
*/
public void setDivision(String division) {
this.division = division;
}
/**
* Gets the user id.
*
* @return the user id
*/
public String getUserId() {
return userId;
}
/**
* Sets the user id.
*
* @param userId the new user id
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* Gets the email.
*
* @return the email
*/
public String getEmail() {
return email;
}
/**
* Sets the email.
*
* @param email the new email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the prj id.
*
* @return the prj id
*/
public String getPrjId() {
return prjId;
}
/**
* Sets the prj id.
*
* @param prjId the new prj id
*/
public void setPrjId(String prjId) {
this.prjId = prjId;
}
} | 1,991 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ComBean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ComBean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.util.StringUtil;
public class ComBean extends CoTopComponent implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
// ๋ก๊ทธ์ธ User ์์ด๋
/** Login User ID. */
private String loginUserName;
// ๋ก๊ทธ์ธ User ๊ถํ
/** Login Users Athority. */
private String loginUserRole;
// ํ์ฌ ํ์ด์ง๋ฒํธ
/** The cur page. */
private int curPage = 1;
// ํ ๋ธ๋ก๋น ๋ณด์ฌ์ค ๊ธ ์
/** The page list size. */
private int pageListSize = 10;
// ๋
ธ์ถํ ๋ธ๋ก ์
/** The block size. */
private int blockSize = 10;
// ์ ์ฒด ๊ธ์ ์
/** The tot list size. */
private int totListSize;
// ์ ์ฒด ๋ธ๋ก ์
/** The tot block size. */
private int totBlockSize;
// Start Index
/** The start index. */
private int startIndex = 0;
/** ์ ์ฒด ๋ธ๋ก์. */
private int totBlockPage;
/** ํ์ฌ ํ์ด์ง์ ๋ช๋ฒ์งธ ๋ธ๋ก. */
private int blockPage;
/** ํ์ฌ ๋ธ๋ก์ ์์ ํ์ด์ง. */
private int blockStart;
/** ํ์ฌ ๋ธ๋ก์ ๋ ํ์ด์ง. */
private int blockEnd;
// ๊ฒ์์กฐ๊ฑด
/** The sch condition. */
private String schCondition;
// ๊ฒ์์ด
/** The sch value. */
private String schValue;
/* ๋ฐ์ดํฐ ์ ๋ ฌ์ ์ํ ์กฐ๊ฑด [S] */
/** The sort field. */
private String sortField = "";
/** The sort order. */
private String sortOrder = "";
/* ๋ฐ์ดํฐ ์ ๋ ฌ์ ์ํ ์กฐ๊ฑด [E] */
/* ํ๋ ๊ฒ์ ์กฐ๊ฑด ์ ์ง [S] */
/** The sch query string. */
private String schQueryString;
/* ํ๋ ๊ฒ์ ์กฐ๊ฑด ์ ์ง [E] */
// ๊ณตํต ๋ณ์ ์์ญ [S]
/** ์ถ์ฒ์ฌ๋ถ. (Y: ์ถ์ฒ, N: ์ถ์ฒ์ํจ) */
private String hotYn = "N";
/** ๋ฑ๋ก์ ID. */
private String creator;
/* 2018-07-20 choye ์ถ๊ฐ */
/** ๋ฑ๋ก์ ์ด๋ฆ. */
private String creatorName;
/** ๋ฑ๋ก์ ๋ถ์. */
private String creatorDivisionName;
/** ๋ฑ๋ก์ผ. */
protected String createdDate;
/** ์์ ์ ID. */
public String modifier;
/* 2018-07-20 choye ์ถ๊ฐ */
/** ์์ ์ ์ด๋ฆ. */
public String modifierName;
/** ์์ ์ ๋ถ์. */
private String modifierDivisionName;
/** ์์ ์ผ์. */
public String modifiedDate;
/** ID ๋ฐฐ์ด. */
private String[] ids;
private String filters;
private String filterCondition;
/** The user use yn. */
private String userUseYn;
/** The dept use yn. */
private String deptUseYn;
private String domain;
/**
* Gets the ids.
*
* @return the ids
*/
public String[] getIds() {
return ids != null ? ids.clone() : null;
}
/**
* Sets the ids.
*
* @param ids the new ids
*/
public void setIds(String[] ids) {
this.ids = ids != null ? ids.clone() : null;
}
/** ์ญ์ ์ฌ๋ถ. */
private String delYn;
// ๊ณตํต ๋ณ์ ์์ญ [E]
/** ๋ ์ง ๊ฒ์ ์กฐ๊ฑด. */
private String dateCondition;
/** ์์ Date. */
private String startDate;
/** ๋ Date. */
private String endDate;
// Grid ๊ด๋ จ STAR ----------------------------------------------------- //
/** Grid ID. */
private String gridId;
/** The no. */
private String no;
/** Grid Action oper. */
private String oper;
/** Grid ์ ๋ ฌ ๊ธฐ์ค ์นผ๋ผ. */
private String sidx;
/** Grid ์ ๋ ฌ(๋ด๋ฆผ์ฐจ์, ์ค๋ฆ์ฐจ์). */
private String sord;
/** pager - current page. */
private int page;
/** pager - display rows count. */
private int rows;
private String isPopup;
// Grid ๊ด๋ จ END ----------------------------------------------------- //
/**
* Gets the sidx.
*
* @return the sidx
*/
public String getSidx() {
if (!isEmpty(sidx) && CoConstDef.VALIDATION_USE_CAMELCASE) {
String _sidx = StringUtil.convertToUnderScore(sidx).toUpperCase();
if (CoCodeManager.getCodeNames(CoConstDef.CD_SYSTEM_GRID_SORT_CAST).contains(_sidx)) {
_sidx = "CAST("+ _sidx +" AS SIGNED)";
}
return _sidx;
}
return sidx;
}
public String getSidxEx() {
if (StringUtil.isEmpty(sidx)) {
return sidx;
}
return sidx.toLowerCase();
}
public String getSidxOrg() {
return sidx;
}
/**
* Gets the page.
*
* @return the page
*/
public int getPage() {
return page;
}
/**
* Sets the page.
*
* @param page the new page
*/
public void setPage(int page) {
this.page = page;
this.curPage = page;
}
/**
* Gets the rows.
*
* @return the rows
*/
public int getRows() {
return rows;
}
/**
* Sets the rows.
*
* @param rows the new rows
*/
public void setRows(int rows) {
this.rows = rows;
this.pageListSize = rows;
}
/**
* Sets the sidx.
*
* @param sidx the new sidx
*/
public void setSidx(String sidx) {
this.sidx = sidx;
}
/**
* Gets the sord.
*
* @return the sord
*/
public String getSord() {
return sord;
}
/**
* Sets the sord.
*
* @param sord the new sord
*/
public void setSord(String sord) {
this.sord = sord;
}
/**
* ์ ์ํ ์ ์ ID ๊ฐ์ ธ์ค๊ธฐ.
*
* @return the login user name
*/
public String getLoginUserName() {
return loginUserName;
}
public void setLoginUserName(String loginUserName) {
this.loginUserName = loginUserName;
}
/**
* ์ ์ํ ์ ์ Authority ๊ฐ์ ธ์ค๊ธฐ.
*
* @return the login user role
*/
public String getLoginUserRole() {
return loginUserRole;
}
/**
* ์ ์ ์ ์ ID & Athority ์ธํ
.
*/
public ComBean() {
loginUserName = loginUserName();
loginUserRole = loginUserRole();
}
/**
* Gets the cur page.
*
* @return the cur page
*/
public int getCurPage() {
return curPage;
}
/**
* Sets the cur page.
*
* @param curPage the new cur page
*/
public void setCurPage(int curPage) {
this.curPage = curPage;
}
/**
* Gets the page list size.
*
* @return the page list size
*/
public int getPageListSize() {
return pageListSize;
}
/**
* Sets the page list size.
*
* @param pageListSize the new page list size
*/
public void setPageListSize(int pageListSize) {
this.pageListSize = pageListSize;
}
/**
* Gets the block size.
*
* @return the block size
*/
public int getBlockSize() {
return blockSize;
}
/**
* Sets the block size.
*
* @param blockSize the new block size
*/
public void setBlockSize(int blockSize) {
this.blockSize = blockSize;
}
/**
* Gets the tot list size.
*
* @return the tot list size
*/
public int getTotListSize() {
return totListSize;
}
/**
* Total List Size ๋ฑ๋ก (=์ ์ฒด ๋ชฉ๋ก ๊ฐฏ์)
*
* + Block Size์ Start Index๋ฅผ ๊ฐฑ์ .
*
* @param totListSize the new tot list size
*/
public void setTotListSize(int totListSize) {
this.totListSize = totListSize;
this.totBlockSize = totListSize/pageListSize < 1 ? 1 : totListSize%pageListSize==0?totListSize/pageListSize:(totListSize/pageListSize)+1;
this.startIndex = (curPage-1)*pageListSize;
int totBlockPage = (totBlockSize / blockSize);
if (totBlockSize != blockSize) {
totBlockPage++;
}
this.totBlockPage = totBlockPage;
int blockPage = ((curPage-1) / blockSize) + 1;
this.blockPage = blockPage;
int blockStart = ((blockPage-1) * blockSize) + 1;
int blockEnd = blockStart+blockSize-1;
if (blockEnd > totBlockSize) {
blockEnd = totBlockSize;
}
this.blockStart = blockStart;
this.blockEnd = blockEnd;
}
/**
* Gets the tot block size.
*
* @return the tot block size
*/
public int getTotBlockSize() {
return totBlockSize;
}
/**
* Sets the tot block size.
*
* @param totBlockSize the new tot block size
*/
public void setTotBlockSize(int totBlockSize) {
this.totBlockSize = totBlockSize;
}
/**
* Gets the start index.
*
* @return the start index
*/
public int getStartIndex() {
return startIndex;
}
/**
* Sets the start index.
*
* @param startIndex the new start index
*/
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
/**
* Gets the tot block page.
*
* @return the tot block page
*/
public int getTotBlockPage() {
return totBlockPage;
}
/**
* Sets the tot block page.
*
* @param totBlockPage the new tot block page
*/
public void setTotBlockPage(int totBlockPage) {
this.totBlockPage = totBlockPage;
}
/**
* Gets the block page.
*
* @return the block page
*/
public int getBlockPage() {
return blockPage;
}
/**
* Sets the block page.
*
* @param blockPage the new block page
*/
public void setBlockPage(int blockPage) {
this.blockPage = blockPage;
}
/**
* Gets the block start.
*
* @return the block start
*/
public int getBlockStart() {
return blockStart;
}
/**
* Sets the block start.
*
* @param blockStart the new block start
*/
public void setBlockStart(int blockStart) {
this.blockStart = blockStart;
}
/**
* Gets the block end.
*
* @return the block end
*/
public int getBlockEnd() {
return blockEnd;
}
/**
* Sets the block end.
*
* @param blockEnd the new block end
*/
public void setBlockEnd(int blockEnd) {
this.blockEnd = blockEnd;
}
/**
* Gets the sch condition.
*
* @return the sch condition
*/
public String getSchCondition() {
return schCondition;
}
/**
* Sets the sch condition.
*
* @param schCondition the new sch condition
*/
public void setSchCondition(String schCondition) {
this.schCondition = schCondition;
}
/**
* Gets the sch value.
*
* @return the sch value
*/
public String getSchValue() {
return schValue;
}
/**
* Sets the sch value.
*
* @param schValue the new sch value
*/
public void setSchValue(String schValue) {
this.schValue = schValue;
}
/**
* Gets the sort field.
*
* @return the sort field
*/
public String getSortField() {
return sortField;
}
/**
* Sets the sort field.
*
* @param sortField the new sort field
*/
public void setSortField(String sortField) {
this.sortField = sortField;
}
/**
* Gets the sort order.
*
* @return the sort order
*/
public String getSortOrder() {
return sortOrder;
}
/**
* Sets the sort order.
*
* @param sortOrder the new sort order
*/
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
/**
* Gets the sch query string.
*
* @return the sch query string
*/
public String getSchQueryString() {
return schQueryString;
}
/**
* Sets the sch query string.
*
* @param schQueryString the new sch query string
*/
public void setSchQueryString(String schQueryString) {
this.schQueryString = schQueryString;
}
/**
* Gets the hot yn.
*
* @return the hot yn
*/
public String getHotYn() {
return hotYn;
}
/**
* Sets the hot yn.
*
* @param hotYn the new hot yn
*/
public void setHotYn(String hotYn) {
this.hotYn = hotYn;
}
/**
* Gets the ๋ฑ๋ก์ ID.
*
* @return the ๋ฑ๋ก์ ID
*/
public String getCreator() {
return creator;
}
/**
* Sets the ๋ฑ๋ก์ ID.
*
* @param creator the new ๋ฑ๋ก์ ID
*/
public void setCreator(String creator) {
this.creator = creator;
}
/**
* Gets the ๋ฑ๋ก์ ์ด๋ฆ. 2018-07-20 choye ์ถ๊ฐ
*
* @return the ๋ฑ๋ก์ ์ด๋ฆ
*/
public String getCreatorName() {
return creatorName;
}
/**
* Sets the ๋ฑ๋ก์ ์ด๋ฆ. 2018-07-20 choye ์ถ๊ฐ
*
* @param creator the new ๋ฑ๋ก์ ์ด๋ฆ
*/
public void setCreatorName(String creatorName) {
this.creatorName = creatorName;
}
/**
* Gets the ๋ฑ๋ก์ ๋ถ์. 2018-07-20 choye ์ถ๊ฐ
*
* @return the ๋ฑ๋ก์ ๋ถ์
*/
public String getCreatorDivisonName() {
return creatorDivisionName;
}
/**
* Sets the ๋ฑ๋ก์ ๋ถ์. 2018-07-20 choye ์ถ๊ฐ
*
* @param creator the new ๋ฑ๋ก์ ๋ถ์
*/
public void setCreatorDivisonName(String creatorDivisionName) {
this.creatorDivisionName = creatorDivisionName;
}
/**
* Gets the ๋ฑ๋ก์ผ.
*
* @return the ๋ฑ๋ก์ผ
*/
public String getCreatedDate() {
if (this.createdDate == null){
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(CoConstDef.DATABASE_FORMAT_DATE_ALL);
this.createdDate = sdf.format(now);
}
return this.createdDate;
}
/**
* Sets the ๋ฑ๋ก์ผ.
*
* @param createdDate the new created date
*/
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
/**
* Sets the ๋ฑ๋ก์ผ as curDate.
*/
public void setCreatedDateCurrentTime(){
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(CoConstDef.DATABASE_FORMAT_DATE_ALL);
this.createdDate = sdf.format(now);
}
/**
* Sets the ์์ ์ผ์ as curdate.
*/
public void setModDtCunnrentTime() {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(CoConstDef.DATABASE_FORMAT_DATE_ALL);
this.modifiedDate = sdf.format(now);
}
/**
* Gets the del yn.
*
* @return the del yn
*/
public String getDelYn() {
return delYn;
}
/**
* Sets the del yn.
*
* @param delYn the new del yn
*/
public void setDelYn(String delYn) {
this.delYn = delYn;
}
/**
* Gets the upd id.
*
* @return the upd id
*/
public String getModifier() {
return modifier;
}
/**
* Sets the upd id.
*
* @param modifier the new upd id
*/
public void setModifier(String modifier) {
this.modifier = modifier;
}
/**
* Gets the ์์ ์ ์ด๋ฆ. 2018-07-20 choye ์ถ๊ฐ
*
* @return the ์์ ์ ์ด๋ฆ
*/
public String getModifierName() {
return modifierName;
}
/**
* Sets the ์์ ์ ์ด๋ฆ. 2018-07-20 choye ์ถ๊ฐ
*
* @param modifier the new ์์ ์ ์ด๋ฆ
*/
public void setModifierName(String modifierName) {
this.modifierName = modifierName;
}
/**
* Gets the ์์ ์ ์ด๋ฆ. 2018-07-20 choye ์ถ๊ฐ
*
* @return the ์์ ์ ๋ถ์
*/
public String getModifierDivisionName() {
return modifierDivisionName;
}
/**
* Sets the ์์ ์ ๋ถ์. 2018-07-20 choye ์ถ๊ฐ
*
* @param modifier the new ์์ ์ ๋ถ์
*/
public void setModifierDivisionName(String modifierDivisionName) {
this.modifierDivisionName = modifierDivisionName;
}
/**
* Gets the upd dt.
*
* @return the upd dt
*/
public String getModifiedDate() {
return modifiedDate;
}
/**
* Sets the upd dt.
*
* @param modifiedDate the new modified date
*/
public void setModifiedDate(String modifiedDate) {
this.modifiedDate = modifiedDate;
}
/**
* Gets the date condition.
*
* @return the date condition
*/
public String getDateCondition() {
return dateCondition;
}
/**
* Sets the date condition.
*
* @param dateCondition the new date condition
*/
public void setDateCondition(String dateCondition) {
this.dateCondition = dateCondition;
}
/**
* Gets the start date.
*
* @return the start date
*/
public String getStartDate() {
return startDate;
}
/**
* Sets the start date.
*
* @param startDate the new start date
*/
public void setStartDate(String startDate) {
this.startDate = startDate;
}
/**
* Gets the end date.
*
* @return the end date
*/
public String getEndDate() {
return endDate;
}
/**
* Sets the end date.
*
* @param endDate the new end date
*/
public void setEndDate(String endDate) {
this.endDate = endDate;
}
/**
* Gets the grid id.
*
* @return the grid id
*/
public String getGridId() {
return gridId;
}
/**
* Sets the grid id.
*
* @param gridId the new grid id
*/
public void setGridId(String gridId) {
this.gridId = gridId;
}
/**
* Gets the oper.
*
* @return the oper
*/
public String getOper() {
return oper;
}
/**
* Sets the oper.
*
* @param oper the new oper
*/
public void setOper(String oper) {
this.oper = oper;
}
/**
* Gets the no.
*
* @return the no
*/
public String getNo() {
return no;
}
/**
* Sets the no.
*
* @param no the new no
*/
public void setNo(String no) {
this.no = no;
}
/**
* Gets the user use yn.
*
* @return the use yn
*/
public String getUserUseYn() {
return userUseYn;
}
/**
* Sets the user use yn.
*
* @param useYn the new use yn
*/
public void setUserUseYn(String userUseYn) {
this.userUseYn = userUseYn;
}
/**
* Gets the use yn.
*
* @return the use yn
*/
public String getDeptUseYn() {
return deptUseYn;
}
/**
* Sets the use yn.
*
* @param useYn the new use yn
*/
public void setDeptUseYn(String deptUseYn) {
this.deptUseYn = deptUseYn;
}
/**
* Gets the bit array sum.
*
* @param value
* the value
* @return the bit array sum
*/
protected static String getBitArraySum(String value){
int sum = 0;
if (value != null){
String arr[] = value.split(",");
if (arr.length > 1){
for (String s : arr) {
try{
sum += Integer.parseInt(s.trim());
}catch(Exception e){
return "";
}
}
}else{
sum = Integer.parseInt(value);
}
}
return sum+"";
}
@Override
public String toString() {
return "ComBean [curPage=" + curPage + ", pageListSize=" + pageListSize
+ ", blockSize=" + blockSize + ", totListSize=" + totListSize
+ ", totBlockSize=" + totBlockSize + ", startIndex="
+ startIndex + ", schCondition=" + schCondition + ", schValue="
+ schValue + ", sortField=" + sortField + ", sortOrder="
+ sortOrder + ", schQueryString=" + schQueryString + ", hotYn="
+ hotYn + "]";
}
public String getFilters() {
return filters;
}
public Map<String, Object> getFiltersMap() {
Map<String, Object> filtersMap = null;
Type collectionType1 = new TypeToken<Map<String, Object>>() {}.getType();
String[] dateField = {"creationDate", "publDate", "modiDate", "regDt"};
if (filters != null) {
filtersMap = (Map<String, Object>) fromJson(filters, collectionType1);
if (filtersMap.containsKey("rules")) {
for (Map<String, String> ruleMap : (List<LinkedTreeMap<String, String>>)filtersMap.get("rules")) {
String field = ruleMap.get("field");
String data = ruleMap.get("data");
for (String date : dateField) {
if (date.equalsIgnoreCase(field)) {
ruleMap.put("data", CommonFunction.formatDateSimple(data));
}
}
}
}
}
return filtersMap;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String getFilterCondition() {
return filterCondition;
}
public void setFilterCondition(String filterCondition) {
this.filterCondition = filterCondition;
}
public String getIsPopup() {
return isPopup;
}
public void setIsPopup(String isPopup) {
this.isPopup = isPopup;
}
public void setLoginUserRole(String loginUserRole) {
this.loginUserRole = loginUserRole;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
} | 20,547 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CamelMap.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CamelMap.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import org.apache.commons.collections.map.ListOrderedMap;
import org.springframework.jdbc.support.JdbcUtils;
public class CamelMap extends ListOrderedMap {
private static final long serialVersionUID = 1L;
@Override
public Object put(Object key, Object value) {
return super.put(JdbcUtils.convertUnderscoreNameToPropertyName((String) key), value);
}
}
| 484 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CodeDtlBean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CodeDtlBean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import com.google.gson.JsonObject;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CodeDtlBean extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** ์ฝ๋๋ฒํธ. */
private String cdNo;
/** ์๋ธ ์ฝ๋ ๋ฒํธ. */
private String cdSubNo;
/** ์ฝ๋๋ช
. */
private String cdNm;
/** ์ฝ๋์์ธ๋ฒํธ. */
private String cdDtlNo;
/** ์ฝ๋์์ธ๋ช
. */
private String cdDtlNm;
/** ์ฝ๋์์ธ๋ช
2. */
private String cdDtlNm2;
/** ์ฝ๋์์ธ์ค๋ช
. */
private String cdDtlExp;
/** ์ฝ๋์ฐ์ ์์. */
private String cdOrder;
private String useYn;
/**
* Gets the field values as JsonObject.
*
* @return the json object
*/
public JsonObject toJson(){
JsonObject jo = new JsonObject();
jo.addProperty("cdNo", this.cdNo);
jo.addProperty("cdSubNo", this.cdSubNo);
jo.addProperty("cdNm", this.cdNm);
jo.addProperty("cdDtlNo", this.cdDtlNo);
jo.addProperty("cdDtlNm", this.cdDtlNm);
jo.addProperty("cdDtlNm2", this.cdDtlNm2);
jo.addProperty("cdDtlExp", this.cdDtlExp);
jo.addProperty("cdOrder", this.cdOrder);
return jo;
}
}
| 1,502 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CodeInfo.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CodeInfo.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.util.List;
import org.apache.ibatis.type.Alias;
import lombok.Data;
/**
* Instantiates a new code info.
*/
@Data
@Alias("codeInfo")
public class CodeInfo {
/** The cd grp id. */
private String cdGrpId;
/** The cd grp nm. */
private String cdGrpNm;
/** The cd id. */
private String cdId;
/** ์๋ธ ๊ทธ๋ฃน ์ฝ๋. */
private String subGrpCd;
/** The cd nm. */
private String cdNm;
/** The cd order. */
private String cdOrder;
/** The remark. */
private String remark;
/** The use yn. */
private String useYn;
/** The reg dt. */
private String regDt;
/** The reg id. */
private String regId;
/** The mod dt. */
private String modDt;
/** The mod id. */
private String modId;
/** The auth mode.<br> 0:์กฐํ๊ถํ, 1:์์ ๊ถํ */
private String authMode;
/** The sub code list. */
private List<CodeInfo> subCodeList;
}
| 1,015 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CoMail.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CoMail.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CoMail extends ComBean {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -6978575958803751406L;
/** The snd seq. */
private String sndSeq; // ๋ฐ์ก์๋ฒ
/** The msg type. */
private String msgType; // ๊ตฌ๋ถ
/** The eml title. */
private String emlTitle; // ๋ฉ์ผ์ ๋ชฉ
/** The eml message. */
private String emlMessage; // ๋ฉ์ผ๋ด์ฉ
/** The eml to. */
private String emlTo; // ๋ฉ์ผ๋ด์ฉ
/** The eml cc. */
private String emlCc; // ๋ฉ์ผ๋ด์ฉ
/** The eml from. */
private String emlFrom = "Fosslight"; // ๋ฐ์ก์
/** The snd status. */
private String sndStatus = "S"; // ๋ฐ์ก์ํ(์ ์ก:S, ์๋ฃ:C, ์ ์ก ์๊ฐ ์ด๊ณผ: G)
/** The use flag. */
private String useFlag; // ์ฌ์ฉ์ฌ๋ถ
/** The creation date. */
private String creationDate; // ๋ฑ๋ก์ผ
/** The creation user id. */
private String creationUserId; // ๋ฑ๋ก์
/** The last update date. */
private String lastUpdateDate; // ์์ ์ผ
/** The last update user id. */
private String lastUpdateUserId;// ์์ ์
/** The error msg. */
private String errorMsg; // ์๋ฌ ๋ฉ์์ง
/** The param oss id. */
private String paramOssId;
/** The param oss ids. */
private List<String> paramOssKey;
/** The param license id. */
private String paramLicenseId;
/** The param prj id. */
private String paramPrjId;
/** The param partner id. */
private String paramPartnerId;
/** The param bat id. */
private String paramBatId;
/** The comment. */
private String comment;
/** The compare data before. */
private Object compareDataBefore; // ๋ณ๊ฒฝ์ฌํญ (๋ณ๊ฒฝ์ )
/** The compare data after. */
private Object compareDataAfter; // ๋ณ๊ฒฝ์ฌํญ (๋ณ๊ฒฝํ)
/** The param prj list. */
private List<Project> paramPrjList;
/** The receive flag. */
private String receiveFlag;
/** The param email. */
private String paramEmail;
/** The param user id. */
private String paramUserId;
/** The param oss info. */
private OssMaster paramOssInfo;
/** The param prj info. */
private Project paramPrjInfo;
/** The param oss list. */
private List<OssMaster> paramOssList;
/** The param expansion 1. */
private String paramExpansion1;
/** The param expansion 2. */
private String paramExpansion2;
/** The param expansion 3. */
private String paramExpansion3;
/** The param stage. */
private String stage;
private String jobType;
private Map<String, OssMaster> paramOssInfoMap;
private List<Map<String, Object>> paramList;
/** Informations *. */
/** Custom Setting */
private String[] toIds; // ์์ ์์ด๋๋ค
/** The cc ids. */
private String[] ccIds = new String[]{}; // ์ฐธ์กฐ ์์ด๋๋ค
/** The bcc ids. */
private String[] bccIds = new String[]{}; // ์จ๊น ์ฐธ์กฐ ์์ด๋๋ค
private String binaryCommitResult;
private String paramStandardScore;
private boolean toIdsCheckDivision = false;
/**
* Gets the snd seq.
*
* @return the snd seq
*/
public String getSndSeq() {
return sndSeq;
}
/**
* Sets the snd seq.
*
* @param sndSeq the new snd seq
*/
public void setSndSeq(String sndSeq) {
this.sndSeq = sndSeq;
}
/**
* Gets the msg type.
*
* @return the msg type
*/
public String getMsgType() {
return msgType;
}
/**
* Sets the msg type.
*
* @param msgType the new msg type
*/
public void setMsgType(String msgType) {
this.msgType = msgType;
}
/**
* Gets the eml title.
*
* @return the eml title
*/
public String getEmlTitle() {
return emlTitle;
}
/**
* Sets the eml title.
*
* @param emlTitle the new eml title
*/
public void setEmlTitle(String emlTitle) {
this.emlTitle = emlTitle;
}
/**
* Gets the eml message.
*
* @return the eml message
*/
public String getEmlMessage() {
return emlMessage;
}
/**
* Sets the eml message.
*
* @param emlMessage the new eml message
*/
public void setEmlMessage(String emlMessage) {
this.emlMessage = emlMessage;
}
/**
* Gets the eml from.
*
* @return the eml from
*/
public String getEmlFrom() {
return emlFrom;
}
/**
* Sets the eml from.
*
* @param emlFrom the new eml from
*/
public void setEmlFrom(String emlFrom) {
this.emlFrom = emlFrom;
}
/**
* Gets the snd status.
*
* @return the snd status
*/
public String getSndStatus() {
return sndStatus;
}
/**
* Sets the snd status.
*
* @param sndStatus the new snd status
*/
public void setSndStatus(String sndStatus) {
this.sndStatus = sndStatus;
}
/**
* Gets the use flag.
*
* @return the use flag
*/
public String getUseFlag() {
return useFlag;
}
/**
* Sets the use flag.
*
* @param useFlag the new use flag
*/
public void setUseFlag(String useFlag) {
this.useFlag = useFlag;
}
/**
* Gets the creation date.
*
* @return the creation date
*/
public String getCreationDate() {
return creationDate;
}
/**
* Sets the creation date.
*
* @param creationDate the new creation date
*/
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
/**
* Gets the creation user id.
*
* @return the creation user id
*/
public String getCreationUserId() {
return creationUserId;
}
/**
* Sets the creation user id.
*
* @param creationUserId the new creation user id
*/
public void setCreationUserId(String creationUserId) {
this.creationUserId = creationUserId;
}
/**
* Gets the last update date.
*
* @return the last update date
*/
public String getLastUpdateDate() {
return lastUpdateDate;
}
/**
* Sets the last update date.
*
* @param lastUpdateDate the new last update date
*/
public void setLastUpdateDate(String lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}
/**
* Gets the last update user id.
*
* @return the last update user id
*/
public String getLastUpdateUserId() {
return lastUpdateUserId;
}
/**
* Sets the last update user id.
*
* @param lastUpdateUserId the new last update user id
*/
public void setLastUpdateUserId(String lastUpdateUserId) {
this.lastUpdateUserId = lastUpdateUserId;
}
/**
* Gets the error msg.
*
* @return the error msg
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* Sets the error msg.
*
* @param errorMsg the new error msg
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
/**
* Custom Setting.
*
* @return the str to ids
*/
public String getStrToIds() {
return toIds != null ? StringUtils.join(toIds, "|") : null;
}
/**
* Sets the str to ids.
*
* @param strToIds the new str to ids
*/
public void setStrToIds(String strToIds) {
this.toIds = strToIds != null ? StringUtils.split(strToIds, "|") : null;
}
/**
* Gets the str to cc ids.
*
* @return the str to cc ids
*/
public String getStrToCcIds() {
return ccIds != null ? StringUtils.join(ccIds, "|") : null;
}
/**
* Sets the str to cc ids.
*
* @param strToCcIds the new str to cc ids
*/
public void setStrToCcIds(String strToCcIds) {
this.ccIds = strToCcIds != null ? StringUtils.split(strToCcIds, "|") : null;
}
/**
* Gets the str to bcc ids.
*
* @return the str to bcc ids
*/
public String getStrToBccIds() {
return bccIds != null ? StringUtils.join(bccIds, "|") : null;
}
/**
* Sets the str to bcc ids.
*
* @param strToBccIds the new str to bcc ids
*/
public void setStrToBccIds(String strToBccIds) {
this.bccIds = strToBccIds != null ? StringUtils.split(strToBccIds, "|") : null;
}
/**
* Gets the to ids.
*
* @return the to ids
*/
public String[] getToIds() {
return toIds != null ? toIds.clone() : null;
}
/**
* Sets the to ids.
*
* @param toIds the new to ids
*/
public void setToIds(String[] toIds) {
List<String> temp = new ArrayList<>();
if (toIds != null) {
for (String s : toIds) {
if (!isEmpty(s)) {
temp.add(s.trim());
}
}
}
this.toIds = temp.toArray(new String[temp.size()]);
}
/**
* Gets the cc ids.
*
* @return the cc ids
*/
public String[] getCcIds() {
return ccIds != null ? ccIds.clone() : null;
}
/**
* Sets the cc ids.
*
* @param ccIds the new cc ids
*/
public void setCcIds(String[] ccIds) {
List<String> temp = new ArrayList<>();
if (ccIds != null) {
for (String s : ccIds) {
if (!isEmpty(s)) {
temp.add(s.trim());
}
}
}
this.ccIds = temp.toArray(new String[temp.size()]);
}
/**
* Gets the bcc ids.
*
* @return the bcc ids
*/
public String[] getBccIds() {
return bccIds != null ? bccIds.clone() : null;
}
/**
* Sets the bcc ids.
*
* @param bccIds the new bcc ids
*/
public void setBccIds(String[] bccIds) {
List<String> temp = new ArrayList<>();
if (bccIds != null) {
for (String s : bccIds) {
if (!isEmpty(s)) {
temp.add(s.trim());
}
}
}
this.bccIds = temp.toArray(new String[temp.size()]);
}
/**
* //.
*
* @return the param oss id
*/
public String getParamOssId() {
return paramOssId;
}
/**
* Gets the param prj id.
*
* @return the param prj id
*/
public String getParamPrjId() {
return paramPrjId;
}
/**
* Sets the param prj id.
*
* @param paramPrjId the new param prj id
*/
public void setParamPrjId(String paramPrjId) {
this.paramPrjId = paramPrjId;
}
/**
* Gets the param license id.
*
* @return the param license id
*/
public String getParamLicenseId() {
return paramLicenseId;
}
/**
* Sets the param license id.
*
* @param paramLicenseId the new param license id
*/
public void setParamLicenseId(String paramLicenseId) {
this.paramLicenseId = paramLicenseId;
}
/**
* Gets the comment.
*
* @return the comment
*/
public String getComment() {
return comment;
}
/**
* Sets the comment.
*
* @param comment the new comment
*/
public void setComment(String comment) {
this.comment = comment;
}
/**
* Sets the param oss id.
*
* @param paramOssId the new param oss id
*/
public void setParamOssId(String paramOssId) {
this.paramOssId = paramOssId;
}
/**
* Instantiates a new co mail.
*
* @param mailType the mail type
*/
public CoMail(String mailType) {
setMsgType(mailType);
}
/**
* Instantiates a new co mail.
*/
public CoMail() {}
/**
* UTILITIES *.
*
* @param path the path
* @param model the model
* @return the string
*/
public String geVelocityTemplateContent(String path, Map<String, Object> model) {
VelocityContext context = new VelocityContext();
Writer writer = new StringWriter();
VelocityEngine vf = new VelocityEngine();
Properties props = new Properties();
context.put("TEMPLATE_URL", path); // context ์ ๋ณด
props.put("resource.loader", "class");
props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
props.put("input.encoding", "UTF-8");
vf.init(props);
try {
Template template = vf.getTemplate(""); // file name
template.merge(context, writer);
return writer.toString();
} catch (Exception e) {
System.out.println("Exception occured while processing velocity template");
log.error(e.getMessage());
}
return "";
}
/**
* Gets the compare data before.
*
* @return the compare data before
*/
public Object getCompareDataBefore() {
return compareDataBefore;
}
/**
* Sets the compare data before.
*
* @param compareDataBefore the new compare data before
*/
public void setCompareDataBefore(Object compareDataBefore) {
this.compareDataBefore = compareDataBefore;
}
/**
* Gets the compare data after.
*
* @return the compare data after
*/
public Object getCompareDataAfter() {
return compareDataAfter;
}
/**
* Sets the compare data after.
*
* @param compareDataAfter the new compare data after
*/
public void setCompareDataAfter(Object compareDataAfter) {
this.compareDataAfter = compareDataAfter;
}
/**
* Gets the param partner id.
*
* @return the param partner id
*/
public String getParamPartnerId() {
return paramPartnerId;
}
/**
* Sets the param partner id.
*
* @param paramPartnerId the new param partner id
*/
public void setParamPartnerId(String paramPartnerId) {
this.paramPartnerId = paramPartnerId;
}
/**
* Gets the param bat id.
*
* @return the param bat id
*/
public String getParamBatId() {
return paramBatId;
}
/**
* Sets the param bat id.
*
* @param paramBatId the new param bat id
*/
public void setParamBatId(String paramBatId) {
this.paramBatId = paramBatId;
}
/**
* Gets the param oss ids.
*
* @return the param oss ids
*/
public List<String> getParamOssKey() {
return paramOssKey;
}
/**
* Sets the param oss ids.
*
* @param paramOssIds the new param oss ids
*/
public void setParamOssKey(List<String> paramOssKey) {
this.paramOssKey = paramOssKey;
}
/**
* Gets the param prj list.
*
* @return the param prj list
*/
public List<Project> getParamPrjList() {
return paramPrjList;
}
/**
* Sets the param prj list.
*
* @param paramPrjList the new param prj list
*/
public void setParamPrjList(List<Project> paramPrjList) {
this.paramPrjList = paramPrjList;
}
/**
* Gets the receive flag.
*
* @return the receive flag
*/
public String getReceiveFlag() {
return receiveFlag;
}
/**
* Sets the receive flag.
*
* @param receiveFlag the new receive flag
*/
public void setReceiveFlag(String receiveFlag) {
this.receiveFlag = receiveFlag;
}
/**
* Gets the param email.
*
* @return the param email
*/
public String getParamEmail() {
return paramEmail;
}
/**
* Sets the param email.
*
* @param paramEmail the new param email
*/
public void setParamEmail(String paramEmail) {
this.paramEmail = paramEmail;
}
/**
* Gets the param user id.
*
* @return the param user id
*/
public String getParamUserId() {
return paramUserId;
}
/**
* Sets the param user id.
*
* @param paramUserId the new param user id
*/
public void setParamUserId(String paramUserId) {
this.paramUserId = paramUserId;
}
/**
* Gets the param oss info.
*
* @return the paramOssInfo
*/
public OssMaster getParamOssInfo() {
return paramOssInfo;
}
/**
* Sets the param oss info.
*
* @param paramOssInfo the paramOssInfo to set
*/
public void setParamOssInfo(OssMaster paramOssInfo) {
this.paramOssInfo = paramOssInfo;
}
/**
* Gets the param oss list.
*
* @return the paramOssList
*/
public List<OssMaster> getParamOssList() {
return paramOssList;
}
/**
* Sets the param oss list.
*
* @param paramOssList the paramOssList to set
*/
public void setParamOssList(List<OssMaster> paramOssList) {
this.paramOssList = paramOssList;
}
/**
* Gets the param expansion 1.
*
* @return the param expansion 1
*/
public String getParamExpansion1() {
return paramExpansion1;
}
/**
* Sets the param expansion 1.
*
* @param paramExpansion1 the new param expansion 1
*/
public void setParamExpansion1(String paramExpansion1) {
this.paramExpansion1 = paramExpansion1;
}
/**
* Gets the param expansion 2.
*
* @return the param expansion 2
*/
public String getParamExpansion2() {
return paramExpansion2;
}
/**
* Sets the param expansion 2.
*
* @param paramExpansion2 the new param expansion 2
*/
public void setParamExpansion2(String paramExpansion2) {
this.paramExpansion2 = paramExpansion2;
}
/**
* Gets the param expansion 3.
*
* @return the param expansion 3
*/
public String getParamExpansion3() {
return paramExpansion3;
}
/**
* Sets the param expansion 3.
*
* @param paramExpansion3 the new param expansion 3
*/
public void setParamExpansion3(String paramExpansion3) {
this.paramExpansion3 = paramExpansion3;
}
/**
* Gets the param prj info.
*
* @return the param prj info
*/
public Project getParamPrjInfo() {
return paramPrjInfo;
}
/**
* Sets the param prj info.
*
* @param paramPrjInfo the new param prj info
*/
public void setParamPrjInfo(Project paramPrjInfo) {
this.paramPrjInfo = paramPrjInfo;
}
/**
* Gets the eml to.
*
* @return the eml to
*/
public String getEmlTo() {
return emlTo;
}
/**
* Sets the eml to.
*
* @param emlTo the new eml to
*/
public void setEmlTo(String emlTo) {
this.emlTo = emlTo;
}
/**
* Gets the eml cc.
*
* @return the eml cc
*/
public String getEmlCc() {
return emlCc;
}
/**
* Sets the eml cc.
*
* @param emlCc the new eml cc
*/
public void setEmlCc(String emlCc) {
this.emlCc = emlCc;
}
/**
* Gets the stage.
*
* @return the stage
*/
public String getStage() {
return stage;
}
/**
* Sets the stage.
*
* @param stage the new stage
*/
public void setStage(String stage) {
this.stage = stage;
}
public String getJobType() {
return jobType;
}
public void setJobType(String jobType) {
this.jobType = jobType;
}
public Map<String, OssMaster> getParamOssInfoMap() {
return paramOssInfoMap;
}
public void setParamOssInfoMap(Map<String, OssMaster> paramOssInfoMap) {
this.paramOssInfoMap = paramOssInfoMap;
}
public List<Map<String, Object>> getParamList() {
return paramList;
}
public void setParamList(List<Map<String, Object>> paramList) {
this.paramList = paramList;
}
public String getBinaryCommitResult() {
return binaryCommitResult;
}
public void setBinaryCommitResult(String binaryCommitResult) {
this.binaryCommitResult = binaryCommitResult;
}
public boolean isToIdsCheckDivision() {
return toIdsCheckDivision;
}
public void setToIdsCheckDivision(boolean toIdsCheckDivision) {
this.toIdsCheckDivision = toIdsCheckDivision;
}
public String getParamStandardScore() {
return paramStandardScore;
}
public void setParamStandardScore(String paramStandardScore) {
this.paramStandardScore = paramStandardScore;
}
} | 19,678 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryAnalysisResult.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/BinaryAnalysisResult.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* The Class BinaryAnalysisResult.
*/
public class BinaryAnalysisResult extends ComBean implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 4907819340622537583L;
/** bat Analysis Result Seq. */
private String batResultId;
/** binaryname + | + binary size. */
private List<String> batKeyList;
/** The bat id. */
private String batId;
/** The binary. */
private String binaryName;
/** The path. */
private String filePath;
private String sourcePath;
/** The file type. */
private String fileType;
/** The check sum. */
private String checkSum;
/** The sha 1. */
private String shaKey;
/** The tlsh. */
private String tlsh;
/** The file size. */
private String fileSize;
/** The string match percentage. */
private String stringMatchPercentage;
/** The oss name. */
private String ossName;
/** The oss name. */
private String ossVersion;
/** The license. */
private String license;
/** The scores. */
private String scores;
/** The percentage. */
private String percentage;
/** The unique matches. */
private String uniqueMatches;
/** The non unique matches assigned. */
private String nonUniqueMatchesAssigned;
/** The parentname. */
private String parentname;
private String platformname;
private String platformversion;
private int tlshDistance = -1;
private String orgTlsh;
private String updatedate;
private String downloadLocation;
private String actionId;
private String actionType;
private String guireportFlag = "N";
private String comment;
private String filename;
/** The sch start date. */
private String schStartDate;
/** The sch end date. */
private String schEndDate;
private String matchName;
private String prjId;
public String getActionId() {
return actionId;
}
public void setActionId(String actionId) {
this.actionId = actionId;
}
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
/**
* Gets the bat result id.
*
* @return the bat result id
*/
public String getBatResultId() {
return batResultId;
}
/**
* Sets the bat result id.
*
* @param batResultId the new bat result id
*/
public void setBatResultId(String batResultId) {
this.batResultId = batResultId;
}
/**
* Gets the bat id.
*
* @return the bat id
*/
public String getBatId() {
return batId;
}
/**
* Sets the bat id.
*
* @param batId the new bat id
*/
public void setBatId(String batId) {
this.batId = batId;
}
/**
* Gets the file path.
*
* @return the file path
*/
public String getFilePath() {
return filePath;
}
/**
* Sets the file path.
*
* @param filePath the new file path
*/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/**
* Gets the file type.
*
* @return the file type
*/
public String getFileType() {
return fileType;
}
/**
* Sets the file type.
*
* @param fileType the new file type
*/
public void setFileType(String fileType) {
this.fileType = fileType;
}
/**
* Gets the check sum.
*
* @return the check sum
*/
public String getCheckSum() {
return checkSum;
}
/**
* Sets the check sum.
*
* @param checkSum the new check sum
*/
public void setCheckSum(String checkSum) {
this.checkSum = checkSum;
}
/**
* Gets the tlsh.
*
* @return the tlsh
*/
public String getTlsh() {
return tlsh;
}
/**
* Sets the tlsh.
*
* @param tlsh the new tlsh
*/
public void setTlsh(String tlsh) {
this.tlsh = tlsh;
}
/**
* Gets the file size.
*
* @return the file size
*/
public String getFileSize() {
return fileSize;
}
/**
* Sets the file size.
*
* @param fileSize the new file size
*/
public void setFileSize(String fileSize) {
this.fileSize = fileSize;
}
/**
* Gets the string match percentage.
*
* @return the string match percentage
*/
public String getStringMatchPercentage() {
return stringMatchPercentage;
}
/**
* Sets the string match percentage.
*
* @param stringMatchPercentage the new string match percentage
*/
public void setStringMatchPercentage(String stringMatchPercentage) {
this.stringMatchPercentage = stringMatchPercentage;
}
/**
* Gets the oss name.
*
* @return the oss name
*/
public String getOssName() {
return ossName;
}
/**
* Sets the oss name.
*
* @param ossName the new oss name
*/
public void setOssName(String ossName) {
this.ossName = ossName;
}
/**
* Gets the unique matches.
*
* @return the unique matches
*/
public String getUniqueMatches() {
return uniqueMatches;
}
/**
* Sets the unique matches.
*
* @param uniqueMatches the new unique matches
*/
public void setUniqueMatches(String uniqueMatches) {
this.uniqueMatches = uniqueMatches;
}
/**
* Gets the non unique matches assigned.
*
* @return the non unique matches assigned
*/
public String getNonUniqueMatchesAssigned() {
return nonUniqueMatchesAssigned;
}
/**
* Sets the non unique matches assigned.
*
* @param nonUniqueMatchesAssigned the new non unique matches assigned
*/
public void setNonUniqueMatchesAssigned(String nonUniqueMatchesAssigned) {
this.nonUniqueMatchesAssigned = nonUniqueMatchesAssigned;
}
/**
* Gets the scores.
*
* @return the scores
*/
public String getScores() {
return scores;
}
/**
* Sets the scores.
*
* @param scores the new scores
*/
public void setScores(String scores) {
this.scores = scores;
}
/**
* Gets the percentage.
*
* @return the percentage
*/
public String getPercentage() {
return percentage;
}
/**
* Sets the percentage.
*
* @param percentage the new percentage
*/
public void setPercentage(String percentage) {
this.percentage = percentage;
}
/**
* Gets the binary name.
*
* @return the binary name
*/
public String getBinaryName() {
return binaryName;
}
/**
* Sets the binary name.
*
* @param binaryName the new binary name
*/
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
/**
* Gets the sha key.
*
* @return the sha key
*/
public String getShaKey() {
return shaKey;
}
/**
* Sets the sha key.
*
* @param shaKey the new sha key
*/
public void setShaKey(String shaKey) {
this.shaKey = shaKey;
}
/**
* Gets the bat key list.
*
* @return the bat key list
*/
public List<String> getBatKeyList() {
return batKeyList;
}
/**
* Sets the bat key list.
*
* @param batKeyList the new bat key list
*/
public void setBatKeyList(List<String> batKeyList) {
this.batKeyList = batKeyList;
}
/**
* Adds the bat key.
*
* @param batKey the bat key
*/
public void addBatKey(String batKey) {
if (this.batKeyList == null) {
this.batKeyList = new ArrayList<>();
}
this.batKeyList.add(batKey);
}
/**
* Gets the oss version.
*
* @return the oss version
*/
public String getOssVersion() {
return ossVersion;
}
/**
* Sets the oss version.
*
* @param ossVersion the new oss version
*/
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
/**
* Gets the license.
*
* @return the license
*/
public String getLicense() {
return license;
}
/**
* Sets the license.
*
* @param license the new license
*/
public void setLicense(String license) {
this.license = license;
}
/**
* Gets the parentname.
*
* @return the parentname
*/
public String getParentname() {
return parentname;
}
/**
* Sets the parentname.
*
* @param parentname the new parentname
*/
public void setParentname(String parentname) {
this.parentname = parentname;
}
public int getTlshDistance() {
return tlshDistance;
}
public void setTlshDistance(int tlshDistance) {
this.tlshDistance = tlshDistance;
}
public String getOrgTlsh() {
return orgTlsh;
}
public void setOrgTlsh(String orgTlsh) {
this.orgTlsh = orgTlsh;
}
public String getPlatformname() {
return platformname;
}
public void setPlatformname(String platformname) {
this.platformname = platformname;
}
public String getPlatformversion() {
return platformversion;
}
public void setPlatformversion(String platformversion) {
this.platformversion = platformversion;
}
public String getUpdatedate() {
return updatedate;
}
public void setUpdatedate(String updatedate) {
this.updatedate = updatedate;
}
public String getDownloadLocation() {
return downloadLocation;
}
public void setDownloadLocation(String downloadLocation) {
this.downloadLocation = downloadLocation;
}
public String getGuireportFlag() {
return guireportFlag;
}
public void setGuireportFlag(String guireportFlag) {
this.guireportFlag = guireportFlag;
}
public String getSourcePath() {
return sourcePath;
}
public void setSourcePath(String sourcePath) {
this.sourcePath = sourcePath;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getSchStartDate() {
return schStartDate;
}
public void setSchStartDate(String schStartDate) {
this.schStartDate = schStartDate;
}
public String getSchEndDate() {
return schEndDate;
}
public void setSchEndDate(String schEndDate) {
this.schEndDate = schEndDate;
}
public String getMatchName() {
return matchName;
}
public void setMatchName(String matchName) {
this.matchName = matchName;
}
public String getPrjId() {
return prjId;
}
public void setPrjId(String prjId) {
this.prjId = prjId;
}
}
| 10,641 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProjectDistributeHis.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ProjectDistributeHis.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* The Class OssMaster.
*
* @author Administrator
*/
/**
* @author Administrator
*
*/
public class ProjectDistributeHis extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 702862084569729284L;
/** The prj id. */
private String prjId;
/** The act type. */
private String actType;
/** The act cont. */
private String actCont;
/**
* Gets the prj id.
*
* @return the prj id
*/
public String getPrjId() {
return prjId;
}
/**
* Sets the prj id.
*
* @param prjId the new prj id
*/
public void setPrjId(String prjId) {
this.prjId = prjId;
}
/**
* Gets the act type.
*
* @return the act type
*/
public String getActType() {
return actType;
}
/**
* Sets the act type.
*
* @param actType the new act type
*/
public void setActType(String actType) {
this.actType = actType;
}
/**
* Gets the act cont.
*
* @return the act cont
*/
public String getActCont() {
return actCont;
}
/**
* Sets the act cont.
*
* @param actCont the new act cont
*/
public void setActCont(String actCont) {
this.actCont = actCont;
}
}
| 1,433 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CodeBean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CodeBean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* The Class HrCodeVO.
*/
public class CodeBean extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** ์ฝ๋๋ฒํธ. */
private String cdNo;
/** ์ฝ๋๋ช
. */
private String cdNm;
/** ์ฝ๋์ค๋ช
. */
private String cdExp;
/** ์์คํ
์ฝ๋์ฌ๋ถ. */
private String sysCdYn;
/** ์ฝ๋์์ธ๋ฒํธ. */
private String[] cdDtlNo;
/** ์ฝ๋์์ธ๋ช
. */
private String[] cdDtlNm;
/** ์ฝ๋์์ธ๋ช
2. */
private String[] cdDtlNm2;
/** ์ฝ๋์์ธ์ค๋ช
. */
private String[] cdDtlExp;
/** ์ฝ๋์ฐ์ ์์. */
private String[] cdOrder;
/** ์ฝ๋์ฌ์ฉ์ฌ๋ถ. */
private String[] useYn;
/**
* Gets the ์ฝ๋๋ฒํธ.
*
* @return the ์ฝ๋๋ฒํธ
*/
public String getCdNo() {
return cdNo;
}
/**
* Sets the ์ฝ๋๋ฒํธ.
*
* @param cdNo the new ์ฝ๋๋ฒํธ
*/
public void setCdNo(String cdNo) {
this.cdNo = cdNo;
}
/**
* Gets the ์ฝ๋๋ช
.
*
* @return the ์ฝ๋๋ช
*/
public String getCdNm() {
return cdNm;
}
/**
* Sets the ์ฝ๋๋ช
.
*
* @param cdNm the new ์ฝ๋๋ช
*/
public void setCdNm(String cdNm) {
this.cdNm = cdNm;
}
/**
* Gets the ์ฝ๋์ค๋ช
.
*
* @return the ์ฝ๋์ค๋ช
*/
public String getCdExp() {
return cdExp;
}
/**
* Sets the ์ฝ๋์ค๋ช
.
*
* @param cdExp the new ์ฝ๋์ค๋ช
*/
public void setCdExp(String cdExp) {
this.cdExp = cdExp;
}
/**
* Gets the ์์คํ
์ฝ๋์ฌ๋ถ.
*
* @return the ์์คํ
์ฝ๋์ฌ๋ถ
*/
public String getSysCdYn() {
return sysCdYn;
}
/**
* Sets the ์์คํ
์ฝ๋์ฌ๋ถ.
*
* @param sysCdYn the new ์์คํ
์ฝ๋์ฌ๋ถ
*/
public void setSysCdYn(String sysCdYn) {
this.sysCdYn = sysCdYn;
}
/**
* Gets the ์ฝ๋์์ธ๋ฒํธ.
*
* @return the ์ฝ๋์์ธ๋ฒํธ
*/
public String[] getCdDtlNo() {
return cdDtlNo != null ? cdDtlNo.clone() : null;
}
/**
* Sets the ์ฝ๋์์ธ๋ฒํธ.
*
* @param cdDtlNo the new ์ฝ๋์์ธ๋ฒํธ
*/
public void setCdDtlNo(String[] cdDtlNo) {
this.cdDtlNo = cdDtlNo != null ? cdDtlNo.clone() : null;
}
/**
* Gets the ์ฝ๋์์ธ๋ช
.
*
* @return the ์ฝ๋์์ธ๋ช
*/
public String[] getCdDtlNm() {
return cdDtlNm != null ? cdDtlNm.clone() : null;
}
/**
* Sets the ์ฝ๋์์ธ๋ช
.
*
* @param cdDtlNm the new ์ฝ๋์์ธ๋ช
*/
public void setCdDtlNm(String[] cdDtlNm) {
this.cdDtlNm = cdDtlNm != null ? cdDtlNm.clone() : null;
}
/**
* Gets the ์ฝ๋์์ธ๋ช
2.
*
* @return the ์ฝ๋์์ธ๋ช
2
*/
public String[] getCdDtlNm2() {
return cdDtlNm2 != null ? cdDtlNm2.clone() : null;
}
/**
* Sets the ์ฝ๋์์ธ๋ช
2.
*
* @param cdDtlNm the new ์ฝ๋์์ธ๋ช
2
*/
public void setCdDtlNm2(String[] cdDtlNm2) {
this.cdDtlNm2 = cdDtlNm2 != null ? cdDtlNm2.clone() : null;
}
/**
* Gets the ์ฝ๋์์ธ์ค๋ช
.
*
* @return the ์ฝ๋์์ธ์ค๋ช
*/
public String[] getCdDtlExp() {
return cdDtlExp != null ? cdDtlExp.clone() : null;
}
/**
* Sets the ์ฝ๋์์ธ์ค๋ช
.
*
* @param cdDtlExp the new ์ฝ๋์์ธ์ค๋ช
*/
public void setCdDtlExp(String[] cdDtlExp) {
this.cdDtlExp = cdDtlExp != null ? cdDtlExp.clone() : null;
}
/**
* Gets the ์ฝ๋์ฐ์ ์์.
*
* @return the ์ฝ๋์ฐ์ ์์
*/
public String[] getCdOrder() {
return cdOrder != null ? cdOrder.clone() : null;
}
/**
* Sets the ์ฝ๋์ฐ์ ์์.
*
* @param cdOrder the new ์ฝ๋์ฐ์ ์์
*/
public void setCdOrder(String[] cdOrder) {
this.cdOrder = cdOrder != null ? cdOrder.clone() : null;
}
public String[] getUseYn() {
return useYn != null ? useYn.clone() : null;
}
public void setUseYn(String[] useYn) {
this.useYn = useYn != null ? useYn.clone() : null;
}
/**
* requst parameter๋ก๋ถํฐ ์ฝ๋ ์์ธ ์ ๋ณด Bean List ์์ฑ
* @param key
* @param type
* @return
*/
public List<CodeDtlBean> getDtlList() {
if (getCdNo() == null || getCdDtlNo() == null || getCdDtlNo().length == 0) {
return null;
}
ArrayList<CodeDtlBean> list = new ArrayList<CodeDtlBean>();
CodeDtlBean dtlBean = null;
int cnt = 0;
for (String s : getCdDtlNo()) {
if (s.isEmpty()) {
continue;
}
dtlBean = new CodeDtlBean();
dtlBean.setCdNo(this.getCdNo());
dtlBean.setCdDtlNo(s);
dtlBean.setCdDtlNm(this.getCdDtlNm()[cnt]);
if (this.getCdDtlExp() == null || this.getCdDtlExp().length < cnt+1) {
} else {
dtlBean.setCdDtlExp(this.getCdDtlExp()[cnt]);
}
dtlBean.setCdOrder(this.getCdOrder()[cnt]);
dtlBean.setUseYn(this.getUseYn()[cnt]);
list.add(dtlBean);
cnt++;
}
return list;
}
}
| 5,968 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CoCode.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CoCode.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.springframework.util.StringUtils;
import oss.fosslight.common.CoConstDef;
/**
* The Class CoCode.
*/
public class CoCode {
/** The cd no. */
private String cdNo;
/** The cd nm. */
private String cdNm;
/** The code dtls. */
private Vector<CoCodeDtl> codeDtls;
/** The code dtls hash. */
private HashMap<String, CoCodeDtl> codeDtlsHash;
/** The code dtls hash. by Code dtls name */
private HashMap<String, CoCodeDtl> codeDtlsNameHash;
/**
* Gets the cd no.
*
* @return the string
*/
public String getCdNo() {
return cdNo;
}
/**
* Sets the cd no.
*
* @param cdNo the new cd no
*/
public void setCdNo(String cdNo) {
this.cdNo = cdNo;
}
/**
* Gets the cd nm.
*
* @return the string
*/
public String getCdNm() {
return cdNm;
}
/**
* Sets the cd nm.
*
* @param cdNm the new cd nm
*/
public void setCdNm(String cdNm) {
this.cdNm = cdNm;
}
/**
* Instantiates a new co code.
*
* @param s the s
* @param s1 the s1
*/
public CoCode(String s, String s1)
{
codeDtls = new Vector<CoCodeDtl>();
codeDtlsHash = new HashMap<String, CoCodeDtl>();
codeDtlsNameHash = new HashMap<String, CoCodeDtl>();
cdNo = s;
cdNm = s1;
}
/**
* Adds the code dtl.
*
* @param codedtl the codedtl
*/
public void addCodeDtl(CoCodeDtl codedtl)
{
codeDtls.add(codedtl);
codeDtlsHash.put(codedtl.cdDtlNo, codedtl);
codeDtlsNameHash.put(codedtl.cdDtlNm, codedtl);
}
/**
* Gets the cd dtl nm.
*
* @param s the s
* @return the string
*/
public String getCdDtlNm(String s)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtlsHash.get(s);
return codedtl != null ? codedtl.cdDtlNm : "";
}
/**
* Gets the cd dtl exp.
*
* @param s the s
* @return the string
*/
public String getCdDtlExp(String s)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtlsHash.get(s);
return (codedtl != null && CoConstDef.FLAG_YES.equals(codedtl.useYn)) ? codedtl.cdDtlExp : "";
}
public String getCdDtlExpByName(String s)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtlsNameHash.get(s);
return (codedtl != null && CoConstDef.FLAG_YES.equals(codedtl.useYn)) ? codedtl.cdDtlExp : "";
}
public String getCdSubCdNo(String s)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtlsHash.get(s);
return (codedtl != null && CoConstDef.FLAG_YES.equals(codedtl.useYn)) ? codedtl.cdSubNo : "";
}
/**
* Gets the cd dtl prior.
*
* @param s the s
* @return the int
*/
public int getCdDtlPrior(String s)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtlsHash.get(s);
return ((codedtl != null && CoConstDef.FLAG_YES.equals(codedtl.useYn)) ? Integer.valueOf(codedtl.cdOrder).intValue() : null);
}
/**
* Gets the cd dtl no, cd dtl nm pair vector.
* @param locale
*
* @return the vector
*/
public Vector<String[]> getCdDtlNoCdDtlNmPairVector(boolean ignoreDel)
{
Vector<String[]> vector = new Vector<String[]>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(new String[] {
codedtl.cdDtlNo, codedtl.cdDtlNm, codedtl.cdSubNo, codedtl.cdDtlExp
});
}
return vector;
}
public Vector<CoCodeDtl> getCdDtlNoCdDtlNmPairVectorBean(boolean ignoreDel)
{
Vector<CoCodeDtl> vector = new Vector<CoCodeDtl>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(codedtl);
}
return vector;
}
/**
* Gets the cd dtl no, cd dtl nm pair vector, cd dtl exp.
*
* @return the vector
*/
public Vector<String[]> getCdAllPairVector(boolean ignoreDel)
{
Vector<String[]> vector = new Vector<String[]>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(new String[] {
codedtl.cdDtlNo, codedtl.cdSubNo, codedtl.cdDtlNm, codedtl.cdDtlNm2, codedtl.cdDtlExp, codedtl.cdOrder+""
});
}
return vector;
}
public Vector<CoCodeDtl> getCdAllPairVectorBean(boolean ignoreDel)
{
Vector<CoCodeDtl> vector = new Vector<CoCodeDtl>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(codedtl);
}
return vector;
}
/**
* Gets the cd dtl no vector.
*
* @return the vector
*/
public Vector<String> getCdDtlNoVector(boolean ignoreDel)
{
Vector<String> vector = new Vector<String>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(codedtl.cdDtlNo);
}
return vector;
}
/**
* Gets the cd dtl nm vector.
* @param locale
*
* @return the vector
*/
public Vector<String> getCdDtlNmVector(boolean ignoreDel) {
Vector<String> vector = new Vector<String>();
int i = 0;
for (int j = codeDtls.size(); i < j; i++) {
CoCodeDtl codedtl = (CoCodeDtl) codeDtls.get(i);
if (!ignoreDel && CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
vector.add(codedtl.cdDtlNm);
}
return vector;
}
/**
* Creates the combo box string.
*
* @param s the s
* @param s1 the s1
* @param i the i
* @return the string
*/
public String createComboBoxString(String s, String s1, int i)
{
StringBuffer stringbuffer = (new StringBuffer("<select name='")).append(s).append("'>\n");
int j = 0;
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
stringbuffer.append(" <option value='").append(codedtl.cdDtlNo).append('\'');
if ((i == 0 && codedtl.cdDtlNo.equals(s1)) || (i == 1 && codedtl.cdDtlNm.equals(s1))) {
stringbuffer.append(" selected");
}
stringbuffer.append(">").append(codedtl.cdDtlNm).append("</option>\n");
}
return stringbuffer.append("</select>\n").toString();
}
/**
* Creates the option string.
*
* @param s the s
* @param i the i
* @return the string
*/
public String createOptionString(String s, int i)
{
StringBuffer stringbuffer = new StringBuffer();
int j = 0;
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
stringbuffer.append(" <option VALUE='").append(codedtl.cdDtlNo).append('\'');
if ((i == 0 && codedtl.cdDtlNo.equals(s)) || (i == 1 && codedtl.cdDtlNm.equals(s))) {
stringbuffer.append(" selected");
}
stringbuffer.append(">").append(codedtl.cdDtlNm).append("</option>\n");
}
return stringbuffer.toString();
}
/**
* Creates the checkbox item string.
*
* @param s the s
* @return the string
*/
public String createCheckboxString(String status, String cd, String callType)
{
StringBuffer stringbuffer = new StringBuffer();
int j = 0;
if (CoConstDef.CD_PROJECT_STATUS.equals(cd)) {
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
stringbuffer.append(" <input name='statuses' type='checkbox' value='").append(codedtl.cdDtlNo).append("' ").append((status.indexOf(codedtl.cdDtlNo)>-1)?"checked='checked'":"");
stringbuffer.append(" style='margin:2px 5px 0px 0px;' /> ").append(codedtl.cdDtlNm).append(" ");
}
} else if (CoConstDef.CD_LICENSE_RESTRICTION.equals(cd)) {
int newLineIdx = 0;
if ("list".equals(callType)){
newLineIdx = 3;
}else if ("edit".equals(callType)){
newLineIdx = 4;
}
List<String> restrictionList = Arrays.asList(status.split(","));
int multiplyRestIdx = 1;
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
stringbuffer.append(" <input name='restrictions' type='checkbox' value='").append(codedtl.cdDtlNo).append("' ").append((restrictionList.contains(codedtl.cdDtlNo))?"checked='checked'":"");
stringbuffer.append(" style='margin:2px 5px 0px 0px;' /> ").append(codedtl.cdDtlNm);
if ("list".equals(callType)){
stringbuffer.append(" "+(stringbuffer.length()>650*multiplyRestIdx?"<br>"+("list".equals(callType)?"<label></label>":""):""));
} else if ("edit".equals(callType)){
stringbuffer.append(" "+(j==newLineIdx?"<br>"+("list".equals(callType)?"<label></label>":""):""));
}
if (stringbuffer.length()>650*multiplyRestIdx) multiplyRestIdx++;
}
} else if (CoConstDef.CD_NOTICE_INFO.equals(cd)) {
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
stringbuffer.append("<input name='noticeType' type='checkbox' value='").append(codedtl.cdDtlNo).append("' ").append(CoConstDef.FLAG_YES.equals(codedtl.cdDtlExp)?"checked='checked'":"");
if (CoConstDef.CD_NOTICE_HTML_STR.equals(codedtl.cdDtlNm.toUpperCase())) {
stringbuffer.append(" disabled ");
}
stringbuffer.append(" /> ").append(codedtl.cdDtlNm).append(" ");
}
}
return stringbuffer.toString();
}
/**
* Creates the checkbox item string (common).
*
* @param s the s
* @return the string
*/
public String createCommonCheckboxString(String val, String name, Boolean NAExceptionFlag){
StringBuffer stringbuffer = new StringBuffer();
int j = 0;
NAExceptionFlag = StringUtils.isEmpty(NAExceptionFlag) ? true : NAExceptionFlag; // default ์ true๋ก setting
if (!StringUtils.isEmpty(name)) {
List<String> values = Arrays.asList(val.split(","));
for (int k = codeDtls.size(); j < k; j++){
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
if (!NAExceptionFlag && codedtl.cdDtlNo.equals("NA")) { // default๋ก NA๋ ์์ฑ false๊ฐ ์
๋ ฅ์ ์์ธ์ฒ๋ฆฌ
continue;
}
stringbuffer.append(" <input name='").append(name).append("' type='checkbox' value='").append(codedtl.cdDtlNo).append("' ").append((values.contains(codedtl.cdDtlNo)) ? "checked='checked'":"");
stringbuffer.append(" style='margin:2px 5px 0px 0px;' /> ").append(codedtl.cdDtlNm).append(" ");
}
}
return stringbuffer.toString();
}
/**
* Creates the option string.
*
* @param s the s
* @param i the i
* @return the string
*/
public String createRadioString(String s, String distributionType, String networkServerType) {
StringBuffer stringbuffer = new StringBuffer();
int j = 0;
if (StringUtils.isEmpty(distributionType)) {
distributionType = CoConstDef.CD_GENERAL_MODEL;
}
if (StringUtils.isEmpty(networkServerType)) {
networkServerType = CoConstDef.FLAG_NO;
}
for (int k = codeDtls.size(); j < k; j++) {
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)
|| codedtl.cdDtlNo.equals(CoConstDef.CD_NETWORK_SERVER)) {
continue;
}
stringbuffer.append("<span class='radioSet'>")
.append("<input type='radio' name='distributionType' value='")
.append(codedtl.cdDtlNo).append("' ").append(" onclick='fn.chgOssNotice(\"").append(codedtl.cdDtlExp).append("\")' ")
.append(" id='radio_").append(codedtl.cdDtlNo).append("' ")
.append((distributionType.indexOf(codedtl.cdDtlNo)>-1)?"checked='checked'":"").append(" />")
.append("<label for='radio_").append(codedtl.cdDtlNo).append("'>").append(codedtl.cdDtlNm).append("</label>")
.append("</span>");
}
stringbuffer.append("<br> โ Network service only? ");
stringbuffer.append("<span class=\"radioSet\">")
.append("<input name='networkServerType' type='radio' value='Y' id='networkServerType_Y'")
.append(networkServerType.equals(CoConstDef.FLAG_YES) ? "checked='checked'" : "").append(" />")
.append("<label for='networkServerType_Y'>Yes</label>")
.append("</span>");
stringbuffer.append("<span class=\"radioSet\">")
.append("<input name='networkServerType' type='radio' value='N' id='networkServerType_N'")
.append(networkServerType.equals(CoConstDef.FLAG_NO) ? "checked='checked'" : "").append(" />")
.append("<label for='networkServerType_N'>No</label>")
.append("</span>");
return stringbuffer.toString();
}
public String createOptionCheckboxString(String s, String s1, int i) {
StringBuffer stringbuffer = new StringBuffer();
int j = 0;
for (int k = codeDtls.size(); j < k; j++)
{
CoCodeDtl codedtl = (CoCodeDtl)codeDtls.get(j);
if (CoConstDef.FLAG_NO.equals(codedtl.useYn)) {
continue;
}
if (s1.equals("oss")) {
stringbuffer.append("<li><input type='checkbox' name='mostUsedOssChartDivision' value='").append(codedtl.cdDtlNo).append("' ")
.append(" id='checkboxOss_").append(codedtl.cdDtlNo).append("' />")
.append("<label for='checkboxOss_").append(codedtl.cdDtlNo).append("'>").append(codedtl.cdDtlNm).append("</label></li>");
} else {
stringbuffer.append("<li><input type='checkbox' name='mostUsedLicenseChartDivision' value='").append(codedtl.cdDtlNo).append("' ")
.append(" id='checkboxLicense_").append(codedtl.cdDtlNo).append("' />")
.append("<label for='checkboxLicense_").append(codedtl.cdDtlNo).append("'>").append(codedtl.cdDtlNm).append("</label></li>");
}
}
return stringbuffer.toString();
}
}
| 17,169 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
File.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/File.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* JF_FILE Table Entity
* ํ์ผ๊ด๋ฆฌ
*
* @author ks-choi
*
*/
public class File extends ComBean implements Serializable{
private static final long serialVersionUID = 6658712585854634962L;
private String fileSeq; //ํ์ผ ์๋ฒ (A.I) 20160524 ms-kwon
private String fileId; // ํ์ผ ID
private String gubn; // ํ์ผ ๊ตฌ๋ถ๊ฐ [A:All, R:Role, U:Login USER, P: Password]
private String gubnChk; // GUBN ํ๋๊ฐ์ ๋ฐ๋ฅธ ์ฒดํฌ๊ฐ [A:NULL, R:๊ถํ๋ช
, U:NULL, P: ์ํธ]
private String mId; // ๊ฒ์ํ ID
private String bId; // ๊ฒ์๊ธ ID
private String origNm; // ์๋ณธ ํ์ผ๋ช
private String logiNm; // ์ ์ฅ๋ ๋ฌผ๋ฆฌ ํ์ผ๋ช
private String logiThumbNm; // ์ ์ฅ๋ ๋ฌผ๋ฆฌ ํ์ผ๋ช
(์ธ๋ค์ผ)
private String logiPath; // ์ ์ฅ๋ ํ์ผ ๊ฒฝ๋ก
private String logiThumbPath; // ์ ์ฅ๋ ํ์ผ ๊ฒฝ๋ก(์ธ๋ค์ผ)
private String ext; // ํ์ฅ์
private String size; // ํฌ๊ธฐ
private String etpId;
private int width;
private int height;
private String resultCode; // ํ์ผ ์ฒ๋ฆฌ ๊ฒฐ๊ณผ์ฝ๋๊ฐ
private String[] fileSeqs;
private String reuseFlag;
private String refPrjId;
public File() {
super();
}
public File(String fileSeq) {
super();
this.fileSeq = fileSeq;
}
public String getFileSeq() {
return fileSeq;
}
public void setFileSeq(String fileSeq) {
this.fileSeq = fileSeq;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getGubn() {
return gubn;
}
public void setGubn(String gubn) {
this.gubn = gubn;
}
public String getGubnChk() {
return gubnChk;
}
public void setGubnChk(String gubnChk) {
this.gubnChk = gubnChk;
}
public String getmId() {
return mId;
}
public void setmId(String mId) {
this.mId = mId;
}
public String getbId() {
return bId;
}
public void setbId(String bId) {
this.bId = bId;
}
public String getOrigNm() {
return origNm;
}
public void setOrigNm(String origNm) {
this.origNm = origNm;
}
public String getLogiNm() {
return logiNm;
}
public void setLogiNm(String logiNm) {
this.logiNm = logiNm;
}
public String getLogiThumbNm() {
return logiThumbNm;
}
public void setLogiThumbNm(String logiThumbNm) {
this.logiThumbNm = logiThumbNm;
}
public String getLogiPath() {
return logiPath;
}
public void setLogiPath(String logiPath) {
this.logiPath = logiPath;
}
public String getLogiThumbPath() {
return logiThumbPath;
}
public void setLogiThumbPath(String logiThumbPath) {
this.logiThumbPath = logiThumbPath;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public String[] getFileSeqs() {
return fileSeqs != null ? fileSeqs.clone() : null;
}
public void setFileSeqs(String[] fileSeqs) {
this.fileSeqs = fileSeqs != null ? fileSeqs.clone() : null;
}
public String getEtpId() {
return etpId;
}
public void setEtpId(String etpId) {
this.etpId = etpId;
}
public String getReuseFlag() {
return reuseFlag;
}
public void setReuseFlag(String reuseFlag) {
this.reuseFlag = reuseFlag;
}
public String getRefPrjId() {
return refPrjId;
}
public void setRefPrjId(String refPrjId) {
this.refPrjId = refPrjId;
}
} | 4,079 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
LicenseMaster.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/LicenseMaster.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.util.StringUtil;
/**
* The Class LicenseMaster.
*/
public class LicenseMaster extends ComBean implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -2103290178702190921L;
/** The license id. */
private String licenseId; //๋ผ์ด์ผ์ค ID
/** The license name. */
private String licenseName; //๋ผ์ด์ผ์ค ์ด๋ฆ
/** The license name temp. */
private String licenseNameTemp; //๋ผ์ด์ผ์ค ์ด๋ฆ
/** The license type. */
private String licenseType; //๋ผ์ด์ผ์ค ํ์
private String licenseTypeFull; //๋ผ์ด์ผ์ค ํ์
/** The license type val. */
private String licenseTypeVal; //๋ผ์ด์ผ์ค ํ์
/** The license nickname. */
private String licenseNickname; //๋ผ์ด์ผ์ค ๋๋ค์
/** The obligation disclosing src yn. */
private String obligationDisclosingSrcYn; //Obligation Option
/** The obligation notification yn. */
private String obligationNotificationYn; //Obligation Option
/** The obligation needs check yn. */
private String obligationNeedsCheckYn; //Obligation Option
/** The obligation. */
private String obligation; //Obligation HTML
/** The obligation code. */
private String obligationCode; //Obligation HTML
/** The obligation checks. */
private String obligationChecks; //Obligation Check ์ํ(๊ณ ์ง, ์์ค๊ณต๊ฐ, ์ฒดํฌ)
/** The short identifier. */
private String shortIdentifier; //Identifier
/** The webpage. */
private String webpage; //URL
private String webpageLinkFormat; //URL
private String[] webpages;
/** The internal url. */
private String internalUrl;
/** The description. */
private String description; //descrition
private String descriptionHtml;
/** The license text. */
private String licenseText; //๋ผ์ด์ผ์ค Text
/** The attribution. */
private String attribution; //attribution
/** The req license text yn. */
private String reqLicenseTextYn; //reqLicenseTextYn
/** The license nickname str. */
private String licenseNicknameStr; // pipe๊ตฌ๋ถ ๋๋ค์
/** The license nicknames. */
private String[] licenseNicknames;
/** The license nickname list. */
private List<String> licenseNicknameList;
private String obligationType;
/** The c start date. */
//๋ ์ง๊ฒ์์กฐ๊ฑด
private String cStartDate; //์์ฑ์ผ(์์)
/** The c end date. */
private String cEndDate; //์์ฑ์ผ(๋)
/** The m start date. */
private String mStartDate; //์์ ์ผ(์์)
/** The m end date. */
private String mEndDate; //์์ ์ผ(๋)
/** The component id. */
//componentsLicnese
private String componentId;
/** The component license id. */
private String componentLicenseId;
/** The comment. */
//comment ์ด๋ ฅ
private String comment;
/** The comment cont. */
private String commentCont;
/** The restriction. */
private String restriction;
private String restrictionStr;
/** The restrictions. */
private String restrictions;
/** The arrRestriction. */
private String[] arrRestriction;
/** The restrictionList. */
private String restrictionList;
private String licenseNameAllSearchFlag;
/** sort order **/
private String sOrder;
private String defaultSearchFlag;
/**
* Instantiates a new license master.
*/
public LicenseMaster() {
super();
}
/**
* Instantiates a new license master.
*
* @param licenseId the license id
*/
public LicenseMaster(String licenseId) {
super();
this.licenseId = licenseId;
}
/**
* Gets the license id.
*
* @return the license id
*/
public String getLicenseId() {
return licenseId;
}
/**
* Sets the license id.
*
* @param licenseId the new license id
*/
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
/**
* Gets the license name.
*
* @return the license name
*/
public String getLicenseName() {
return licenseName;
}
/**
* Sets the license name.
*
* @param licenseName the new license name
*/
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
/**
* Gets the license type.
*
* @return the license type
*/
public String getLicenseType() {
return licenseType;
}
/**
* Sets the license type.
*
* @param licenseType the new license type
*/
public void setLicenseType(String licenseType) {
this.licenseType = licenseType;
}
/**
* Gets the obligation notification yn.
*
* @return the obligation notification yn
*/
public String getObligationNotificationYn() {
return obligationNotificationYn;
}
/**
* Sets the obligation notification yn.
*
* @param obligationNotificationYn the new obligation notification yn
*/
public void setObligationNotificationYn(String obligationNotificationYn) {
this.obligationNotificationYn = obligationNotificationYn;
}
/**
* Gets the short identifier.
*
* @return the short identifier
*/
public String getShortIdentifier() {
return shortIdentifier;
}
/**
* Sets the short identifier.
*
* @param shortIdentifier the new short identifier
*/
public void setShortIdentifier(String shortIdentifier) {
this.shortIdentifier = shortIdentifier;
}
/**
* Gets the webpage.
*
* @return the webpage
*/
public String getWebpage() {
return CommonFunction.convertUrlLinkFormat(webpage);
}
/**
* Sets the webpage.
*
* @param webpage the new webpage
*/
public void setWebpage(String webpage) {
this.webpage = webpage;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(String description) {
this.description = description;
if (!isEmptyWithLineSeparator(description)) {
this.descriptionHtml = CommonFunction.makeHtmlLinkTagWithText(CommonFunction.lineReplaceToBR(description));
}
}
/**
* Gets the license text.
*
* @return the license text
*/
public String getLicenseText() {
return licenseText;
}
/**
* Sets the license text.
*
* @param licenseText the new license text
*/
public void setLicenseText(String licenseText) {
this.licenseText = licenseText;
}
/**
* Gets the attribution.
*
* @return the attribution
*/
public String getAttribution() {
return attribution;
}
/**
* Sets the attribution.
*
* @param attribution the new attribution
*/
public void setAttribution(String attribution) {
this.attribution = attribution;
}
/**
* Gets the obligation disclosing src yn.
*
* @return the obligation disclosing src yn
*/
public String getObligationDisclosingSrcYn() {
return obligationDisclosingSrcYn;
}
/**
* Sets the obligation disclosing src yn.
*
* @param obligationDisclosingSrcYn the new obligation disclosing src yn
*/
public void setObligationDisclosingSrcYn(String obligationDisclosingSrcYn) {
this.obligationDisclosingSrcYn = obligationDisclosingSrcYn;
}
/**
* Gets the obligation needs check yn.
*
* @return the obligation needs check yn
*/
public String getObligationNeedsCheckYn() {
return obligationNeedsCheckYn;
}
/**
* Sets the obligation needs check yn.
*
* @param obligationNeedsCheckYn the new obligation needs check yn
*/
public void setObligationNeedsCheckYn(String obligationNeedsCheckYn) {
this.obligationNeedsCheckYn = obligationNeedsCheckYn;
}
/**
* Gets the license nickname.
*
* @return the license nickname
*/
public String getLicenseNickname() {
return licenseNickname;
}
/**
* Sets the license nickname.
*
* @param licenseNickname the new license nickname
*/
public void setLicenseNickname(String licenseNickname) {
this.licenseNickname = licenseNickname;
}
/**
* Gets the obligation.
*
* @return the obligation
*/
public String getObligation() {
return obligation;
}
/**
* Sets the obligation.
*
* @param obligation the new obligation
*/
public void setObligation(String obligation) {
this.obligation = obligation;
}
/**
* Gets the c start date.
*
* @return the c start date
*/
public String getcStartDate() {
return cStartDate;
}
/**
* Sets the c start date.
*
* @param cStartDate the new c start date
*/
public void setcStartDate(String cStartDate) {
this.cStartDate = cStartDate;
}
/**
* Gets the c end date.
*
* @return the c end date
*/
public String getcEndDate() {
return cEndDate;
}
/**
* Sets the c end date.
*
* @param cEndDate the new c end date
*/
public void setcEndDate(String cEndDate) {
this.cEndDate = cEndDate;
}
/**
* Gets the m start date.
*
* @return the m start date
*/
public String getmStartDate() {
return mStartDate;
}
/**
* Sets the m start date.
*
* @param mStartDate the new m start date
*/
public void setmStartDate(String mStartDate) {
this.mStartDate = mStartDate;
}
/**
* Gets the m end date.
*
* @return the m end date
*/
public String getmEndDate() {
return mEndDate;
}
/**
* Sets the m end date.
*
* @param mEndDate the new m end date
*/
public void setmEndDate(String mEndDate) {
this.mEndDate = mEndDate;
}
/**
* Gets the obligation checks.
*
* @return the obligation checks
*/
public String getObligationChecks() {
return obligationChecks;
}
/**
* Sets the obligation checks.
*
* @param obligationChecks the new obligation checks
*/
public void setObligationChecks(String obligationChecks) {
this.obligationChecks = obligationChecks;
}
/**
* Gets the component license id.
*
* @return the component license id
*/
public String getComponentLicenseId() {
return componentLicenseId;
}
/**
* Sets the component license id.
*
* @param componentLicenseId the new component license id
*/
public void setComponentLicenseId(String componentLicenseId) {
this.componentLicenseId = componentLicenseId;
}
/**
* Gets the comment.
*
* @return the comment
*/
public String getComment() {
return comment;
}
/**
* Sets the comment.
*
* @param comment the new comment
*/
public void setComment(String comment) {
this.comment = comment;
}
/**
* Gets the component id.
*
* @return the component id
*/
public String getComponentId() {
return componentId;
}
/**
* Sets the component id.
*
* @param componentId the new component id
*/
public void setComponentId(String componentId) {
this.componentId = componentId;
}
/**
* Gets the serialversionuid.
*
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}
/**
* Gets the license nicknames.
*
* @return the license nicknames
*/
public String[] getLicenseNicknames() {
return licenseNicknames != null ? licenseNicknames.clone() : null;
}
/**
* Sets the license nicknames.
*
* @param licenseNicknames the new license nicknames
*/
public void setLicenseNicknames(String[] licenseNicknames) {
this.licenseNicknames = licenseNicknames != null ?
licenseNicknames.clone() : null;
}
/**
* Gets the req license text yn.
*
* @return the req license text yn
*/
public String getReqLicenseTextYn() {
return reqLicenseTextYn;
}
/**
* Sets the req license text yn.
*
* @param reqLicenseTextYn the new req license text yn
*/
public void setReqLicenseTextYn(String reqLicenseTextYn) {
this.reqLicenseTextYn = reqLicenseTextYn;
}
/**
* Gets the comment cont.
*
* @return the comment cont
*/
public String getCommentCont() {
return commentCont;
}
/**
* Sets the comment cont.
*
* @param commentCont the new comment cont
*/
public void setCommentCont(String commentCont) {
this.commentCont = commentCont;
}
/**
* Gets the license nickname list.
*
* @return the license nickname list
*/
public List<String> getLicenseNicknameList() {
return licenseNicknameList;
}
/**
* Sets the license nickname list.
*
* @param licenseNicknameList the new license nickname list
*/
public void setLicenseNicknameList(List<String> licenseNicknameList) {
this.licenseNicknameList = licenseNicknameList;
}
/**
* Adds the license nickname list.
*
* @param licenseNicknameStr the license nickname str
*/
public void addLicenseNicknameList(String licenseNicknameStr) {
if (this.licenseNicknameList == null) {
this.licenseNicknameList = new ArrayList<>();
}
this.licenseNicknameList.add(licenseNicknameStr);
}
/**
* Gets the license nickname str.
*
* @return the license nickname str
*/
public String getLicenseNicknameStr() {
return licenseNicknameStr;
}
/**
* Sets the license nickname str.
*
* @param licenseNicknameStr the new license nickname str
*/
public void setLicenseNicknameStr(String licenseNicknameStr) {
this.licenseNicknameStr = licenseNicknameStr;
}
/**
* Gets the license type val.
*
* @return the license type val
*/
public String getLicenseTypeVal() {
return licenseTypeVal;
}
/**
* Sets the license type val.
*
* @param licenseTypeVal the new license type val
*/
public void setLicenseTypeVal(String licenseTypeVal) {
this.licenseTypeVal = licenseTypeVal;
}
/**
* Gets the obligation code.
*
* @return the obligation code
*/
public String getObligationCode() {
return obligationCode;
}
/**
* Sets the obligation code.
*
* @param obligationCode the new obligation code
*/
public void setObligationCode(String obligationCode) {
this.obligationCode = obligationCode;
}
/**
* Gets the license name temp.
*
* @return the license name temp
*/
public String getLicenseNameTemp() {
return licenseNameTemp;
}
/**
* Sets the license name temp.
*
* @param licenseNameTemp the new license name temp
*/
public void setLicenseNameTemp(String licenseNameTemp) {
this.licenseNameTemp = licenseNameTemp;
}
/**
* Gets the internal url.
*
* @return the internalUrl
*/
public String getInternalUrl() {
return internalUrl;
}
/**
* Sets the internal url.
*
* @param internalUrl the internalUrl to set
*/
public void setInternalUrl(String internalUrl) {
this.internalUrl = internalUrl;
}
/**
* @return the descriptionHtml
*/
public String getDescriptionHtml() {
return descriptionHtml;
}
/**
* @param descriptionHtml the descriptionHtml to set
*/
public void setDescriptionHtml(String descriptionHtml) {
this.descriptionHtml = descriptionHtml;
}
public String getWebpageLinkFormat() {
if (StringUtil.isEmpty(this.webpageLinkFormat) && !StringUtil.isEmpty(this.webpage)) {
if (this.webpage.contains(",")){
String[] webpages = this.webpage.split(",");
String result = "";
for (int i = 0 ; i < webpages.length ; i++){
if (i > 0){ result += "<br>"; }
result += "<a href='"+webpages[i]+"' target='_blank'>" + webpages[i] + "</a>";
}
return result;
}else{
return "<a href='"+this.webpage+"' target='_blank'>" + this.webpage + "</a>";
}
}
return webpageLinkFormat;
}
public void setWebpageLinkFormat(String webpageLinkFormat) {
this.webpageLinkFormat = webpageLinkFormat;
}
public String getObligationType() {
return obligationType;
}
public void setObligationType(String obligationType) {
this.obligationType = obligationType;
}
public String getRestriction() {
return restriction;
}
public void setRestriction(String restriction) {
this.restriction = restriction;
}
public String getRestrictions() {
return restrictions;
}
public void setRestrictions(String restrictions) {
this.restrictions = restrictions;
}
public String[] getArrRestriction() {
return arrRestriction != null ? arrRestriction.clone() : null;
}
public void setArrRestriction(String[] arrRestriction) {
this.arrRestriction = arrRestriction != null ?
arrRestriction.clone() : null;
}
public String getRestrictionList() {
return restrictionList;
}
public void setRestrictionList(String restrictionList) {
this.restrictionList = restrictionList;
}
public String getRestrictionStr() {
return restrictionStr;
}
public void setRestrictionStr(String restrictionStr) {
this.restrictionStr = restrictionStr;
}
public String getLicenseTypeFull() {
return licenseTypeFull;
}
public void setLicenseTypeFull(String licenseTypeFull) {
this.licenseTypeFull = licenseTypeFull;
}
public String getLicenseNameAllSearchFlag() {
return licenseNameAllSearchFlag;
}
public void setLicenseNameAllSearchFlag(String licenseNameAllSearchFlag) {
this.licenseNameAllSearchFlag = licenseNameAllSearchFlag;
}
public String[] getWebpages() {
return webpages != null ? webpages.clone() : null;
}
public void setWebpages(String[] webpages) {
this.webpages = webpages != null ? webpages.clone() : null;
}
public String getsOrder() {
return sOrder;
}
public void setsOrder(String sOrder) {
this.sOrder = sOrder;
}
public String getDefaultSearchFlag() {
return defaultSearchFlag;
}
public void setDefaultSearchFlag(String defaultSearchFlag) {
this.defaultSearchFlag = defaultSearchFlag;
}
}
| 18,449 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CommentsHistory.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CommentsHistory.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import oss.fosslight.common.CommonFunction;
/**
* The Class commentsHistory.
*/
public class CommentsHistory extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 5662786622538214724L;
/** The comm id. */
private String commId;
/** The reference id. */
private String referenceId;
/** The reference div. */
private String referenceDiv;
/** The contents. */
private String contents;
/** The use yn. */
private String useYn;
/** The mail type. */
private String mailType;
/** The mail send type. */
private String mailSendType;
/** The status. */
private String status;
/** The status code. */
private String statusCode;
/** The sch reference div. */
private String schReferenceDiv;
/** The sch keyword. */
private String schKeyword;
/** The expansion 1. */
private String expansion1;
/** The readYn. */
private String readYn;
/** The prjName. */
private String prjName;
/** The reviewer. */
private String reviewer;
/** The user. */
private String user;
/** The prjDivisionId. */
private String prjDivisionId;
/* 2018-07-20 choye ์ถ๊ฐ */
/** The commentsMode. */
private String commentsMode;
/** The delOsdd. */
private String delOsdd;
/**
* Gets the comm id.
*
* @return the comm id
*/
public String getCommId() {
return commId;
}
/**
* Sets the comm id.
*
* @param commId the new comm id
*/
public void setCommId(String commId) {
this.commId = commId;
}
/**
* Gets the reference id.
*
* @return the reference id
*/
public String getReferenceId() {
return referenceId;
}
/**
* Sets the reference id.
*
* @param referenceId the new reference id
*/
public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}
/**
* Gets the reference div.
*
* @return the reference div
*/
public String getReferenceDiv() {
return referenceDiv;
}
/**
* Sets the reference div.
*
* @param referenceDiv the new reference div
*/
public void setReferenceDiv(String referenceDiv) {
this.referenceDiv = referenceDiv;
}
/**
* Gets the contents.
*
* @return the contents
*/
public String getContents() {
return contents;
}
/**
* Sets the contents.
*
* @param contents the new contents
*/
public void setContents(String contents) {
this.contents = contents;
}
/**
* Gets the use yn.
*
* @return the use yn
*/
public String getUseYn() {
return useYn;
}
/**
* Sets the use yn.
*
* @param useYn the new use yn
*/
public void setUseYn(String useYn) {
this.useYn = useYn;
}
/**
* Gets the mail type.
*
* @return the mail type
*/
public String getMailType() {
return mailType;
}
/**
* Sets the mail type.
*
* @param mailType the new mail type
*/
public void setMailType(String mailType) {
this.mailType = mailType;
}
/**
* Gets the mail send type.
*
* @return the mail send type
*/
public String getMailSendType() {
return mailSendType;
}
/**
* Sets the mail send type.
*
* @param mailSendType the new mail send type
*/
public void setMailSendType(String mailSendType) {
this.mailSendType = mailSendType;
}
/**
* Gets the status.
*
* @return the status
*/
public String getStatus() {
return status;
}
/**
* Sets the status.
*
* @param status the new status
*/
public void setStatus(String status) {
this.status = status;
}
/**
* Gets the sch reference div.
*
* @return the sch reference div
*/
public String getSchReferenceDiv() {
return schReferenceDiv;
}
/**
* Sets the sch reference div.
*
* @param schReferenceDiv the new sch reference div
*/
public void setSchReferenceDiv(String schReferenceDiv) {
this.schReferenceDiv = schReferenceDiv;
}
/**
* Gets the sch keyword.
*
* @return the sch keyword
*/
public String getSchKeyword() {
return avoidNull(schKeyword).trim();
}
/**
* Sets the sch keyword.
*
* @param schKeyword the new sch keyword
*/
public void setSchKeyword(String schKeyword) {
this.schKeyword = schKeyword;
}
/**
* Gets the sch keyword sql.
*
* @return the sch keyword sql
*/
public String getSchKeywordSql() {
return CommonFunction.makeSearchQuery(this.schKeyword, "CONTENTS");
}
/**
* Gets the sch keyword list.
*
* @return the sch keyword list
*/
public String[] getSchKeywordList() {
return this.schKeyword.split(" ");
}
/**
* Gets the expansion 1.
*
* @return the expansion 1
*/
public String getExpansion1() {
return expansion1;
}
/**
* Sets the expansion 1.
*
* @param expansion1 the new expansion 1
*/
public void setExpansion1(String expansion1) {
this.expansion1 = expansion1;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
/**
* Sets the readYn.
*
* @param readYn the new readYn
*/
public String getReadYn() {
return readYn;
}
public void setReadYn(String readYn) {
this.readYn = readYn;
}
/**
* Sets the prjName.
*
* @param prjName the new prjName
*/
public String getPrjName() {
return prjName;
}
public void setPrjName(String prjName) {
this.prjName = prjName;
}
/**
* Sets the reviewer.
*
* @param reviewer the new reviewer
*/
public String getReviewer() {
return reviewer;
}
public void setReviewer(String reviewer) {
this.reviewer = reviewer;
}
/**
* Sets the user.
*
* @param user the new user
*/
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
/**
* Sets the prjDivisionId.
*
* @param prjDivisionId the new prjDivisionId
*/
public String getPrjDivisionId() {
return prjDivisionId;
}
public void setPrjDivisionId(String prjDivisionId) {
this.prjDivisionId = prjDivisionId;
}
/**
* Sets the commentsMode.
*
* @param commentsMode the new commentsMode
*/
public String getCommentsMode() {
return commentsMode;
}
public void setCommentsMode(String commentsMode) {
this.commentsMode = commentsMode;
}
/**
* Sets the delOsdd.
*
* @param delOsdd the new delOsdd
*/
public String getDelOsdd() {
return delOsdd;
}
public void setDelOsdd(String delOsdd) {
this.delOsdd = delOsdd;
}
} | 6,959 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Project.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/Project.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.util.StringUtil;
public class Project extends ComBean implements Serializable {
@Override
public String toString() {
return "Project [prjId=" + prjId + ", prjName=" + prjName + ", prjVersion=" + prjVersion + ", distributionType="
+ distributionType + ", ossNoticeDueDate=" + ossNoticeDueDate + ", comment=" + comment + ", commentIdx="
+ commentIdx + ", osType=" + osType + ", osTypeEtc=" + osTypeEtc + ", identificationStatus="
+ identificationStatus + ", verificationStatus=" + verificationStatus + ", destributionName="
+ destributionName + ", destributionSoftwareType=" + destributionSoftwareType
+ ", identificationSubStatusPartner=" + identificationSubStatusPartner + ", identificationSubStatusSrc="
+ identificationSubStatusSrc + ", identificationSubStatusBat=" + identificationSubStatusBat
+ ", completeYn=" + completeYn + ", reviewer=" + reviewer + ", useYn=" + useYn + ", prjIds="
+ Arrays.toString(prjIds) + ", category=" + category + ", subcategory=" + subcategory + ", modelName="
+ modelName + ", releaseDate=" + releaseDate + ", prjDivision=" + prjDivision + ", prjDivisionName="
+ prjDivisionName + ", prjUserId=" + prjUserId + ", prjUserName=" + prjUserName + ", watchers="
+ Arrays.toString(watchers) + ", watcherList=" + watcherList + ", modelList=" + modelList + ", copy="
+ copy + ", oldId=" + oldId + ", lastModifiedTime=" + lastModifiedTime + ", distributeTarget="
+ distributeTarget + ", destributionStatus=" + destributionStatus + ", distributeMasterCategory="
+ distributeMasterCategory + ", distributeName=" + distributeName + ", distributeSoftwareType="
+ distributeSoftwareType + ", distributeDeployYn=" + distributeDeployYn + ", distributeDeployTime="
+ distributeDeployTime + ", licenseFileName=" + licenseFileName + ", openSourceFileName="
+ openSourceFileName + ", srcCsvFileId=" + srcCsvFileId + ", srcAndroidCsvFileId=" + srcAndroidCsvFileId
+ ", srcAndroidNoticeFileId=" + srcAndroidNoticeFileId + ", noticeFileId=" + noticeFileId
+ ", reviewReportFileId=" + reviewReportFileId + ", srcAndroidResultFileId=" + srcAndroidResultFileId
+ ", packageFileId=" + packageFileId + ", noticeFile=" + noticeFile + ", reviewReportFile="
+ reviewReportFile + ", packageFile=" + packageFile + ", csvFile=" + csvFile + ", androidCsvFile="
+ androidCsvFile + ", androidNoticeFile=" + androidNoticeFile + ", ossId=" + ossId + ", ossName="
+ ossName + ", licenseName=" + licenseName + ", status=" + status + ", refPartnerId=" + refPartnerId
+ ", readmeContent=" + readmeContent + ", readmeYn=" + readmeYn + ", verifyFileContent="
+ verifyFileContent + ", exceptFileContent=" + exceptFileContent + ", schStartDate=" + schStartDate
+ ", schEndDate=" + schEndDate + ", prjModelJson=" + prjModelJson + ", division=" + division
+ ", vulnYn=" + vulnYn + ", ossReportFlag=" + ossReportFlag +"]";
}
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -6696666941312232808L;
/** The prj id. */
private String prjId;
/** The prj id list. */
private List<String> prjIdList;
/** The prj name. */
private String prjName;
/** The prj version. */
private String prjVersion;
/** The distribution type. */
private String distributionType;
/** distribution type ์ฝ๋์ ์์ธ ์ฝ๋ ์ค๋ช
(์ ํ์ ๋ฐ๋ฅธ ๋ฒํผ ํ์ ์ ์ด๋ฅผ ์ํด ํ์). */
private String distributionTypeOfCodeDtlExp;
/** The oss notice due date. */
private String ossNoticeDueDate;
/** The comment. */
private String comment;
/** The comment idx. */
private String commentIdx;
/** The os type. */
private String osType;
/** The os type etc. */
private String osTypeEtc;
/** The notice type. */
private String noticeType;
private String noticeTypeEtc;
/** The use custom notice yn. */
private String useCustomNoticeYn;
/** ๋ค์ด๋ก๋ ํ์ฉ ํ๋๊ทธ. */
private int allowDownloadBitFlag = 1;
/** The allow download notice HTML yn. */
private String allowDownloadNoticeHTMLYn;
/** The allow download notice text yn. */
private String allowDownloadNoticeTextYn;
/** The allow download simple HTML yn. */
private String allowDownloadSimpleHTMLYn;
/** The allow download simple text yn. */
private String allowDownloadSimpleTextYn;
/** The allow download SPDX sheet yn. */
private String allowDownloadSPDXSheetYn;
/** The allow download SPDX rdf yn. */
private String allowDownloadSPDXRdfYn;
/** The allow download SPDX tag yn. */
private String allowDownloadSPDXTagYn;
/** The allow download SPDX json yn. */
private String allowDownloadSPDXJsonYn;
/** The allow download SPDX yaml yn. */
private String allowDownloadSPDXYamlYn;
/** The allow download CycloneDX json yn. */
private String allowDownloadCDXJsonYn;
/** The allow download CycloneDX xml yn. */
private String allowDownloadCDXXmlYn;
/** The identification status. */
private String identificationStatus;
/** The verification status. */
private String verificationStatus;
/** The destribution name. */
private String destributionName;
/** The destribution software type. */
private String destributionSoftwareType;
/** The identification sub status partner. */
private String identificationSubStatusPartner;
/** The identification sub status dep. */
private String identificationSubStatusDep;
/** The identification sub status src. */
private String identificationSubStatusSrc;
/** The identification sub status bat. */
private String identificationSubStatusBat;
/** The identification sub status android. */
private String identificationSubStatusAndroid;
/** The identification sub status bin. */
private String identificationSubStatusBin;
/** The identification sub status bom. */
private String identificationSubStatusBom;
/** The complete yn. */
private String completeYn;
/** The drop yn. */
private String dropYn;
/** The verify yn */
private String verifyYn;
/** The reviewer. */
private String reviewer;
/** The use yn. */
private String useYn;
/** The prj ids. */
private String[] prjIds;
/** The code. */
private String code;
/** The category. */
// PROJECT_MODEL
private String category;
/** The subcategory. */
private String subcategory;
/** The model name. */
private String modelName;
/** The release date. */
private String releaseDate;
/** The model list info. */
private List<String> modelListInfo;
/** The category nm. */
private String categoryNm;
/** The act type. */
private String actType;
/** The act cont. */
private String actCont;
/** The prj division. */
// PROJECT_WATCHER
private String prjDivision;
/** The prj division name. */
private String prjDivisionName;
/** The prj user id. */
private String prjUserId;
/** The prj user name. */
private String prjUserName;
/** The prj email. */
private String prjEmail;
/** The watchers. */
private String[] watchers;
/** The watcher list. */
private List<Project> watcherList;
/** The model list. */
private List<Project> modelList;
/** The model delete list. */
private List<Project> modelDeleteList;
/** The division list. */
private ArrayList<Map<String, String>> divisionList;
/** The email list. */
private ArrayList<Map<String, String>> emailList;
/** The watcher list info. */
private List<String> watcherListInfo;
/** The osdd sync yn. */
private String osddSyncYn;
/** The osdd sync time. */
private String osddSyncTime;
/** The copy. */
// COPY
private String copy;
/** The old id. */
private String oldId;
/** The copy prj id. */
private String copyPrjId;
/** The copy flag. */
private String copyFlag = "N";
/** The last modified time. */
// DISTRIBUTION
private String lastModifiedTime; //์ต์ข
์์ ์๊ฐ
/** The distribute target. */
private String distributeTarget; //๋ฐฐํฌ์ฌ์ดํธ
/** The destribution status. */
private String destributionStatus; // ๋์คํธ๋ฆฌ๋ทฐํธ ์ํ
private String beforeDistributionStatus;
/** The distribute master category. */
private String distributeMasterCategory;
/** The distribute name. */
private String distributeName; // ๋์คํฌ๋ฆฝ์
์ด๋ฆ
/** The before distribute name. */
private String beforeDistributeName; // ๋ฐฐํฌ๋์๋ ๋์คํฌ๋ฆฝ์ ์ด๋ฆ
/** The distribute software type. */
private String distributeSoftwareType = CoConstDef.CD_DTL_NOTICE_DEFAULT_SOFTWARE_TYPE_MODEL; // ์ํํธ์จ์ด/๋ชจ๋ธ ํ์
/** The before distribute software type. */
private String beforeDistributeSoftwareType; // ๋ฐฐํฌ๋์๋ ์ํํธ์จ์ด/๋ชจ๋ธ ํ์
/** The distribute deploy yn. */
private String distributeDeployYn; // ๋ฐฐํฌ์ ๋ฌด
/** The distribute deploy time. */
private String distributeDeployTime; // ๋ฐฐํฌ์๊ฐ
/** The distribute deploy user. */
private String distributeDeployUser; // ๋ฐฐํฌ์
private String beforeDistributeDeployUser;
/** The distribute rejector. */
private String distributeRejector; // ๋ฐฐํฌ์ทจ์์
/** The distribute rejected time. */
private String distributeRejectedTime; // ๋ฐฐํฌ์ทจ์์ผ์
/** The distribute deploy error msg. */
private String distributeDeployErrorMsg; // ์๋ฌ๋ฉ์ธ์ง
/** The distribute deploy model yn. */
private String distributeDeployModelYn = "N"; // ๋ชจ๋ธ๋ง ๋ฐฐํฌ์ ๋ฌด
/** The distribute osd key. */
private String distributeOsdKey; // descKey
/** The distribute last modified. */
private String distributeLastModified; // ๋ฐฐํฌ ์ต์ข
์์ ์๊ฐ
/** The distribute reserved user. */
private String distributeReservedUser; // ๋ฐฐํฌ ์์ฝ์
/** The distribute reserve flag. */
private String distributeReserveFlag; // ์ค์ผ์ค๋ฌ ์ฌ๋ถ
/** The save flag. */
private String saveFlag;
private String excelDownloadFlag = "N"; // project list excel downlaod ์ฒ๋ฆฌ ์ Y
// ์ฌ์ฉ์ comment๊ฐ ์ด์ค๋ฑ๋ก๋๋ ๊ฒฝ์ฐ "Y"์ผ๋ก ์ค์
private String ignoreUserCommentReg;
/* The ossReportFlag */
private String ossReportFlag;
private String ossNameMergeFlag;
private String depCsvFileFlag = "N";
private String srcCsvFileFlag = "N";
private String binCsvFileFlag = "N";
private String binBinaryFileFlag = "N";
private String srcAndroidCsvFileFlag = "N";
private String srcAndroidNoticeFileFlag = "N";
private String srcAndroidNoticeXmlFileFlag = "N";
private String srcAndroidResultFileFlag = "N";
private String identificationStatusConfFlag = "N";
private String verificationStatusConfFlag = "N";
private int permission;
private int statusPermission;
private String secCode;
private String vulDocInst;
private String vulDocInfo;
private Float standardScore;
private String copyWatcherLocation;
/** add watcher list. */
private ArrayList<Map<String, String>> changeWatcherList;
public String getIgnoreUserCommentReg() {
return ignoreUserCommentReg;
}
public void setIgnoreUserCommentReg(String ignoreUserCommentReg) {
this.ignoreUserCommentReg = ignoreUserCommentReg;
}
public String getExcelDownloadFlag() {
return excelDownloadFlag;
}
public void setExcelDownloadFlag(String excelDownloadFlag) {
this.excelDownloadFlag = excelDownloadFlag;
}
/** The license file name. */
private String licenseFileName; // ๋ผ์ด์ผ์ค ํ์ผ๋ช
/** The open source file name. */
private String openSourceFileName; // ์คํ์์ค ํ์ผ๋ช
/** The bin csv file id. */
private String depCsvFileId;
/** The src csv file id. */
// FILE_ID
private String srcCsvFileId;
/** The bin csv file id. */
private String binCsvFileId;
/** The bin binary file id. */
private String binBinaryFileId;
/** The src android csv file id. */
private String srcAndroidCsvFileId;
/** The src android notice file id. */
private String srcAndroidNoticeFileId;
/** The src android notice xml id. */
private String srcAndroidNoticeXmlId;
/** The src android result file id. */
private String srcAndroidResultFileId;
/** The notice file id. */
private String noticeFileId; // ๋ผ์ด์ผ์ค ํ์ผID
/** The review report file id. */
private String reviewReportFileId;
/** The package file id. */
private String packageFileId; // ์คํ์์ค ํ์ผID
private String packageFileId2; // ์คํ์์ค ํ์ผID
private String packageFileId3; // ์คํ์์ค ํ์ผID
private String packageVulDocFileId;
/** The notice file. */
private List<T2File> noticeFile; // ๋ผ์ด์ผ์ค ํ์ผ๊ฐ์ฒด
/** The review report file. */
private List<T2File> reviewReportFile;
/** The package file. */
private List<T2File> packageFile; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
private List<T2File> packageFile2; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
private List<T2File> packageFile3; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
/** The dep csv file. */
private List<T2File> depCsvFile; // csv ํ์ผ ๊ฐ์ฒด
/** The csv file. */
private List<T2File> csvFile; // csv ํ์ผ ๊ฐ์ฒด
/** The csv file seq. */
private List<T2File> csvFileSeq; // csv Add Seq ํ์ผ ๊ฐ์ฒด
/** The bin csv file. */
private List<T2File> binCsvFile; // csv ํ์ผ ๊ฐ์ฒด
/** The bin binary file. */
private List<T2File> binBinaryFile; // csv ํ์ผ ๊ฐ์ฒด
/** The android csv file. */
private List<T2File> androidCsvFile; // ์๋๋ก์ด๋ csv ํ์ผ ๊ฐ์ฒด
/** The android notice file. */
private List<T2File> androidNoticeFile; // ์๋๋ก์ด๋ notice ํ์ผ ๊ฐ์ฒด
/** The android result file. */
private List<T2File> androidResultFile; // ์๋๋ก์ด๋ Result ํ์ผ ๊ฐ์ฒด
/** The notice file info. */
private T2File noticeFileInfo; // ๋ผ์ด์ผ์ค ํ์ผ๊ฐ์ฒด
/** The package file info. */
private T2File packageFileInfo; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
private T2File packageFileInfo2; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
private T2File packageFileInfo3; // ์คํ์์ค ํ์ผ๊ฐ์ฒด
private T2File packageVulDocFileInfo;
/** The notice text file id. */
private String noticeTextFileId;
/** The simple html file id. */
private String simpleHtmlFileId;
/** The simple text file id. */
private String simpleTextFileId;
/** The spdx sheet file id. */
private String spdxSheetFileId;
/** The spdx rdf file id. */
private String spdxRdfFileId;
/** The spdx tag file id. */
private String spdxTagFileId;
/** The spdx json file id. */
private String spdxJsonFileId;
/** The spdx yaml file id. */
private String spdxYamlFileId;
/** The zip file id. */
private String zipFileId;
/** The oss id. */
// OSS ๊ฒ์์ฉ
private String ossId;
/** The oss name. */
private String ossName;
private String[] ossNickNames;
/** The oss version. */
private String ossVersion;
/** The license name. */
private String licenseName;
/** The status. */
private String status;
private String statuses;
private String[] arrStatuses;
/** The status org. */
private String statusOrg;
/** The ref partner id. */
private String refPartnerId;
/** The readme content. */
// README ํ์ผ ์ฉ
private String readmeContent;
/** The readme file name. */
private String readmeFileName;
/** The readme yn. */
private String readmeYn;
/** The verify file content. */
private String verifyFileContent;
/** The verify file count. */
private String verifyFileCount;
/** The except file content. */
private String exceptFileContent;
/** The sch start date. */
// OTHER
private String schStartDate;
/** The sch end date. */
private String schEndDate;
/** The prj model json. */
private String prjModelJson;
/** The prj delete model json. */
private String prjDeleteModelJson;
/** The division. */
private String division;
/** The vuln yn. */
private String vulnYn;
/** The cvss score. */
private String cvssScore;
/** The cve id. */
private String cveId;
/** The android sheet num. */
private String[] androidSheetNum;
/** The binary name. */
private String binaryName;
private String schBinaryName;
/** The partner name. */
private String partnerName;
/** The bin src flag. */
private String binSrcFlag;
/** The software name. */
private String softwareName;
/** The reference div. */
private String referenceDiv;
/** The comm ref div. */
private String commRefDiv;
/** The android flag. */
private String androidFlag;
/** The network server flag. */
private String networkServerFlag = "N";
/** The load from android project flag. */
private String loadFromAndroidProjectFlag = "N";
/** The creator nm. */
private String creatorNm;
/** The vulnerability. */
private String vulnerability;
/** The watcher str. */
private String watcherStr;
/** The upd vuln. */
private String updVuln;
/** The distribute check yn. */
private String distributeCheckYn;
/** The sent osdd del mail. */
private String sentOsddDelMail;
/** The sent osdd diff file mail. */
private String sentOsddDiffFileMail;
/** The need package file reset. */
private String needPackageFileReset;
/** The reviewer name. */
private String reviewerName;
/** The osdd notice file name. */
private String osddNoticeFileName;
/** The osdd notice file E-TAG. */
private String osddNoticeFileEtag;
/** The osdd source file name. */
private String osddSourceFileName;
/** The osdd source file name. */
private String osddSourceFileName2;
/** The osdd source file name. */
private String osddSourceFileName3;
/** The osdd source file E-TAG. */
private String osddSourceFileEtag;
/** The osdd source file E-TAG. */
private String osddSourceFileEtag2;
/** The osdd source file E-TAG. */
private String osddSourceFileEtag3;
private String stage;
private String prjDivisionId;
/** The publicYn. */
private String publicYn;
/** The viewOnlyFlag. */
private String viewOnlyFlag;
/** selfcheck ๋ฑ vulnerability ์ถ์ถ ๋์์ ์์๋ฒ์ ๋ชจํจ์ฌ๋ถ */
private String versionMatchedFlag = "N";
private String resetDistributionStatus = "N";
/* 2018-07-19 choye ์ถ๊ฐ */
/** The commId. */
private String commId;
/** The statusRequestYn. */
private String statusRequestYn;
/* 2018-07-27 choye ์ถ๊ฐ */
/** The delOsdd. */
private String delOsdd;
private String ossCount;
private String deleteMemo;
private String componentCount;
private String referenceId;
/** packaging file delete YN */
private String deleteFlag;
/** packaging verify checking flag */
private String statusVerifyYn;
private String userRole;
private String reuseKeyword;
private String ossAnalysisStatus;
private String analysisStartDate;
private String modelFlag;
private String changeStatusFlag;
private String ossNameTemp;
private String dependencies;
/** The cyclonedx file id. */
private String cdxJsonFileId;
private String cdxXmlFileId;
/**
* Gets the upd vuln.
*
* @return the upd vuln
*/
public String getUpdVuln() {
return updVuln;
}
/**
* Sets the upd vuln.
*
* @param updVuln the new upd vuln
*/
public void setUpdVuln(String updVuln) {
this.updVuln = updVuln;
}
/**
* Gets the watcher str.
*
* @return the watcher str
*/
public String getWatcherStr() {
return watcherStr;
}
/**
* Sets the watcher str.
*
* @param watcherStr the new watcher str
*/
public void setWatcherStr(String watcherStr) {
this.watcherStr = watcherStr;
}
/** Package verication ๋ฏธ์ํ์ฌ๋ถ. */
private String skipPackageFlag = "N";
/** The without verify yn. */
private String withoutVerifyYn;
/** binary DB ๋ฑ๋ก ๋ฌด์์ฒ๋ฆฌ */
private String ignoreBinaryDbFlag;
/** ์ฌ์ฉ์ ์์์ ์ฅ์ค์ธ comment. */
private String userComment;
/** list - prj(project), par(3rdparty), bat */
private String listKind;
/** listKind pair id */
private String listId;
private String BomCnt;
private String discloseCnt;
private String productGroup;
private List<String> productGroups;
private String targetName;
private String networkServerType;
private String priority;
private String reProcessDistributionFlag = "N";
private String changedNoticeYn = "N";
private String modelListAppendFlag = "N";
private String modelSeq;
private String deleteOsddFlag;
/**
* Gets the prj id.
*
* @return the prj id
*/
public String getPrjId() {
return prjId;
}
/**
* Sets the prj id.
*
* @param prjId the new prj id
*/
public void setPrjId(String prjId) {
this.prjId = prjId;
}
/**
* Gets the prj name.
*
* @return the prj name
*/
public String getPrjName() {
return prjName;
}
/**
* Sets the prj name.
*
* @param prjName the new prj name
*/
public void setPrjName(String prjName) {
this.prjName = prjName;
}
/**
* Gets the prj version.
*
* @return the prj version
*/
public String getPrjVersion() {
return prjVersion;
}
/**
* Sets the prj version.
*
* @param prjVersion the new prj version
*/
public void setPrjVersion(String prjVersion) {
this.prjVersion = prjVersion;
}
/**
* Gets the distribution type.
*
* @return the distribution type
*/
public String getDistributionType() {
return distributionType;
}
/**
* Sets the distribution type.
*
* @param distributionType the new distribution type
*/
public void setDistributionType(String distributionType) {
this.distributionType = distributionType;
if (!isEmpty(distributionType) && isEmpty(this.distributionTypeOfCodeDtlExp)) {
this.distributionTypeOfCodeDtlExp = CoCodeManager.getCodeExpString(CoConstDef.CD_DISTRIBUTION_TYPE, distributionType);
}
}
/**
* Gets the oss notice due date.
*
* @return the oss notice due date
*/
public String getOssNoticeDueDate() {
return ossNoticeDueDate;
}
/**
* Sets the oss notice due date.
*
* @param ossNoticeDueDate the new oss notice due date
*/
public void setOssNoticeDueDate(String ossNoticeDueDate) {
this.ossNoticeDueDate = ossNoticeDueDate;
}
/**
* Gets the comment.
*
* @return the comment
*/
public String getComment() {
return comment;
}
/**
* Sets the comment.
*
* @param comment the new comment
*/
public void setComment(String comment) {
this.comment = comment;
}
/**
* Gets the comment idx.
*
* @return the comment idx
*/
public String getCommentIdx() {
return commentIdx;
}
/**
* Sets the comment idx.
*
* @param commentIdx the new comment idx
*/
public void setCommentIdx(String commentIdx) {
this.commentIdx = commentIdx;
}
/**
* Gets the os type.
*
* @return the os type
*/
public String getOsType() {
return osType;
}
/**
* Sets the os type.
*
* @param osType the new os type
*/
public void setOsType(String osType) {
this.osType = osType;
}
/**
* Gets the os type etc.
*
* @return the os type etc
*/
public String getOsTypeEtc() {
return osTypeEtc;
}
/**
* Sets the os type etc.
*
* @param osTypeEtc the new os type etc
*/
public void setOsTypeEtc(String osTypeEtc) {
this.osTypeEtc = osTypeEtc;
}
/**
* Gets the identification status.
*
* @return the identification status
*/
public String getIdentificationStatus() {
return identificationStatus;
}
/**
* Sets the identification status.
*
* @param identificationStatus the new identification status
*/
public void setIdentificationStatus(String identificationStatus) {
this.identificationStatus = identificationStatus;
}
/**
* Gets the verification status.
*
* @return the verification status
*/
public String getVerificationStatus() {
return verificationStatus;
}
/**
* Sets the verification status.
*
* @param verificationStatus the new verification status
*/
public void setVerificationStatus(String verificationStatus) {
this.verificationStatus = verificationStatus;
}
/**
* Gets the destribution name.
*
* @return the destribution name
*/
public String getDestributionName() {
return destributionName;
}
/**
* Sets the destribution name.
*
* @param destributionName the new destribution name
*/
public void setDestributionName(String destributionName) {
this.destributionName = destributionName;
}
/**
* Gets the destribution software type.
*
* @return the destribution software type
*/
public String getDestributionSoftwareType() {
return destributionSoftwareType;
}
/**
* Sets the destribution software type.
*
* @param destributionSoftwareType the new destribution software type
*/
public void setDestributionSoftwareType(String destributionSoftwareType) {
this.destributionSoftwareType = destributionSoftwareType;
}
/**
* Gets the identification sub status partner.
*
* @return the identification sub status partner
*/
public String getIdentificationSubStatusPartner() {
return identificationSubStatusPartner;
}
/**
* Sets the identification sub status partner.
*
* @param identificationSubStatusPartner the new identification sub status partner
*/
public void setIdentificationSubStatusPartner(String identificationSubStatusPartner) {
this.identificationSubStatusPartner = identificationSubStatusPartner;
}
/**
* Gets the identification sub status src.
*
* @return the identification sub status src
*/
public String getIdentificationSubStatusSrc() {
return identificationSubStatusSrc;
}
/**
* Sets the identification sub status src.
*
* @param identificationSubStatusSrc the new identification sub status src
*/
public void setIdentificationSubStatusSrc(String identificationSubStatusSrc) {
this.identificationSubStatusSrc = identificationSubStatusSrc;
}
/**
* Gets the identification sub status bat.
*
* @return the identification sub status bat
*/
public String getIdentificationSubStatusBat() {
return identificationSubStatusBat;
}
/**
* Sets the identification sub status bat.
*
* @param identificationSubStatusBat the new identification sub status bat
*/
public void setIdentificationSubStatusBat(String identificationSubStatusBat) {
this.identificationSubStatusBat = identificationSubStatusBat;
}
/**
* Gets the complete yn.
*
* @return the complete yn
*/
public String getCompleteYn() {
return completeYn;
}
/**
* Sets the complete yn.
*
* @param completeYn the new complete yn
*/
public void setCompleteYn(String completeYn) {
this.completeYn = completeYn;
}
/**
* Gets the drop yn.
*
* @return the drop yn
*/
public String getDropYn() {
return dropYn;
}
/**
* Sets the drop yn.
*
* @param dropYn the new drop yn
*/
public void setDropYn(String dropYn) {
this.dropYn = dropYn;
}
public String getVerifyYn() {
return verifyYn;
}
public void setVerifyYn(String verifyYn) {
this.verifyYn = verifyYn;
}
/**
* Gets the reviewer.
*
* @return the reviewer
*/
public String getReviewer() {
return reviewer;
}
/**
* Sets the reviewer.
*
* @param reviewer the new reviewer
*/
public void setReviewer(String reviewer) {
this.reviewer = reviewer;
}
/**
* Gets the user use yn.
*
* @return the use yn
*/
public String getUseYn() {
return useYn;
}
/**
* Sets the user use yn.
*
* @param useYn the new use yn
*/
public void setUseYn(String useYn) {
this.useYn = useYn;
}
/**
* Gets the category.
*
* @return the category
*/
public String getCategory() {
return category;
}
/**
* Sets the category.
*
* @param category the new category
*/
public void setCategory(String category) {
this.category = category;
}
/**
* Gets the subcategory.
*
* @return the subcategory
*/
public String getSubcategory() {
return subcategory;
}
/**
* Sets the subcategory.
*
* @param subcategory the new subcategory
*/
public void setSubcategory(String subcategory) {
this.subcategory = subcategory;
}
/**
* Gets the model name.
*
* @return the model name
*/
public String getModelName() {
return modelName;
}
/**
* Sets the model name.
*
* @param modelName the new model name
*/
public void setModelName(String modelName) {
this.modelName = modelName;
}
/**
* Gets the release date.
*
* @return the release date
*/
public String getReleaseDate() {
return releaseDate;
}
/**
* Sets the release date.
*
* @param releaseDate the new release date
*/
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
/**
* Gets the model list info.
*
* @return the model list info
*/
public List<String> getModelListInfo() {
return modelListInfo;
}
/**
* Sets the model list info.
*
* @param modelListInfo the new model list info
*/
public void setModelListInfo(List<String> modelListInfo) {
this.modelListInfo = modelListInfo;
}
/**
* Gets the prj division.
*
* @return the prj division
*/
public String getPrjDivision() {
return prjDivision;
}
/**
* Sets the prj division.
*
* @param prjDivision the new prj division
*/
public void setPrjDivision(String prjDivision) {
this.prjDivision = prjDivision;
}
/**
* Gets the prj division name.
*
* @return the prj division name
*/
public String getPrjDivisionName() {
return prjDivisionName;
}
/**
* Sets the prj division name.
*
* @param prjDivisionName the new prj division name
*/
public void setPrjDivisionName(String prjDivisionName) {
this.prjDivisionName = prjDivisionName;
}
/**
* Gets the prj user id.
*
* @return the prj user id
*/
public String getPrjUserId() {
return prjUserId;
}
/**
* Sets the prj user id.
*
* @param prjUserId the new prj user id
*/
public void setPrjUserId(String prjUserId) {
this.prjUserId = prjUserId;
}
/**
* Gets the prj user name.
*
* @return the prj user name
*/
public String getPrjUserName() {
return prjUserName;
}
/**
* Sets the prj user name.
*
* @param prjUserName the new prj user name
*/
public void setPrjUserName(String prjUserName) {
this.prjUserName = prjUserName;
}
/**
* Gets the prj email.
*
* @return the prj email
*/
public String getPrjEmail() {
return prjEmail;
}
/**
* Sets the prj email.
*
* @param prjEmail the new prj email
*/
public void setPrjEmail(String prjEmail) {
this.prjEmail = prjEmail;
}
/**
* Gets the watchers.
*
* @return the watchers
*/
public String[] getWatchers() {
return watchers != null ? watchers.clone() : null;
}
/**
* Sets the watchers.
*
* @param watchers the new watchers
*/
public void setWatchers(String[] watchers) {
this.watchers = watchers != null ? watchers.clone() : null;
}
public void setWatchers(String watcher) {
if (!isEmpty(watcher)) {
this.watchers = new String[] {watcher};
} else {
this.watchers = null;
}
}
/**
* Gets the watcher list.
*
* @return the watcher list
*/
public List<Project> getWatcherList() {
return watcherList;
}
/**
* Sets the watcher list.
*
* @param watcherList the new watcher list
*/
public void setWatcherList(List<Project> watcherList) {
this.watcherList = watcherList;
}
/**
* Gets the division list.
*
* @return the division list
*/
public ArrayList<Map<String, String>> getDivisionList() {
return divisionList;
}
/**
* Sets the division list.
*
* @param divisionList the division list
*/
public void setDivisionList(ArrayList<Map<String, String>> divisionList) {
this.divisionList = divisionList;
}
/**
* Gets the email list.
*
* @return the email list
*/
public ArrayList<Map<String, String>> getEmailList() {
return emailList;
}
/**
* Sets the email list.
*
* @param emailList the email list
*/
public void setEmailList(ArrayList<Map<String, String>> emailList) {
this.emailList = emailList;
}
/**
* Gets the model list.
*
* @return the model list
*/
public List<Project> getModelList() {
return modelList;
}
/**
* Sets the model list.
*
* @param modelList the new model list
*/
public void setModelList(List<Project> modelList) {
this.modelList = modelList;
}
/**
* Gets the destribution status.
*
* @return the destribution status
*/
public String getDestributionStatus() {
return destributionStatus;
}
/**
* Sets the destribution status.
*
* @param destributionStatus the new destribution status
*/
public void setDestributionStatus(String destributionStatus) {
this.destributionStatus = destributionStatus;
}
public String getBeforeDistributionStatus() {
return beforeDistributionStatus;
}
public void setBeforeDistributionStatus(String beforeDistributionStatus) {
this.beforeDistributionStatus = beforeDistributionStatus;
}
/**
* Gets the license file name.
*
* @return the license file name
*/
public String getLicenseFileName() {
return licenseFileName;
}
/**
* Sets the license file name.
*
* @param licenseFileName the new license file name
*/
public void setLicenseFileName(String licenseFileName) {
this.licenseFileName = licenseFileName;
}
/**
* Gets the open source file name.
*
* @return the open source file name
*/
public String getOpenSourceFileName() {
return openSourceFileName;
}
/**
* Sets the open source file name.
*
* @param openSourceFileName the new open source file name
*/
public void setOpenSourceFileName(String openSourceFileName) {
this.openSourceFileName = openSourceFileName;
}
/**
* Gets the src csv file id.
*
* @return the src csv file id
*/
public String getSrcCsvFileId() {
return srcCsvFileId;
}
/**
* Sets the src csv file id.
*
* @param srcCsvFileId the new src csv file id
*/
public void setSrcCsvFileId(String srcCsvFileId) {
this.srcCsvFileId = srcCsvFileId;
}
/**
* Gets the src android csv file id.
*
* @return the src android csv file id
*/
public String getSrcAndroidCsvFileId() {
return srcAndroidCsvFileId;
}
/**
* Sets the src android csv file id.
*
* @param srcAndroidCsvFileId the new src android csv file id
*/
public void setSrcAndroidCsvFileId(String srcAndroidCsvFileId) {
this.srcAndroidCsvFileId = srcAndroidCsvFileId;
}
/**
* Gets the src android notice file id.
*
* @return the src android notice file id
*/
public String getSrcAndroidNoticeFileId() {
return srcAndroidNoticeFileId;
}
/**
* Sets the src android notice file id.
*
* @param srcAndroidNoticeFileId the new src android notice file id
*/
public void setSrcAndroidNoticeFileId(String srcAndroidNoticeFileId) {
this.srcAndroidNoticeFileId = srcAndroidNoticeFileId;
}
/**
* Gets the notice file id.
*
* @return the notice file id
*/
public String getNoticeFileId() {
return noticeFileId;
}
/**
* Sets the notice file id.
*
* @param noticeFileId the new notice file id
*/
public void setNoticeFileId(String noticeFileId) {
this.noticeFileId = noticeFileId;
}
/**
* Gets the review report file id.
*
* @return the review report file id
*/
public String getReviewReportFileId() {
return reviewReportFileId;
}
/**
* Sets the review report file id.
*
* @param reviewReportFileId the new review report file id
*/
public void setReviewReportFileId(String reviewReportFileId) {
this.reviewReportFileId = reviewReportFileId;
}
/**
* Gets the package file id.
*
* @return the package file id
*/
public String getPackageFileId() {
return packageFileId;
}
/**
* Sets the package file id.
*
* @param packageFileId the new package file id
*/
public void setPackageFileId(String packageFileId) {
this.packageFileId = packageFileId;
}
/**
* Gets the notice file.
*
* @return the notice file
*/
public List<T2File> getNoticeFile() {
return noticeFile;
}
/**
* Sets the notice file.
*
* @param noticeFile the new notice file
*/
public void setNoticeFile(List<T2File> noticeFile) {
this.noticeFile = noticeFile;
}
/**
* Get the review report file.
*
* @return the review report file
*/
public List<T2File> getReviewReportFile() {
return this.reviewReportFile;
}
/**
* Set the review report file.
*
* @param reviewReportFile the new review report file
*/
public void setReviewReportFile(List<T2File> reviewReportFile) {
this.reviewReportFile = reviewReportFile;
}
/**
* Gets the package file.
*
* @return the package file
*/
public List<T2File> getPackageFile() {
return packageFile;
}
/**
* Sets the package file.
*
* @param packageFile the new package file
*/
public void setPackageFile(List<T2File> packageFile) {
this.packageFile = packageFile;
}
/**
* Gets the csv file.
*
* @return the csv file
*/
public List<T2File> getCsvFile() {
return csvFile;
}
/**
* Sets the csv file.
*
* @param csvFile the new csv file
*/
public void setCsvFile(List<T2File> csvFile) {
this.csvFile = csvFile;
}
/**
* Gets the android csv file.
*
* @return the android csv file
*/
public List<T2File> getAndroidCsvFile() {
return androidCsvFile;
}
/**
* Sets the android csv file.
*
* @param androidCsvFile the new android csv file
*/
public void setAndroidCsvFile(List<T2File> androidCsvFile) {
this.androidCsvFile = androidCsvFile;
}
/**
* Gets the android notice file.
*
* @return the android notice file
*/
public List<T2File> getAndroidNoticeFile() {
return androidNoticeFile;
}
/**
* Sets the android notice file.
*
* @param androidNoticeFile the new android notice file
*/
public void setAndroidNoticeFile(List<T2File> androidNoticeFile) {
this.androidNoticeFile = androidNoticeFile;
}
/**
* Gets the oss id.
*
* @return the oss id
*/
public String getOssId() {
return ossId;
}
/**
* Sets the oss id.
*
* @param ossId the new oss id
*/
public void setOssId(String ossId) {
this.ossId = ossId;
}
/**
* Gets the oss name.
*
* @return the oss name
*/
public String getOssName() {
return ossName;
}
/**
* Sets the oss name.
*
* @param ossName the new oss name
*/
public void setOssName(String ossName) {
this.ossName = ossName;
}
/**
* Gets the oss version.
*
* @return the oss version
*/
public String getOssVersion() {
return ossVersion;
}
/**
* Sets the oss version.
*
* @param ossVersion the new oss version
*/
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
/**
* Gets the license name.
*
* @return the license name
*/
public String getLicenseName() {
return licenseName;
}
/**
* Sets the license name.
*
* @param licenseName the new license name
*/
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
/**
* Gets the status.
*
* @return the status
*/
public String getStatus() {
return status;
}
/**
* Sets the status.
*
* @param status the new status
*/
public void setStatus(String status) {
this.status = status;
}
/**
* Gets the status org.
*
* @return the status org
*/
public String getStatusOrg() {
return statusOrg;
}
/**
* Sets the status org.
*
* @param statusOrg the new status org
*/
public void setStatusOrg(String statusOrg) {
this.statusOrg = statusOrg;
}
/**
* Gets the prj model json.
*
* @return the prj model json
*/
public String getPrjModelJson() {
return prjModelJson;
}
/**
* Sets the prj model json.
*
* @param prjModelJson the new prj model json
*/
public void setPrjModelJson(String prjModelJson) {
this.prjModelJson = prjModelJson;
}
/**
* Gets the copy.
*
* @return the copy
*/
public String getCopy() {
return copy;
}
/**
* Sets the copy.
*
* @param copy the new copy
*/
public void setCopy(String copy) {
this.copy = copy;
}
/**
* Gets the old id.
*
* @return the old id
*/
public String getOldId() {
return oldId;
}
/**
* Sets the old id.
*
* @param oldId the new old id
*/
public void setOldId(String oldId) {
this.oldId = oldId;
}
/**
* Gets the division.
*
* @return the division
*/
public String getDivision() {
return division;
}
/**
* Sets the division.
*
* @param division the new division
*/
public void setDivision(String division) {
this.division = division;
}
/**
* Gets the vuln yn.
*
* @return the vuln yn
*/
public String getVulnYn() {
return vulnYn;
}
/**
* Sets the vuln yn.
*
* @param vulnYn the new vuln yn
*/
public void setVulnYn(String vulnYn) {
this.vulnYn = vulnYn;
}
/**
* Gets the serialversionuid.
*
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}
/**
* Gets the prj ids.
*
* @return the prj ids
*/
public String[] getPrjIds() {
return prjIds != null ? prjIds.clone() : null;
}
/**
* Sets the prj ids.
*
* @param prjIds the new prj ids
*/
public void setPrjIds(String[] prjIds) {
this.prjIds = prjIds != null ? prjIds.clone() : null;
}
/**
* Gets the ref partner id.
*
* @return the ref partner id
*/
public String getRefPartnerId() {
return refPartnerId;
}
/**
* Sets the ref partner id.
*
* @param refPartnerId the new ref partner id
*/
public void setRefPartnerId(String refPartnerId) {
this.refPartnerId = refPartnerId;
}
/**
* Gets the readme content.
*
* @return the readme content
*/
public String getReadmeContent() {
return readmeContent;
}
/**
* Sets the readme content.
*
* @param readmeContent the new readme content
*/
public void setReadmeContent(String readmeContent) {
this.readmeContent = readmeContent;
}
/**
* Gets the readme yn.
*
* @return the readme yn
*/
public String getReadmeYn() {
return readmeYn;
}
/**
* Sets the readme yn.
*
* @param readmeYn the new readme yn
*/
public void setReadmeYn(String readmeYn) {
this.readmeYn = readmeYn;
}
/**
* Gets the distribute master category.
*
* @return the distribute master category
*/
public String getDistributeMasterCategory() {
return distributeMasterCategory;
}
/**
* Sets the distribute master category.
*
* @param distributeMasterCategory the new distribute master category
*/
public void setDistributeMasterCategory(String distributeMasterCategory) {
this.distributeMasterCategory = distributeMasterCategory;
}
/**
* Gets the distribute name.
*
* @return the distribute name
*/
public String getDistributeName() {
return distributeName;
}
/**
* Sets the distribute name.
*
* @param distributeName the new distribute name
*/
public void setDistributeName(String distributeName) {
this.distributeName = distributeName;
}
public String getBeforeDistributeName() {
return beforeDistributeName;
}
public void setBeforeDistributeName(String beforeDistributeName) {
this.beforeDistributeName = beforeDistributeName;
}
/**
* Gets the distribute software type.
*
* @return the distribute software type
*/
public String getDistributeSoftwareType() {
return distributeSoftwareType;
}
/**
* Sets the distribute software type.
*
* @param distributeSoftwareType the new distribute software type
*/
public void setDistributeSoftwareType(String distributeSoftwareType) {
this.distributeSoftwareType = distributeSoftwareType;
}
public String getBeforeDistributeSoftwareType() {
return beforeDistributeSoftwareType;
}
public void setBeforeDistributeSoftwareType(String beforeDistributeSoftwareType) {
this.beforeDistributeSoftwareType = beforeDistributeSoftwareType;
}
/**
* Gets the distribute deploy yn.
*
* @return the distribute deploy yn
*/
public String getDistributeDeployYn() {
return distributeDeployYn;
}
/**
* Sets the distribute deploy yn.
*
* @param distributeDeployYn the new distribute deploy yn
*/
public void setDistributeDeployYn(String distributeDeployYn) {
this.distributeDeployYn = distributeDeployYn;
}
/**
* Gets the distribute deploy time.
*
* @return the distribute deploy time
*/
public String getDistributeDeployTime() {
return distributeDeployTime;
}
/**
* Sets the distribute deploy time.
*
* @param distributeDeployTime the new distribute deploy time
*/
public void setDistributeDeployTime(String distributeDeployTime) {
this.distributeDeployTime = distributeDeployTime;
}
/**
* Gets the distribute target.
*
* @return the distribute target
*/
public String getDistributeTarget() {
return distributeTarget;
}
/**
* Sets the distribute target.
*
* @param distributeTarget the new distribute target
*/
public void setDistributeTarget(String distributeTarget) {
this.distributeTarget = distributeTarget;
}
/**
* Gets the sch start date.
*
* @return the sch start date
*/
public String getSchStartDate() {
return schStartDate;
}
/**
* Sets the sch start date.
*
* @param schStartDate the new sch start date
*/
public void setSchStartDate(String schStartDate) {
this.schStartDate = schStartDate;
}
/**
* Gets the sch end date.
*
* @return the sch end date
*/
public String getSchEndDate() {
return schEndDate;
}
/**
* Sets the sch end date.
*
* @param schEndDate the new sch end date
*/
public void setSchEndDate(String schEndDate) {
this.schEndDate = schEndDate;
}
/**
* Gets the verify file content.
*
* @return the verify file content
*/
public String getVerifyFileContent() {
return verifyFileContent;
}
/**
* Sets the verify file content.
*
* @param verifyFileContent the new verify file content
*/
public void setVerifyFileContent(String verifyFileContent) {
this.verifyFileContent = verifyFileContent;
}
/**
* Gets the except file content.
*
* @return the except file content
*/
public String getExceptFileContent() {
return exceptFileContent;
}
/**
* Sets the except file content.
*
* @param exceptFileContent the new except file content
*/
public void setExceptFileContent(String exceptFileContent) {
this.exceptFileContent = exceptFileContent;
}
/**
* Etc str.
*
* @return the string
*/
public String etcStr() {
StringBuilder etc = new StringBuilder();
etc.append(modifiedDate + "|" + loginUserRole() + "|" + modifier);
if (!StringUtil.isEmpty(identificationStatus)) {
etc.append("|I:" + identificationStatus);
} else {
etc.append("|I:null");
}
if (!StringUtil.isEmpty(verificationStatus)) {
etc.append("|V:" + verificationStatus);
} else {
etc.append("|V:null");
}
if (!StringUtil.isEmpty(destributionStatus)) {
etc.append("|D:" + destributionStatus);
} else {
etc.append("|D:null");
}
return etc.toString();
}
/**
* Gets the last modified time.
*
* @return the last modified time
*/
public String getLastModifiedTime() {
return lastModifiedTime;
}
/**
* Sets the last modified time.
*
* @param lastModifiedTime the new last modified time
*/
public void setLastModifiedTime(String lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
}
/**
* Gets the cvss score.
*
* @return the cvss score
*/
public String getCvssScore() {
return cvssScore;
}
/**
* Sets the cvss score.
*
* @param cvssScore the new cvss score
*/
public void setCvssScore(String cvssScore) {
this.cvssScore = cvssScore;
}
/**
* Gets the distribute deploy error msg.
*
* @return the distribute deploy error msg
*/
public String getDistributeDeployErrorMsg() {
return distributeDeployErrorMsg;
}
/**
* Sets the distribute deploy error msg.
*
* @param distributeDeployErrorMsg the new distribute deploy error msg
*/
public void setDistributeDeployErrorMsg(String distributeDeployErrorMsg) {
this.distributeDeployErrorMsg = distributeDeployErrorMsg;
}
/**
* Gets the distribute deploy model yn.
*
* @return the distribute deploy model yn
*/
public String getDistributeDeployModelYn() {
return distributeDeployModelYn;
}
/**
* Sets the distribute deploy model yn.
*
* @param distributeDeployModelYn the new distribute deploy model yn
*/
public void setDistributeDeployModelYn(String distributeDeployModelYn) {
this.distributeDeployModelYn = distributeDeployModelYn;
}
/**
* Gets the distribute last modified.
*
* @return the distribute last modified
*/
public String getDistributeLastModified() {
return distributeLastModified;
}
/**
* Sets the distribute last modified.
*
* @param distributeLastModified the new distribute last modified
*/
public void setDistributeLastModified(String distributeLastModified) {
this.distributeLastModified = distributeLastModified;
}
/**
* Gets the distribute osd key.
*
* @return the distribute osd key
*/
public String getDistributeOsdKey() {
return distributeOsdKey;
}
/**
* Sets the distribute osd key.
*
* @param distributeOsdKey the new distribute osd key
*/
public void setDistributeOsdKey(String distributeOsdKey) {
this.distributeOsdKey = distributeOsdKey;
}
/**
* Gets the android sheet num.
*
* @return the android sheet num
*/
public String[] getAndroidSheetNum() {
return androidSheetNum != null ? androidSheetNum.clone() : null;
}
/**
* Sets the android sheet num.
*
* @param androidSheetNum the new android sheet num
*/
public void setAndroidSheetNum(String[] androidSheetNum) {
this.androidSheetNum = androidSheetNum != null ?
androidSheetNum.clone() : null;
}
/**
* Gets the code.
*
* @return the code
*/
public String getCode() {
return code;
}
/**
* Sets the code.
*
* @param code the new code
*/
public void setCode(String code) {
this.code = code;
}
/**
* Gets the verify file count.
*
* @return the verify file count
*/
public String getVerifyFileCount() {
return verifyFileCount;
}
/**
* Sets the verify file count.
*
* @param verifyFileCount the new verify file count
*/
public void setVerifyFileCount(String verifyFileCount) {
this.verifyFileCount = verifyFileCount;
}
/**
* Gets the notice file info.
*
* @return the notice file info
*/
public T2File getNoticeFileInfo() {
return noticeFileInfo;
}
/**
* Sets the notice file info.
*
* @param noticeFileInfo the new notice file info
*/
public void setNoticeFileInfo(T2File noticeFileInfo) {
this.noticeFileInfo = noticeFileInfo;
}
/**
* Gets the package file info.
*
* @return the package file info
*/
public T2File getPackageFileInfo() {
return packageFileInfo;
}
/**
* Sets the package file info.
*
* @param packageFileInfo the new package file info
*/
public void setPackageFileInfo(T2File packageFileInfo) {
this.packageFileInfo = packageFileInfo;
}
/**
* Gets the binary name.
*
* @return the binary name
*/
public String getBinaryName() {
return binaryName;
}
/**
* Sets the binary name.
*
* @param binaryName the new binary name
*/
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
/**
* Gets the partner name.
*
* @return the partner name
*/
public String getPartnerName() {
return partnerName;
}
/**
* Sets the partner name.
*
* @param partnerName the new partner name
*/
public void setPartnerName(String partnerName) {
this.partnerName = partnerName;
}
/**
* Gets the reference div.
*
* @return the reference div
*/
public String getReferenceDiv() {
return referenceDiv;
}
/**
* Sets the reference div.
*
* @param referenceDiv the new reference div
*/
public void setReferenceDiv(String referenceDiv) {
this.referenceDiv = referenceDiv;
}
/**
* Gets the save flag.
*
* @return the save flag
*/
public String getSaveFlag() {
return saveFlag;
}
/**
* Sets the save flag.
*
* @param saveFlag the new save flag
*/
public void setSaveFlag(String saveFlag) {
this.saveFlag = saveFlag;
}
/**
* Gets the src android result file id.
*
* @return the src android result file id
*/
public String getSrcAndroidResultFileId() {
return srcAndroidResultFileId;
}
/**
* Sets the src android result file id.
*
* @param srcAndroidResultFileId the new src android result file id
*/
public void setSrcAndroidResultFileId(String srcAndroidResultFileId) {
this.srcAndroidResultFileId = srcAndroidResultFileId;
}
/**
* Gets the android result file.
*
* @return the android result file
*/
public List<T2File> getAndroidResultFile() {
return androidResultFile;
}
/**
* Sets the android result file.
*
* @param androidResultFile the new android result file
*/
public void setAndroidResultFile(List<T2File> androidResultFile) {
this.androidResultFile = androidResultFile;
}
/**
* Gets the prj id list.
*
* @return the prj id list
*/
public List<String> getPrjIdList() {
return prjIdList;
}
/**
* Sets the prj id list.
*
* @param prjIdList the new prj id list
*/
public void setPrjIdList(List<String> prjIdList) {
this.prjIdList = prjIdList;
}
/**
* Adds the prj id list.
*
* @param prjId the prj id
*/
public void addPrjIdList(String prjId) {
if (this.prjIdList == null) {
this.prjIdList = new ArrayList<>();
}
this.prjIdList.add(prjId);
}
/**
* Gets the cve id.
*
* @return the cve id
*/
public String getCveId() {
return cveId;
}
/**
* Sets the cve id.
*
* @param cveId the new cve id
*/
public void setCveId(String cveId) {
this.cveId = cveId;
}
/**
* Gets the bin src flag.
*
* @return the bin src flag
*/
public String getBinSrcFlag() {
return binSrcFlag;
}
/**
* Sets the bin src flag.
*
* @param binSrcFlag the new bin src flag
*/
public void setBinSrcFlag(String binSrcFlag) {
this.binSrcFlag = binSrcFlag;
}
/**
* Gets the software name.
*
* @return the software name
*/
public String getSoftwareName() {
return softwareName;
}
/**
* Sets the software name.
*
* @param softwareName the new software name
*/
public void setSoftwareName(String softwareName) {
this.softwareName = softwareName;
}
/**
* Gets the copy prj id.
*
* @return the copy prj id
*/
public String getCopyPrjId() {
return copyPrjId;
}
/**
* Sets the copy prj id.
*
* @param copyPrjId the new copy prj id
*/
public void setCopyPrjId(String copyPrjId) {
this.copyPrjId = copyPrjId;
}
/**
* Gets the notice type.
*
* @return the notice type
*/
public String getNoticeType() {
return noticeType;
}
/**
* Sets the notice type.
*
* @param noticeType the new notice type
*/
public void setNoticeType(String noticeType) {
this.noticeType = noticeType;
}
public String getNoticeTypeEtc() {
return noticeTypeEtc;
}
public void setNoticeTypeEtc(String noticeTypeEtc) {
this.noticeTypeEtc = noticeTypeEtc;
}
/**
* Gets the user comment.
*
* @return the user comment
*/
public String getUserComment() {
return userComment;
}
/**
* Sets the user comment.
*
* @param userComment the new user comment
*/
public void setUserComment(String userComment) {
this.userComment = userComment;
}
/**
* Gets the identification sub status android.
*
* @return the identification sub status android
*/
public String getIdentificationSubStatusAndroid() {
return identificationSubStatusAndroid;
}
/**
* Sets the identification sub status android.
*
* @param identificationSubStatusAndroid the new identification sub status android
*/
public void setIdentificationSubStatusAndroid(String identificationSubStatusAndroid) {
this.identificationSubStatusAndroid = identificationSubStatusAndroid;
}
/**
* Gets the comm ref div.
*
* @return the comm ref div
*/
public String getCommRefDiv() {
return commRefDiv;
}
/**
* Sets the comm ref div.
*
* @param commRefDiv the new comm ref div
*/
public void setCommRefDiv(String commRefDiv) {
this.commRefDiv = commRefDiv;
}
/**
* Gets the bin csv file id.
*
* @return the bin csv file id
*/
public String getBinCsvFileId() {
return binCsvFileId;
}
/**
* Sets the bin csv file id.
*
* @param binCsvFileId the new bin csv file id
*/
public void setBinCsvFileId(String binCsvFileId) {
this.binCsvFileId = binCsvFileId;
}
/**
* Gets the bin csv file.
*
* @return the bin csv file
*/
public List<T2File> getBinCsvFile() {
return binCsvFile;
}
/**
* Sets the bin csv file.
*
* @param binCsvFile the new bin csv file
*/
public void setBinCsvFile(List<T2File> binCsvFile) {
this.binCsvFile = binCsvFile;
}
/**
* Gets the identification sub status bin.
*
* @return the identification sub status bin
*/
public String getIdentificationSubStatusBin() {
return identificationSubStatusBin;
}
/**
* Sets the identification sub status bin.
*
* @param identificationSubStatusBin the new identification sub status bin
*/
public void setIdentificationSubStatusBin(String identificationSubStatusBin) {
this.identificationSubStatusBin = identificationSubStatusBin;
}
/**
* Gets the android flag.
*
* @return the android flag
*/
public String getAndroidFlag() {
return androidFlag;
}
/**
* Sets the android flag.
*
* @param androidFlag the new android flag
*/
public void setAndroidFlag(String androidFlag) {
this.androidFlag = androidFlag;
}
/**
* Gets the distribute reserved user.
*
* @return the distribute reserved user
*/
public String getDistributeReservedUser() {
return distributeReservedUser;
}
/**
* Sets the distribute reserved user.
*
* @param distributeReservedUser the new distribute reserved user
*/
public void setDistributeReservedUser(String distributeReservedUser) {
this.distributeReservedUser = distributeReservedUser;
}
/**
* Gets the distribute reserve flag.
*
* @return the distribute reserve flag
*/
public String getDistributeReserveFlag() {
return distributeReserveFlag;
}
/**
* Sets the distribute reserve flag.
*
* @param distributeReserveFlag the new distribute reserve flag
*/
public void setDistributeReserveFlag(String distributeReserveFlag) {
this.distributeReserveFlag = distributeReserveFlag;
}
/**
* Gets the network server flag.
*
* @return the network server flag
*/
public String getNetworkServerFlag() {
return networkServerFlag;
}
/**
* Sets the network server flag.
*
* @param networkServerFlag the new network server flag
*/
public void setNetworkServerFlag(String networkServerFlag) {
this.networkServerFlag = networkServerFlag;
}
/**
* Gets the readme file name.
*
* @return the readme file name
*/
public String getReadmeFileName() {
return readmeFileName;
}
/**
* Sets the readme file name.
*
* @param readmeFileName the new readme file name
*/
public void setReadmeFileName(String readmeFileName) {
this.readmeFileName = readmeFileName;
}
/**
* Gets the csv add file seq.
*
* @return the csv add file seq
*/
public List<T2File> getCsvFileSeq() {
return csvFileSeq;
}
/**
* Sets the csv add file seq.
*
* @param csvFileSeq the new csv add file seq
*/
public void setCsvFileSeq(List<T2File> csvFileSeq) {
this.csvFileSeq = csvFileSeq;
}
/**
* Gets the skip package flag.
*
* @return the skip package flag
*/
public String getSkipPackageFlag() {
return skipPackageFlag;
}
/**
* Sets the skip package flag.
*
* @param skipPackageFlag the new skip package flag
*/
public void setSkipPackageFlag(String skipPackageFlag) {
this.skipPackageFlag = skipPackageFlag;
}
/**
* Gets the bin binary file id.
*
* @return the bin binary file id
*/
public String getBinBinaryFileId() {
return binBinaryFileId;
}
/**
* Sets the bin binary file id.
*
* @param binBinaryFileId the new bin binary file id
*/
public void setBinBinaryFileId(String binBinaryFileId) {
this.binBinaryFileId = binBinaryFileId;
}
/**
* Gets the bin binary file.
*
* @return the bin binary file
*/
public List<T2File> getBinBinaryFile() {
return binBinaryFile;
}
/**
* Sets the bin binary file.
*
* @param binBinaryFile the new bin binary file
*/
public void setBinBinaryFile(List<T2File> binBinaryFile) {
this.binBinaryFile = binBinaryFile;
}
/**
* Gets the load from android project flag.
*
* @return the load from android project flag
*/
public String getLoadFromAndroidProjectFlag() {
return loadFromAndroidProjectFlag;
}
/**
* Sets the load from android project flag.
*
* @param loadFromAndroidProjectFlag the new load from android project flag
*/
public void setLoadFromAndroidProjectFlag(String loadFromAndroidProjectFlag) {
this.loadFromAndroidProjectFlag = loadFromAndroidProjectFlag;
}
/**
* Gets the copy flag.
*
* @return the copy flag
*/
public String getCopyFlag() {
return copyFlag;
}
/**
* Sets the copy flag.
*
* @param copyFlag the new copy flag
*/
public void setCopyFlag(String copyFlag) {
this.copyFlag = copyFlag;
}
/**
* Gets the without verify yn.
*
* @return the without verify yn
*/
public String getWithoutVerifyYn() {
return withoutVerifyYn;
}
/**
* Sets the without verify yn.
*
* @param withoutVerifyYn the new without verify yn
*/
public void setWithoutVerifyYn(String withoutVerifyYn) {
this.withoutVerifyYn = withoutVerifyYn;
}
/**
* Gets the creator nm.
*
* @return the creator nm
*/
public String getCreatorNm() {
return creatorNm;
}
/**
* Sets the creator nm.
*
* @param creatorNm the new creator nm
*/
public void setCreatorNm(String creatorNm) {
this.creatorNm = creatorNm;
}
/**
* Gets the vulnerability.
*
* @return the vulnerability
*/
public String getVulnerability() {
return vulnerability;
}
/**
* Sets the vulnerability.
*
* @param vulnerability the new vulnerability
*/
public void setVulnerability(String vulnerability) {
this.vulnerability = vulnerability;
}
/**
* Gets the distribution type of code dtl exp.
*
* @return the distribution type of code dtl exp
*/
public String getDistributionTypeOfCodeDtlExp() {
return distributionTypeOfCodeDtlExp;
}
/**
* Sets the distribution type of code dtl exp.
*
* @param distributionTypeOfCodeDtlExp the new distribution type of code dtl exp
*/
public void setDistributionTypeOfCodeDtlExp(String distributionTypeOfCodeDtlExp) {
this.distributionTypeOfCodeDtlExp = distributionTypeOfCodeDtlExp;
}
/**
* Gets the watcher list info.
*
* @return the watcher list info
*/
public List<String> getWatcherListInfo() {
return watcherListInfo;
}
/**
* Sets the watcher list info.
*
* @param watcherListInfo the new watcher list info
*/
public void setWatcherListInfo(List<String> watcherListInfo) {
this.watcherListInfo = watcherListInfo;
}
/**
* Gets the identification sub status bom.
*
* @return the identificationSubStatusBom
*/
public String getIdentificationSubStatusBom() {
return identificationSubStatusBom;
}
/**
* Sets the identification sub status bom.
*
* @param identificationSubStatusBom the identificationSubStatusBom to set
*/
public void setIdentificationSubStatusBom(String identificationSubStatusBom) {
this.identificationSubStatusBom = identificationSubStatusBom;
}
/**
* Gets the model delete list.
*
* @return the model delete list
*/
public List<Project> getModelDeleteList() {
return modelDeleteList;
}
/**
* Sets the model delete list.
*
* @param modelDeleteList the new model delete list
*/
public void setModelDeleteList(List<Project> modelDeleteList) {
this.modelDeleteList = modelDeleteList;
}
/**
* Gets the prj delete model json.
*
* @return the prj delete model json
*/
public String getPrjDeleteModelJson() {
return prjDeleteModelJson;
}
/**
* Sets the prj delete model json.
*
* @param prjDeleteModelJson the new prj delete model json
*/
public void setPrjDeleteModelJson(String prjDeleteModelJson) {
this.prjDeleteModelJson = prjDeleteModelJson;
}
/**
* Gets the osdd sync yn.
*
* @return the osdd sync yn
*/
public String getOsddSyncYn() {
return osddSyncYn;
}
/**
* Sets the osdd sync yn.
*
* @param osddSyncYn the new osdd sync yn
*/
public void setOsddSyncYn(String osddSyncYn) {
this.osddSyncYn = osddSyncYn;
}
/**
* Gets the osdd sync time.
*
* @return the osdd sync time
*/
public String getOsddSyncTime() {
return osddSyncTime;
}
/**
* Sets the osdd sync time.
*
* @param osddSyncTime the new osdd sync time
*/
public void setOsddSyncTime(String osddSyncTime) {
this.osddSyncTime = osddSyncTime;
}
/**
* Gets the act type.
*
* @return the act type
*/
public String getActType() {
return actType;
}
/**
* Sets the act type.
*
* @param actType the new act type
*/
public void setActType(String actType) {
this.actType = actType;
}
/**
* Gets the act cont.
*
* @return the act cont
*/
public String getActCont() {
return actCont;
}
/**
* Sets the act cont.
*
* @param actCont the new act cont
*/
public void setActCont(String actCont) {
this.actCont = actCont;
}
/**
* Gets the category nm.
*
* @return the category nm
*/
public String getCategoryNm() {
return categoryNm;
}
/**
* Sets the category nm.
*
* @param categoryNm the new category nm
*/
public void setCategoryNm(String categoryNm) {
this.categoryNm = categoryNm;
}
/**
* Gets the distribute check yn.
*
* @return the distribute check yn
*/
public String getDistributeCheckYn() {
return distributeCheckYn;
}
/**
* Sets the distribute check yn.
*
* @param distributeCheckYn the new distribute check yn
*/
public void setDistributeCheckYn(String distributeCheckYn) {
this.distributeCheckYn = distributeCheckYn;
}
/**
* Gets the sent osdd del mail.
*
* @return the sent osdd del mail
*/
public String getSentOsddDelMail() {
return sentOsddDelMail;
}
/**
* Sets the sent osdd del mail.
*
* @param sentOsddDelMail the new sent osdd del mail
*/
public void setSentOsddDelMail(String sentOsddDelMail) {
this.sentOsddDelMail = sentOsddDelMail;
}
/**
* Gets the sent osdd diff file mail.
*
* @return the sent osdd diff file mail
*/
public String getSentOsddDiffFileMail() {
return sentOsddDiffFileMail;
}
/**
* Sets the sent osdd diff file mail.
*
* @param sentOsddDiffFileMail the new sent osdd diff file mail
*/
public void setSentOsddDiffFileMail(String sentOsddDiffFileMail) {
this.sentOsddDiffFileMail = sentOsddDiffFileMail;
}
/**
* Gets the need package file reset.
*
* @return the need package file reset
*/
public String getNeedPackageFileReset() {
return needPackageFileReset;
}
/**
* Sets the need package file reset.
*
* @param needPackageFileReset the new need package file reset
*/
public void setNeedPackageFileReset(String needPackageFileReset) {
this.needPackageFileReset = needPackageFileReset;
}
/**
* Gets the reviewer name.
*
* @return the reviewer name
*/
public String getReviewerName() {
return reviewerName;
}
/**
* Sets the reviewer name.
*
* @param reviewerName the new reviewer name
*/
public void setReviewerName(String reviewerName) {
this.reviewerName = reviewerName;
}
/**
* Gets the use custom notice yn.
*
* @return the use custom notice yn
*/
public String getUseCustomNoticeYn() {
return useCustomNoticeYn;
}
/**
* Sets the use custom notice yn.
*
* @param useCustomNoticeYn the new use custom notice yn
*/
public void setUseCustomNoticeYn(String useCustomNoticeYn) {
this.useCustomNoticeYn = useCustomNoticeYn;
}
/**
* Gets the allow download bit flag.
*
* @return the allow download bit flag
*/
public int getAllowDownloadBitFlag() {
return allowDownloadBitFlag;
}
/**
* Sets the allow download bit flag.
*
* @param allowDownloadBitFlag the new allow download bit flag
*/
public void setAllowDownloadBitFlag(int allowDownloadBitFlag) {
this.allowDownloadBitFlag = allowDownloadBitFlag;
}
/**
* Gets the allow download notice HTML yn.
*
* @return the allow download notice HTML yn
*/
public String getAllowDownloadNoticeHTMLYn() {
return allowDownloadNoticeHTMLYn;
}
/**
* Sets the allow download notice HTML yn.
*
* @param allowDownloadNoticeHTMLYn the new allow download notice HTML yn
*/
public void setAllowDownloadNoticeHTMLYn(String allowDownloadNoticeHTMLYn) {
this.allowDownloadNoticeHTMLYn = allowDownloadNoticeHTMLYn;
}
/**
* Gets the allow download notice text yn.
*
* @return the allow download notice text yn
*/
public String getAllowDownloadNoticeTextYn() {
return allowDownloadNoticeTextYn;
}
/**
* Sets the allow download notice text yn.
*
* @param allowDownloadNoticeTextYn the new allow download notice text yn
*/
public void setAllowDownloadNoticeTextYn(String allowDownloadNoticeTextYn) {
this.allowDownloadNoticeTextYn = allowDownloadNoticeTextYn;
}
/**
* Gets the allow download SPDX sheet yn.
*
* @return the allow download SPDX sheet yn
*/
public String getAllowDownloadSPDXSheetYn() {
return allowDownloadSPDXSheetYn;
}
/**
* Sets the allow download SPDX sheet yn.
*
* @param allowDownloadSPDXSheetYn the new allow download SPDX sheet yn
*/
public void setAllowDownloadSPDXSheetYn(String allowDownloadSPDXSheetYn) {
this.allowDownloadSPDXSheetYn = allowDownloadSPDXSheetYn;
}
/**
* Gets the allow download simple HTML yn.
*
* @return the allow download simple HTML yn
*/
public String getAllowDownloadSimpleHTMLYn() {
return allowDownloadSimpleHTMLYn;
}
/**
* Sets the allow download simple HTML yn.
*
* @param allowDownloadSimpleHTMLYn the new allow download simple HTML yn
*/
public void setAllowDownloadSimpleHTMLYn(String allowDownloadSimpleHTMLYn) {
this.allowDownloadSimpleHTMLYn = allowDownloadSimpleHTMLYn;
}
/**
* Gets the allow download simple text yn.
*
* @return the allow download simple text yn
*/
public String getAllowDownloadSimpleTextYn() {
return allowDownloadSimpleTextYn;
}
/**
* Sets the allow download simple text yn.
*
* @param allowDownloadSimpleTextYn the new allow download simple text yn
*/
public void setAllowDownloadSimpleTextYn(String allowDownloadSimpleTextYn) {
this.allowDownloadSimpleTextYn = allowDownloadSimpleTextYn;
}
/**
* Gets the allow download SPDX rdf yn.
*
* @return the allow download SPDX rdf yn
*/
public String getAllowDownloadSPDXRdfYn() {
return allowDownloadSPDXRdfYn;
}
/**
* Sets the allow download SPDX rdf yn.
*
* @param allowDownloadSPDXRdfYn the new allow download SPDX rdf yn
*/
public void setAllowDownloadSPDXRdfYn(String allowDownloadSPDXRdfYn) {
this.allowDownloadSPDXRdfYn = allowDownloadSPDXRdfYn;
}
/**
* Gets the allow download SPDX tag yn.
*
* @return the allow download SPDX tag yn
*/
public String getAllowDownloadSPDXTagYn() {
return allowDownloadSPDXTagYn;
}
/**
* Sets the allow download SPDX tag yn.
*
* @param allowDownloadSPDXTagYn the new allow download SPDX tag yn
*/
public void setAllowDownloadSPDXTagYn(String allowDownloadSPDXTagYn) {
this.allowDownloadSPDXTagYn = allowDownloadSPDXTagYn;
}
/**
* Gets the allow download SPDX json yn.
*
* @return the allow download SPDX json yn
*/
public String getAllowDownloadSPDXJsonYn() {
return allowDownloadSPDXJsonYn;
}
/**
* Sets the allow download SPDX json yn.
*
* @param allowDownloadSPDXJsonYn the new allow download SPDX json yn
*/
public void setAllowDownloadSPDXJsonYn(String allowDownloadSPDXJsonYn) {
this.allowDownloadSPDXJsonYn = allowDownloadSPDXJsonYn;
}
/**
* Gets the allow download SPDX yaml yn.
*
* @return the allow download SPDX yaml yn
*/
public String getAllowDownloadSPDXYamlYn() {
return allowDownloadSPDXYamlYn;
}
/**
* Sets the allow download SPDX yaml yn.
*
* @param allowDownloadSPDXYamlYn the new allow download SPDX yaml yn
*/
public void setAllowDownloadSPDXYamlYn(String allowDownloadSPDXYamlYn) {
this.allowDownloadSPDXYamlYn = allowDownloadSPDXYamlYn;
}
/**
* Gets the distribute deploy user.
*
* @return the distribute deploy user
*/
public String getDistributeDeployUser() {
return distributeDeployUser;
}
/**
* Sets the distribute deploy user.
*
* @param distributeDeployUser the new distribute deploy user
*/
public void setDistributeDeployUser(String distributeDeployUser) {
this.distributeDeployUser = distributeDeployUser;
}
public String getBeforeDistributeDeployUser() {
return beforeDistributeDeployUser;
}
public void setBeforeDistributeDeployUser(String beforeDistributeDeployUser) {
this.beforeDistributeDeployUser = beforeDistributeDeployUser;
}
/**
* Gets the distribute rejector.
*
* @return the distribute rejector
*/
public String getDistributeRejector() {
return distributeRejector;
}
/**
* Sets the distribute rejector.
*
* @param distributeRejector the new distribute rejector
*/
public void setDistributeRejector(String distributeRejector) {
this.distributeRejector = distributeRejector;
}
/**
* Gets the distribute rejected time.
*
* @return the distribute rejected time
*/
public String getDistributeRejectedTime() {
return distributeRejectedTime;
}
/**
* Sets the distribute rejected time.
*
* @param distributeRejectedTime the new distribute rejected time
*/
public void setDistributeRejectedTime(String distributeRejectedTime) {
this.distributeRejectedTime = distributeRejectedTime;
}
/**
* Gets the osdd notice file name.
*
* @return the osdd notice file name
*/
public String getOsddNoticeFileName() {
return osddNoticeFileName;
}
/**
* Sets the osdd notice file name.
*
* @param osddNoticeFileName the new osdd notice file name
*/
public void setOsddNoticeFileName(String osddNoticeFileName) {
this.osddNoticeFileName = osddNoticeFileName;
}
/**
* Gets the osdd notice file E-TAG.
*
* @return the osdd notice file E-TAG.
*/
public String getOsddNoticeFileEtag() {
return osddNoticeFileEtag;
}
/**
* Sets the osdd notice file E-TAG.
*
* @param osddNoticeFileName the new osdd notice file E-TAG.
*/
public void setOsddNoticeFileEtag(String osddNoticeFileEtag) {
this.osddNoticeFileEtag = osddNoticeFileEtag;
}
/**
* Gets the osdd source file name.
*
* @return the osdd source file name
*/
public String getOsddSourceFileName() {
return osddSourceFileName;
}
/**
* Sets the osdd source file name.
*
* @param osddSourceFileName the new osdd source file name
*/
public void setOsddSourceFileName(String osddSourceFileName) {
this.osddSourceFileName = osddSourceFileName;
}
public String getOsddSourceFileName2() {
return osddSourceFileName2;
}
public void setOsddSourceFileName2(String osddSourceFileName2) {
this.osddSourceFileName2 = osddSourceFileName2;
}
public String getOsddSourceFileName3() {
return osddSourceFileName3;
}
public void setOsddSourceFileName3(String osddSourceFileName3) {
this.osddSourceFileName3 = osddSourceFileName3;
}
public String getOsddSourceFileEtag() {
return osddSourceFileEtag;
}
public void setOsddSourceFileEtag(String osddSourceFileEtag) {
this.osddSourceFileEtag = osddSourceFileEtag;
}
public String getOsddSourceFileEtag2() {
return osddSourceFileEtag2;
}
public void setOsddSourceFileEtag2(String osddSourceFileEtag2) {
this.osddSourceFileEtag2 = osddSourceFileEtag2;
}
public String getOsddSourceFileEtag3() {
return osddSourceFileEtag3;
}
public void setOsddSourceFileEtag3(String osddSourceFileEtag3) {
this.osddSourceFileEtag3 = osddSourceFileEtag3;
}
/**
* Gets the notice text file id.
*
* @return the notice text file id
*/
public String getNoticeTextFileId() {
return noticeTextFileId;
}
/**
* Sets the notice text file id.
*
* @param noticeTextFileId the new notice text file id
*/
public void setNoticeTextFileId(String noticeTextFileId) {
this.noticeTextFileId = noticeTextFileId;
}
/**
* Gets the simple html file id.
*
* @return the simple html file id
*/
public String getSimpleHtmlFileId() {
return simpleHtmlFileId;
}
/**
* Sets the simple html file id.
*
* @param simpleHtmlFileId the new simple html file id
*/
public void setSimpleHtmlFileId(String simpleHtmlFileId) {
this.simpleHtmlFileId = simpleHtmlFileId;
}
/**
* Gets the simple text file id.
*
* @return the simple text file id
*/
public String getSimpleTextFileId() {
return simpleTextFileId;
}
/**
* Sets the simple text file id.
*
* @param simpleTextFileId the new simple text file id
*/
public void setSimpleTextFileId(String simpleTextFileId) {
this.simpleTextFileId = simpleTextFileId;
}
/**
* Gets the spdx sheet file id.
*
* @return the spdx sheet file id
*/
public String getSpdxSheetFileId() {
return spdxSheetFileId;
}
/**
* Sets the spdx sheet file id.
*
* @param spdxSheetFileId the new spdx sheet file id
*/
public void setSpdxSheetFileId(String spdxSheetFileId) {
this.spdxSheetFileId = spdxSheetFileId;
}
/**
* Gets the spdx rdf file id.
*
* @return the spdx rdf file id
*/
public String getSpdxRdfFileId() {
return spdxRdfFileId;
}
/**
* Sets the spdx rdf file id.
*
* @param spdxRdfFileId the new spdx rdf file id
*/
public void setSpdxRdfFileId(String spdxRdfFileId) {
this.spdxRdfFileId = spdxRdfFileId;
}
/**
* Gets the spdx tag file id.
*
* @return the spdx tag file id
*/
public String getSpdxTagFileId() {
return spdxTagFileId;
}
/**
* Sets the spdx tag file id.
*
* @param spdxTagFileId the new spdx tag file id
*/
public void setSpdxTagFileId(String spdxTagFileId) {
this.spdxTagFileId = spdxTagFileId;
}
/**
* Gets the spdx json file id.
*
* @return the spdx json file id
*/
public String getSpdxJsonFileId() {
return spdxJsonFileId;
}
/**
* Sets the spdx json file id.
*
* @param spdxJsonFileId the new spdx json file id
*/
public void setSpdxJsonFileId(String spdxJsonFileId) {
this.spdxJsonFileId = spdxJsonFileId;
}
/**
* Gets the spdx yaml file id.
*
* @return the spdx yaml file id
*/
public String getSpdxYamlFileId() {
return spdxYamlFileId;
}
/**
* Sets the spdx yaml file id.
*
* @param spdxYamlFileId the new spdx yaml file id
*/
public void setSpdxYamlFileId(String spdxYamlFileId) {
this.spdxYamlFileId = spdxYamlFileId;
}
/**
* Gets the zip file id.
*
* @return the zip file id
*/
public String getZipFileId() {
return zipFileId;
}
/**
* Sets the zip file id.
*
* @param zipFileId the new zip file id
*/
public void setZipFileId(String zipFileId) {
this.zipFileId = zipFileId;
}
public String getStage() {
return stage;
}
public void setStage(String stage) {
this.stage = stage;
}
public String getPrjDivisionId() {
return prjDivisionId;
}
public void setPrjDivisionId(String prjDivisionId) {
this.prjDivisionId = prjDivisionId;
}
public String[] getOssNickNames() {
return ossNickNames != null ? ossNickNames.clone() : null;
}
public void setOssNickNames(String[] ossNickNames) {
this.ossNickNames = ossNickNames != null ?
ossNickNames.clone() : null;
}
public String getStatuses() {
return statuses;
}
public void setStatuses(String statuses) {
this.statuses = statuses;
}
public String[] getArrStatuses() {
return arrStatuses != null ? arrStatuses.clone() : null;
}
public void setArrStatuses(String[] arrStatuses) {
this.arrStatuses = arrStatuses != null ?
arrStatuses.clone() : null;
}
public String getPublicYn() {
return publicYn;
}
public void setPublicYn(String publicYn) {
this.publicYn = publicYn;
}
public String getViewOnlyFlag() {
return viewOnlyFlag;
}
public void setViewOnlyFlag(String viewOnlyFlag) {
this.viewOnlyFlag = viewOnlyFlag;
}
public String getVersionMatchedFlag() {
return versionMatchedFlag;
}
public void setVersionMatchedFlag(String versionMatchedFlag) {
this.versionMatchedFlag = versionMatchedFlag;
}
public String getResetDistributionStatus() {
return resetDistributionStatus;
}
public void setResetDistributionStatus(String resetDistributionStatus) {
this.resetDistributionStatus = resetDistributionStatus;
}
/* 2018-07-19 choye ์ถ๊ฐ */
public String getCommId() {
return commId;
}
public void setCommId(String commId) {
this.commId = commId;
}
public String getStatusRequestYn() {
return statusRequestYn;
}
public void setStatusRequestYn(String statusRequestYn) {
this.statusRequestYn = statusRequestYn;
}
/* 2018-07-27 choye ์ถ๊ฐ */
public String getDelOsdd() {
return delOsdd;
}
public void setDelOsdd(String delOsdd) {
this.delOsdd = delOsdd;
}
public String getOssCount() {
return ossCount;
}
public void setOssCount(String ossCount) {
this.ossCount = ossCount;
}
public String getDeleteMemo() {
return deleteMemo;
}
public void setDeleteMemo(String deleteMemo) {
this.deleteMemo = deleteMemo;
}
public String getIgnoreBinaryDbFlag() {
return ignoreBinaryDbFlag;
}
public void setIgnoreBinaryDbFlag(String ignoreBinaryDbFlag) {
this.ignoreBinaryDbFlag = ignoreBinaryDbFlag;
}
public String getListKind() {
return listKind;
}
public void setListKind(String listKind) {
this.listKind = listKind;
}
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
public String getSchBinaryName() {
return schBinaryName;
}
public void setSchBinaryName(String schBinaryName) {
this.schBinaryName = schBinaryName;
}
public String getComponentCount() {
return componentCount;
}
public void setComponentCount(String componentCount) {
this.componentCount = componentCount;
}
public String getReferenceId() {
return referenceId;
}
public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}
public String getBomCnt() {
return BomCnt;
}
public void setBomCnt(String bomCnt) {
BomCnt = bomCnt;
}
public String getDiscloseCnt() {
return discloseCnt;
}
public void setDiscloseCnt(String discloseCnt) {
this.discloseCnt = discloseCnt;
}
public String getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(String deleteFlag) {
this.deleteFlag = deleteFlag;
}
public String getStatusVerifyYn() {
return statusVerifyYn;
}
public void setStatusVerifyYn(String statusVerifyYn) {
this.statusVerifyYn = statusVerifyYn;
}
public String getProductGroup() {
return productGroup;
}
public void setProductGroup(String productGroup) {
this.productGroup = productGroup;
}
public List<String> getProductGroups() {
return productGroups;
}
public void setProductGroups(List<String> productGroups) {
this.productGroups = productGroups;
}
public String getPackageFileId2() {
return packageFileId2;
}
public void setPackageFileId2(String packageFileId2) {
this.packageFileId2 = packageFileId2;
}
public String getPackageFileId3() {
return packageFileId3;
}
public void setPackageFileId3(String packageFileId3) {
this.packageFileId3 = packageFileId3;
}
public List<T2File> getPackageFile2() {
return packageFile2;
}
public void setPackageFile2(List<T2File> packageFile2) {
this.packageFile2 = packageFile2;
}
public List<T2File> getPackageFile3() {
return packageFile3;
}
public void setPackageFile3(List<T2File> packageFile3) {
this.packageFile3 = packageFile3;
}
public T2File getPackageFileInfo2() {
return packageFileInfo2;
}
public void setPackageFileInfo2(T2File packageFileInfo2) {
this.packageFileInfo2 = packageFileInfo2;
}
public T2File getPackageFileInfo3() {
return packageFileInfo3;
}
public void setPackageFileInfo3(T2File packageFileInfo3) {
this.packageFileInfo3 = packageFileInfo3;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public String getReuseKeyword() {
return reuseKeyword;
}
public void setReuseKeyword(String reuseKeyword) {
this.reuseKeyword = reuseKeyword;
}
public String getTargetName() {
return targetName;
}
public void setTargetName(String targetName) {
this.targetName = targetName;
}
public String getOssAnalysisStatus() {
return ossAnalysisStatus;
}
public void setOssAnalysisStatus(String ossAnalysisStatus) {
this.ossAnalysisStatus = ossAnalysisStatus;
}
public String getAnalysisStartDate() {
return analysisStartDate;
}
public void setAnalysisStartDate(String analysisStartDate) {
this.analysisStartDate = analysisStartDate;
}
public String getModelFlag() {
return modelFlag;
}
public void setModelFlag(String modelFlag) {
this.modelFlag = modelFlag;
}
public String getChangeStatusFlag() {
return changeStatusFlag;
}
public void setChangeStatusFlag(String changeStatusFlag) {
this.changeStatusFlag = changeStatusFlag;
}
public String getSrcAndroidNoticeXmlId() {
return srcAndroidNoticeXmlId;
}
public void setSrcAndroidNoticeXmlId(String srcAndroidNoticeXmlId) {
this.srcAndroidNoticeXmlId = srcAndroidNoticeXmlId;
}
public String getNetworkServerType() {
return networkServerType;
}
public void setNetworkServerType(String networkServerType) {
this.networkServerType = networkServerType;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
public String getReProcessDistributionFlag() {
return reProcessDistributionFlag;
}
public void setReProcessDistributionFlag(String reProcessDistributionFlag) {
this.reProcessDistributionFlag = reProcessDistributionFlag;
}
public String getChangedNoticeYn() {
return changedNoticeYn;
}
public void setChangedNoticeYn(String changedNoticeYn) {
this.changedNoticeYn = changedNoticeYn;
}
public String getOssReportFlag() {
return ossReportFlag;
}
public void setOssReportFlag(String ossReportFlag) {
this.ossReportFlag = ossReportFlag;
}
public String getModelListAppendFlag() {
return modelListAppendFlag;
}
public void setModelListAppendFlag(String modelListAppendFlag) {
this.modelListAppendFlag = modelListAppendFlag;
}
public String getModelSeq() {
return modelSeq;
}
public void setModelSeq(String modelSeq) {
this.modelSeq = modelSeq;
}
public String getOssNameMergeFlag() {
return ossNameMergeFlag;
}
public void setOssNameMergeFlag(String ossNameMergeFlag) {
this.ossNameMergeFlag = ossNameMergeFlag;
}
public String getSrcCsvFileFlag() {
return srcCsvFileFlag;
}
public void setSrcCsvFileFlag(String srcCsvFileFlag) {
this.srcCsvFileFlag = srcCsvFileFlag;
}
public String getBinCsvFileFlag() {
return binCsvFileFlag;
}
public void setBinCsvFileFlag(String binCsvFileFlag) {
this.binCsvFileFlag = binCsvFileFlag;
}
public String getBinBinaryFileFlag() {
return binBinaryFileFlag;
}
public void setBinBinaryFileFlag(String binBinaryFileFlag) {
this.binBinaryFileFlag = binBinaryFileFlag;
}
public String getSrcAndroidCsvFileFlag() {
return srcAndroidCsvFileFlag;
}
public void setSrcAndroidCsvFileFlag(String srcAndroidCsvFileFlag) {
this.srcAndroidCsvFileFlag = srcAndroidCsvFileFlag;
}
public String getSrcAndroidNoticeFileFlag() {
return srcAndroidNoticeFileFlag;
}
public void setSrcAndroidNoticeFileFlag(String srcAndroidNoticeFileFlag) {
this.srcAndroidNoticeFileFlag = srcAndroidNoticeFileFlag;
}
public String getSrcAndroidNoticeXmlFileFlag() {
return srcAndroidNoticeXmlFileFlag;
}
public void setSrcAndroidNoticeXmlFileFlag(String srcAndroidNoticeXmlFileFlag) {
this.srcAndroidNoticeXmlFileFlag = srcAndroidNoticeXmlFileFlag;
}
public String getSrcAndroidResultFileFlag() {
return srcAndroidResultFileFlag;
}
public void setSrcAndroidResultFileFlag(String srcAndroidResultFileFlag) {
this.srcAndroidResultFileFlag = srcAndroidResultFileFlag;
}
public String getIdentificationStatusConfFlag() {
return identificationStatusConfFlag;
}
public void setIdentificationStatusConfFlag(String identificationStatusConfFlag) {
this.identificationStatusConfFlag = identificationStatusConfFlag;
}
public String getVerificationStatusConfFlag() {
return verificationStatusConfFlag;
}
public void setVerificationStatusConfFlag(String verificationStatusConfFlag) {
this.verificationStatusConfFlag = verificationStatusConfFlag;
}
public int getPermission() {
return permission;
}
public void setPermission(int permission) {
this.permission = permission;
}
public int getStatusPermission() {
return statusPermission;
}
public void setStatusPermission(int statusPermission) {
this.statusPermission = statusPermission;
}
public String getOssNameTemp() {
return ossNameTemp;
}
public void setOssNameTemp(String ossNameTemp) {
this.ossNameTemp = ossNameTemp;
}
public String getDeleteOsddFlag() {
return deleteOsddFlag;
}
public void setDeleteOsddFlag(String deleteOsddFlag) {
this.deleteOsddFlag = deleteOsddFlag;
}
public String getSecCode() {
return secCode;
}
public void setSecCode(String secCode) {
this.secCode = secCode;
}
public String getDependencies() {
return dependencies;
}
public void setDependencies(String dependencies) {
this.dependencies = dependencies;
}
public String getIdentificationSubStatusDep() {
return identificationSubStatusDep;
}
public void setIdentificationSubStatusDep(String identificationSubStatusDep) {
this.identificationSubStatusDep = identificationSubStatusDep;
}
public String getDepCsvFileId() {
return depCsvFileId;
}
public void setDepCsvFileId(String depCsvFileId) {
this.depCsvFileId = depCsvFileId;
}
public List<T2File> getDepCsvFile() {
return depCsvFile;
}
public void setDepCsvFile(List<T2File> depCsvFile) {
this.depCsvFile = depCsvFile;
}
public String getDepCsvFileFlag() {
return depCsvFileFlag;
}
public void setDepCsvFileFlag(String depCsvFileFlag) {
this.depCsvFileFlag = depCsvFileFlag;
}
public String getAllowDownloadCDXJsonYn() {
return allowDownloadCDXJsonYn;
}
public void setAllowDownloadCDXJsonYn(String allowDownloadCDXJsonYn) {
this.allowDownloadCDXJsonYn = allowDownloadCDXJsonYn;
}
public String getAllowDownloadCDXXmlYn() {
return allowDownloadCDXXmlYn;
}
public void setAllowDownloadCDXXmlYn(String allowDownloadCDXXmlYn) {
this.allowDownloadCDXXmlYn = allowDownloadCDXXmlYn;
}
public String getCdxJsonFileId() {
return cdxJsonFileId;
}
public void setCdxJsonFileId(String cdxJsonFileId) {
this.cdxJsonFileId = cdxJsonFileId;
}
public String getCdxXmlFileId() {
return cdxXmlFileId;
}
public void setCdxXmlFileId(String cdxXmlFileId) {
this.cdxXmlFileId = cdxXmlFileId;
}
public String getVulDocInst() {
return vulDocInst;
}
public void setVulDocInst(String vulDocInst) {
this.vulDocInst = vulDocInst;
}
public String getPackageVulDocFileId() {
return packageVulDocFileId;
}
public void setPackageVulDocFileId(String packageVulDocFileId) {
this.packageVulDocFileId = packageVulDocFileId;
}
public String getVulDocInfo() {
return vulDocInfo;
}
public void setVulDocInfo(String vulDocInfo) {
this.vulDocInfo = vulDocInfo;
}
public T2File getPackageVulDocFileInfo() {
return packageVulDocFileInfo;
}
public void setPackageVulDocFileInfo(T2File packageVulDocFileInfo) {
this.packageVulDocFileInfo = packageVulDocFileInfo;
}
public Float getStandardScore() {
return standardScore;
}
public void setStandardScore(Float standardScore) {
this.standardScore = standardScore;
}
public String getCopyWatcherLocation() {
return copyWatcherLocation;
}
public void setCopyWatcherLocation(String copyWatcherLocation) {
this.copyWatcherLocation = copyWatcherLocation;
}
public ArrayList<Map<String, String>> getChangeWatcherList() {
return changeWatcherList;
}
public void setChangeWatcherList(ArrayList<Map<String, String>> changeWatcherList) {
this.changeWatcherList = changeWatcherList;
}
}
| 97,268 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
BinaryData.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/BinaryData.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
/**
* The Class BinaryData.
*/
@Getter @Setter
public class BinaryData extends ComBean implements Serializable {
private static final long serialVersionUID = 1L;
/** The id. */
private String id;
/** The bat id. */
private String batId;
/** The filename. */
private String fileName;
/** The pathname. */
private String pathName;
private String sourcePath;
/** The checksum. */
private String checkSum;
/** The tlshchecksum. */
private String tlshCheckSum;
/** The ossname. */
private String ossName;
/** The ossversion. */
private String ossVersion;
/** The license. */
private String license;
/** The parentname. */
private String parentName;
/** The platformname. */
private String platformName;
/** The platformversion. */
private String platformVersion;
/** The updatedate. */
private String updateDate;
/** The sch start date. */
private String schStartDate;
/** The sch end date. */
private String schEndDate;
private String downloadlocation;
private String equalFlag = "N";
private String comment;
private String parameter;
private String binaryPopupFlag = "N";
private String actionId;
private String actionType;
private int tlshDistance = -1;
}
| 1,441 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssAnalysis.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssAnalysis.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
@Setter @Getter
public class OssAnalysis extends ComBean implements Serializable {
private static final long serialVersionUID = 1L;
public OssAnalysis() {}
public OssAnalysis(String groupId, String ossName, String ossVersion, String ossNickname
, String licenseName, String ossCopyright, String downloadLocation
, String homepage, String summaryDescription, String comment, String result, String title) {
this.groupId = groupId;
this.ossName = ossName;
this.ossVersion = ossVersion;
this.ossNickname = ossNickname;
this.licenseName = licenseName;
this.ossCopyright = ossCopyright;
this.downloadLocation = downloadLocation;
this.homepage = homepage;
this.summaryDescription = summaryDescription;
this.comment = comment;
this.result = result;
this.title = title;
}
private String groupId;
private String componentId;
private String prjId;
private String title;
private String result;
private String ossName;
private String ossNickname;
private String ossVersion;
private String licenseName;
private String licenseDiv;
private String concludedLicense;
private String askalonoLicense;
private String scancodeLicense;
private String needReviewLicenseAskalono;
private String needReviewLicenseScanode;
private String detectedLicense;
private String downloadLocation;
private String downloadLocationGroup;
private String homepage;
private String ossCopyright;
private String summaryDescription;
private String comment;
private String analysisYn;
private String completeYn;
private String referenceOssId;
private String useYn;
private String ossType;
private String ossId;
}
| 1,903 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Notice.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/Notice.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
@Getter @Setter
public class Notice extends ComBean implements Serializable {
private static final long serialVersionUID = 3499915410560019672L;
private String seq;
private String title;
private String notice;
private String replaceNotice;
private String sDate;
private String eDate;
private String publishYn;
}
| 546 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2Code.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2Code.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.List;
public class T2Code extends ComBean implements Serializable {
private static final long serialVersionUID = -3911799499686061439L;
private String cdNo;
private String cdNm;
private String cdExp;
private String sysCdYn;
private List<T2CodeDtl> t2codeDtl;
private List<T2Code> newRowList;
private List<T2Code> modifyRowList;
private List<T2Code> deleteRowList;
// ์์ฑ์ ๊ธฐ๋ณธ
public T2Code() {}
// default setting cdNo ์์ฑ์
public T2Code(String cdNo) {
setCdNo(cdNo);
}
public String getCdNo() {
return cdNo;
}
public void setCdNo(String cdNo) {
this.cdNo = cdNo;
}
public String getCdNm() {
return cdNm;
}
public void setCdNm(String cdNm) {
this.cdNm = cdNm;
}
public String getCdExp() {
return cdExp;
}
public void setCdExp(String cdExp) {
this.cdExp = cdExp;
}
public String getSysCdYn() {
return sysCdYn;
}
public void setSysCdYn(String sysCdYn) {
this.sysCdYn = sysCdYn;
}
public List<T2CodeDtl> getT2codeDtl() {
return t2codeDtl;
}
public void setT2codeDtl(List<T2CodeDtl> t2codeDtl) {
this.t2codeDtl = t2codeDtl;
}
public List<T2Code> getNewRowList() {
return newRowList;
}
public void setNewRowList(List<T2Code> newRowList) {
this.newRowList = newRowList;
}
public List<T2Code> getModifyRowList() {
return modifyRowList;
}
public void setModifyRowList(List<T2Code> modifyRowList) {
this.modifyRowList = modifyRowList;
}
public List<T2Code> getDeleteRowList() {
return deleteRowList;
}
public void setDeleteRowList(List<T2Code> deleteRowList) {
this.deleteRowList = deleteRowList;
}
}
| 1,893 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
UploadFile.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/UploadFile.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
public class UploadFile extends ComBean implements Serializable{
private static final long serialVersionUID = 4663446686199447488L;
private String registSeq;
private String registFileId;
private String filePath;
private String fileName;
private String originalFilename;
private String inputName;
private int indexNum;
private long size;
private String contentType;
private boolean uploadSucc;
private int wgetResult;
private String fileExt;
public String getFileExt() {
return fileExt;
}
public void setFileExt(String fileExt) {
this.fileExt = fileExt;
}
public String getRegistSeq() {
return registSeq;
}
public void setRegistSeq(String registSeq) {
this.registSeq = registSeq;
}
public String getRegistFileId() {
return registFileId;
}
public void setRegistFileId(String registFileId) {
this.registFileId = registFileId;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getOriginalFilename() {
return originalFilename;
}
public void setOriginalFilename(String originalFilename) {
this.originalFilename = originalFilename;
}
public String getInputName() {
return inputName;
}
public void setInputName(String inputName) {
this.inputName = inputName;
}
public int getIndexNum() {
return indexNum;
}
public void setIndexNum(int indexNum) {
this.indexNum = indexNum;
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public boolean isUploadSucc() {
return uploadSucc;
}
public void setUploadSucc(boolean uploadSucc) {
this.uploadSucc = uploadSucc;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public int getWgetResult() {
return wgetResult;
}
public void setWgetResult(int wgetResult) {
this.wgetResult = wgetResult;
}
} | 2,339 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Configuration.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/Configuration.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* The Class Configuration.
*/
public class Configuration extends ComBean implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -4882283606058177605L;
/** The Default Tab. */
private String defaultTab;
/** The Default Locale. */
private String defaultLocale;
/** The default search type. */
private String defaultSearchType;
/**
* Gets the Default Tab.
*
* @return the Default Tab
*/
public String getDefaultTab() {
return defaultTab;
}
/**
* Sets the Default Tab.
*
* @param defaultTab the new default tab
*/
public void setDefaultTab(String defaultTab) {
this.defaultTab = defaultTab;
}
/**
* Gets the Default Locale.
*
* @return the Default Locale
*/
public String getDefaultLocale() {
return defaultLocale;
}
/**
* Sets the Default Locale.
*
* @param defaultLocale the new default locale
*/
public void setDefaultLocale(String defaultLocale) {
this.defaultLocale = defaultLocale;
}
/**
* Gets the default search type.
*
* @return the default search type
*/
public String getDefaultSearchType() {
return defaultSearchType;
}
/**
* Sets the default search type.
*
* @param defaultSearchType the new default search type
*/
public void setDefaultSearchType(String defaultSearchType) {
this.defaultSearchType = defaultSearchType;
}
}
| 1,636 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2SecuredResources.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2SecuredResources.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import oss.fosslight.common.CoConstDef;
@Setter
@Getter
public class T2SecuredResources implements Serializable{
private static final long serialVersionUID = 1L;
private String resourceId; // ๋ฆฌ์์ค ID
private String resourceName; // ๋ฆฌ์์ค ๋ช
private String resourcePattern; // ๋ฆฌ์์ค ํจํด
private String description; // ๋ฆฌ์์ค ์ค๋ช
private String resourceType; // ๋ฆฌ์์ค ํ์
('URL')
private Integer sortOrder; // ์์
private String createDate; // ๋ฑ๋ก์ผ
private String modifyDate; // ์์ ์ผ
private List<T2SecuredResourcesRole> securedResourcesRoles; // ๋ฆฌ์์ค์ ๋งตํ๋์ด ์๋ ์ญํ ๋ฆฌ์คํธ
public void setCreateDate() {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(CoConstDef.DATABASE_FORMAT_DATE_ALL);
this.createDate = sdf.format(now);
}
public void setModifyDate(){
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(CoConstDef.DATABASE_FORMAT_DATE_ALL);
this.modifyDate = sdf.format(now);
}
} | 1,339 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
LicenseHtmlGeneratorFromXml.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/LicenseHtmlGeneratorFromXml.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.common.CommonFunction;
@Slf4j
public class LicenseHtmlGeneratorFromXml extends ComBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static int convertXmlCnt = 0;
private static final String TAG = "LicenseHtmlGeneratorFromXml";
private static final String TAG_ROOT = "licenses";
private static final String TAG_FILE_NAME = "file-name";
private static final String TAG_FILE_CONTENT = "file-content";
private static final String ATTR_CONTENT_ID = "contentId";
private static final String HTML_HEAD_STRING =
"<html><head>\n" +
"<style type=\"text/css\">\n" +
"body { padding: 0; font-family: sans-serif; }\n" +
".same-license { background-color: #eeeeee;\n" +
" border-top: 20px solid white;\n" +
" padding: 10px; }\n" +
".label { font-weight: bold; }\n" +
".file-list { margin-left: 1em; color: blue; }\n" +
"</style>\n" +
"</head>" +
"<body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">\n" +
"<div class=\"toc\">\n" +
"<ul>";
private static final String HTML_MIDDLE_STRING =
"</ul>\n" +
"</div><!-- table of contents -->\n" +
"<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
private static final String HTML_REAR_STRING =
"</table></body></html>";
private final List<File> mXmlFiles;
/*
* A map from a file name to a content id (MD5 sum of file content) for its license.
* For example, "/system/priv-app/TeleService/TeleService.apk" maps to
* "9645f39e9db895a4aa6e02cb57294595". Here "9645f39e9db895a4aa6e02cb57294595" is a MD5 sum
* of the content of packages/services/Telephony/MODULE_LICENSE_APACHE2.
*/
private final Map<String, String> mFileNameToContentIdMap = new HashMap<String, String>();
/*
* A map from a content id (MD5 sum of file content) to a license file content.
* For example, "9645f39e9db895a4aa6e02cb57294595" maps to the content string of
* packages/services/Telephony/MODULE_LICENSE_APACHE2. Here "9645f39e9db895a4aa6e02cb57294595"
* is a MD5 sum of the file content.
*/
private final Map<String, String> mContentIdToFileContentMap = new HashMap<String, String>();
static class ContentIdAndFileNames {
final String mContentId;
final List<String> mFileNameList = new ArrayList<String>();
ContentIdAndFileNames(String contentId) {
mContentId = contentId;
}
}
private LicenseHtmlGeneratorFromXml(List<File> xmlFiles) {
mXmlFiles = xmlFiles;
}
public static boolean generateHtml(List<File> xmlFiles, File outputFile) {
LicenseHtmlGeneratorFromXml genertor = new LicenseHtmlGeneratorFromXml(xmlFiles);
return genertor.generateHtml(outputFile);
}
private boolean generateHtml(File outputFile) {
for (File xmlFile : mXmlFiles) {
parse(xmlFile);
}
if (mFileNameToContentIdMap.isEmpty() || mContentIdToFileContentMap.isEmpty()) {
return false;
}
PrintWriter writer = null;
try {
writer = new PrintWriter(outputFile);
generateHtml(mFileNameToContentIdMap, mContentIdToFileContentMap, writer);
writer.flush();
writer.close();
return true;
} catch (FileNotFoundException | SecurityException e) {
log.error(TAG, "Failed to generate " + outputFile, e);
if (writer != null) {
writer.close();
}
return false;
}
}
private void parse(File xmlFile) {
if (xmlFile == null || !xmlFile.exists() || xmlFile.length() == 0) {
return;
}
InputStreamReader in = null;
try {
if (xmlFile.getName().endsWith(".gz")) {
in = new InputStreamReader(new GZIPInputStream(new FileInputStream(xmlFile)));
} else {
in = new FileReader(xmlFile);
}
parse(in, mFileNameToContentIdMap, mContentIdToFileContentMap);
in.close();
} catch (XmlPullParserException | IOException e) {
log.error(TAG, "Failed to parse " + xmlFile, e);
if (in != null) {
try {
in.close();
} catch (IOException ie) {
log.error(TAG, "Failed to close " + xmlFile);
}
}
}
}
/*
* Parses an input stream and fills a map from a file name to a content id for its license
* and a map from a content id to a license file content.
*
* Following xml format is expected from the input stream.
*
* <licenses>
* <file-name contentId="content_id_of_license1">file1</file-name>
* <file-name contentId="content_id_of_license2">file2</file-name>
* ...
* <file-content contentId="content_id_of_license1">license1 file contents</file-content>
* <file-content contentId="content_id_of_license2">license2 file contents</file-content>
* ...
* </licenses>
*/
@VisibleForTesting
static void parse(InputStreamReader in, Map<String, String> outFileNameToContentIdMap,
Map<String, String> outContentIdToFileContentMap)
throws XmlPullParserException, IOException {
Map<String, String> fileNameToContentIdMap = new HashMap<String, String>();
Map<String, String> contentIdToFileContentMap = new HashMap<String, String>();
XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance();
xmlPullParserFactory.setNamespaceAware(true);
XmlPullParser parser = xmlPullParserFactory.newPullParser();
parser.setInput(in);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, "", TAG_ROOT);
int state = parser.getEventType();
while (state != XmlPullParser.END_DOCUMENT) {
if (state == XmlPullParser.START_TAG) {
if (TAG_FILE_NAME.equals(parser.getName())) {
String contentId = parser.getAttributeValue("", ATTR_CONTENT_ID);
if (!CommonFunction.isEmpty(contentId)) {
String fileName = readText(parser).trim();
if (!CommonFunction.isEmpty(fileName)) {
fileNameToContentIdMap.put(fileName, contentId);
}
}
} else if (TAG_FILE_CONTENT.equals(parser.getName())) {
String contentId = parser.getAttributeValue("", ATTR_CONTENT_ID);
if (!CommonFunction.isEmpty(contentId) &&
!outContentIdToFileContentMap.containsKey(contentId) &&
!contentIdToFileContentMap.containsKey(contentId)) {
String fileContent = readText(parser);
if (!CommonFunction.isEmpty(fileContent)) {
contentIdToFileContentMap.put(contentId, fileContent);
}
}
}
}
state = parser.next();
}
outFileNameToContentIdMap.putAll(fileNameToContentIdMap);
outContentIdToFileContentMap.putAll(contentIdToFileContentMap);
}
private static String readText(XmlPullParser parser)
throws IOException, XmlPullParserException {
StringBuffer result = new StringBuffer();
int state = parser.next();
while (state == XmlPullParser.TEXT) {
result.append(parser.getText());
state = parser.next();
}
return result.toString();
}
@VisibleForTesting
static void generateHtml(Map<String, String> fileNameToContentIdMap,
Map<String, String> contentIdToFileContentMap, PrintWriter writer) {
List<String> fileNameList = new ArrayList<>();
fileNameList.addAll(fileNameToContentIdMap.keySet());
Collections.sort(fileNameList);
writer.println(HTML_HEAD_STRING);
convertXmlCnt = 0;
Map<String, Integer> contentIdToOrderMap = new HashMap<>();
List<ContentIdAndFileNames> contentIdAndFileNamesList = new ArrayList<>();
// Prints all the file list with a link to its license file content.
for (String fileName : fileNameList) {
String contentId = fileNameToContentIdMap.get(fileName);
// Assigns an id to a newly referred license file content.
if (!contentIdToOrderMap.containsKey(contentId)) {
contentIdToOrderMap.put(contentId, convertXmlCnt);
// An index in contentIdAndFileNamesList is the order of each element.
contentIdAndFileNamesList.add(new ContentIdAndFileNames(contentId));
convertXmlCnt++;
}
int id = contentIdToOrderMap.get(contentId);
contentIdAndFileNamesList.get(id).mFileNameList.add(fileName);
writer.format("<li><a href=\"#id%d\">%s</a></li>\n", id, fileName);
}
writer.println(HTML_MIDDLE_STRING);
convertXmlCnt = 0;
// Prints all contents of the license files in order of id.
for (ContentIdAndFileNames contentIdAndFileNames : contentIdAndFileNamesList) {
writer.format("<tr id=\"id%d\"><td class=\"same-license\">\n", convertXmlCnt);
writer.println("<div class=\"label\">Notices for file(s):</div>");
writer.println("<div class=\"file-list\">");
for (String fileName : contentIdAndFileNames.mFileNameList) {
writer.format("%s <br/>\n", fileName);
}
writer.println("</div><!-- file-list -->");
writer.println("<pre class=\"license-text\">");
writer.println(contentIdToFileContentMap.get(
contentIdAndFileNames.mContentId));
writer.println("</pre><!-- license-text -->");
writer.println("</td></tr><!-- same-license -->");
convertXmlCnt++;
}
writer.println(HTML_REAR_STRING);
}}
| 11,391 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ProjectIdentification.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ProjectIdentification.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import oss.fosslight.common.CommonFunction;
public class ProjectIdentification extends ComBean implements Serializable, Comparable<ProjectIdentification>, Cloneable {
@Override
public String toString() {
return "ProjectIdentification [componentId=" + componentId + ", referenceId=" + referenceId + ", referenceDiv="
+ referenceDiv + ", ossId=" + ossId + ", ossName=" + ossName + ", ossVersion=" + ossVersion
+ ", downloadLocation=" + downloadLocation + ", homepage=" + homepage + ", mExcludeYn=" + mExcludeYn
+ ", filePath=" + filePath + ", binaryName=" + binaryName + ", binarySize=" + binarySize
+ ", binaryNotice=" + binaryNotice + ", refPartnerId=" + refPartnerId + ", reportFileId=" + reportFileId
+ ", excludeYn=" + excludeYn + ", mergePreDiv=" + mergePreDiv + ", componentLicenseId="
+ componentLicenseId + ", licenseId=" + licenseId + ", licenseName=" + licenseName + ", licenseText="
+ licenseText + ", copyrightText=" + copyrightText + ", sExcludeYn=" + sExcludeYn + ", mergeOrder="
+ mergeOrder + ", licenseDiv=" + licenseDiv + ", ossLicenseComb=" + ossLicenseComb + ", ossCopyright="
+ ossCopyright + ", grpCnt=" + grpCnt + ", merge=" + merge + ", groupingColumn=" + groupingColumn
+ ", androidNoticeFileId=" + androidNoticeFileId + ", androidResultFileId=" + androidResultFileId
+ ", loadFromAndroidProjectFlag=" + loadFromAndroidProjectFlag + ", refPrjId="+ refPrjId
+ ", obli=" + obli + "]";
}
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 2960062822605199127L;
/** The component id. */
// OSS_COMPONENTS
private String componentId;
/** The reference id. */
private String referenceId;
/** The reference div. */
private String referenceDiv;
/** The oss id. */
private String ossId;
/** The oss name. */
private String ossName;
/** The check name */
private String checkName;
/** The check license */
private String checkLicense;
/** The check license and name evidence */
private String checkedEvidence;
private String checkedEvidenceType;
/** The oss name exists yn. */
private String ossNameExistsYn;
/** The oss version. */
private String ossVersion;
/** The version diff flag. */
private String versionDiffFlag;
/** The download location. */
private String downloadLocation;
/** The homepage. */
private String homepage;
/** The m exclude yn. */
private String mExcludeYn;
/** The file path. */
private String filePath;
/** The binary name. */
private String binaryName;
/** The binary size. */
private String binarySize;
/** The binary notice. */
private String binaryNotice;
/** The custom binary yn. */
private String customBinaryYn;
/** The ref partner id. */
private String refPartnerId;
/** The ref partner id. */
private String refPartnerName;
/** The ref prj id. */
private String refPrjId;
/** The ref bat id. */
private String refBatId;
/** The report file id. */
private String reportFileId;
/** The exclude yn. */
private String excludeYn;
/** The merge pre div. */
private String mergePreDiv;
/** The prev obligation type. */
private String preObligationType;
/** The obligation type. */
private String obligationType;
/** The obligation license. */
private String obligationLicense;
/** The notify. */
private String notify;
/** The source. */
private String source;
/** The bat str plus. */
private String batStrPlus;
/** The bat string match percentage. */
private String batStringMatchPercentage;
/** The bat string match percentage float. */
private String batStringMatchPercentageFloat;
/** The bat percentage. */
private String batPercentage;
/** The bat score. */
private String batScore;
/** The bat checksum. */
private String batChecksum;
/** The ref component id. */
private String refComponentId;
/** The ref div. */
private String refDiv;
/** The component license id. */
// OSS_COMPONENTS_LICENSE
private String componentLicenseId;
/** The license id. */
private String licenseId;
/** The license name. */
private String licenseName;
/** The license name exists yn. */
private String licenseNameExistsYn;
private String licenseUserGuideYn;
private String licenseUserGuideStr;
/** The license text. */
private String licenseText;
/** The copyright text. */
private String copyrightText;
/** The s exclude yn. */
private String sExcludeYn;
/** The vuln yn. */
private String vulnYn;
/** The cvss score. */
private String cvssScore;
/** The cvss score. */
private String cvssScore2;
private String cvssScoreMax;
private String cvssScoreMax1;
private String cvssScoreMax2;
private String cvssScoreMax3;
private String cvssScoreMax4;
private String cvssScoreMax5;
/** The cve id. */
private String cveId;
/** The merge order. */
// OTHER
private String mergeOrder;
/** The role out license. */
private String roleOutLicense;
/** The role out license id list. */
private List<String> roleOutLicenseIdList;
/** The sort android flag. */
private String sortAndroidFlag;
/** The bom with android flag. */
private String bomWithAndroidFlag;
/** The license div. */
// OSS_MASTER
private String licenseDiv;
/** The oss license comb. */
// OSS_LICENSE
private String ossLicenseComb;
/** The oss copyright. */
private String ossCopyright;
/** The license type. */
private String licenseType;
/** The editable. */
private String editable;
/** The grp cnt. */
// OTHER
private String grpCnt;
/** The merge. */
private String merge;
/** The notice flag. */
private String noticeFlag;
/** The main data. */
private String mainData;
/** The sub data. */
private String subData;
/** The main data grid list. */
private List<ProjectIdentification> mainDataGridList;
/** The sub data grid list. */
private List<List<ProjectIdentification>> subDataGridList;
/** The grouping column. */
//Grouping
private String groupingColumn;
/** The obli. */
private String obli;
/** The save bom flag. */
private String saveBomFlag;
/** The component id list. */
private List<String> componentIdList;
/** The component license list. */
private List<ProjectIdentification> componentLicenseList;
/** The oss components license list. */
private List<OssComponentsLicense> ossComponentsLicenseList;
/** Bin(Android)์์ ๋ค๋ฅธ ํ๋ก์ ํธ์์ laodํ๋ ๊ฒฝ์ฐ. */
private String loadFromAndroidProjectFlag;
/** The android csv file id. */
private String androidCsvFileId;
/** The android notice file id. */
private String androidNoticeFileId;
/** The android result file id. */
private String androidResultFileId;
/** The download report flag. */
private String downloadReportFlag;
/** The component idx. */
private String componentIdx;
/** The ref component idx. */
private String refComponentIdx; /* 2018-07-17 choye ์ถ๊ฐ */
/** The rnum. */
public String rnum;
/** The vulnerability. */
private String vulnerability;
private String comments;
private String incCommentsFlag;
/**
* self check ๋ถ๋ช
ํํ oss๋๋ license์ ๋ํด์ obligation ํ์ ์ฌ๋ถ
*/
private String obligationGrayFlag;
private String obligationMsg;
/** The oss copyright. */
private String copyright;
/** The partnerId. */
private String partnerId;
/** The Restriction. */
private String restriction;
private String guireportFlag = "N";
private String typeFlag = "N";
private String bulkRegistYn = "N";
private String licenseTypeIdx;
private String adminCheckYn;
private String ossNickName;
private String attribution;
private String ossVersionEmptyFlag;
/** Check whether the Object is included in the oss list */
private String checkOssList = "N";
private String publDate;
private String patchLink;
private String dependencies;
private String refOssName;
public String getRedirectLocation() {
return redirectLocation;
}
public void setRedirectLocation(String redirectLocation) {
this.redirectLocation = redirectLocation;
}
private String redirectLocation;
public String getRecommendedNickname() {
return recommendedNickname;
}
public void setRecommendedNickname(String recommendedNickname) {
this.recommendedNickname = recommendedNickname;
}
private String recommendedNickname;
public String getGuireportFlag() {
return guireportFlag;
}
public void setGuireportFlag(String guireportFlag) {
this.guireportFlag = guireportFlag;
}
public String getObligationGrayFlag() {
return obligationGrayFlag;
}
public void setObligationGrayFlag(String obligationGrayFlag) {
this.obligationGrayFlag = obligationGrayFlag;
}
public String getObligationMsg() {
return obligationMsg;
}
public void setObligationMsg(String obligationMsg) {
this.obligationMsg = obligationMsg;
}
/**
* Gets the check oss list.
*
* @return the check oss list
*/
public String getCheckOssList(){
return checkOssList;
}
/**
* Sets the check oss list.
*
* @param checkOssList the new check oss list
*/
public void setCheckOssList(String checkOssList){
this.checkOssList = checkOssList;
}
/**
* Gets the component idx.
*
* @return the component idx
*/
public String getComponentIdx() {
return componentIdx;
}
/**
* Sets the component idx.
*
* @param componentIdx the new component idx
*/
public void setComponentIdx(String componentIdx) {
this.componentIdx = componentIdx;
}
/* 2018-07-17 choye ์ถ๊ฐ */
/**
* Gets the ref component idx.
*
* @return the ref component idx
*/
public String getRefComponentIdx() {
return refComponentIdx;
}
/**
* Sets the reg component idx.
*
* @param ref componentIdx the new ref component idx
*/
public void setRefComponentIdx(String refComponentIdx) {
this.refComponentIdx = refComponentIdx;
}
/**
* Gets the component id.
*
* @return the component id
*/
public String getComponentId() {
return componentId;
}
/**
* Sets the component id.
*
* @param componentId the new component id
*/
public void setComponentId(String componentId) {
this.componentId = componentId;
}
/**
* Gets the reference id.
*
* @return the reference id
*/
public String getReferenceId() {
return referenceId;
}
/**
* Sets the reference id.
*
* @param referenceId the new reference id
*/
public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}
/**
* Gets the reference div.
*
* @return the reference div
*/
public String getReferenceDiv() {
return referenceDiv;
}
/**
* Sets the reference div.
*
* @param referenceDiv the new reference div
*/
public void setReferenceDiv(String referenceDiv) {
this.referenceDiv = referenceDiv;
}
/**
* Gets the oss id.
*
* @return the oss id
*/
public String getOssId() {
return ossId;
}
/**
* Sets the oss id.
*
* @param ossId the new oss id
*/
public void setOssId(String ossId) {
this.ossId = ossId;
}
/**
* Gets the oss name.
*
* @return the oss name
*/
public String getOssName() {
return ossName;
}
/**
* Sets the oss name.
*
* @param ossName the new oss name
*/
public void setOssName(String ossName) {
this.ossName = ossName;
}
/**
* Gets the check name.
*
* @return the check name
*/
public String getCheckName() {
return checkName;
}
/**
* Sets the check name.
*
* @param checkName the new check name
*/
public void setCheckName(String checkName) {
this.checkName = checkName;
}
/**
* Gets the check license.
*
* @return the check license
*/
public String getCheckLicense() {
return checkLicense;
}
/**
* Sets the check license.
*
* @param checkLicense the new check license
*/
public void setCheckLicense(String checkLicense) {
this.checkLicense = checkLicense;
}
/**
* Gets the oss version.
*
* @return the oss version
*/
public String getOssVersion() {
return ossVersion;
}
/**
* Sets the oss version.
*
* @param ossVersion the new oss version
*/
public void setOssVersion(String ossVersion) {
this.ossVersion = ossVersion;
}
/**
* Gets the version diff flag.
*
* @return the version diff flag
*/
public String getVersionDiffFlag() {
return versionDiffFlag;
}
/**
* Sets the version diff flag.
*
* @param versionDiffFlag the new version diff flag
*/
public void setVersionDiffFlag(String versionDiffFlag) {
this.versionDiffFlag = versionDiffFlag;
}
/**
* Gets the download location.
*
* @return the download location
*/
public String getDownloadLocation() {
return CommonFunction.convertUrlLinkFormat(downloadLocation);
}
/**
* Sets the download location.
*
* @param downloadLocation the new download location
*/
public void setDownloadLocation(String downloadLocation) {
this.downloadLocation = downloadLocation;
}
/**
* Gets the homepage.
*
* @return the homepage
*/
public String getHomepage() {
return CommonFunction.convertUrlLinkFormat(homepage);
}
/**
* Sets the homepage.
*
* @param homepage the new homepage
*/
public void setHomepage(String homepage) {
this.homepage = homepage;
}
/**
* Gets the m exclude yn.
*
* @return the m exclude yn
*/
public String getmExcludeYn() {
return mExcludeYn;
}
/**
* Sets the m exclude yn.
*
* @param mExcludeYn the new m exclude yn
*/
public void setmExcludeYn(String mExcludeYn) {
this.mExcludeYn = mExcludeYn;
}
/**
* Gets the binary name.
*
* @return the binary name
*/
public String getBinaryName() {
return binaryName;
}
/**
* Sets the binary name.
*
* @param binaryName the new binary name
*/
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
/**
* Gets the binary size.
*
* @return the binary size
*/
public String getBinarySize() {
return binarySize;
}
/**
* Sets the binary size.
*
* @param binarySize the new binary size
*/
public void setBinarySize(String binarySize) {
this.binarySize = binarySize;
}
/**
* Gets the binary notice.
*
* @return the binary notice
*/
public String getBinaryNotice() {
return binaryNotice;
}
/**
* Sets the binary notice.
*
* @param binaryNotice the new binary notice
*/
public void setBinaryNotice(String binaryNotice) {
this.binaryNotice = binaryNotice;
}
/**
* Gets the component license id.
*
* @return the component license id
*/
public String getComponentLicenseId() {
return componentLicenseId;
}
/**
* Sets the component license id.
*
* @param componentLicenseId the new component license id
*/
public void setComponentLicenseId(String componentLicenseId) {
this.componentLicenseId = componentLicenseId;
}
/**
* Gets the license id.
*
* @return the license id
*/
public String getLicenseId() {
return licenseId;
}
/**
* Sets the license id.
*
* @param licenseId the new license id
*/
public void setLicenseId(String licenseId) {
this.licenseId = licenseId;
}
/**
* Gets the license name.
*
* @return the license name
*/
public String getLicenseName() {
return licenseName;
}
/**
* Sets the license name.
*
* @param licenseName the new license name
*/
public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}
/**
* Gets the license text.
*
* @return the license text
*/
public String getLicenseText() {
return licenseText;
}
/**
* Sets the license text.
*
* @param licenseText the new license text
*/
public void setLicenseText(String licenseText) {
this.licenseText = licenseText;
}
/**
* Gets the copyright text.
*
* @return the copyright text
*/
public String getCopyrightText() {
return copyrightText;
}
/**
* Sets the copyright text.
*
* @param copyrightText the new copyright text
*/
public void setCopyrightText(String copyrightText) {
this.copyrightText = copyrightText;
}
/**
* Gets the s exclude yn.
*
* @return the s exclude yn
*/
public String getsExcludeYn() {
return sExcludeYn;
}
/**
* Sets the s exclude yn.
*
* @param sExcludeYn the new s exclude yn
*/
public void setsExcludeYn(String sExcludeYn) {
this.sExcludeYn = sExcludeYn;
}
/**
* Gets the file path.
*
* @return the file path
*/
public String getFilePath() {
return filePath;
}
/**
* Sets the file path.
*
* @param filePath the new file path
*/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/**
* Gets the license div.
*
* @return the license div
*/
public String getLicenseDiv() {
return licenseDiv;
}
/**
* Sets the license div.
*
* @param licenseDiv the new license div
*/
public void setLicenseDiv(String licenseDiv) {
this.licenseDiv = licenseDiv;
}
/**
* Gets the oss license comb.
*
* @return the oss license comb
*/
public String getOssLicenseComb() {
return ossLicenseComb;
}
/**
* Sets the oss license comb.
*
* @param ossLicenseComb the new oss license comb
*/
public void setOssLicenseComb(String ossLicenseComb) {
this.ossLicenseComb = ossLicenseComb;
}
/**
* Gets the oss copyright.
*
* @return the oss copyright
*/
public String getOssCopyright() {
return ossCopyright;
}
/**
* Sets the oss copyright.
*
* @param ossCopyright the new oss copyright
*/
public void setOssCopyright(String ossCopyright) {
this.ossCopyright = ossCopyright;
}
/**
* Gets the grp cnt.
*
* @return the grp cnt
*/
public String getGrpCnt() {
return grpCnt;
}
/**
* Sets the grp cnt.
*
* @param grpCnt the new grp cnt
*/
public void setGrpCnt(String grpCnt) {
this.grpCnt = grpCnt;
}
/**
* Gets the serialversionuid.
*
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}
/**
* Gets the grouping column.
*
* @return the grouping column
*/
public String getGroupingColumn() {
return groupingColumn;
}
/**
* Sets the grouping column.
*
* @param groupingColumn the new grouping column
*/
public void setGroupingColumn(String groupingColumn) {
this.groupingColumn = groupingColumn;
}
/**
* Gets the merge.
*
* @return the merge
*/
public String getMerge() {
return merge;
}
/**
* Sets the merge.
*
* @param merge the new merge
*/
public void setMerge(String merge) {
this.merge = merge;
}
/**
* Gets the obli.
*
* @return the obli
*/
public String getObli() {
return obli;
}
/**
* Sets the obli.
*
* @param obli the new obli
*/
public void setObli(String obli) {
this.obli = obli;
}
/**
* Gets the ref partner id.
*
* @return the ref partner id
*/
public String getRefPartnerId() {
return refPartnerId;
}
/**
* Sets the ref partner id.
*
* @param refPartnerId the new ref partner id
*/
public void setRefPartnerId(String refPartnerId) {
this.refPartnerId = refPartnerId;
}
/**
* Gets the report file id.
*
* @return the report file id
*/
public String getReportFileId() {
return reportFileId;
}
/**
* Sets the report file id.
*
* @param reportFileId the new report file id
*/
public void setReportFileId(String reportFileId) {
this.reportFileId = reportFileId;
}
/**
* Gets the exclude yn.
*
* @return the exclude yn
*/
public String getExcludeYn() {
return excludeYn;
}
/**
* Sets the exclude yn.
*
* @param excludeYn the new exclude yn
*/
public void setExcludeYn(String excludeYn) {
this.excludeYn = excludeYn;
}
/**
* Gets the merge order.
*
* @return the merge order
*/
public String getMergeOrder() {
return mergeOrder;
}
/**
* Sets the merge order.
*
* @param mergeOrder the new merge order
*/
public void setMergeOrder(String mergeOrder) {
this.mergeOrder = mergeOrder;
}
/**
* Gets the merge pre div.
*
* @return the merge pre div
*/
public String getMergePreDiv() {
return mergePreDiv;
}
/**
* Sets the merge pre div.
*
* @param mergePreDiv the new merge pre div
*/
public void setMergePreDiv(String mergePreDiv) {
this.mergePreDiv = mergePreDiv;
}
/**
* Gets the vuln yn.
*
* @return the vuln yn
*/
public String getVulnYn() {
return vulnYn;
}
/**
* Sets the vuln yn.
*
* @param vulnYn the new vuln yn
*/
public void setVulnYn(String vulnYn) {
this.vulnYn = vulnYn;
}
/**
* Gets the license type.
*
* @return the license type
*/
public String getLicenseType() {
return licenseType;
}
/**
* Sets the license type.
*
* @param licenseType the new license type
*/
public void setLicenseType(String licenseType) {
this.licenseType = licenseType;
}
public String getPreObligationType() {
return preObligationType;
}
public void setPreObligationType(String preObligationType) {
this.preObligationType = preObligationType;
}
/**
* Gets the obligation type.
*
* @return the obligation type
*/
public String getObligationType() {
return obligationType;
}
/**
* Sets the obligation type.
*
* @param obligationType the new obligation type
*/
public void setObligationType(String obligationType) {
this.obligationType = obligationType;
}
/**
* Gets the obligation license.
*
* @return the obligation license
*/
public String getObligationLicense() {
return obligationLicense;
}
/**
* Sets the obligation license.
*
* @param obligationLicense the new obligation license
*/
public void setObligationLicense(String obligationLicense) {
this.obligationLicense = obligationLicense;
}
/**
* Gets the bat string match percentage.
*
* @return the bat string match percentage
*/
public String getBatStringMatchPercentage() {
return batStringMatchPercentage;
}
/**
* Sets the bat string match percentage.
*
* @param batStringMatchPercentage the new bat string match percentage
*/
public void setBatStringMatchPercentage(String batStringMatchPercentage) {
this.batStringMatchPercentage = batStringMatchPercentage;
}
public String getBatStringMatchPercentageFloat() {
return batStringMatchPercentageFloat;
}
public void setBatStringMatchPercentageFloat(String batStringMatchPercentageFloat) {
this.batStringMatchPercentageFloat = batStringMatchPercentageFloat;
}
/**
* Gets the bat percentage.
*
* @return the bat percentage
*/
public String getBatPercentage() {
return batPercentage;
}
/**
* Sets the bat percentage.
*
* @param batPercentage the new bat percentage
*/
public void setBatPercentage(String batPercentage) {
this.batPercentage = batPercentage;
}
/**
* Gets the bat score.
*
* @return the bat score
*/
public String getBatScore() {
return batScore;
}
/**
* Sets the bat score.
*
* @param batScore the new bat score
*/
public void setBatScore(String batScore) {
this.batScore = batScore;
}
/**
* Gets the bat str plus.
*
* @return the bat str plus
*/
public String getBatStrPlus() {
return batStrPlus;
}
/**
* Sets the bat str plus.
*
* @param batStrPlus the new bat str plus
*/
public void setBatStrPlus(String batStrPlus) {
this.batStrPlus = batStrPlus;
}
/**
* Gets the cvss score.
*
* @return the cvss score
*/
public String getCvssScore() {
return cvssScore;
}
/**
* Sets the cvss score.
*
* @param cvssScore the new cvss score
*/
public void setCvssScore(String cvssScore) {
this.cvssScore = cvssScore;
}
/**
* Gets the role out license.
*
* @return the role out license
*/
public String getRoleOutLicense() {
return roleOutLicense;
}
/**
* Sets the role out license.
*
* @param roleOutLicense the new role out license
*/
public void setRoleOutLicense(String roleOutLicense) {
this.roleOutLicense = roleOutLicense;
}
/**
* Gets the ref component id.
*
* @return the ref component id
*/
public String getRefComponentId() {
return refComponentId;
}
/**
* Sets the ref component id.
*
* @param refComponentId the new ref component id
*/
public void setRefComponentId(String refComponentId) {
this.refComponentId = refComponentId;
}
/**
* Gets the ref div.
*
* @return the ref div
*/
public String getRefDiv() {
return refDiv;
}
/**
* Sets the ref div.
*
* @param refDiv the new ref div
*/
public void setRefDiv(String refDiv) {
this.refDiv = refDiv;
}
/**
* Gets the component id list.
*
* @return the component id list
*/
public List<String> getComponentIdList() {
return componentIdList;
}
/**
* Sets the component id list.
*
* @param componentIdList the new component id list
*/
public void setComponentIdList(List<String> componentIdList) {
this.componentIdList = componentIdList;
}
/**
* Adds the component id list.
*
* @param s the s
*/
public void addComponentIdList(String s) {
if (this.componentIdList == null) {
this.componentIdList = new ArrayList<>();
}
this.componentIdList.add(s);
}
/**
* Gets the component license list.
*
* @return the component license list
*/
public List<ProjectIdentification> getComponentLicenseList() {
return componentLicenseList;
}
/**
* Sets the component license list.
*
* @param componentLicenseList the new component license list
*/
public void setComponentLicenseList(List<ProjectIdentification> componentLicenseList) {
this.componentLicenseList = componentLicenseList;
}
/**
* Adds the component license list.
*
* @param license the license
*/
public void addComponentLicenseList(ProjectIdentification license) {
if (this.componentLicenseList == null) {
this.componentLicenseList = new ArrayList<>();
}
this.componentLicenseList.add(license);
}
/**
* Gets the oss components license list.
*
* @return the oss components license list
*/
public List<OssComponentsLicense> getOssComponentsLicenseList() {
return ossComponentsLicenseList;
}
/**
* Sets the oss components license list.
*
* @param ossComponentsLicenseList the new oss components license list
*/
public void setOssComponentsLicenseList(List<OssComponentsLicense> ossComponentsLicenseList) {
this.ossComponentsLicenseList = ossComponentsLicenseList;
}
/**
* Adds the oss components license.
*
* @param bean the bean
*/
public void addOssComponentsLicense(OssComponentsLicense bean) {
if (this.ossComponentsLicenseList == null) {
this.ossComponentsLicenseList = new ArrayList<>();
}
this.ossComponentsLicenseList.add(bean);
}
/**
* Gets the source.
*
* @return the source
*/
public String getSource() {
return source;
}
/**
* Sets the source.
*
* @param source the new source
*/
public void setSource(String source) {
this.source = source;
}
/**
* Gets the notify.
*
* @return the notify
*/
public String getNotify() {
return notify;
}
/**
* Sets the notify.
*
* @param notify the new notify
*/
public void setNotify(String notify) {
this.notify = notify;
}
/**
* Gets the ref prj id.
*
* @return the ref prj id
*/
public String getRefPrjId() {
return refPrjId;
}
/**
* Sets the ref prj id.
*
* @param refPrjId the new ref prj id
*/
public void setRefPrjId(String refPrjId) {
this.refPrjId = refPrjId;
}
/**
* Gets the ref bat id.
*
* @return the ref bat id
*/
public String getRefBatId() {
return refBatId;
}
/**
* Sets the ref bat id.
*
* @param refBatId the new ref bat id
*/
public void setRefBatId(String refBatId) {
this.refBatId = refBatId;
}
/**
* Gets the editable.
*
* @return the editable
*/
public String getEditable() {
return editable;
}
/**
* Sets the editable.
*
* @param editable the new editable
*/
public void setEditable(String editable) {
this.editable = editable;
}
/**
* Gets the bat checksum.
*
* @return the bat checksum
*/
public String getBatChecksum() {
return batChecksum;
}
/**
* Sets the bat checksum.
*
* @param batChecksum the new bat checksum
*/
public void setBatChecksum(String batChecksum) {
this.batChecksum = batChecksum;
}
/**
* Gets the cve id.
*
* @return the cve id
*/
public String getCveId() {
return cveId;
}
/**
* Sets the cve id.
*
* @param cveId the new cve id
*/
public void setCveId(String cveId) {
this.cveId = cveId;
}
/**
* Gets the rnum.
*
* @return the rnum
*/
public String getRnum() {
return rnum;
}
/**
* Sets the rnum.
*
* @param rnum the new rnum
*/
public void setRnum(String rnum) {
this.rnum = rnum;
}
/**
* Gets the main data.
*
* @return the main data
*/
public String getMainData() {
return mainData;
}
/**
* Sets the main data.
*
* @param mainData the new main data
*/
public void setMainData(String mainData) {
this.mainData = mainData;
}
/**
* Gets the sub data.
*
* @return the sub data
*/
public String getSubData() {
return subData;
}
/**
* Sets the sub data.
*
* @param subData the new sub data
*/
public void setSubData(String subData) {
this.subData = subData;
}
/**
* Gets the main data grid list.
*
* @return the main data grid list
*/
public List<ProjectIdentification> getMainDataGridList() {
return mainDataGridList;
}
/**
* Sets the main data grid list.
*
* @param mainDataGridList the new main data grid list
*/
public void setMainDataGridList(List<ProjectIdentification> mainDataGridList) {
this.mainDataGridList = mainDataGridList;
}
/**
* Gets the sub data grid list.
*
* @return the sub data grid list
*/
public List<List<ProjectIdentification>> getSubDataGridList() {
return subDataGridList;
}
/**
* Sets the sub data grid list.
*
* @param subDataGridList the new sub data grid list
*/
public void setSubDataGridList(List<List<ProjectIdentification>> subDataGridList) {
this.subDataGridList = subDataGridList;
}
/**
* Gets the sort android flag.
*
* @return the sort android flag
*/
public String getSortAndroidFlag() {
return sortAndroidFlag;
}
/**
* Sets the sort android flag.
*
* @param sortAndroidFlag the new sort android flag
*/
public void setSortAndroidFlag(String sortAndroidFlag) {
this.sortAndroidFlag = sortAndroidFlag;
}
/**
* Gets the custom binary yn.
*
* @return the custom binary yn
*/
public String getCustomBinaryYn() {
return customBinaryYn;
}
/**
* Sets the custom binary yn.
*
* @param customBinaryYn the new custom binary yn
*/
public void setCustomBinaryYn(String customBinaryYn) {
this.customBinaryYn = customBinaryYn;
}
/**
* Gets the save bom flag.
*
* @return the save bom flag
*/
public String getSaveBomFlag() {
return saveBomFlag;
}
/**
* Sets the save bom flag.
*
* @param saveBomFlag the new save bom flag
*/
public void setSaveBomFlag(String saveBomFlag) {
this.saveBomFlag = saveBomFlag;
}
/**
* Gets the download report flag.
*
* @return the download report flag
*/
public String getDownloadReportFlag() {
return downloadReportFlag;
}
/**
* Sets the download report flag.
*
* @param downloadReportFlag the new download report flag
*/
public void setDownloadReportFlag(String downloadReportFlag) {
this.downloadReportFlag = downloadReportFlag;
}
/**
* Gets the bom with android flag.
*
* @return the bom with android flag
*/
public String getBomWithAndroidFlag() {
return bomWithAndroidFlag;
}
/**
* Sets the bom with android flag.
*
* @param bomWithAndroidFlag the new bom with android flag
*/
public void setBomWithAndroidFlag(String bomWithAndroidFlag) {
this.bomWithAndroidFlag = bomWithAndroidFlag;
}
/**
* Gets the load from android project flag.
*
* @return the load from android project flag
*/
public String getLoadFromAndroidProjectFlag() {
return loadFromAndroidProjectFlag;
}
/**
* Sets the load from android project flag.
*
* @param loadFromAndroidProjectFlag the new load from android project flag
*/
public void setLoadFromAndroidProjectFlag(String loadFromAndroidProjectFlag) {
this.loadFromAndroidProjectFlag = loadFromAndroidProjectFlag;
}
/**
* Gets the android csv file id.
*
* @return the android csv file id
*/
public String getAndroidCsvFileId() {
return androidCsvFileId;
}
/**
* Sets the android csv file id.
*
* @param androidCsvFileId the new android csv file id
*/
public void setAndroidCsvFileId(String androidCsvFileId) {
this.androidCsvFileId = androidCsvFileId;
}
/**
* Gets the android notice file id.
*
* @return the android notice file id
*/
public String getAndroidNoticeFileId() {
return androidNoticeFileId;
}
/**
* Sets the android notice file id.
*
* @param androidNoticeFileId the new android notice file id
*/
public void setAndroidNoticeFileId(String androidNoticeFileId) {
this.androidNoticeFileId = androidNoticeFileId;
}
/**
* Gets the android result file id.
*
* @return the android result file id
*/
public String getAndroidResultFileId() {
return androidResultFileId;
}
/**
* Sets the android result file id.
*
* @param androidResultFileId the new android result file id
*/
public void setAndroidResultFileId(String androidResultFileId) {
this.androidResultFileId = androidResultFileId;
}
/**
* Gets the notice flag.
*
* @return the notice flag
*/
public String getNoticeFlag() {
return noticeFlag;
}
/**
* Sets the notice flag.
*
* @param noticeFlag the new notice flag
*/
public void setNoticeFlag(String noticeFlag) {
this.noticeFlag = noticeFlag;
}
/**
* Gets the role out license id list.
*
* @return the role out license id list
*/
public List<String> getRoleOutLicenseIdList() {
return roleOutLicenseIdList;
}
/**
* Sets the role out license id list.
*
* @param roleOutLicenseIdList the new role out license id list
*/
public void setRoleOutLicenseIdList(List<String> roleOutLicenseIdList) {
this.roleOutLicenseIdList = roleOutLicenseIdList;
}
/**
* Gets the vulnerability.
*
* @return the vulnerability
*/
public String getVulnerability() {
return vulnerability;
}
/**
* Sets the vulnerability.
*
* @param vulnerability the new vulnerability
*/
public void setVulnerability(String vulnerability) {
this.vulnerability = vulnerability;
}
/**
* Gets the license name exists yn.
*
* @return the license name exists yn
*/
public String getLicenseNameExistsYn() {
return licenseNameExistsYn;
}
/**
* Sets the license name exists yn.
*
* @param licenseNameExistsYn the new license name exists yn
*/
public void setLicenseNameExistsYn(String licenseNameExistsYn) {
this.licenseNameExistsYn = licenseNameExistsYn;
}
/**
* Gets the oss name exists yn.
*
* @return the oss name exists yn
*/
public String getOssNameExistsYn() {
return ossNameExistsYn;
}
/**
* Sets the oss name exists yn.
*
* @param ossNameExistsYn the new oss name exists yn
*/
public void setOssNameExistsYn(String ossNameExistsYn) {
this.ossNameExistsYn = ossNameExistsYn;
}
/**
* @return the licenseUserGuideYn
*/
public String getLicenseUserGuideYn() {
return licenseUserGuideYn;
}
/**
* @param licenseUserGuideYn the licenseUserGuideYn to set
*/
public void setLicenseUserGuideYn(String licenseUserGuideYn) {
this.licenseUserGuideYn = licenseUserGuideYn;
}
/**
* @return the comments
*/
public String getComments() {
return comments;
}
/**
* @param comments the comments to set
*/
public void setComments(String comments) {
this.comments = comments;
}
/**
* @return the incCommentsFlag
*/
public String getIncCommentsFlag() {
return incCommentsFlag;
}
/**
* @param incCommentsFlag the incCommentsFlag to set
*/
public void setIncCommentsFlag(String incCommentsFlag) {
this.incCommentsFlag = incCommentsFlag;
}
public String getLicenseUserGuideStr() {
return licenseUserGuideStr;
}
public void setLicenseUserGuideStr(String licenseUserGuideStr) {
this.licenseUserGuideStr = licenseUserGuideStr;
}
public String getCopyright() {
return copyright;
}
public void setCopyright(String copyright) {
this.copyright = copyright;
}
public String getPartnerId() {
return partnerId;
}
public void setPartnerId(String partnerId) {
this.partnerId = partnerId;
}
public String getRestriction() {
return restriction;
}
public void setRestriction(String restriction) {
this.restriction = restriction;
}
public String getCvssScore2() {
return cvssScore2;
}
public void setCvssScore2(String cvssScore2) {
this.cvssScore2 = cvssScore2;
}
public String getTypeFlag() {
return typeFlag;
}
public void setTypeFlag(String typeFlag) {
this.typeFlag = typeFlag;
}
public String getBulkRegistYn() {
return bulkRegistYn;
}
public void setBulkRegistYn(String bulkRegistYn) {
this.bulkRegistYn = bulkRegistYn;
}
public String getLicenseTypeIdx() {
return licenseTypeIdx;
}
public void setLicenseTypeIdx(String licenseTypeIdx) {
this.licenseTypeIdx = licenseTypeIdx;
}
public String getCvssScoreMax() {
return cvssScoreMax;
}
public void setCvssScoreMax(String cvssScoreMax) {
this.cvssScoreMax = cvssScoreMax;
}
public String getRefPartnerName() {
return refPartnerName;
}
public void setRefPartnerName(String refPartnerName) {
this.refPartnerName = refPartnerName;
}
public String getAdminCheckYn() {
return adminCheckYn;
}
public void setAdminCheckYn(String adminCheckYn) {
this.adminCheckYn = adminCheckYn;
}
@Override
public int compareTo(ProjectIdentification o) {
return this.refDiv.compareTo(o.refDiv);
}
public String getOssNickName() {
return ossNickName;
}
public void setOssNickName(String ossNickName) {
this.ossNickName = ossNickName;
}
public ProjectIdentification copy() throws CloneNotSupportedException{
return (ProjectIdentification)super.clone();
}
public String getAttribution() {
return attribution;
}
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public String getCheckedEvidenceType() {
return checkedEvidenceType;
}
public void setCheckedEvidenceType(String checkedEvidenceType) {
this.checkedEvidenceType = checkedEvidenceType;
}
public String getCheckedEvidence() {
return checkedEvidence;
}
public void setCheckedEvidence(String checkedEvidence) {
this.checkedEvidence = checkedEvidence;
}
public String getCvssScoreMax1() {
return cvssScoreMax1;
}
public void setCvssScoreMax1(String cvssScoreMax1) {
this.cvssScoreMax1 = cvssScoreMax1;
}
public String getCvssScoreMax2() {
return cvssScoreMax2;
}
public void setCvssScoreMax2(String cvssScoreMax2) {
this.cvssScoreMax2 = cvssScoreMax2;
}
public String getCvssScoreMax3() {
return cvssScoreMax3;
}
public void setCvssScoreMax3(String cvssScoreMax3) {
this.cvssScoreMax3 = cvssScoreMax3;
}
public String getCvssScoreMax4() {
return cvssScoreMax4;
}
public void setCvssScoreMax4(String cvssScoreMax4) {
this.cvssScoreMax4 = cvssScoreMax4;
}
public String getCvssScoreMax5() {
return cvssScoreMax5;
}
public void setCvssScoreMax5(String cvssScoreMax5) {
this.cvssScoreMax5 = cvssScoreMax5;
}
public String getPublDate() {
return publDate;
}
public void setPublDate(String publDate) {
this.publDate = publDate;
}
public String getPatchLink() {
return patchLink;
}
public void setPatchLink(String patchLink) {
this.patchLink = patchLink;
}
public String getOssVersionEmptyFlag() {
return ossVersionEmptyFlag;
}
public void setOssVersionEmptyFlag(String ossVersionEmptyFlag) {
this.ossVersionEmptyFlag = ossVersionEmptyFlag;
}
public String getDependencies() {
return dependencies;
}
public void setDependencies(String dependencies) {
this.dependencies = dependencies;
}
public String getRefOssName() {
return refOssName;
}
public void setRefOssName(String refOssName) {
this.refOssName = refOssName;
}
}
| 42,575 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2SecuredResourcesRole.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2SecuredResourcesRole.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class T2SecuredResourcesRole implements Serializable{
private static final long serialVersionUID = 1L;
private String resourceId;
private String authority;
} | 400 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2Authorities.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2Authorities.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class T2Authorities implements Serializable{
private static final long serialVersionUID = 1L;
private String userId; // ์ฌ์ฉ์ Id
private String authority; // ๊ถํ ์์ด๋
private String[] userIds; //์ฌ์ฉ์ ์์ด๋๋ค
private String[] authoritys; // ๊ถํ ์์ด๋๋ค
public static final String ROLE_USER = "ROLE_USER";
} | 647 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
OssNotice.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/OssNotice.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.List;
public class OssNotice extends ComBean implements Serializable {
private static final long serialVersionUID = -3729500877991189740L;
private String prjId;
private String noticeType = "10";
private String noticeTypeEtc;
private String companyNameFull;
private String companyNameShort;
private String distributionSiteUrl;
private String email;
private String appended;
private String appendedTEXT;
private String useCompanyNameTitle;
private String distributedOtherCompany;
private String mergedOtherOssNotice;
private String accompaniedSourceCode;
private String packageJson;
private List<OssComponents> ossComponents;
private String packageFileId;
private String packageFileId2;
private String packageFileId3;
private String packageVulDocFileId;
private String userComment;
private String networkServerFlag = "N";
private String fileType;
private String simpleNoticeFlag = "N";
private String withoutVerifyYn;
/** binary DB ๋ฑ๋ก ๋ฌด์์ฒ๋ฆฌ */
private String ignoreBinaryDbFlag;
private String ossDistributionSite;
private String ossDistributionSiteYn;
private String refDiv;
private String refDivUnExists;
private String noticeTextFileId;
private String simpleHtmlFileId;
private String simpleTextFileId;
private String spdxSheetFileId;
private String spdxRdfFileId;
private String spdxTagFileId;
private String spdxJsonFileId;
private String spdxYamlFileId;
/** OSS_NOTICE_NEW UI ๋ณ๊ฒฝ ํ ์ฌ์ฉ๋๋ properties */
private String editNoticeYn = "N";
private String editCompanyYn = "N";
private String editDistributionSiteUrlYn = "N";
private String editEmailYn = "N";
private String hideOssVersionYn = "N";
private String editAppendedYn = "N";
private String isSimpleNotice;
private String previewOnly = "N";
/** //OSS_NOTICE_NEW UI ๋ณ๊ฒฝ ํ ์ฌ์ฉ๋๋ properties */
public String getPrjId() {
return prjId;
}
public void setPrjId(String prjId) {
this.prjId = prjId;
}
public String getNoticeType() {
return noticeType;
}
public void setNoticeType(String noticeType) {
this.noticeType = noticeType;
}
public String getNoticeTypeEtc() {
return noticeTypeEtc;
}
public void setNoticeTypeEtc(String noticeTypeEtc) {
this.noticeTypeEtc = noticeTypeEtc;
}
public String getCompanyNameFull() {
return companyNameFull;
}
public void setCompanyNameFull(String companyNameFull) {
this.companyNameFull = companyNameFull;
}
public String getCompanyNameShort() {
return companyNameShort;
}
public void setCompanyNameShort(String companyNameShort) {
this.companyNameShort = companyNameShort;
}
public String getDistributionSiteUrl() {
return distributionSiteUrl;
}
public void setDistributionSiteUrl(String distributionSiteUrl) {
this.distributionSiteUrl = distributionSiteUrl;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAppended() {
return appended;
}
public void setAppended(String appended) {
this.appended = appended;
}
public String getAppendedTEXT() {
return appendedTEXT;
}
public void setAppendedTEXT(String appendedTEXT) {
this.appendedTEXT = appendedTEXT;
}
public String getUseCompanyNameTitle() {
return useCompanyNameTitle;
}
public void setUseCompanyNameTitle(String useCompanyNameTitle) {
this.useCompanyNameTitle = useCompanyNameTitle;
}
public String getDistributedOtherCompany() {
return distributedOtherCompany;
}
public void setDistributedOtherCompany(String distributedOtherCompany) {
this.distributedOtherCompany = distributedOtherCompany;
}
public String getMergedOtherOssNotice() {
return mergedOtherOssNotice;
}
public void setMergedOtherOssNotice(String mergedOtherOssNotice) {
this.mergedOtherOssNotice = mergedOtherOssNotice;
}
public String getAccompaniedSourceCode() {
return accompaniedSourceCode;
}
public void setAccompaniedSourceCode(String accompaniedSourceCode) {
this.accompaniedSourceCode = accompaniedSourceCode;
}
public String getPackageJson() {
return packageJson;
}
public void setPackageJson(String packageJson) {
this.packageJson = packageJson;
}
public List<OssComponents> getOssComponents() {
return ossComponents;
}
public void setOssComponents(List<OssComponents> ossComponents) {
this.ossComponents = ossComponents;
}
public String getNetworkServerFlag() {
return networkServerFlag;
}
public void setNetworkServerFlag(String networkServerFlag) {
this.networkServerFlag = networkServerFlag;
}
public String getPackageFileId() {
return packageFileId;
}
public void setPackageFileId(String packageFileId) {
this.packageFileId = packageFileId;
}
public String getPackageFileId2() {
return packageFileId2;
}
public void setPackageFileId2(String packageFileId2) {
this.packageFileId2 = packageFileId2;
}
public String getPackageFileId3() {
return packageFileId3;
}
public void setPackageFileId3(String packageFileId3) {
this.packageFileId3 = packageFileId3;
}
public String getUserComment() {
return userComment;
}
public void setUserComment(String userComment) {
this.userComment = userComment;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getWithoutVerifyYn() {
return withoutVerifyYn;
}
public void setWithoutVerifyYn(String withoutVerifyYn) {
this.withoutVerifyYn = withoutVerifyYn;
}
public String getOssDistributionSite() {
return ossDistributionSite;
}
public void setOssDistributionSite(String ossDistributionSite) {
this.ossDistributionSite = ossDistributionSite;
}
public String getOssDistributionSiteYn() {
return ossDistributionSiteYn;
}
public void setOssDistributionSiteYn(String ossDistributionSiteYn) {
this.ossDistributionSiteYn = ossDistributionSiteYn;
}
public String getSimpleNoticeFlag() {
return simpleNoticeFlag;
}
public void setSimpleNoticeFlag(String simpleNoticeFlag) {
this.simpleNoticeFlag = simpleNoticeFlag;
}
public String getRefDiv() {
return refDiv;
}
public void setRefDiv(String refDiv) {
this.refDiv = refDiv;
}
public String getRefDivUnExists() {
return refDivUnExists;
}
public void setRefDivUnExists(String refDivUnExists) {
this.refDivUnExists = refDivUnExists;
}
public String getNoticeTextFileId() {
return noticeTextFileId;
}
public void setNoticeTextFileId(String noticeTextFileId) {
this.noticeTextFileId = noticeTextFileId;
}
public String getSimpleHtmlFileId() {
return simpleHtmlFileId;
}
public void setSimpleHtmlFileId(String simpleHtmlFileId) {
this.simpleHtmlFileId = simpleHtmlFileId;
}
public String getSimpleTextFileId() {
return simpleTextFileId;
}
public void setSimpleTextFileId(String simpleTextFileId) {
this.simpleTextFileId = simpleTextFileId;
}
public String getSpdxSheetFileId() {
return spdxSheetFileId;
}
public void setSpdxSheetFileId(String spdxSheetFileId) {
this.spdxSheetFileId = spdxSheetFileId;
}
public String getSpdxRdfFileId() {
return spdxRdfFileId;
}
public void setSpdxRdfFileId(String spdxRdfFileId) {
this.spdxRdfFileId = spdxRdfFileId;
}
public String getSpdxTagFileId() {
return spdxTagFileId;
}
public void setSpdxTagFileId(String spdxTagFileId) {
this.spdxTagFileId = spdxTagFileId;
}
public String getSpdxJsonFileId() {
return spdxJsonFileId;
}
public void setSpdxJsonFileId(String spdxJsonFileId) {
this.spdxJsonFileId = spdxJsonFileId;
}
public String getSpdxYamlFileId() {
return spdxYamlFileId;
}
public void setSpdxYamlFileId(String spdxYamlFileId) {
this.spdxYamlFileId = spdxYamlFileId;
}
public String getIgnoreBinaryDbFlag() {
return ignoreBinaryDbFlag;
}
public void setIgnoreBinaryDbFlag(String ignoreBinaryDbFlag) {
this.ignoreBinaryDbFlag = ignoreBinaryDbFlag;
}
public String getEditNoticeYn() {
return editNoticeYn;
}
public void setEditNoticeYn(String editNoticeYn) {
this.editNoticeYn = editNoticeYn;
}
public String getEditCompanyYn() {
return editCompanyYn;
}
public void setEditCompanyYn(String editCompanyYn) {
this.editCompanyYn = editCompanyYn;
}
public String getEditDistributionSiteUrlYn() {
return editDistributionSiteUrlYn;
}
public void setEditDistributionSiteUrlYn(String editDistributionSiteUrlYn) {
this.editDistributionSiteUrlYn = editDistributionSiteUrlYn;
}
public String getEditEmailYn() {
return editEmailYn;
}
public void setEditEmailYn(String editEmailYn) {
this.editEmailYn = editEmailYn;
}
public String getHideOssVersionYn() {
return hideOssVersionYn;
}
public void setHideOssVersionYn(String hideOssVersionYn) {
this.hideOssVersionYn = hideOssVersionYn;
}
public String getEditAppendedYn() {
return editAppendedYn;
}
public void setEditAppendedYn(String editAppendedYn) {
this.editAppendedYn = editAppendedYn;
}
public String getIsSimpleNotice() {
return isSimpleNotice;
}
public void setIsSimpleNotice(String isSimpleNotice) {
this.isSimpleNotice = isSimpleNotice;
}
public String getPreviewOnly() {
return previewOnly;
}
public void setPreviewOnly(String previewOnly) {
this.previewOnly = previewOnly;
}
public String getPackageVulDocFileId() {
return packageVulDocFileId;
}
public void setPackageVulDocFileId(String packageVulDocFileId) {
this.packageVulDocFileId = packageVulDocFileId;
}
}
| 9,899 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
T2Users.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/T2Users.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import java.util.List;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
/**
* The Class T2Users.
*/
public class T2Users extends ComBean implements Serializable{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 6658712585854634962L;
/** The user id. */
private String userId; // ์ฌ์ฉ์ ID
/** The user name. */
private String userName; // ์ฌ์ฉ์ ์ด๋ฆ(๋๋ค์)
/** The password. */
private String password; // ์ํธ
/** The email. */
private String email;
/** The division. */
private String division;
/** The enabled. */
private String enabled; // ์ฌ์ฉ ๊ตฌ๋ถ
/** The Default Tab. 2018-08-14 choye ์ถ๊ฐ */
private String defaultTab; // ๋ก๊ทธ์ธํ tab์ ๋ณด
private String defaultTabAnchor; // ๋ก๊ทธ์ธํ tab์ ๋ณด
/** The Default Locale. */
private String defaultLocale;
/** The authorities list. */
private List<T2Authorities> authoritiesList; // ์ฌ์ฉ์ ๊ถํ ๋ชฉ๋ก
/** The authority. */
private String authority; //ํด๋น ๊ถํ Role
/** The viewerAuthority. */
private String viewerAuthority; // view ๊ถํ Role
/** The adminAuthority. */
private String adminAuthority; // admin ๊ถํ Role
private String useYn;
private String divisionName;
private String tokenType;
private String token;
private String expireDate;
private String expireFlag;
private String modifiedFlag;
public String getModifiedFlag() {
return modifiedFlag;
}
public void setModifiedFlag(String modifiedFlag) {
this.modifiedFlag = modifiedFlag;
}
public String getExpireFlag() {
return expireFlag;
}
public void setExpireFlag(String expireFlag) {
this.expireFlag = expireFlag;
}
public T2Users() {}
public T2Users(String userName) {
this.userName = userName;
}
/**
* Gets the user id.
*
* @return the user id
*/
public String getUserId() {
return userId;
}
/**
* Sets the user id.
*
* @param userId the new user id
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* Gets the user name.
*
* @return the user name
*/
public String getUserName() {
return userName;
}
/**
* Sets the user name.
*
* @param userName the new user name
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Gets the password.
*
* @return the password
*/
public String getPassword() {
return password;
}
/**
* Sets the password.
*
* @param password the new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Gets the email.
*
* @return the email
*/
public String getEmail() {
return email;
}
/**
* Sets the email.
*
* @param email the new email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the division.
*
* @return the division
*/
public String getDivision() {
return division;
}
/**
* Sets the division.
*
* @param division the new division
*/
public void setDivision(String division) {
this.division = division;
}
/**
* Gets the enabled.
*
* @return the enabled
*/
public String getEnabled() {
return enabled;
}
/**
* Sets the enabled.
*
* @param enabled the new enabled
*/
public void setEnabled(String enabled) {
this.enabled = enabled;
}
/**
* Gets the defaultLocale.
*
* @return the defaultLocale
*/
public String getDefaultLocale() {
return defaultLocale;
}
/**
* Sets the defaultLocale.
*
* @param defaultLocale the new defaultLocale
*/
public void setDefaultLocale(String defaultLocale) {
this.defaultLocale = defaultLocale;
}
/**
* Gets the defaultTab. 2018-08-14 choye ์ถ๊ฐ
*
* @return the defaultTab
*/
public String getDefaultTab() {
return defaultTab;
}
/**
* Sets the defaultTab. 2018-08-14 choye ์ถ๊ฐ
*
* @param defaultTab the new defaultTab
*/
public void setDefaultTab(String defaultTab) {
this.defaultTab = defaultTab;
}
/**
* Gets the authorities list.
*
* @return the authorities list
*/
public List<T2Authorities> getAuthoritiesList() {
return authoritiesList;
}
/**
* Sets the authorities list.
*
* @param authoritiesList the new authorities list
*/
public void setAuthoritiesList(List<T2Authorities> authoritiesList) {
this.authoritiesList = authoritiesList;
}
/**
* Gets the authority.
*
* @return the authority
*/
public String getAuthority() {
return authority;
}
/**
* Sets the authority.
*
* @param authority the new authority
*/
public void setAuthority(String authority) {
this.authority = authority;
}
/**
* Gets the viewerAuthority.
*
* @return the viewerAuthority
*/
public String getViewerAuthority() {
return viewerAuthority;
}
/**
* Sets the viewerAuthority.
*
* @param viewerAuthority the new viewerAuthority
*/
public void setViewerAuthority(String viewerAuthority) {
this.viewerAuthority = viewerAuthority;
}
/**
* Gets the adminAuthority.
*
* @return the adminAuthority
*/
public String getAdminAuthority() {
return adminAuthority;
}
/**
* Sets the adminAuthority.
*
* @param adminAuthority the new adminAuthority
*/
public void setAdminAuthority(String adminAuthority) {
this.adminAuthority = adminAuthority;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
public void setDivisionName(String divisionName) {
this.divisionName = divisionName;
}
public String getDivisionName() {
return divisionName;
}
public String getDefaultTabAnchor() {
if (isEmpty(defaultTabAnchor) && !isEmpty(defaultTab)) {
String _temp = "";
for (String s : defaultTab.split(",")) {
String _anchor = CoCodeManager.getCodeExpString(CoConstDef.CD_DEFAULT_TAB, s);
if (!isEmpty(_anchor)) {
if (!isEmpty(_temp)) {
_temp += ",";
}
_temp += _anchor;
}
}
if (!isEmpty(_temp)) {
return _temp;
}
}
for (String[] dtlCd : CoCodeManager.getValues(CoConstDef.CD_DEFAULT_TAB)) {
defaultTab = dtlCd[0]; // detail No
defaultTabAnchor = dtlCd[3]; // detail Description
break;
}
return defaultTabAnchor;
}
public void setDefaultTabAnchor(String defaultTabAnchor) {
this.defaultTabAnchor = defaultTabAnchor;
}
public String getTokenType() {
return tokenType;
}
public void setTokenType(String tokenType) {
this.tokenType = tokenType;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getExpireDate() {
return expireDate;
}
public void setExpireDate(String expireDate) {
this.expireDate = expireDate;
}
} | 7,310 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Vulnerability.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/Vulnerability.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class Vulnerability extends ComBean implements Serializable {
private static final long serialVersionUID = 8760328282030574612L;
// NVD_CEV
private String year;
private String cveId;
private String publDate;
private String modiDate;
private String cvssScore;
private String cvssAccVector;
private String cvssAccComple;
private String cvssAuth;
private String cvssConfImpact;
private String cvssIntImpact;
private String cvssAvaImpact;
private String cvssSource;
private String cvssGenOnDt;
private String vulnSummary;
private String ossName;
private String ossNickname;
private String product;
private String vendor;
private String version;
private String vulnerabilityLink;
private String ossId;
private String ossNameAllSearchFlag;
private String[] ossNicknames;
private String specialCharactersProduct;
private String[] ossNicknameArr;
private String patchLink;
private String vulnerabilityResolution;
private String VulnerabilityCheckFlag;
}
| 1,252 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
CoMailManager.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/CoMailManager.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.StringWriter;
import java.io.Writer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import difflib.DiffUtils;
import difflib.Patch;
import lombok.extern.slf4j.Slf4j;
import oss.fosslight.CoTopComponent;
import oss.fosslight.common.CoCodeManager;
import oss.fosslight.common.CoConstDef;
import oss.fosslight.common.CommonFunction;
import oss.fosslight.repository.MailManagerMapper;
import oss.fosslight.repository.OssMapper;
import oss.fosslight.repository.T2UserMapper;
import oss.fosslight.service.FileService;
import oss.fosslight.service.ProjectService;
import oss.fosslight.util.DateUtil;
import oss.fosslight.util.PdfUtil;
import oss.fosslight.util.StringUtil;
/**
* The Class CoMailManager.
*/
@Component
@Slf4j
public class CoMailManager extends CoTopComponent {
/** The instance. */
private static CoMailManager instance;
private static JavaMailSender mailSender;
private static MailManagerMapper mailManagerMapper;
private static T2UserMapper userMapper;
private static ProjectService projectService;
private static FileService fileService;
private static OssMapper ossMapper;
private static String DEFAULT_BCC;
private static String[] BAT_FAILED_BCC;
private static String[] MAIL_LIST_SECURITY;
/** The conn str. */
private static String connStr;
/** The conn user. */
private static String connUser;
/** The conn pw. */
private static String connPw;
/**
* Instantiates a new co mail manager.
*/
private CoMailManager() { }
/**
* Gets the single instance of CoMailManager.
*
* @return single instance of CoMailManager
*/
public static CoMailManager getInstance() {
if (instance == null) {
instance = new CoMailManager();
mailSender = (JavaMailSender) getWebappContext().getBean(JavaMailSender.class);
mailManagerMapper = (MailManagerMapper) getWebappContext().getBean(MailManagerMapper.class);
userMapper = (T2UserMapper) getWebappContext().getBean(T2UserMapper.class);
projectService = (ProjectService) getWebappContext().getBean(ProjectService.class);
fileService = (FileService) getWebappContext().getBean(FileService.class);
ossMapper = (OssMapper) getWebappContext().getBean(OssMapper.class);
DEFAULT_BCC = avoidNull(CommonFunction.getProperty("smtp.default.bcc"));
BAT_FAILED_BCC = avoidNull(CommonFunction.getProperty("smtp.default.bat")).split(","); // (To be added) BAT Detail setting
MAIL_LIST_SECURITY = avoidNull(CommonFunction.getProperty("smtp.default.security")).split(","); // (To be added) Vulnerability Detail setting
connStr = CommonFunction.makeJdbcUrl( CommonFunction.getProperty("spring.datasource.url"));
connUser = CommonFunction.getProperty("spring.datasource.username");
connPw = CommonFunction.getProperty("spring.datasource.password");
}
return instance;
}
/**
* Send mail.
*
* @param bean the bean
* @return true, if successful
*/
@SuppressWarnings("unchecked")
public boolean sendMail(CoMail bean) {
boolean procResult = true;
boolean EMAIL_USE_FLAG = CoConstDef.FLAG_YES.equals(CommonFunction.getProperty("mail.smtp.useflag"));
if (!EMAIL_USE_FLAG) {
return procResult;
}
try {
// Check the required things
if (bean == null || isEmpty(bean.getMsgType())) {
log.error("Mail Bean or Type is Empty");
return false;
}
boolean isTest = !"REAL".equals(avoidNull(CommonFunction.getProperty("server.mode")));
Map<String, Object> convertDataMap = new HashMap<>();
convertDataMap.put("mailType", bean.getMsgType());
convertDataMap.put("isModify", false); // Check if the data are modified
String msgType = bean.getMsgType();
// To use the same title in case of recalculated
if (CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED.equals(msgType)) {
msgType = CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED;
}
String title = (isTest ? "[TEST]" : "") + CoCodeManager.getCodeString(CoConstDef.CD_MAIL_TYPE, msgType);
title = makeMailSubject(title, bean);
// Add a direct link to OSS information (ADMIN ONLY)
if (CoConstDef.CD_MAIL_TYPE_OSS_REGIST.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_MODIFIED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_DEACTIVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_ACTIVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_REGIST.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE_TYPE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_MODIFIED_COMMENT.equals(bean.getMsgType())
) {
convertDataMap.put("contentsTitle", StringUtil.replace(makeMailSubject((isTest ? "[TEST]" : "") + CoCodeManager.getCodeString(CoConstDef.CD_MAIL_TYPE, bean.getMsgType()), bean, true), "[FOSSLight]", ""));
} else {
convertDataMap.put("contentsTitle", StringUtil.replace(title, "[FOSSLight]", ""));
}
// Get component information
String mailComponents = CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_COMPONENT, bean.getMsgType());
// Acquire data by component without comparing changes (compare VO data directly)
if (!isEmpty(mailComponents)) {
for (String component : mailComponents.split(",")) {
if (!isEmpty(component)) {
component = component.trim();
Object _contents = setContentsInfo(bean, component);
if (_contents != null) {
if (CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PROJECT_RECALCULATED_ALL.equals(component)) {
component = CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_OSS;
}
convertDataMap.put(CoCodeManager.getCodeString(CoConstDef.CD_MAIL_COMPONENT_NAME, component), _contents);
}
}
}
}
if (CoConstDef.CD_MAIL_TYPE_OSS_DELETE.equals(bean.getMsgType()) && bean.getParamOssInfo() != null) {
OssMaster oss_basic_info = bean.getParamOssInfo();
String result = appendChangeStyleLinkFormatArray(oss_basic_info.getDownloadLocation());
oss_basic_info.setDownloadLocation(result);
convertDataMap.put(CoCodeManager.getCodeString(CoConstDef.CD_MAIL_COMPONENT_NAME, CoConstDef.CD_MAIL_COMPONENT_OSSBASICINFO), oss_basic_info); // oss_basic_info
}
if (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_REJECT.equals(bean.getMsgType()) && bean.getParamPrjInfo() != null) {
// In case of distribution reject, distribution info must be received as a separate parameter (already deleted)
convertDataMap.put(CoCodeManager.getCodeString(CoConstDef.CD_MAIL_COMPONENT_NAME, CoConstDef.CD_MAIL_COMPONENT_PROJECT_DISTRIBUTIONINFO), bean.getParamPrjInfo()); // oss_basic_info
}
// TODO 92๋ฒ ๋ฉ์ผ ( vulnerability recalculated )์ ๊ฒฝ์ฐ as-is to-be ๊ฐ ์กด์ฌํ๊ธฐ ๋๋ฌธ์ ์์ธ์ฒ๋ฆฌํ๋ค.
// 94๋ฒ ๋ฉ์ผ NVD Data > CVSS Score๊ฐ 9.0์ด์์ธ ๋์์ค ํ์ฌ ๋ฐฐ์น๋ก์ธํด NVD Data๊ฐ ์ญ์ ๋ ๊ฒฝ์ฐ mail ๋ฐ์ก
if (CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED.equals(bean.getMsgType())) {
if (bean.getParamOssInfoMap() == null || bean.getParamOssInfoMap().isEmpty()) {
return false;
}
String recalculatedMsgType = CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED.equals(bean.getMsgType())
? CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_RECALCULATED
: CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_REMOVE_RECALCULATED;
// ๋ณ๊ฒฝ๋ oss id ๊ณผ ํด๋น ํ๋ก์ ํธ์์ ์ฌ์ฉ์ค์ธ oss ๋ชฉ๋ก์ ๋น๊ตํ๊ธฐ ์ํด์ 210 ๋ฒ ์ฟผ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ค.
List<OssMaster> _contents = (List<OssMaster>) setContentsInfo(bean, recalculatedMsgType);
List<OssMaster> _reMakeContents = new ArrayList<>();
for (OssMaster _bean : _contents) {
String key = _bean.getOssName().toUpperCase()+"_"+_bean.getOssVersion();
if (bean.getParamOssInfoMap().containsKey(key)) {
OssMaster reMakeBean = bean.getParamOssInfoMap().get(key);
OssMaster diffBean = CoCodeManager.OSS_INFO_UPPER.get(key);
if (diffBean == null) {
return false;
}
if ("0".equals(reMakeBean.getCvssScoreTo())) {
reMakeBean.setCveIdTo("NONE");
}
_reMakeContents.add(reMakeBean);
}
}
if (_reMakeContents.isEmpty()) {
return false;
}
convertDataMap.put("vulnerability_prj_recalc_oss_info", _reMakeContents);
}
if (CoConstDef.CD_MAIL_TYPE_VULNERABILITY_NVDINFO_DIFF.equals(bean.getMsgType())) {
convertDataMap.put("vulnerability_diff_vendor_info", bean.getParamList());
}
// ldap Search์ ์ฌ์ฉ์ ์ ๋ณด๊ฐ ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ
if (CoConstDef.CD_MAIL_TYPE_CHANGED_USER_INFO.equals(bean.getMsgType()) && bean.getParamList() != null) {
List<Map<String, Object>> userList = bean.getParamList();
List<T2Users> changedUserList = new ArrayList<>();
List<T2Users> retireeUserList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c1 = Calendar.getInstance();
String strToday = sdf.format(c1.getTime());
for (Map<String, Object> userInfo : userList) {
T2Users t2user = new T2Users();
t2user.setUserId((String) userInfo.get("userId"));
t2user.setModifiedDate(strToday);
// ์ ๋ณด ๋ณ๊ฒฝ ์ฌ์ฉ์
if (userInfo.containsKey("beforeUserName")) {
String userName = (String) userInfo.get("beforeUserName");
if (!userInfo.containsKey("newcomer")) {
userName += " -> ";
userName += (String) userInfo.get("afterUserName");
} else {
t2user.setModifiedDate((String) userInfo.get("createdDate"));
}
t2user.setUserName(userName);
changedUserList.add(t2user);
}
// ํด์ง์
else {
t2user.setUserName((String) userInfo.get("afterUserName"));
String useYn = (String) userInfo.get("beforeUseYn");
useYn += " -> ";
useYn += (String) userInfo.get("afterUseYn");
t2user.setUseYn(useYn);
retireeUserList.add(t2user);
}
}
if (changedUserList.size() > 0) {
convertDataMap.put("changed_user_info", changedUserList);
}
if (retireeUserList.size() > 0) {
convertDataMap.put("retiree_user_info", retireeUserList);
}
}
// Common
{
if (isEmpty(bean.getCreationUserId())) {
bean.setCreationUserId(bean.getLoginUserName());
}
if (!isEmpty(bean.getComment())) {
// FIXME
if (CoConstDef.CD_MAIL_TYPE_PROJECT_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_PARTER_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_OSS_MODIFIED_COMMENT.equals(bean.getMsgType())
||CoConstDef.CD_MAIL_TYPE_LICENSE_MODIFIED_COMMENT.equals(bean.getMsgType())
) {
bean.setComment(appendChangeStyleMultiLine(bean.getParamExpansion1(), bean.getParamExpansion2()));
}
convertDataMap.put("comment", bean.getComment());
}
if (isEmpty(bean.getModifier())) {
bean.setModifier(bean.getLoginUserName());
}
convertDataMap.put("modifier", bean.getModifier());
if (isEmpty(bean.getModifiedDate())) {
bean.setModifiedDate(DateUtil.getCurrentDateAsString());
}
convertDataMap.put("modifiedDate", bean.getModifiedDate());
T2Users userParam = new T2Users();
userParam.setUserId(bean.getModifier());
T2Users userInfo = userMapper.getUser(userParam);
convertDataMap.put("modifierNm", makeUserNameFormatWithDivision(userInfo));
// In case of comparing changes
if (bean.getCompareDataBefore() != null) {
convertDataMap.put("before", bean.getCompareDataBefore());
}
if (bean.getCompareDataAfter() != null) {
convertDataMap.put("after", bean.getCompareDataAfter());
}
// partner ๊ธฐ๋ณธ์ ๋ณด๊ฐ ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ, ์ฝ๋๋ณํํ์ฌ ๋ค์ ๋งต์ ๊ฒฉ๋ฉํ๋ค.
if (CoConstDef.CD_MAIL_TYPE_PARTNER_CHANGED.equals(bean.getMsgType())) {
convertDataMap.put("before", convertCodePartnerBaiscInfo( bean.getCompareDataBefore()));
convertDataMap.put("after", convertCodePartnerBaiscInfo( bean.getCompareDataAfter()));
}
// ํ๋ก์ ํธ ๊ธฐ๋ณธ์ ๋ณด๊ฐ ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ, ์ฝ๋๋ณํํ์ฌ ๋ค์ ๋งต์ ๊ฒฉ๋ฉํ๋ค.
if (CoConstDef.CD_MAIL_TYPE_PROJECT_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_COPIED.equals(bean.getMsgType())) {
convertDataMap.put("before", convertCodeProjectBaiscInfo( bean.getCompareDataBefore()));
convertDataMap.put("after", convertCodeProjectBaiscInfo( bean.getCompareDataAfter()));
}
if (CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(bean.getMsgType())) {
convertDataMap.put("paramOssInfo", bean.getParamOssInfo());
convertModifiedData(convertDataMap, bean.getMsgType());
}
// as-is, to-be ๋น๊ต ๋ฉ์ผ์ ๊ฒฝ์ฐ, ๋ณ๊ฒฝ ๋ถ๋ถ ์์์ ์ํ ์ฒ๋ฆฌ์ถ๊ฐ
if (bean.getCompareDataBefore() != null || bean.getCompareDataAfter() != null) {
convertModifiedData(convertDataMap, bean.getMsgType());
}
// when modifying/registering oss, if there is a version diff, license information by version is output
if (CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())) {
convertDataMap.put("versionDiffInfoList", bean.getParamList());
}
// 17.08.02 sw-yun 22๋ฒ ๋ฉ์ผ์ ๋์ด์ ์ฌ์ฉํ์ง ์๊ณ , 21๋ฒ ๋ฉ์ผ์ ํฌํจ
if (CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE.equals(bean.getMsgType()) || CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME.equals(bean.getMsgType())) {
// license type์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ ์ฌ์ฉ์ค์ธ ํ๋ก์ ํธ ๋ฆฌ์คํธ๋ฅผ ํ์
if (!isEmpty(bean.getParamLicenseId())
&& bean.getCompareDataBefore() != null && bean.getCompareDataAfter() != null
&& !((LicenseMaster) bean.getCompareDataBefore()).getLicenseType().equals(((LicenseMaster) bean.getCompareDataAfter()).getLicenseType())) {
// license type์ด ๋ณ๊ฒฝ๋ oss list
if (bean.getParamOssList() != null) {
List<Project> prjListFinal = new ArrayList<>();
List<String> duplCheckPrjIdList = new ArrayList<>();
for (OssMaster ossInfo : bean.getParamOssList()) {
List<Project> prjList = ossMapper.getOssChangeForUserList(ossInfo);
if (prjList != null && !prjList.isEmpty()) {
for (Project prjBean : prjList) {
if (!duplCheckPrjIdList.contains(prjBean.getPrjId())) {
prjBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, prjBean.getDistributionType()));
prjBean.setCreator(makeUserNameFormatWithDivision(prjBean.getCreator()));
prjBean.setCreatedDate(CommonFunction.formatDateSimple(prjBean.getCreatedDate()));
prjBean.setReviewer(makeUserNameFormatWithDivision(prjBean.getReviewer()));
prjListFinal.add(prjBean);
duplCheckPrjIdList.add(prjBean.getPrjId());
}
}
}
}
if (!prjListFinal.isEmpty()) {
convertDataMap.put("projectList", prjListFinal);
}
// ๋ฉ์ผ ํ์์ผ๋ก ์ฝ๋ ๋ณํ
for (OssMaster ossInfo : bean.getParamOssList()) {
if (!isEmpty(ossInfo.getOssVersion())) {
ossInfo.setOssName(ossInfo.getOssName() + " (" + ossInfo.getOssVersion() +")");
}
ossInfo.setLicenseName(CommonFunction.makeLicenseExpression(ossInfo.getOssLicenses()));
ossInfo.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, ossInfo.getLicenseType()));
ossInfo.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, ossInfo.getObligationType()));
ossInfo.setOrgLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, ossInfo.getOrgLicenseType()));
ossInfo.setOrgObligationType(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, ossInfo.getOrgObligationType()));
}
convertDataMap.put("ossList", bean.getParamOssList());
}
}
}
// 17.08.02 sw-yun 12๋ฒ ๋ฉ์ผ์ ๋์ด์ ์ฌ์ฉํ์ง ์๊ณ , 11๋ฒ ๋ฉ์ผ์ ํฌํจ
if (CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())) {
if (!isEmpty(bean.getParamOssId())
&& bean.getCompareDataBefore() != null && bean.getCompareDataAfter() != null
&& !((OssMaster) bean.getCompareDataBefore()).getLicenseType().equals(((OssMaster) bean.getCompareDataAfter()).getLicenseType())) {
OssMaster paramVo = CoCodeManager.OSS_INFO_BY_ID.get(bean.getParamOssId());
if (paramVo == null) {
paramVo = (OssMaster) bean.getCompareDataBefore();
}
List<Project> prjList = ossMapper.getOssChangeForUserList(paramVo);
if (prjList != null && !prjList.isEmpty()) {
for (Project prjBean : prjList) {
prjBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, prjBean.getDistributionType()));
prjBean.setCreator(makeUserNameFormatWithDivision(prjBean.getCreator()));
prjBean.setCreatedDate(CommonFunction.formatDateSimple(prjBean.getCreatedDate()));
prjBean.setReviewer(makeUserNameFormatWithDivision(prjBean.getReviewer()));
}
convertDataMap.put("projectList", prjList);
}
}
}
if (CoConstDef.CD_MAIL_TYPE_OSS_RENAME.equals(bean.getMsgType())) {
if (!isEmpty(bean.getParamOssId())
&& bean.getCompareDataBefore() != null && bean.getCompareDataAfter() != null) {
List<Project> prjList = ossMapper.getOssChangeForUserList((OssMaster) bean.getCompareDataBefore());
if (prjList != null && !prjList.isEmpty()) {
for (Project prjBean : prjList) {
prjBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, prjBean.getDistributionType()));
prjBean.setCreator(makeUserNameFormatWithDivision(prjBean.getCreator()));
prjBean.setCreatedDate(CommonFunction.formatDateSimple(prjBean.getCreatedDate()));
prjBean.setReviewer(makeUserNameFormatWithDivision(prjBean.getReviewer()));
}
convertDataMap.put("projectList", prjList);
}
}
}
if (CoConstDef.CD_MAIL_TYPE_OSS_DELETE.equals(bean.getMsgType())) {
if (!isEmpty(bean.getParamOssId()) ) {
List<Project> prjList = ossMapper.getOssChangeForUserList(bean.getParamOssInfo());
if (prjList != null && !prjList.isEmpty()) {
for (Project prjBean : prjList) {
prjBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, prjBean.getDistributionType()));
prjBean.setCreator(makeUserNameFormatWithDivision(prjBean.getCreator()));
prjBean.setCreatedDate(CommonFunction.formatDateSimple(prjBean.getCreatedDate()));
prjBean.setReviewer(makeUserNameFormatWithDivision(prjBean.getReviewer()));
}
convertDataMap.put("projectList", prjList);
}
}
}
if (CoConstDef.CD_MAIL_TOKEN_CREATE_TYPE.equals(bean.getMsgType())) {
T2Users user = new T2Users();
user.setUserId(bean.getParamUserId());
user = userMapper.getUser(user);
convertDataMap.put("mailType", CoConstDef.CD_MAIL_TOKEN_CREATE_TYPE);
convertDataMap.put("token", user.getToken());
convertDataMap.put("expireDate", user.getExpireDate());
convertDataMap.put("tokenInfo", CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TOKEN_CREATE_TYPE));
}
if (CoConstDef.CD_MAIL_TYPE_RESET_USER_PASSWORD.equals(bean.getMsgType())) {
Map<String, Object> userInfoMap = bean.getParamList().get(0);
T2Users user = new T2Users();
user.setUserId(userInfoMap.get("userId").toString());
user.setPassword(userInfoMap.get("afterPassword").toString());
user.setModifiedDate(userInfoMap.get("modifiedTime").toString());
convertDataMap.put("userInfo", user);
convertDataMap.put("requestedIP", userInfoMap.get("requestedIP"));
}
if (CoConstDef.CD_MAIL_TOKEN_DELETE_TYPE.equals(bean.getMsgType())) {
convertDataMap.put("mailType", CoConstDef.CD_MAIL_TOKEN_DELETE_TYPE);
convertDataMap.put("tokenInfo", CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_DEFAULT_CONTENTS, CoConstDef.CD_MAIL_TOKEN_DELETE_TYPE));
}
if (CoConstDef.CD_MAIL_PACKAGING_UPLOAD_SUCCESS.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_PACKAGING_UPLOAD_FAILURE.equals(bean.getMsgType())) {
convertDataMap.put("mailType", bean.getMsgType());
convertDataMap.put("prjId", bean.getParamPrjId());
convertDataMap.put("fileName", bean.getParamExpansion1());
convertDataMap.put("errorMsg", bean.getParamExpansion2());
}
if (CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REQUESTTOOPEN_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_SELFCHECK_PROJECT_WATCHER_INVATED.equals(bean.getMsgType())
) {
if (!isEmpty(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_TYPE, bean.getMsgType()))) {
String subTitle = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_TYPE, bean.getMsgType()));
Project project = null;
PartnerMaster partner = null;
BinaryMaster binary = null;
if (subTitle.indexOf("${Project Name}") > -1) {
String _s = "";
if (!isEmpty(bean.getParamPrjId())) {
project = mailManagerMapper.getProjectInfoById(bean.getParamPrjId());
}
if (project != null) {
if (subTitle.indexOf("${Project Name}") > -1) {
if (subTitle.indexOf("${Project ID}") < 0) {
_s += "(" + bean.getParamPrjId() +")";
}
_s += project.getPrjName();
if (!isEmpty(project.getPrjVersion())) {
_s += " (" + project.getPrjVersion() +")";
}
}
}
subTitle = StringUtil.replace(subTitle, "${Project Name}", _s);
if (subTitle.indexOf("${Project Name}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Project Name}", _s);
}
}
if (subTitle.indexOf("${Project ID}") > -1) {
String _s = avoidNull(bean.getParamPrjId());
subTitle = StringUtil.replace(subTitle, "${Project ID}", _s);
if (subTitle.indexOf("${Project ID}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Project ID}", _s);
}
}
if (subTitle.indexOf("${3rd Party Name}") > -1) {
String _s = "";
if (!isEmpty(bean.getParamPartnerId())) {
partner = mailManagerMapper.getPartnerInfo(bean.getParamPartnerId());
}
if (partner != null) {
if (subTitle.indexOf("${3rd Party Name}") > -1) {
if (subTitle.indexOf("${3rd Party ID}") < 0) {
_s += "(" + partner.getPartnerId() +")";
}
_s += partner.getPartnerName();
}
}
subTitle = StringUtil.replace(subTitle, "${3rd Party Name}", _s);
if (subTitle.indexOf("${3rd Party Name}") > -1) {
subTitle = StringUtil.replace(subTitle, "${3rd Party Name}", _s);
}
}
if (subTitle.indexOf("${3rd Party ID}") > -1) {
String _s = avoidNull(bean.getParamPartnerId());
subTitle = StringUtil.replace(subTitle, "${3rd Party ID}", _s);
if (subTitle.indexOf("${3rd Party ID}") > -1) {
subTitle = StringUtil.replace(subTitle, "${3rd Party ID}", _s);
}
}
if (subTitle.indexOf("${SelfCheck Project Name}") > -1) {
String _s = "";
if (!isEmpty(bean.getParamPrjId())) {
project = mailManagerMapper.getSelfCheckProjectInfoById(bean.getParamPrjId());
}
if (project != null) {
if (subTitle.indexOf("${SelfCheck Project Name}") > -1) {
_s += "(" + bean.getParamPrjId() +")"; // SelfCheck project ID
_s += project.getPrjName(); // SelfCheck Project Name
if (!isEmpty(project.getPrjVersion())) { // SelfCheck Project Version
_s += " (" + project.getPrjVersion() +")";
}
}
}
subTitle = StringUtil.replace(subTitle, "${SelfCheck Project Name}", _s);
if (subTitle.indexOf("${SelfCheck Project Name}") > -1) {
subTitle = StringUtil.replace(subTitle, "${SelfCheck Project Name}", _s);
}
}
if (subTitle.indexOf("${Binary Name}") > -1) {
String _s = "";
if (!isEmpty(bean.getParamPrjId())) {
binary = mailManagerMapper.getBinaryInfo(bean.getParamBatId());
}
if (binary != null) {
if (subTitle.indexOf("${Binary Name}") > -1) {
if (subTitle.indexOf("${Binary ID}") < 0) {
_s += "(" + binary.getBatId() +")";
}
_s += binary.getBinaryFileName();
}
}
subTitle = StringUtil.replace(subTitle, "${Binary Name}", _s);
if (subTitle.indexOf("${Binary Name}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Binary Name}", _s);
}
}
if (subTitle.indexOf("${Binary ID}") > -1) {
String _s = avoidNull(bean.getParamBatId());
subTitle = StringUtil.replace(subTitle, "${Binary ID}", _s);
if (subTitle.indexOf("${Binary ID}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Binary ID}", _s);
}
}
if (subTitle.indexOf("${Email}") > -1) {
String _convEmail = avoidNull(bean.getParamEmail());
subTitle = StringUtil.replace(subTitle, "${Email}", _convEmail);
}
if (subTitle.indexOf("${User}") > -1) {
String _convUser = avoidNull(makeUserNameFormatWithDivision(!isEmpty(bean.getParamUserId()) ? bean.getParamUserId() : bean.getLoginUserName()));
subTitle = StringUtil.replace(subTitle, "${User}", _convUser);
if (subTitle.indexOf("${User}") > -1) {
subTitle = StringUtil.replace(subTitle, "${User}", _convUser);
}
}
if (subTitle.indexOf("${Stage}") > -1) {
String _stage = avoidNull(bean.getStage());
subTitle = StringUtil.replace(subTitle, "${Stage}", _stage);
}
convertDataMap.put("contentsSubTitle", subTitle);
}
} else if (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE.equals(bean.getMsgType())) {
if (!isEmpty(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_TYPE, bean.getMsgType()))) {
String subTitle = avoidNull(CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_TYPE, bean.getMsgType()));
if (subTitle.indexOf("${Param1}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Param1}", avoidNull(bean.getParamExpansion1()));
}
if (subTitle.indexOf("${Param2}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Param2}", avoidNull(bean.getParamExpansion2()));
}
if (subTitle.indexOf("${Param3}") > -1) {
subTitle = StringUtil.replace(subTitle, "${Param3}", avoidNull(bean.getParamExpansion3()));
}
convertDataMap.put("contentsSubTitle", subTitle);
}
} else if (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE.equals(bean.getMsgType()) && !isEmpty(bean.getParamExpansion1())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_FILE.equals(bean.getMsgType()) && !isEmpty(bean.getParamExpansion1())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_DESCRIPTION.equals(bean.getMsgType()) && !isEmpty(bean.getParamExpansion1())) {
String subTitle = "";
subTitle += "<br>" + bean.getParamExpansion1();
if (!isEmpty(bean.getParamExpansion2())) {
subTitle += bean.getParamExpansion2();
}
if (!isEmpty(bean.getParamExpansion3())) {
subTitle += bean.getParamExpansion3();
}
convertDataMap.put("contentsSubTitle", subTitle);
}
}
// mail Template
String msgContents = getVelocityTemplateContent(getTemplateFilePath(bean.getMsgType()), convertDataMap);
if (isEmpty(msgContents)) {
throw new Exception("Can not convert mail contents Email Type : " + bean.getMsgType());
}
bean.setEmlMessage(msgContents);
// title
title = title.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>", "");
bean.setEmlTitle(title);
Project prjInfo = null;
PartnerMaster partnerInfo = null;
BinaryMaster batInfo = null;
List<String> watcherList = null;
List<String> ccList = null;
List<String> toList = null;
switch (bean.getMsgType()) {
case CoConstDef.CD_MAIL_TYPE_OSS_REGIST:
case CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION:
case CoConstDef.CD_MAIL_TYPE_OSS_UPDATE:
case CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE:
case CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME:
case CoConstDef.CD_MAIL_TYPE_OSS_RENAME:
case CoConstDef.CD_MAIL_TYPE_OSS_DELETE:
case CoConstDef.CD_MAIL_TYPE_OSS_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_LICENSE_REGIST:
case CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE:
case CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME:
case CoConstDef.CD_MAIL_TYPE_LICENSE_DELETE:
case CoConstDef.CD_MAIL_TYPE_LICENSE_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_OSS_DEACTIVATED:
case CoConstDef.CD_MAIL_TYPE_OSS_ACTIVATED:
// Set creator to sender and cc the other Admin users
bean.setToIds(selectMailAddrFromIds(new String[]{bean.getLoginUserName()}));
bean.setCcIds(selectAdminMailAddr());
break;
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_OSS:
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED_ALL:
case CoConstDef.CD_MAIL_TYPE_CHANGED_USER_INFO:
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_NVDINFO_DIFF:
bean.setToIds(selectAdminMailAddr());
break;
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REQ_REVIEW:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REQ_REVIEW:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF:
case CoConstDef.CD_MAIL_TYPE_BIN_PROJECT_IDENTIFICATION_CONF:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CANCELED_CONF:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REJECT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_SELF_REJECT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CONF:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CANCELED_CONF:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REJECT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_SELF_REJECT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_RESERVED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_CANCELED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DELETED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_FILE:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_DESCRIPTION:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_REJECT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_FAILED:
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT:
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED:
case CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_ADDED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_ADDED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_ADDED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_ADDED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_ADD:
case CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_CHANGED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DELETED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY:
case CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_COMFIRMED_ONLY:
case CoConstDef.CD_MAIL_TYPE_PROJECT_CHANGED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_COPIED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_COMPLETED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_DROPPED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_REOPENED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_CREATED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED:
case CoConstDef.CD_MAIL_TYPE_PROJECT_REQUESTTOOPEN_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_BINARY_DATA_COMMIT:
// to : project creator + cc : watcher + reviewer
prjInfo = mailManagerMapper.getProjectInfo(bean.getParamPrjId());
if (CoConstDef.CD_MAIL_TYPE_PROJECT_MODIFIED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_MODIFIED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_MODIFIED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_MODIFIED_COMMENT.equals(bean.getMsgType())
) {
toList = new ArrayList<>();
ccList = new ArrayList<>();
// ๋ก๊ทธ์ธ ์ฌ์ฉ์๊ฐ Admin์ด๋ฉด to : project creator cc: reviewer, watcher
if (CommonFunction.isAdmin()) {
toList.addAll(mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId())); // creator๋ฅผ ํฌํจํ๊ณ ์์
if (!isEmpty(prjInfo.getReviewer())) {
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
ccList.addAll(Arrays.asList(selectAdminMailAddr()));
}
} else {
ccList.addAll(mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId())); // creator๋ฅผ ํฌํจํ๊ณ ์์
if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
}
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_ADDED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_ADDED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_ADDED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_ADDED_COMMENT.equals(bean.getMsgType())) {
// comment send์ ๊ฒฝ์ฐ, ์ผ๋จ ์์ ์ cc๋ก ๋ณด๋ธ๋ค.
toList = new ArrayList<>();
ccList = new ArrayList<>();
if ("W".equals(bean.getReceiveFlag())) {
watcherList = mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId());
if (watcherList != null && !watcherList.isEmpty()) {
toList.addAll(watcherList);
} else {
// watcher๊ฐ ์ค์ ๋์ด ์์ง ์์ ๊ฒฝ์ฐ, ๊ทธ๋ฅ ์์ ์๊ฒ ๋ณด๋ธ๋ค
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
} else if ("R".equals(bean.getReceiveFlag())) {
if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
} else if ("C".equals(bean.getReceiveFlag())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getCreator()})));
} else if ("WR".equals(bean.getReceiveFlag())) {
watcherList = mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId());
if (watcherList != null && !watcherList.isEmpty()) {
toList.addAll(watcherList);
} else {
// watcher๊ฐ ์ค์ ๋์ด ์์ง ์์ ๊ฒฝ์ฐ, ๊ทธ๋ฅ ์์ ์๊ฒ ๋ณด๋ธ๋ค
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
} else {
ccList = new ArrayList<>();
toList = new ArrayList<>();
// to ์ค์ -------------------------------------
// Reviewer
if (CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_ADD.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_CHANGED.equals(bean.getMsgType())) {
if (bean.getToIds() != null && bean.getToIds().length > 0) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(bean.getToIds())));
} else if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
}
} else if (CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_RESERVED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_CANCELED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_FILE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_DESCRIPTION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_FAILED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REQUESTTOOPEN_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_BINARY_DATA_COMMIT.equals(bean.getMsgType())
) {
if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
// Creator, watcher, Reviewer
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_COPIED.equals(bean.getMsgType())
){
if (!bean.isToIdsCheckDivision()) {
toList.addAll(mailManagerMapper.setProjectWatcherMailList(bean.getParamPrjId())); // creator๋ฅผ ํฌํจํ๊ณ ์์
} else {
toList.addAll(mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId()));
}
if (!isEmpty(prjInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
// Creator, watcher
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_CREATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BIN_PROJECT_IDENTIFICATION_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_COMFIRMED_ONLY.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_COMPLETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DROPPED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REOPENED.equals(bean.getMsgType())
) {
toList.addAll(mailManagerMapper.setProjectWatcherMailListNotCheckDivision(bean.getParamPrjId())); // creator๋ฅผ ํฌํจ
}
// Creator only
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED.equals(bean.getMsgType())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getCreator()})));
}
// cc ์ค์ ------------------------------------
if (CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_ADD.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_RESERVED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_CANCELED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_FILE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_DESCRIPTION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_FAILED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REQUESTTOOPEN_COMMENT.equals(bean.getMsgType())
) {
ccList.addAll(mailManagerMapper.setProjectWatcherMailList(bean.getParamPrjId()));
if (CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_ADD.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REVIEWER_CHANGED.equals(bean.getMsgType())){
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
}
// admin all
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_CREATED.equals(bean.getMsgType())) {
ccList.addAll(Arrays.asList(selectAdminMailAddr()));
}
// Reviewer
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BIN_PROJECT_IDENTIFICATION_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_ADDED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_PACKAGING_COMFIRMED_ONLY.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_ADDED_COMMENT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_COMPLETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DROPPED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_REOPENED.equals(bean.getMsgType())
) {
if (!isEmpty(prjInfo.getReviewer())) {
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{prjInfo.getReviewer()})));
} else {
ccList.addAll(Arrays.asList(selectAdminMailAddr()));
}
// Secuirty ํํธ ์ถ๊ฐ
if (!isTest &&
(
CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_RECALCULATED.equals(bean.getMsgType()))
|| CoConstDef.CD_MAIL_TYPE_VULNERABILITY_PROJECT_REMOVE_RECALCULATED.equals(bean.getMsgType())) {
ccList.addAll(Arrays.asList(MAIL_LIST_SECURITY));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
}
break;
case CoConstDef.CD_MAIL_TYPE_PARTER_REQ_REVIEW:
case CoConstDef.CD_MAIL_TYPE_PARTER_CONF:
case CoConstDef.CD_MAIL_TYPE_PARTER_CANCELED_CONF:
case CoConstDef.CD_MAIL_TYPE_PARTER_REJECT:
case CoConstDef.CD_MAIL_TYPE_PARTER_SELF_REJECT:
case CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_CHANGED:
case CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_TO_CHANGED:
case CoConstDef.CD_MAIL_TYPE_PARTNER_CHANGED:
case CoConstDef.CD_MAIL_TYPE_PARTER_ADDED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PARTER_DELETED:
case CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED:
case CoConstDef.CD_MAIL_TYPE_PARTER_MODIFIED_COMMENT:
case CoConstDef.CD_MAIL_TYPE_PARTNER_BINARY_DATA_COMMIT:
// to : creator + cc : watcher + reviewer
partnerInfo = mailManagerMapper.getPartnerInfo(bean.getParamPartnerId());
if (CoConstDef.CD_MAIL_TYPE_PARTER_MODIFIED_COMMENT.equals(bean.getMsgType())) {
toList = new ArrayList<>();
ccList = new ArrayList<>();
// ๋ก๊ทธ์ธ ์ฌ์ฉ์๊ฐ Admin์ด๋ฉด to : project creator cc: reviewer, watcher
if (CommonFunction.isAdmin()) {
toList.addAll(mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId())); // creator๋ฅผ ํฌํจํ๊ณ ์์
if (!isEmpty(partnerInfo.getReviewer())) {
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
ccList.addAll(Arrays.asList(selectAdminMailAddr()));
}
} else {
ccList.addAll(mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId())); // creator๋ฅผ ํฌํจํ๊ณ ์์
if (!isEmpty(partnerInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
}
else if (CoConstDef.CD_MAIL_TYPE_PARTER_ADDED_COMMENT.equals(bean.getMsgType())) {
// comment send์ ๊ฒฝ์ฐ, ์ผ๋จ ์์ ์ cc๋ก ๋ณด๋ธ๋ค.
toList = new ArrayList<>();
ccList = new ArrayList<>();
if ("W".equals(bean.getReceiveFlag())) {
watcherList = mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId());
if (watcherList != null && !watcherList.isEmpty()) {
toList.addAll(watcherList);
} else {
// watcher๊ฐ ์ค์ ๋์ด ์์ง ์์ ๊ฒฝ์ฐ, ๊ทธ๋ฅ ์์ ์๊ฒ ๋ณด๋ธ๋ค
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
} else if ("R".equals(bean.getReceiveFlag())) {
if (!isEmpty(partnerInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
} else if ("C".equals(bean.getReceiveFlag())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getCreator()})));
} else if ("WR".equals(bean.getReceiveFlag())) {
watcherList = mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId());
if (watcherList != null && !watcherList.isEmpty()) {
toList.addAll(watcherList);
} else {
// watcher๊ฐ ์ค์ ๋์ด ์์ง ์์ ๊ฒฝ์ฐ, ๊ทธ๋ฅ ์์ ์๊ฒ ๋ณด๋ธ๋ค
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
if (!isEmpty(partnerInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
} else {
ccList = new ArrayList<>();
toList = new ArrayList<>();
// to list ------------------------------------------------------------
// reviewer
if (CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_TO_CHANGED.equals(bean.getMsgType())) {
if (bean.getToIds() != null && bean.getToIds().length > 0) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(bean.getToIds())));
} else if (!isEmpty(partnerInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
}
}
// Reviewer
if (CoConstDef.CD_MAIL_TYPE_PARTER_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTNER_BINARY_DATA_COMMIT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTNER_CHANGED.equals(bean.getMsgType())
) {
if (!isEmpty(partnerInfo.getReviewer())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
toList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
// creator, watcher
else if (CoConstDef.CD_MAIL_TYPE_PARTER_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTNER_CHANGED.equals(bean.getMsgType())
) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getCreator()})));
toList.addAll(mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId()));
}
// Creator only
else if (CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED.equals(bean.getMsgType())) {
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getCreator()})));
}
// cc -----------------------------------------------------------------------
// Creator, Watcher
if (CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_TO_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REQ_REVIEW.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_SELF_REJECT.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_DELETED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED.equals(bean.getMsgType())
) {
ccList.addAll(mailManagerMapper.setPartnerWatcherMailList(bean.getParamPartnerId()));
if (CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_CHANGED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REVIEWER_TO_CHANGED.equals(bean.getMsgType())) {
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{bean.getLoginUserName()})));
}
}
// Reviwer
else if (CoConstDef.CD_MAIL_TYPE_PARTER_CANCELED_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_CONF.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_REJECT.equals(bean.getMsgType())
) {
if (!isEmpty(partnerInfo.getReviewer())) {
ccList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{partnerInfo.getReviewer()})));
} else {
ccList.addAll(Arrays.asList(selectAdminMailAddr()));
}
}
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
}
break;
case CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_REGISTED:
batInfo = mailManagerMapper.getBinaryInfo(bean.getParamBatId());
ccList = new ArrayList<>();
toList = new ArrayList<>();
// to list ------------------------------------------------------------
// Creator only
toList.addAll(Arrays.asList(selectMailAddrFromIds(new String[]{batInfo.getCreator()})));
// cc -----------------------------------------------------------------------
// Creator, Watcher
ccList.addAll(mailManagerMapper.binaryWatcherMailList(bean.getParamBatId()));
if (toList != null && !toList.isEmpty()) {
bean.setToIds(toList.toArray(new String[toList.size()]));
}
if (ccList != null && !ccList.isEmpty()) {
bean.setCcIds(ccList.toArray(new String[ccList.size()]));
}
break;
case CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_INVATED:
case CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_INVATED:
case CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_INVATED:
case CoConstDef.CD_MAIL_TYPE_SELFCHECK_PROJECT_WATCHER_INVATED:
bean.setToIds(new String[]{bean.getParamEmail()});
bean.setCcIds(selectMailAddrFromIds(new String[]{bean.getLoginUserName()}));
break;
default:
// ํธ์ถํ๋ ์ชฝ์์ ์ค์ ๋ ๊ฒฝ์ฐ
if (bean.getToIds() != null && bean.getToIds().length > 0) {
bean.setToIds(selectMailAddrFromIds(bean.getToIds()));
}
if (bean.getCcIds() != null && bean.getCcIds().length > 0) {
bean.setCcIds(selectMailAddrFromIds(bean.getCcIds()));
}
if (bean.getBccIds() != null && bean.getBccIds().length > 0) {
bean.setBccIds(selectMailAddrFromIds(bean.getBccIds()));
}
break;
}
// BAT ๋ถ์ ์คํจ์ Admin ๋ด๋น์ bcc ์ถ๊ฐ
if (CoConstDef.CD_MAIL_TYPE_BAT_ERROR.equals(bean.getMsgType())) {
bean.setBccIds(BAT_FAILED_BCC);
}
if ((Boolean) convertDataMap.get("isModify")
&& !isEmpty(bean.getComment())
&& ( CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME.equals(bean.getMsgType()))) {
convertDataMap.put("isModify", false);
}
if (!(Boolean) convertDataMap.get("isModify")){
// ์์ ์ ์ค๋ณต๋ฌธ์ ์์
try {
List<String> _toList = null;
List<String> _ccList = null;
if (bean.getToIds() != null) {
_toList = Arrays.asList(bean.getToIds());
} else {
_toList = new ArrayList<>();
}
if (bean.getCcIds() != null) {
_ccList = Arrays.asList(bean.getCcIds());
} else {
_ccList = new ArrayList<>();
}
// ์ผ๋จ ์๊ธฐ์์ ์ ์ค๋ณต๋๊ฒ ์์ผ๋ฉด ์ญ์
List<String> _toListFinal = new ArrayList<String>(new HashSet<String>(_toList));
List<String> _ccListFinal = new ArrayList<>();
List<String> _ccListTmp = new ArrayList<String>(new HashSet<String>(_ccList));
// tolist๋ฅผ ๊ธฐ์ค์ผ๋ก cclist์์ ์ญ์
for (String s : _ccListTmp) {
if (!_toListFinal.contains(s)) {
_ccListFinal.add(s);
}
}
// ๋ค์ array๋ก
bean.setToIds(_toListFinal.toArray(new String[_toListFinal.size()]));
bean.setCcIds(_ccListFinal.toArray(new String[_ccListFinal.size()]));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
mailManagerMapper.insertEmailHistory(bean);
// ๋ฐ์ก์ฒ๋ฆฌ
new Thread(() -> sendEmail(bean)).start();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
procResult = false;
}
return procResult;
}
private Object convertCodePartnerBaiscInfo(Object bean) {
PartnerMaster convBean = (PartnerMaster) bean;
// creator
if (!isEmpty(convBean.getCreator())) {
convBean.setCreator(makeUserNameFormatWithDivision(convBean.getCreator()));
}
if (!isEmpty(convBean.getDivision())) {
convBean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, convBean.getDivision()));
}
// reviewer
if (!isEmpty(convBean.getReviewer())) {
convBean.setReviewer(makeUserNameFormatWithDivision(convBean.getReviewer()));
}
return convBean;
}
private Object convertCodeProjectBaiscInfo(Object bean) {
Project convBean = (Project) bean;
// opertating system
convBean.setOsType(CoConstDef.COMMON_SELECTED_ETC.equals(convBean.getOsType()) ? convBean.getOsTypeEtc() : CoCodeManager.getCodeString(CoConstDef.CD_OS_TYPE, convBean.getOsType()));
// distribution type
convBean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, convBean.getDistributionType()));
// distribution site
convBean.setDistributeTarget(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_CODE, convBean.getDistributeTarget()));
// due date
// modified date
if (!isEmpty(convBean.getModifiedDate())) {
convBean.setModifiedDate(DateUtil.dateFormatConvert(convBean.getModifiedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
// modifier
if (!isEmpty(convBean.getModifier())) {
convBean.setModifier(makeUserNameFormatWithDivision(convBean.getModifier()));
}
// reviewer
if (!isEmpty(convBean.getReviewer())) {
convBean.setReviewer(makeUserNameFormatWithDivision(convBean.getReviewer()));
}
// created date
if (!isEmpty(convBean.getCreatedDate())) {
convBean.setCreatedDate(DateUtil.dateFormatConvert(convBean.getCreatedDate(), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
// creator
if (!isEmpty(convBean.getCreator())) {
convBean.setCreator(makeUserNameFormatWithDivision(convBean.getCreator()));
}
String noticeTypeEtc = null;
if (!isEmpty(convBean.getNoticeTypeEtc())) {
noticeTypeEtc = " (" +CoCodeManager.getCodeString(CoConstDef.CD_PLATFORM_GENERATED, convBean.getNoticeTypeEtc()) + ")";
}
if (!isEmpty(convBean.getNoticeType())) {
String noticeType = CoCodeManager.getCodeString(CoConstDef.CD_NOTICE_TYPE, convBean.getNoticeType());
if (!isEmpty(noticeTypeEtc)) {
noticeType += noticeTypeEtc;
}
convBean.setNoticeType(noticeType);
}
if (!isEmpty(convBean.getPriority())) {
convBean.setPriority(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, convBean.getPriority()));
}
if (!isEmpty(convBean.getDivision())) {
convBean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, convBean.getDivision()));
}
return convBean;
}
private String makeMailSubject(String title, CoMail bean) {
return makeMailSubject(title, bean, false);
}
// 1) ${User}
// 2) ${OSS Name}
// 3) ${License Name}
// 4) ${Project Name}
/**
* 1) ${User}
* 2) ${OSS Name}
* 3) ${License Name}
* 4) ${Creator}
* 5) ${Reviewer}
*
* @param title
* @param bean
* @return
*/
private String makeMailSubject(String title, CoMail bean, boolean isMailBodySubject) {
if (title.indexOf("${User}") > -1) {
if (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_COMPLETE.equals(bean.getMsgType())) { // ์์ฝํ ์ฌ์ฉ์๋ช
์ผ๋ก ์นํํด์ผํจ
if ("BATCH".equals(bean.getJobType())) {
title = StringUtil.replace(title, "${User}", avoidNull(makeUserNameFormat(avoidNull(mailManagerMapper.getDistributeReservedUser(bean.getParamPrjId()), bean.getLoginUserName()) )));
} else {
title = StringUtil.replace(title, "${User}", avoidNull(makeUserNameFormat(bean.getLoginUserName())));
}
}
else if (CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PARTER_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_BAT_WATCHER_REGISTED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TOKEN_CREATE_TYPE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TOKEN_DELETE_TYPE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_SELFCHECK_PROJECT_WATCHER_INVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_RESET_USER_PASSWORD.equals(bean.getMsgType())) {
String _convUser = avoidNull(makeUserNameFormat(!isEmpty(bean.getParamUserId()) ? bean.getParamUserId() : bean.getLoginUserName()));
title = StringUtil.replace(title, "${User}", _convUser);
if (title.indexOf("${User}") > -1) {
title = StringUtil.replace(title, "${User}", _convUser);
}
}
else {
title = StringUtil.replace(title, "${User}", avoidNull(makeUserNameFormat(bean.getLoginUserName())));
}
}
if (title.indexOf("${OSS Name}") > -1) {
String _s = "";
OssMaster ossInfo = null;
// rename์ธ ๊ฒฝ์ฐ
// oss name = after oss
// before oss name = before oss
if (CoConstDef.CD_MAIL_TYPE_OSS_RENAME.equals(bean.getMsgType())) {
ossInfo = (OssMaster) bean.getCompareDataAfter();
}
else if (!isEmpty(bean.getParamOssId())) {
ossInfo = mailManagerMapper.getOssInfoById(bean.getParamOssId());
}
if (ossInfo != null) {
if (title.indexOf("${OSS ID}") < 0) {
_s += "(" + bean.getParamOssId() +")";
}
_s += ossInfo.getOssName();
// Admin์๊ฒ๋ง ๋ฐ์ก๋๋ oss ๊ด๋ จ ๋ฉ์ผ์ ๊ฒฝ์ฐ ๋ฐ๋ก๊ฐ๊ธฐ link ํ์์ผ๋ก ๋ฐ์ก
if (isMailBodySubject
&& (
CoConstDef.CD_MAIL_TYPE_OSS_REGIST.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_DEACTIVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_ACTIVATED.equals(bean.getMsgType())
)
)
{
String linkUrl = CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org");
linkUrl += "/oss/list/" + ossInfo.getOssName();
_s = "<a href='" + linkUrl + "' style='font-size:16px;' target='_blank'>" + _s + "</a>";
if (!isEmpty(ossInfo.getOssVersion())) {
_s += " (" + ossInfo.getOssVersion() +")";
}
}
}
title = StringUtil.replace(title, "${OSS Name}", _s);
}
if (title.indexOf("${OSS ID}") > -1) {
if (isMailBodySubject
&& (
CoConstDef.CD_MAIL_TYPE_OSS_REGIST.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_DEACTIVATED.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_OSS_ACTIVATED.equals(bean.getMsgType())
)
)
{
String _s = "OSS-" + avoidNull(bean.getParamOssId());
String linkUrl = CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org");
linkUrl += "/oss/edit/" + bean.getParamOssId();
_s = "<a href='"+linkUrl+"' style='font-size:16px;' target='_blank'>" + _s + "</a>";
title = StringUtil.replace(title, "OSS-${OSS ID}", _s);
} else {
title = StringUtil.replace(title, "${OSS ID}", avoidNull(bean.getParamOssId()));
}
}
// ์ญ์ ๋ ์ด๋ฉ์ผ์ ๋ํ ์ ๋ณด
if (title.indexOf("${OSS Before Name}") > -1) {
String _s = "";
OssMaster ossInfo = null;
if (bean.getCompareDataBefore() != null) {
ossInfo = (OssMaster) bean.getCompareDataBefore();
}
if (ossInfo != null) {
_s += ossInfo.getOssName();
if (!isEmpty(ossInfo.getOssVersion())) {
_s += " (" + ossInfo.getOssVersion() +")";
}
}
title = StringUtil.replace(title, "${OSS Before Name}", _s);
}
if (title.indexOf("${License Name}") > -1) {
String _s = "";
LicenseMaster licenseInfo = null;
if (!isEmpty(bean.getParamLicenseId())) {
licenseInfo = mailManagerMapper.getLicenseInfoById(bean.getParamLicenseId());
}
if (licenseInfo != null) {
if (title.indexOf("${License ID}") < 0) {
_s += "(" + bean.getParamLicenseId() +")";
}
_s += licenseInfo.getLicenseName();
}
if (isMailBodySubject
&& (CoConstDef.CD_MAIL_TYPE_LICENSE_REGIST.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE_TYPE.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_LICENSE_MODIFIED_COMMENT.equals(bean.getMsgType())
)) {
String linkUrl = CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org");
linkUrl += "/license/edit/" + bean.getParamLicenseId();
_s = "<a href='" + linkUrl + "' target='_blank'>" + _s + "</a>";
}
title = StringUtil.replace(title, "${License Name}", _s);
}
if (title.indexOf("${License ID}") > -1) {
title = StringUtil.replace(title, "${License ID}", avoidNull(bean.getParamLicenseId()));
}
if (title.indexOf("${License Before Name}") > -1) {
String _s = "";
LicenseMaster licenseInfo = null;
if (bean.getCompareDataBefore() != null) {
licenseInfo = (LicenseMaster) bean.getCompareDataBefore();
}
if (licenseInfo != null) {
_s += licenseInfo.getLicenseName();
}
title = StringUtil.replace(title, "${License Before Name}", _s);
}
if (title.indexOf("${Project Name}") > -1) {
String _s = "";
String _s2 = "";
String _s3 = "";
String _s4 = "";
String _s5 = "";
Project project = null;
if (!isEmpty(bean.getParamPrjId())) {
project = mailManagerMapper.getProjectInfoById(bean.getParamPrjId());
}
if (project != null) {
if (title.indexOf("${Project Name}") > -1) {
if (title.indexOf("${Project ID}") < 0) {
_s += "(" + bean.getParamPrjId() +")";
}
_s += project.getPrjName();
if (!isEmpty(project.getPrjVersion())) {
_s += " (" + project.getPrjVersion() +")";
}
String url = CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org") + "/project/view/" + bean.getParamPrjId();
_s = "<a href='"+url+"' target='_blank'>" + _s + "</a>";
}
if (title.indexOf("${Creator}") > -1) {
_s2 = avoidNull(makeUserNameFormat(project.getCreator()));
}
if (title.indexOf("${ReviewerTo}") == -1
&& title.indexOf("${Reviewer}") > -1
&& !isEmpty(project.getReviewer())) {
_s3 = avoidNull(makeUserNameFormat(project.getReviewer()));
}
if (title.indexOf("${LastDistributor}") > -1) {
if (!isEmpty(project.getDistributeDeployUser())) {
_s4 = avoidNull(makeUserNameFormat(project.getDistributeDeployUser()));
} else {
_s4 = avoidNull(makeUserNameFormat(project.getCreator()));
}
}
if (title.indexOf("${Rejector}") > -1 && !isEmpty(project.getDistributeRejector())) {
_s5 = avoidNull(makeUserNameFormat(project.getDistributeRejector()));
}
}
if (title.indexOf("${Project Name}") > -1) {
title = StringUtil.replace(title, "${Project Name}", _s);
}
if (title.indexOf("${Creator}") > -1) {
title = StringUtil.replace(title, "${Creator}", _s2);
}
if (title.indexOf("${ReviewerTo}") > -1) {
String[] toIds = bean.getToIds();
title = StringUtil.replace(title, "${Reviewer}", avoidNull(makeUserNameFormat(toIds[0])));
title = StringUtil.replace(title, "${ReviewerTo}", avoidNull(makeUserNameFormat(toIds[1])));
}
if (title.indexOf("${ReviewerTo}") == -1 && title.indexOf("${Reviewer}") > -1) {
title = StringUtil.replace(title, "${Reviewer}", _s3);
}
if (title.indexOf("${LastDistributor}") > -1) {
title = StringUtil.replace(title, "${LastDistributor}", _s4);
}
if (title.indexOf("${Rejector}") > -1) {
title = StringUtil.replace(title, "${Rejector}", _s5);
}
if (title.indexOf("${Project ID}") > -1) {
title = StringUtil.replace(title, "${Project ID}", avoidNull(bean.getParamPrjId()));
}
}
if (title.indexOf("${3rd Party Name}") > -1) {
String _s = "";
String _s2 = "";
String _s3 = "";
PartnerMaster partnerInfo = null;
if (!isEmpty(bean.getParamPartnerId())) {
partnerInfo = mailManagerMapper.getPartnerInfo(bean.getParamPartnerId());
}
if (partnerInfo != null) {
if (title.indexOf("${3rd Party Name}") > -1) {
if (title.indexOf("${3rd Party ID}") < 0) {
_s += "(" + bean.getParamPartnerId() +")";
}
_s += partnerInfo.getPartnerName();
if (!isEmpty(partnerInfo.getSoftwareName())) {
_s += " (" + partnerInfo.getSoftwareName() +")";
}
String url = CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org") + "/partner/view/" + bean.getParamPartnerId();
_s = "<a href='" + url + "' target='_blank'>" + _s + "</a>";
}
if (title.indexOf("${Creator}") > -1) {
_s2 = avoidNull(makeUserNameFormat(partnerInfo.getCreator()));
}
if (title.indexOf("${Reviewer}") > -1 && !isEmpty(partnerInfo.getReviewer())) {
_s3 = avoidNull(makeUserNameFormat(partnerInfo.getReviewer()));
}
}
if (title.indexOf("${3rd Party Name}") > -1) {
title = StringUtil.replace(title, "${3rd Party Name}", _s);
}
if (title.indexOf("${Creator}") > -1) {
title = StringUtil.replace(title, "${Creator}", _s2);
}
if (title.indexOf("${Reviewer}") > -1 && title.indexOf("${ReviewerTo}") > -1) {
String[] toIds = bean.getToIds();
title = StringUtil.replace(title, "${Reviewer}", avoidNull(makeUserNameFormat(toIds[0])));
title = StringUtil.replace(title, "${ReviewerTo}", avoidNull(makeUserNameFormat(toIds[1])));
}
if (title.indexOf("${Reviewer}") > -1 && title.indexOf("${ReviewerTo}") == -1) {
title = StringUtil.replace(title, "${Reviewer}", _s3);
}
if (title.indexOf("${3rd Party ID}") > -1) {
title = StringUtil.replace(title, "${3rd Party ID}", avoidNull(bean.getParamPartnerId()));
}
}
if (title.indexOf("${Binary Name}") > -1) {
String _s = "";
BinaryMaster binaryInfo = null;
if (!isEmpty(bean.getParamBatId())) {
binaryInfo = mailManagerMapper.getBinaryInfo(bean.getParamBatId());
if (title.indexOf("${Binary ID}") < 0) {
_s = "(" + bean.getParamBatId() + ")";
}
}
if (binaryInfo != null) {
_s += binaryInfo.getBinaryFileName();
}
title = StringUtil.replace(title, "${Binary Name}", _s);
if (title.indexOf("${Binary ID}") > -1) {
title = StringUtil.replace(title, "${Binary ID}", avoidNull(bean.getParamBatId()));
}
}
if (title.indexOf("${Email}") > -1) {
String _convEmail = avoidNull(bean.getParamEmail());
title = StringUtil.replace(title, "${Email}", _convEmail);
}
if (title.indexOf("${Copied Project ID}") > -1) {
Project projectInfo = (Project) bean.getCompareDataBefore();
title = StringUtil.replace(title, "${Copied Project ID}", projectInfo.getPrjId());
title = StringUtil.replace(title, "${Copied Project Name}", projectInfo.getPrjName());
}
if (CoConstDef.CD_MAIL_PACKAGING_UPLOAD_SUCCESS.equals(bean.getMsgType())
|| CoConstDef.CD_MAIL_PACKAGING_UPLOAD_FAILURE.equals(bean.getMsgType())) {
if (title.indexOf("${File Name}") > -1) {
title = StringUtil.replace(title, "${File Name}", bean.getParamExpansion1()); // file name set
}
if (title.indexOf("${Project ID}") > -1) {
title = StringUtil.replace(title, "${Project ID}", bean.getParamPrjId());
}
}
if (title.indexOf("${BinaryCommitResult}") > -1) {
title = StringUtil.replace(title, "${BinaryCommitResult}", bean.getBinaryCommitResult());
}
return title;
}
private Map<String, Object> convertModifiedData(Map<String, Object> convertDataMap, String msgType) {
boolean isModified = false;
if (CoConstDef.CD_MAIL_TYPE_OSS_UPDATE.equals(msgType)
|| CoConstDef.CD_MAIL_TYPE_ADDNICKNAME_UPDATE.equals(msgType)
|| CoConstDef.CD_MAIL_TYPE_OSS_CHANGE_NAME.equals(msgType)
|| CoConstDef.CD_MAIL_TYPE_OSS_RENAME.equals(msgType)
) {
if (CoConstDef.CD_MAIL_TYPE_OSS_RENAME.equals(msgType)) {
isModified = true;
}
OssMaster before = (OssMaster) convertDataMap.get("before");
OssMaster after = (OssMaster) convertDataMap.get("after");
before.setCopyright(CommonFunction.htmlEscape(before.getCopyright()));
after.setCopyright(CommonFunction.htmlEscape(after.getCopyright()));
before.setSummaryDescription(CommonFunction.htmlEscape(before.getSummaryDescription()));
after.setSummaryDescription(CommonFunction.htmlEscape(after.getSummaryDescription()));
before.setAttribution(CommonFunction.htmlEscape(before.getAttribution()));
after.setAttribution(CommonFunction.htmlEscape(after.getAttribution()));
after.setOssName(appendChangeStyleMultiLine(before.getOssName(), after.getOssName()));
isModified = checkEquals(before.getOssName(), after.getOssName(), isModified);
if (before.getOssNicknames() != null || after.getOssNicknames() != null) {
List<String> _beforeList = before.getOssNicknames() == null ? new ArrayList<>() : Arrays.asList(before.getOssNicknames());
List<String> _afterList = after.getOssNicknames() == null ? new ArrayList<>() : Arrays.asList(after.getOssNicknames());
List<String> _newBeforeList = new ArrayList<>(_beforeList);
List<String> _newAfterList = new ArrayList<>(_afterList);
Collections.sort(_newBeforeList);
Collections.sort(_newAfterList);
List<String> addList = new ArrayList<>();
List<String> delList = new ArrayList<>();
// ์ญ์ ์ฌ๋ถ ์ฒดํฌ
for (String s : _newBeforeList) {
if (!isEmpty(s) && !_newAfterList.contains(s)) {
delList.add(s);
//_newAfterList.add(idx, "");
isModified = true;
}
}
// ์ถ๊ฐ ์ฌ๋ถ ์ฒดํฌ
for (String s : _newAfterList) {
if (!isEmpty(s) && !_newBeforeList.contains(s)) {
addList.add(s);
//_newBeforeList.add(idx, "");
isModified = true;
}
}
// ํ๋์ ํตํฉ list๋ก ๋ง๋ค์ด์ ์์ ์ ๋ ฌ
List<String> tmpList = _newBeforeList;
tmpList.addAll(_newAfterList);
List<String> mergeList = new ArrayList<>(new HashSet<String>(tmpList));
Collections.sort(mergeList);
List<String> _finalBeforeList = new ArrayList<>();
List<String> _finalAfterList = new ArrayList<>();
for (String s : mergeList) {
if (delList.contains(s)) {
_finalBeforeList.add(appendChangeStyleMultiLine(s, ""));
_finalAfterList.add("");
} else if (addList.contains(s)) {
_finalAfterList.add(appendChangeStyleMultiLine("", s));
_finalBeforeList.add("");
} else {
_finalBeforeList.add(s);
_finalAfterList.add(s);
}
}
String[] beforeArry = _finalBeforeList.toArray(new String[_finalBeforeList.size()]);
String[] afterArry = _finalAfterList.toArray(new String[_finalAfterList.size()]);
before.setOssNicknames(beforeArry);
after.setOssNicknames(afterArry);
}
after.setOssVersion(appendChangeStyleMultiLine(before.getOssVersion(), after.getOssVersion()));
isModified = checkEquals(before.getOssVersion(), after.getOssVersion(), isModified);
after.setLicenseName(appendChangeStyleMultiLine(before.getLicenseName(), after.getLicenseName()));
isModified = checkEquals(before.getLicenseName(), after.getLicenseName(), isModified);
if (CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_DIV, "M").equals(after.getLicenseDiv())){ // multi license์ผ๋ ๋ง
List<OssLicense> beforeLicenses = before.getOssLicenses();
List<OssLicense> afterLicenses = after.getOssLicenses();
int len = beforeLicenses.size() > afterLicenses.size() ? beforeLicenses.size() : afterLicenses.size();
for (int i = 0 ; i < len ; i++){
boolean isBefore = beforeLicenses.size() > i;
boolean isAfter = afterLicenses.size() > i;
if (isBefore && isAfter){ // ์์ ์
OssLicense beforeLicense = beforeLicenses.get(i);
OssLicense afterLicense = afterLicenses.get(i);
afterLicense.setOssLicenseComb(appendChangeStyle(beforeLicense.getOssLicenseComb(), afterLicense.getOssLicenseComb()));
afterLicense.setLicenseName(appendChangeStyle(beforeLicense.getLicenseName(), afterLicense.getLicenseName()));
afterLicense.setOssCopyright(appendChangeStyle(beforeLicense.getOssCopyright(), afterLicense.getOssCopyright()));
isModified = checkEquals(beforeLicense.getOssCopyright(), afterLicense.getOssCopyright(), isModified);
afterLicenses.set(i, afterLicense);
}else if (!isBefore && isAfter) { // ์ ๊ท ๋ฑ๋ก์
OssLicense afterLicense = afterLicenses.get(i);
afterLicense.setOssLicenseComb(appendChangeStyle("", afterLicense.getOssLicenseComb()));
afterLicense.setLicenseName(appendChangeStyle("", afterLicense.getLicenseName()));
afterLicense.setOssCopyright(appendChangeStyle("", afterLicense.getOssCopyright()));
isModified = checkEquals("", afterLicense.getOssCopyright(), isModified);
afterLicenses.set(i, afterLicense);
}else if (isBefore && !isAfter){ // ์ญ์ ์
OssLicense beforeLicense = beforeLicenses.get(i);
OssLicense afterLicense = new OssLicense();
afterLicense.setOssLicenseComb(appendChangeStyle(beforeLicense.getOssLicenseComb(), ""));
afterLicense.setLicenseName(appendChangeStyle(beforeLicense.getLicenseName(), ""));
afterLicense.setOssCopyright(appendChangeStyle(beforeLicense.getOssCopyright(), ""));
isModified = checkEquals(beforeLicense.getOssCopyright(), "", isModified);
afterLicenses.add(i, afterLicense);
}
}
}
after.setCopyright(appendChangeStyleMultiLine(before.getCopyright(), after.getCopyright(), true));
isModified = checkEquals(before.getCopyright(), after.getCopyright(), isModified);
before.setDownloadLocationLinkFormat(appendChangeStyleLinkFormatArray(before.getDownloadLocation()));
String[] beforeUrl = before.getDownloadLocation().split(",");
String[] afterUrl = after.getDownloadLocation().split(",");
String resultDownloadLocation = appendChangeStyleLinkFormatArray(beforeUrl, afterUrl, 0);
after.setDownloadLocationLinkFormat(resultDownloadLocation);
isModified = checkEquals(before.getDownloadLocation(), after.getDownloadLocation(), isModified);
before.setHomepageLinkFormat(appendChangeStyleLinkFormat(before.getHomepage()));
after.setHomepageLinkFormat(appendChangeStyleLinkFormat(before.getHomepage(), after.getHomepage()));
isModified = checkEquals(before.getHomepage(), after.getHomepage(), isModified);
after.setSummaryDescription(appendChangeStyleMultiLine(before.getSummaryDescription(), after.getSummaryDescription(), true));
isModified = checkEquals(before.getSummaryDescription(), after.getSummaryDescription(), isModified);
after.setAttribution(appendChangeStyleMultiLine(before.getAttribution(), after.getAttribution(), true));
isModified = checkEquals(before.getAttribution(), after.getAttribution(), isModified);
String beforeDetectedLicense = before.getDetectedLicense();
String afterDetectedLicense = after.getDetectedLicense();
if (!isEmpty(beforeDetectedLicense) || !isEmpty(afterDetectedLicense)) {
List<String> _beforeList = Arrays.asList(beforeDetectedLicense.split(","));
List<String> _afterList = Arrays.asList(afterDetectedLicense.split(","));
Collections.sort(_beforeList);
Collections.sort(_afterList);
List<String> addList = new ArrayList<>();
List<String> delList = new ArrayList<>();
// ์ญ์ ์ฌ๋ถ ์ฒดํฌ
for (String s : _beforeList) {
if (!isEmpty(s) && !_afterList.contains(s)) {
delList.add(s);
isModified = true;
}
}
// ์ถ๊ฐ ์ฌ๋ถ ์ฒดํฌ
for (String s : _afterList) {
if (!isEmpty(s) && !_beforeList.contains(s)) {
addList.add(s);
isModified = true;
}
}
if (_beforeList.size() != _afterList.size()) {
isModified = true;
}
// ํ๋์ ํตํฉ list๋ก ๋ง๋ค์ด์ ์์ ์ ๋ ฌ
List<String> tmpList = Stream.concat(_beforeList.stream(), _afterList.stream()).collect(Collectors.toList());
List<String> mergeList = new ArrayList<>(new HashSet<String>(tmpList));
Collections.sort(mergeList);
List<String> _finalBeforeList = new ArrayList<>();
List<String> _finalAfterList = new ArrayList<>();
for (String s : mergeList) {
if (!isEmpty(s)) {
if (delList.contains(s)) {
_finalBeforeList.add(appendChangeStyleMultiLine(s, ""));
} else if (addList.contains(s)) {
_finalAfterList.add(appendChangeStyleMultiLine("", s));
} else {
_finalBeforeList.add(s);
_finalAfterList.add(s);
}
}
}
before.clearDetectLicense();
after.clearDetectLicense();
before.addDetectedLicense(String.join(", ", _finalBeforeList));
after.addDetectedLicense(String.join(", ", _finalAfterList));
}
//๋ฐ์ดํฐ ๋ณ๊ฒฝ ์์์
if (!isModified){
convertDataMap.replace("isModify", true);
}
convertDataMap.replace("before", before);
convertDataMap.replace("after", after);
// oss modify
} else if (CoConstDef.CD_MAIL_TYPE_LICENSE_UPDATE.equals(msgType) || CoConstDef.CD_MAIL_TYPE_LICENSE_RENAME.equals(msgType)) {
// license modify
LicenseMaster before = (LicenseMaster) convertDataMap.get("before");
LicenseMaster after = (LicenseMaster) convertDataMap.get("after");
before.setDescription(CommonFunction.htmlEscape(before.getDescription()));
after.setDescription(CommonFunction.htmlEscape(after.getDescription()));
before.setAttribution(CommonFunction.htmlEscape(before.getAttribution()));
after.setAttribution(CommonFunction.htmlEscape(after.getAttribution()));
before.setLicenseText(CommonFunction.htmlEscape(before.getLicenseText()));
after.setLicenseText(CommonFunction.htmlEscape(after.getLicenseText()));
after.setLicenseName(appendChangeStyle(before.getLicenseName(), after.getLicenseName()));
isModified = checkEquals(before.getLicenseName(), after.getLicenseName(), isModified);
after.setShortIdentifier(appendChangeStyle(before.getShortIdentifier(), after.getShortIdentifier()));
isModified = checkEquals(before.getShortIdentifier(), after.getShortIdentifier(), isModified);
if (before.getLicenseNicknames() != null || after.getLicenseNicknames() != null) {
List<String> _beforeList = before.getLicenseNicknames() == null ? new ArrayList<>() : Arrays.asList(before.getLicenseNicknames());
List<String> _afterList = after.getLicenseNicknames() == null ? new ArrayList<>() : Arrays.asList(after.getLicenseNicknames());
List<String> _newBeforeList = new ArrayList<>(_beforeList);
List<String> _newAfterList = new ArrayList<>(_afterList);
Collections.sort(_beforeList);
Collections.sort(_afterList);
// ๊ฐฏ์๋ฅผ ๋ง์ถฐ์ ์ ๋ ฌ
if (_beforeList.size() < _afterList.size()) {
for (int i=_beforeList.size(); i<_afterList.size(); i++) {
_newBeforeList.add("");
}
} else if (_afterList.size() < _beforeList.size()) {
for (int i=_afterList.size(); i<_beforeList.size(); i++) {
_newAfterList.add("");
}
}
_beforeList = _newBeforeList;
_afterList = _newAfterList;
// delete case
for (int i=0; i<_beforeList.size(); i++) {
String s = _beforeList.get(i);
if (!isEmpty(s) && !s.equals(_afterList.get(i))) {
// ๋์ผํ position์ ๊ฐ์ด ๋ค๋ฅธ ๊ฒฝ์ฐ ์ญ์ ๋ก ํ๋จ
_newAfterList.add(i, "");
_newBeforeList.add(""); // size๋ฅผ ๋ง์ถฐ์ค๋ค.
}
}
_beforeList = _newBeforeList;
_afterList = _newAfterList;
// add
for (int i=0; i<_afterList.size(); i++) {
String s = _afterList.get(i);
if (!isEmpty(s) && !s.equals(_beforeList.get(i))) {
_newBeforeList.add(i, "");
appendChangeStyle(_newAfterList.get(i));
isModified = true;
_newAfterList.add("");
}
}
_beforeList = _newBeforeList;
_afterList = _newAfterList;
// before and after ๋ชจ๋ ๊ณต๋ฐฑ์ธ row๋ ์ญ์
for (int i=0; i<_beforeList.size(); i++) {
if (isEmpty(_beforeList.get(i)) && isEmpty(_afterList.get(i))) {
_newBeforeList.remove(i);
_newAfterList.remove(i);
}
}
for (int i=0; i<_newBeforeList.size(); i++) {
if (isEmpty(_newAfterList.get(i))){
_newBeforeList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}else{
_newAfterList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}
isModified = checkEquals(_newBeforeList.get(i), _newAfterList.get(i), isModified);
}
String[] beforeArry = _newBeforeList.toArray(new String[_newBeforeList.size()]);
String[] afterArry = _newAfterList.toArray(new String[_newAfterList.size()]);
before.setLicenseNicknames(beforeArry);
after.setLicenseNicknames(afterArry);
}
after.setLicenseType(appendChangeStyle(before.getLicenseType(), after.getLicenseType()));
isModified = checkEquals(before.getLicenseType(), after.getLicenseType(), isModified);
after.setObligation(appendChangeStyle(before.getObligation(), after.getObligation()));
isModified = checkEquals(before.getObligation(), after.getObligation(), isModified);
String[] beforeWebPage = isEmpty(before.getWebpage()) ? new String[0] : before.getWebpage().split(",");
String[] afterWebPage = isEmpty(after.getWebpage()) ? new String[0] : after.getWebpage().split(",");
String resultWebPage = appendChangeStyleLinkFormatArray(beforeWebPage, afterWebPage, 0);
after.setWebpageLinkFormat(resultWebPage);
isModified = checkEquals(before.getWebpage(), after.getWebpage(), isModified);
after.setDescription(appendChangeStyleMultiLine(before.getDescription(), after.getDescription(), true));
isModified = checkEquals(before.getDescription(), after.getDescription(), isModified);
after.setAttribution(appendChangeStyleMultiLine(before.getAttribution(), after.getAttribution(), true));
isModified = checkEquals(before.getAttribution(), after.getAttribution(), isModified);
after.setLicenseText(appendChangeStyleMultiLine(before.getLicenseText(), after.getLicenseText(), true));
isModified = checkEquals(before.getLicenseText(), after.getLicenseText(), isModified);
if (before.getRestriction() != null || after.getRestriction() != null) {
List<String> _beforeList = before.getRestriction() == null ? new ArrayList<>() : Arrays.asList(before.getRestriction().split(","));
List<String> _afterList = after.getRestriction() == null ? new ArrayList<>() : Arrays.asList(after.getRestriction().split(","));
List<String> _newBeforeList = new ArrayList<>();
List<String> _newAfterList = new ArrayList<>();
for (String cd : CoCodeManager.getCodes(CoConstDef.CD_LICENSE_RESTRICTION)) {
// ๋๋ค ์์ผ๋ฉด ๋ณ๊ฒฝ์ฌํญ ์์
if (!_beforeList.contains(cd) && !_afterList.contains(cd)) {
continue;
}
// add
if (!_beforeList.contains(cd) && _afterList.contains(cd)) {
_newBeforeList.add("");
_newAfterList.add(changeStyle(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, cd), "mod"));
isModified = true;
}
// delete
else if (_beforeList.contains(cd) && !_afterList.contains(cd)) {
_newBeforeList.add(changeStyle(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, cd), "del", true));
_newBeforeList.add("");
isModified = true;
}
// ๋ณ๊ฒฝ ์์
else {
_newBeforeList.add(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, cd));
_newAfterList.add(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, cd));
}
}
String[] beforeArry = _newBeforeList.toArray(new String[_newBeforeList.size()]);
String[] afterArry = _newAfterList.toArray(new String[_newAfterList.size()]);
before.setArrRestriction(beforeArry);
after.setArrRestriction(afterArry);
}
//๋ฐ์ดํฐ ๋ณ๊ฒฝ ์์์
if (!isModified){
convertDataMap.replace("isModify", true);
}
convertDataMap.replace("before", before);
convertDataMap.replace("after", after);
} else if (CoConstDef.CD_MAIL_TYPE_PROJECT_CHANGED.equals(msgType)||CoConstDef.CD_MAIL_TYPE_PROJECT_COPIED.equals(msgType)) {
// Project modify
Project before = (Project) convertDataMap.get("before");
Project after = (Project) convertDataMap.get("after");
isModified = checkEquals(before.getPrjName(), after.getPrjName(), isModified);
isModified = checkEquals(before.getPrjVersion(), after.getPrjVersion(), isModified);
isModified = checkEquals(before.getOsType(), after.getOsType(), isModified);
isModified = checkEquals(before.getDistributionType(), after.getDistributionType(), isModified);
isModified = checkEquals(before.getDistributeTarget(), after.getDistributeTarget(), isModified);
isModified = checkEquals(before.getComment(), after.getComment(), isModified);
isModified = checkEquals(before.getCreator(), after.getCreator(), isModified);
isModified = checkEquals(before.getNoticeType(), after.getNoticeType(), isModified);
isModified = checkEquals(before.getNetworkServerType(), after.getNetworkServerType(), isModified);
isModified = checkEquals(before.getPriority(), after.getPriority(), isModified);
isModified = checkEquals(before.getDivision(), after.getDivision(), isModified);
after.setPrjName(appendChangeStyle(before.getPrjName(), after.getPrjName()));
after.setPrjVersion(appendChangeStyle(before.getPrjVersion(), after.getPrjVersion()));
after.setOsType(appendChangeStyle(before.getOsType(), after.getOsType()));
after.setDistributionType(appendChangeStyle(before.getDistributionType(), after.getDistributionType()));
after.setDistributeTarget(appendChangeStyle(before.getDistributeTarget(), after.getDistributeTarget()));
after.setComment(appendChangeStyleDiv(before.getComment(), after.getComment()));
after.setCreator(appendChangeStyle(before.getCreator(), after.getCreator()));
after.setNoticeType(appendChangeStyle(before.getNoticeType(), after.getNoticeType()));
after.setNetworkServerType(appendChangeStyle(before.getNetworkServerType(), after.getNetworkServerType()));
after.setPriority(appendChangeStyle(before.getPriority(), after.getPriority()));
after.setDivision(appendChangeStyle(before.getDivision(), after.getDivision()));
if (before.getModelList().size() > 0 || after.getModelList().size() > 0) {
String distributeTargetString = "";
List<String> _beforeList = new ArrayList<>();
if (before.getModelList().size() > 0){
distributeTargetString = before.getDistributeTarget();
if (distributeTargetString.equals("opensource.lge.com")) {
before.setDistributeTarget(CoConstDef.CD_DTL_DISTRIBUTE_LGE);
} else {
before.setDistributeTarget(CoConstDef.CD_DTL_DISTRIBUTE_SKS);
}
for (int i=0; i < before.getModelList().size(); i++){
String categoryName = CommonFunction.makeCategoryFormat(before.getDistributeTarget(),before.getModelList().get(i).getCategory());
String before_str = categoryName+"/"+before.getModelList().get(i).getModelName()+"/"+before.getModelList().get(i).getReleaseDate();
_beforeList.add(before_str);
}
before.setDistributeTarget(distributeTargetString);
}
List<String> _afterList = new ArrayList<>();
if (after.getModelList().size() > 0){
distributeTargetString = after.getDistributeTarget();
if (distributeTargetString.equals("opensource.lge.com")) {
after.setDistributeTarget(CoConstDef.CD_DTL_DISTRIBUTE_LGE);
} else {
after.setDistributeTarget(CoConstDef.CD_DTL_DISTRIBUTE_SKS);
}
for (int i=0; i < after.getModelList().size(); i++){
String categoryName = CommonFunction.makeCategoryFormat(after.getDistributeTarget(),after.getModelList().get(i).getCategory());
String after_str = categoryName+"/"+after.getModelList().get(i).getModelName()+"/"+after.getModelList().get(i).getReleaseDate();
_afterList.add(after_str);
}
after.setDistributeTarget(distributeTargetString);
}
List<String> _newBeforeList = new ArrayList<>(_beforeList);
List<String> _newAfterList = new ArrayList<>(_afterList);
Collections.sort(_beforeList);
Collections.sort(_afterList);
// ๊ฐฏ์๋ฅผ ๋ง์ถฐ์ ์ ๋ ฌ
if (_beforeList.size() < _afterList.size()) {
for (int i=_beforeList.size(); i<_afterList.size(); i++) {
_newBeforeList.add("");
}
} else if (_afterList.size() < _beforeList.size()) {
for (int i=_afterList.size(); i<_beforeList.size(); i++) {
_newAfterList.add("");
}
}
_beforeList = new ArrayList<>(_newBeforeList);
_afterList = new ArrayList<>(_newAfterList);
// delete case
int b_size = _beforeList.size();
for (int i=0; i<b_size; i++) {
String s = _beforeList.get(i);
if (!isEmpty(s) && !s.equals(_afterList.get(i))) {
// ๋์ผํ position์ ๊ฐ์ด ๋ค๋ฅธ ๊ฒฝ์ฐ ์ญ์ ๋ก ํ๋จ
_newAfterList.add(i, "");
_newBeforeList.add(i+1,""); // size๋ฅผ ๋ง์ถฐ์ค๋ค.
}
}
_beforeList = new ArrayList<>(_newBeforeList);
_afterList = new ArrayList<>(_newAfterList);
// add
int a_size = _afterList.size();
for (int i=0; i<a_size; i++) {
String s = _afterList.get(i);
if (!isEmpty(s) && !s.equals(_beforeList.get(i))) {
if (!isEmpty(_beforeList.get(i))){
_newBeforeList.add(i, "");
appendChangeStyle(_newAfterList.get(i));
isModified = true;
_newAfterList.add(i-1,"");
}
}
}
_beforeList = _newBeforeList;
_afterList = _newAfterList;
// before and after ๋ชจ๋ ๊ณต๋ฐฑ์ธ row๋ ์ญ์
for (int i=0; i<_beforeList.size(); i++) {
if (isEmpty(_beforeList.get(i)) && isEmpty(_afterList.get(i))) {
_newBeforeList.remove(i);
_newAfterList.remove(i);
}
}
for (int i=0; i<_newBeforeList.size(); i++) {
if (isEmpty(_newAfterList.get(i))){
_newBeforeList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}else{
_newAfterList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}
isModified = checkEquals(_newBeforeList.get(i), _newAfterList.get(i), isModified);
}
before.setModelListInfo(_newBeforeList);
after.setModelListInfo(_newAfterList);
}
//watcher
if (before.getWatcherList().size() > 0 || after.getWatchers() != null) {
List<String> _beforeList = new ArrayList<>();
if (before.getWatcherList().size() > 0){
for (int i=0; i < before.getWatcherList().size(); i++){
String before_str = "";
if (isEmpty(before.getWatcherList().get(i).getPrjEmail())){
before_str = makeUserNameFormatWithDivision(before.getWatcherList().get(i).getPrjDivision(), before.getWatcherList().get(i).getPrjUserId());
}else{
before_str = before.getWatcherList().get(i).getPrjEmail();
}
_beforeList.add(before_str);
}
}
List<String> _afterList = new ArrayList<>();
String[] watchers = after.getWatchers();
if (watchers != null && watchers.length > 0){
for (int i=0; i < watchers.length; i++){
String[] after_array = watchers[i].split("/");
String after_str = "";
if ("Email".equals(after_array[1])){
after_str = after_array[0];
}else{
after_str = makeUserNameFormatWithDivision(after_array[0], after_array[1]);
}
_afterList.add(after_str);
}
}
List<String> _newBeforeList = new ArrayList<>(_beforeList);
List<String> _newAfterList = new ArrayList<>(_afterList);
Collections.sort(_beforeList);
Collections.sort(_afterList);
// ๊ฐฏ์๋ฅผ ๋ง์ถฐ์ ์ ๋ ฌ
if (_beforeList.size() < _afterList.size()) {
for (int i=_beforeList.size(); i<_afterList.size(); i++) {
_newBeforeList.add("");
}
} else if (_afterList.size() < _beforeList.size()) {
for (int i=_afterList.size(); i<_beforeList.size(); i++) {
_newAfterList.add("");
}
}
_beforeList = new ArrayList<>(_newBeforeList);
_afterList = new ArrayList<>(_newAfterList);
// delete case
int b_size = _beforeList.size();
for (int i=0; i<b_size; i++) {
String s = _beforeList.get(i);
if (!isEmpty(s) && !s.equals(_afterList.get(i))) {
// ๋์ผํ position์ ๊ฐ์ด ๋ค๋ฅธ ๊ฒฝ์ฐ ์ญ์ ๋ก ํ๋จ
_newAfterList.add(i, "");
_newBeforeList.add(i+1,""); // size๋ฅผ ๋ง์ถฐ์ค๋ค.
}
}
_beforeList = new ArrayList<>(_newBeforeList);
_afterList = new ArrayList<>(_newAfterList);
// add
int a_size = _afterList.size();
for (int i=0; i<a_size; i++) {
String s = _afterList.get(i);
if (!isEmpty(s) && !s.equals(_beforeList.get(i))) {
if (!isEmpty(_beforeList.get(i))){
_newBeforeList.add(i, "");
appendChangeStyle(_newAfterList.get(i));
isModified = true;
_newAfterList.add(i-1,"");
}
}
}
_beforeList = _newBeforeList;
_afterList = _newAfterList;
// before and after ๋ชจ๋ ๊ณต๋ฐฑ์ธ row๋ ์ญ์
for (int i=0; i<_beforeList.size(); i++) {
if (isEmpty(_beforeList.get(i)) && isEmpty(_afterList.get(i))) {
_newBeforeList.remove(i);
_newAfterList.remove(i);
}
}
for (int i=0; i<_newBeforeList.size(); i++) {
if (isEmpty(_newAfterList.get(i))){
_newBeforeList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}else{
_newAfterList.set(i, appendChangeStyle(_newBeforeList.get(i), _newAfterList.get(i)));
}
isModified = checkEquals(_newBeforeList.get(i), _newAfterList.get(i), isModified);
}
before.setWatcherListInfo(_newBeforeList);
after.setWatcherListInfo(_newAfterList);
}
//๋ฐ์ดํฐ ๋ณ๊ฒฝ ์์์
if (!isModified){
convertDataMap.replace("isModify", true);
}
convertDataMap.replace("before", before);
convertDataMap.replace("after", after);
}else if (CoConstDef.CD_MAIL_TYPE_OSS_REGIST_NEWVERSION.equals(msgType)) {
OssMaster om = (OssMaster) convertDataMap.get("paramOssInfo");
if (om != null) {
List<String> checkOssNickNamesAdd = new ArrayList<>();
if (om.getOssNicknames() != null && om.getOssNicknames().length > 0) {
if (om.getExistOssNickNames() != null && om.getExistOssNickNames().length > 0) {
checkOssNickNamesAdd = Arrays.asList(om.getOssNicknames()).stream().filter(x -> !Arrays.asList(om.getExistOssNickNames()).contains(x)).collect(Collectors.toList());
}else {
checkOssNickNamesAdd = Arrays.asList(om.getOssNicknames());
}
}
if (checkOssNickNamesAdd != null && checkOssNickNamesAdd.size() > 0) {
String changeOssNickName = "";
if (om.getExistOssNickNames() != null && om.getExistOssNickNames().length > 0) {
for (String nickName : om.getExistOssNickNames()) {
changeOssNickName += nickName + "<br/>";
}
}
for (String ossNickName : checkOssNickNamesAdd) {
if (!isEmpty(ossNickName)) {
ossNickName = appendChangeStyle("newVersion_ossNickNameAdd", ossNickName);
changeOssNickName += ossNickName + "<br/>";
}
}
if (!isEmpty(changeOssNickName)) {
OssMaster ossBasicInfo = (OssMaster) convertDataMap.get("oss_basic_info");
ossBasicInfo.setOssNickname(changeOssNickName);
convertDataMap.replace("oss_basic_info", ossBasicInfo);
}
}
}
} else if (CoConstDef.CD_MAIL_TYPE_PARTNER_CHANGED.equals(msgType)) {
PartnerMaster before = (PartnerMaster) convertDataMap.get("before");
PartnerMaster after = (PartnerMaster) convertDataMap.get("after");
after.setPartnerName(appendChangeStyle(before.getPartnerName(), after.getPartnerName()));
after.setSoftwareName(appendChangeStyle(before.getSoftwareName(), after.getSoftwareName()));
after.setSoftwareVersion(appendChangeStyle(before.getSoftwareVersion(), after.getSoftwareVersion()));
after.setDeliveryForm(appendChangeStyle(before.getDeliveryForm(), after.getDeliveryForm()));
after.setDescription(appendChangeStyle(before.getDescription(), after.getDescription()));
after.setConfirmationFileId(appendChangeStyle(before.getConfirmationFileId(), after.getConfirmationFileId()));
after.setCreator(appendChangeStyle(before.getCreator(), after.getCreator()));
after.setDivision(appendChangeStyle(before.getDivision(), after.getDivision()));
after.setReviewer(appendChangeStyle(before.getReviewer(), after.getReviewer()));
convertDataMap.replace("before", before);
convertDataMap.replace("after", after);
}
return convertDataMap;
}
private boolean checkEquals(String before, String after, boolean isModified) {
if (isModified) {
return isModified;
}
return !avoidNull(before).equals(after);
}
private String appendChangeStyleLinkFormat(String downloadLocation) {
return "<a href='"+downloadLocation+"' target='_blank'>" + downloadLocation + "</a>";
}
private String appendChangeStyleLinkFormatArray(String downloadLocations){
String[] downloadLocation = avoidNull(downloadLocations).split(",");
String result = "";
for (int idx = 0; idx < downloadLocation.length; idx++){
if (idx > 0){
result += "<br>";
}
result += appendChangeStyleLinkFormat(downloadLocation[idx]);
}
return result;
}
private String appendChangeStyleLinkFormat(String before, String after) {
return "<a href='"+after+"' target='_blank'>" + appendChangeStyle(before, after) + "</a>";
}
private String appendChangeStyleLinkFormatArray(String[] before, String[] after, int seq) {
int length = before.length > after.length ? before.length : after.length;
String result = "";
String beforeVal = (before.length > seq ? before[seq] : "");
String afterVal = (after.length > seq ? after[seq] : "");
if (length == seq) {
return result;
} else {
if (seq > 0) {
result = "<br>";
}
}
result += "<a href='"+afterVal+"' target='_blank'>" + appendChangeStyle(beforeVal, afterVal) + "</a>" + appendChangeStyleLinkFormatArray(before, after, ++seq);
return result;
}
private String appendChangeStyle(String before, String after) {
before = avoidNull(before).trim();
after = avoidNull(after).trim();
if (!avoidNull(before).equals(after)) {
if (isEmpty(after)){
after = changeStyle(before,"del");
}else{
after = changeStyle(after,"mod");
}
}
return after;
}
private String appendChangeStyleMultiLine(String before, String after) {
return appendChangeStyleMultiLine(before, after, false);
}
private String appendChangeStyleMultiLine(String before, String after, boolean brFlag) {
List<String> original = Arrays.asList(CommonFunction.brReplaceToLine(before).split("\n"));
List<String> revised = Arrays.asList(CommonFunction.brReplaceToLine(after).split("\n"));
Patch<String> patch = DiffUtils.diff(original, revised);
List<String> udiff = DiffUtils.generateUnifiedDiff("original", "revised",
original, patch, 100);
// ๋ณ๊ฒฝ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด, after์ ์ญ์ ์ ์ถ๊ฐ๋ฅผ ๋ชจํธ ํฌํจํด์ return ํ๋ค.
if (udiff != null && udiff.size() > 0) {
String changeStr = "";
int ignoreIdx = 0;
for (String s : udiff) {
if (ignoreIdx < 3) {
ignoreIdx ++;
continue;
}
// flag๋ฅผ ๋ฐ์์ ํ์ํ ์์ญ์์๋ง br tag๋ฅผ ๋ฃ์
if (!isEmpty(changeStr) && brFlag) {
changeStr += "<br/>";
}
String changeMode = s.substring(0, 1);
String str = s.substring(1);
if ("+".equals(changeMode)) {
changeStr += changeStyle(str,"mod", true);
} else if ("-".equals(changeMode)) {
changeStr += changeStyle(str,"del", true);
} else {
changeStr += str;
}
ignoreIdx ++;
}
return changeStr;
}
return after;
}
private String appendChangeStyleDiv(String before, String after) {
before = avoidNull(before).trim();
after = avoidNull(after).trim();
if (!avoidNull(before).equals(after)) {
if (isEmpty(after)){
after = changeStyleDiv(before,"del");
}else{
after = changeStyleDiv(after,"mod");
}
}
return after;
}
private String appendChangeStyle(String s) {
return "<p>" + s + "</p>";
}
private String changeStyle(String s, String tp) {
return changeStyle(s, tp, false);
}
private String changeStyle(String s, String tp, boolean useLineDeco) {
String appendHtml = "";
if (tp == "del"){
if (useLineDeco) {
appendHtml = "<span style=\"background-color:red;text-decoration:line-through;\">" + s + "</span>";
} else {
appendHtml = "<span style=\"background-color:red\">" + s + "</span>";
}
}else if (tp == "mod"){
appendHtml = "<span style=\"background-color:yellow\">" + s + "</span>";
}
return appendHtml;
}
/**
* editor๋ก ์์ฑ๋ html ํ๊ทธ๋ฅผ ํฌํจํ๋ ํญ๋ชฉ์ ๊ฒฝ์ฐ span์ background ์์ฑ์ด ์ ์ฉ๋์ง ์์, div์ฉ์ ์ถ๊ฐํจ
* @param s
* @param tp
* @return
*/
private String changeStyleDiv(String s, String tp) {
String appendHtml = "";
if (tp == "del"){
appendHtml = "<div style=\"background-color:red\">" + s + "</div>";
}else if (tp == "mod"){
appendHtml = "<div style=\"background-color:yellow\">" + s + "</div>";
}
return appendHtml;
}
private String getTemplateFilePath(String msgType) {
for (String s : CoCodeManager.getCodes(CoConstDef.CD_MAIL_COMPONENT_TEMPLATE)) {
for (String type : CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_COMPONENT_TEMPLATE, s).split(",")) {
if (msgType.equals(type.trim())) {
return "/template/email/" + CoCodeManager.getCodeString(CoConstDef.CD_MAIL_COMPONENT_TEMPLATE, s);
}
}
}
return null;
}
private String makeUserNameFormat(T2Users userInfo) {
String rtn = "";
if (userInfo != null) {
rtn += avoidNull(userInfo.getUserName());
rtn += "(" + avoidNull(userInfo.getUserId()) + ")";
}
return rtn;
}
private String makeUserNameFormatWithDivision(T2Users userInfo) {
String rtn = "";
if (userInfo != null) {
if (!isEmpty(userInfo.getDivision())) {
String _division = CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, userInfo.getDivision());
if (!isEmpty(_division)) {
rtn += _division + " ";
}
}
rtn += avoidNull(userInfo.getUserName());
rtn += "(" + avoidNull(userInfo.getUserId()) + ")";
}
return rtn;
}
public String makeUserNameFormat(String userId) {
if (isEmpty(userId)) {
return "";
}
T2Users userParam = new T2Users();
userParam.setUserId(userId);
return makeUserNameFormat(userMapper.getUser(userParam));
}
public String makeUserNameFormatWithDivision(String userId) {
return makeUserNameFormatWithDivision(null, userId);
}
public String makeUserNameFormatWithDivision(String divisionCd, String userId) {
String rtnVal = "";
if (!isEmpty(divisionCd) && "all".equalsIgnoreCase(userId)) {
String _division = CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, divisionCd);
if (!isEmpty(_division)) {
rtnVal += _division + "/" + userId;
}
} else {
T2Users userParam = new T2Users();
userParam.setUserId(userId);
T2Users userInfo = userMapper.getUser(userParam);
if (userInfo != null && !isEmpty(userInfo.getUserName())) {
if (!isEmpty(userInfo.getDivision())) {
String _division = CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, userInfo.getDivision());
if (!isEmpty(_division)) {
rtnVal += _division + " ";
}
}
rtnVal += userInfo.getUserName() + "(" + userId + ")";
}
}
if (isEmpty(rtnVal)) {
return userId;
}
return rtnVal;
}
private Object setContentsInfo(CoMail bean, String component) {
List<String> param = new ArrayList<>();
// ์์๋๋ก
switch (component) {
case CoConstDef.CD_MAIL_COMPONENT_OSSBASICINFO:
param.add(bean.getParamOssId());
return makeOssBasicInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_LICENSEBASICINFO:
param.add(bean.getParamLicenseId());
return makeLicenseBasicInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_PROJECT_BASICINFO:
case CoConstDef.CD_MAIL_COMPONENT_SELFCHECK_PROJECT_BASICINFO:
param.add(bean.getParamPrjId());
return makeProjectBasicInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_PROJECT_BOMOSSINFO:
case CoConstDef.CD_MAIL_COMPONENT_PROJECT_DISCROSEOSSINFO:
ProjectIdentification ossListParam = new ProjectIdentification();
ossListParam.setReferenceId(bean.getParamPrjId());
ossListParam.setReferenceDiv(CoConstDef.CD_DTL_COMPONENT_ID_BOM);
ossListParam.setMerge(CoConstDef.FLAG_NO);
Map<String, Object> mailComponentDataMap = projectService.getIdentificationGridList(ossListParam);
if (CoConstDef.CD_MAIL_COMPONENT_PROJECT_DISCROSEOSSINFO.equals(component)) {
Project project = new Project();
project.setPrjId(bean.getParamPrjId());
mailComponentDataMap.put("projectBean", projectService.getProjectDetail(project));
}
return makeIdentificationOssListInfo(mailComponentDataMap, component);
case CoConstDef.CD_MAIL_COMPONENT_PROJECT_DISTRIBUTIONINFO:
param.add(bean.getParamPrjId());
return makeDistributionInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_PROJECT_MODELINFO:
param.add(bean.getParamPrjId());
return makeModelInfo(getMailComponentData(param, component), bean.getMsgType());
case CoConstDef.CD_MAIL_COMPONENT_PARTNER_BASICINFO:
param.add(bean.getParamPartnerId());
return makePartnerBasicInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_PARTNER_OSSLIST:
case CoConstDef.CD_MAIL_COMPONENT_PARTNER_DISCLOSEOSSINFO:
case CoConstDef.CD_MAIL_COMPONENT_PARTNER_NOT_DISCLOSEOSSINFO:
param.add(bean.getParamPartnerId());
return makePartnerOssListInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_BATRESULT:
param.add(bean.getParamBatId());
return makeBatResultInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PRJ:
param.add(bean.getParamPrjId());
return makeVulnerabilityInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_OSS:
case CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PROJECT_RECALCULATED_ALL:
return makeVulnerabilityInfo(getMailComponentDataWithArray(bean.getParamOssKey(), component));
case CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_RECALCULATED:
case CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_REMOVE_RECALCULATED:
param.add(bean.getParamPrjId());
param.add(bean.getParamStandardScore());
param.add(bean.getParamStandardScore());
return makeVulnerabilityInfo(getMailComponentData(param, component));
case CoConstDef.CD_MAIL_COMPONENT_PACKAGING_REQUESTED_URL:
return CoCodeManager.getCodeExpString(CoConstDef.CD_COLLAB_INFO, CoConstDef.CD_PACKAGING_REQUESTED_URL);
default:
break;
}
return null;
}
/**
* 3rd party ๊ด๋ จ ๋ฉ์ผ์ OSS LIST ์ ๋ณด๋ฐํ
* @param mailComponentData
* @return
*/
private List<OssComponents> makePartnerOssListInfo(List<Map<String, Object>> mailComponentData) {
List<OssComponents> list = null;
Set<Map<String, String>> ossSet = new HashSet<Map<String, String>>();
if (mailComponentData != null && !mailComponentData.isEmpty()) {
list = new ArrayList<>();
for (Map<String, Object> dataMap : mailComponentData) {
Map<String, String> oss = new HashMap<String, String>();
oss.put("OSS_NAME", (String)dataMap.get("OSS_NAME"));
oss.put("OSS_VERSION", (String)dataMap.get("OSS_VERSION"));
oss.put("LICENSE_NAME", (String)dataMap.get("LICENSE_NAME"));
ossSet.add(oss);
}
for (Map<String, String> dataSet : ossSet) {
OssComponents bean = new OssComponents();
bean.setOssName(dataSet.get("OSS_NAME"));
bean.setOssVersion(dataSet.get("OSS_VERSION"));
bean.setLicenseName(dataSet.get("LICENSE_NAME"));
list.add(bean);
}
}
return list;
}
private List<OssMaster> makeVulnerabilityInfo(List<Map<String, Object>> mailComponentData) {
List<OssMaster> list = null;
OssMaster bean;
for (Map<String, Object> dataMap : mailComponentData) {
if (list == null) {
list = new ArrayList<>();
}
bean = new OssMaster();
if (dataMap.containsKey("PRJ_ID")) {
bean.setPrjId((String) dataMap.get("PRJ_ID"));
}
if (dataMap.containsKey("COMPONENT_ID")) {
bean.setComponentId((String) dataMap.get("COMPONENT_ID"));
}
bean.setOssId((String) dataMap.get("OSS_ID"));
bean.setOssName((String) dataMap.get("OSS_NAME"));
bean.setOssVersion((String) dataMap.get("OSS_VERSION"));
bean.setCveId((String) dataMap.get("CVE_ID"));
bean.setCvssScore(String.valueOf(dataMap.get("CVSS_SCORE")));
bean.setVulnSummary((String) dataMap.get("VULN_SUMMARY"));
bean.setPublishedDate((String) dataMap.get("PUBL_DATE"));
bean.setModifiedDate((String) dataMap.get("MODI_DATE"));
list.add(bean);
}
return list;
}
private BinaryMaster makeBatResultInfo(List<Map<String, Object>> mailComponentData) {
BinaryMaster bean = null;
for (Map<String, Object> dataMap : mailComponentData) {
bean = new BinaryMaster();
bean.setBatId((String) dataMap.get("BAT_ID"));
bean.setSoftwareName((String) dataMap.get("SOFTWARE_NAME"));
bean.setSoftwareVersion((String) dataMap.get("SOFTWARE_VERSION"));
bean.setPartnerName(avoidNull((String) dataMap.get("PARTNER_NAME")));
bean.setBinaryFileId((String) dataMap.get("BINARY_FILE_ID"));
bean.setBatStatus((String) dataMap.get("BAT_STATUS"));
bean.setBatResultCount((String) dataMap.get("BAT_RESULT_COUNT"));
bean.setCreator(makeUserNameFormatWithDivision((String) dataMap.get("CREATOR")));
if (!isEmpty((String) dataMap.get("BAT_ERROR_MSG"))) {
bean.setBatErrorMsg((String) dataMap.get("BAT_ERROR_MSG"));
}
break;
}
if (bean != null && !isEmpty(bean.getBatStatus())) {
bean.setBatStatus(CoCodeManager.getCodeString(CoConstDef.CD_BAT_STATUS, bean.getBatStatus()));
}
return bean;
}
private PartnerMaster makePartnerBasicInfo(List<Map<String, Object>> mailComponentData) {
PartnerMaster bean = null;
for (Map<String, Object> dataMap : mailComponentData) {
bean = new PartnerMaster();
bean.setPartnerId((String) dataMap.get("PARTNER_ID"));
bean.setStatus((String) dataMap.get("STATUS"));
bean.setPartnerName((String) dataMap.get("PARTNER_NAME"));
bean.setSoftwareName((String) dataMap.get("SOFTWARE_NAME"));
bean.setSoftwareVersion((String) dataMap.get("SOFTWARE_VERSION"));
bean.setDeliveryForm(CoCodeManager.getCodeString(CoConstDef.CD_PARTNER_DELIVERY_FORM, (String) dataMap.get("DELIVERY_FORM")));
bean.setDescription((String) dataMap.get("DESCRIPTION"));
bean.setConfirmationFileId((String) dataMap.get("CONFIRMATION_FILE_ID"));
bean.setOssFileId((String) dataMap.get("OSS_FILE_ID"));
bean.setReviewer(makeUserNameFormatWithDivision((String) dataMap.get("REVIEWER")));
bean.setCreator(makeUserNameFormatWithDivision((String) dataMap.get("CREATOR")));
bean.setCreatedDate(CommonFunction.formatDate((String) dataMap.get("CREATED_DATE")));
bean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, (String) dataMap.get("DIVISION")));
break;
}
return bean;
}
private List<Project> makeModelInfo(List<Map<String, Object>> mailComponentData, String mailType) {
List<Project> list = null;
Project bean;
String distributeTargetCode = null;
for (Map<String, Object> dataMap : mailComponentData) {
if (list == null) {
list = new ArrayList<>();
}
if (isEmpty(distributeTargetCode)) {
distributeTargetCode = CoConstDef.CD_DTL_DISTRIBUTE_SKS.equals(avoidNull( (String) dataMap.get("DISTRIBUTE_TARGET"), CoConstDef.CD_DTL_DISTRIBUTE_LGE)) ? CoConstDef.CD_MODEL_TYPE2 : CoConstDef.CD_MODEL_TYPE;
}
bean = new Project();
bean.setPrjId((String) dataMap.get("PRJ_ID"));
bean.setCategory(CommonFunction.makeCategoryFormat((String) dataMap.get("DISTRIBUTE_TARGET"), (String) dataMap.get("CATEGORY"), (String) dataMap.get("SUBCATEGORY")));
bean.setModelName((String) dataMap.get("MODEL_NAME"));
bean.setReleaseDate(CommonFunction.formatDateSimple((String) dataMap.get("RELEASE_DATE")));
bean.setModifier((String) dataMap.get("MODIFIER"));
if (dataMap.get("MODIFIED_DATE") != null && !isEmpty((String) dataMap.get("MODIFIED_DATE"))) {
bean.setModifiedDate(CommonFunction.formatDateSimple((String) dataMap.get("MODIFIED_DATE")));
}
if (dataMap.containsKey("DEL_YN") && CoConstDef.FLAG_YES.equals(dataMap.get("DEL_YN"))) {
bean.setCategory(changeStyle(bean.getCategory(), "del", true));
bean.setModelName(changeStyle(bean.getModelName(), "del", true));
bean.setReleaseDate(changeStyle(bean.getReleaseDate(), "del", true));
}
// distribution ์์ฝ ๋ฐ ์์ฝ์ทจ์์ ๊ฒฝ์ฐ๋ง modifier ๊ฐ ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ, ์ ๊ท ์ถ๊ฐ๋ ๊ฒ์ผ๋ก ํ์ํ๋ค.
else if ( (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_RESERVED.equals(mailType) || CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_CANCELED.equals(mailType) )
&& isEmpty(bean.getModifiedDate())) {
bean.setCategory(changeStyle(bean.getCategory(), "mod"));
bean.setModelName(changeStyle(bean.getModelName(), "mod"));
bean.setReleaseDate(changeStyle(bean.getReleaseDate(), "mod"));
}
list.add(bean);
}
return list;
}
private Project makeDistributionInfo(List<Map<String, Object>> mailComponentData) {
Project bean = null;
for (Map<String, Object> dataMap : mailComponentData) {
bean = new Project();
bean.setDistributeName((String) dataMap.get("DISTRIBUTE_NAME"));
bean.setDistributeMasterCategory((String) dataMap.get("DISTRIBUTE_MASTER_CATEGORY"));
bean.setDistributeSoftwareType((String) dataMap.get("DISTRIBUTE_SOFTWARE_TYPE"));
bean.setDistributeDeployTime((String) dataMap.get("DISTRIBUTE_DEPLOY_TIME"));
bean.setDistributeDeployYn((String) dataMap.get("DISTRIBUTE_DEPLOY_YN"));
bean.setDistributeDeployModelYn((String) dataMap.get("DISTRIBUTE_DEPLOY_MODEL_YN"));
bean.setDistributeDeployErrorMsg((String) dataMap.get("DISTRIBUTE_DEPLOY_ERROR_MSG"));
bean.setDistributeTarget((String) dataMap.get("DISTRIBUTE_TARGET"));
bean.setPackageFileId((String) dataMap.get("PACKAGE_FILE_ID"));
bean.setPackageFileId2((String) dataMap.get("PACKAGE_FILE_ID2"));
bean.setPackageFileId3((String) dataMap.get("PACKAGE_FILE_ID3"));
bean.setNoticeFileId((String) dataMap.get("NOTICE_FILE_ID"));
// code convert
// master category
if (!isEmpty(bean.getDistributeMasterCategory())) {
bean.setDistributeMasterCategory(CommonFunction.makeCategoryFormat(bean.getDistributeTarget(), bean.getDistributeMasterCategory().substring(0, 3), bean.getDistributeMasterCategory().substring(3)));
}
if (!isEmpty(bean.getDistributeSoftwareType())) {
bean.setDistributeSoftwareType(CoCodeManager.getCodeString(CoConstDef.CD_NOTICE_DEFAULT_SOFTWARE_TYPE, bean.getDistributeSoftwareType()));
}
// target site
if (!isEmpty(bean.getDistributeTarget())) {
bean.setDistributeTarget(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_CODE, bean.getDistributeTarget()));
}
break;
}
return bean;
}
@SuppressWarnings("unchecked")
private List<OssComponents> makeIdentificationOssListInfo(Map<String, Object> mailComponentDataMap, String component) {
List<ProjectIdentification> projectList = null;
List<OssComponents> list = null;
OssComponents bean = null;
String currentGroupKey = null;
Project project = (Project) mailComponentDataMap.get("projectBean");
String networkServerType = "";
String networkRestriction = "";
if (project != null) {
networkServerType = project.getNetworkServerType();
networkRestriction = CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, CoConstDef.CD_LICENSE_NETWORK_RESTRICTION).toUpperCase();
}
if (mailComponentDataMap != null && (mailComponentDataMap.containsKey("mainData") || mailComponentDataMap.containsKey("rows") )) {
projectList = (List<ProjectIdentification>) mailComponentDataMap.get(mailComponentDataMap.containsKey("mainData") ? "mainData" : "rows");
for (ProjectIdentification prjBean : projectList) {
// exclude ์ ์ธ
if (CoConstDef.FLAG_YES.equals(prjBean.getExcludeYn())) {
continue;
}
if (currentGroupKey != null && currentGroupKey.equals(prjBean.getGroupingColumn())) {
continue;
} else {
currentGroupKey = prjBean.getGroupingColumn();
}
if (CoConstDef.CD_MAIL_COMPONENT_PROJECT_DISCROSEOSSINFO.equals(component)
&& !CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE.equals(CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK.equals(prjBean.getObligationLicense()) ? prjBean.getObligationType() : prjBean.getObligationLicense())) {
continue;
}
if (CoConstDef.FLAG_YES.equals(networkServerType)
&& !networkRestriction.equals(prjBean.getRestriction().toUpperCase())) {
continue;
}
if (list == null) {
list = new ArrayList<>();
}
bean = new OssComponents();
bean.setOssName(prjBean.getOssName());
bean.setOssVersion(prjBean.getOssVersion());
bean.setLicenseName(prjBean.getLicenseName());
list.add(bean);
}
}
return list;
}
private Project makeProjectBasicInfo(List<Map<String, Object>> mailComponentData) {
Project bean = null;
String packageFileName = null;
String packageFileName2 = null;
String packageFileName3 = null;
String noticeFileName = null;
for (Map<String, Object> dataMap : mailComponentData) {
bean = new Project();
bean.setPrjId(avoidNull((String) dataMap.get("PRJ_ID")));
bean.setPrjName(avoidNull((String) dataMap.get("PRJ_NAME")));
bean.setPrjVersion(avoidNull((String) dataMap.get("PRJ_VERSION")));
bean.setDistributionType(avoidNull((String) dataMap.get("DISTRIBUTION_TYPE")));
bean.setNetworkServerType(avoidNull((String) dataMap.get("NETWORK_SERVER_TYPE")));
bean.setComment(avoidNull((String) dataMap.get("COMMENT")));
bean.setOsType(avoidNull((String) dataMap.get("OS_TYPE")));
bean.setOsTypeEtc(avoidNull((String) dataMap.get("OS_TYPE_ETC")));
bean.setDistributeTarget(avoidNull((String) dataMap.get("DISTRIBUTE_TARGET")));
bean.setCreator(makeUserNameFormatWithDivision(avoidNull((String) dataMap.get("CREATOR"))));
bean.setReviewer(makeUserNameFormatWithDivision(avoidNull((String) dataMap.get("REVIEWER"))));
bean.setIdentificationStatus(avoidNull((String) dataMap.get("IDENTIFICATION_STATUS")));
bean.setVerificationStatus(avoidNull((String) dataMap.get("VERIFICATION_STATUS")));
bean.setDestributionStatus(avoidNull((String) dataMap.get("DESTRIBUTION_STATUS")));
bean.setNoticeType(avoidNull((String) dataMap.get("NOTICE_TYPE")));
bean.setNoticeTypeEtc(avoidNull((String) dataMap.get("NOTICE_TYPE_ETC")));
bean.setPriority(avoidNull((String) dataMap.get("PRIORITY")));
bean.setDivision(avoidNull((String) dataMap.get("DIVISION")));
packageFileName = (String) dataMap.get("PACKAGE_FILE_ID");
packageFileName2 = (String) dataMap.get("PACKAGE_FILE_ID2");
packageFileName3 = (String) dataMap.get("PACKAGE_FILE_ID3");
noticeFileName = (String) dataMap.get("NOTICE_FILE_ID");
break;
}
if (bean != null) {
// published file ์ ๋ณด๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ + packaging ์ํ๊ฐ confirm์ธ ๊ฒฝ์ฐ ํ์ผ ์ ๋ณด ๋
ธ์ถ
if (CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(bean.getVerificationStatus())) {
if (!isEmpty(packageFileName)) {
T2File packageFile = fileService.selectFileInfo(packageFileName);
if (packageFile != null) {
bean.setPackageFileId(packageFile.getOrigNm());
}
}
if (!isEmpty(packageFileName2)) {
T2File packageFile2 = fileService.selectFileInfo(packageFileName2);
if (packageFile2 != null) {
bean.setPackageFileId2(packageFile2.getOrigNm());
}
}
if (!isEmpty(packageFileName3)) {
T2File packageFile3 = fileService.selectFileInfo(packageFileName3);
if (packageFile3 != null) {
bean.setPackageFileId3(packageFile3.getOrigNm());
}
}
if (!isEmpty(noticeFileName)) {
T2File noticeFile = fileService.selectFileInfo(noticeFileName);
if (noticeFile != null) {
bean.setNoticeFileId(noticeFile.getOrigNm());
}
}
}
// ์ฝ๋๋ณํ
if (!isEmpty(bean.getDistributionType())) {
bean.setDistributionType(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTION_TYPE, bean.getDistributionType()));
}
if (!isEmpty(bean.getOsType())) {
bean.setOsType(CoConstDef.COMMON_SELECTED_ETC.equals(bean.getOsType()) ? bean.getOsTypeEtc() : CoCodeManager.getCodeString(CoConstDef.CD_OS_TYPE, bean.getOsType()));
}
if (!isEmpty(bean.getIdentificationStatus())) {
bean.setIdentificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getIdentificationStatus()));
}
if (!isEmpty(bean.getVerificationStatus())) {
bean.setVerificationStatus(CoCodeManager.getCodeString(CoConstDef.CD_IDENTIFICATION_STATUS, bean.getVerificationStatus()));
}
if (!isEmpty(bean.getDestributionStatus())) {
bean.setDestributionStatus(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_STATUS, bean.getDestributionStatus()));
}
if (!isEmpty(bean.getDistributeTarget())) {
bean.setDistributeTarget(CoCodeManager.getCodeString(CoConstDef.CD_DISTRIBUTE_CODE, bean.getDistributeTarget()));
}
if (!isEmpty(bean.getNoticeType())) {
String noticeType = CoCodeManager.getCodeString(CoConstDef.CD_NOTICE_TYPE, bean.getNoticeType());
String noticeTypeEtc = CoCodeManager.getCodeString(CoConstDef.CD_PLATFORM_GENERATED, bean.getNoticeTypeEtc());
if (!isEmpty(noticeTypeEtc)) {
noticeType += " (" + noticeTypeEtc + ")";
}
bean.setNoticeType(noticeType);
}
if (!isEmpty(bean.getPriority())) {
bean.setPriority(CoCodeManager.getCodeString(CoConstDef.CD_PROJECT_PRIORITY, bean.getPriority()));
}
if (!isEmpty(bean.getDivision())) {
bean.setDivision(CoCodeManager.getCodeString(CoConstDef.CD_USER_DIVISION, bean.getDivision()));
}
}
return bean;
}
/**
* 101 ๋ผ์ด์ ์ค ๊ธฐ๋ณธ์ ๋ณด
* @param mailComponentData
* @return
*/
private LicenseMaster makeLicenseBasicInfo(List<Map<String, Object>> mailComponentData) {
LicenseMaster bean = null;
for (Map<String, Object> dataMap : mailComponentData) {
bean = new LicenseMaster();
bean.setLicenseId(avoidNull((String) dataMap.get("LICENSE_ID")));
bean.setLicenseName(avoidNull((String) dataMap.get("LICENSE_NAME")));
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, avoidNull((String) dataMap.get("LICENSE_TYPE"))));
bean.setObligationDisclosingSrcYn(avoidNull((String) dataMap.get("OBLIGATION_DISCLOSING_SRC_YN")));
bean.setObligationNotificationYn(avoidNull((String) dataMap.get("OBLIGATION_NOTIFICATION_YN")));
bean.setObligationNeedsCheckYn(avoidNull((String) dataMap.get("OBLIGATION_NEEDS_CHECK_YN")));
if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationNeedsCheckYn()))) {
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, CoConstDef.CD_DTL_OBLIGATION_NEEDSCHECK));
} else if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationDisclosingSrcYn()))) {
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, CoConstDef.CD_DTL_OBLIGATION_DISCLOSURE));
} else if (CoConstDef.FLAG_YES.equals(avoidNull(bean.getObligationNotificationYn()))) {
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, CoConstDef.CD_DTL_OBLIGATION_NOTICE));
}
bean.setShortIdentifier(avoidNull((String) dataMap.get("SHORT_IDENTIFIER")));
bean.setWebpage(avoidNull((String) dataMap.get("WEBPAGE")));
if (!isEmpty(bean.getWebpage()) && !(bean.getWebpage().startsWith("http://") || bean.getWebpage().startsWith("https://"))) {
bean.setWebpage("http://" + bean.getWebpage());
}
bean.setDescription(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("DESCRIPTION"))));
bean.setLicenseText(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("LICENSE_TEXT"))));
bean.setAttribution(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("ATTRIBUTION"))));
bean.setLicenseNickname(avoidNull((String) dataMap.get("LICENSE_NICKNAME")));
// RESTRICTION ์ ๋ณด ๋ฉ์ผ์ ์ถ๊ฐ
String restrictionStr = "";
if (!isEmpty((String) dataMap.get("RESTRICTION"))) {
for (String restrictionCd : ((String) dataMap.get("RESTRICTION")).split(",")) {
if (!isEmpty(restrictionStr)) {
restrictionStr += ", ";
}
restrictionStr += CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_RESTRICTION, restrictionCd);
}
}
bean.setRestriction(restrictionStr);
break;
}
return bean;
}
/**
* 100 OSS ๊ธฐ๋ณธ์ ๋ณด
* @param mailComponentData
* @return
*/
private OssMaster makeOssBasicInfo(List<Map<String, Object>> mailComponentData) {
OssMaster bean = null;
// oss master, license list, nick name list๋ฅผ ๋ถ๋ฆฌํ๋ค
boolean isFirst = true;
OssLicense license = null;
for (Map<String, Object> dataMap : mailComponentData) {
if (isFirst) {
bean = new OssMaster();
bean.setOssId(avoidNull((String) dataMap.get("OSS_ID")));
bean.setOssName((String) dataMap.get("OSS_NAME"));
bean.setOssVersion((String) dataMap.get("OSS_VERSION"));
bean.setOssType(avoidNull((String) dataMap.get("OSS_TYPE")));
String result = appendChangeStyleLinkFormatArray((String) dataMap.get("DOWNLOAD_LOCATION"));
bean.setDownloadLocation(result);
bean.setHomepage(avoidNull((String) dataMap.get("HOMEPAGE")));
bean.setSummaryDescription(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("SUMMARY_DESCRIPTION"))));
bean.setAttribution(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("ATTRIBUTION"))));
bean.setCopyright(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("COPYRIGHT")))); // copyright ๋ tag ๋ฅผ ํฌํจํ๊ณ ์๊ธฐ ๋๋ฌธ์, ๋ฉ์ผ ๋ฐ์ก์๋ (html) escape ์ฒ๋ฆฌํจ
bean.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, avoidNull((String) dataMap.get("OSS_LICENSE_TYPE"))));
bean.setObligation(CoCodeManager.getCodeString(CoConstDef.CD_OBLIGATION_TYPE, avoidNull((String) dataMap.get("OSS_OBLIGATION_TYPE"))));
bean.setOssNickname(avoidNull((String) dataMap.get("OSS_NICKNAME")));
if (!isEmpty((String) dataMap.get("CREATED_DATE"))) {
bean.setCreatedDate(DateUtil.dateFormatConvert((String) dataMap.get("CREATED_DATE"), DateUtil.TIMESTAMP_PATTERN, DateUtil.DATE_PATTERN_DASH));
}
if (!isEmpty((String) dataMap.get("CREATOR"))) {
bean.setCreator(CoMailManager.getInstance().makeUserNameFormat((String) dataMap.get("CREATOR")));
}
if (!isEmpty(bean.getOssId()) && CoCodeManager.OSS_INFO_BY_ID.containsKey(bean.getOssId())) {
bean.setMultiLicenseFlag(CoCodeManager.OSS_INFO_BY_ID.get(bean.getOssId()).getLicenseDiv());
}
String detectedLicenses = dataMap.containsKey("DETECTED_LICENSE") ? (String) dataMap.get("DETECTED_LICENSE") : "";
bean.setDetectedLicense(detectedLicenses);
}
if (dataMap.containsKey("LICENSE_ID")) {
license = new OssLicense();
license.setLicenseId((String) dataMap.get("LICENSE_ID"));
license.setOssLicenseIdx((String) dataMap.get("OSS_LICENSE_IDX"));
license.setOssLicenseComb((String) dataMap.get("OSS_LICENSE_COMB"));
license.setOssCopyright(CommonFunction.htmlEscape(avoidNull((String) dataMap.get("OSS_COPYRIGHT"))));
license.setOssLicenseText((String) dataMap.get("OSS_LICENSE_TEXT"));
license.setLicenseName((String) dataMap.get("LICENSE_NAME"));
license.setLicenseType(CoCodeManager.getCodeString(CoConstDef.CD_LICENSE_TYPE, avoidNull((String) dataMap.get("LICENSE_TYPE"))));
bean.addOssLicense(license);
}
isFirst = false;
}
if (bean != null && bean.getOssLicenses() != null && !bean.getOssLicenses().isEmpty()) {
bean.setLicenseName(CommonFunction.makeLicenseExpression(bean.getOssLicenses()));
}
return bean;
}
/**
* Sets the basic info.
*
* @param params the params
* @param key the key
* @return
*/
private List<Map<String, Object>> getMailComponentData(List<String> params, String key) {
// sql ๋ฌธ ์์ฑ
String sql = CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_COMPONENT_NAME, key);
List<Map<String, Object>> dataList = new ArrayList<>();
try (
Connection conn = DriverManager.getConnection(connStr, connUser, connPw);
PreparedStatement pstmt = conn.prepareStatement(sql);
) {
int parameterIndex = 1;
for (String param : params) {
pstmt.setString(parameterIndex++, param);
}
try (
ResultSet rs = pstmt.executeQuery();
) {
if (rs != null) {
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount(); // ์ปฌ๋ผ์
Map<String, Object> dataMap;
while (rs.next()) {
dataMap = new HashMap<>();
for (int colIdx = 1; colIdx <= colCount; colIdx++) {
String _contents = (String) rs.getString(colIdx);
if (avoidNull(_contents).indexOf("\n") > -1) {
_contents = _contents.replaceAll("\n", "<br />");
}
dataMap.put(rsmd.getColumnLabel(colIdx), _contents);
}
if (CoConstDef.CD_MAIL_COMPONENT_OSSBASICINFO.equals(key)) {
if (dataMap.containsKey("identificationStatus") && dataMap.containsKey("verificationStatus")
&& CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(dataMap.get("identificationStatus")) && CoConstDef.CD_DTL_IDENTIFICATION_STATUS_CONFIRM.equals(dataMap.get("verificationStatus"))) {
if (dataMap.containsKey("noticeFileId")) {
dataMap.remove("noticeFileId");
}
if (dataMap.containsKey("packageFileId")) {
dataMap.remove("packageFileId");
}
}
}
if (CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PRJ.equals(key) || CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_OSS.equals(key) || CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PROJECT_RECALCULATED_ALL.equals(key)) {
dataMap.remove("noticeFileId");
dataMap.remove("packageFileId");
}
dataList.add(dataMap);
}
}
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
return dataList;
}
private List<Map<String, Object>> getMailComponentDataWithArray(List<String> params, String key) {
// sql ๋ฌธ ์์ฑ
String sql = CoCodeManager.getCodeExpString(CoConstDef.CD_MAIL_COMPONENT_NAME, key);
List<Map<String, Object>> dataList = new ArrayList<>();
// sql param ์์ฑ
sql = sql.replace("?", createInQuery(params));
try (
Connection conn = DriverManager.getConnection(connStr, connUser, connPw);
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery()
) {
if (rs != null) {
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount(); // ์ปฌ๋ผ์
Map<String, Object> dataMap;
while (rs.next()) {
dataMap = new HashMap<>();
for (int colIdx=1; colIdx<=colCount; colIdx++) {
String _contents = (String)rs.getString(colIdx);
if (avoidNull(_contents).indexOf("\n") > -1) {
_contents = _contents.replaceAll("\n", "<br />");
}
dataMap.put(rsmd.getColumnLabel(colIdx), _contents);
}
if (CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PRJ.equals(key) || CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_OSS.equals(key) || CoConstDef.CD_MAIL_COMPONENT_VULNERABILITY_PROJECT_RECALCULATED_ALL.equals(key)) {
dataMap.remove("noticeFileId");
dataMap.remove("packageFileId");
}
dataList.add(dataMap);
}
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
return dataList;
}
private CharSequence createInQuery(List<String> params) {
StringBuilder keyList = new StringBuilder();
for (String key : params) {
if (keyList.length() > 0) {
keyList.append(" OR ");
}
keyList.append(" CONCAT(UPPER(T1.OSS_NAME), '_', T1.OSS_VERSION) = '"+key+"'");
}
return keyList.toString();
}
/**
* Get velocity template content.
*
* @param path the path
* @param model the model
* @return the string
*/
private String getVelocityTemplateContent(String path, Map<String, Object> model) {
VelocityContext context = new VelocityContext();
Writer writer = new StringWriter();
VelocityEngine vf = new VelocityEngine();
Properties props = new Properties();
for (String key : model.keySet()) {
if (!"templateUrl".equals(key)) {
context.put(key, model.get(key));
}
}
context.put("domain", CommonFunction.emptyCheckProperty("server.domain", "http://fosslight.org"));
context.put("commonFunction", CommonFunction.class);
props.put("resource.loader", "class");
props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
props.put("input.encoding", "UTF-8");
vf.init(props);
try {
Template template = vf.getTemplate(path); // file name
template.merge(context, writer);
return writer.toString();
} catch (Exception e) {
log.error("Exception occured while processing velocity template:" + e.getMessage());
}
return "";
}
private String[] selectMailAddrFromIds(String[] toIds) {
Map<String, String[]> param = new HashMap<String, String[]>();
param.put("idArr", toIds);
List<String> mailList = mailManagerMapper.selectMailAddrFromIds(param);
String[] results = new String[mailList.size()];
return mailList.toArray(results);
}
private String[] selectAdminMailAddr() {
String adminMailStr = avoidNull(CommonFunction.getProperty("smtp.default.admin"));
if (isEmpty(adminMailStr)) {
List<String> adminMailList = mailManagerMapper.selectAdminMailAddr();
String[] array = new String[adminMailList.size()];
return adminMailList.toArray(array);
} else {
return new String[]{adminMailStr};
}
}
private void sendEmail(CoMail coMail) {
// Send Email Info Setting
try{
MimeMessage message = mailSender.createMimeMessage();
String _replyToId = "";
if (!isEmpty(coMail.getParamLicenseId())) {
_replyToId = "LI" +coMail.getParamLicenseId();
} else if (!isEmpty(coMail.getParamOssId())) {
_replyToId = "OS"+coMail.getParamOssId();
} else if (!isEmpty(coMail.getParamPrjId())) {
_replyToId = "PJ"+coMail.getParamPrjId();
} else if (!isEmpty(coMail.getParamPartnerId())) {
_replyToId = "PN"+coMail.getParamPartnerId();
}
if (!isEmpty(_replyToId)) {
_replyToId = "<OSC." +_replyToId + "@fosslight.org>";
message.setHeader("In-Reply-To", _replyToId);
message.setHeader("References", _replyToId);
}
MimeMessageHelper helper = new MimeMessageHelper(message, true);
String userId = coMail.getLoginUserName();
String userName = "";
if (isEmpty(userId)) {
// ์์คํ
์์ ๋ฐ์กํ๋ case
// 1. bat ๊ด๋ จ
if (!isEmpty(coMail.getParamBatId())) {
BinaryMaster batBean = mailManagerMapper.getBinaryInfo(coMail.getParamBatId());
if (batBean != null && !isEmpty(batBean.getCreator())) {
userId = batBean.getCreator();
}
}
}
if (!isEmpty(userId)) {
T2Users userParam = new T2Users();
userParam.setUserId(userId);
T2Users userInfo = userMapper.getUser(userParam);
if (userInfo != null && !isEmpty(userInfo.getUserName())) {
userName = userInfo.getUserName();
}
}
String mailFrom = avoidNull(CommonFunction.getProperty("mail.smtp.email"), CommonFunction.getProperty("mail.smtp.username"));
if (CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DELETED.equals(coMail.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_DIFF_FILE.equals(coMail.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_FILE.equals(coMail.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_DISTRIBUTE_EDIT_DESCRIPTION.equals(coMail.getMsgType()) ) {
InternetAddress from = new InternetAddress(mailFrom, "FOSSLight Hub" + " (FOSSLight)", "UTF-8");
helper.setFrom(from);
}
else if (!isEmpty(userId) && !isEmpty(userName)) {
if (userName.length() > 15 && userName.contains("/") && userName.split("/").length > 1) {
userName = userName.substring(0, userName.lastIndexOf("/"));
}
InternetAddress from = new InternetAddress(mailFrom, userName + " " + userId + " (FOSSLight)", "UTF-8");
helper.setFrom(from);
} else {
helper.setFrom(mailFrom);
}
if (!isEmpty(DEFAULT_BCC)) {
String[] _bcc = coMail.getBccIds() == null ? new String[]{} : coMail.getBccIds();
List<String> _bccList = new ArrayList<>(Arrays.asList(_bcc));
if (_bccList == null || _bccList.isEmpty()) {
_bccList = new ArrayList<>();
}
_bccList.add(DEFAULT_BCC);
coMail.setBccIds(_bccList.toArray(new String[_bccList.size()]));
}
helper.setTo(coMail.getToIds());
helper.setCc(coMail.getCcIds() != null ? coMail.getCcIds() : new String[]{});
helper.setBcc(coMail.getBccIds() != null ? coMail.getBccIds() : new String[]{});
helper.setSubject(coMail.getEmlTitle());
helper.setText(coMail.getEmlMessage(), true);
if(CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONF.equals(coMail.getMsgType())
|| CoConstDef.CD_MAIL_TYPE_PROJECT_IDENTIFICATION_CONFIRMED_ONLY.equals(coMail.getMsgType())){
try {
Map<String, Object> fileInfo = PdfUtil.getInstance().getPdfFilePath(coMail.getParamPrjId());
String fileName = (String) fileInfo.get("fileName");
String filePath = (String) fileInfo.get("filePath");
log.debug("filepath: " + fileInfo.get("filePath"));
DataSource dataSource = new FileDataSource(filePath);
helper.addAttachment(MimeUtility.encodeText(fileName, "UTF-8", "B"), dataSource);
}catch(Exception e){
// Don't Exist Pdf
log.debug(e.getMessage(), e);
}
}
// Email Send
mailSender.send(message);
// Email History Status Update
coMail.setSndStatus("C"); // ์ ์ก์๋ฃ
mailManagerMapper.updateSendStatus(coMail);
} catch(Exception e) {
log.error(e.getMessage(), e);
coMail.setSndStatus("F"); // ์ ์ก์คํจ
coMail.setErrorMsg(e.getMessage());
mailManagerMapper.updateErrorMsg(coMail);
}
}
public void sendErrorMail(CoMail bean) {
boolean isProd = "REAL".equals(avoidNull(CommonFunction.getProperty("server.mode")));
if (isProd) {
bean.setToIds(selectAdminMailAddr());
try {
bean.setCreationUserId("system");
mailManagerMapper.insertEmailHistory(bean);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
// ๋ฐ์ก์ฒ๋ฆฌ
new Thread(() -> sendEmail(bean)).start();
}
}
}
| 152,455 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ReportCombean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ReportCombean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
/**
* The Class partnerMaster
*/
public class ReportCombean implements Serializable{
private static final long serialVersionUID = 6760737950434033025L;
private String[] sheetNums;
private String fileSeq;
private String no;
private String name;
private String type;
private String parameter;
private String androidFileSeq;
private String androidNoticeFileSeq;
private String androidResultFileSeq;
public String[] getSheetNums() {
return sheetNums != null ? sheetNums.clone() : null;
}
public void setSheetNums(String[] sheetNums) {
this.sheetNums = sheetNums != null ? sheetNums.clone() : null;
}
public String getFileSeq() {
return fileSeq;
}
public void setFileSeq(String fileSeq) {
this.fileSeq = fileSeq;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getAndroidFileSeq() {
return androidFileSeq;
}
public void setAndroidFileSeq(String androidFileSeq) {
this.androidFileSeq = androidFileSeq;
}
public String getAndroidNoticeFileSeq() {
return androidNoticeFileSeq;
}
public void setAndroidNoticeFileSeq(String androidNoticeFileSeq) {
this.androidNoticeFileSeq = androidNoticeFileSeq;
}
public String getAndroidResultFileSeq() {
return androidResultFileSeq;
}
public void setAndroidResultFileSeq(String androidResultFileSeq) {
this.androidResultFileSeq = androidResultFileSeq;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getParameter() {
return parameter;
}
public void setParameter(String parameter) {
this.parameter = parameter;
}
} | 1,993 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
JsonResponseBean.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/JsonResponseBean.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public class JsonResponseBean {
public static final Integer STATUS_CODE_SUCCESS = 1;
public static final Integer STATUS_CODE_FAIL = 0;
public static final String STATUS_CODE_SUCCESS_STR = "success";
public static final String STATUS_CODE_FAIL_STR = "fail";
private Integer statusCode; // ์ฑ๊ณต(1) ํน์ ์คํจ(0)
private String statusMessage; // ์ฑ๊ณต ํน์ ์คํจ ๋ฉ์์ง(messageProperties[์ฑ๊ณต, ์คํจ])
private JsonElement data; // ๋ฐ์ดํฐ (select = ์กฐํํ ๋ฐ์ดํฐ๋ค, insert/update/delete = ์ ์ฉ๋ row์)
// Default Success Value Setup
public JsonResponseBean() {
this.statusCode = STATUS_CODE_SUCCESS;
this.statusMessage = STATUS_CODE_SUCCESS_STR;
}
public Integer getStatusCode() {
return statusCode;
}
public void setStatusCode(Integer statusCode) {
this.statusCode = statusCode;
}
public String getStatusMessage() {
return statusMessage;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
public JsonElement getData() {
return data;
}
public void setData(JsonElement data) {
this.data = data;
}
@Override
public String toString() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("statusCode", statusCode);
jsonObject.addProperty("statusMessage", statusMessage == null ? "" : statusMessage);
jsonObject.add("data", data == null ? new JsonObject() : data);
return jsonObject.toString();
}
} | 1,698 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Bat.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/Bat.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
/**
* The Class Bat.
*/
@Getter @Setter
public class Bat extends ComBean implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 9018255826730935058L;
/** The id. */
private String id;
/** The bat id. */
private String batId;
/** The filename. */
private String filename ;
/** The pathname. */
private String pathname ;
private String sourcepath ;
/** The checksum. */
private String checksum ;
/** The tlshchecksum. */
private String tlshchecksum;
/** The ossname. */
private String ossname ;
/** The ossversion. */
private String ossversion ;
/** The license. */
private String license ;
/** The parentname. */
private String parentname ;
/** The platformname. */
private String platformname;
/** The platformversion. */
private String platformversion;
/** The updatedate. */
private String updatedate;
/** The sch start date. */
private String schStartDate;
/** The sch end date. */
private String schEndDate;
private String downloadlocation;
private String equalFlag = "N";
private String comment;
private String parameter;
private String binaryPopupFlag = "N";
}
| 1,502 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
ImageView.java | /FileExtraction/Java_unseen/fosslight_fosslight/src/main/java/oss/fosslight/domain/ImageView.java | /*
* Copyright (c) 2021 LG Electronics Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
package oss.fosslight.domain;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.AbstractView;
import oss.fosslight.config.AppConstBean;
import oss.fosslight.util.StringUtil;
@Component("imageView")
@PropertySources(value = {@PropertySource(value=AppConstBean.APP_CONFIG_PROPERTIES_PATH)})
public class ImageView extends AbstractView {
@Override
protected void renderMergedOutputModel(Map<String, Object> model,
HttpServletRequest req, HttpServletResponse res) throws Exception {
T2File imageFile = (T2File)model.get("imageFile");
// ์๋ต ๋ฉ์์ง์ ํ์ผ์ ๊ธธ์ด๋ฅผ ๋๊ฒจ์ค๋๋ค.
res.setContentLength(StringUtil.string2integer(imageFile.getSize()));
// ์๋ต์ ํ์
์ด ์ด๋ฏธ์ง์์ ์๋ ค์ค๋๋ค.
res.setContentType(StringUtil.avoidNull(imageFile.getContentType(), MediaType.IMAGE_JPEG_VALUE));
// ํ์ผ๋ก๋ถํฐ byte๋ฅผ ์ฝ์ด์ต๋๋ค.
byte[] bytes = readFile(imageFile.getLogiPath(), imageFile.getLogiNm());
write(res, bytes);
}
/**
* ํ์ผ๋ก๋ถํฐ byte ๋ฐฐ์ด ์ฝ์ด์ค๊ธฐ
*/
private byte[] readFile(String filePath, String fileName) throws IOException {
String path = filePath + "/" + fileName;
byte[] bytes = null;
try (
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path));
) {
int length = bis.available();
bytes = new byte[length];
bis.read(bytes);
} catch (Exception e){
throw e;
}
return bytes;
}
/**
* ์๋ต OutputStream์ ํ์ผ ๋ด์ฉ ์ฐ๊ธฐ
*/
private void write(HttpServletResponse res, byte[] bytes) throws IOException {
OutputStream output = res.getOutputStream();
output.write(bytes);
output.flush();
}
}
| 2,276 | Java | .java | fosslight/fosslight | 172 | 114 | 89 | 2021-04-29T09:49:47Z | 2024-05-09T06:51:21Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.