commit
1c315b754e
21 changed files with 2899 additions and 0 deletions
@ -0,0 +1,66 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!-- You may freely edit this file. See commented blocks below for --> |
||||
|
<!-- some examples of how to customize the build. --> |
||||
|
<!-- (If you delete it and reopen the project it will be recreated.) --> |
||||
|
<project name="bookshelf" default="default" basedir="."> |
||||
|
<description>Builds, tests, and runs the project bookshelf.</description> |
||||
|
<import file="nbproject/build-impl.xml"/> |
||||
|
<!-- |
||||
|
|
||||
|
There exist several targets which are by default empty and which can be |
||||
|
used for execution of your tasks. These targets are usually executed |
||||
|
before and after some main targets. They are: |
||||
|
|
||||
|
-pre-init: called before initialization of project properties |
||||
|
-post-init: called after initialization of project properties |
||||
|
-pre-compile: called before javac compilation |
||||
|
-post-compile: called after javac compilation |
||||
|
-pre-compile-single: called before javac compilation of single file |
||||
|
-post-compile-single: called after javac compilation of single file |
||||
|
-pre-compile-test: called before javac compilation of JUnit tests |
||||
|
-post-compile-test: called after javac compilation of JUnit tests |
||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test |
||||
|
-post-compile-test-single: called after javac compilation of single JUunit test |
||||
|
-pre-dist: called before jar building |
||||
|
-post-dist: called after jar building |
||||
|
-post-clean: called after cleaning build products |
||||
|
-pre-run-deploy: called before deploying |
||||
|
-post-run-deploy: called after deploying |
||||
|
|
||||
|
Example of pluging an obfuscator after the compilation could look like |
||||
|
|
||||
|
<target name="post-compile"> |
||||
|
<obfuscate> |
||||
|
<fileset dir="${build.classes.dir}"/> |
||||
|
</obfuscate> |
||||
|
</target> |
||||
|
|
||||
|
For list of available properties check the imported |
||||
|
nbproject/build-impl.xml file. |
||||
|
|
||||
|
|
||||
|
Other way how to customize the build is by overriding existing main targets. |
||||
|
The target of interest are: |
||||
|
|
||||
|
init-macrodef-javac: defines macro for javac compilation |
||||
|
init-macrodef-junit: defines macro for junit execution |
||||
|
init-macrodef-debug: defines macro for class debugging |
||||
|
do-dist: jar archive building |
||||
|
run: execution of project |
||||
|
javadoc-build: javadoc generation |
||||
|
|
||||
|
Example of overriding the target for project execution could look like |
||||
|
|
||||
|
<target name="run" depends="<PROJNAME>-impl.jar"> |
||||
|
<exec dir="bin" executable="launcher.exe"> |
||||
|
<arg file="${dist.jar}"/> |
||||
|
</exec> |
||||
|
</target> |
||||
|
|
||||
|
Notice that overridden target depends on jar target and not only on |
||||
|
compile target as regular run target does. Again, for list of available |
||||
|
properties which you can use check the target you are overriding in |
||||
|
nbproject/build-impl.xml file. |
||||
|
|
||||
|
--> |
||||
|
</project> |
||||
@ -0,0 +1,2 @@ |
|||||
|
Manifest-Version: 1.0 |
||||
|
|
||||
@ -0,0 +1,28 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project default="-deploy-ant" basedir="."> |
||||
|
<target name="-init" if="deploy.ant.enabled"> |
||||
|
<property file="${deploy.ant.properties.file}"/> |
||||
|
<tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/> |
||||
|
<unwar src="${deploy.ant.archive}" dest="${temp.module.folder}"> |
||||
|
<patternset includes="META-INF/context.xml"/> |
||||
|
</unwar> |
||||
|
<xmlproperty file="${temp.module.folder}/META-INF/context.xml"/> |
||||
|
<delete dir="${temp.module.folder}"/> |
||||
|
</target> |
||||
|
<target name="-deploy-ant" if="deploy.ant.enabled" depends="-init"> |
||||
|
<echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/> |
||||
|
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" |
||||
|
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/> |
||||
|
<deploy url="${tomcat.url}/manager" username="${tomcat.username}" |
||||
|
password="${tomcat.password}" path="${Context(path)}" |
||||
|
war="${deploy.ant.archive}"/> |
||||
|
<property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/> |
||||
|
</target> |
||||
|
<target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init"> |
||||
|
<echo message="Undeploying ${Context(path)}"/> |
||||
|
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" |
||||
|
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/> |
||||
|
<undeploy url="${tomcat.url}/manager" username="${tomcat.username}" |
||||
|
password="${tomcat.password}" path="${Context(path)}"/> |
||||
|
</target> |
||||
|
</project> |
||||
@ -0,0 +1,690 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!-- |
||||
|
*** GENERATED FROM project.xml - DO NOT EDIT *** |
||||
|
*** EDIT ../build.xml INSTEAD *** |
||||
|
|
||||
|
For the purpose of easier reading the script |
||||
|
is divided into following sections: |
||||
|
- initialization |
||||
|
- compilation |
||||
|
- dist |
||||
|
- execution |
||||
|
- debugging |
||||
|
- javadoc |
||||
|
- junit compilation |
||||
|
- junit execution |
||||
|
- junit debugging |
||||
|
- cleanup |
||||
|
|
||||
|
--> |
||||
|
<project name="bookshelf-impl" default="build" basedir=".." xmlns:webproject3="http://www.netbeans.org/ns/web-project/3" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1" xmlns:webproject1="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<import file="ant-deploy.xml"/> |
||||
|
<target name="default" depends="dist,javadoc" description="Build whole project."/> |
||||
|
<!-- |
||||
|
INITIALIZATION SECTION |
||||
|
--> |
||||
|
<target name="-pre-init"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-init-private" depends="-pre-init"> |
||||
|
<property file="nbproject/private/private.properties"/> |
||||
|
</target> |
||||
|
<target name="-init-user" depends="-pre-init,-init-private"> |
||||
|
<property file="${user.properties.file}"/> |
||||
|
<!-- The two properties below are usually overridden --> |
||||
|
<!-- by the active platform. Just a fallback. --> |
||||
|
<property name="default.javac.source" value="1.4"/> |
||||
|
<property name="default.javac.target" value="1.4"/> |
||||
|
</target> |
||||
|
<target name="-init-project" depends="-pre-init,-init-private,-init-user"> |
||||
|
<property file="nbproject/project.properties"/> |
||||
|
</target> |
||||
|
<target name="-do-ear-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" if="dist.ear.dir"> |
||||
|
<property value="${build.ear.web.dir}/META-INF" name="build.meta.inf.dir"/> |
||||
|
<property name="build.classes.dir.real" value="${build.ear.classes.dir}"/> |
||||
|
<property name="build.web.dir.real" value="${build.ear.web.dir}"/> |
||||
|
</target> |
||||
|
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property, -do-ear-init"> |
||||
|
<condition property="have.tests"> |
||||
|
<or> |
||||
|
<available file="${test.src.dir}"/> |
||||
|
</or> |
||||
|
</condition> |
||||
|
<condition property="have.sources"> |
||||
|
<or> |
||||
|
<available file="${src.dir}"/> |
||||
|
</or> |
||||
|
</condition> |
||||
|
<condition property="netbeans.home+have.tests"> |
||||
|
<and> |
||||
|
<isset property="netbeans.home"/> |
||||
|
<isset property="have.tests"/> |
||||
|
</and> |
||||
|
</condition> |
||||
|
<condition property="no.javadoc.preview"> |
||||
|
<isfalse value="${javadoc.preview}"/> |
||||
|
</condition> |
||||
|
<property name="javac.compilerargs" value=""/> |
||||
|
<condition property="no.deps"> |
||||
|
<and> |
||||
|
<istrue value="${no.dependencies}"/> |
||||
|
</and> |
||||
|
</condition> |
||||
|
<condition property="no.dist.ear.dir"> |
||||
|
<not> |
||||
|
<isset property="dist.ear.dir"/> |
||||
|
</not> |
||||
|
</condition> |
||||
|
<property name="build.web.excludes" value="${build.classes.excludes}"/> |
||||
|
<condition property="do.compile.jsps"> |
||||
|
<istrue value="${compile.jsps}"/> |
||||
|
</condition> |
||||
|
<condition property="do.display.browser"> |
||||
|
<istrue value="${display.browser}"/> |
||||
|
</condition> |
||||
|
<available file="${conf.dir}/MANIFEST.MF" property="has.custom.manifest"/> |
||||
|
<available file="${conf.dir}/persistence.xml" property="has.persistence.xml"/> |
||||
|
<condition property="do.war.package.with.custom.manifest"> |
||||
|
<and> |
||||
|
<istrue value="${war.package}"/> |
||||
|
<isset property="has.custom.manifest"/> |
||||
|
</and> |
||||
|
</condition> |
||||
|
<condition property="do.war.package.without.custom.manifest"> |
||||
|
<and> |
||||
|
<istrue value="${war.package}"/> |
||||
|
<not> |
||||
|
<isset property="has.custom.manifest"/> |
||||
|
</not> |
||||
|
</and> |
||||
|
</condition> |
||||
|
<property value="${build.web.dir}/META-INF" name="build.meta.inf.dir"/> |
||||
|
<property name="build.classes.dir.real" value="${build.classes.dir}"/> |
||||
|
<property name="build.web.dir.real" value="${build.web.dir}"/> |
||||
|
<condition property="application.args.param" value="${application.args}" else=""> |
||||
|
<and> |
||||
|
<isset property="application.args"/> |
||||
|
<not> |
||||
|
<equals arg1="${application.args}" arg2="" trim="true"/> |
||||
|
</not> |
||||
|
</and> |
||||
|
</condition> |
||||
|
</target> |
||||
|
<target name="-post-init"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init"> |
||||
|
<fail unless="src.dir">Must set src.dir</fail> |
||||
|
<fail unless="test.src.dir">Must set test.src.dir</fail> |
||||
|
<fail unless="build.dir">Must set build.dir</fail> |
||||
|
<fail unless="build.web.dir">Must set build.web.dir</fail> |
||||
|
<fail unless="build.generated.dir">Must set build.generated.dir</fail> |
||||
|
<fail unless="dist.dir">Must set dist.dir</fail> |
||||
|
<fail unless="build.classes.dir">Must set build.classes.dir</fail> |
||||
|
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> |
||||
|
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> |
||||
|
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail> |
||||
|
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail> |
||||
|
<fail unless="dist.war">Must set dist.war</fail> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-property"> |
||||
|
<macrodef name="property" uri="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<attribute name="name"/> |
||||
|
<attribute name="value"/> |
||||
|
<sequential> |
||||
|
<property name="@{name}" value="${@{value}}"/> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-javac"> |
||||
|
<macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2"> |
||||
|
<attribute name="srcdir" default="${src.dir}"/> |
||||
|
<attribute name="destdir" default="${build.classes.dir.real}"/> |
||||
|
<attribute name="classpath" default="${javac.classpath}:${j2ee.platform.classpath}"/> |
||||
|
<attribute name="debug" default="${javac.debug}"/> |
||||
|
<element name="customize" optional="true"/> |
||||
|
<sequential> |
||||
|
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> |
||||
|
<classpath> |
||||
|
<path path="@{classpath}"/> |
||||
|
</classpath> |
||||
|
<compilerarg line="${javac.compilerargs}"/> |
||||
|
<customize/> |
||||
|
</javac> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-junit"> |
||||
|
<macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2"> |
||||
|
<attribute name="includes" default="**/*Test.java"/> |
||||
|
<sequential> |
||||
|
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed"> |
||||
|
<batchtest todir="${build.test.results.dir}"> |
||||
|
<fileset dir="${test.src.dir}" includes="@{includes}"/> |
||||
|
</batchtest> |
||||
|
<classpath> |
||||
|
<path path="${run.test.classpath}"/> |
||||
|
</classpath> |
||||
|
<syspropertyset> |
||||
|
<propertyref prefix="test-sys-prop."/> |
||||
|
<mapper type="glob" from="test-sys-prop.*" to="*"/> |
||||
|
</syspropertyset> |
||||
|
<formatter type="brief" usefile="false"/> |
||||
|
<formatter type="xml"/> |
||||
|
</junit> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-java"> |
||||
|
<macrodef name="java" uri="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<attribute name="classname" default="${main.class}"/> |
||||
|
<element name="customize" optional="true"/> |
||||
|
<sequential> |
||||
|
<java fork="true" classname="@{classname}"> |
||||
|
<jvmarg line="${runmain.jvmargs}"/> |
||||
|
<classpath> |
||||
|
<path path="${build.classes.dir.real}:${javac.classpath}:${j2ee.platform.classpath}"/> |
||||
|
</classpath> |
||||
|
<syspropertyset> |
||||
|
<propertyref prefix="run-sys-prop."/> |
||||
|
<mapper type="glob" from="run-sys-prop.*" to="*"/> |
||||
|
</syspropertyset> |
||||
|
<customize/> |
||||
|
</java> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-nbjpda"> |
||||
|
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<attribute name="name" default="${main.class}"/> |
||||
|
<attribute name="classpath" default="${debug.classpath}"/> |
||||
|
<sequential> |
||||
|
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}"> |
||||
|
<classpath> |
||||
|
<path path="@{classpath}"/> |
||||
|
</classpath> |
||||
|
</nbjpdastart> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<attribute name="dir" default="${build.classes.dir.real}"/> |
||||
|
<sequential> |
||||
|
<nbjpdareload> |
||||
|
<fileset includes="${fix.includes}*.class" dir="@{dir}"/> |
||||
|
</nbjpdareload> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-debug"> |
||||
|
<macrodef name="debug" uri="http://www.netbeans.org/ns/web-project/1"> |
||||
|
<attribute name="classname" default="${main.class}"/> |
||||
|
<attribute name="classpath" default="${debug.classpath}"/> |
||||
|
<attribute name="args" default="${application.args.param}"/> |
||||
|
<sequential> |
||||
|
<java fork="true" classname="@{classname}"> |
||||
|
<jvmarg value="-Xdebug"/> |
||||
|
<jvmarg value="-Xnoagent"/> |
||||
|
<jvmarg value="-Djava.compiler=none"/> |
||||
|
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/> |
||||
|
<jvmarg line="${runmain.jvmargs}"/> |
||||
|
<classpath> |
||||
|
<path path="@{classpath}"/> |
||||
|
</classpath> |
||||
|
<syspropertyset> |
||||
|
<propertyref prefix="run-sys-prop."/> |
||||
|
<mapper type="glob" from="run-sys-prop.*" to="*"/> |
||||
|
</syspropertyset> |
||||
|
<arg line="@{args}"/> |
||||
|
</java> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="-init-macrodef-copy-ear-war"> |
||||
|
<macrodef name="copy-ear-war"> |
||||
|
<attribute name="file"/> |
||||
|
<attribute name="propname"/> |
||||
|
<sequential> |
||||
|
<basename property="base_@{propname}" file="@{file}"/> |
||||
|
<zipfileset id="tld.files_@{propname}" src="@{file}" includes="META-INF/*.tld META-INF/tlds/*.tld"/> |
||||
|
<pathconvert property="tld.files.path_@{propname}" refid="tld.files_@{propname}"/> |
||||
|
<condition value="yes" property="hastlds_@{propname}"> |
||||
|
<contains string="${tld.files.path_@{propname}}" substring=".tld" casesensitive="false"/> |
||||
|
</condition> |
||||
|
<condition value="${build.web.dir.real}/WEB-INF/lib" property="copy.to.dir_@{propname}"> |
||||
|
<isset property="hastlds_@{propname}"/> |
||||
|
</condition> |
||||
|
<condition value="${dist.ear.dir}" property="copy.to.dir_@{propname}"> |
||||
|
<not> |
||||
|
<isset property="hastlds_@{propname}"/> |
||||
|
</not> |
||||
|
</condition> |
||||
|
<copy file="@{file}" todir="${copy.to.dir_@{propname}}"/> |
||||
|
<condition value="${base_@{propname}}" property="@{propname}"> |
||||
|
<not> |
||||
|
<isset property="hastlds_@{propname}"/> |
||||
|
</not> |
||||
|
</condition> |
||||
|
<condition value="" property="@{propname}"> |
||||
|
<isset property="hastlds_@{propname}"/> |
||||
|
</condition> |
||||
|
</sequential> |
||||
|
</macrodef> |
||||
|
</target> |
||||
|
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-copy-ear-war"/> |
||||
|
<!-- |
||||
|
COMPILATION SECTION |
||||
|
--> |
||||
|
<target name="deps-module-jar" depends="init" if="no.dist.ear.dir" unless="no.deps"/> |
||||
|
<target name="deps-ear-jar" depends="init" if="dist.ear.dir" unless="no.deps"/> |
||||
|
<target name="deps-jar" depends="init, deps-module-jar, deps-ear-jar" unless="no.deps"/> |
||||
|
<target name="-pre-pre-compile" depends="init,deps-jar"> |
||||
|
<mkdir dir="${build.classes.dir.real}"/> |
||||
|
</target> |
||||
|
<target name="-pre-compile"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-copy-webdir"> |
||||
|
<copy todir="${build.web.dir.real}"> |
||||
|
<fileset excludes="${build.web.excludes}" dir="${web.docbase.dir}"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-do-compile" depends="init, deps-jar, -pre-pre-compile, -pre-compile, -copy-manifest, -copy-persistence-xml, -copy-webdir, library-inclusion-in-archive,library-inclusion-in-manifest" if="have.sources"> |
||||
|
<webproject2:javac destdir="${build.classes.dir.real}"/> |
||||
|
<copy todir="${build.classes.dir.real}"> |
||||
|
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-copy-manifest" if="has.custom.manifest"> |
||||
|
<mkdir dir="${build.meta.inf.dir}"/> |
||||
|
<copy todir="${build.meta.inf.dir}"> |
||||
|
<fileset dir="${conf.dir}" includes="MANIFEST.MF"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-copy-persistence-xml" if="has.persistence.xml"> |
||||
|
<mkdir dir="${build.web.dir.real}/WEB-INF/classes/META-INF"/> |
||||
|
<copy todir="${build.web.dir.real}/WEB-INF/classes/META-INF"> |
||||
|
<fileset dir="${conf.dir}" includes="persistence.xml"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-post-compile"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/> |
||||
|
<target name="-pre-compile-single"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile"> |
||||
|
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> |
||||
|
<webproject2:javac> |
||||
|
<customize> |
||||
|
<patternset includes="${javac.includes}"/> |
||||
|
</customize> |
||||
|
</webproject2:javac> |
||||
|
<copy todir="${build.classes.dir.real}"> |
||||
|
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-post-compile-single"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/> |
||||
|
<target name="compile-jsps" depends="compile" if="do.compile.jsps" description="Test compile JSP pages to expose compilation errors."> |
||||
|
<mkdir dir="${build.generated.dir}/src"/> |
||||
|
<java classname="org.netbeans.modules.web.project.ant.JspC" fork="true" failonerror="true"> |
||||
|
<arg value="-uriroot"/> |
||||
|
<arg file="${basedir}/${build.web.dir.real}"/> |
||||
|
<arg value="-d"/> |
||||
|
<arg file="${basedir}/${build.generated.dir}/src"/> |
||||
|
<arg value="-die1"/> |
||||
|
<classpath path="${java.home}/../lib/tools.jar:${copyfiles.classpath}:${jspcompilation.classpath}"/> |
||||
|
</java> |
||||
|
<mkdir dir="${build.generated.dir}/classes"/> |
||||
|
<webproject2:javac srcdir="${build.generated.dir}/src" destdir="${build.generated.dir}/classes" classpath="${j2ee.platform.classpath}:${build.classes.dir.real}:${jspcompilation.classpath}"/> |
||||
|
</target> |
||||
|
<target name="-do-compile-single-jsp" depends="compile" if="jsp.includes"> |
||||
|
<fail unless="javac.jsp.includes">Must select some files in the IDE or set javac.jsp.includes</fail> |
||||
|
<mkdir dir="${build.generated.dir}/src"/> |
||||
|
<java classname="org.netbeans.modules.web.project.ant.JspCSingle" fork="true" failonerror="true"> |
||||
|
<arg value="-uriroot"/> |
||||
|
<arg file="${basedir}/${build.web.dir.real}"/> |
||||
|
<arg value="-d"/> |
||||
|
<arg file="${basedir}/${build.generated.dir}/src"/> |
||||
|
<arg value="-die1"/> |
||||
|
<arg value="-jspc.files"/> |
||||
|
<arg path="${jsp.includes}"/> |
||||
|
<classpath path="${java.home}/../lib/tools.jar:${copyfiles.classpath}:${jspcompilation.classpath}"/> |
||||
|
</java> |
||||
|
<mkdir dir="${build.generated.dir}/classes"/> |
||||
|
<webproject2:javac srcdir="${build.generated.dir}/src" destdir="${build.generated.dir}/classes" classpath="${j2ee.platform.classpath}:${build.classes.dir.real}:${jspcompilation.classpath}"> |
||||
|
<customize> |
||||
|
<patternset includes="${javac.jsp.includes}"/> |
||||
|
</customize> |
||||
|
</webproject2:javac> |
||||
|
</target> |
||||
|
<target name="compile-single-jsp"> |
||||
|
<fail unless="jsp.includes">Must select a file in the IDE or set jsp.includes</fail> |
||||
|
<antcall target="-do-compile-single-jsp"/> |
||||
|
</target> |
||||
|
<!-- |
||||
|
DIST BUILDING SECTION |
||||
|
--> |
||||
|
<target name="-pre-dist"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-do-dist-without-manifest" if="do.war.package.without.custom.manifest" depends="init,compile,compile-jsps,-pre-dist"> |
||||
|
<dirname property="dist.jar.dir" file="${dist.war}"/> |
||||
|
<mkdir dir="${dist.jar.dir}"/> |
||||
|
<jar jarfile="${dist.war}" compress="${jar.compress}"> |
||||
|
<fileset dir="${build.web.dir.real}"/> |
||||
|
</jar> |
||||
|
</target> |
||||
|
<target name="-do-dist-with-manifest" if="do.war.package.with.custom.manifest" depends="init,compile,compile-jsps,-pre-dist"> |
||||
|
<dirname property="dist.jar.dir" file="${dist.war}"/> |
||||
|
<mkdir dir="${dist.jar.dir}"/> |
||||
|
<jar manifest="${build.meta.inf.dir}/MANIFEST.MF" jarfile="${dist.war}" compress="${jar.compress}"> |
||||
|
<fileset dir="${build.web.dir.real}"/> |
||||
|
</jar> |
||||
|
</target> |
||||
|
<target name="do-dist" depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest"/> |
||||
|
<target name="library-inclusion-in-manifest" depends="init" if="dist.ear.dir"> |
||||
|
<mkdir dir="${build.web.dir.real}/META-INF"/> |
||||
|
<manifest file="${build.web.dir.real}/META-INF/MANIFEST.MF" mode="update"/> |
||||
|
<delete dir="${dist.ear.dir}/temp"/> |
||||
|
</target> |
||||
|
<target name="library-inclusion-in-archive" depends="init" unless="dist.ear.dir"/> |
||||
|
<target name="do-ear-dist" depends="init,compile,compile-jsps,-pre-dist,library-inclusion-in-manifest"> |
||||
|
<dirname property="dist.jar.dir" file="${dist.ear.war}"/> |
||||
|
<mkdir dir="${dist.jar.dir}"/> |
||||
|
<jar jarfile="${dist.ear.war}" compress="${jar.compress}" manifest="${build.web.dir.real}/META-INF/MANIFEST.MF"> |
||||
|
<fileset dir="${build.web.dir.real}"/> |
||||
|
</jar> |
||||
|
</target> |
||||
|
<target name="-post-dist"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="dist" depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)."/> |
||||
|
<target name="dist-ear" depends="init,compile,-pre-dist,do-ear-dist,-post-dist" description="Build distribution (WAR) to be packaged into an EAR."/> |
||||
|
<!-- |
||||
|
EXECUTION SECTION |
||||
|
--> |
||||
|
<target name="run" depends="run-deploy,run-display-browser" description="Deploy to server and show in browser."/> |
||||
|
<target name="-pre-run-deploy"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-post-run-deploy"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-pre-nbmodule-run-deploy"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. --> |
||||
|
</target> |
||||
|
<target name="-post-nbmodule-run-deploy"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. --> |
||||
|
</target> |
||||
|
<target name="-run-deploy-am"> |
||||
|
<!-- Task to deploy to the Access Manager runtime. --> |
||||
|
</target> |
||||
|
<target name="run-deploy" depends="init,compile,compile-jsps,-do-compile-single-jsp,dist,-pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,-post-run-deploy"/> |
||||
|
<target name="-run-deploy-nb" if="netbeans.home"> |
||||
|
<nbdeploy debugmode="false" clientUrlPart="${client.urlPart}" forceRedeploy="${forceRedeploy}"/> |
||||
|
</target> |
||||
|
<target name="-init-deploy-ant" unless="netbeans.home"> |
||||
|
<property name="deploy.ant.archive" value="${dist.war}"/> |
||||
|
<property name="deploy.ant.docbase.dir" value="${web.docbase.dir}"/> |
||||
|
<property name="deploy.ant.resource.dir" value="${resource.dir}"/> |
||||
|
<property name="deploy.ant.enabled" value="true"/> |
||||
|
</target> |
||||
|
<target name="run-undeploy" depends="dist,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant"/> |
||||
|
<target name="-run-undeploy-nb" if="netbeans.home"> |
||||
|
<fail message="Undeploy is not supported from within the IDE"/> |
||||
|
</target> |
||||
|
<target name="verify" depends="init,dist"> |
||||
|
<nbverify file="${dist.war}"/> |
||||
|
</target> |
||||
|
<target name="run-display-browser" depends="run-deploy,-init-display-browser,-display-browser-nb,-display-browser-cl"/> |
||||
|
<target name="-init-display-browser" if="do.display.browser"> |
||||
|
<condition property="do.display.browser.nb"> |
||||
|
<isset property="netbeans.home"/> |
||||
|
</condition> |
||||
|
<condition property="do.display.browser.cl"> |
||||
|
<isset property="deploy.ant.enabled"/> |
||||
|
</condition> |
||||
|
</target> |
||||
|
<target name="-display-browser-nb" if="do.display.browser.nb"> |
||||
|
<nbbrowse url="${client.url}"/> |
||||
|
</target> |
||||
|
<target name="-get-browser" if="do.display.browser.cl" unless="browser"> |
||||
|
<condition property="browser" value="rundll32"> |
||||
|
<os family="windows"/> |
||||
|
</condition> |
||||
|
<condition property="browser.args" value="url.dll,FileProtocolHandler" else=""> |
||||
|
<os family="windows"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/bin/open"> |
||||
|
<os family="mac"/> |
||||
|
</condition> |
||||
|
<property environment="env"/> |
||||
|
<condition property="browser" value="${env.BROWSER}"> |
||||
|
<isset property="env.BROWSER"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/bin/firefox"> |
||||
|
<available file="/usr/bin/firefox"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/local/firefox/firefox"> |
||||
|
<available file="/usr/local/firefox/firefox"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/bin/mozilla"> |
||||
|
<available file="/usr/bin/mozilla"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/local/mozilla/mozilla"> |
||||
|
<available file="/usr/local/mozilla/mozilla"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/sfw/lib/firefox/firefox"> |
||||
|
<available file="/usr/sfw/lib/firefox/firefox"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/opt/csw/bin/firefox"> |
||||
|
<available file="/opt/csw/bin/firefox"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/usr/sfw/lib/mozilla/mozilla"> |
||||
|
<available file="/usr/sfw/lib/mozilla/mozilla"/> |
||||
|
</condition> |
||||
|
<condition property="browser" value="/opt/csw/bin/mozilla"> |
||||
|
<available file="/opt/csw/bin/mozilla"/> |
||||
|
</condition> |
||||
|
</target> |
||||
|
<target name="-display-browser-cl" depends="-get-browser" if="do.display.browser.cl"> |
||||
|
<fail unless="browser"> |
||||
|
Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. |
||||
|
</fail> |
||||
|
<property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/> |
||||
|
<echo>Launching ${browse.url}</echo> |
||||
|
<exec executable="${browser}" spawn="true"> |
||||
|
<arg line="${browser.args} ${browse.url}"/> |
||||
|
</exec> |
||||
|
</target> |
||||
|
<target name="run-main" depends="init,compile-single"> |
||||
|
<fail unless="run.class">Must select one file in the IDE or set run.class</fail> |
||||
|
<webproject1:java classname="${run.class}"/> |
||||
|
</target> |
||||
|
<!-- |
||||
|
DEBUGGING SECTION |
||||
|
--> |
||||
|
<target name="debug" description="Debug project in IDE." depends="init,compile,compile-jsps,-do-compile-single-jsp,dist" if="netbeans.home"> |
||||
|
<nbdeploy debugmode="true" clientUrlPart="${client.urlPart}"/> |
||||
|
<antcall target="connect-debugger"/> |
||||
|
<antcall target="debug-display-browser"/> |
||||
|
</target> |
||||
|
<target name="connect-debugger" unless="is.debugged"> |
||||
|
<nbjpdaconnect name="${name}" host="${jpda.host}" address="${jpda.address}" transport="${jpda.transport}"> |
||||
|
<classpath> |
||||
|
<path path="${debug.classpath}:${ws.debug.classpaths}"/> |
||||
|
</classpath> |
||||
|
<sourcepath> |
||||
|
<path path="${web.docbase.dir}:${ws.web.docbase.dirs}"/> |
||||
|
</sourcepath> |
||||
|
</nbjpdaconnect> |
||||
|
</target> |
||||
|
<target name="debug-display-browser" if="do.display.browser"> |
||||
|
<nbbrowse url="${client.url}"/> |
||||
|
</target> |
||||
|
<target name="debug-single" if="netbeans.home" depends="init,compile,compile-jsps,-do-compile-single-jsp,debug"/> |
||||
|
<target name="-debug-start-debugger" if="netbeans.home" depends="init"> |
||||
|
<webproject1:nbjpdastart name="${debug.class}"/> |
||||
|
</target> |
||||
|
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single"> |
||||
|
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> |
||||
|
<webproject1:debug classname="${debug.class}"/> |
||||
|
</target> |
||||
|
<target name="debug-single-main" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/> |
||||
|
<target name="-pre-debug-fix" depends="init"> |
||||
|
<fail unless="fix.includes">Must set fix.includes</fail> |
||||
|
<property name="javac.includes" value="${fix.includes}.java"/> |
||||
|
</target> |
||||
|
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single"> |
||||
|
<webproject1:nbjpdareload/> |
||||
|
</target> |
||||
|
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/> |
||||
|
<!-- |
||||
|
JAVADOC SECTION |
||||
|
--> |
||||
|
<target name="javadoc-build" depends="init"> |
||||
|
<mkdir dir="${dist.javadoc.dir}"/> |
||||
|
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true"> |
||||
|
<classpath> |
||||
|
<path path="${javac.classpath}:${j2ee.platform.classpath}"/> |
||||
|
</classpath> |
||||
|
<sourcepath> |
||||
|
<pathelement location="${src.dir}"/> |
||||
|
</sourcepath> |
||||
|
<packageset dir="${src.dir}" includes="*/**"/> |
||||
|
<fileset dir="${src.dir}" includes="*.java"/> |
||||
|
</javadoc> |
||||
|
</target> |
||||
|
<target name="javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,javadoc-build"> |
||||
|
<nbbrowse file="${dist.javadoc.dir}/index.html"/> |
||||
|
</target> |
||||
|
<target name="javadoc" depends="init,javadoc-build,javadoc-browse" description="Build Javadoc."/> |
||||
|
<!-- |
||||
|
|
||||
|
JUNIT COMPILATION SECTION |
||||
|
--> |
||||
|
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile"> |
||||
|
<mkdir dir="${build.test.classes.dir}"/> |
||||
|
</target> |
||||
|
<target name="-pre-compile-test"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test"> |
||||
|
<webproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}:${j2ee.platform.classpath}"/> |
||||
|
<copy todir="${build.test.classes.dir}"> |
||||
|
<fileset dir="${test.src.dir}" excludes="**/*.java"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-post-compile-test"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/> |
||||
|
<target name="-pre-compile-test-single"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single"> |
||||
|
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> |
||||
|
<webproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}:${j2ee.platform.classpath}"> |
||||
|
<customize> |
||||
|
<patternset includes="${javac.includes}"/> |
||||
|
</customize> |
||||
|
</webproject2:javac> |
||||
|
<copy todir="${build.test.classes.dir}"> |
||||
|
<fileset dir="${test.src.dir}" excludes="**/*.java"/> |
||||
|
</copy> |
||||
|
</target> |
||||
|
<target name="-post-compile-test-single"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/> |
||||
|
<!-- |
||||
|
|
||||
|
JUNIT EXECUTION SECTION |
||||
|
--> |
||||
|
<target name="-pre-test-run" if="have.tests" depends="init"> |
||||
|
<mkdir dir="${build.test.results.dir}"/> |
||||
|
</target> |
||||
|
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run"> |
||||
|
<webproject2:junit/> |
||||
|
</target> |
||||
|
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run"> |
||||
|
<fail if="tests.failed">Some tests failed; see details above.</fail> |
||||
|
</target> |
||||
|
<target name="test-report" if="have.tests" depends="init"/> |
||||
|
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/> |
||||
|
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/> |
||||
|
<target name="-pre-test-run-single" if="have.tests" depends="init"> |
||||
|
<mkdir dir="${build.test.results.dir}"/> |
||||
|
</target> |
||||
|
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single"> |
||||
|
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> |
||||
|
<webproject2:junit includes="${test.includes}"/> |
||||
|
</target> |
||||
|
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single"> |
||||
|
<fail if="tests.failed">Some tests failed; see details above.</fail> |
||||
|
</target> |
||||
|
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/> |
||||
|
<!-- |
||||
|
|
||||
|
JUNIT DEBUGGING SECTION |
||||
|
--> |
||||
|
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test"> |
||||
|
<fail unless="test.class">Must select one file in the IDE or set test.class</fail> |
||||
|
<webproject1:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}" args="${test.class}"/> |
||||
|
</target> |
||||
|
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test"> |
||||
|
<webproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/> |
||||
|
</target> |
||||
|
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/> |
||||
|
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single"> |
||||
|
<webproject1:nbjpdareload dir="${build.test.classes.dir}"/> |
||||
|
</target> |
||||
|
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/> |
||||
|
<!-- |
||||
|
|
||||
|
CLEANUP SECTION |
||||
|
--> |
||||
|
<target name="deps-clean" depends="init" if="no.dist.ear.dir" unless="no.deps"/> |
||||
|
<target name="do-clean" depends="init"> |
||||
|
<condition value="${build.web.dir.real}" property="build.dir.to.clean"> |
||||
|
<isset property="dist.ear.dir"/> |
||||
|
</condition> |
||||
|
<property value="${build.web.dir.real}" name="build.dir.to.clean"/> |
||||
|
<delete includeEmptyDirs="true" quiet="true"> |
||||
|
<fileset dir="${build.dir.to.clean}/WEB-INF/lib"/> |
||||
|
</delete> |
||||
|
<delete dir="${build.dir}"/> |
||||
|
<available file="${build.dir.to.clean}/WEB-INF/lib" type="dir" property="status.clean-failed"/> |
||||
|
<delete dir="${dist.dir}"/> |
||||
|
</target> |
||||
|
<target name="check-clean" depends="do-clean" if="status.clean-failed"> |
||||
|
<echo message="Warning: unable to delete some files in ${build.web.dir.real}/WEB-INF/lib - they are probably locked by the J2EE server. "/> |
||||
|
<echo level="info" message="To delete all files undeploy the module from Server Registry in Runtime tab and then use Clean again."/> |
||||
|
</target> |
||||
|
<target name="-post-clean"> |
||||
|
<!-- Empty placeholder for easier customization. --> |
||||
|
<!-- You can override this target in the ../build.xml file. --> |
||||
|
</target> |
||||
|
<target name="clean" depends="init,deps-clean,do-clean,check-clean,-post-clean" description="Clean build products."/> |
||||
|
<target name="clean-ear" depends="clean" description="Clean build products."/> |
||||
|
</project> |
||||
@ -0,0 +1,8 @@ |
|||||
|
build.xml.data.CRC32=c1b5a629 |
||||
|
build.xml.script.CRC32=16f4cbe7 |
||||
|
build.xml.stylesheet.CRC32=95be3570 |
||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
|
nbproject/build-impl.xml.data.CRC32=c1b5a629 |
||||
|
nbproject/build-impl.xml.script.CRC32=4e40cf18 |
||||
|
nbproject/build-impl.xml.stylesheet.CRC32=ac43bae1 |
||||
@ -0,0 +1,65 @@ |
|||||
|
build.classes.dir=${build.web.dir}/WEB-INF/classes |
||||
|
build.classes.excludes=**/*.java,**/*.form |
||||
|
build.dir=build |
||||
|
build.ear.classes.dir=${build.ear.web.dir}/WEB-INF/classes |
||||
|
build.ear.web.dir=${build.dir}/ear-module |
||||
|
build.generated.dir=${build.dir}/generated |
||||
|
build.test.classes.dir=${build.dir}/test/classes |
||||
|
build.test.results.dir=${build.dir}/test/results |
||||
|
build.web.dir=${build.dir}/web |
||||
|
build.web.excludes=${build.classes.excludes} |
||||
|
client.urlPart= |
||||
|
compile.jsps=false |
||||
|
conf.dir=conf |
||||
|
debug.classpath=${javac.classpath}:${build.classes.dir}:${build.ear.classes.dir} |
||||
|
debug.test.classpath=\ |
||||
|
${run.test.classpath} |
||||
|
display.browser=true |
||||
|
dist.dir=dist |
||||
|
dist.ear.war=${dist.dir}/${war.ear.name} |
||||
|
dist.javadoc.dir=${dist.dir}/javadoc |
||||
|
dist.war=${dist.dir}/${war.name} |
||||
|
j2ee.platform=1.4 |
||||
|
j2ee.server.type=Tomcat55 |
||||
|
jar.compress=false |
||||
|
javac.classpath= |
||||
|
# Space-separated list of extra javac options |
||||
|
javac.compilerargs= |
||||
|
javac.debug=true |
||||
|
javac.deprecation=false |
||||
|
javac.source=${default.javac.source} |
||||
|
javac.target=${default.javac.target} |
||||
|
javac.test.classpath=\ |
||||
|
${javac.classpath}:\ |
||||
|
${build.classes.dir}:\ |
||||
|
${libs.junit.classpath} |
||||
|
javadoc.additionalparam= |
||||
|
javadoc.author=false |
||||
|
javadoc.encoding= |
||||
|
javadoc.noindex=false |
||||
|
javadoc.nonavbar=false |
||||
|
javadoc.notree=false |
||||
|
javadoc.preview=true |
||||
|
javadoc.private=false |
||||
|
javadoc.splitindex=true |
||||
|
javadoc.use=true |
||||
|
javadoc.version=false |
||||
|
javadoc.windowtitle= |
||||
|
jspcompilation.classpath=${jspc.classpath}:${javac.classpath} |
||||
|
lib.dir=${web.docbase.dir}/WEB-INF/lib |
||||
|
platform.active=default_platform |
||||
|
resource.dir=setup |
||||
|
run.test.classpath=\ |
||||
|
${javac.test.classpath}:\ |
||||
|
${build.test.classes.dir} |
||||
|
# Space-separated list of JVM arguments used when running class with main method |
||||
|
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): |
||||
|
runmain.jvmargs= |
||||
|
source.root=. |
||||
|
src.dir=src |
||||
|
test.src.dir=test |
||||
|
war.content.additional= |
||||
|
war.ear.name=bookshelf.war |
||||
|
war.name=bookshelf.war |
||||
|
war.package=true |
||||
|
web.docbase.dir=web |
||||
@ -0,0 +1,18 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project xmlns="http://www.netbeans.org/ns/project/1"> |
||||
|
<type>org.netbeans.modules.web.project</type> |
||||
|
<configuration> |
||||
|
<data xmlns="http://www.netbeans.org/ns/web-project/3"> |
||||
|
<name>bookshelf</name> |
||||
|
<minimum-ant-version>1.6</minimum-ant-version> |
||||
|
<web-module-libraries/> |
||||
|
<web-module-additional-libraries/> |
||||
|
<source-roots> |
||||
|
<root id="src.dir"/> |
||||
|
</source-roots> |
||||
|
<test-roots> |
||||
|
<root id="test.src.dir"/> |
||||
|
</test-roots> |
||||
|
</data> |
||||
|
</configuration> |
||||
|
</project> |
||||
@ -0,0 +1,39 @@ |
|||||
|
/* |
||||
|
* BookshelfDatabase.java |
||||
|
* |
||||
|
* Created on November 19, 2006, 11:36 AM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* Represents a connection to a database. |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public interface BookshelfDatabase { |
||||
|
|
||||
|
public BookshelfDocument getDocumentFromGlobalId(int globalId); |
||||
|
public List<DeweyCategory> getDeweyCategories(String level); |
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
/* |
||||
|
* BookshelfDocument.java |
||||
|
* |
||||
|
* Created on November 5, 2006, 8:59 PM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import javax.naming.*; |
||||
|
import javax.naming.directory.*; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public class BookshelfDocument { |
||||
|
private int globalId; |
||||
|
private String title; |
||||
|
|
||||
|
/** Creates a new instance of BookshelfDocument */ |
||||
|
public BookshelfDocument(SearchResult res) { |
||||
|
try { |
||||
|
Attributes attrs = res.getAttributes(); |
||||
|
|
||||
|
Attribute gidAttr = attrs.get("frItixGlobalId"); |
||||
|
this.globalId = Integer.parseInt((String) gidAttr.get()); |
||||
|
|
||||
|
Attribute titleAttr = attrs.get("frItixTitle"); |
||||
|
this.title = (String) titleAttr.get(); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String toString() { |
||||
|
return "[" + this.globalId + "] \"" + this.title + "\""; |
||||
|
} |
||||
|
|
||||
|
public int getGlobalId() { |
||||
|
return globalId; |
||||
|
} |
||||
|
|
||||
|
public String getTitle() { |
||||
|
return title; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
/* |
||||
|
* DeweyCategory.java |
||||
|
* |
||||
|
* Created on January 22, 2007, 9:16 PM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import javax.naming.*; |
||||
|
import javax.naming.directory.*; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public class DeweyCategory { |
||||
|
private String id; |
||||
|
private String name; |
||||
|
|
||||
|
/** Creates a new instance of DeweyCategory */ |
||||
|
public DeweyCategory(SearchResult res) { |
||||
|
try { |
||||
|
Attributes attrs = res.getAttributes(); |
||||
|
|
||||
|
Attribute idAttr = attrs.get("frItixCategoryId"); |
||||
|
this.id = (String) idAttr.get(); |
||||
|
|
||||
|
Attribute nameAttr = attrs.get("frItixCategoryName"); |
||||
|
this.name = (String) nameAttr.get(); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public String toString() { |
||||
|
return "[" + this.getId() + "] \"" + this.getName() + "\""; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,194 @@ |
|||||
|
/* |
||||
|
* Isbn.java |
||||
|
* |
||||
|
* Created on November 19, 2006, 10:08 AM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
/** |
||||
|
* Represents an ISBN (10 or 13 chars long). |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public abstract class Isbn { |
||||
|
/** The ISBN without separator */ |
||||
|
private String isbn; |
||||
|
|
||||
|
/** Creates a new instance of Isbn */ |
||||
|
public Isbn(String newIsbn) { |
||||
|
// Is the checksum valid ?
|
||||
|
if (this.check(newIsbn)) { |
||||
|
|
||||
|
// All is OK
|
||||
|
this.isbn = newIsbn; |
||||
|
} else { |
||||
|
throw new IllegalArgumentException("Bad Checksum"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check the validity of the Isbn |
||||
|
*/ |
||||
|
public abstract boolean check(String isbn); |
||||
|
|
||||
|
/** |
||||
|
* Returns the string representation of this ISBN. |
||||
|
*/ |
||||
|
public String toString() { |
||||
|
return isbn; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* The factory of ISBNs. |
||||
|
* |
||||
|
* @param i an ISBN (10 or 13) |
||||
|
* @return an object |
||||
|
*/ |
||||
|
public static Isbn newIsbn(String i) { |
||||
|
// remove separators and length check
|
||||
|
i = Isbn.cleanIsbn(i); |
||||
|
|
||||
|
Isbn newIsbn = null; |
||||
|
|
||||
|
// An ISBN must be 10 or 13 chars long.
|
||||
|
if (i.length() == 10) { |
||||
|
newIsbn = new Isbn10(i); |
||||
|
} else if (i.length() == 13) { |
||||
|
newIsbn = new Isbn13(i); |
||||
|
} else { |
||||
|
throw new IllegalArgumentException("The ISBN has an invalid size" |
||||
|
+ " (" + i.length() + ")"); |
||||
|
} |
||||
|
|
||||
|
return newIsbn; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Cleans the ISBN by removing all hyphens and white spaces. |
||||
|
* |
||||
|
* @param newIsbn the isbn to check |
||||
|
* @return the cleaned isbn |
||||
|
*/ |
||||
|
public static String cleanIsbn(String newIsbn) { |
||||
|
StringBuffer b = new StringBuffer(13); |
||||
|
|
||||
|
// Remove all the separators
|
||||
|
int len = newIsbn.length(); |
||||
|
for (int i = 0; i < len; i++) { |
||||
|
|
||||
|
char c = newIsbn.charAt(i); |
||||
|
|
||||
|
if ((c >= '0' && c <= '9') || c == 'X' || c == 'x') { |
||||
|
// valid ISBN character
|
||||
|
b.append(c); |
||||
|
} else if (c == '-' || c == ' ') { |
||||
|
// ignore separators
|
||||
|
} else { |
||||
|
throw new IllegalArgumentException("Invalid character found in" |
||||
|
+ " the ISBN at pos " + i + " (" + c + ")"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return b.toString(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* An old ISBN (10 chars) |
||||
|
*/ |
||||
|
class Isbn10 extends Isbn { |
||||
|
public Isbn10(String i) { |
||||
|
super(i); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check the validity of an ISBN10. |
||||
|
* |
||||
|
* @param isbn the result of the function cleanIsbn. |
||||
|
* @return true or false |
||||
|
*/ |
||||
|
public boolean check(String isbn) { |
||||
|
boolean res = false; |
||||
|
|
||||
|
int sum = 0; |
||||
|
for (int i = 0; i < 9; i++) { |
||||
|
if (isbn.charAt(i) == 'x' || isbn.charAt(i) == 'X') { |
||||
|
throw new IllegalArgumentException("Invalid 'X' character found" |
||||
|
+ " in the middle of the ISBN"); |
||||
|
} |
||||
|
|
||||
|
sum += (isbn.charAt(i) - '0') * (10 - i); |
||||
|
} |
||||
|
|
||||
|
if (isbn.charAt(9) == 'x' || isbn.charAt(9) == 'X') { |
||||
|
sum += 10; |
||||
|
} else { |
||||
|
sum += (isbn.charAt(9) - '0'); |
||||
|
} |
||||
|
|
||||
|
if ((sum % 11) == 0) { |
||||
|
res = true; |
||||
|
} |
||||
|
|
||||
|
return res; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* A new ISBN (13 chars). |
||||
|
*/ |
||||
|
class Isbn13 extends Isbn { |
||||
|
public Isbn13(String i) { |
||||
|
super(i); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Check the validity of an ISBN13. |
||||
|
* |
||||
|
* @param s the result of the function cleanIsbn. |
||||
|
* @return true or false |
||||
|
*/ |
||||
|
public boolean check(String s) { |
||||
|
boolean res = false; |
||||
|
|
||||
|
int sum = 0; |
||||
|
int w = 1; |
||||
|
for (int i = 0; i < 13; i++) { |
||||
|
if (s.charAt(i) == 'x' || s.charAt(i) == 'X') { |
||||
|
throw new IllegalArgumentException("Invalid 'X' character found" |
||||
|
+ " in an ISBN13"); |
||||
|
} |
||||
|
|
||||
|
sum += (s.charAt(i) - '0') * w; |
||||
|
w = (w == 1 ? 3 : 1); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
if ((sum % 10) == 0) { |
||||
|
res = true; |
||||
|
} |
||||
|
|
||||
|
return res; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,144 @@ |
|||||
|
/* |
||||
|
* LdapDatabase.java |
||||
|
* |
||||
|
* Created on November 19, 2006, 11:38 AM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import javax.naming.*; |
||||
|
import javax.naming.directory.*; |
||||
|
|
||||
|
/** |
||||
|
* Represents an LDAP directory. |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public class LdapDatabase implements BookshelfDatabase { |
||||
|
private DirContext dctx; |
||||
|
|
||||
|
/** Creates a new instance of LdapDatabase */ |
||||
|
public LdapDatabase(String jndiUrl, String user, String pass) throws NamingException { |
||||
|
//Create a Hashtable object to place environment settings
|
||||
|
Hashtable env = new Hashtable(); |
||||
|
|
||||
|
//Specify service provider class
|
||||
|
String sp = "com.sun.jndi.ldap.LdapCtxFactory"; |
||||
|
env.put(Context.INITIAL_CONTEXT_FACTORY, sp); |
||||
|
|
||||
|
//Specify location of LDAP directory service
|
||||
|
env.put(Context.PROVIDER_URL, jndiUrl); |
||||
|
|
||||
|
//Set the authentication type
|
||||
|
env.put(Context.SECURITY_AUTHENTICATION, "simple"); |
||||
|
|
||||
|
//Set username and password
|
||||
|
env.put(Context.SECURITY_PRINCIPAL, user); |
||||
|
env.put(Context.SECURITY_CREDENTIALS, pass); |
||||
|
|
||||
|
dctx = new InitialDirContext(env); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Closes the connection to the directory. |
||||
|
*/ |
||||
|
protected void finalize() throws NamingException { |
||||
|
dctx.close(); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* See BookshelfDatabase.java |
||||
|
*/ |
||||
|
public BookshelfDocument getDocumentFromGlobalId(int globalId) { |
||||
|
// Set search base
|
||||
|
String base = ""; |
||||
|
|
||||
|
// Set attribute filter and search scope
|
||||
|
SearchControls sc = new SearchControls(); |
||||
|
String[] attributeFilter = { "frItixGlobalId", "frItixTitle" }; |
||||
|
sc.setReturningAttributes(attributeFilter); |
||||
|
sc.setSearchScope(SearchControls.SUBTREE_SCOPE); |
||||
|
|
||||
|
// Define filter
|
||||
|
String filter = "(frItixGlobalId=" + globalId + ")"; |
||||
|
NamingEnumeration results; |
||||
|
|
||||
|
// The document
|
||||
|
BookshelfDocument d = null; |
||||
|
|
||||
|
try { |
||||
|
results = dctx.search(base, filter, sc); |
||||
|
if (results.hasMore()) { |
||||
|
SearchResult sr = (SearchResult)results.next(); |
||||
|
d = new BookshelfDocument(sr); |
||||
|
d.toString(); |
||||
|
} else { |
||||
|
throw new RuntimeException("No matching document found"); |
||||
|
} |
||||
|
} catch (NamingException ex) { |
||||
|
ex.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return d; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Returns the list of all the categories of the Decimal Dewey |
||||
|
* Classification under the given level. |
||||
|
* |
||||
|
* @param level the catagory in which we search |
||||
|
*/ |
||||
|
public List<DeweyCategory> getDeweyCategories(String level) { |
||||
|
if ("".equals(level)) { |
||||
|
// Set search base
|
||||
|
String base = ""; |
||||
|
|
||||
|
// Set attribute filter and search scope
|
||||
|
SearchControls sc = new SearchControls(); |
||||
|
String[] attributeFilter = { "frItixCategoryId", "frItixCategoryName" }; |
||||
|
sc.setReturningAttributes(attributeFilter); |
||||
|
sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); |
||||
|
|
||||
|
// Define filter
|
||||
|
String filter = "(objectClass=frItixCategory)"; |
||||
|
NamingEnumeration results; |
||||
|
|
||||
|
// The document
|
||||
|
List<DeweyCategory> categories = new ArrayList<DeweyCategory>(); |
||||
|
|
||||
|
try { |
||||
|
results = dctx.search(base, filter, sc); |
||||
|
while (results.hasMore()) { |
||||
|
SearchResult sr = (SearchResult) results.next(); |
||||
|
categories.add(new DeweyCategory(sr)); |
||||
|
} |
||||
|
} catch (NamingException ex) { |
||||
|
ex.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return categories; |
||||
|
} |
||||
|
|
||||
|
throw new RuntimeException("Not implemented"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,177 @@ |
|||||
|
/* |
||||
|
* BookshelfDocumentTest.java |
||||
|
* JUnit based test |
||||
|
* |
||||
|
* Created on November 5, 2006, 9:16 PM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import junit.framework.*; |
||||
|
import java.util.*; |
||||
|
import javax.naming.*; |
||||
|
import javax.naming.directory.*; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Asserts the behavior of the class BookshelfDocument |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public class BookshelfDocumentTest extends TestCase { |
||||
|
private DirContext dctx; |
||||
|
|
||||
|
/** |
||||
|
* Creates a new test suite |
||||
|
*/ |
||||
|
public BookshelfDocumentTest(String testName) { |
||||
|
super(testName); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Establishes the connection to the LDAP server. |
||||
|
*/ |
||||
|
protected void setUp() throws Exception { |
||||
|
//Create a Hashtable object to place environment settings
|
||||
|
Hashtable env = new Hashtable(); |
||||
|
|
||||
|
//Specify service provider class
|
||||
|
String sp = "com.sun.jndi.ldap.LdapCtxFactory"; |
||||
|
env.put(Context.INITIAL_CONTEXT_FACTORY, sp); |
||||
|
|
||||
|
//Specify location of LDAP directory service
|
||||
|
String jndiUrl = "ldap://localhost:389/dc=bookshelf,dc=itix,dc=fr"; |
||||
|
env.put(Context.PROVIDER_URL,jndiUrl); |
||||
|
|
||||
|
//Specify an user and password
|
||||
|
String user = "cn=Manager,dc=bookshelf,dc=itix,dc=fr"; |
||||
|
String pwd = "secret"; |
||||
|
|
||||
|
//Set the authentication type
|
||||
|
env.put(Context.SECURITY_AUTHENTICATION, "simple"); |
||||
|
|
||||
|
//Set username and password
|
||||
|
env.put(Context.SECURITY_PRINCIPAL, user); |
||||
|
env.put(Context.SECURITY_CREDENTIALS, pwd); |
||||
|
|
||||
|
dctx = new InitialDirContext(env); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Closes the connection to the LDAP server |
||||
|
*/ |
||||
|
protected void tearDown() throws Exception { |
||||
|
dctx.close(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Test if a document can be constructed from an LDAP search. |
||||
|
*/ |
||||
|
public void testConstructDocument() throws Exception { |
||||
|
//Set search base
|
||||
|
String base = ""; |
||||
|
|
||||
|
//Set attribute filter and search scope
|
||||
|
SearchControls sc = new SearchControls(); |
||||
|
String[] attributeFilter = {"frItixGlobalId", "frItixTitle"}; |
||||
|
sc.setReturningAttributes(attributeFilter); |
||||
|
sc.setSearchScope(SearchControls.SUBTREE_SCOPE); |
||||
|
|
||||
|
//Define filter
|
||||
|
String filter = "(frItixTitle=*SELinux*)"; |
||||
|
|
||||
|
//Perform search
|
||||
|
NamingEnumeration results = dctx.search(base, filter, sc); |
||||
|
|
||||
|
//results
|
||||
|
while (results.hasMore()) { |
||||
|
SearchResult sr = (SearchResult)results.next(); |
||||
|
BookshelfDocument d = new BookshelfDocument(sr); |
||||
|
d.toString(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Tests a failing construtor (frItixTitle missing). |
||||
|
*/ |
||||
|
public void testConstructDocument2() throws Exception { |
||||
|
//Set search base
|
||||
|
String base = ""; |
||||
|
|
||||
|
//Set attribute filter and search scope
|
||||
|
SearchControls sc = new SearchControls(); |
||||
|
String[] attributeFilter = {"frItixGlobalId"}; |
||||
|
sc.setReturningAttributes(attributeFilter); |
||||
|
sc.setSearchScope(SearchControls.SUBTREE_SCOPE); |
||||
|
|
||||
|
//Define filter
|
||||
|
String filter = "(frItixTitle=*SELinux*)"; |
||||
|
|
||||
|
//Perform search
|
||||
|
NamingEnumeration results = dctx.search(base, filter, sc); |
||||
|
|
||||
|
//results
|
||||
|
while (results.hasMore()) { |
||||
|
SearchResult sr = (SearchResult)results.next(); |
||||
|
try { |
||||
|
BookshelfDocument d = new BookshelfDocument(sr); |
||||
|
fail("Should throw a RuntimeException"); |
||||
|
} catch (RuntimeException expected) { |
||||
|
// Normal behavior
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Tests a failing construtor (frItixGlobalId missing). |
||||
|
*/ |
||||
|
public void testConstructDocument3() throws Exception { |
||||
|
//Set search base
|
||||
|
String base = ""; |
||||
|
|
||||
|
//Set attribute filter and search scope
|
||||
|
SearchControls sc = new SearchControls(); |
||||
|
String[] attributeFilter = {"frItixTitle"}; |
||||
|
sc.setReturningAttributes(attributeFilter); |
||||
|
sc.setSearchScope(SearchControls.SUBTREE_SCOPE); |
||||
|
|
||||
|
//Define filter
|
||||
|
String filter = "(frItixTitle=*SELinux*)"; |
||||
|
|
||||
|
//Perform search
|
||||
|
NamingEnumeration results = dctx.search(base, filter, sc); |
||||
|
|
||||
|
//results
|
||||
|
while (results.hasMore()) { |
||||
|
SearchResult sr = (SearchResult)results.next(); |
||||
|
try { |
||||
|
BookshelfDocument d = new BookshelfDocument(sr); |
||||
|
fail("Should throw a RuntimeException"); |
||||
|
} catch (RuntimeException expected) { |
||||
|
// Normal behavior
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,102 @@ |
|||||
|
/* |
||||
|
* IsbnTest.java |
||||
|
* JUnit based test |
||||
|
* |
||||
|
* Created on November 19, 2006, 10:10 AM |
||||
|
* |
||||
|
* |
||||
|
* Bookshelf - Manage a virtual bookshelf |
||||
|
* |
||||
|
* Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
* |
||||
|
* This program is free software; you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation; either version 2 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
* for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
*/ |
||||
|
|
||||
|
package fr.itix.bookshelf; |
||||
|
|
||||
|
import junit.framework.*; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
*/ |
||||
|
public class IsbnTest extends TestCase { |
||||
|
|
||||
|
public IsbnTest(String testName) { |
||||
|
super(testName); |
||||
|
} |
||||
|
|
||||
|
public void testConstructor() { |
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn(""); |
||||
|
this.fail("no exception thrown on empty ISBN"); |
||||
|
} catch (IllegalArgumentException ignored) { |
||||
|
// normal behavior
|
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("0306406152"); |
||||
|
} catch (Exception e) { |
||||
|
this.fail("Exception thrown on valid ISBN - 1 [" + e + "]"); |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("0-306-40615-2"); |
||||
|
} catch (Exception e) { |
||||
|
this.fail("Exception thrown on valid ISBN - 2 [" + e + "]"); |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn(" 0 306 40615 2 "); |
||||
|
} catch (Exception e) { |
||||
|
this.fail("Exception thrown on valid ISBN - 3 [" + e + "]"); |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("123456789012345"); |
||||
|
this.fail("no exception thrown on too long ISBN (15)"); |
||||
|
} catch (IllegalArgumentException ignored) { |
||||
|
// normal behavior
|
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("123456789012"); |
||||
|
this.fail("no exception thrown on bad ISBN (12 chars)"); |
||||
|
} catch (IllegalArgumentException ignored) { |
||||
|
// normal behavior
|
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("12345678"); |
||||
|
this.fail("no exception thrown on too short ISBN (8)"); |
||||
|
} catch (IllegalArgumentException ignored) { |
||||
|
// normal behavior
|
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
Isbn i = Isbn.newIsbn("978-0-356-42615-0"); |
||||
|
} catch (Exception e) { |
||||
|
this.fail("Exception thrown on valid ISBN13 - [" + e + "]"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected void setUp() throws Exception { |
||||
|
} |
||||
|
|
||||
|
protected void tearDown() throws Exception { |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<Context path="/bookshelf"/> |
||||
@ -0,0 +1,17 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
|
||||
|
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" |
||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" |
||||
|
version="2.4"> |
||||
|
<session-config> |
||||
|
<session-timeout> |
||||
|
30 |
||||
|
</session-timeout> |
||||
|
</session-config> |
||||
|
<welcome-file-list> |
||||
|
<welcome-file> |
||||
|
index.jsp |
||||
|
</welcome-file> |
||||
|
</welcome-file-list> |
||||
|
</web-app> |
||||
@ -0,0 +1,36 @@ |
|||||
|
<%@page contentType="text/html"%> |
||||
|
<%@page pageEncoding="UTF-8"%> |
||||
|
<%-- |
||||
|
Bookshelf - Manage a virtual bookshelf |
||||
|
|
||||
|
Copyright (C) 2006 Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
|
||||
|
This program is free software; you can redistribute it and/or modify it |
||||
|
under the terms of the GNU General Public License as published by the |
||||
|
Free Software Foundation; either version 2 of the License, or (at your |
||||
|
option) any later version. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, but |
||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
|
for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License along |
||||
|
with this program; if not, write to the Free Software Foundation, Inc., |
||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
--%> |
||||
|
|
||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
||||
|
"http://www.w3.org/TR/html4/loose.dtd"> |
||||
|
|
||||
|
<html> |
||||
|
<head> |
||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
|
<title>JSP Page</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
|
||||
|
<h1>JSP Page</h1> |
||||
|
|
||||
|
</body> |
||||
|
</html> |
||||
File diff suppressed because it is too large
@ -0,0 +1,50 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
base="dc=bookshelf,dc=itix,dc=fr" |
||||
|
|
||||
|
echo "Extracting level 1..." |
||||
|
egrep '^[0-9]00 ' dewey.txt > dewey1.txt |
||||
|
echo "Extracting level 2..." |
||||
|
egrep '^[0-9][0-9]0 ' dewey.txt > dewey2.txt |
||||
|
echo "Extracting level 3..." |
||||
|
egrep '^[0-9][0-9][1-9] ' dewey.txt > dewey3.txt |
||||
|
|
||||
|
n=$(wc -l < dewey.txt) |
||||
|
n1=$(wc -l < dewey1.txt) |
||||
|
n2=$(wc -l < dewey2.txt) |
||||
|
n3=$(wc -l < dewey3.txt) |
||||
|
|
||||
|
sum=$(($n1 + $n2 + $n3)) |
||||
|
|
||||
|
echo "original: $n" |
||||
|
echo "dewey1/2/3: $n1/$n2/$n3" |
||||
|
echo "sum: $sum" |
||||
|
|
||||
|
echo "Generating LDAP, level 1..." |
||||
|
|
||||
|
sed -r "s/([0-9][0-9][0-9]) (.*)/dn: frItixCategoryId=\\1,$base\\ |
||||
|
frItixCategoryId: \\1\\ |
||||
|
frItixCategoryName: \\2\\ |
||||
|
objectClass: frItixCategory\\ |
||||
|
/" dewey1.txt > dewey1.ldif |
||||
|
|
||||
|
|
||||
|
|
||||
|
echo "Generating LDAP, level 2..." |
||||
|
|
||||
|
sed -r "s/(([0-9])[0-9][0-9]) (.*)/dn: frItixCategoryId=\\1,frItixCategoryId=\\200,$base\\ |
||||
|
frItixCategoryId: \\1\\ |
||||
|
frItixCategoryName: \\3\\ |
||||
|
objectClass: frItixCategory\\ |
||||
|
/" dewey2.txt > dewey2.ldif |
||||
|
|
||||
|
|
||||
|
|
||||
|
echo "Generating LDAP, level 3..." |
||||
|
|
||||
|
sed -r "s/((([0-9])[0-9])[0-9]) (.*)/dn: frItixCategoryId=\\1,frItixCategoryId=\\20,frItixCategoryId=\\300,$base\\ |
||||
|
frItixCategoryId: \\1\\ |
||||
|
frItixCategoryName: \\4\\ |
||||
|
objectClass: frItixCategory\\ |
||||
|
/" dewey3.txt > dewey3.ldif |
||||
|
|
||||
@ -0,0 +1,114 @@ |
|||||
|
attributeType ( 1.3.6.1.4.14000.1.1.6 NAME 'frItixId' |
||||
|
DESC 'An abstract type which represents an ID' |
||||
|
EQUALITY integerMatch |
||||
|
ORDERING integerOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.1 NAME 'frItixNextLocalDocumentId' |
||||
|
DESC 'The next available localDocumentId in a bookshelf' |
||||
|
SUP frItixId |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.2 NAME 'frItixNextGlobalId' |
||||
|
DESC 'The next available globalId in a bookshelf' |
||||
|
SUP frItixId |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.3 NAME 'frItixGlobalId' |
||||
|
DESC 'A globalId identifies a document within a bookshelf' |
||||
|
SUP frItixId |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.4 NAME 'frItixTitle' |
||||
|
DESC 'The title of a document' |
||||
|
SUP name |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.5 NAME 'frItixAuthor' |
||||
|
DESC 'The author of a document' |
||||
|
SUP cn ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.7 NAME 'frItixCollection' |
||||
|
DESC 'The name of the collection of the book' |
||||
|
SUP name |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.8 NAME 'frItixPublisherName' |
||||
|
DESC 'The name of the publisher of the book' |
||||
|
SUP name |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.9 NAME 'frItixPages' |
||||
|
DESC 'The number of pages in the book' |
||||
|
EQUALITY integerMatch |
||||
|
ORDERING integerOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.10 NAME 'frItixEditionNumber' |
||||
|
DESC 'The edition number of the book (1st, 2nd, etc.)' |
||||
|
EQUALITY integerMatch |
||||
|
ORDERING integerOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.11 NAME ( 'frItixISBN' 'frItixISBN10' ) |
||||
|
DESC 'The International Standard Book Number (10) of a book' |
||||
|
EQUALITY caseIgnoreMatch |
||||
|
ORDERING caseIgnoreOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{10} |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.12 NAME 'frItixISBN13' |
||||
|
DESC 'The International Standard Book Number (13) of a book' |
||||
|
EQUALITY caseIgnoreMatch |
||||
|
ORDERING caseIgnoreOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{13} |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.13 NAME 'frItixPublicationDate' |
||||
|
DESC 'The publication date of the book' |
||||
|
EQUALITY integerMatch |
||||
|
ORDERING integerOrderingMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.14 NAME ( 'frItixCategoryId' ) |
||||
|
DESC 'The Dewey category number' |
||||
|
EQUALITY caseExactMatch |
||||
|
ORDERING caseExactOrderingMatch |
||||
|
SUBSTR caseExactSubstringsMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
attributeType ( 1.3.6.1.4.14000.1.1.15 NAME ( 'frItixCategoryName' ) |
||||
|
DESC 'The Dewey category name' |
||||
|
EQUALITY caseIgnoreMatch |
||||
|
ORDERING caseIgnoreOrderingMatch |
||||
|
SUBSTR caseIgnoreSubstringsMatch |
||||
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 |
||||
|
SINGLE-VALUE ) |
||||
|
|
||||
|
objectClass ( 1.3.6.1.4.14000.1.3.1 NAME 'frItixBookshelf' |
||||
|
DESC 'A bookshelf' |
||||
|
SUP top |
||||
|
MUST ( frItixNextLocalDocumentId $ frItixNextGlobalId ) ) |
||||
|
|
||||
|
objectClass ( 1.3.6.1.4.14000.1.3.2 NAME 'frItixDocument' |
||||
|
DESC 'A document' |
||||
|
SUP top |
||||
|
ABSTRACT |
||||
|
MUST ( frItixGlobalId $ frItixTitle ) |
||||
|
MAY ( frItixAuthor $ organizationName ) ) |
||||
|
|
||||
|
objectClass ( 1.3.6.1.4.14000.1.3.3 NAME 'frItixBook' |
||||
|
DESC 'A book' |
||||
|
SUP frItixDocument |
||||
|
MAY ( frItixCollection $ frItixPublisherName $ frItixPublicationDate $ frItixPages $ frItixEditionNumber $ frItixISBN10 $ frItixISBN13 ) ) |
||||
|
|
||||
|
|
||||
|
objectClass ( 1.3.6.1.4.14000.1.3.4 NAME 'frItixCategory' |
||||
|
DESC 'A Dewey Category' |
||||
|
SUP top |
||||
|
MUST ( frItixCategoryId $ frItixCategoryName ) ) |
||||
|
|
||||
@ -0,0 +1,16 @@ |
|||||
|
include /etc/openldap/schema/core.schema |
||||
|
include /etc/openldap/schema/cosine.schema |
||||
|
include /etc/openldap/schema/inetorgperson.schema |
||||
|
include /etc/openldap/schema/bookshelf.schema |
||||
|
|
||||
|
|
||||
|
pidfile /var/run/openldap/slapd.pid |
||||
|
argsfile /var/run/openldap/slapd.args |
||||
|
|
||||
|
database bdb |
||||
|
suffix "dc=bookshelf,dc=itix,dc=fr" |
||||
|
rootdn "cn=Manager,dc=bookshelf,dc=itix,dc=fr" |
||||
|
rootpw secret |
||||
|
checkpoint 32 30 # <kbyte> <min> |
||||
|
directory /var/lib/openldap-data |
||||
|
index objectClass eq |
||||
Loading…
Reference in new issue