Child: [r5] (diff)

Download this file

actions.java    81 lines (66 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* SPDXVersion: SPDX-1.1
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
* Creator: Organization: TripleCheck (contact@triplecheck.de)
* Created: 2013-09-13T00:00:00Z
* LicenseName: NOASSERTION
* FileName: actions.java
* FileType: SOURCE
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
* FileComment: <text> A simple static class to provide default actions
* related to SPDX handling </text>
*/
package main;
import definitions.is;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import script.log;
import spdxlib.SPDXfile;
public class actions {
/**
* Find all files within a given folder, return the respective
* details such as hashes and other details relevant for SPDX processing
* @param folder The folder location where we will look for SPDX files
*/
public static ArrayList<SPDXfile> findSPDX(File folder){
// only find the SPDX documents with .SPDX extension
ArrayList<File> files = utils.files.findFilesFiltered(folder, ".spdx", 25);
ArrayList<SPDXfile> list = new ArrayList();
try {
for(File file: files){
String filePath = file.getCanonicalPath();
// ignore SVN folders of any kind
if(filePath.contains(".svn")){
continue;
}
SPDXfile spdxFile;
spdxFile = new SPDXfile(file.getCanonicalFile());
list.add(spdxFile);
}
String pathName = folder.getCanonicalPath();
pathName = "."
+ pathName.replace(core.getWorkFolder().getCanonicalPath(), "");
// System.err.println(core.getWorkFolder().getCanonicalPath());
log.write(is.INFO, "Found %1 files in %2",
files.size()
+"", pathName);
} catch (IOException ex) {
Logger.getLogger(actions.class.getName()).log(Level.SEVERE, null, ex);
System.exit(-100);
}
return list;
}
/**
* This method adds up all the licenses found on the licenses folder
*/
public static void addLicenses(){
File folder = new File(core.getWorkFolder(), "licenses");
ArrayList<File> files = utils.files.findFilesFiltered(folder, ".java", 2);
for(File file : files){
core.script.runJava(file, null, is.license);
}
}
}