@@ -1,12 +1,5 @@ |
<?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.) --> |
-<!-- By default, only the Clean and Build commands use this build script. --> |
-<!-- Commands such as Run, Debug, and Test only use this build script if --> |
-<!-- the Compile on Save feature is turned off for the project. --> |
-<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> |
-<!-- in the project's Project Properties dialog box.--> |
+ |
<project name="csip-weps-dataHandler" default="default" basedir="." |
xmlns:if="ant:if" |
xmlns:unless="ant:unless" |
@@ -15,64 +8,6 @@ |
<import file="nbproject/build-impl.xml"/> |
|
<taskdef resource="net/sf/antcontrib/antlib.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 archive building |
- -post-dist: called after archive 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: 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. |
- |
- --> |
|
|
<!-- |
@@ -107,13 +42,29 @@ |
<fileset dir="${csip.wepsd.dataFiles.root.path}/bin" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/cfg" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/db" includes="**/*" /> |
+ <fileset dir="${csip.wepsd.dataFiles.root.path}/NRCS" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/help" includes="**/*" /> |
+ <fileset dir="${csip.wepsd.dataFiles.root.path}/readme" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/images" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/mcrew_cfg" includes="**/*" /> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/tables" includes="**/*" /> |
+ <fileset dir="${csip.wepsd.dataFiles.root.path}/certs" includes="**/*" /> |
+ <fileset dir="${csip.wepsd.dataFiles.root.path}/wmrm" includes="**/*" /> |
</delete> |
</target> |
|
+ |
+ <!-- |
+ ** post Dist section |
+ ** make an export jar of just the support class for other endpoints to use as an include |
+ --> |
+ <target name="-pre-dist"> |
+ <property name="csip.wepsd.sharedClass.name" value="WepsModelDataService" /> |
+ <jar destfile="${dist.dir}/${csip.wepsd.sharedClass.name}.jar" |
+ basedir="${build.classes.dir}" |
+ includes="**/${csip.wepsd.sharedClass.name}.class" |
+ /> |
+ </target> |
|
|
|
@@ -123,7 +74,6 @@ |
** Set with the csip.wepsd.dataFiles.src.path property in project.properties file. |
--> |
<target name="-csip-wepsd-getDataFiles" depends="-csip-wepsd-uptodate" if="csip.wepsd.dataSrc.outofdate"> |
- <echo>more nothing</echo> |
<if> <istrue value="${csip.wepsd.dataSrc.outofdate.bin}"/> |
<then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="bin"/> </then> |
</if> |
@@ -131,11 +81,22 @@ |
<then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="cfg"/> </then> |
</if> |
<if> <istrue value="${csip.wepsd.dataSrc.outofdate.db}"/> |
- <then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="db"/> </then> |
+ <then> |
+ <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="db"/> |
+ <antcall target="-csip-wepsd-makeNRCSDir"/> |
+ </then> |
+ </if> |
+ <if> <istrue value="${csip.wepsd.dataSrc.outofdate.NRCS}"/> |
+ <then> |
+ <antcall target="-csip-wepsd-makeNRCSDir"/> |
+ </then> |
</if> |
<if> <istrue value="${csip.wepsd.dataSrc.outofdate.help}"/> |
<then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="help"/> </then> |
</if> |
+ <if> <istrue value="${csip.wepsd.dataSrc.outofdate.readme}"/> |
+ <then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="readme"/> </then> |
+ </if> |
<if> <istrue value="${csip.wepsd.dataSrc.outofdate.images}"/> |
<then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="images"/> </then> |
</if> |
@@ -145,8 +106,63 @@ |
<if> <istrue value="${csip.wepsd.dataSrc.outofdate.tables}"/> |
<then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="tables"/> </then> |
</if> |
- <echo>more nothing</echo> |
+ <if> <istrue value="${csip.wepsd.dataSrc.outofdate.certs}"/> |
+ <then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="certs"/> </then> |
+ </if> |
+ <if> <istrue value="${csip.wepsd.dataSrc.outofdate.wmrm}"/> |
+ <then> <weps-wsi-getDataFile-macro weps.wsi.getDataFile.datadir.name="wmrm"/> </then> |
+ </if> |
</target> |
+ |
+ |
+ |
+ <!-- |
+ ** Get the required data files |
+ ** Source is the weps install project in Netbeans. |
+ ** Set with the csip.wepsd.dataFiles.src.path property in project.properties file. |
+ --> |
+ <target name="-csip-wepsd-makeNRCSDir"> |
+ <echo>-csip-wepsd-makeNRCSDir copying db</echo> |
+ <copy todir="${csip.wepsd.dataFiles.root.path}/NRCS"> |
+ <fileset dir="${csip.wepsd.netbeans.dir}/${csip.wepsd.dataFiles.src.path}/db"> |
+ <exclude name="**/crops/**"/> |
+ <exclude name="**/man/**"/> |
+ <exclude name="**/operations/**"/> |
+ </fileset> |
+ </copy> |
+ |
+ <echo>-csip-wepsd-makeNRCSDir copying crops</echo> |
+ <copy todir="${csip.wepsd.dataFiles.root.path}/NRCS/crops" overwrite="true"> |
+ <fileset dir="${csip.wepsd.netbeans.dir}/${csip.wepsd.dataFiles.src.path}/db/crops/NRCS"> |
+ <include name="*.zip"/> |
+ </fileset> |
+ </copy> |
+ |
+ <echo>-csip-wepsd-makeNRCSDir copying man</echo> |
+ <copy todir="${csip.wepsd.dataFiles.root.path}/NRCS/man" overwrite="true"> |
+ <fileset dir="${csip.wepsd.netbeans.dir}/${csip.wepsd.dataFiles.src.path}/db/man/NRCS"> |
+ </fileset> |
+ </copy> |
+ |
+ <echo>-csip-wepsd-makeNRCSDir copying operations</echo> |
+ <copy todir="${csip.wepsd.dataFiles.root.path}/NRCS/operations" overwrite="true"> |
+ <fileset dir="${csip.wepsd.netbeans.dir}/${csip.wepsd.dataFiles.src.path}/db/operations/NRCS"> |
+ <include name="*.zip"/> |
+ </fileset> |
+ </copy> |
+ |
+ <echo>-csip-wepsd-makeNRCSDir zip</echo> |
+ <delete file="${csip.wepsd.dataFiles.root.path}/NRCS/NRCS.zip" failonerror="false"/> |
+ <zip destfile="${csip.wepsd.dataFiles.root.path}/NRCS/NRCS.zip" |
+ basedir="${csip.wepsd.dataFiles.root.path}/NRCS" /> |
+ <delete includeEmptyDirs="true"> |
+ <fileset dir="${csip.wepsd.dataFiles.root.path}/NRCS" includes="**/*" excludes="*.zip"/> |
+ </delete> |
+ |
+ <echo>-csip-wepsd-makeNRCSDir finished</echo> |
+ </target> |
+ |
+ |
|
<!-- |
** macro for doing the getDataFiles functions |
@@ -174,7 +190,7 @@ |
<macrodef name="weps-wsi-dirCopy-macro"> |
<attribute name="weps.wsi.dirCopy.datadir.name"/> |
<sequential> |
- <delete includeEmptyDirs="true"> |
+ <delete includeEmptyDirs="true" failonerror="false"> |
<fileset dir="${csip.wepsd.dataFiles.root.path}/@{weps.wsi.dirCopy.datadir.name}" includes="**/*"/> |
</delete> |
<copy todir="${csip.wepsd.dataFiles.root.path}/@{weps.wsi.dirCopy.datadir.name}" preservelastmodified="true"> |
@@ -300,9 +316,12 @@ |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="cfg"/> |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="db"/> |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="help"/> |
+ <weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="readme"/> |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="images"/> |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="mcrew_cfg"/> |
<weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="tables"/> |
+ <weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="certs"/> |
+ <weps-wsi-dirOutOfDate-macro weps.wsi.dirUptodate.datadir.name="wmrm"/> |
|
<condition property="csip.wepsd.dataSrc.outofdate"> |
<or> |
@@ -310,9 +329,12 @@ |
<istrue value="${csip.wepsd.dataSrc.outofdate.cfg}"/> |
<istrue value="${csip.wepsd.dataSrc.outofdate.db}"/> |
<istrue value="${csip.wepsd.dataSrc.outofdate.help}"/> |
+ <istrue value="${csip.wepsd.dataSrc.outofdate.readme}"/> |
<istrue value="${csip.wepsd.dataSrc.outofdate.images}"/> |
<istrue value="${csip.wepsd.dataSrc.outofdate.mcrew_cfg}"/> |
<istrue value="${csip.wepsd.dataSrc.outofdate.tables}"/> |
+ <istrue value="${csip.wepsd.dataSrc.outofdate.certs}"/> |
+ <istrue value="${csip.wepsd.dataSrc.outofdate.wmrm}"/> |
</or> |
</condition> |
|
@@ -359,9 +381,9 @@ |
</if> |
</then> |
<else> |
- <!-- Create the dir and set as outofdate --> |
+ <!-- not available, Create the dir and set as outofdate --> |
<property name="weps.wsi.dirOutOfDate.macro.retval" value="true"/> |
- <mkdir dir="@{weps.wsi.dirUptodate.dataFiles.path}"/> |
+ <mkdir dir="${csip.wepsd.dataFiles.root.path}/@{weps.wsi.dirUptodate.datadir.name}"/> |
</else> |
</if> |
|
@@ -1,24 +1,10 @@ |
-/* |
- * To change this license header, choose License Headers in Project Properties. |
- * To change this template packageResourceFile, choose Tools | Templates |
- * and open the template in the editor. |
- */ |
+ |
package d.dataHandler; |
|
-import csip.Config; |
-import csip.ModelDataService; |
+import CSIP.weps.dataHandler.support.WepsModelDataService; |
import csip.annotations.*; |
-import csip.utils.Binaries; |
-import static csip.utils.Binaries.resolve; |
-import java.io.File; |
-import java.io.IOException; |
-import java.nio.file.DirectoryIteratorException; |
-import java.nio.file.DirectoryStream; |
-import java.nio.file.Files; |
-import static java.nio.file.StandardCopyOption.*; |
import oms3.annotations.*; |
import javax.ws.rs.*; |
-import org.codehaus.jettison.json.JSONObject; |
|
/** |
* WEPS-DataHandler This implements the CSIP WEPS DATA service. |
@@ -32,172 +18,21 @@ |
@Resource(file = "/d/downloadData/bin/bin.zip", id = "binID", type = ResourceType.ARCHIVE), |
@Resource(file = "/d/downloadData/cfg/cfg.zip", id = "cfgID", type = ResourceType.ARCHIVE), |
@Resource(file = "/d/downloadData/db/db.zip", id = "dbID", type = ResourceType.ARCHIVE), |
+ @Resource(file = "/d/downloadData/NRCS/NRCS.zip", id = "NRCSID", type = ResourceType.ARCHIVE), |
@Resource(file = "/d/downloadData/help/help.zip", id = "helpID", type = ResourceType.ARCHIVE), |
+ @Resource(file = "/d/downloadData/readme/readme.zip", id = "readmeID", type = ResourceType.ARCHIVE), |
@Resource(file = "/d/downloadData/images/images.zip", id = "imagesID", type = ResourceType.ARCHIVE), |
@Resource(file = "/d/downloadData/mcrew_cfg/mcrew_cfg.zip", id = "mcrew_cfgID", type = ResourceType.ARCHIVE), |
- @Resource(file = "/d/downloadData/tables/tables.zip", id = "tablesID", type = ResourceType.ARCHIVE) |
+ @Resource(file = "/d/downloadData/tables/tables.zip", id = "tablesID", type = ResourceType.ARCHIVE), |
+ @Resource(file = "/d/downloadData/certs/certs.zip", id = "certsID", type = ResourceType.ARCHIVE), |
+ @Resource(file = "/d/downloadData/wmrm/wmrm.zip", id = "wmrmID", type = ResourceType.ARCHIVE) |
}) |
-public class V1_0 extends ModelDataService { |
+public class V1_0 extends WepsModelDataService { |
|
- protected String csipDirName; |
- protected String version; |
- |
- /** |
- * |
- * @throws Exception |
- */ |
- @Override |
- protected void doProcess() throws Exception { |
- |
- csipDirName = Config.getString("csip.dir"); |
- version = getClass().getAnnotation(Name.class).value()+":"+"v000.01"; |
- |
- String parmRequestType = getStringParam("requestType", ""); |
- switch (parmRequestType) { |
- case ("getVersion"): |
- doGetVersion(); |
- break; |
- case ("listAllPackages"): |
- doListAllPackages(); |
- break; |
- case ("listAllFiles"): |
- doListAllFiles(); |
- break; |
- case ("listPackageFiles"): |
- doListPackageFiles(getStringParam("packageName", "")); |
- break; |
- case ("getPackageZip"): |
- doGetPackageZip(getStringParam("packageName", "")); |
- break; |
- case ("getPackageFile"): |
- doGetPackageFile(getStringParam("packageName", ""), getStringParam("fileName", "")); |
- break; |
- case ("getFile"): |
- doGetFile(getStringParam("fileName", "")); |
- break; |
- default: |
- putResult("Error", "Unknown requesttype"); |
- putResult("Failing parameter", "requesttype"); |
- putResult("Failing requesttype", parmRequestType); |
- break; |
- } |
- getMetainfo().put("CSIP-Weps-Data.version", version); |
- |
+ public V1_0 () { |
+ super(); |
+ version = "CSIP DataHandler: v 0.0.2n"; |
} |
- |
- |
- protected void doGetVersion() throws Exception { |
- putResult("version", version); |
- putResult("destDir", "dataHandler"); |
- } |
- |
- protected void doListPackageFiles(String packageName) throws Exception { |
- |
- iterateDir (getResourceFile(packageName + "ID").getParentFile().toPath(), ""); |
- } |
- |
- protected void doGetPackageZip(String packageName) throws Exception { |
- Resource resource; |
- String fileName; |
- |
- resource = Binaries.getResourceById(getClass(), packageName + "ID"); |
- fileName = resolve(resource.file()).substring(1); |
- |
- getFile (fileName, true); |
- } |
- |
- protected void doGetFile(String fileName) throws Exception { |
- getFile (fileName, true); |
- } |
- |
- protected void doGetPackageFile(String packageName, String fileName) throws Exception { |
- Resource resource; |
- String packageBaseStr; |
- |
- resource = Binaries.getResourceById(getClass(), packageName + "ID"); |
- packageBaseStr = new File(resolve(resource.file())).getParent().substring(1); |
- |
- getFile (packageBaseStr + "/" + fileName, true); |
- } |
- |
- |
- protected void doListAllPackages() throws Exception { |
- |
- Resource[] resources = Binaries.getMergedResources(getClass()); |
- |
- for (Resource resource : resources) { |
- File file = new File(resource.file()); |
- putResult("Package", new JSONObject().put("Name",file.getParentFile().getName()) |
- .put("FileName",file.getName()) |
- ); |
- } |
- } |
- |
- protected void doListAllFiles() throws Exception { |
- |
- Resource[] resources = Binaries.getMergedResources(getClass()); |
- java.nio.file.Path csipDirPath = new File (csipDirName).toPath(); |
- |
- for (Resource resource : resources) { |
- File packageResourceFile = new File(resource.file()); |
- if (resource.file().endsWith(".zip")) { |
- iterateDir (csipDirPath, packageResourceFile.getParent().substring(1) + "/"); //Skip the leading slash to make this a "relative" path |
- } else { |
- putResult("fileName", packageResourceFile.toString().replace('\\', '/')); |
- } |
- } |
- |
- } |
- |
- protected void iterateDir (java.nio.file.Path basePath, String newPath) { |
- java.nio.file.Path path = basePath.resolve(newPath); |
- try (DirectoryStream<java.nio.file.Path> dirStream = Files.newDirectoryStream(path, "*")) { |
- for (java.nio.file.Path entry: dirStream) { |
- File file = entry.toFile(); |
- if (file.isDirectory()) { |
- iterateDir (basePath, newPath + entry.getFileName().toString() + "/"); |
- } else { |
- putResult("fileName", (newPath + entry.getFileName().toString()).replace('\\', '/')); |
- } |
- } |
- } catch (DirectoryIteratorException | IOException ex) { |
- // I/O error encounted during the iteration, the cause is an IOException |
- // Skip : do nothing |
- } |
- |
- } |
- |
-/* |
|
- protected void doGetFiles() throws Exception { |
- String fileIDstr; |
- String[] parmFileNames = getStringArrayParam("fileNames"); |
- |
- for (String fileName : parmFileNames) { |
- fileIDstr = findFileID (fileName); |
- if (fileIDstr != null) { |
- getFile (fileIDstr, true); |
- } |
- } |
- } |
- |
- */ |
- |
- protected void getFile (String srcFileName, boolean toResult) throws Exception { |
- File srcFile; |
- java.nio.file.Path srcPath; |
- java.nio.file.Path resFilePath; |
- |
- srcFile = new File (csipDirName + "/" + srcFileName); |
- srcPath = srcFile.toPath(); |
- resFilePath = getWorkspaceDir().toPath().resolve(srcFile.getName()); |
- |
- Files.copy (srcPath, resFilePath, REPLACE_EXISTING); |
- |
- if (toResult) { |
- putResult(resFilePath.toFile()); |
- } |
- } |
- |
} |
|