--- a/tool/src/spdxlib/DocumentCreate.java
+++ b/tool/src/spdxlib/DocumentCreate.java
@@ -12,6 +12,7 @@
package spdxlib;
+import definitions.is;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
@@ -21,6 +22,7 @@
import script.License;
import ssdeep.ssdeep;
import main.core;
+import script.log;
/**
@@ -49,6 +51,7 @@
boolean isOk = false;
+ public ArrayList<File> files;
public boolean isProcessing;
public int
@@ -82,7 +85,7 @@
return null;
}
// get the files from the target source code folder
- ArrayList<File> files = utils.files.findFiles(folderSourceCode);
+ files = utils.files.findFiles(folderSourceCode);
// no need to continue if no files were found
if((files == null) || (files.isEmpty())){
System.err.println("ND02 - No files were found for creating SPDX");
@@ -102,8 +105,6 @@
String textDate = getDateSPDX();
- // save this title as UID
- UID = ">> " + filename + " >> Products ";
filename = filename + ".spdx";
@@ -129,6 +130,8 @@
+ addParagraph("File Information")
;
+
+ log.write(is.INFO, "Preparing to process %1 files", "" + files.size());
// iterate through each file
for(File thisFile : files){
@@ -201,6 +204,8 @@
+ utils.Checksum.generateFileChecksum("MD5", thisFile))
+ addText("FileChecksum: SSDEEP: " + ssdeep)
+ addText("FileSize: " + fileSize)
+// + addText("FileModified: " + getFileDateSPDX(thisFile))
+
+ addText(LOC)
//+ addText("FileLastModified: " + fileModified)
+ licenseInfoInFile
@@ -271,4 +276,21 @@
//TODO for some reason "T" and "Z" are not accepted as parameters
return textDate.replace(" ", "T") + "Z";
}
+
+
+ /**
+ * Get the current time and date in SPDX format from a file
+ * @param file the file from where we want the date
+ * @return the properly formatted SPDX time format
+ */
+ public static String getFileDateSPDX(File file) {
+ // do the time calculation such as 2012-09-03T13:32:12Z
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date date = new Date(file.lastModified());
+ String textDate = dateFormat.format(date);
+ //TODO for some reason "T" and "Z" are not accepted as parameters
+ return textDate.replace(" ", "T") + "Z";
+ }
+
+
}