Skip to content

Commit 3ad4f31

Browse files
Merge pull request #300 from mpradny/java_sl_split
#299 Early import of Java Script libraries
2 parents 3d77c3f + 81464f1 commit 3ad4f31

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

nsfodp/bundles/org.openntf.nsfodp.commons.odp/src/org/openntf/nsfodp/commons/odp/OnDiskProject.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class OnDiskProject {
5656
"Code/Agents/*.ija", //$NON-NLS-1$
5757
"Code/Agents/*.lsa", //$NON-NLS-1$
5858
"Code/Agents/*.aa", //$NON-NLS-1$
59-
"Code/ScriptLibraries/*.javalib", //$NON-NLS-1$
6059
"Folders/*", //$NON-NLS-1$
6160
"Forms/*", //$NON-NLS-1$
6261
"Framesets/*", //$NON-NLS-1$
@@ -73,6 +72,12 @@ public class OnDiskProject {
7372
).collect(Collectors.toList());
7473
private final List<PathMatcher> directDxlFiles;
7574

75+
public static final List<String> DIRECT_EARLY_DXL_FILE_GLOBS = Stream.of(
76+
"Code/ScriptLibraries/*.javalib" //$NON-NLS-1$
77+
).collect(Collectors.toList());
78+
private final List<PathMatcher> directEarlyDxlFiles;
79+
80+
7681
public static final List<String> IGNORED_FILE_GLOBS = Stream.of(
7782
"**/.DS_Store", //$NON-NLS-1$
7883
"**/Thumbs.db" //$NON-NLS-1$
@@ -110,6 +115,9 @@ public OnDiskProject(Path baseDirectory) {
110115
this.directDxlFiles = DIRECT_DXL_FILE_GLOBS.stream()
111116
.map(glob -> GlobMatcher.glob(baseDir.getFileSystem(), glob))
112117
.collect(Collectors.toList());
118+
this.directEarlyDxlFiles = DIRECT_EARLY_DXL_FILE_GLOBS.stream()
119+
.map(glob -> GlobMatcher.glob(baseDir.getFileSystem(), glob))
120+
.collect(Collectors.toList());
113121
this.ignoredFileGlobs = IGNORED_FILE_GLOBS.stream()
114122
.map(glob -> GlobMatcher.glob(baseDir.getFileSystem(), glob))
115123
.collect(Collectors.toList());
@@ -280,6 +288,20 @@ public Stream<Path> getDirectDXLElements() {
280288
.flatMap(Function.identity());
281289
}
282290

291+
public Stream<Path> getDirectEarlyDXLElements() {
292+
return directEarlyDxlFiles.stream()
293+
.map(glob -> {
294+
try {
295+
return Files.find(baseDir, Integer.MAX_VALUE, (path, attr) -> {
296+
return glob.matches(baseDir.relativize(path)) && attr.size() > 0;
297+
});
298+
} catch (IOException e) {
299+
throw new RuntimeException(e);
300+
}
301+
})
302+
.flatMap(Function.identity());
303+
}
304+
283305
public List<AbstractSplitDesignElement> getFileResources() {
284306
FileSystem fs = baseDir.getFileSystem();
285307
return FILE_RESOURCES.stream()

nsfodp/bundles/org.openntf.nsfodp.compiler/src/org/openntf/nsfodp/compiler/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Messages extends NLS {
3232
public static String ODPCompiler_errorConvertingXSP;
3333
public static String ODPCompiler_importingCustomControls;
3434
public static String ODPCompiler_importingDbProperties;
35+
public static String ODPCompiler_importingEarlyDesignElements;
3536
public static String ODPCompiler_importingDesignElements;
3637
public static String ODPCompiler_importingFileResources;
3738
public static String ODPCompiler_importingJava;

nsfodp/bundles/org.openntf.nsfodp.compiler/src/org/openntf/nsfodp/compiler/ODPCompiler.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public synchronized Path compile(ClassLoader cl) throws Exception {
398398
try(NDXLImporter importer = session.createDXLImporter()) {
399399

400400
importDbProperties(importer, database);
401+
importEarlyBasicElements(importer, database);
401402
importLotusScriptLibraries(importer, database);
402403
importBasicElements(importer, database);
403404
importFileResources(importer, database);
@@ -598,6 +599,30 @@ private void importDbProperties(NDXLImporter importer, NDatabase database) throw
598599
importDxl(importer, dxl, database, "database.properties"); //$NON-NLS-1$
599600
}
600601

602+
private void importEarlyBasicElements(NDXLImporter importer, NDatabase database) throws Exception {
603+
subTask(Messages.ODPCompiler_importingEarlyDesignElements);
604+
List<Integer> noteIds = new ArrayList<>();
605+
try(Stream<Path> dxlElements = odp.getDirectEarlyDXLElements()) {
606+
dxlElements
607+
.filter(p -> {
608+
try {
609+
return Files.size(p) > 0;
610+
} catch (IOException e) {
611+
throw new RuntimeException(e);
612+
}
613+
})
614+
.forEach(p -> {
615+
try {
616+
try(InputStream is = NSFODPUtil.newInputStream(p)) {
617+
noteIds.addAll(importDxl(importer, is, database, MessageFormat.format(Messages.ODPCompiler_basicElementLabel, odp.getBaseDirectory().relativize(p))));
618+
}
619+
} catch(Exception e) {
620+
throw new RuntimeException("Exception while importing element " + odp.getBaseDirectory().relativize(p), e);
621+
}
622+
});
623+
}
624+
}
625+
601626
private void importBasicElements(NDXLImporter importer, NDatabase database) throws Exception {
602627
subTask(Messages.ODPCompiler_importingDesignElements);
603628
List<Integer> noteIds = new ArrayList<>();

nsfodp/bundles/org.openntf.nsfodp.compiler/src/org/openntf/nsfodp/compiler/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ODPCompiler_dxlImportFailed=DXL import failed for element ''{0}'':\n{1}
2727
ODPCompiler_errorConvertingXSP=Exception while converting XSP element {0}
2828
ODPCompiler_importingCustomControls=Importing custom controls
2929
ODPCompiler_importingDbProperties=Importing DB properties
30+
ODPCompiler_importingEarlyDesignElements=Importing basic design elements - early part (Java libs)
3031
ODPCompiler_importingDesignElements=Importing basic design elements
3132
ODPCompiler_importingFileResources=Importing file resources
3233
ODPCompiler_importingJava=Importing Java design elements

0 commit comments

Comments
 (0)