mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-31 08:25:39 +00:00
Merge pull request #291 from nsacyber/logfile-enhancement-cleanup
[#290] RIM Upload modification
This commit is contained in:
commit
32fcecd48a
@ -30,6 +30,8 @@ import java.util.UUID;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -59,6 +61,7 @@ public class ReferenceManifestPageController
|
|||||||
extends PageController<NoPageParams> {
|
extends PageController<NoPageParams> {
|
||||||
|
|
||||||
private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
||||||
|
private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rim|rimel|bin|log))$)";
|
||||||
|
|
||||||
private final BiosDateValidator biosValidator;
|
private final BiosDateValidator biosValidator;
|
||||||
private final ReferenceManifestManager referenceManifestManager;
|
private final ReferenceManifestManager referenceManifestManager;
|
||||||
@ -193,9 +196,9 @@ public class ReferenceManifestPageController
|
|||||||
// loop through the files
|
// loop through the files
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
fileName = file.getOriginalFilename();
|
fileName = file.getOriginalFilename();
|
||||||
if (fileName.toLowerCase().endsWith("swidtag")) {
|
Pattern pattern = Pattern.compile(LOG_FILE_PATTERN);
|
||||||
rims.add(file);
|
Matcher matcher = pattern.matcher(fileName);
|
||||||
} else {
|
if (matcher.matches()) {
|
||||||
filePath = Paths.get(String.format("%s/%s",
|
filePath = Paths.get(String.format("%s/%s",
|
||||||
SwidResource.RESOURCE_UPLOAD_FOLDER,
|
SwidResource.RESOURCE_UPLOAD_FOLDER,
|
||||||
file.getOriginalFilename()));
|
file.getOriginalFilename()));
|
||||||
@ -212,6 +215,10 @@ public class ReferenceManifestPageController
|
|||||||
"%s successfully uploaded", file.getOriginalFilename());
|
"%s successfully uploaded", file.getOriginalFilename());
|
||||||
messages.addSuccess(uploadCompletedMessage);
|
messages.addSuccess(uploadCompletedMessage);
|
||||||
LOGGER.info(uploadCompletedMessage);
|
LOGGER.info(uploadCompletedMessage);
|
||||||
|
} else {
|
||||||
|
// assume it is a swid tag, processing below will throw and error
|
||||||
|
// if it is not.
|
||||||
|
rims.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,10 +232,6 @@ public class ReferenceManifestPageController
|
|||||||
messages,
|
messages,
|
||||||
rim,
|
rim,
|
||||||
referenceManifestManager);
|
referenceManifestManager);
|
||||||
|
|
||||||
for (SwidResource swidRes : rim.parseResource()) {
|
|
||||||
System.out.println("testing this section!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ public class ReferenceManifest extends ArchivableEntity {
|
|||||||
if (jaxbe != null) {
|
if (jaxbe != null) {
|
||||||
return jaxbe;
|
return jaxbe;
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Invalid swidtag file!");
|
throw new IOException("Invalid Base RIM, swidtag format expected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user