diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..98445261 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +**/target/ +docs/ +Dockerfile +Dockerfile-alpine +NOTICE +LICENSE +README.md +.travis.yml + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d2199d18 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,64 @@ +FROM maven:3-jdk-8-alpine AS BUILD + +RUN apk add --no-cache git + +WORKDIR /usr/src/app + +COPY . /usr/src/app + +RUN mvn --batch-mode --errors --fail-fast \ + --define maven.javadoc.skip=true \ + --define skipTests=true install + +FROM jetty:jre8 + +ARG JAVAPS_VERSION=1.3.0-SNAPSHOT +ENV JAVAPS_VERSION ${JAVAPS_VERSION} +ENV JAVAPS_ROOT ${JETTY_BASE}/webapps/ROOT +ENV JAVAPS_TMP ${JAVAPS_ROOT}/WEB-INF/tmp +ENV JAVAPS_CONFIG ${JAVAPS_ROOT}/WEB-INF/config +ENV JAVAPS_LIB ${JAVAPS_ROOT}/WEB-INF/lib + +COPY --from=BUILD /usr/src/app/webapp/target/javaPS-webapp-${JAVAPS_VERSION}/ /var/lib/jetty/webapps/ROOT +COPY etc/docker-log4j2.xml /var/lib/jetty/webapps/ROOT/WEB-INF/config/log4j2.xml +COPY etc/docker-configuration.json /var/lib/jetty/webapps/ROOT/WEB-INF/config/configuration.json + +USER root +RUN set -ex \ + && apt-get update \ + && apt-get install -y --no-install-recommends jq \ + && rm -rf /var/lib/apt/lists/* \ + && wget -q -P /usr/local/bin https://raw.githubusercontent.com/52North/arctic-sea/master/etc/faroe-entrypoint.sh \ + && chmod +x /usr/local/bin/faroe-entrypoint.sh \ + && ln -sf ${JAVAPS_CONFIG}/log4j2.xml ${JAVAPS_ROOT}/WEB-INF/classes/log4j2.xml \ + && mkdir -p ${JAVAPS_TMP}\ + && chown -R jetty:jetty ${JAVAPS_ROOT} +USER jetty + +VOLUME /var/lib/jetty/webapps/ROOT/WEB-INF/tmp +VOLUME /var/lib/jetty/webapps/ROOT/WEB-INF/config + +HEALTHCHECK --interval=5s --timeout=20s --retries=3 \ + CMD wget 'http://localhost:8080/service?service=WPS&request=GetCapabilities' -q -O - > /dev/null 2>&1 + +ENV FAROE_CONFIGURATION ${JAVAPS_CONFIG}/configuration.json + +LABEL maintainer="Benjamin Proß " \ + org.opencontainers.image.title="52°North javaPS" \ + org.opencontainers.image.description="Next generation standardized web-based geo-processing" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.url="https://github.com/52North/javaPS" \ + org.opencontainers.image.vendor="52°North GmbH" \ + org.opencontainers.image.source="https://github.com/52north/javaPS.git" \ + org.opencontainers.image.documentation="https://github.com/52North/javaPS/blob/develop/README.md" \ + org.opencontainers.image.version="${JAVAPS_VERSION}" \ + org.opencontainers.image.authors="Benjamin Proß , Christian Autermann " + +ARG GIT_COMMIT +LABEL org.opencontainers.image.revision "${GIT_COMMIT}" + +ARG BUILD_DATE +LABEL org.opencontainers.image.created "${BUILD_DATE}" + +CMD [ "java", "-jar", "/usr/local/jetty/start.jar" ] +ENTRYPOINT [ "/usr/local/bin/faroe-entrypoint.sh", "/docker-entrypoint.sh" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f082271e --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (C) 2013 by 52 North Initiative for Geospatial Open + Source Software GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index d0af96c3..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,194 +0,0 @@ -Apache License -============== - -_Version 2.0, January 2004_ -_<>_ - -### Terms and Conditions for use, reproduction, and distribution - -#### 1. Definitions - -“License” shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -“Licensor” shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -“Legal Entity” shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, “control” means **(i)** the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the -outstanding shares, or **(iii)** beneficial ownership of such entity. - -“You” (or “Your”) shall mean an individual or Legal Entity exercising -permissions granted by this License. - -“Source” form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -“Object” form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -“Work” shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -“Derivative Works” shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -“Contribution” shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -“submitted” means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as “Not a Contribution.” - -“Contributor” shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -#### 2. Grant of Copyright License - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -#### 3. Grant of Patent License - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -#### 4. Redistribution - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -* **(a)** You must give any other recipients of the Work or Derivative Works a copy of -this License; and -* **(b)** You must cause any modified files to carry prominent notices stating that You -changed the files; and -* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. - -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -#### 5. Submission of Contributions - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -#### 6. Trademarks - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -#### 7. Disclaimer of Warranty - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -#### 8. Limitation of Liability - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -#### 9. Accepting Warranty or Additional Liability - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -_END OF TERMS AND CONDITIONS_ - -### APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets `[]` replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same “printed page” as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/NOTICE b/NOTICE index 07a1c30d..08ffb064 100644 --- a/NOTICE +++ b/NOTICE @@ -1,20 +1,17 @@ -Copyright (C) 2015 52°North Initiative for Geospatial Open Source -Software GmbH +Licensed under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at: -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. This project includes: - 52°North Faroe under The Apache Software License, Version 2.0 52°North Faroe Annotations under The Apache Software License, Version 2.0 52°North Faroe JSON Backend under The Apache Software License, Version 2.0 @@ -33,6 +30,7 @@ This project includes: Animal Sniffer Annotations under MIT license Apache Commons Codec under Apache License, Version 2.0 Apache Commons Configuration under Apache License, Version 2.0 + Apache Commons IO under Apache License, Version 2.0 Apache Commons Lang under Apache License, Version 2.0 Apache Commons Logging under The Apache Software License, Version 2.0 Apache HttpClient under Apache License, Version 2.0 diff --git a/README.md b/README.md index 8da2cc0a..53febf0e 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Try out the latest javaPS alpha-release on on our [Geoprocessing Demo Server](ht ## References -* [WPS for Coordinate Transformation](http://ows.dev.52north.org:8080/javaps/service?request=GetCapabilities&service=WPS) - WPS service deployed for the Testbed-13 project. +* [WPS for Tsunami Simulation](http://tsunami-riesgos.awi.de:8080/javaps/service?request=GetCapabilities&service=WPS) - WPS service deployed in the RIESGOS project. ## Contact diff --git a/alpine.Dockerfile b/alpine.Dockerfile new file mode 100644 index 00000000..962355c3 --- /dev/null +++ b/alpine.Dockerfile @@ -0,0 +1,62 @@ +FROM maven:3-jdk-8-alpine AS BUILD + +RUN apk add --no-cache git + +WORKDIR /usr/src/app + +COPY . /usr/src/app + +RUN mvn --batch-mode --errors --fail-fast \ + --define maven.javadoc.skip=true \ + --define skipTests=true install + +FROM jetty:jre8-alpine + +ARG JAVAPS_VERSION=1.3.0-SNAPSHOT +ENV JAVAPS_VERSION ${JAVAPS_VERSION} +ENV JAVAPS_ROOT ${JETTY_BASE}/webapps/ROOT +ENV JAVAPS_TMP ${JAVAPS_ROOT}/WEB-INF/tmp +ENV JAVAPS_CONFIG ${JAVAPS_ROOT}/WEB-INF/config +ENV JAVAPS_LIB ${JAVAPS_ROOT}/WEB-INF/lib + +COPY --from=BUILD /usr/src/app/webapp/target/javaPS-webapp-${JAVAPS_VERSION}/ /var/lib/jetty/webapps/ROOT +COPY etc/docker-log4j2.xml /var/lib/jetty/webapps/ROOT/WEB-INF/config/log4j2.xml +COPY etc/docker-configuration.json /var/lib/jetty/webapps/ROOT/WEB-INF/config/configuration.json + +USER root +RUN set -ex \ + && apk add --no-cache jq \ + && wget -q -P /usr/local/bin https://raw.githubusercontent.com/52North/arctic-sea/master/etc/faroe-entrypoint.sh \ + && chmod +x /usr/local/bin/faroe-entrypoint.sh \ + && ln -sf ${JAVAPS_CONFIG}/log4j2.xml ${JAVAPS_ROOT}/WEB-INF/classes/log4j2.xml \ + && mkdir -p ${JAVAPS_TMP}\ + && chown -R jetty:jetty ${JAVAPS_ROOT} +USER jetty + +VOLUME /var/lib/jetty/webapps/ROOT/WEB-INF/tmp +VOLUME /var/lib/jetty/webapps/ROOT/WEB-INF/config + +HEALTHCHECK --interval=5s --timeout=20s --retries=3 \ + CMD wget 'http://localhost:8080/service?service=WPS&request=GetCapabilities' -q -O - > /dev/null 2>&1 + +ENV FAROE_CONFIGURATION ${JAVAPS_CONFIG}/configuration.json + +LABEL maintainer="Benjamin Proß " \ + org.opencontainers.image.title="52°North javaPS" \ + org.opencontainers.image.description="Next generation standardized web-based geo-processing" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.url="https://github.com/52North/javaPS" \ + org.opencontainers.image.vendor="52°North GmbH" \ + org.opencontainers.image.source="https://github.com/52north/javaPS.git" \ + org.opencontainers.image.documentation="https://github.com/52North/javaPS/blob/develop/README.md" \ + org.opencontainers.image.version="${JAVAPS_VERSION}" \ + org.opencontainers.image.authors="Benjamin Proß , Christian Autermann " + +ARG GIT_COMMIT +LABEL org.opencontainers.image.revision "${GIT_COMMIT}" + +ARG BUILD_DATE +LABEL org.opencontainers.image.created "${BUILD_DATE}" + +CMD [ "java", "-jar", "/usr/local/jetty/start.jar" ] +ENTRYPOINT [ "/usr/local/bin/faroe-entrypoint.sh", "/docker-entrypoint.sh" ] diff --git a/engine/pom.xml b/engine/pom.xml index 41ad528d..a63eafbd 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -112,6 +112,10 @@ hamcrest-all test + + org.mockito + mockito-core + diff --git a/engine/src/main/java/org/n52/javaps/engine/JobIdGenerator.java b/engine/src/main/java/org/n52/javaps/engine/JobIdGenerator.java index 16555921..8629633f 100644 --- a/engine/src/main/java/org/n52/javaps/engine/JobIdGenerator.java +++ b/engine/src/main/java/org/n52/javaps/engine/JobIdGenerator.java @@ -16,12 +16,8 @@ */ package org.n52.javaps.engine; -import java.util.List; - -import org.n52.shetland.ogc.wps.JobId; -import org.n52.shetland.ogc.wps.OutputDefinition; import org.n52.javaps.algorithm.IAlgorithm; -import org.n52.javaps.algorithm.ProcessInputs; +import org.n52.shetland.ogc.wps.JobId; /** * TODO JavaDoc @@ -29,7 +25,5 @@ * @author Christian Autermann */ public interface JobIdGenerator { - JobId create(IAlgorithm algorithm, - ProcessInputs inputs, - List outputs); + JobId create(IAlgorithm algorithm); } diff --git a/engine/src/main/java/org/n52/javaps/engine/impl/EngineImpl.java b/engine/src/main/java/org/n52/javaps/engine/impl/EngineImpl.java index 6dd70de2..e68eac4a 100644 --- a/engine/src/main/java/org/n52/javaps/engine/impl/EngineImpl.java +++ b/engine/src/main/java/org/n52/javaps/engine/impl/EngineImpl.java @@ -160,8 +160,6 @@ public JobId execute(OwsCode identifier, IAlgorithm algorithm = getProcess(identifier); TypedProcessDescription description = algorithm.getDescription(); - ProcessInputs processInputs = this.processInputDecoder.decode(description, inputs); - List outputDefinitionsOrDefault = outputDefinitions; if (outputDefinitionsOrDefault == null || outputDefinitionsOrDefault.isEmpty()) { @@ -172,9 +170,9 @@ public JobId execute(OwsCode identifier, createDefaultOutputDefinitions(description.getOutput(identifier).asGroup()))); } - JobId jobId = jobIdGenerator.create(algorithm, processInputs, outputDefinitionsOrDefault); + JobId jobId = jobIdGenerator.create(algorithm); - Job job = new Job(algorithm, jobId, processInputs, OutputDefinition.getOutputsById(outputDefinitionsOrDefault), + Job job = new Job(algorithm, jobId, inputs, OutputDefinition.getOutputsById(outputDefinitionsOrDefault), responseMode); LOG.info("Submitting {}", job.getJobId()); Future submit = this.executor.submit(job); @@ -278,8 +276,6 @@ private final class Job extends AbstractFuture implements Runnable, Proc private final JobId jobId; - private final ProcessInputs inputs; - private final ProcessOutputs outputs; private final TypedProcessDescription description; @@ -300,12 +296,17 @@ private final class Job extends AbstractFuture implements Runnable, Proc private final ResponseMode responseMode; - Job(IAlgorithm algorithm, JobId jobId, ProcessInputs inputs, Map outputDefinitions, - ResponseMode responseMode) { + private final List inputData; + + private ProcessInputs inputs; + + Job(IAlgorithm algorithm, JobId jobId, List inputData, + Map outputDefinitions, ResponseMode responseMode) { + this.jobStatus = JobStatus.accepted(); this.jobId = Objects.requireNonNull(jobId, "jobId"); - this.inputs = Objects.requireNonNull(inputs, "inputs"); this.algorithm = Objects.requireNonNull(algorithm, "algorithm"); + this.inputData = inputData; this.description = algorithm.getDescription(); this.outputDefinitions = Objects.requireNonNull(outputDefinitions, "outputDefinitions"); this.responseMode = Objects.requireNonNull(responseMode, "responseMode"); @@ -384,6 +385,7 @@ public void run() { setJobStatus(JobStatus.running()); LOG.info(EXECUTING, this.jobId); try { + this.inputs = processInputDecoder.decode(description, inputData); this.algorithm.execute(this); LOG.info("Executed {}, creating result", this.jobId); try { diff --git a/engine/src/main/java/org/n52/javaps/engine/impl/FileBasedResultPersistence.java b/engine/src/main/java/org/n52/javaps/engine/impl/FileBasedResultPersistence.java index b03f1ff0..438f0e11 100644 --- a/engine/src/main/java/org/n52/javaps/engine/impl/FileBasedResultPersistence.java +++ b/engine/src/main/java/org/n52/javaps/engine/impl/FileBasedResultPersistence.java @@ -20,10 +20,12 @@ import static java.util.stream.Collectors.toSet; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.OutputStream; import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -33,6 +35,8 @@ import java.time.Duration; import java.time.OffsetDateTime; import java.time.ZoneOffset; +import java.util.Base64; +import java.util.Base64.Encoder; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -49,6 +53,7 @@ import javax.inject.Inject; +import org.apache.commons.io.IOUtils; import org.n52.faroe.annotation.Configurable; import org.n52.faroe.annotation.Setting; import org.n52.iceland.util.MoreFiles; @@ -286,9 +291,25 @@ private void persist(Path directory, encodeFormat(valueData.getFormat(), outputNode.putObject(Keys.FORMAT)); Path outputFile = Files.createTempFile(directory, null, null); outputNode.put(Keys.FILE, outputFile.toString()); - try (InputStream in = valueData.getData()) { - Files.copy(in, outputFile, StandardCopyOption.REPLACE_EXISTING); + + Optional encoding = valueData.getFormat().getEncoding(); + + if (encoding.isPresent() && encoding.get().equals(Format.BASE64_ENCODING)) { + + try (InputStream in = valueData.getData()) { + + Encoder base64encoder = Base64.getEncoder(); + + OutputStream outputStream = base64encoder.wrap(new FileOutputStream(outputFile.toFile())); + IOUtils.copy(in, outputStream); + } + + } else { + try (InputStream in = valueData.getData()) { + Files.copy(in, outputFile, StandardCopyOption.REPLACE_EXISTING); + } } + } } } diff --git a/engine/src/main/java/org/n52/javaps/engine/impl/UUIDJobIdGenerator.java b/engine/src/main/java/org/n52/javaps/engine/impl/UUIDJobIdGenerator.java index 8c53a77c..11a20bb4 100644 --- a/engine/src/main/java/org/n52/javaps/engine/impl/UUIDJobIdGenerator.java +++ b/engine/src/main/java/org/n52/javaps/engine/impl/UUIDJobIdGenerator.java @@ -16,21 +16,16 @@ */ package org.n52.javaps.engine.impl; -import java.util.List; import java.util.UUID; -import org.n52.shetland.ogc.wps.JobId; -import org.n52.shetland.ogc.wps.OutputDefinition; -import org.n52.javaps.engine.JobIdGenerator; import org.n52.javaps.algorithm.IAlgorithm; -import org.n52.javaps.algorithm.ProcessInputs; +import org.n52.javaps.engine.JobIdGenerator; +import org.n52.shetland.ogc.wps.JobId; public class UUIDJobIdGenerator implements JobIdGenerator { @Override - public JobId create(IAlgorithm algorithm, - ProcessInputs inputs, - List outputs) { + public JobId create(IAlgorithm algorithm) { return new JobId(UUID.randomUUID().toString()); } diff --git a/engine/src/test/java/org/n52/javaps/engine/impl/FileBasedResultPersistenceTest.java b/engine/src/test/java/org/n52/javaps/engine/impl/FileBasedResultPersistenceTest.java new file mode 100644 index 00000000..84418978 --- /dev/null +++ b/engine/src/test/java/org/n52/javaps/engine/impl/FileBasedResultPersistenceTest.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016-2019 52°North Initiative for Geospatial Open Source + * Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.n52.javaps.engine.impl; + +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.mockito.Mockito; +import org.n52.javaps.engine.EngineException; +import org.n52.javaps.engine.EngineProcessExecutionContext; +import org.n52.shetland.ogc.ows.OwsCode; +import org.n52.shetland.ogc.wps.DataTransmissionMode; +import org.n52.shetland.ogc.wps.Format; +import org.n52.shetland.ogc.wps.JobId; +import org.n52.shetland.ogc.wps.JobStatus; +import org.n52.shetland.ogc.wps.OutputDefinition; +import org.n52.shetland.ogc.wps.ResponseMode; +import org.n52.shetland.ogc.wps.data.ProcessData; +import org.n52.shetland.ogc.wps.data.ValueProcessData; + +public class FileBasedResultPersistenceTest { + + @Test + public void testSaveBase64() { + + OwsCode processId = new OwsCode("FileBasedResultPersistenceTestProcess"); + OwsCode outputId = new OwsCode("FileBasedResultPersistenceTestOutput"); + JobId jobId = new JobId("javaps-unit-test-" + UUID.randomUUID().toString().substring(0, 5)); + + FileBasedResultPersistence fileBasedResultPersistence = new FileBasedResultPersistence(); + + try { + fileBasedResultPersistence.setBasePath(File.createTempFile("javaps-unit-test", ".tmp").getParentFile()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + EngineProcessExecutionContext context = Mockito.mock(EngineProcessExecutionContext.class); + + Mockito.when(context.getProcessId()).thenReturn(processId); + Mockito.when(context.getJobStatus()).thenReturn(JobStatus.succeeded()); + Mockito.when(context.getResponseMode()).thenReturn(ResponseMode.DOCUMENT); + Mockito.when(context.getJobId()).thenReturn(jobId); + + OutputDefinition outputDefinition = Mockito.mock(OutputDefinition.class); + + Mockito.when(outputDefinition.getDataTransmissionMode()).thenReturn(DataTransmissionMode.VALUE); + + Map outputDefinitions = new HashMap<>(); + + outputDefinitions.put(outputId, outputDefinition); + + Mockito.when(context.getOutputDefinitions()).thenReturn(outputDefinitions); + + List encodedOutputs = new ArrayList<>(); + + ValueProcessData output = Mockito.mock(GeneratingProcessData.class); + + Mockito.when(output.getId()).thenReturn(outputId); + Mockito.when(output.isValue()).thenReturn(true); + Mockito.when(output.asValue()).thenReturn(output); + + Mockito.when(output.getFormat()).thenReturn(new Format("text/xml", "base64")); + + String testdata = new String("test data"); + + InputStream in = new ByteArrayInputStream(testdata.getBytes()); + + try { + Mockito.when(output.getData()).thenReturn(in); + } catch (IOException e) { + fail(e.getMessage()); + } + + encodedOutputs.add(output); + + try { + Mockito.when(context.getEncodedOutputs()).thenReturn(encodedOutputs); + } catch (Throwable e) { + fail(e.getMessage()); + } + + fileBasedResultPersistence.save(context); + + try { + InputStream result = fileBasedResultPersistence.getResult(jobId).getOutputs().get(0).asValue().getData(); + + StringWriter writer = new StringWriter(); + String encoding = StandardCharsets.UTF_8.name(); + IOUtils.copy(result, writer, encoding); + + Base64.getDecoder().decode(writer.toString()); + + } catch (EngineException | IOException e) { + fail(e.getMessage()); + } + + } + +} diff --git a/etc/docker-configuration.json b/etc/docker-configuration.json new file mode 100644 index 00000000..281a1a9b --- /dev/null +++ b/etc/docker-configuration.json @@ -0,0 +1,162 @@ +{ + "settings" : { + "misc.httpResponseCodeUseInKvpAndPoxBinding" : { + "type" : "boolean", + "value" : false + }, + "serviceProvider.name" : { + "type" : "string", + "value" : "52North" + }, + "serviceProvider.file" : { + "type" : "file", + "value" : null + }, + "serviceProvider.site" : { + "type" : "uri", + "value" : "http://52north.org" + }, + "serviceProvider.individualName" : { + "type" : "string", + "value" : "TBA" + }, + "serviceProvider.phone" : { + "type" : "string", + "value" : "+49(0)251/396 371-0" + }, + "serviceProvider.facsimile" : { + "type" : "string", + "value" : "+49(0)251/396 371-11" + }, + "serviceProvider.address" : { + "type" : "string", + "value" : "Martin-Luther-King-Weg 24" + }, + "serviceProvider.city" : { + "type" : "string", + "value" : "Münster" + }, + "serviceProvider.postalCode" : { + "type" : "string", + "value" : "48155" + }, + "serviceProvider.country" : { + "type" : "string", + "value" : "Germany" + }, + "serviceProvider.email" : { + "type" : "string", + "value" : "info@52north.org" + }, + "serviceProvider.state" : { + "type" : "string", + "value" : "North Rhine-Westphalia" + }, + "serviceProvider.positionName" : { + "type" : "string", + "value" : "TBA" + }, + "serviceProvider.hoursOfService" : { + "type" : "string", + "value" : "9 to 5" + }, + "serviceProvider.contactInstructions" : { + "type" : "string", + "value" : "Call or email, please!" + }, + "serviceProvider.onlineResource" : { + "type" : "string", + "value" : "team website|https://github.com/orgs/52North/teams/geoprocessing/members" + }, + "serviceProvider.role.value" : { + "type" : "string", + "value" : "resourceProvider" + }, + "serviceProvider.role.codespace" : { + "type" : "uri", + "value" : "http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" + }, + "serviceIdentification.file" : { + "type" : "file", + "value" : null + }, + "serviceIdentification.abstract" : { + "type" : "multilingual", + "value" : { + "en" : "52North WPS 2.0 Service", + "de" : "52North WPS 2.0 Dienst" + } + }, + "serviceIdentification.title" : { + "type" : "multilingual", + "value" : { + "en" : "javaPS", + "de" : "javaPS" + } + }, + "serviceIdentification.keywords" : { + "type" : "string", + "value" : "OGC, WPS 2.0" + }, + "serviceIdentification.serviceType" : { + "type" : "string", + "value" : "OGC:TEST" + }, + "i18n.defaultLanguage" : { + "type" : "string", + "value" : "en" + }, + "serviceIdentification.serviceTypeCodeSpace" : { + "type" : "string", + "value" : null + }, + "serviceIdentification.fees" : { + "type" : "string", + "value" : "NONE" + }, + "serviceIdentification.accessConstraints" : { + "type" : "string", + "value" : "NONE" + }, + "misc.includeStackTraceInExceptionReport" : { + "type" : "boolean", + "value" : true + }, + "misc.characterEncoding" : { + "type" : "string", + "value" : "UTF-8" + }, + "i18n.showAllLanguageValues" : { + "type" : "boolean", + "value" : false + }, + "statistics.counting-outputstream" : { + "type" : "boolean", + "value" : false + }, + "service.serviceURL" : { + "type" : "uri", + "value" : "http://localhost:8080/service" + }, + "filewatcher.enabled" : { + "type" : "boolean", + "value" : true + }, + "misc.includeOriginalRequest" : { + "type" : "boolean", + "value" : false + }, + "misc.baseDirectory" : { + "type" : "file", + "value" : "/var/lib/jetty/webapps/ROOT/WEB-INF/tmp/" + }, + "misc.duration" : { + "type" : "string", + "value" : "PT2H" + }, + "misc.checkInterval" : { + "type" : "string", + "value" : "PT1H" + } + } +} \ No newline at end of file diff --git a/etc/docker-log4j2.xml b/etc/docker-log4j2.xml new file mode 100644 index 00000000..57e32bf1 --- /dev/null +++ b/etc/docker-log4j2.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 76e13e2c..d5eb0ae6 100644 --- a/pom.xml +++ b/pom.xml @@ -91,9 +91,9 @@ ${maven.build.timestamp} yyyyMMdd-HHmm 5.1.3.RELEASE - 1.7.25 + 1.7.26 2.3 - 5.3.0 + 6.0.0 @@ -310,7 +310,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.8 + 2.9.9 com.google.guava @@ -345,6 +345,12 @@ 4.4.10 test + + org.mockito + mockito-core + 2.27.0 + test + net.sf.saxon Saxon-HE diff --git a/service/src/main/resources/components/algorithms.xml b/service/src/main/resources/components/algorithms.xml index cf704b77..ec3cf816 100644 --- a/service/src/main/resources/components/algorithms.xml +++ b/service/src/main/resources/components/algorithms.xml @@ -25,6 +25,4 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"> - - diff --git a/webapp/src/main/webapp/configuration.json b/webapp/src/main/webapp/WEB-INF/config/configuration.json similarity index 100% rename from webapp/src/main/webapp/configuration.json rename to webapp/src/main/webapp/WEB-INF/config/configuration.json