Updated build
This commit is contained in:
parent
b4e8847f12
commit
6f0795b027
10 changed files with 345 additions and 881 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -1,191 +1,391 @@
|
|||
<?xml version="1.0"?>
|
||||
<project basedir="." default="all">
|
||||
<import file="${basedir}/build-github.xml"/>
|
||||
|
||||
|
||||
<property file="build.properties.local" />
|
||||
<property file="build.properties" />
|
||||
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="${jscompiler}" />
|
||||
|
||||
<target name="reader" depends="atlas">
|
||||
<target name="merge">
|
||||
<concat destfile="${basedir}/../../build/shapes.js" fixlastline="yes" append="no">
|
||||
<fileset dir="${war.dir}/shapes" includes="**/*.js"/>
|
||||
<fileset dir="${war.dir}/stencils" includes="**/*.js"/>
|
||||
</concat>
|
||||
|
||||
<echo file="${war.dir}/stencils.xml" append="false"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]>${line.separator}</echo>
|
||||
<echo file="${war.dir}/stencils.xml" append="true"><![CDATA[<stencils>]]>${line.separator}</echo>
|
||||
<concat destfile="${war.dir}/stencils.xml" fixlastline="yes" append="yes">
|
||||
<fileset dir="${war.dir}/shapes" includes="**/*.xml"/>
|
||||
<fileset dir="${war.dir}/stencils" includes="**/*.xml"/>
|
||||
</concat>
|
||||
<echo file="${war.dir}/stencils.xml" append="true"><![CDATA[</stencils>]]></echo>
|
||||
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/shapes.min.js">
|
||||
<sources dir="${basedir}/../../build">
|
||||
<file name="shapes.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<tstamp>
|
||||
<format property="time.stamp" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
|
||||
</tstamp>
|
||||
|
||||
<echo file="${war.dir}/cache.manifest" append="false">CACHE MANIFEST${line.separator}${line.separator}</echo>
|
||||
<echo file="${war.dir}/cache.manifest" append="true"># THIS FILE WAS GENERATED. DO NOT MODIFY!${line.separator}</echo>
|
||||
<echo file="${war.dir}/cache.manifest" append="true"># ${time.stamp}${line.separator}${line.separator}</echo>
|
||||
<concat destfile="${war.dir}/cache.manifest" fixlastline="yes" append="yes">
|
||||
<fileset dir="${basedir}" includes="cache.txt"/>
|
||||
</concat>
|
||||
|
||||
<delete dir="${basedir}/../../build"/>
|
||||
</target>
|
||||
|
||||
<target name="app" depends="merge">
|
||||
<delete file=".tmp0.js"/>
|
||||
<echo file=".tmp0.js">
|
||||
var mxBasePath = 'https://www.draw.io/mxgraph/';
|
||||
var mxLoadStylesheets = mxLoadResources = false;
|
||||
var mxLanguage = 'en';
|
||||
var mxLoadStylesheets = false;
|
||||
</echo>
|
||||
|
||||
<delete file=".tmp1.js"/>
|
||||
<java fork="false" classname="Preprocessor" classpath="${mxgraph2.dir}/etc/build">
|
||||
<arg value="${mxgraph2.dir}/javascript/src/js/mxClient.js"/>
|
||||
<arg value=".tmp1.js"/>
|
||||
<arg value="reader_excludes"/>
|
||||
</java>
|
||||
|
||||
<loadfile property="version" srcFile="${mxgraph2.dir}/VERSION"/>
|
||||
<replace file=".tmp1.js" token="@MXGRAPH-VERSION@" value="${version}"/>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${war.dir}/js/reader.min.js">
|
||||
<sources dir="${war.dir}/js/sanitizer">
|
||||
<file name="sanitizer.min.js" />
|
||||
<delete file=".tmp1.js"/>
|
||||
<copy file="${war.dir}/styles/default.xml" tofile=".tmp1.xml" overwrite="true"/>
|
||||
<replaceregexp file=".tmp1.xml" match="\n" flags="g" replace=""/>
|
||||
<replaceregexp file=".tmp1.xml" match="\t" flags="g" replace=""/>
|
||||
<replaceregexp file=".tmp1.xml" match="'" replace="\\\\'" byline="true"/>
|
||||
|
||||
<delete file="Graph-Stylesheet.js"/>
|
||||
<echo file="Graph-Stylesheet.js">Graph.prototype.defaultThemes[Graph.prototype.defaultThemeName] = mxUtils.parseXml('</echo>
|
||||
<concat destfile="Graph-Stylesheet.js" fixlastline="no" append="yes">
|
||||
<file name=".tmp1.xml" />
|
||||
</concat>
|
||||
<echo file="Graph-Stylesheet.js" append="true">').documentElement;</echo>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="grapheditor.min.js">
|
||||
<sources dir="${grapheditor.dir}">
|
||||
<file name="Editor.js" />
|
||||
<file name="EditorUi.js" />
|
||||
<file name="Sidebar.js" />
|
||||
<file name="Graph.js" />
|
||||
<file name="Shapes.js" />
|
||||
<file name="Actions.js" />
|
||||
<file name="Menus.js" />
|
||||
<file name="Format.js" />
|
||||
<file name="Toolbar.js" />
|
||||
<file name="Dialogs.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="sidebar.min.js">
|
||||
<sources dir="${war.dir}/js/diagramly/sidebar">
|
||||
<file name="Sidebar.js" />
|
||||
<file name="Sidebar-Advanced.js" />
|
||||
<file name="Sidebar-Android.js" />
|
||||
<file name="Sidebar-ArchiMate.js" />
|
||||
<file name="Sidebar-ArchiMate3.js" />
|
||||
<file name="Sidebar-Arrows2.js" />
|
||||
<file name="Sidebar-AWS.js" />
|
||||
<file name="Sidebar-AWS3D.js" />
|
||||
<file name="Sidebar-Azure.js" />
|
||||
<file name="Sidebar-Basic.js" />
|
||||
<file name="Sidebar-Bootstrap.js" />
|
||||
<file name="Sidebar-BPMN.js" />
|
||||
<file name="Sidebar-Cabinet.js" />
|
||||
<file name="Sidebar-Citrix.js" />
|
||||
<file name="Sidebar-EIP.js" />
|
||||
<file name="Sidebar-Electrical.js" />
|
||||
<file name="Sidebar-ER.js" />
|
||||
<file name="Sidebar-Floorplan.js" />
|
||||
<file name="Sidebar-Flowchart.js" />
|
||||
<file name="Sidebar-Gmdl.js" />
|
||||
<file name="Sidebar-Ios.js" />
|
||||
<file name="Sidebar-Ios7.js" />
|
||||
<file name="Sidebar-LeanMapping.js" />
|
||||
<file name="Sidebar-Mockup.js" />
|
||||
<file name="Sidebar-MSCAE.js" />
|
||||
<file name="Sidebar-Network.js" />
|
||||
<file name="Sidebar-Office.js" />
|
||||
<file name="Sidebar-PID.js" />
|
||||
<file name="Sidebar-Rack.js" />
|
||||
<file name="Sidebar-Sysml.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${war.dir}/js/atlas-viewer.min.js">
|
||||
<sources dir=".">
|
||||
<file name=".tmp0.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/spin">
|
||||
<file name="spin.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/sanitizer">
|
||||
<file name="sanitizer.min.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/deflate">
|
||||
<file name="base64.js"/>
|
||||
<file name="pako.min.js"/>
|
||||
<file name="base64.js" />
|
||||
<file name="pako.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/json">
|
||||
<file name="json2.min.js"/>
|
||||
<file name="json2.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name=".tmp0.js"/>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${grapheditor.dir}">
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name=".tmp1.js"/>
|
||||
<sources dir="${basedir}/../mxgraph">
|
||||
<file name="mxClient.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${grapheditor.dir}">
|
||||
<file name="Editor.js" />
|
||||
<file name="EditorUi.js" />
|
||||
<file name="Graph.js" />
|
||||
<file name="Shapes.js"/>
|
||||
<file name="Shapes.js" />
|
||||
<file name="Actions.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="DrawioFile.js" />
|
||||
<file name="LocalFile.js" />
|
||||
<file name="EditorUi.js" />
|
||||
<file name="Pages.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name="Graph-Stylesheet.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="GraphViewer.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<delete file=".tmp1.xml"/>
|
||||
|
||||
<echo file=".tmp1.js">
|
||||
(function()
|
||||
{
|
||||
Editor.initMath();
|
||||
GraphViewer.initCss();
|
||||
mxStencilRegistry.dynamicLoading = false;
|
||||
|
||||
if (window.onDrawioViewerLoad != null)
|
||||
{
|
||||
window.onDrawioViewerLoad();
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphViewer.processElements();
|
||||
}
|
||||
})();
|
||||
</echo>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${war.dir}/js/viewer.min.js">
|
||||
<sources dir="${war.dir}/js">
|
||||
<file name="atlas-viewer.min.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name=".tmp1.js"/>
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<delete file=".tmp0.js"/>
|
||||
<delete file=".tmp1.js"/>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${war.dir}/js/embed.min.js">
|
||||
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/atlas.min.js">
|
||||
<sources dir="${war.dir}/js/spin">
|
||||
<file name="spin.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/sanitizer">
|
||||
<file name="sanitizer.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/deflate">
|
||||
<file name="pako.min.js" />
|
||||
<file name="base64.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/json">
|
||||
<file name="json2.min.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="Embed.js"/>
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${grapheditor.dir}">
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${basedir}/../mxgraph">
|
||||
<file name="mxClient.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name="grapheditor.min.js"/>
|
||||
<file name="sidebar.min.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="DrawioFile.js" />
|
||||
<file name="LocalFile.js" />
|
||||
<file name="LocalLibrary.js" />
|
||||
<file name="StorageFile.js" />
|
||||
<file name="StorageLibrary.js" />
|
||||
<file name="Dialogs.js" />
|
||||
<file name="EditorUi.js" />
|
||||
<file name="Settings.js" />
|
||||
<file name="App.js" />
|
||||
<file name="Menus.js" />
|
||||
<file name="Pages.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name="Graph-Stylesheet.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<concat destfile="${war.dir}/js/embed-static.min.js" fixlastline="yes" append="no">
|
||||
<file name="${war.dir}/js/reader.min.js" />
|
||||
<file name="${war.dir}/js/embed.min.js" />
|
||||
</concat>
|
||||
<replaceregexp file="${war.dir}/js/embed-static.min.js" match="}\)\(\);$" replace=""/>
|
||||
<echo file="${war.dir}/js/embed-static.min.js" append="true">})('</echo>
|
||||
<copy file="${war.dir}/styles/default.xml" tofile=".tmp0.xml" overwrite="true"/>
|
||||
<replaceregexp file=".tmp0.xml" match="\n" flags="g" replace=""/>
|
||||
<replaceregexp file=".tmp0.xml" match="\t" flags="g" replace=""/>
|
||||
<replaceregexp file=".tmp0.xml" match="'" replace="\\\\'" byline="true"/>
|
||||
<concat destfile="${war.dir}/js/embed-static.min.js" fixlastline="no" append="yes">
|
||||
<file name=".tmp0.xml" />
|
||||
</concat>
|
||||
<delete file=".tmp0.xml"/>
|
||||
<echo file="${war.dir}/js/embed-static.min.js" append="true">');</echo>
|
||||
<loadfile property="version" srcFile="../../VERSION"/>
|
||||
<replace file="${war.dir}/js/atlas.min.js" token="@DRAWIO-VERSION@" value="${version}"/>
|
||||
|
||||
<copy file="${war.dir}/js/diagramly/Embed.js" tofile="${war.dir}/js/embed.dev.js" overwrite="true"/>
|
||||
<replaceregexp file="${war.dir}/js/embed.dev.js" match="}\)\(\);$" replace=""/>
|
||||
<replaceregexp file="${war.dir}/js/embed.min.js" match="}\)\(\);$" replace=""/>
|
||||
</target>
|
||||
|
||||
<target name="clean-desktop" depends="atlas">
|
||||
<delete dir="${desktop.dir}/js" />
|
||||
<delete dir="${desktop.dir}/images" />
|
||||
<delete dir="${desktop.dir}/img" />
|
||||
<delete dir="${desktop.dir}/mxgraph" />
|
||||
<delete dir="${desktop.dir}/resources" />
|
||||
<delete dir="${desktop.dir}/styles" />
|
||||
</target>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="desktop-init.min.js">
|
||||
<sources dir="${desktop.dir}">
|
||||
<file name="Desktop-Init.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="desktop-start.min.js">
|
||||
<sources dir="${desktop.dir}">
|
||||
<file name="Desktop-Start.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/extensions.min.js">
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="Extensions.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/app.min.js">
|
||||
<sources dir="${war.dir}/js/spin">
|
||||
<file name="spin.min.js" />
|
||||
</sources>
|
||||
|
||||
<target name="build-desktop" depends="clean-desktop">
|
||||
<concat destfile="${desktop.dir}/js/desktop.min.js" fixlastline="yes" append="no">
|
||||
<file name="desktop-init.min.js" />
|
||||
<file name="${war.dir}/js/app.min.js" />
|
||||
<file name="${war.dir}/js/extensions.min.js" />
|
||||
<file name="${war.dir}/js/shapes.min.js" />
|
||||
<file name="desktop-start.min.js" />
|
||||
</concat>
|
||||
<delete file="desktop-init.min.js"/>
|
||||
<delete file="desktop-start.min.js"/>
|
||||
<copy todir="${desktop.dir}/js">
|
||||
<fileset file="${war.dir}/stencils.xml"></fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/js/jscolor">
|
||||
<fileset dir="${war.dir}/js/jscolor"></fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/images">
|
||||
<fileset dir="${war.dir}/images">
|
||||
<exclude name="ajax-loader.gif"/>
|
||||
<exclude name="drawlogo*.png"/>
|
||||
<exclude name="apple-*"/>
|
||||
<exclude name="android-*"/>
|
||||
<exclude name="favicon*"/>
|
||||
<exclude name="mstile-*"/>
|
||||
<exclude name="glyphicons_facebook.png"/>
|
||||
<exclude name="glyphicons_blogger.png"/>
|
||||
<exclude name="glyphicons_google.png"/>
|
||||
<exclude name="glyphicons_twitter.png"/>
|
||||
<exclude name="glyphicons_github.png"/>
|
||||
<exclude name="stop-flat-icon-80.png"/>
|
||||
<exclude name="1x1.png"/>
|
||||
<exclude name="2x2.png"/>
|
||||
<exclude name="3x3.png"/>
|
||||
<exclude name="images/log.png"/>
|
||||
<exclude name="logo-confluence.png"/>
|
||||
<exclude name="logo-jira.png"/>
|
||||
<exclude name="dropbox-logo-*"/>
|
||||
<exclude name="google-drive-logo-*"/>
|
||||
<exclude name="onedrive-logo-*"/>
|
||||
<exclude name="safari-pinned-tab.svg"/>
|
||||
<exclude name="manifest.json"/>
|
||||
<exclude name="browserconfig.xml"/>
|
||||
<sources dir="${war.dir}/js/sanitizer">
|
||||
<file name="sanitizer.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/deflate">
|
||||
<file name="pako.min.js" />
|
||||
<file name="base64.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${grapheditor.dir}">
|
||||
<file name="Init.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${basedir}/../mxgraph">
|
||||
<file name="mxClient.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name="grapheditor.min.js"/>
|
||||
<file name="sidebar.min.js"/>
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="DrawioFile.js" />
|
||||
<file name="LocalFile.js" />
|
||||
<file name="LocalLibrary.js" />
|
||||
<file name="StorageFile.js" />
|
||||
<file name="StorageLibrary.js" />
|
||||
<file name="Dialogs.js" />
|
||||
<file name="EditorUi.js" />
|
||||
<file name="Settings.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir=".">
|
||||
<file name="Graph-Stylesheet.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/dropbox">
|
||||
<file name="dropbox.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly/util">
|
||||
<file name="mxAsyncCanvas.js" />
|
||||
<file name="mxJsCanvas.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="DrawioUser.js" />
|
||||
<file name="UrlLibrary.js" />
|
||||
<file name="DriveRealtime.js" />
|
||||
<file name="RealtimeMapping.js" />
|
||||
<file name="DriveFile.js" />
|
||||
<file name="DriveLibrary.js" />
|
||||
<file name="DriveClient.js" />
|
||||
<file name="DropboxClient.js" />
|
||||
<file name="DropboxFile.js" />
|
||||
<file name="DropboxLibrary.js" />
|
||||
<file name="OneDriveFile.js" />
|
||||
<file name="OneDriveLibrary.js" />
|
||||
<file name="OneDriveClient.js" />
|
||||
<file name="ChatWindow.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/js/diagramly">
|
||||
<file name="App.js" />
|
||||
<file name="Menus.js" />
|
||||
<file name="Pages.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
|
||||
<replace file="${war.dir}/js/app.min.js" token="@DRAWIO-VERSION@" value="${version}"/>
|
||||
|
||||
<delete file="Graph-Stylesheet.js"/>
|
||||
<delete file="grapheditor.min.js"/>
|
||||
<delete file="sidebar.min.js"/>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="app">
|
||||
</target>
|
||||
|
||||
<!-- ================== Stand-alone war creation ============================= -->
|
||||
|
||||
<path id="javac.class.path">
|
||||
<fileset dir="${war.dir}/WEB-INF/lib" includes="mxgraph-core.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="servlet-api.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="commons-codec-1.10.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="commons-fileupload-1.3.2.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="gson-2.7.jar" />
|
||||
</path>
|
||||
|
||||
<target name="javac">
|
||||
<mkdir dir="${javac.dir}"/>
|
||||
<javac srcdir="${src.dir}" excludes="**/EmbedServlet2.java" encoding="utf-8" destdir="${javac.dir}" source="1.7" target="1.7" debug="true" debuglevel="lines,vars,source">
|
||||
<classpath refid="javac.class.path" />
|
||||
</javac>
|
||||
<copy todir="${javac.dir}/META-INF">
|
||||
<fileset dir="${src.dir}/META-INF">
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/img">
|
||||
<fileset dir="${war.dir}/img"></fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/mxgraph">
|
||||
<fileset dir="${war.dir}/mxgraph"></fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/resources">
|
||||
<fileset dir="${war.dir}/resources"></fileset>
|
||||
</copy>
|
||||
<copy todir="${desktop.dir}/styles">
|
||||
<fileset dir="${war.dir}/styles"></fileset>
|
||||
</copy>
|
||||
<copy file="${basedir}/desktop-manifest.json" tofile="${desktop.dir}/manifest.json" overwrite="true"/>
|
||||
<loadfile property="version2" srcFile="${basedir}/../../VERSION"/>
|
||||
<replace file="${desktop.dir}/manifest.json" token="@DRAWIO-VERSION@" value="${version2}"/>
|
||||
<zip destfile="${desktop.dir}/../drawio-desktop-${version2}.zip">
|
||||
<zipfileset dir="${desktop.dir}">
|
||||
<exclude name="Desktop-Init.js"/>
|
||||
<exclude name="Desktop-Start.js"/>
|
||||
</zipfileset>
|
||||
</zip>
|
||||
<copy todir="${javac.dir}" file="${src.dir}/log4j.properties" />
|
||||
</target>
|
||||
|
||||
<target name="atlas" depends="app">
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/atlas.min.js">
|
||||
<sources dir="${war.dir}/js">
|
||||
<file name="atlas.min.js" />
|
||||
</sources>
|
||||
|
||||
<sources dir="${war.dir}/connect/common/js">
|
||||
<file name="mxReader.js" />
|
||||
</sources>
|
||||
</jscomp>
|
||||
<target name="clean-war" depends="javac" description="Create the stand-alone war file">
|
||||
<delete failonerror="false">
|
||||
<fileset dir="${javac.dir}">
|
||||
</fileset>
|
||||
<fileset dir="${build.dir}">
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="build-desktop,reader">
|
||||
<target name="war" depends="javac" description="Create the stand-alone war file">
|
||||
<zip excludes="**/appengine*.jar,**/jsr*.jar,**/junit*.jar" destfile="${build.dir}/${war.name}" basedir="${war.dir}" >
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
BIN
etc/build/jars/commons-codec-1.10.jar
Normal file
BIN
etc/build/jars/commons-codec-1.10.jar
Normal file
Binary file not shown.
BIN
etc/build/jars/commons-fileupload-1.3.2.jar
Normal file
BIN
etc/build/jars/commons-fileupload-1.3.2.jar
Normal file
Binary file not shown.
BIN
etc/build/jars/gson-2.7.jar
Normal file
BIN
etc/build/jars/gson-2.7.jar
Normal file
Binary file not shown.
BIN
etc/build/jars/servlet-api.jar
Normal file
BIN
etc/build/jars/servlet-api.jar
Normal file
Binary file not shown.
|
@ -1,120 +0,0 @@
|
|||
/**
|
||||
* $Id: ErrorServlet.java,v 1.6 2014/02/21 12:01:30 gaudenz Exp $
|
||||
* Copyright (c) 2014, JGraph Ltd
|
||||
*/
|
||||
package com.mxgraph.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class OpenServlet
|
||||
*/
|
||||
public class EmailServlet extends HttpServlet
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(HttpServlet.class
|
||||
.getName());
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EmailServlet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
|
||||
try
|
||||
{
|
||||
String data = request.getParameter("data");
|
||||
String body = request.getParameter("body");
|
||||
|
||||
if (data != null || body != null)
|
||||
{
|
||||
if ((data != null && data.length() > 140) || body != null)
|
||||
{
|
||||
Properties props = new Properties();
|
||||
Session session = Session.getDefaultInstance(props, null);
|
||||
Message msg = new MimeMessage(session);
|
||||
|
||||
String email = request.getParameter("email");
|
||||
String version = request.getParameter("version");
|
||||
String url = request.getParameter("url");
|
||||
|
||||
if (email != null)
|
||||
{
|
||||
msg.setReplyTo(new InternetAddress[] { new InternetAddress(
|
||||
email) });
|
||||
}
|
||||
|
||||
msg.setFrom(new InternetAddress("davidjgraph@gmail.com",
|
||||
"Draw.io"));
|
||||
msg.addRecipient(Message.RecipientType.TO,
|
||||
((body != null) ? new InternetAddress(
|
||||
"feedback@jgraph.com", "Draw.io feedback")
|
||||
: new InternetAddress("zlib@jgraph.com",
|
||||
"Draw.io error report")));
|
||||
msg.setSubject("Draw.io "
|
||||
+ ((body != null) ? "Feedback" : "Error Report"));
|
||||
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
messageBodyPart.setText(((body != null) ? body : data)
|
||||
+ "\n\n----"
|
||||
+ ((url != null) ? "\nURL: " + url : "")
|
||||
+ ((email != null) ? "\nEmail: " + email : "")
|
||||
+ "\nRemote Address: " + request.getRemoteAddr()
|
||||
+ ((version != null) ? "\nVersion: " + version : ""));
|
||||
|
||||
Multipart multipart = new MimeMultipart();
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
|
||||
msg.setContent(multipart);
|
||||
Transport.send(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.severe("CRITICAL : " + data);
|
||||
}
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
e.printStackTrace(new PrintStream(response.getOutputStream()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,407 +0,0 @@
|
|||
/**
|
||||
* $Id: EmbedServlet.java,v 1.18 2014/01/31 22:27:07 gaudenz Exp $
|
||||
* Copyright (c) 2011-2012, JGraph Ltd
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
* We could split the static part and the stencils into two separate requests
|
||||
* in order for multiple graphs in the pages to not load the static part
|
||||
* multiple times. This is only relevant if the embed arguments are different,
|
||||
* in which case there is a problem with parsin the graph model too soon, ie.
|
||||
* before certain stencils become available.
|
||||
*
|
||||
* Easier solution is for the user to move the embed script to after the last
|
||||
* graph in the page and merge the stencil arguments.
|
||||
*
|
||||
* Note: The static part is roundly 105K, the stencils are much smaller in size.
|
||||
* This means if the embed function is widely used, it will make sense to factor
|
||||
* out the static part because only stencils will change between pages.
|
||||
*/
|
||||
package com.mxgraph.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.appengine.api.utils.SystemProperty;
|
||||
|
||||
/**
|
||||
* Servlet implementation class OpenServlet
|
||||
*/
|
||||
public class EmbedServlet extends HttpServlet
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String reader = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String embed = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String embedDev = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String stylesheet = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static String lastModified = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected HashMap<String, String> stencils = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected HashMap<String, String[]> libraries = new HashMap<String, String[]>();
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EmbedServlet()
|
||||
{
|
||||
if (lastModified == null)
|
||||
{
|
||||
// Uses deployment date as lastModified header
|
||||
String applicationVersion = SystemProperty.applicationVersion.get();
|
||||
Date uploadDate = new Date(Long.parseLong(applicationVersion
|
||||
.substring(applicationVersion.lastIndexOf(".") + 1))
|
||||
/ (2 << 27) * 1000);
|
||||
|
||||
DateFormat httpDateFormat = new SimpleDateFormat(
|
||||
"EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
lastModified = httpDateFormat.format(uploadDate);
|
||||
}
|
||||
|
||||
initLibraries(libraries);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public static void initLibraries(HashMap<String, String[]> libraries)
|
||||
{
|
||||
libraries.put("bpmn", new String[] { "/shapes/bpmn/mxBpmnShape2.js",
|
||||
"/stencils/bpmn.xml" });
|
||||
libraries.put("er", new String[] { "/shapes/er/mxER.js" });
|
||||
libraries.put("ios", new String[] { "/shapes/mockup/mxMockupiOS.js" });
|
||||
libraries.put("ios7", new String[] { "/stencils/ios7.xml" });
|
||||
libraries.put("android", new String[] { "/shapes/mxAndroid.js",
|
||||
"/stencils/android/android.xml" });
|
||||
libraries.put("lean_mapping", new String[] { "/shapes/mxLeanMap.js",
|
||||
"/stencils/lean_mapping.xml" });
|
||||
// Required for anchor shape which follows non-standard naming scheme (see Sidebar.js)
|
||||
libraries.put("mockup",
|
||||
new String[] { "/shapes/mockup/mxMockupButtons.js" });
|
||||
libraries.put("mockup/buttons",
|
||||
new String[] { "/shapes/mockup/mxMockupButtons.js" });
|
||||
libraries.put("mockup/containers",
|
||||
new String[] { "/shapes/mockup/mxMockupContainers.js" });
|
||||
libraries.put("mockup/forms",
|
||||
new String[] { "/shapes/mockup/mxMockupForms.js" });
|
||||
libraries.put("mockup/graphics", new String[] {
|
||||
"/shapes/mockup/mxMockupGraphics.js",
|
||||
"/stencils/mockup/misc.xml" });
|
||||
libraries.put("mockup/markup",
|
||||
new String[] { "/shapes/mockup/mxMockupMarkup.js" });
|
||||
libraries
|
||||
.put("mockup/misc", new String[] {
|
||||
"/shapes/mockup/mxMockupMisc.js",
|
||||
"/stencils/mockup/misc.xml" });
|
||||
libraries.put("mockup/navigation", new String[] {
|
||||
"/shapes/mockup/mxMockupNavigation.js",
|
||||
"/stencils/mockup/misc.xml" });
|
||||
libraries.put("mockup/text",
|
||||
new String[] { "/shapes/mockup/mxMockupText.js" });
|
||||
libraries.put("pid2inst",
|
||||
new String[] { "/shapes/pid2/mxPidInstruments.js" });
|
||||
libraries.put("pid2misc", new String[] { "/shapes/pid2/mxPidMisc.js",
|
||||
"/stencils/pid/misc.xml" });
|
||||
libraries.put("pid2valves",
|
||||
new String[] { "/shapes/pid2/mxPidValves.js" });
|
||||
libraries.put("floorplan", new String[] { "/shapes/mxFloorplan.js",
|
||||
"/stencils/floorplan.xml" });
|
||||
libraries.put("archimate", new String[] { "/shapes/mxArchiMate.js" });
|
||||
libraries.put("azure", new String[] { "/stencils/azure.xml" });
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
String qs = request.getQueryString();
|
||||
|
||||
if (qs != null && qs.equals("stats"))
|
||||
{
|
||||
writeStats(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reader == null)
|
||||
{
|
||||
reader = readFile("/js/reader.min.js");
|
||||
}
|
||||
|
||||
if (embed == null)
|
||||
{
|
||||
embed = readFile("/js/embed.min.js");
|
||||
}
|
||||
|
||||
if (embedDev == null)
|
||||
{
|
||||
embedDev = readFile("/js/embed.dev.js");
|
||||
}
|
||||
|
||||
if (stylesheet == null)
|
||||
{
|
||||
stylesheet = readXmlFile("/styles/default.xml", true);
|
||||
}
|
||||
|
||||
// Checks or sets last modified date of delivered content.
|
||||
// Date comparison not needed. Only return 304 if
|
||||
// delivered by this servlet instance.
|
||||
String modSince = request.getHeader("If-Modified-Since");
|
||||
|
||||
if (modSince != null && modSince.equals(lastModified))
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeEmbedResponse(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEmbedResponse(HttpServletRequest request,
|
||||
HttpServletResponse response) throws IOException
|
||||
{
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/javascript; charset=UTF-8");
|
||||
response.setHeader("Last-Modified", lastModified);
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
// FIXME: Accept-encoding header is missing
|
||||
String encoding = request.getHeader("Accept-Encoding");
|
||||
|
||||
// Supports GZIP content encoding
|
||||
if (encoding != null && encoding.indexOf("gzip") >= 0)
|
||||
{
|
||||
response.setHeader("Content-Encoding", "gzip");
|
||||
out = new GZIPOutputStream(out);
|
||||
}
|
||||
|
||||
// Creates XML for stencils
|
||||
PrintWriter writer = new PrintWriter(out);
|
||||
|
||||
// Writes JavaScript and adds function call with
|
||||
// stylesheet and stencils as arguments
|
||||
writer.println(createEmbedJavaScript(request.getParameter("s"), request.getParameter("dev")));
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public String createEmbedJavaScript(String sparam, String dev) throws IOException
|
||||
{
|
||||
StringBuffer result = new StringBuffer("[");
|
||||
StringBuffer js = new StringBuffer("");
|
||||
|
||||
// Processes each stencil only once
|
||||
HashSet<String> done = new HashSet<String>();
|
||||
|
||||
// Processes each lib only once
|
||||
HashSet<String> libsLoaded = new HashSet<String>();
|
||||
|
||||
if (sparam != null)
|
||||
{
|
||||
String[] names = sparam.split(";");
|
||||
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
if (names[i].indexOf("..") < 0 && !done.contains(names[i]))
|
||||
{
|
||||
if (names[i].equals("*"))
|
||||
{
|
||||
js.append(readXmlFile("/js/shapes.min.js", false));
|
||||
result.append("'" + readXmlFile("/stencils.xml", true)
|
||||
+ "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Checks if any JS files are associated with the library
|
||||
// name and injects the JS into the page
|
||||
String[] libs = libraries.get(names[i]);
|
||||
|
||||
if (libs != null)
|
||||
{
|
||||
for (int j = 0; j < libs.length; j++)
|
||||
{
|
||||
if (!libsLoaded.contains(libs[j]))
|
||||
{
|
||||
String tmp = stencils.get(libs[j]);
|
||||
libsLoaded.add(libs[j]);
|
||||
|
||||
if (tmp == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
tmp = readXmlFile(libs[j], !libs[j]
|
||||
.toLowerCase().endsWith(".js"));
|
||||
|
||||
// Cache for later use
|
||||
if (tmp != null)
|
||||
{
|
||||
stencils.put(libs[j], tmp);
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
// This seems possible according to access log so ignore stencil
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp != null)
|
||||
{
|
||||
// TODO: Add JS to Javascript code inline. This had to be done to quickly
|
||||
// add JS-based dynamic loading to the existing embed setup where everything
|
||||
// dynamic is passed via function call, so an indirection via eval must be
|
||||
// used even though the JS could be parsed directly by adding it to JS.
|
||||
if (libs[j].toLowerCase().endsWith(".js"))
|
||||
{
|
||||
js.append(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.length() > 1)
|
||||
{
|
||||
result.append(",");
|
||||
}
|
||||
|
||||
result.append("'" + tmp + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String tmp = stencils.get(names[i]);
|
||||
|
||||
if (tmp == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
tmp = readXmlFile("/stencils/" + names[i]
|
||||
+ ".xml", true);
|
||||
|
||||
// Cache for later use
|
||||
if (tmp != null)
|
||||
{
|
||||
stencils.put(names[i], tmp);
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
// This seems possible according to access log so ignore stencil
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp != null)
|
||||
{
|
||||
if (result.length() > 1)
|
||||
{
|
||||
result.append(",");
|
||||
}
|
||||
|
||||
result.append("'" + tmp + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done.add(names[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.append("]");
|
||||
|
||||
String tmp = (dev != null && dev.equals("1")) ? embedDev : embed;
|
||||
|
||||
// JS must be executed after core but before embed function
|
||||
return reader + "\n" + js + tmp + "})('" + stylesheet + "',"
|
||||
+ result.toString() + ");";
|
||||
}
|
||||
|
||||
public void writeStats(HttpServletResponse response) throws IOException
|
||||
{
|
||||
PrintWriter writer = new PrintWriter(response.getOutputStream());
|
||||
writer.println("<html>");
|
||||
writer.println("<body>");
|
||||
writer.println("Deployed: " + lastModified);
|
||||
writer.println("</body>");
|
||||
writer.println("</html>");
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
public String readXmlFile(String filename, boolean xmlContent)
|
||||
throws IOException
|
||||
{
|
||||
String result = readFile(filename);
|
||||
|
||||
if (xmlContent)
|
||||
{
|
||||
result = result.replaceAll("'", "\\\\'").replaceAll("\t", "")
|
||||
.replaceAll("\n", "");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String readFile(String filename) throws IOException
|
||||
{
|
||||
InputStream is = getServletContext().getResourceAsStream(filename);
|
||||
|
||||
return Utils.readInputStream(is);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/**
|
||||
* $Id: LicenseInitServlet.java,v 1.4 2013/12/13 13:18:11 david Exp $
|
||||
* Copyright (c) 2011-2012, JGraph Ltd
|
||||
*/
|
||||
package com.mxgraph.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
||||
import com.google.appengine.api.datastore.Entity;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class LicenseInitServlet extends HttpServlet
|
||||
{
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LicenseInitServlet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
initDatastore();
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.setContentType("text/html");
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
out.write("License Datastore initialized".getBytes());
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void initDatastore()
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.DATE, -1);
|
||||
|
||||
Entity entity = new Entity(LicenseServlet.ENTITY_SC, "example.com");
|
||||
entity.setProperty("type", "test");
|
||||
entity.setProperty("json", "{\"expiry\": \""
|
||||
+ LicenseServlet.isoDateFormat.format(c.getTime()) + "\"}");
|
||||
|
||||
DatastoreServiceFactory.getDatastoreService().put(entity);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
/**
|
||||
* $Id: LicenseServlet.java,v 1.4 2013/12/13 13:18:11 david Exp $
|
||||
* Copyright (c) 2011-2012, JGraph Ltd
|
||||
*/
|
||||
package com.mxgraph.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.appengine.api.datastore.DatastoreService;
|
||||
import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
||||
import com.google.appengine.api.datastore.EntityNotFoundException;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
|
||||
/**
|
||||
* Possible values for json property:
|
||||
*
|
||||
* {"expiry": "YYYY-MM-DD"} (eg. {"expiry": "2016-03-31"}) or {"expiry": "never"}
|
||||
*
|
||||
* A date within 90 days will show a message that the license will expire.
|
||||
* A date in the past (or same day) will show a message that the license has expired.
|
||||
* A date in the future or an empty JSON object (eg. {}) will remove the footer.
|
||||
* An empty string for json is the same as no entry (ie. footer will not be removed).
|
||||
*
|
||||
* Possible keys:
|
||||
*
|
||||
* Any domain name (eg. example.com).
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class LicenseServlet extends HttpServlet
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static String ENTITY_SC = "DrawioLicense";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static SimpleDateFormat isoDateFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LicenseServlet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
String domain = request.getParameter("domain");
|
||||
|
||||
if (domain != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json");
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
out.write(getLicense(domain).getBytes());
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}
|
||||
catch (EntityNotFoundException e)
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.setStatus(
|
||||
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected String getLicense(String domain) throws EntityNotFoundException
|
||||
{
|
||||
// Returns test licences
|
||||
if (domain.equals("valid-example.test"))
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.DATE, 120);
|
||||
|
||||
return "{\"expiry\": \"" + isoDateFormat.format(c.getTime())
|
||||
+ "\"}";
|
||||
}
|
||||
else if (domain.equals("expire-example.test"))
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.DATE, 30);
|
||||
|
||||
return "{\"expiry\": \"" + isoDateFormat.format(c.getTime())
|
||||
+ "\"}";
|
||||
}
|
||||
else if (domain.equals("expired-example.test"))
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.DATE, -10);
|
||||
|
||||
return "{\"expiry\": \"" + isoDateFormat.format(c.getTime())
|
||||
+ "\"}";
|
||||
}
|
||||
|
||||
// Uses the datastore to retrieve the data for the domain
|
||||
DatastoreService datastore = DatastoreServiceFactory
|
||||
.getDatastoreService();
|
||||
|
||||
// LATER: Check email first then domain
|
||||
return datastore.get(KeyFactory.createKey(ENTITY_SC, domain))
|
||||
.getProperty("json").toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue