mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 05:13:38 +00:00
Code clean up.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
DevOps/
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -1,226 +0,0 @@
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
import com.blackducksoftware.sdk.fault.SdkFault;
|
||||
import com.blackducksoftware.sdk.protex.client.util.BDProtexSample;
|
||||
import com.blackducksoftware.sdk.protex.client.util.ProtexServerProxy;
|
||||
import com.blackducksoftware.sdk.protex.project.Project;
|
||||
import com.blackducksoftware.sdk.protex.project.ProjectApi;
|
||||
import com.blackducksoftware.sdk.protex.report.Report;
|
||||
import com.blackducksoftware.sdk.protex.report.ReportApi;
|
||||
import com.blackducksoftware.sdk.protex.report.ReportFormat;
|
||||
import com.blackducksoftware.sdk.protex.report.ReportSection;
|
||||
import com.blackducksoftware.sdk.protex.report.ReportSectionType;
|
||||
import com.blackducksoftware.sdk.protex.report.ReportTemplateRequest;
|
||||
|
||||
|
||||
/**
|
||||
* This sample generates COS report and writes it to a file in HTML and xls
|
||||
*
|
||||
* It demonstrates:
|
||||
* - How to generate a report from a client side supplied template
|
||||
* - How to receive this report and write it to a file (using MTOM - Attachments)
|
||||
*/
|
||||
public class GetCOSReport extends BDProtexSample {
|
||||
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("arg[0] - Protex server URL");
|
||||
System.out.println("arg[1] - Protex user ID");
|
||||
System.out.println("arg[2] - Password");
|
||||
System.out.println("arg[3] - Project ID");
|
||||
System.out.println("arg[4] - Output path\\Filename (without extension)");
|
||||
System.out.println("arg[5] - SCS Report Header text");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// check and save parameters
|
||||
if (args.length < 5) {
|
||||
System.err.println("Not enough parameters!");
|
||||
usage();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String serverUri = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
String projectId = args[3];
|
||||
String reportFileName = args[4];
|
||||
//String headerText = args[5];
|
||||
String tableOfContents = "true";
|
||||
|
||||
ReportApi reportApi = null;
|
||||
ProjectApi projectApi = null;
|
||||
try {
|
||||
Long connectionTimeout = 120 * 1000L;
|
||||
ProtexServerProxy myProtexServer = new ProtexServerProxy(serverUri, username, password,
|
||||
connectionTimeout);
|
||||
|
||||
reportApi = myProtexServer.getReportApi(15 * connectionTimeout);
|
||||
projectApi = myProtexServer.getProjectApi(15 * connectionTimeout);
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
System.err.println("Connection to server '" + serverUri + "' failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
Boolean showTOC = Boolean.valueOf("true".equals(tableOfContents));
|
||||
|
||||
//now get the rest of the report data
|
||||
ReportTemplateRequest templateRequest = new ReportTemplateRequest();
|
||||
templateRequest.setName(projectId);
|
||||
Project project = projectApi.getProjectById(projectId);
|
||||
String projectName = project.getName();
|
||||
templateRequest.setTitle("Protex COS Report for " + projectName);
|
||||
//templateRequest.setHeader(headerText);
|
||||
templateRequest.setForced(Boolean.TRUE);
|
||||
//templateRequest.setTableofcontents("TOC");
|
||||
|
||||
|
||||
|
||||
ReportSection section = new ReportSection();
|
||||
section.setLabel("Summary");
|
||||
section.setSectionType(ReportSectionType.SUMMARY);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Analysis Summary");
|
||||
section.setSectionType(ReportSectionType.ANALYSIS_SUMMARY);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("BOM");
|
||||
section.setSectionType(ReportSectionType.BILL_OF_MATERIALS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Licenses in Effect");
|
||||
section.setSectionType(ReportSectionType.LICENSES_IN_EFFECT);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("License Conflicts");
|
||||
section.setSectionType(ReportSectionType.LICENSE_CONFLICTS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("File Inventory");
|
||||
section.setSectionType(ReportSectionType.FILE_INVENTORY);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("IP Architecture");
|
||||
section.setSectionType(ReportSectionType.IP_ARCHITECTURE);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Obligations");
|
||||
section.setSectionType(ReportSectionType.OBLIGATIONS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Identified Files");
|
||||
section.setSectionType(ReportSectionType.IDENTIFIED_FILES);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Excluded Components");
|
||||
section.setSectionType(ReportSectionType.EXCLUDED_COMPONENTS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Work History - Bill of Material");
|
||||
section.setSectionType(ReportSectionType.WORK_HISTORY_BILL_OF_MATERIALS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Work History - File Inventory");
|
||||
section.setSectionType(ReportSectionType.WORK_HISTORY_FILE_INVENTORY);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Potential Bill Of Materials");
|
||||
section.setSectionType(ReportSectionType.POTENTIAL_BILL_OF_MATERIALS);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
section = new ReportSection();
|
||||
section.setLabel("Searches");
|
||||
section.setSectionType(ReportSectionType.STRING_SEARCHES);
|
||||
templateRequest.getSections().add(section);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Call the Api
|
||||
Report reportHTML = null;
|
||||
Report reportXLS = null;
|
||||
try {
|
||||
try {
|
||||
reportHTML = reportApi.generateAdHocProjectReport(projectId, templateRequest, ReportFormat.HTML, showTOC);
|
||||
reportXLS = reportApi.generateAdHocProjectReport(projectId, templateRequest, ReportFormat.XLS, showTOC);
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("generateProjectReport failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// Check for valid return
|
||||
if (reportHTML == null || reportXLS == null) {
|
||||
System.err.println("unexpected return object");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (reportHTML.getFileName() == null || reportXLS.getFileName() == null) {
|
||||
System.err.println("unexpected return object: File name can't be null or empty");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (reportHTML.getFileContent() == null || reportXLS.getFileContent() == null) {
|
||||
System.err.println("unexpected return object: File content can't be null or empty");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
File transferredFileHTML = new File(reportFileName + ".html");
|
||||
File transferredFileXLS = new File(reportFileName + ".xls");
|
||||
FileOutputStream outStream = null;
|
||||
try {
|
||||
|
||||
outStream = new FileOutputStream(transferredFileHTML);
|
||||
reportHTML.getFileContent().writeTo(outStream);
|
||||
} catch (IOException e) {
|
||||
System.err.println("report.getFileContent().writeTo() failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
} finally {
|
||||
if (outStream != null) {
|
||||
outStream.close();
|
||||
}
|
||||
}
|
||||
System.out.println("\nHTML Report written to: " + transferredFileHTML.getAbsolutePath());
|
||||
|
||||
try {
|
||||
|
||||
outStream = new FileOutputStream(transferredFileXLS);
|
||||
reportXLS.getFileContent().writeTo(outStream);
|
||||
} catch (IOException e) {
|
||||
System.err.println("report.getFileContent().writeTo() failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
} finally {
|
||||
if (outStream != null) {
|
||||
outStream.close();
|
||||
}
|
||||
}
|
||||
System.out.println("\nXLS Report written to: " + transferredFileXLS.getAbsolutePath());
|
||||
} catch (SOAPFaultException e) {
|
||||
System.err.println("SampleGenerateReportFromTemplate failed: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
GetCOSReport.java will generate Code Origination Scan (COS) report from the Protex project specified and writes to
|
||||
a output file in HTML and xls format
|
||||
|
||||
How to Execute:
|
||||
java -jar GetCOSReport.jar <Protex server URL> <User ID> <User Password> <Project ID> <Output Path\Filename without extension>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Protex server URL
|
||||
IN arg[1] - User ID
|
||||
IN arg[2] - Password
|
||||
IN arg[3] - Protex project ID
|
||||
OUT arg[4] - Output Path\filename (without file extension)
|
||||
Example:
|
||||
java -jar GetCOSReport.jar http://jfipscn01.intel.com abc@intel.com abc MyTest_5271 c:\ScanResults\MyTest_COS
|
||||
|
||||
Output:
|
||||
c:\ScanResults\MyTest_COS.html
|
||||
c:\ScanResults\MyTest_COS.xls
|
||||
Binary file not shown.
@@ -1,126 +0,0 @@
|
||||
import java.io.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class GenerateCodeCenterDashboard {
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("Folder path\\name - Location and folder name where all Code Center xml files are stored\n" +
|
||||
"File path\\name - location and filename to store the dashboard summary html report ");
|
||||
System.out.println("");
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************************
|
||||
*
|
||||
* @param xml file generated by GetAssociateAndValidateResult script
|
||||
* @return HTML String
|
||||
*********************************************************************************/
|
||||
public String getCodeCenterResult(File file) {
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
//System.out.println("Exists: " + file.getName() + " " + file.exists());
|
||||
if (file.exists()) {
|
||||
Document doc = db.parse(file);
|
||||
|
||||
|
||||
|
||||
NodeList appList = doc.getElementsByTagName("Application");
|
||||
Node appName = appList.item(0);
|
||||
Element appElement = (Element) appName;
|
||||
|
||||
NodeList validList = doc.getElementsByTagName("ValidationStatus");
|
||||
Node validNode = validList.item(0);
|
||||
Element validElement = (Element) validNode;
|
||||
|
||||
NodeList approveList = doc.getElementsByTagName("ApprovedStatus");
|
||||
Node approveNode = approveList.item(0);
|
||||
Element approveElement = (Element) approveNode;
|
||||
|
||||
|
||||
String prj_str = "<tr><td style='text-align: center;'>" + appElement.getTextContent() + "</td>";
|
||||
if (validElement.getTextContent().equals("PASSED"))
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + validElement.getTextContent() + "</td>";
|
||||
else
|
||||
prj_str = prj_str + "<td style='text-align: center;': bgcolor=gold> <b> <font color=red>" + validElement.getTextContent() + "</td>";
|
||||
|
||||
if (approveElement.getTextContent().equals("APPROVED"))
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + approveElement.getTextContent() + "</td></tr>";
|
||||
else
|
||||
prj_str = prj_str + "<td style='text-align: center;': bgcolor=gold> <b> <font color=red>" + approveElement.getTextContent() + "</td></tr>";
|
||||
|
||||
|
||||
return prj_str;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return "Error!! Parsing XML reports";
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
* main()
|
||||
* @param args
|
||||
***********************************************************************************/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 2) {
|
||||
System.err.println("Not enough parameters!");
|
||||
usage();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
GenerateCodeCenterDashboard parser = new GenerateCodeCenterDashboard();
|
||||
String filename;
|
||||
File folder = new File( args[0] );
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
String html_content = "";
|
||||
String OSName = null;
|
||||
String delimiter = null;
|
||||
OSName = System.getProperty("os.name");
|
||||
if (OSName.contains("Windows")) delimiter = "\\";
|
||||
else delimiter = "/";
|
||||
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
if (listOfFiles[i].isFile())
|
||||
{
|
||||
filename = folder.getPath() + delimiter + listOfFiles[i].getName();
|
||||
//System.out.println("File: " + filename);
|
||||
if (filename.endsWith(".xml") || filename.endsWith(".XML"))
|
||||
{
|
||||
File filehandle = new File(filename);
|
||||
String prj_str = parser.getCodeCenterResult( filehandle );
|
||||
html_content = html_content + prj_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File f = new File(args[1]);
|
||||
try {
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
|
||||
bw.write( "<html><body>"
|
||||
+ "<h1> <span style='text-align:center;font-weight:bold'> Code Center Summary </span></h1>"
|
||||
+ "<table border='2px'>"
|
||||
+ "<tr style='background-color: rgb(240, 240, 240);'>"
|
||||
+ "<th style='border-left: 1px solid;'> Code Center Application </th>"
|
||||
+ "<th style='border-left: 1px solid;'> Validation Status </th>"
|
||||
+ "<th style='border-left: 1px solid;'> Approval Status </th>"
|
||||
+ "</tr>"
|
||||
+ html_content + "</table></body></html>" ) ;
|
||||
|
||||
bw.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
GenerateCodeCenterDashboard.java parses the Code Center Application results xml files generated by GetAssociateAndValidateResult.java;
|
||||
read the data and writes the data in a summary (Dashboard) into the output html file.
|
||||
NOTE: All the Code Center Application xml files are required to be stored in a single folder
|
||||
|
||||
How to Execute:
|
||||
java -jar GenerateProtexScanDashboard.jar <stored scan files Path\foldername> <output file path\filename>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Location (PATH) of Code Center result files
|
||||
OUT arg[1] - Dashboard Output Path\filename.html
|
||||
|
||||
|
||||
Example:
|
||||
Windows> java -jar GenerateCodeCenterDashboard.jar c:\Results\CCXML c:\Results\CodeCenter_Dashboard.html
|
||||
Linux> java -jar GenerateCodeCenterDashboard.jar /Results/CCXML /Results/CodeCenter_Dashboard.html
|
||||
|
||||
Output:
|
||||
Windows: c:\Results\CodeCenter_Dashboard.html (Will contain scan result summary of all Code Center xml files)
|
||||
Linux: /Results/CodeCenter_Dashboard.html (Will contain scan result summary of all Code Center xml files)
|
||||
Binary file not shown.
@@ -1,740 +0,0 @@
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.regex.Pattern;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import com.blackducksoftware.sdk.codecenter.application.ApplicationApi;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.Application;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ApplicationNameVersionOrIdToken;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ApplicationNameVersionToken;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.*;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.data.Component;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.data.LicenseNameOrIdToken;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.data.LicenseSummary;
|
||||
import com.blackducksoftware.sdk.codecenter.attribute.AttributeApi;
|
||||
import com.blackducksoftware.sdk.codecenter.attribute.data.AbstractAttribute;
|
||||
import com.blackducksoftware.sdk.codecenter.attribute.data.AttributeNameOrIdToken;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.BDSCodeCenterSample;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.CodeCenterServerProxyV7_0;
|
||||
import com.blackducksoftware.sdk.codecenter.common.data.ApprovalStatusEnum;
|
||||
import com.blackducksoftware.sdk.codecenter.common.data.AttributeValue;
|
||||
import com.blackducksoftware.sdk.codecenter.fault.SdkFault;
|
||||
import com.blackducksoftware.sdk.codecenter.request.RequestApi;
|
||||
import com.blackducksoftware.sdk.codecenter.request.data.*;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This sample file extract application details, application metadata, BOMs, request for metadata and
|
||||
// each components metadata in BOM. It stores all the data in an HTML format into the file passed as argument
|
||||
// The output file if the IP Plan of the application
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class GenerateIPPlanReport extends BDSCodeCenterSample {
|
||||
|
||||
|
||||
private static void usage() {
|
||||
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("arg[0] - Code Center server URL");
|
||||
System.out.println("arg[1] - Code Center user ID");
|
||||
System.out.println("arg[2] - Password");
|
||||
System.out.println("arg[3] - Application name");
|
||||
System.out.println("arg[4] - Output Path");
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* GetComponentData: Get component and component request details for each component in BOM of the application
|
||||
* @param thisapp
|
||||
* @param applicationApi
|
||||
* @param apptoken
|
||||
* @param requestApi
|
||||
* @param colaApi
|
||||
* @param attributeApi
|
||||
* @return String with data in html format
|
||||
************************************************************************************/
|
||||
public String GetComponentData(Application thisapp, ApplicationApi applicationApi, ApplicationNameVersionToken apptoken,
|
||||
RequestApi requestApi, ColaApi colaApi, AttributeApi attributeApi ) {
|
||||
|
||||
|
||||
String ptr_str = "";
|
||||
RequestPageFilter pageFilter = new RequestPageFilter();
|
||||
pageFilter.setFirstRowIndex(0);
|
||||
pageFilter.setLastRowIndex(2000);
|
||||
pageFilter.setSortAscending(false);
|
||||
pageFilter.setSortedColumn(RequestColumn.REQUEST_APPROVAL_STATUS);
|
||||
pageFilter.getApprovalStatuses().add(ApprovalStatusEnum.APPROVED);
|
||||
//get total number of Components in BOM
|
||||
List<RequestSummary> requestsList = null;
|
||||
try {
|
||||
//requestsList = applicationApi.getApplicationRequests(apptoken);
|
||||
requestsList = applicationApi.searchApplicationRequests((ApplicationNameVersionOrIdToken)apptoken, "", pageFilter);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("getApplicationRequests() failed while fetching the details of the request to be updated: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (requestsList == null) {
|
||||
System.err.println("getApplicationRequests() failed: returned null as result");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
System.out.println("# Requests: " + requestsList.size());
|
||||
|
||||
|
||||
for (RequestSummary request : requestsList) {
|
||||
Component thiscomp = null;
|
||||
Request thisreq = null;
|
||||
String Name = " ";
|
||||
String Version = " ";
|
||||
String License = " ";
|
||||
String ReqLicense = " ";
|
||||
String ReqLicenseUsage = " ";
|
||||
String Description = " ";
|
||||
String Homepage = " ";
|
||||
String Supplier = " ";
|
||||
String SupplierCategory = " ";
|
||||
String SoftwareStackClassification = " ";
|
||||
String SoftwareTechnologyClassification = " ";
|
||||
String SpecificTechnologyClassification = " ";
|
||||
String OperatingSystem = " ";
|
||||
String OperatingSystemOther = " ";
|
||||
String ProgrammingLanguage = " ";
|
||||
String ProgrammingLanguageOther = " ";
|
||||
String DeliveryFormat = " ";
|
||||
String CopyrightOwnership = " ";
|
||||
String LicenseSource = " ";
|
||||
String LicenseLocation = " ";
|
||||
String AdditionalInformationAndComments = " ";
|
||||
String Comments = " ";
|
||||
String SourceLocation = " ";
|
||||
String SourceLocationSub = " ";
|
||||
String VersionRest = " ";
|
||||
String ApprovalStatus = " ";
|
||||
String LocationCntrl = " ";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Get the individual component request details like control string,
|
||||
// license source, etc....
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
try {
|
||||
thisreq = requestApi.getRequest(request.getId());
|
||||
} catch (Exception e) {
|
||||
System.err.println("getRequest failed: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}//try....catch
|
||||
|
||||
List<AttributeValue> reqAttList = null;
|
||||
try {
|
||||
ReqLicense = thisreq.getLicenseInfo().getNameToken().getName().trim().replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
} catch (Exception e) {
|
||||
//System.err.println("WARNING: empty Component Request License field");
|
||||
}
|
||||
try {
|
||||
ReqLicenseUsage = thisreq.getUsage().toString();
|
||||
} catch (Exception e) {
|
||||
//System.err.println("WARNING: empty Component Request Usage field");
|
||||
}
|
||||
try {
|
||||
ApprovalStatus = thisreq.getApprovalStatus().toString();
|
||||
} catch (Exception e) {
|
||||
//System.err.println("WARNING: empty Component Request Approval Status field");
|
||||
}
|
||||
try {
|
||||
reqAttList = thisreq.getAttributeValues();
|
||||
} catch (Exception e) {
|
||||
//System.err.println("WARNING: empty Component Request Metadata Values field");
|
||||
}
|
||||
try {
|
||||
if ( null != reqAttList ) {
|
||||
if ( 0 < reqAttList.size() ) {
|
||||
//System.out.println("RequestAttList size is " + reqAttList.size());
|
||||
for (AttributeValue attValue : reqAttList) {
|
||||
AttributeNameOrIdToken attNameToken = attValue.getAttributeId();
|
||||
AbstractAttribute attribute = attributeApi.getAttribute(attNameToken);
|
||||
String attName = attribute.getName().trim();
|
||||
List<String> attStringList = attValue.getValues();
|
||||
|
||||
if (null != attStringList) {
|
||||
if ( 0 < attStringList.size() ) {
|
||||
ListIterator<String> LI = attStringList.listIterator();
|
||||
String attstring = LI.next().trim();
|
||||
while ( LI.hasNext() ) {
|
||||
attstring = attstring + "\n" + LI.next().trim();
|
||||
}
|
||||
attstring = attstring.replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
if ( attName.equals("CPR - Additional Information and Comments") ) {
|
||||
AdditionalInformationAndComments = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPR - License Location") ) {
|
||||
LicenseLocation = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPR - License Source") ) {
|
||||
LicenseSource = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPR - Location") ) {
|
||||
SourceLocation = attstring.trim();
|
||||
if ( SourceLocation.length() > 0 ) {
|
||||
if ( SourceLocation.startsWith("/") ) {
|
||||
SourceLocation = SourceLocation.substring(1);
|
||||
}
|
||||
if ( SourceLocation.endsWith("/") ) {
|
||||
SourceLocation = SourceLocation.substring(0, (SourceLocation.length() - 1) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( attName.equals("CPR - Location - Cntrl") ) {
|
||||
LocationCntrl = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPR - Location - Sub") ) {
|
||||
SourceLocationSub = attstring.trim();
|
||||
if ( SourceLocationSub.length() > 0 ) {
|
||||
if ( SourceLocationSub.startsWith("/") ) {
|
||||
SourceLocationSub = SourceLocationSub.substring(1);
|
||||
}
|
||||
if ( SourceLocationSub.endsWith("/") ) {
|
||||
SourceLocationSub = SourceLocationSub.substring(0, (SourceLocationSub.length() - 1) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( attName.equals("CPR - Versions") ) {
|
||||
VersionRest = attstring.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create component request data, caught exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Get the individual component details
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
try {
|
||||
thiscomp = colaApi.getCatalogComponent(request.getComponentId());
|
||||
} catch (Exception e) {
|
||||
System.err.println("getCatalogComponent() failed: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}//try....catch
|
||||
|
||||
try {
|
||||
Name = thiscomp.getNameVersion().getName().trim();
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Name field");
|
||||
}
|
||||
try {
|
||||
Version = thiscomp.getNameVersion().getVersion().trim();
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Version field");
|
||||
}
|
||||
try {
|
||||
Description = thiscomp.getDescription().trim();
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Description field");
|
||||
}
|
||||
try {
|
||||
Homepage = thiscomp.getHomepage().trim();
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Homepage field");
|
||||
}
|
||||
|
||||
try {
|
||||
//License = thiscomp.getLicenseInfo().getNameToken().getName().trim().replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
License = thiscomp.getDeclaredLicenses().get(0).getNameToken().getName().trim().replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Declared License field");
|
||||
}
|
||||
List<AttributeValue> compAttList = null;
|
||||
try {
|
||||
compAttList = thiscomp.getAttributeValues();
|
||||
} catch (Exception e) {
|
||||
System.err.println("WARNING: empty Component Attribute Values field");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Read the attributes of the component
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
if ( null != compAttList ) {
|
||||
if ( 0 < compAttList.size() ) {
|
||||
for (AttributeValue attValue : compAttList) {
|
||||
|
||||
AttributeNameOrIdToken attNameToken = attValue.getAttributeId();
|
||||
AbstractAttribute attribute = null;
|
||||
try {
|
||||
attribute = attributeApi.getAttribute(attNameToken);
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("WARNING: empty Component Attributes field");
|
||||
}
|
||||
String attName = attribute.getName().trim();
|
||||
|
||||
List<String> attStringList = attValue.getValues();
|
||||
if (null != attStringList) {
|
||||
if ( 0 < attStringList.size() ) {
|
||||
ListIterator<String> LI = attStringList.listIterator();
|
||||
String attstring = LI.next().trim();
|
||||
while ( LI.hasNext() ) {
|
||||
attstring = attstring + "\n\n\n" + LI.next().trim();
|
||||
}
|
||||
attstring = attstring.replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
if ( attName.equals("APP/CPC - SW Stack Classification") ) {
|
||||
SoftwareStackClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP/CPC - SW Technology Classification") ) {
|
||||
SoftwareTechnologyClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP/CPC - SW Technology Classification - Other") ) {
|
||||
SpecificTechnologyClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Copyright Ownership") ) {
|
||||
CopyrightOwnership = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Distribution Type") ) {
|
||||
DeliveryFormat = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Operating System") ) {
|
||||
OperatingSystem = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Operating System - Other") ) {
|
||||
OperatingSystemOther = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Programming Language") ) {
|
||||
ProgrammingLanguage = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Programming Language - Other") ) {
|
||||
ProgrammingLanguageOther = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Software Supplier Category") ) {
|
||||
SupplierCategory = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("CPC - Supplier Name") ) {
|
||||
Supplier = attstring.trim();
|
||||
}
|
||||
|
||||
}//if attstringlist
|
||||
|
||||
} //if attstringlist
|
||||
} //For each compattlist
|
||||
} //if compAttsize
|
||||
ptr_str = ptr_str + "<tr><td style='text-align: center;'>" + Name + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Version + "</td>"
|
||||
+ "<td style='text-align: center;'>" + License + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Description + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Homepage + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Supplier + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SupplierCategory + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SoftwareStackClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SoftwareTechnologyClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SpecificTechnologyClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + OperatingSystem + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ProgrammingLanguage + "</td>"
|
||||
+ "<td style='text-align: center;'>" + DeliveryFormat + "</td>"
|
||||
+ "<td style='text-align: center;'>" + CopyrightOwnership + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ReqLicense + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ReqLicenseUsage + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SourceLocation + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SourceLocationSub + "</td>"
|
||||
+ "<td style='text-align: center;'>" + LocationCntrl + "</td>"
|
||||
+ "<td style='text-align: center;'>" + LicenseLocation + "</td>"
|
||||
+ "<td style='text-align: center;'>" + LicenseSource + "</td>"
|
||||
+ "<td style='text-align: center;'>" + AdditionalInformationAndComments + "</td>"
|
||||
+ "<td style='text-align: center;'>" + VersionRest + "</td>"
|
||||
|
||||
+ "</tr>";
|
||||
} // compattlist = null
|
||||
} //for RequestSummary request
|
||||
|
||||
return ptr_str;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*********************************************************************************************
|
||||
* GetApplicationData() Get Application's details and Metadata
|
||||
* @param thisapp
|
||||
* @param attributeApi
|
||||
* @param colaApi
|
||||
* @return String with data in html format
|
||||
*********************************************************************************************/
|
||||
public String GetApplicationData(Application thisapp, AttributeApi attributeApi, ColaApi colaApi) {
|
||||
|
||||
String Name = null;
|
||||
String Version = null;
|
||||
String ProgramPlatform = null;
|
||||
String ProductName = null;
|
||||
String Description = null;
|
||||
String IdentificationsProductName = null;
|
||||
String SubGroupName = null;
|
||||
String GroupName = null;
|
||||
String OutboundLicense = null;
|
||||
String OBLInstructions = null;
|
||||
String License = null;
|
||||
String LicenseAcceptance = null;
|
||||
String InformationClassification = null;
|
||||
String ExportECCN = null;
|
||||
String Standards = null;
|
||||
String StandardsMember = null;
|
||||
String StandardsList = null;
|
||||
String Indemnification = null;
|
||||
String IndemnificationGMApprover = null;
|
||||
String Warranty = null;
|
||||
String WarrantyDataSheet = null;
|
||||
String SoftwareStackClassification = null;
|
||||
String SoftwareTechnologyClassification = null;
|
||||
String SoftwareTechnologyClassificationOther = null;
|
||||
//String ThirdPartyPatents = null;
|
||||
String IntelPatents = null;
|
||||
String IntelPatentStatus = null;
|
||||
String OpenSource = null;
|
||||
String ptr_str = "";
|
||||
|
||||
|
||||
List<AttributeValue> appAttList = null;
|
||||
try {
|
||||
try {
|
||||
Name = thisapp.getName();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: Name, caught exception: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
Version = thisapp.getVersion();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: Version, caught exception: " + e.getMessage());
|
||||
}
|
||||
LicenseNameOrIdToken LicenseToken = null;
|
||||
try {
|
||||
LicenseToken = thisapp.getLicenseId();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: LicenseToken, caught exception: " + e.getMessage());
|
||||
}
|
||||
if ( LicenseToken != null ) {
|
||||
try {
|
||||
License = colaApi.getLicense(LicenseToken).getNameToken().getName();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: LicenseToken, caught exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Description = thisapp.getDescription().trim().replaceAll(Pattern.quote("\r\n"), "\u0001").replaceAll(Pattern.quote("\r"), "\u0001").replaceAll(Pattern.quote("\n"), "\u0001");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: Description, caught exception: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
appAttList = thisapp.getAttributeValues();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing application data: attributeValues, caught exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// get application metadata
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
if ( null != appAttList ) {
|
||||
if ( 0 < appAttList.size() ) {
|
||||
for (AttributeValue attValue : appAttList) {
|
||||
AttributeNameOrIdToken attNameToken = attValue.getAttributeId();
|
||||
AbstractAttribute attribute = attributeApi.getAttribute(attNameToken);
|
||||
String attName = attribute.getName().trim();
|
||||
List<String> attStringList = attValue.getValues();
|
||||
if (null != attStringList) {
|
||||
if ( 0 < attStringList.size() ) {
|
||||
ListIterator<String> LI = attStringList.listIterator();
|
||||
String attstring = LI.next().trim();
|
||||
while ( LI.hasNext() ) {
|
||||
attstring = attstring + "\n\n\n" + LI.next().trim();
|
||||
}
|
||||
|
||||
attstring = attstring.replaceAll(Pattern.quote("\r\n"), "\n").replaceAll(Pattern.quote("\r"), "\n");
|
||||
if ( attName.equals("APP - Identifications - Program and Platforms")) {
|
||||
ProgramPlatform = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Identifications - Product Name")) {
|
||||
ProductName = attstring.trim();
|
||||
}
|
||||
//if ( attName.equals("APP - 3rd Party Patents")) {
|
||||
//ThirdPartyPatents = attstring.trim();
|
||||
//}
|
||||
if ( attName.equals("APP - Export - ECCN")) {
|
||||
ExportECCN = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Super Group")) {
|
||||
GroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Group - IAG")) {
|
||||
SubGroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Group - SMG")) {
|
||||
SubGroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Group - SSG")) {
|
||||
SubGroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Group - TMG")) {
|
||||
SubGroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.startsWith("APP - Group - Intel Labs")) {
|
||||
SubGroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Identifications - Product Name")) {
|
||||
IdentificationsProductName = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Indemnification")) {
|
||||
Indemnification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Indemnification - GM Approval")) {
|
||||
IndemnificationGMApprover = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Information Classification")) {
|
||||
InformationClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Intel Patents")) {
|
||||
IntelPatents = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Intel Patents - Status")) {
|
||||
IntelPatentStatus = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - OBL")) {
|
||||
OutboundLicense = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - OBL - Instructions")) {
|
||||
OBLInstructions = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - OBL - Acceptance")) {
|
||||
LicenseAcceptance = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Open Source")) {
|
||||
OpenSource = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Standards")) {
|
||||
Standards = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Standards - List")) {
|
||||
StandardsList = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Standards - Member")) {
|
||||
StandardsMember = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Super Group")) {
|
||||
GroupName = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP/CPC - SW Stack Classification")) {
|
||||
SoftwareStackClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP/CPC - SW Technology Classification")) {
|
||||
SoftwareTechnologyClassification = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP/CPC - SW Technology Classification - Other")) {
|
||||
SoftwareTechnologyClassificationOther = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Warranty")) {
|
||||
Warranty = attstring.trim();
|
||||
}
|
||||
if ( attName.equals("APP - Warranty - Data Sheet")) {
|
||||
WarrantyDataSheet = attstring.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr_str = "<tr><td style='text-align: center;'>" + Name + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Version + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ProgramPlatform + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ProductName + "</td>"
|
||||
+ "<td style='text-align: center;'>" + GroupName + "/" + SubGroupName + "</td>"
|
||||
+ "<td style='text-align: center;'>" + OutboundLicense + "</td>"
|
||||
+ "<td style='text-align: center;'>" + OBLInstructions + "</td>"
|
||||
+ "<td style='text-align: center;'>" + LicenseAcceptance + "</td>"
|
||||
+ "<td style='text-align: center;'>" + InformationClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + OpenSource + "</td>"
|
||||
+ "<td style='text-align: center;'>" + ExportECCN + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Standards + "</td>"
|
||||
+ "<td style='text-align: center;'>" + StandardsMember + "</td>"
|
||||
+ "<td style='text-align: center;'>" + StandardsList + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Indemnification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + IndemnificationGMApprover + "</td>"
|
||||
+ "<td style='text-align: center;'>" + Warranty + "</td>"
|
||||
+ "<td style='text-align: center;'>" + WarrantyDataSheet + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SoftwareStackClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SoftwareTechnologyClassification + "</td>"
|
||||
+ "<td style='text-align: center;'>" + SoftwareTechnologyClassificationOther + "</td>"
|
||||
//+ "<td style='text-align: center;'>" + ThirdPartyPatents + "</td>"
|
||||
+ "<td style='text-align: center;'>" + IntelPatents + "</td>"
|
||||
+ "<td style='text-align: center;'>" + IntelPatentStatus + "</td>"
|
||||
|
||||
|
||||
+ "</tr>";
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create application data, caught exception: " + e.getMessage());
|
||||
}
|
||||
return ptr_str;
|
||||
};
|
||||
|
||||
/**********************************************************************************
|
||||
* main()
|
||||
* @param args
|
||||
* @throws Exception
|
||||
**********************************************************************************/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// check and save parameters
|
||||
if (args.length < 5) {
|
||||
System.err.println("\n\nNot enough parameters!");
|
||||
usage();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String serverUri = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
String applicationName = args[3];
|
||||
String Path = args[4];
|
||||
String outFile = "";
|
||||
|
||||
ApplicationApi applicationApi = null;
|
||||
RequestApi requestApi = null;
|
||||
AttributeApi attributeApi = null;
|
||||
ColaApi colaApi = null;
|
||||
|
||||
try {
|
||||
Long connectionTimeout = 600 * 1000L;
|
||||
CodeCenterServerProxyV7_0 myCodeCenterServer = new CodeCenterServerProxyV7_0(serverUri, username, password,
|
||||
connectionTimeout);
|
||||
applicationApi = myCodeCenterServer.getApplicationApi();
|
||||
attributeApi = myCodeCenterServer.getAttributeApi();
|
||||
colaApi = myCodeCenterServer.getColaApi();
|
||||
requestApi = myCodeCenterServer.getRequestApi();
|
||||
} catch (RuntimeException e) {
|
||||
System.err.println("\nConnection to server '" + serverUri + "' failed: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// get the application object
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Application thisapp = null;
|
||||
ApplicationNameVersionToken apptoken = new ApplicationNameVersionToken();
|
||||
String OSName = null;
|
||||
String delimiter = null;
|
||||
OSName = System.getProperty("os.name");
|
||||
if (OSName.contains("Windows")) delimiter = "\\";
|
||||
else delimiter = "/";
|
||||
outFile = Path + delimiter + applicationName + " IP Plan.html";
|
||||
try {
|
||||
apptoken.setName(applicationName);
|
||||
apptoken.setVersion("Unspecified");
|
||||
thisapp = applicationApi.getApplication(apptoken);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
apptoken.setVersion("unspecified");
|
||||
thisapp = applicationApi.getApplication(apptoken);
|
||||
} catch (Exception e1) {
|
||||
System.err.println("get APP " + applicationName + " caught exception : " + e1.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
if ( null == thisapp ) {
|
||||
System.err.println("FAILED: to get app for " + applicationName );
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String html_content = "";
|
||||
|
||||
GenerateIPPlanReport ipplan = new GenerateIPPlanReport();
|
||||
html_content = ipplan.GetApplicationData(thisapp, attributeApi, colaApi);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write the application and components in an HTML file with HTML tags
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
File f = new File(outFile);
|
||||
try {
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
|
||||
// Write application details and metadata
|
||||
bw.write( "<html><body>"
|
||||
+ "<header><h1> <span style='text-align:center;font-weight:bold'>" + applicationName + " IP Plan"
|
||||
+ "</span></h1></header>"
|
||||
+ "<table border='2px'>"
|
||||
+ "<tr style='background-color: rgb(240, 240, 240);'>"
|
||||
+ "<th> Application Name </th>"
|
||||
+ "<th> Application version </th>"
|
||||
+ "<th> Program/Platform </th>"
|
||||
+ "<th> Product Name </th>"
|
||||
+ "<th> Group Name </th>"
|
||||
+ "<th> OBL </th>"
|
||||
+ "<th> OBL Instruction </th>"
|
||||
+ "<th> License Acceptance </th>"
|
||||
+ "<th> Information Classification </th>"
|
||||
+ "<th> Open Source Distribution </th>"
|
||||
+ "<th> Export Community Control Number </th>"
|
||||
+ "<th> Standards </th>"
|
||||
+ "<th> Standard Member </th>"
|
||||
+ "<th> Standard List </th>"
|
||||
+ "<th> Indemnification </th>"
|
||||
+ "<th> Indemnification GM Approver </th>"
|
||||
+ "<th> Warranty </th>"
|
||||
+ "<th> Warranty - Product/Software Data Sheet </th>"
|
||||
+ "<th> Software Stack Classification </th>"
|
||||
+ "<th> Software Technology Classification </th>"
|
||||
+ "<th> Specific Technology Classification </th>"
|
||||
//+ "<th> 3rd Party Patents </th>"
|
||||
+ "<th> Intel Patents </th>"
|
||||
+ "<th> Intel Patent Status </th>"
|
||||
+ "</tr>"
|
||||
+ html_content
|
||||
+ "</table>" ) ;
|
||||
bw.write(" ");
|
||||
|
||||
html_content = ipplan.GetComponentData(thisapp, applicationApi, apptoken, requestApi, colaApi, attributeApi);
|
||||
|
||||
// Write each component and its request component details and its metadata
|
||||
bw.write( "<header><h1> <span style='text-align:center;font-weight:bold'>" + " Bill Of Materials"
|
||||
+ "</span></h1></header>"
|
||||
+"<table border='2px'>"
|
||||
+ "<tr style='background-color: rgb(240, 240, 240);'>"
|
||||
+ "<th> Component Name </th>"
|
||||
+ "<th> Component version </th>"
|
||||
+ "<th> License </th>"
|
||||
+ "<th> Description </th>"
|
||||
+ "<th> Homepage </th>"
|
||||
+ "<th> Supplier </th>"
|
||||
+ "<th> Supplier Category </th>"
|
||||
+ "<th> Software Stack Classification </th>"
|
||||
+ "<th> Software Technology Classification </th>"
|
||||
+ "<th> Software Technology Classification Other </th>"
|
||||
+ "<th> Operating System </th>"
|
||||
+ "<th> Programming Language </th>"
|
||||
+ "<th> Distribution Type </th>"
|
||||
+ "<th> Copyright Ownership </th>"
|
||||
+ "<th> Requested License </th>"
|
||||
+ "<th> Requested Usage </th>"
|
||||
+ "<th> Software Location </th>"
|
||||
+ "<th> Software Sub Location </th>"
|
||||
+ "<th> Control Strings </th>"
|
||||
+ "<th> License Location </th>"
|
||||
+ "<th> License Source </th>"
|
||||
+ "<th> Version Restrictions </th>"
|
||||
+ "<th> Information and Comments </th>"
|
||||
+ "</tr>"
|
||||
+ html_content
|
||||
+ "</table></body></html>" ) ;
|
||||
System.out.println("Done");
|
||||
|
||||
bw.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
} //main()
|
||||
|
||||
} //class GenerateIPPlan
|
||||
File diff suppressed because one or more lines are too long
@@ -1,20 +0,0 @@
|
||||
GenerateIPPlanReport.java extracts application metadata and BOM details from the Code Center application specified in input parameter
|
||||
and writes to a output file in HTML format. The output file created is with filename as "<Application Name> IP Plan.html"
|
||||
|
||||
How to Execute:
|
||||
java -jar GenerateIPPlanReport.jar <Code Center Server URL> <User ID> <User Password> <Application Name> <Output Path>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Code Center server URL
|
||||
IN arg[1] - Code Center user ID
|
||||
IN arg[2] - Password
|
||||
IN arg[3] - Application name
|
||||
OUT arg[4] - Output Path (without filename)
|
||||
Example:
|
||||
Windows> java -jar GenerateIPPlanReport.jar http://sccodecenter.intel.com abc@intel.com abc "Android R4 AOSP Abi" "c:\IP Plans"
|
||||
Linux> java -jar GenerateIPPlanReport.jar http://sccodecenter.intel.com abc@intel.com abc "Android R4 AOSP Abi" "/IP Plans"
|
||||
|
||||
Output:
|
||||
Windows: c:\IP Plans\Android R4 AOSP Abi IP Plan.html
|
||||
Linux: /IP Plans/Android R4 AOSP Abi IP Plan.html
|
||||
|
||||
Binary file not shown.
@@ -1,174 +0,0 @@
|
||||
import java.io.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class GenerateProtexScanDashboard {
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("Folder path\\name - Location and folder name where all scan results xml files are stored\n" +
|
||||
"File path\\name - location and filename to store the dashboard summary html report ");
|
||||
System.out.println("");
|
||||
|
||||
}
|
||||
|
||||
public String getAllScanResult(File file) {
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
int number;
|
||||
//File file = new File(fileName);
|
||||
|
||||
//System.out.println("Exists: " + file.getName() + " " + file.exists());
|
||||
if (file.exists()) {
|
||||
Document doc = db.parse(file);
|
||||
|
||||
|
||||
//System.out.println("File: " + fileName);
|
||||
//System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
|
||||
//System.out.println("Root element attrib :" + doc.getDocumentElement().getAttribute("name"));
|
||||
|
||||
NodeList serverList = doc.getElementsByTagName("ServerUrl");
|
||||
Node serverUrlNode = serverList.item(0);
|
||||
Element serverUrlElement = (Element) serverUrlNode;
|
||||
//System.out.println("Server url: " + serverUrlElement.getTextContent());
|
||||
|
||||
NodeList analyzedTimeList = doc.getElementsByTagName("LastAnalyzed");
|
||||
Node anaTimeNode = analyzedTimeList.item(0);
|
||||
Element anaTimeElement = (Element) anaTimeNode;
|
||||
//System.out.println("ANAly Time: " + anaTimeElement.getTextContent());
|
||||
|
||||
NodeList analyzedList = doc.getElementsByTagName("Analyzed");
|
||||
Node anaNode = analyzedList.item(0);
|
||||
Element anaElement = (Element) anaNode;
|
||||
//System.out.println("ANAly : " + anaElement.getTextContent());
|
||||
|
||||
NodeList pendingList = doc.getElementsByTagName("PendingID");
|
||||
Node penNode = pendingList.item(0);
|
||||
Element penElement = (Element) penNode;
|
||||
//System.out.println("Pending : " + penElement.getTextContent());
|
||||
|
||||
NodeList totCompList = doc.getElementsByTagName("TotalComponents");
|
||||
Node tCompNode = totCompList.item(0);
|
||||
Element tCompElement = (Element) tCompNode;
|
||||
//System.out.println("total Comp : " + tCompElement.getTextContent());
|
||||
|
||||
NodeList totLicList = doc.getElementsByTagName("TotalLicenses");
|
||||
Node tLicNode = totLicList.item(0);
|
||||
Element tLicElement = (Element) tLicNode;
|
||||
//System.out.println("Tot Lic : " + tLicElement.getTextContent());
|
||||
|
||||
NodeList pendingRevList = doc.getElementsByTagName("PendingReview");
|
||||
Node penRevNode = pendingRevList.item(0);
|
||||
Element penRevElement = (Element) penRevNode;
|
||||
//System.out.println("Pending Rev: " + penRevElement.getTextContent());
|
||||
|
||||
NodeList licVioList = doc.getElementsByTagName("LicenseViolations");
|
||||
Node licVioNode = licVioList.item(0);
|
||||
Element licVioElement = (Element) licVioNode;
|
||||
//System.out.println("Lice Violati : " + licVioElement.getTextContent());
|
||||
|
||||
String prj_str = "<tr><td><a href='" + serverUrlElement.getTextContent() + "' target='_blank'>"
|
||||
+ doc.getDocumentElement().getAttribute("name") + "</a></td>"
|
||||
+ "<td style='text-align: center;'>" + anaTimeElement.getTextContent() + "</td>"
|
||||
+ "<td style='text-align: center;'>" + anaElement.getTextContent() + "</td>";
|
||||
|
||||
number = Integer.parseInt(penElement.getTextContent());
|
||||
if (number > 0)
|
||||
prj_str = prj_str + "<td style='text-align: center;': bgcolor=gold> <b> <font color=red>" + penElement.getTextContent() + "</font></b></td>";
|
||||
else
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + penElement.getTextContent() + "</td>";
|
||||
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + tCompElement.getTextContent() + "</td>"
|
||||
+ "<td style='text-align: center;'>" + tLicElement.getTextContent() + "</td>";
|
||||
|
||||
number = Integer.parseInt(penRevElement.getTextContent());
|
||||
if (number > 0)
|
||||
prj_str = prj_str + "<td style='text-align: center;': bgcolor=gold> <b> <font color=red>" + penRevElement.getTextContent() + "</font></b></td>";
|
||||
else
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + penRevElement.getTextContent() + "</td>";
|
||||
|
||||
number = Integer.parseInt(licVioElement.getTextContent());
|
||||
if (number > 0)
|
||||
prj_str = prj_str + "<td style='text-align: center;': bgcolor=gold> <b> <font color=red>" + licVioElement.getTextContent() + "</font></b></td>";
|
||||
else
|
||||
prj_str = prj_str + "<td style='text-align: center;'>" + licVioElement.getTextContent() + "</td>";
|
||||
|
||||
// prj_str = prj_str + "<td style='text-align: center;'><a href='COS_report.html' target='_blank'>COS Report</a></td></tr>";
|
||||
|
||||
return prj_str;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return "Error!! Parsing XML reports";
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 2) {
|
||||
System.err.println("Not enough parameters!");
|
||||
usage();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
GenerateProtexScanDashboard parser = new GenerateProtexScanDashboard();
|
||||
String filename;
|
||||
File folder = new File( args[0] );
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
String html_content = "";
|
||||
String OSName = null;
|
||||
String delimiter = null;
|
||||
OSName = System.getProperty("os.name");
|
||||
if (OSName.contains("Windows")) delimiter = "\\";
|
||||
else delimiter = "/";
|
||||
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
if (listOfFiles[i].isFile())
|
||||
{
|
||||
filename = folder.getPath() + delimiter + listOfFiles[i].getName();
|
||||
//System.out.println("File: " + filename);
|
||||
if (filename.endsWith(".xml") || filename.endsWith(".XML"))
|
||||
{
|
||||
File filehandle = new File(filename);
|
||||
String prj_str = parser.getAllScanResult( filehandle );
|
||||
html_content = html_content + prj_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File f = new File(args[1]);
|
||||
try {
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
|
||||
bw.write( "<html><body>"
|
||||
+ "<h1> <span style='text-align:center;font-weight:bold'> Protex Scan Summary </span></h1>"
|
||||
+ "<table border='2px'>"
|
||||
+ "<tr style='background-color: rgb(240, 240, 240);'>"
|
||||
+ "<th rowspan='2'> Protex Project </th>"
|
||||
+ "<th rowspan='2'> Last Scan Timestamp </th>"
|
||||
+ "<th colspan='2' style='border-bottom: 1px solid;'> Files </th>"
|
||||
+ "<th colspan='4' style='border-bottom: 1px solid;'> BOM </th>"
|
||||
// + "<th rowspan='2'> Detailed Summary </th>"
|
||||
+ "</tr><tr style='background-color: rgb(240, 240, 240);'>"
|
||||
+ "<th style='border-left: 1px solid;'> Analyzed </th>"
|
||||
+ "<th style='border-left: 1px solid;'> Pending </th>"
|
||||
+ "<th style='border-left: 1px solid;'> Components </th>"
|
||||
+ "<th style='border-left: 1px solid;'> NumLicense </th>"
|
||||
+ "<th style='border-left: 1px solid;'> PendingReview </th>"
|
||||
+ "<th style='border-left: 1px solid;'> LicenseViolations </th></tr>"
|
||||
+ html_content + "</table></body></html>" ) ;
|
||||
|
||||
bw.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
GenerateProtexScanDashboard.java parses the scan results xml files generated by GetScanResults.java; read the data and
|
||||
writes the data in a summary (Dashboard) into the output html file.
|
||||
NOTE: All the scan analysis result xml files (generated from GetScanResult script are required to be stored in a single folder)
|
||||
|
||||
How to Execute:
|
||||
java -jar GenerateProtexScanDashboard.jar <stored scan files Path\foldername> <output file path\filename>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Location of scan analysis files
|
||||
OUT arg[1] - Dashboard Output Path\filename.html
|
||||
|
||||
Example:
|
||||
Windows> java -jar GenerateProtexScanDashboard.jar c:\ScanResults c:\scanResults\Protex_Project_Summary.html
|
||||
Linux> java -jar GenerateProtexScanDashboard.jar /ScanResults /scanResults/Protex_Project_Summary.html
|
||||
|
||||
Output:
|
||||
Windows: c:\scanResults\Protex_Project_Summary.html (Will contain scan result summary of all xml files)
|
||||
Linux: /scanResults/Protex_Project_Summary.html
|
||||
Binary file not shown.
@@ -1,219 +0,0 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
import com.blackducksoftware.sdk.codecenter.application.ApplicationApi;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.Application;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ApplicationNameVersionOrIdToken;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ApplicationNameVersionToken;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.BDSCodeCenterSample;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.CodeCenterServerProxyV7_0;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.ColaApi;
|
||||
import com.blackducksoftware.sdk.codecenter.cola.data.Component;
|
||||
import com.blackducksoftware.sdk.codecenter.common.data.ApprovalStatusEnum;
|
||||
import com.blackducksoftware.sdk.codecenter.request.RequestApi;
|
||||
import com.blackducksoftware.sdk.codecenter.request.data.Request;
|
||||
import com.blackducksoftware.sdk.codecenter.request.data.RequestColumn;
|
||||
import com.blackducksoftware.sdk.codecenter.request.data.RequestPageFilter;
|
||||
import com.blackducksoftware.sdk.codecenter.request.data.RequestSummary;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//This sample file dis-associates any previous association with Protex project
|
||||
//and associates with the Project passed in as argument and validates with project
|
||||
//RETURNS 0 FOR SUCCESS AND 1 FOR FAILURE
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class GetAssociateAndValidateResult extends BDSCodeCenterSample {
|
||||
|
||||
private static ApplicationApi appApi = null;
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("arg[0] - Code Center server URL");
|
||||
System.out.println("arg[1] - Code Center user ID");
|
||||
System.out.println("arg[2] - Password");
|
||||
System.out.println("arg[3] - Application Name");
|
||||
System.out.println("arg[4] - Output Path without filename");
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
* main()
|
||||
* @param args
|
||||
* @throws Exception
|
||||
**************************************************************************************************/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// check and save parameters
|
||||
if (args.length < 5) {
|
||||
System.err.println("\n\nNot enough parameters!");
|
||||
usage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String serverUri = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
// Set the attachment Id
|
||||
String applicationName = args[3];
|
||||
String Path = args[4];
|
||||
String outFilePath = "";
|
||||
String ValidationStatus = "ERROR";
|
||||
String ApprovalStatus = "UNAPPROVED";
|
||||
RequestApi requestApi = null;
|
||||
ColaApi colaApi = null;
|
||||
try {
|
||||
Long connectionTimeout = 120 * 1000L;
|
||||
CodeCenterServerProxyV7_0 myCodeCenterServer = new CodeCenterServerProxyV7_0(serverUri, username, password,
|
||||
connectionTimeout);
|
||||
// Try some longer timeouts.
|
||||
// yes this is a blanket hack
|
||||
// revisit this later to see if timeouts can be reduced to normal.
|
||||
appApi = myCodeCenterServer.getApplicationApi();
|
||||
appApi = myCodeCenterServer.getApplicationApi( 0L ); //workaround from bd. call this twice and use infinite timeout
|
||||
requestApi = myCodeCenterServer.getRequestApi();
|
||||
colaApi = myCodeCenterServer.getColaApi();
|
||||
} catch (RuntimeException e) {
|
||||
System.err.println("\nConnection to server '" + serverUri + "' failed: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// get the application object
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Application thisapp = null;
|
||||
ApplicationNameVersionToken apptoken = new ApplicationNameVersionToken();
|
||||
try {
|
||||
apptoken.setName(applicationName);
|
||||
apptoken.setVersion("Unspecified");
|
||||
thisapp = appApi.getApplication(apptoken);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
apptoken.setVersion("unspecified");
|
||||
thisapp = appApi.getApplication(apptoken);
|
||||
} catch (Exception e1) {
|
||||
System.err.println("get APP " + applicationName + " caught exception : " + e1.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
if ( null == thisapp ) {
|
||||
System.err.println("FAILED: to get app for " + applicationName );
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Read validation status
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
ValidationStatus = thisapp.getValidationStatus().toString();
|
||||
/*if ( validateException || (! ValidationStatus.equals("PASSED")) ) {
|
||||
System.err.println("Validation status is " + ValidationStatus + " for app " + applicationName );
|
||||
ValidationStatus = "Unavailable";
|
||||
}*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Read Application Approval Status
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
List<RequestSummary> requestsList = null;
|
||||
String ptr_str = "";
|
||||
RequestPageFilter pageFilter = new RequestPageFilter();
|
||||
pageFilter.setFirstRowIndex(0);
|
||||
pageFilter.setLastRowIndex(10);
|
||||
pageFilter.setSortAscending(false);
|
||||
pageFilter.setSortedColumn(RequestColumn.REQUEST_APPROVAL_STATUS);
|
||||
pageFilter.getApprovalStatuses().add(ApprovalStatusEnum.APPROVED);
|
||||
try {
|
||||
requestsList = appApi.searchApplicationRequests((ApplicationNameVersionOrIdToken)apptoken, "", pageFilter);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("getApplicationRequests() failed while fetching the details of the request to be updated: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (requestsList == null) {
|
||||
System.err.println("getApplicationRequests() failed: returned null as result");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
for (RequestSummary request : requestsList) {
|
||||
Request thisreq = null;
|
||||
Component thiscomp = null;
|
||||
String Name = " ";
|
||||
try {
|
||||
thisreq = requestApi.getRequest(request.getId());
|
||||
} catch (Exception e) {
|
||||
System.err.println("getRequest failed: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}//try....catch
|
||||
|
||||
try {
|
||||
thiscomp = colaApi.getCatalogComponent(request.getComponentId());
|
||||
} catch (Exception e) {
|
||||
System.err.println("getCatalogComponent() failed: "
|
||||
+ e.getMessage());
|
||||
System.exit(-1);
|
||||
}//try....catch
|
||||
|
||||
try {
|
||||
Name = thiscomp.getNameVersion().getName().trim();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Missing component data : Name, caught exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
if (Name.equals("IP Plan Approval")) {
|
||||
try {
|
||||
ApprovalStatus = thisreq.getApprovalStatus().toString();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create request data: ApprovalStatus, caught exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} //for (RequestSummary request : requestsList)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write the application status in an xml file
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
String OSName = null;
|
||||
String delimiter = null;
|
||||
OSName = System.getProperty("os.name");
|
||||
if (OSName.contains("Windows")) delimiter = "\\";
|
||||
else delimiter = "/";
|
||||
outFilePath = Path + delimiter + applicationName + "_CM.xml";
|
||||
PrintWriter outFile = null;
|
||||
|
||||
try {
|
||||
outFile = new PrintWriter(outFilePath);
|
||||
} catch (Exception e) {
|
||||
System.err.println("\nUnable to create output file writer : " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
outFile.println("<ApplicationData>");
|
||||
outFile.println("<Application>" + applicationName + "</Application>");
|
||||
outFile.println("<ApprovedStatus>" + ApprovalStatus + "</ApprovedStatus>");
|
||||
outFile.println("<ValidationStatus>" + ValidationStatus + "</ValidationStatus>");
|
||||
outFile.println("</ApplicationData>");
|
||||
outFile.flush();
|
||||
outFile.close();
|
||||
|
||||
|
||||
System.exit(0);
|
||||
|
||||
} catch (SOAPFaultException e) {
|
||||
System.err.println("GetCodeCenterApplication failed in main: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
GetAssociateAndValidateResult.jar will read the Application's (passed in as argument) Validate and IP Approval status and writes the data into an
|
||||
output file in xml format. The file generated will be the same as application name with "_CM.xml" suffix.
|
||||
|
||||
How to Execute:
|
||||
java -jar GetAssociateAndValidateResult.jar <Code Center server URL> <Code Center Username> <Password> <Code Center application> <output path>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Code Center server URL
|
||||
IN arg[1] - User ID
|
||||
IN arg[2] - Password
|
||||
IN arg[3] - Application (IP Plan) name
|
||||
OUT arg[4] - Output Path without filename
|
||||
|
||||
Example:
|
||||
Windows> java -jar GetAssociateAndValidateResult.jar http://sccodecenter.intel.com abc@intel.com abc "My App" "C:\Results\CCXML"
|
||||
Linux> java -jar GetAssociateAndValidateResult.jar http://sccodecenter.intel.com abc@intel.com abc "My App" "/Results/CCXML"
|
||||
|
||||
Output:
|
||||
Windows: C:\Results\CCXML\My App_CM.xml
|
||||
Linux: /Results/CCXML/My App_CM.xml
|
||||
Binary file not shown.
@@ -1,266 +0,0 @@
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
//import org.apache.cxf.common.util.SortedArraySet;
|
||||
|
||||
|
||||
|
||||
import com.blackducksoftware.sdk.fault.SdkFault;
|
||||
import com.blackducksoftware.sdk.protex.client.util.BDProtexSample;
|
||||
import com.blackducksoftware.sdk.protex.client.util.ProtexServerProxy;
|
||||
import com.blackducksoftware.sdk.protex.project.Project;
|
||||
import com.blackducksoftware.sdk.protex.project.ProjectApi;
|
||||
import com.blackducksoftware.sdk.protex.project.bom.BomApi;
|
||||
import com.blackducksoftware.sdk.protex.project.bom.BomLicenseInfo;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.CodeTreeApi;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.CodeTreeNode;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.CodeTreeNodeRequest;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.CodeTreeNodeType;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.NodeCount;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.NodeCountType;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.discovery.CodeMatchDiscovery;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.discovery.CodeMatchType;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.discovery.DiscoveryApi;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.discovery.IdentificationStatus;
|
||||
import com.blackducksoftware.sdk.protex.project.codetree.identification.IdentificationApi;
|
||||
|
||||
/**
|
||||
* This sample program retrieves scan results and store the results in XML format in the output
|
||||
* file which is passed as input argument 4
|
||||
*
|
||||
* Retrieves below info:
|
||||
* - Total files analyzed
|
||||
* - Total file skipped
|
||||
* - Total files with pending identifications
|
||||
* - Total original code files
|
||||
* - List of inbound licenses
|
||||
* - OBL
|
||||
*/
|
||||
public class GetScanResult extends BDProtexSample {
|
||||
|
||||
private static String translateXmlEntities(String line) {
|
||||
|
||||
if ( null == line ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
//this MUST go first
|
||||
return line.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll("'", "'")
|
||||
.replaceAll("\"", """);
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("arg[0] - Protex server URL");
|
||||
System.out.println("arg[1] - Protex user ID");
|
||||
System.out.println("arg[2] - Password");
|
||||
System.out.println("arg[3] - Project ID");
|
||||
System.out.println("arg[4] - Location of output xml file");
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************************
|
||||
*
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// check and save parameters
|
||||
if (args.length < 5) {
|
||||
System.err.println("Not enough parameters!");
|
||||
usage();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
String serverUri = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
String projectId = args[3];
|
||||
String outPath = args[4];
|
||||
|
||||
ProjectApi projectApi = null;
|
||||
CodeTreeApi codetreeApi = null;
|
||||
DiscoveryApi discoveryApi = null;
|
||||
BomApi bomApi = null;
|
||||
|
||||
// get service and service port
|
||||
try {
|
||||
Long connectionTimeout = 120 * 1000L;
|
||||
ProtexServerProxy myProtexServer = new ProtexServerProxy(serverUri, username, password,
|
||||
connectionTimeout);
|
||||
|
||||
projectApi = myProtexServer.getProjectApi(5 * connectionTimeout);
|
||||
codetreeApi = myProtexServer.getCodeTreeApi(15 * connectionTimeout);
|
||||
discoveryApi = myProtexServer.getDiscoveryApi(15 * connectionTimeout);
|
||||
bomApi = myProtexServer.getBomApi(30 * connectionTimeout);
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
System.err.println("Connection to server '" + serverUri + "' failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
//get the license list
|
||||
List<BomLicenseInfo> licenses = null;
|
||||
try {
|
||||
licenses = bomApi.getBomLicenseInfo(projectId);
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("\ngetLicenseInfo failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
// Check for valid return
|
||||
if (licenses == null) {
|
||||
System.err.println("\ngetLicenseInfo: unexpected return object");
|
||||
System.exit(-1);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// code tree nodes
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int DEPTH = 1; //pulling just the parent results in all 0 counts!??
|
||||
CodeTreeNodeRequest nodeRequest = new CodeTreeNodeRequest();
|
||||
nodeRequest.setDepth(DEPTH);
|
||||
nodeRequest.getCounts().add(NodeCountType.PENDING_ID_CODE_MATCH);
|
||||
nodeRequest.getCounts().add(NodeCountType.PENDING_REVIEW);
|
||||
nodeRequest.getCounts().add(NodeCountType.VIOLATIONS);
|
||||
nodeRequest.getCounts().add(NodeCountType.NO_DISCOVERIES);
|
||||
nodeRequest.getCounts().add(NodeCountType.FILES);
|
||||
nodeRequest.getCounts().add(NodeCountType.DISCOVERED_COMPONENTS);
|
||||
nodeRequest.getIncludedNodeTypes().add(CodeTreeNodeType.EXPANDED_ARCHIVE);
|
||||
nodeRequest.getIncludedNodeTypes().add(CodeTreeNodeType.FILE);
|
||||
nodeRequest.getIncludedNodeTypes().add(CodeTreeNodeType.FOLDER);
|
||||
nodeRequest.setIncludeParentNode(true);
|
||||
|
||||
// get CodeTree
|
||||
String root = "/";
|
||||
int TOP_ONLY = 0;
|
||||
Long analyzedFiles = null;
|
||||
Long skippedFiles = null;
|
||||
Long discoveriesPending = null;
|
||||
Long noDiscoveries = null;
|
||||
Long discoveredComponents = null;
|
||||
Integer bomComponents = null;
|
||||
Integer bomLicenses = null;
|
||||
Long pendingReview = null;
|
||||
Long licenseViolations = null;
|
||||
|
||||
//PartialCodeTree partialCodeTree = null;
|
||||
List<CodeTreeNode> partialCodeTree = null;
|
||||
try {
|
||||
partialCodeTree = codetreeApi.getCodeTreeNodes(projectId, root, nodeRequest);
|
||||
for ( CodeTreeNode node : partialCodeTree) {
|
||||
if ( ! node.getName().equals("") ) continue;
|
||||
|
||||
List<NodeCount> countList = node.getNodeCounts();
|
||||
for (NodeCount count: countList) {
|
||||
Long value = count.getCount();
|
||||
NodeCountType type = count.getCountType();
|
||||
if ( NodeCountType.PENDING_ID_CODE_MATCH == type ) {
|
||||
discoveriesPending = value;
|
||||
} else if ( NodeCountType.PENDING_REVIEW == type ) {
|
||||
pendingReview = value;
|
||||
} else if ( NodeCountType.VIOLATIONS == type ) {
|
||||
licenseViolations = value;
|
||||
} else if ( NodeCountType.NO_DISCOVERIES == type ) {
|
||||
noDiscoveries = value;
|
||||
} else if ( NodeCountType.FILES == type ) {
|
||||
analyzedFiles = value;
|
||||
} else if ( NodeCountType.DISCOVERED_COMPONENTS == type ) {
|
||||
discoveredComponents = value;
|
||||
}
|
||||
|
||||
}//for (NodeCount
|
||||
}//for ( CodeTreeNode node
|
||||
|
||||
skippedFiles = codetreeApi.getSkippedFileCount(projectId);
|
||||
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("getCodeTree(TOP_ONLY) failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Project project = null;
|
||||
String analyzedDate = null;
|
||||
String projectName = null;
|
||||
project = projectApi.getProjectById(projectId);
|
||||
if (project != null) {
|
||||
DateFormat formatter = new SimpleDateFormat("dd MMM, yyyy hh:mm:ss a");
|
||||
analyzedDate = formatter.format(project.getLastAnalyzedDate().getTime());
|
||||
projectName = project.getName();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BOM (file) counts
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
try {
|
||||
bomComponents = bomApi.getBomComponentCount(projectId);
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("getBomComponentCount() failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
try {
|
||||
bomLicenses = bomApi.getBomLicenseCount(projectId);
|
||||
} catch (SdkFault e) {
|
||||
System.err.println("getBomLicenseCount() failed: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
PrintWriter outFile = null;
|
||||
try {
|
||||
outFile = new PrintWriter(outPath);
|
||||
} catch (Exception e) {
|
||||
System.err.println("\nUnable to create output file writer : " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
outFile.println("<Project name=\"" + projectName + "\" id=\"" + projectId + "\" >");
|
||||
outFile.println("<ServerUrl>" + serverUri +"</ServerUrl>");
|
||||
outFile.println("<LastAnalyzed>" + analyzedDate +"</LastAnalyzed>");
|
||||
outFile.println("<ScanFileInfo>");
|
||||
outFile.println("\t<Analyzed>" + analyzedFiles + "</Analyzed>");
|
||||
outFile.println("\t<Skipped>" + skippedFiles + "</Skipped>");
|
||||
outFile.println("\t<PendingID>" + discoveriesPending + "</PendingID>");
|
||||
outFile.println("\t<NoDiscoveries>" + noDiscoveries + "</NoDiscoveries>" );
|
||||
outFile.println("</ScanFileInfo>");
|
||||
outFile.println("<Components>");
|
||||
outFile.println("\t<DiscoveredComponents>" + discoveredComponents + "</DiscoveredComponents>");
|
||||
outFile.println("</Components>");
|
||||
|
||||
outFile.println("<BOM>");
|
||||
outFile.println("\t<TotalComponents>" + bomComponents + "</TotalComponents>");
|
||||
outFile.println("\t<TotalLicenses>" + bomLicenses + "</TotalLicenses>");
|
||||
outFile.println("\t<LicenseList>");
|
||||
if (licenses.size() == 0) {
|
||||
outFile.println("\t\t<None/>");
|
||||
} else {
|
||||
for (BomLicenseInfo license : licenses) {
|
||||
String licensename = translateXmlEntities(license.getName());
|
||||
if ( ! licensename.equals("Unspecified") ) {
|
||||
outFile.println("\t\t<License>" + licensename + "</License>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outFile.println("\t</LicenseList>");
|
||||
outFile.println("\t<PendingReview>" + pendingReview + "</PendingReview>");
|
||||
outFile.println("\t<LicenseViolations>" + licenseViolations + "</LicenseViolations>");
|
||||
outFile.println("</BOM>");
|
||||
outFile.println("</Project>\n");
|
||||
|
||||
outFile.flush();
|
||||
outFile.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
GetScanResult.java collects the scan analysis summary (# files scanned; # Pending identification; # Licencen conflicts; etc)
|
||||
of a protex Project passed is as argument. If the project is scanned, the analysis are written to the outfile passed in as
|
||||
argument. Else, throws an exception
|
||||
|
||||
How to Execute:
|
||||
java -jar GetScanResult.jar <Protex server URL> <User ID> <User Password> <Project ID> <Output Path\Filename>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Protex server URL
|
||||
IN arg[1] - the username for this server
|
||||
IN arg[2] - password
|
||||
IN arg[3] - Project ID
|
||||
OUT arg[4] - location of output xml file
|
||||
|
||||
Example:
|
||||
java -jar GetScanResult.jar http://jfipscn01.intel.com abc@intel.com abc c_test_k_5271 c:\ScanResults\Project_Scan_result.xml
|
||||
|
||||
Output:
|
||||
c:\ScanResults\Project_Scan_result.xml (Will contain scan result)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
RunAssociateAndValidateProtexProject.java will dis-associate the application from previously associated Protex project and
|
||||
re-associate the application to the project name passed as argument and execute validate. This script does the data integrity
|
||||
check between the application and Protex project
|
||||
|
||||
How to Execute:
|
||||
java -jar RunAssociateAndValidateProtexProject.jar <Code Center server URL> <Code Center Username> <Password> <Code Center application> <Project Name> <Protex Server ID>
|
||||
|
||||
Input Parameters:
|
||||
IN arg[0] - Code Center server URL
|
||||
IN arg[1] - User ID
|
||||
IN arg[2] - Password
|
||||
IN arg[3] - Application (IP Plan) name
|
||||
IN arg[4] - Protex Project name
|
||||
IN arg[5] - Protex Server ID
|
||||
|
||||
Example:
|
||||
java -jar RunAssociateAndValidateProtexProject.jar http://sccodecenter.intel.com abc@intel.com abc "My App" "My Project" JF1
|
||||
|
||||
=======================================================================================================================
|
||||
|
||||
Protex Server ID Protex Server URL
|
||||
BA1 http://baipscn01.intel.com
|
||||
GK1 http://gkipscn01.intel.com
|
||||
HD1 http://hdipscn01.intel.com
|
||||
IL1 http://iilipscn01.intel.com
|
||||
JF1 http://jfipscn01.intel.com
|
||||
JF2 http://jfipscn02.intel.com
|
||||
JF03 http://jfipscn03.intel.com
|
||||
NN01 http://nnsipscn01.intel.com
|
||||
SC2 http://scipscn02.intel.com
|
||||
SC3 http://scipscn03.intel.com
|
||||
SH1 http://shipscn01.intel.com
|
||||
Binary file not shown.
@@ -1,142 +0,0 @@
|
||||
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
import com.blackducksoftware.sdk.codecenter.administration.data.ServerNameToken;
|
||||
import com.blackducksoftware.sdk.codecenter.application.ApplicationApi;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.Application;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ApplicationNameVersionToken;
|
||||
import com.blackducksoftware.sdk.codecenter.application.data.ProjectNameToken;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.BDSCodeCenterSample;
|
||||
import com.blackducksoftware.sdk.codecenter.client.util.CodeCenterServerProxyV7_0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//This sample file dis-associates any previous association with Protex project
|
||||
//and associates with the Project passed in as argument and validates with project
|
||||
//RETURNS 0 FOR SUCCESS AND 1 FOR FAILURE
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public class RunAssociateAndValidateProtexProject extends BDSCodeCenterSample {
|
||||
|
||||
private static ApplicationApi appApi = null;
|
||||
|
||||
private static void usage() {
|
||||
System.out.println("Input Parameters:" );
|
||||
System.out.println("arg[0] - Code Center server URL");
|
||||
System.out.println("arg[1] - Code Center user ID");
|
||||
System.out.println("arg[2] - Password");
|
||||
System.out.println("arg[3] - Application Name");
|
||||
System.out.println("arg[4] - Protex Project Name");
|
||||
System.out.println("arg[5] - Protex Server ID (Readme file under RunAssociateAndValidateProject folder has all server ID details");
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
* main()
|
||||
* @param args
|
||||
* @throws Exception
|
||||
**************************************************************************************************/
|
||||
public static void main(String[] args) throws Exception {
|
||||
// check and save parameters
|
||||
if (args.length < 6) {
|
||||
System.err.println("\n\nNot enough parameters!");
|
||||
usage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
String serverUri = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
// Set the attachment Id
|
||||
String applicationName = args[3];
|
||||
String projectName = args[4];
|
||||
String projectServer = args[5];
|
||||
|
||||
|
||||
try {
|
||||
Long connectionTimeout = 120 * 1000L;
|
||||
CodeCenterServerProxyV7_0 myCodeCenterServer = new CodeCenterServerProxyV7_0(serverUri, username, password,
|
||||
connectionTimeout);
|
||||
// Try some longer timeouts.
|
||||
// yes this is a blanket hack
|
||||
// revisit this later to see if timeouts can be reduced to normal.
|
||||
appApi = myCodeCenterServer.getApplicationApi();
|
||||
appApi = myCodeCenterServer.getApplicationApi( 0L ); //workaround from bd. call this twice and use infinite timeout
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
System.err.println("\nConnection to server '" + serverUri + "' failed: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
ServerNameToken protexServerToken = new ServerNameToken();
|
||||
ProjectNameToken protexProjectToken = new ProjectNameToken();
|
||||
try {
|
||||
protexServerToken.setName(projectServer);
|
||||
protexProjectToken.setServerId(protexServerToken);
|
||||
protexProjectToken.setName(projectName);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Caught exception setting up Protex project token : " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// get the application object
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Application thisapp = null;
|
||||
ApplicationNameVersionToken apptoken = new ApplicationNameVersionToken();
|
||||
try {
|
||||
apptoken.setName(applicationName);
|
||||
apptoken.setVersion("Unspecified");
|
||||
thisapp = appApi.getApplication(apptoken);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
apptoken.setVersion("unspecified");
|
||||
thisapp = appApi.getApplication(apptoken);
|
||||
} catch (Exception e1) {
|
||||
System.err.println("get APP " + applicationName + " caught exception : " + e1.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
if ( null == thisapp ) {
|
||||
System.err.println("FAILED: to get app for " + applicationName );
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//Disassociate current application project pair
|
||||
try {
|
||||
appApi.disassociateProtexProject(apptoken);
|
||||
} catch (Exception e) {
|
||||
System.err.println("\ndisassociate() call in main() for application " + applicationName + " caught exception: " + e.getMessage());
|
||||
}
|
||||
//Associate application to new project
|
||||
try {
|
||||
appApi.associateProtexProject(apptoken, protexProjectToken);
|
||||
} catch (Exception e) {
|
||||
System.err.println("\nassociate() call in main() for application " + applicationName + " caught exception: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//validate the Application Project pair
|
||||
String ValidationStatus = "ERROR";
|
||||
try {
|
||||
appApi.validate(apptoken, true, true);
|
||||
ValidationStatus = "PASSED";
|
||||
} catch (Exception e) {
|
||||
System.err.println("API exception: appApi.validate() for " + applicationName + " : " + e.getMessage());
|
||||
if ( -1 != e.getMessage().indexOf("not synchronized") ) {
|
||||
ValidationStatus = "NotSynched";
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(ValidationStatus);
|
||||
System.exit(0);
|
||||
|
||||
} catch (SOAPFaultException e) {
|
||||
System.err.println("GetCodeCenterApplication failed in main: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
ScanProtexProject.bat will take the user credentials, Protex server URL and project ID as input. The bat uses bdstool
|
||||
to initiate the scan. After the 1st scan, rerun of this .bat file will only scan changes in code base will be scanned.
|
||||
If a forced scan is needed, then open the ScanProtexProject.bat in edit more, and update to below line
|
||||
call bdstool analyze --force
|
||||
|
||||
Prerequisite:
|
||||
Protex client MUST be installed prior to executing the script
|
||||
|
||||
How to Execute:
|
||||
Windows OS:
|
||||
1) Open a DOS Window
|
||||
ScanProtexProject.bat <Protex server URL> <User ID> <User Password> <Project ID> <Scan Folder Path>
|
||||
|
||||
Linux OS
|
||||
1) Open a bash windows
|
||||
sh ScanProtexProject.sh <Protex server URL> <User ID> <User Password> <Project ID> <Scan Folder Path>
|
||||
Input Parameters:
|
||||
IN arg[0] - Protex server URL
|
||||
IN arg[1] - User ID
|
||||
IN arg[2] - Password
|
||||
IN arg[3] - Protex project ID
|
||||
IN arg[4] - Source files Path
|
||||
|
||||
Example:
|
||||
ScanProtexProject.bat https://jfipscn01.intel.com abc@intel.com abc c_test_k_5271 c:\ScanSource
|
||||
sh ScanProtexProject.sh https://jfipscn01.intel.com abc@intel.com abc c_test_k_5271 ~/ScanSource
|
||||
================================================================================================================================
|
||||
Protex Server ID Protex Server URL
|
||||
BA1 https://baipscn01.intel.com
|
||||
GK1 https://gkipscn01.intel.com
|
||||
IL1 https://iilipscn01.intel.com
|
||||
JF1 https://jfipscn01.intel.com
|
||||
JF2 https://jfipscn02.intel.com
|
||||
JF03 https://jfipscn03.intel.com
|
||||
JF04 https://jfipscn04.intel.com
|
||||
JF05 https://jfipscn05.intel.com
|
||||
JF06 https://jfipscn06.intel.com
|
||||
NN01 https://nnsipscn01.intel.com
|
||||
SC2 https://scipscn02.intel.com
|
||||
SC3 https://scipscn03.intel.com
|
||||
SH1 https://shipscn01.intel.com
|
||||
MU01 https://imuipscn01.intel.com
|
||||
@@ -1,38 +0,0 @@
|
||||
@echo off
|
||||
if "%1" == "" GOTO ENDFILE
|
||||
if "%2" == "" GOTO ENDFILE
|
||||
if "%3" == "" GOTO ENDFILE
|
||||
if "%4" == "" GOTO ENDFILE
|
||||
if "%5" == "" GOTO ENDFILE
|
||||
|
||||
|
||||
Rem set environmental values to enable login to the Protex server
|
||||
|
||||
|
||||
Rem Set the server URL
|
||||
SET BDSSERVER=%1
|
||||
|
||||
Rem Set the login name
|
||||
SET BDSUSER=%2
|
||||
|
||||
Rem Set the password
|
||||
SET BDSPASSWORD=%3
|
||||
|
||||
pushd "%5"
|
||||
call bdstool login
|
||||
call bdstool new-project %4 --verbose
|
||||
call bdstool analyze
|
||||
call bdstool logout
|
||||
goto DONE
|
||||
|
||||
:ENDFILE
|
||||
echo "Arugument Missing"
|
||||
echo "Input Parameters:" );
|
||||
echo "arg[1] - Protex server URL e.g http://scipscn03.intel.com");
|
||||
echo "arg[2] - Protex user ID e.g abc@intel.com");
|
||||
echo "arg[3] - Password e.g abc");
|
||||
echo "arg[4] - Project ID e.g c_byt_beta_audio_6009");
|
||||
echo "arg[5] - Source Code location e.g \"C:\\MySource\\ScanDir\"");
|
||||
|
||||
:DONE
|
||||
popd
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -ne 5 ]; then
|
||||
echo "Arugument Missing"
|
||||
echo "Input Parameters:"
|
||||
echo "arg[1] - Protex server URL"
|
||||
echo "arg[2] - Protex user ID e.g abc@intel.com"
|
||||
echo "arg[3] - Password e.g abc"
|
||||
echo "arg[4] - Project ID e.g c_byt_beta_audio_6009"
|
||||
echo "arg[5] - Source Code location e.g /home/sourcefiles"
|
||||
exit
|
||||
fi
|
||||
|
||||
# set environmental values to enable login to the Protex server
|
||||
|
||||
# Set the server URL
|
||||
export BDSSERVER=$1
|
||||
|
||||
# Set the login name
|
||||
export BDSUSER=$2
|
||||
|
||||
# Set the password
|
||||
SET BDSPASSWORD=$3
|
||||
|
||||
pushd $5
|
||||
bdstool login
|
||||
bdstool new-project $4 --verbose
|
||||
bdstool analyze
|
||||
bdstool logout
|
||||
popd
|
||||
|
||||
exit
|
||||
Reference in New Issue
Block a user