- add standalone presentation checker
This commit is contained in:
parent
ead8f766e7
commit
0a7a90a67a
4
bigbluebutton-web/pres-checker/.gitignore
vendored
Normal file
4
bigbluebutton-web/pres-checker/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
lib/
|
||||||
|
build/
|
||||||
|
.gradle
|
||||||
|
|
38
bigbluebutton-web/pres-checker/build.gradle
Executable file
38
bigbluebutton-web/pres-checker/build.gradle
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
apply plugin: 'java'
|
||||||
|
|
||||||
|
sourceCompatibility=1.8
|
||||||
|
targetCompatibility=1.8
|
||||||
|
|
||||||
|
version = '0.0.1'
|
||||||
|
archivesBaseName = 'bbb-pres-check'
|
||||||
|
|
||||||
|
task resolveDeps(type: Copy) {
|
||||||
|
into('lib')
|
||||||
|
from configurations.default
|
||||||
|
from configurations.default.allArtifacts.file
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile 'org.apache.poi:poi:3.15@jar'
|
||||||
|
compile 'org.apache.poi:poi-ooxml:3.15@jar'
|
||||||
|
compile 'org.apache.poi:poi-ooxml-schemas:3.15@jar'
|
||||||
|
compile 'commons-io:commons-io:2.4@jar'
|
||||||
|
compile 'org.apache.commons:commons-lang3:3.5@jar'
|
||||||
|
compile 'org.apache.commons:commons-collections4:4.1@jar'
|
||||||
|
compile 'org.apache.xmlbeans:xmlbeans:2.6.0@jar'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest.mainAttributes("Permissions": "all-permissions")
|
||||||
|
manifest.mainAttributes("Codebase": "*")
|
||||||
|
manifest.mainAttributes("Application-Name": "BigBlueButton Presentation Checker")
|
||||||
|
manifest.mainAttributes("Application-Library-Allowable-Codebase": "*")
|
||||||
|
manifest.mainAttributes("Caller-Allowable-Codebase": "*")
|
||||||
|
manifest.mainAttributes("Trusted-Only": "true")
|
||||||
|
}
|
||||||
|
|
4
bigbluebutton-web/pres-checker/build.sh
Executable file
4
bigbluebutton-web/pres-checker/build.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
gradle clean
|
||||||
|
gradle jar
|
||||||
|
cp build/lib/*.jar lib
|
||||||
|
|
2
bigbluebutton-web/pres-checker/run.sh
Executable file
2
bigbluebutton-web/pres-checker/run.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
java -cp "lib/*" org.bigbluebutton.prescheck.Main $@
|
||||||
|
|
@ -0,0 +1,94 @@
|
|||||||
|
package org.bigbluebutton.prescheck;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.collections4.Predicate;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||||
|
import org.apache.poi.xslf.usermodel.XSLFPictureData;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Main main = new Main();
|
||||||
|
|
||||||
|
String filepath;
|
||||||
|
try {
|
||||||
|
// Parse the string argument into an integer value.
|
||||||
|
filepath = args[0];
|
||||||
|
boolean valid = main.check(main, filepath);
|
||||||
|
if (!valid) System.exit(2);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
catch (Exception nfe) {
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean check(Main main, String file) {
|
||||||
|
boolean valid = true;
|
||||||
|
XMLSlideShow xmlSlideShow;
|
||||||
|
try {
|
||||||
|
xmlSlideShow = new XMLSlideShow(new FileInputStream(file));
|
||||||
|
valid &= !main.embedsEmf(xmlSlideShow);
|
||||||
|
valid &= !main.containsTinyTileBackground(xmlSlideShow);
|
||||||
|
// Close the resource once we finished reading it
|
||||||
|
xmlSlideShow.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the slide-show file embeds any EMF document
|
||||||
|
*
|
||||||
|
* @param xmlSlideShow
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean embedsEmf(XMLSlideShow xmlSlideShow) {
|
||||||
|
EmfPredicate emfPredicate = new EmfPredicate();
|
||||||
|
ArrayList<XSLFPictureData> embeddedEmfFiles = (ArrayList<XSLFPictureData>) CollectionUtils
|
||||||
|
.select(xmlSlideShow.getPictureData(), emfPredicate);
|
||||||
|
if (embeddedEmfFiles.size() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the slide-show contains a small background tile image
|
||||||
|
*
|
||||||
|
* @param xmlSlideShow
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean containsTinyTileBackground(XMLSlideShow xmlSlideShow) {
|
||||||
|
TinyTileBackgroundPredicate tinyTileCondition = new TinyTileBackgroundPredicate();
|
||||||
|
ArrayList<XSLFPictureData> tileImage = (ArrayList<XSLFPictureData>) CollectionUtils
|
||||||
|
.select(xmlSlideShow.getPictureData(), tinyTileCondition);
|
||||||
|
if (tileImage.size() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class EmfPredicate implements Predicate<XSLFPictureData> {
|
||||||
|
public boolean evaluate(XSLFPictureData img) {
|
||||||
|
return img.getContentType().equals("image/x-emf");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class TinyTileBackgroundPredicate
|
||||||
|
implements Predicate<XSLFPictureData> {
|
||||||
|
public boolean evaluate(XSLFPictureData img) {
|
||||||
|
return img.getContentType() != null
|
||||||
|
&& img.getContentType().equals("image/jpeg")
|
||||||
|
&& LittleEndian.getLong(img.getChecksum()) == 4114937224L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user