Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
add support parsing swf-metadata to swfparser flash supports metadata tag in swf file with metadata in xmp (xml) format. parse some common data to include it in the head section of the html string of converttohtml.
reger06e5cd616400
diff --git a/lib/webcat-swf-0.1.jar b/lib/webcat-swf-0.1.jarindex f39fcc9a5..79ab7eebb 100644Binary files a/lib/webcat-swf-0.1.jar and b/lib/webcat-swf-0.1.jar differdiff --git a/libbuild/WebCat-swf/pom.xml b/libbuild/WebCat-swf/pom.xmlindex 14b90ed84..57cf305d2 100644--- a/libbuild/WebCat-swf/pom.xml+++ b/libbuild/WebCat-swf/pom.xml@@ -52,5 +52,11 @@<version>1.5</version><type>jar</type></dependency>+ <dependency>+ <groupId>com.adobe.xmp</groupId>+ <artifactId>xmpcore</artifactId>+ <version>5.1.2</version>+ <type>jar</type>+ </dependency></dependencies></project>\ No newline at end of filediff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.javaindex 53fb8d718..45792b5a5 100644--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java@@ -1,5 +1,10 @@package pt.tumba.parser.swf;+import com.adobe.xmp.XMPConst;+import com.adobe.xmp.XMPException;+import com.adobe.xmp.XMPMeta;+import com.adobe.xmp.XMPMetaFactory;+import com.adobe.xmp.properties.XMPProperty;import java.io.ByteArrayInputStream;import java.io.File;import java.io.FileInputStream;@@ -34,15 +39,9 @@ public class SWF2HTML extends SWFTagTypesImpl {}- /**- * Description of the Field- */protected Map fontCodes = new HashMap();-- /**- * Description of the Field- */- protected PrintWriter output;+ protected String headerstr ="";+ protected PrintWriter output; // body of html output (containing all text)//private HTMLParser aux;@@ -159,6 +158,65 @@ public class SWF2HTML extends SWFTagTypesImpl {return new TextDumper();}+ /**+ * Parse and interprete Metadata string (xmp rdf format) and create a+ * html header tags for the html output+ *+ * @param xml Metadata+ * @throws IOException+ */+ @Override+ public void tagMetaData(String xml) throws IOException {++ try {+ XMPMeta xmpmeta = XMPMetaFactory.parseFromString(xml);+ XMPProperty xp = xmpmeta.getProperty(XMPConst.NS_DC, "title");+ if (xp != null) {+ headerstr = "<title>" + xp.getValue() + "</title>";+ }++ xp = xmpmeta.getProperty(XMPConst.NS_DC, "creator");+ if (xp != null) {+ headerstr += "<meta name=\"author\" content=\"" + xp.getValue() + "\">";+ }++ xp = xmpmeta.getProperty(XMPConst.NS_DC, "description");+ if (xp != null) {+ headerstr += "<meta name=\"description\" content=\"" + xp.getValue() + "\">";+ }+ xp = xmpmeta.getProperty(XMPConst.NS_DC, "subject");+ if (xp != null) {+ headerstr += "<meta name=\"keywords\" content=\"" + xp.getValue() + "\">";+ }++ // get a date (modified , created)+ xp = xmpmeta.getProperty(XMPConst.NS_XMP, "ModifyDate");+ if (xp != null) {+ headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">";+ } else {+ xp = xmpmeta.getProperty(XMPConst.NS_XMP, "CreateDate");+ if (xp != null) {+ headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">";+ } else {+ xp = xmpmeta.getProperty(XMPConst.NS_DC, "date");+ if (xp != null) {+ headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">";+ }+ }+ }++ xp = xmpmeta.getProperty(XMPConst.NS_XMP, "CreatorTool");+ if (xp != null) {+ headerstr += "<meta name=\"generator\" content=\"" + xp.getValue() + "\">";+ }++ xp = xmpmeta.getProperty(XMPConst.NS_DC, "publisher");+ if (xp != null) {+ headerstr += "<meta name=\"publisher\" content=\"" + xp.getValue() + "\">";+ }++ } catch (XMPException ex) { }+ }/*** Description of the Class@@ -167,13 +225,8 @@ public class SWF2HTML extends SWFTagTypesImpl {*@created 15 de Setembro de 2002*/public class TextDumper implements SWFText {- /**- * Description of the Field- */+protected Integer fontId;- /**- * Description of the Field- */protected boolean firstY = true;@@ -285,23 +338,26 @@ public class SWF2HTML extends SWFTagTypesImpl {/**- * Arguments are: 0. Name of input SWF+ * Parses swf input and extracts text and wrap it as html*- *@param in Description of the Parameter- *@return Description of the Return Value- *@exception Exception Description of the Exception+ * @param in SWF inputstream+ * @return html of text in swf+ * @exception Exception Description of the Exception*/public String convertSWFToHTML(InputStream in) throws Exception {StringWriter out1 = new StringWriter();output = new PrintWriter(out1);- output.println("<html><body>");TagParser parser = new TagParser(this);SWFReader reader = new SWFReader(parser, in);reader.readFile();in.close();- output.println("</body></html>");sizeCount = reader.size;- return out1.toString();+ // generate html output string+ final String ret = "<html>"+ + (headerstr.isEmpty() ? "<body>" : "<header>" + headerstr + "</header><body>")+ + out1.toString()+ + "</body></html>";+ return ret;}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.javaindex ff6afb7eb..279fa4b08 100644--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java@@ -425,4 +425,14 @@ public interface SWFTagTypes extends SWFSpriteTagTypes {*@exception IOException Description of the Exception*/public void tagGeneratorFont(byte[] data) throws IOException;++ /**+ * Metadata such as title in xml format+ * The format of the metadata is RDF that is compliant with Adobe’s+ * Extensible Metadata Platform (XMP™) specification.+ *+ * @param data xml data as string+ * @throws IOException+ */+ public void tagMetaData(String data) throws IOException;}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.javaindex 8ca7cb816..a0adaffb2 100644--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java@@ -881,4 +881,20 @@ public class SWFTagTypesImpl implements SWFTagTypes {colors, imageData);}}++ /**+ * SWFTagTypes METADATA+ * Metadata such as title in xml format+ * The format of the metadata is RDF that is compliant with Adobe’s+ * Extensible Metadata Platform (XMP™) specification.+ *+ * @param data xml data as string+ * @throws IOException+ */+ @Override+ public void tagMetaData (String xml) throws IOException {+ if (tags != null) {+ tags.tagMetaData(xml);+ }+ }}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.javaindex ae0ac8466..497543b8a 100644--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java@@ -200,11 +200,14 @@ public class TagParser implements SWFTags, SWFConstants {parseDefineBits(in);break;case TAG_JPEGTABLES:- //parseDefineJPEGTables(in); // TODO: content length=0 (in==null) occurs for unknown reason - find out!+ if (in != null) parseDefineJPEGTables(in); // TODO: content length=0 (in==null) occurs for unknown reason - find out!break;case TAG_DEFINEBITSJPEG3:parseDefineBitsJPEG3(in);break;+ case TAG_METADATA:+ if (in != null) parseMetaData(in);+ break;default://--Unknown Tag Typetagtypes.tag(tagType, longTag, contents);@@ -366,6 +369,15 @@ public class TagParser implements SWFTags, SWFConstants {tagtypes.tagDefineBitsJPEG3(id, imageData, alphaData);}+ /**+ * parse METADATA tag (TAG_METADATA = 77)+ * @param in+ * @throws IOException+ */+ protected void parseMetaData(InStream in) throws IOException {+ String xmlMetaData = in.readString();+ tagtypes.tagMetaData(xmlMetaData);+ }/*** Description of the Methoddiff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.javaindex abbfdaaf5..bb40f91e2 100644--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java@@ -1203,6 +1203,12 @@ public class TagWriter implements SWFTagTypes, SWFConstants {}+ @Override+ public void tagMetaData (String xml) throws IOException {+ startTag(TAG_METADATA, true);+ out.writeString(xml);+ completeTag();+ }//-----------------------------------------------------------------------/**