commit 3fc67af65719b2df3b0e6d6bba61a1b17e6ac527 Author: Robert von Burg Date: Tue Aug 16 22:04:41 2022 +0200 [Project] Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + 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 [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/README.md b/README.md new file mode 100644 index 0000000..148f8ed --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Strolch Maven Archetypes + +This repository contains archetypes to be used when creating new Strolch applications. + +Install this maven module locally: + + git clone https://github.com/strolch-li/strolch-maven-archetypes.git + cd strolch-maven-archetypes + mvn clean install + +Now you can use the archetypes to create your project. The following archetypes are available: + +* li.strolch.mvn.archetype.main +* li.strolch.mvn.archetype.webapp + +To create a Strolch project see https://strolch.li/development/ diff --git a/li.strolch.mvn.archetype.main/.gitignore b/li.strolch.mvn.archetype.main/.gitignore new file mode 100644 index 0000000..1e97e93 --- /dev/null +++ b/li.strolch.mvn.archetype.main/.gitignore @@ -0,0 +1,5 @@ +target/ +.project +.settings +.classpath +*.iml \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/pom.xml b/li.strolch.mvn.archetype.main/pom.xml new file mode 100644 index 0000000..e79bf8d --- /dev/null +++ b/li.strolch.mvn.archetype.main/pom.xml @@ -0,0 +1,41 @@ + + + + li.strolch + li.strolch-maven-archetypes + 0.1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + li.strolch.mvn.archetype.main + maven-archetype + + + + localhost + file://${project.basedir}/../target/${project.artifactId} + + + + + + + + src/main/resources + false + + + + + + org.apache.maven.archetype + archetype-packaging + ${archetype-packaging.version} + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/META-INF/maven/archetype-metadata.xml b/li.strolch.mvn.archetype.main/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..bad952b --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,37 @@ + + + + + Strolch App + + + + + + src/main/java + + + src/main/resources + + + src/test/java + + + src/test/resources + + + runtime + + + + + README.md + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/README.md b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/README.md new file mode 100644 index 0000000..584d1e0 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/README.md @@ -0,0 +1,37 @@ +Strolch Project: ${appName} / ${artifactId} +====================================== + +This is a Strolch project which is started by a main()-method. It has an example +test class to show how to start an agent for tests. + +The project's runtime directory is in the root folder and contains the +configuration and data files needed to start via the main()-method. + +The test has it's own runtime directory, with its own configuration, but the +model file in the data directory points to the main runtime directory and uses +that model file, so that one does not need to duplicate resource files. + +Preparation +------------------ + +Please change the SCM connection in the pom.xml: + + + + scm:git:https://github.com/4treesCH/strolch.git + scm:git:https://github.com/4treesCH/strolch.git + https://github.com/4treesCH/strolch + + +Running tests +------------------------- + + mvn clean test + + +Running App +-------------------------- + + mvn clean compile + mvn exec:java + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/pom.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..e3c8f24 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,247 @@ + + 4.0.0 + + ${groupId} + ${artifactId} + ${appName} + ${version} + jar + + + + scm:git:https://github.com/4treesCH/strolch.git + scm:git:https://github.com/4treesCH/strolch.git + https://github.com/4treesCH/strolch + + + + ${artifactId} + + UTF-8 + yyyy-MM-dd HH:mm:ss + ${maven.build.timestamp} + + 17 + + + 1.7.30 + 1.2.9 + 2.8.9 + + 1.7.0-SNAPSHOT + + + 4.13.2 + 2.2 + + + 1.12.2 + 3.0.0 + 2.8.1 + 3.8.1 + 3.2.1 + 3.10.0 + 2.10 + 3.2.0 + 3.3.2 + 2.2 + 3.3.1 + 3.0.0-M2 + 3.2.0 + 3.2.0 + 3.3.0 + 3.1.2 + 3.0.1 + 1.6.12 + 2.22.2 + 3.0.0 + 3.2.0 + 3.2.0 + + + + + + + li.strolch + li.strolch.bom + pom + ${strolch.version} + import + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + runtime + + + + com.google.code.gson + gson + ${gson.version} + + + + + junit + junit + ${junit.version} + test + + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${hamcrest.version} + test + + + + + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + runtime + + + com.google.code.gson + gson + + + + + li.strolch + li.strolch.model + + + li.strolch + li.strolch.agent + + + li.strolch + li.strolch.service + + + li.strolch + li.strolch.testbase + test + + + + + junit + junit + test + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + + ${appFinalName} + + + + src/main/resources + true + + **/*.properties + + + + src/main/resources + false + + **/*.properties + + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + ${buildnumber-maven-plugin.version} + + + validate + + create + + + + + false + false + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${jdk.version} + ${jdk.version} + true + true + -Xlint:all + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + ${package}.Main + + + + + + + + + + + dev.local + + true + + + dev + + + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml new file mode 100644 index 0000000..c0e3aba --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml new file mode 100644 index 0000000..a009e8e --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml @@ -0,0 +1,211 @@ + + + + + + true + + + true + + + true + + + true + + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + li.strolch.service.privilege.users.PrivilegeSetUserPasswordService + li.strolch.service.privilege.users.PrivilegeSetUserLocaleService + + + + + + + li.strolch.service.privilege.users.PrivilegeUpdateUserService + li.strolch.service.privilege.users.PrivilegeUpdateUserRolesService + li.strolch.service.privilege.users.PrivilegeSetUserPasswordService + li.strolch.service.privilege.users.PrivilegeSetUserLocaleService + li.strolch.service.privilege.users.PrivilegeRemoveUserService + li.strolch.service.privilege.users.PrivilegeRemoveRoleFromUserService + li.strolch.service.privilege.users.PrivilegeAddUserService + li.strolch.service.privilege.users.PrivilegeAddRoleToUserService + li.strolch.service.privilege.roles.PrivilegeUpdateRoleService + li.strolch.service.privilege.roles.PrivilegeRemoveRoleService + li.strolch.service.privilege.roles.PrivilegeRemovePrivilegeFromRoleService + li.strolch.service.privilege.roles.PrivilegeAddRoleService + li.strolch.service.privilege.roles.PrivilegeAddOrReplacePrivilegeOnRoleService + + + true + + + true + + + true + + + true + + + true + + + true + + + Reload + GetPolicies + Persist + GetCertificates + PersistSessions + + + true + + + SYSTEM + DISABLED + ENABLED + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + true + + + true + + + true + + + li.strolch.runtime.privilege.StrolchSystemAction + li.strolch.runtime.privilege.StrolchSystemActionWithResult + li.strolch.persistence.postgresql.PostgreSqlSchemaInitializer + + + Persist + GetCertificates + PersistSessions + + + true + + + true + + + true + + + true + + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml new file mode 100644 index 0000000..27e29a9 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml @@ -0,0 +1,46 @@ + + + + + + User + Bob + ENABLED + en-GB + + AppUser + ModelAccessor + UserPrivileges + + + + + + + + + + Application + Administrator + ENABLED + en-GB + + StrolchAdmin + ModelAccessor + PrivilegeAdmin + + + + + + + + + SYSTEM + + ModelAccessor + PrivilegeAdmin + agent + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml new file mode 100644 index 0000000..85305a0 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml @@ -0,0 +1,101 @@ + + + + + ${appName} + + en + true + Europe/Zurich + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PrivilegeHandler + + defaultRealm + TRANSIENT + Model.xml + true + + + + + EnumHandler + li.strolch.runtime.query.enums.EnumHandler + li.strolch.runtime.query.enums.DefaultEnumHandler + RealmHandler + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + true + + + + + PolicyHandler + li.strolch.policy.PolicyHandler + li.strolch.policy.DefaultPolicyHandler + + true + + + + + MigrationsHandler + li.strolch.migrations.MigrationsHandler + li.strolch.migrations.MigrationsHandler + RealmHandler + + + + OperationsLog + li.strolch.handler.operationslog.OperationsLog + li.strolch.handler.operationslog.OperationsLog + RealmHandler + + + + StrolchJobsHandler + li.strolch.job.StrolchJobsHandler + li.strolch.job.StrolchJobsHandler + RealmHandler + + + + PostInitializer + li.strolch.agent.api.PostInitializer + ${package}.PostInitializer + ServiceHandler + + + + + + ExecutionHandler + li.strolch.execution.ExecutionHandler + li.strolch.execution.EventBasedExecutionHandler + PostInitializer + + true + + + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml new file mode 100644 index 0000000..cba3b97 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/Model.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/Model.xml new file mode 100644 index 0000000..c6ac169 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/Model.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd new file mode 100644 index 0000000..0375feb --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd @@ -0,0 +1,201 @@ + + + + + This is Version 1.6.x of the StrolchModel XSD. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/Main.java b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/Main.java new file mode 100644 index 0000000..48bbf83 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/Main.java @@ -0,0 +1,50 @@ +package ${package}; + +import li.strolch.agent.api.StrolchAgent; +import li.strolch.agent.api.StrolchBootstrapper; +import li.strolch.runtime.configuration.StrolchEnvironment; +import li.strolch.utils.helper.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Main { + + private static final Logger logger = LoggerFactory.getLogger(Main.class); + private static final String APP_NAME = "${appName}"; + + private static StrolchAgent agent; + + public static void main(String[] args) throws Throwable { + + logger.info("Starting " + APP_NAME + "..."); + long start = System.currentTimeMillis(); + try { + // find environment from ENV.properties + String env = StrolchEnvironment.getEnvironmentFromResourceEnv(Main.class); + + // and now start by system properties user.dir + StrolchBootstrapper bootstrapper = new StrolchBootstrapper(Main.class); + Main.agent = bootstrapper.setupByUserDir(env, "runtime"); + Main.agent.initialize(); + Main.agent.start(); + + } catch (Throwable e) { + logger.error("Failed to start " + APP_NAME + " due to: " + e.getMessage(), e); + throw e; + } + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try { + Thread.sleep(200); + System.out.println("Shutting down ..."); + Main.agent.stop(); + Main.agent.destroy(); + } catch (InterruptedException e) { + logger.error("Failed to stop " + APP_NAME + " due to " + e.getMessage(), e); + } + })); + + long took = System.currentTimeMillis() - start; + logger.info("Started " + APP_NAME + " in " + (StringHelper.formatMillisecondsDuration(took))); + } +} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/PostInitializer.java b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/PostInitializer.java new file mode 100644 index 0000000..8174aa8 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/java/PostInitializer.java @@ -0,0 +1,87 @@ +package ${package}; + +import java.util.concurrent.TimeUnit; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.StrolchAgent; +import li.strolch.agent.impl.SimplePostInitializer; +import li.strolch.execution.ArchiveExecutedActivitiesJob; +import li.strolch.execution.ExecutionHandler; +import li.strolch.handler.mail.MailHandler; +import li.strolch.job.JobMode; +import li.strolch.job.StrolchJobsHandler; +import li.strolch.policy.ReloadPoliciesJob; +import li.strolch.policy.ReloadPrivilegeHandlerJob; +import li.strolch.runtime.configuration.RuntimeConfiguration; +import li.strolch.utils.helper.ExceptionHelper; + +public class PostInitializer extends SimplePostInitializer { + + public PostInitializer(ComponentContainer container, String componentName) { + super(container, componentName); + } + + @Override + public void start() throws Exception { + + registerJobs(); + notifyStart(); + + super.start(); + } + + private void registerJobs() throws Exception { + if (!getContainer().hasComponent(StrolchJobsHandler.class)) + return; + + StrolchJobsHandler jobsHandler = getComponent(StrolchJobsHandler.class); + + // Manually triggered jobs to run once on startup + // jobsHandler.register(XXX.class).runNow(); + + // special jobs which are triggered by an admin, and not run at startup + jobsHandler.register(ReloadPoliciesJob.class); + jobsHandler.register(ReloadPrivilegeHandlerJob.class); + + // recurring jobs + // jobsHandler.registerAndScheduleJob(XXX.class); + + if (getContainer().hasComponent(ExecutionHandler.class)) { + StrolchAgent agent = getContainer().getAgent(); + ArchiveExecutedActivitiesJob archiveExecutedActivitiesJob = new ArchiveExecutedActivitiesJob(agent, + JobMode.Recurring, 5, TimeUnit.MINUTES, 6, TimeUnit.HOURS); + jobsHandler.register(archiveExecutedActivitiesJob).runNow(); + } + } + + private void notifyStart() { + + if (!(getConfiguration().getBoolean("notifyStart", Boolean.FALSE) && getContainer() + .hasComponent(MailHandler.class))) + return; + + String recipients = getConfiguration().getString("notifyStartRecipients", ""); + if (recipients.isEmpty()) { + logger.error("config param notifyStartRecipients is empty, can not notify of boot!"); + return; + } + + StrolchAgent agent = getContainer().getAgent(); + RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration(); + String subject = runtimeConfiguration.getApplicationName() + ":" + runtimeConfiguration.getEnvironment() + + " Startup Complete!"; + + String body = "Dear User\n\n" // + + "The " + getConfiguration().getRuntimeConfiguration().getApplicationName() + + " Server has just completed startup with version " // + + agent.getVersion().getAppVersion().getArtifactVersion() // + + "\n\n" // + + "\tYour Server."; + + try { + getContainer().getComponent(MailHandler.class).sendMail(subject, body, recipients); + } catch (Exception e) { + logger.error("Notifying of server startup failed: " + ExceptionHelper.getRootCause(e), e); + } + } +} diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/ENV.properties b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/ENV.properties new file mode 100644 index 0000000..8212444 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/ENV.properties @@ -0,0 +1 @@ +ENV_STROLCH=${strolch.env} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/appVersion.properties b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/appVersion.properties new file mode 100644 index 0000000..a4594a2 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/appVersion.properties @@ -0,0 +1,6 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +artifactVersion=${project.version} +scmRevision=${buildNumber} +scmBranch=${scmBranch} +buildTimestamp=${buildTimestamp} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/logback.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/logback.xml new file mode 100644 index 0000000..fcc71f0 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + + + %d [%thread] %-5level %class{36}:%line %method - %msg%n + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/java/SimpleTest.java b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/java/SimpleTest.java new file mode 100644 index 0000000..8252938 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/java/SimpleTest.java @@ -0,0 +1,49 @@ +package ${package}; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.privilege.model.Certificate; +import li.strolch.testbase.runtime.RuntimeMock; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SimpleTest { + + private static final String SRC_PATH = "src/test/resources/runtime-SimpleTest"; + private static final String TARGET_PATH = "target/" + SimpleTest.class; + + private static RuntimeMock runtimeMock; + private static Certificate certificate; + + @BeforeClass + public static void beforeClass() { + runtimeMock = new RuntimeMock().mockRuntime(TARGET_PATH, SRC_PATH); + runtimeMock.startContainer(); + certificate = runtimeMock.loginTest(); + } + + @AfterClass + public static void afterClass() { + + if (certificate != null) + runtimeMock.logout(certificate); + + if (runtimeMock != null) + runtimeMock.destroyRuntime(); + } + + @Test + public void shouldLoadIntoRealm() { + + try (StrolchTransaction tx = runtimeMock.openUserTx(certificate, true)) { + + Resource ball = tx.getResourceBy("Ball", "yellowBall", true); + assertTrue(ball.hasParameter("parameters", "color")); + assertEquals("yellow", ball.getParameter("parameters", "color", true).getValue()); + } + } +} diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/logback.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/logback.xml new file mode 100644 index 0000000..fcc71f0 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + + + %d [%thread] %-5level %class{36}:%line %method - %msg%n + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml new file mode 100644 index 0000000..be4bbfc --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml new file mode 100644 index 0000000..43cc297 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml @@ -0,0 +1,105 @@ + + + + + li.strolch.runtime.privilege.StrolchSystemAction + li.strolch.runtime.privilege.StrolchSystemActionWithResult + li.strolch.persistence.postgresql.PostgreSqlSchemaInitializer + + + true + + + true + + + true + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + true + + + true + + + true + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml new file mode 100644 index 0000000..1215921 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml @@ -0,0 +1,22 @@ + + + + SYSTEM + + agent + + + + + Application + Administrator + ENABLED + en-GB + + AppUser + + + + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml new file mode 100644 index 0000000..891421b --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml @@ -0,0 +1,50 @@ + + + + + ${appName} + + en + true + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PrivilegeHandler + + defaultRealm + TRANSIENT + Model.xml + true + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + true + + + + PostInitializer + li.strolch.agent.api.PostInitializer + ${package}.PostInitializer + ServiceHandler + + + + + diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml new file mode 100644 index 0000000..cba3b97 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml new file mode 100644 index 0000000..f81c984 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore new file mode 100644 index 0000000..7385672 --- /dev/null +++ b/li.strolch.mvn.archetype.main/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore @@ -0,0 +1 @@ +/sessions.dat diff --git a/li.strolch.mvn.archetype.webapp/.gitignore b/li.strolch.mvn.archetype.webapp/.gitignore new file mode 100644 index 0000000..1e97e93 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/.gitignore @@ -0,0 +1,5 @@ +target/ +.project +.settings +.classpath +*.iml \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/pom.xml b/li.strolch.mvn.archetype.webapp/pom.xml new file mode 100644 index 0000000..643b175 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/pom.xml @@ -0,0 +1,41 @@ + + + + li.strolch + li.strolch-maven-archetypes + 0.1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + li.strolch.mvn.archetype.webapp + maven-archetype + + + + localhost + file://${project.basedir}/../target/${project.artifactId} + + + + + + + + src/main/resources + false + + + + + + org.apache.maven.archetype + archetype-packaging + ${archetype-packaging.version} + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/META-INF/maven/archetype-metadata.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..4e6b912 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,63 @@ + + + + + Strolch App + + + + + + src/main/java + + + src/main/resources + + + src/test/java + + + src/test/resources + + + src/main/webapp/ + + bower.json + package.json + locales.json + app/index.html + app/src/behaviors/c-app-behavior.html + app/src/main/c-drawer.html + + + + src/main/webapp/ + + bower.json + package.json + locales.json + app/index.html + app/src/behaviors/c-app-behavior.html + app/src/main/c-drawer.html + + + + runtime + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/README.md b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/README.md new file mode 100644 index 0000000..6b8ca14 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/README.md @@ -0,0 +1,61 @@ +Strolch Project: ${appName} / ${artifactId} +====================================== + +This is a Strolch project which is started by a servlet container as this +project builds WARs. + +The project's runtime directory is in the root folder and contains the +configuration and data files needed to start via the `StartupListener`. + +The test has it's own runtime directory, with its own configuration, but the +model file in the data directory points to the main runtime directory and uses +that model file, so that one does not need to duplicate resource files. + +Preparation +------------------ + +Please change the SCM connection in the pom.xml: + + + + scm:git:https://github.com/strolch-li/strolch.git + scm:git:https://github.com/strolch-li/strolch.git + https://github.com/strolch-li/strolch + + +Before you are able to start the app, you need to update the path in the +`StrolchBootstrap.xml` file in web `src/main/webapp/WEB-INF`. There add a new +environment with the following format: + + + ${path.to.runtime.directory} + dev + + +Now install web dependencies: + + cd src/main/webapp + npm install + gulp + + +Running tests +------------------------- + + mvn clean test + + +Building WAR +-------------------------- +Without compressing the web files: + + mvn clean package + +With compressing the web files for local runtime: + + mvn clean package -Prelease -Pdev.local + +And if you want to prepare for deployment, which uses a different environment: + + mvn clean package -Prelease -Dstrolch.env= + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/pom.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..a30e3af --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,432 @@ + + 4.0.0 + + ${groupId} + ${artifactId} + ${appName} + ${version} + war + + + + scm:git:https://github.com/strolch-li/strolch.git + scm:git:https://github.com/strolch-li/strolch.git + https://github.com/strolch-li/strolch + + + + ${artifactId} + ${artifactId} + + UTF-8 + yyyy-MM-dd HH:mm:ss + ${maven.build.timestamp} + + 17 + + + 1.7.30 + 1.2.9 + 2.34 + 2.8.9 + 5.0.0 + 42.4.1 + 4.9.3 + 1.3.2 + 1.1.1 + 1.6.2 + 4.0.1 + 2.1.1 + 2.35 + 2.3.1 + 2.3.3 + 2.1.0 + 1.4.2 + 1.17 + 2.4.4 + 1.1 + 2.0.1 + 1.9.0 + 1.6.2 + + + 4.13.2 + 2.2 + + + 1.8.0-SNAPSHOT + + + 1.12.2 + 3.0.0 + 2.8.1 + 3.8.1 + 3.2.1 + 3.10.0 + 2.10 + 3.2.0 + 3.3.2 + 2.2 + 3.3.1 + 3.0.0-M2 + 3.2.0 + 3.2.0 + 3.3.0 + 3.1.2 + 3.0.1 + 1.6.12 + 2.22.2 + 3.0.0 + 3.2.0 + 3.2.0 + + + + + + + li.strolch + li.strolch.bom + pom + ${strolch.version} + import + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + runtime + + + + com.google.code.gson + gson + ${gson.version} + + + + + javax.xml.bind + jaxb-api + ${jaxb.api.version} + + + javax.servlet + javax.servlet-api + ${serverlet.version} + provided + + + javax.ws.rs + javax.ws.rs-api + ${jaxrs.api.version} + + + org.glassfish.jersey.bundles + jaxrs-ri + ${jaxrs.ri.version} + + + org.glassfish.jersey + jersey-bom + ${jersey.version} + pom + import + + + org.glassfish.tyrus + tyrus-client + ${tyrus.version} + + + org.glassfish.tyrus + tyrus-container-grizzly-client + ${tyrus.version} + + + org.glassfish.tyrus + tyrus-container-grizzly-server + ${tyrus.version} + + + org.glassfish.grizzly + grizzly-framework + ${grizzly.version} + + + + + javax.websocket + javax.websocket-api + ${websocket.version} + provided + + + + + junit + junit + ${junit.version} + test + + + org.hamcrest + hamcrest-core + ${hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${hamcrest.version} + test + + + + + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + compile + + + com.google.code.gson + gson + + + + + li.strolch + li.strolch.model + + + li.strolch + li.strolch.agent + + + li.strolch + li.strolch.rest + + + li.strolch + li.strolch.service + + + li.strolch + li.strolch.testbase + test + + + + + javax.servlet + javax.servlet-api + + + javax.websocket + javax.websocket-api + + + org.glassfish.jersey.bundles + jaxrs-ri + + + org.glassfish.tyrus + tyrus-client + + + org.glassfish.tyrus + tyrus-container-grizzly-client + + + org.glassfish.grizzly + grizzly-framework + + + + + junit + junit + test + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + + ${appFinalName} + + + + src/main/resources + true + + **/*.properties + StrolchBootstrap.xml + + + + src/main/resources + false + + **/*.properties + StrolchBootstrap.xml + + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + ${buildnumber-maven-plugin.version} + + + validate + + create + + + + + false + false + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${jdk.version} + ${jdk.version} + true + true + -Xlint:all + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + ${warFinalName} + + + + + + + + + + + dev.local + + true + + + dev.local + + + + + release + + false + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + + src/main/webapp/app/bower_components + + ** + + false + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + exec-npm-install + generate-sources + + npm + + install + + ${basedir}/src/main/webapp + + + exec + + + + exec-gulp + generate-sources + + gulp + ${basedir}/src/main/webapp + + + exec + + + + + + + org.apache.maven.plugins + maven-war-plugin + + false + ${warFinalName} + app/**/*,node_modules/**/* + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml new file mode 100644 index 0000000..7071ddd --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeConfig.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml new file mode 100644 index 0000000..cdf7da1 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeRoles.xml @@ -0,0 +1,218 @@ + + + + + + ${package}.service.CreateBookService + ${package}.service.UpdateBookService + ${package}.service.RemoveBookService + + + + internal + ${package}.search.BookSearch + + + true + + + + + + + + Get + Update + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + Get + Update + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + li.strolch.service.privilege.users.PrivilegeSetUserPasswordService + li.strolch.service.privilege.users.PrivilegeSetUserLocaleService + + + + + + + li.strolch.service.privilege.users.PrivilegeUpdateUserService + li.strolch.service.privilege.users.PrivilegeUpdateUserRolesService + li.strolch.service.privilege.users.PrivilegeSetUserPasswordService + li.strolch.service.privilege.users.PrivilegeSetUserLocaleService + li.strolch.service.privilege.users.PrivilegeRemoveUserService + li.strolch.service.privilege.users.PrivilegeRemoveRoleFromUserService + li.strolch.service.privilege.users.PrivilegeAddUserService + li.strolch.service.privilege.users.PrivilegeAddRoleToUserService + li.strolch.service.privilege.roles.PrivilegeUpdateRoleService + li.strolch.service.privilege.roles.PrivilegeRemoveRoleService + li.strolch.service.privilege.roles.PrivilegeRemovePrivilegeFromRoleService + li.strolch.service.privilege.roles.PrivilegeAddRoleService + li.strolch.service.privilege.roles.PrivilegeAddOrReplacePrivilegeOnRoleService + + + true + + + true + + + true + + + true + + + true + + + true + + + Reload + GetPolicies + Persist + GetCertificates + PersistSessions + + + true + + + SYSTEM + DISABLED + ENABLED + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + true + + + true + + + true + + + li.strolch.runtime.privilege.StrolchSystemAction + li.strolch.runtime.privilege.StrolchSystemActionWithResult + li.strolch.persistence.postgresql.PostgreSqlSchemaInitializer + + + Persist + GetCertificates + PersistSessions + + + true + + + true + + + true + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml new file mode 100644 index 0000000..27e29a9 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/PrivilegeUsers.xml @@ -0,0 +1,46 @@ + + + + + + User + Bob + ENABLED + en-GB + + AppUser + ModelAccessor + UserPrivileges + + + + + + + + + + Application + Administrator + ENABLED + en-GB + + StrolchAdmin + ModelAccessor + PrivilegeAdmin + + + + + + + + + SYSTEM + + ModelAccessor + PrivilegeAdmin + agent + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml new file mode 100644 index 0000000..5324bda --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchConfiguration.xml @@ -0,0 +1,131 @@ + + + + + ${appName} + + en + true + Europe/Zurich + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PrivilegeHandler + + defaultRealm + TRANSIENT + Model.xml + true + + + + + EnumHandler + li.strolch.runtime.query.enums.EnumHandler + li.strolch.runtime.query.enums.DefaultEnumHandler + RealmHandler + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + true + + + + + PolicyHandler + li.strolch.policy.PolicyHandler + li.strolch.policy.DefaultPolicyHandler + + true + + + + + MigrationsHandler + li.strolch.migrations.MigrationsHandler + li.strolch.migrations.MigrationsHandler + RealmHandler + + + + OperationsLog + li.strolch.handler.operationslog.OperationsLog + li.strolch.handler.operationslog.OperationsLog + RealmHandler + + + + StrolchJobsHandler + li.strolch.job.StrolchJobsHandler + li.strolch.job.StrolchJobsHandler + RealmHandler + + + + SessionHandler + li.strolch.rest.StrolchSessionHandler + li.strolch.rest.DefaultStrolchSessionHandler + PrivilegeHandler + + 30 + 10080 + true + + + + RestfulHandler + li.strolch.rest.RestfulStrolchComponent + li.strolch.rest.RestfulStrolchComponent + SessionHandler + + 30 + false + + + + + PostInitializer + li.strolch.agent.api.PostInitializer + ${package}.components.PostInitializer + RestfulHandler + + + + + + ExecutionHandler + li.strolch.execution.ExecutionHandler + li.strolch.execution.EventBasedExecutionHandler + PostInitializer + + true + + + + + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml new file mode 100644 index 0000000..cba3b97 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/config/StrolchPolicies.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/Model.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/Model.xml new file mode 100644 index 0000000..8084d4e --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/Model.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd new file mode 100644 index 0000000..0375feb --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/runtime/data/StrolchModel.xsd @@ -0,0 +1,201 @@ + + + + + This is Version 1.6.x of the StrolchModel XSD. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/components/PostInitializer.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/components/PostInitializer.java new file mode 100644 index 0000000..651f3b1 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/components/PostInitializer.java @@ -0,0 +1,87 @@ +package ${package}.components; + +import java.util.concurrent.TimeUnit; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.StrolchAgent; +import li.strolch.agent.impl.SimplePostInitializer; +import li.strolch.execution.ArchiveExecutedActivitiesJob; +import li.strolch.execution.ExecutionHandler; +import li.strolch.handler.mail.MailHandler; +import li.strolch.job.JobMode; +import li.strolch.job.StrolchJobsHandler; +import li.strolch.policy.ReloadPoliciesJob; +import li.strolch.policy.ReloadPrivilegeHandlerJob; +import li.strolch.runtime.configuration.RuntimeConfiguration; +import li.strolch.utils.helper.ExceptionHelper; + +public class PostInitializer extends SimplePostInitializer { + + public PostInitializer(ComponentContainer container, String componentName) { + super(container, componentName); + } + + @Override + public void start() throws Exception { + + registerJobs(); + notifyStart(); + + super.start(); + } + + private void registerJobs() throws Exception { + if (!getContainer().hasComponent(StrolchJobsHandler.class)) + return; + + StrolchJobsHandler jobsHandler = getComponent(StrolchJobsHandler.class); + + // Manually triggered jobs to run once on startup + // jobsHandler.register(XXX.class).runNow(); + + // special jobs which are triggered by an admin, and not run at startup + jobsHandler.register(ReloadPoliciesJob.class); + jobsHandler.register(ReloadPrivilegeHandlerJob.class); + + // recurring jobs + // jobsHandler.registerAndScheduleJob(XXX.class); + + if (getContainer().hasComponent(ExecutionHandler.class)) { + StrolchAgent agent = getContainer().getAgent(); + ArchiveExecutedActivitiesJob archiveExecutedActivitiesJob = new ArchiveExecutedActivitiesJob(agent, + JobMode.Recurring, 5, TimeUnit.MINUTES, 6, TimeUnit.HOURS); + jobsHandler.register(archiveExecutedActivitiesJob).runNow(); + } + } + + private void notifyStart() { + + if (!(getConfiguration().getBoolean("notifyStart", Boolean.FALSE) && getContainer() + .hasComponent(MailHandler.class))) + return; + + String recipients = getConfiguration().getString("notifyStartRecipients", ""); + if (recipients.isEmpty()) { + logger.error("config param notifyStartRecipients is empty, can not notify of boot!"); + return; + } + + StrolchAgent agent = getContainer().getAgent(); + RuntimeConfiguration runtimeConfiguration = agent.getStrolchConfiguration().getRuntimeConfiguration(); + String subject = runtimeConfiguration.getApplicationName() + ":" + runtimeConfiguration.getEnvironment() + + " Startup Complete!"; + + String body = "Dear User\n\n" // + + "The " + getConfiguration().getRuntimeConfiguration().getApplicationName() + + " Server has just completed startup with version " // + + agent.getVersion().getAppVersion().getArtifactVersion() // + + "\n\n" // + + "\tYour Server."; + + try { + getContainer().getComponent(MailHandler.class).sendMail(subject, body, recipients); + } catch (Exception e) { + logger.error("Notifying of server startup failed: " + ExceptionHelper.getRootCause(e), e); + } + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/Constants.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/Constants.java new file mode 100644 index 0000000..b453fb5 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/Constants.java @@ -0,0 +1,20 @@ +package ${package}.model; + +public class Constants { + + public static final String TYPE_BOOK = "Book"; + public static final String TYPE_LOCATION = "Location"; + public static final String TYPE_STOCK = "Stock"; + + public static final String BAG_PARAMETERS = "parameters"; + + public static final String PARAM_STOCK = "stock"; + public static final String PARAM_STOCKS = "stocks"; + public static final String PARAM_BOOK = "book"; + public static final String PARAM_BOOK_NAME = "bookName"; + public static final String PARAM_AUTHOR = "author"; + public static final String PARAM_TITLE = "title"; + public static final String PARAM_CITY = "city"; + +} + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/JsonVisitors.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/JsonVisitors.java new file mode 100644 index 0000000..b489609 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/model/JsonVisitors.java @@ -0,0 +1,39 @@ +package ${package}.model; + +import static ${package}.model.Constants.*; + +import java.util.Optional; + +import com.google.gson.JsonArray; +import li.strolch.model.StrolchElement; +import li.strolch.model.json.StrolchRootElementToJsonVisitor; +import li.strolch.persistence.api.StrolchTransaction; + +public class JsonVisitors { + + public static StrolchRootElementToJsonVisitor toJson() { + return new StrolchRootElementToJsonVisitor().withoutPolicies(); + } + + public static StrolchRootElementToJsonVisitor flatToJson() { + return toJson().withoutVersion().flat(); + } + + public static StrolchRootElementToJsonVisitor bookToJson() { + return flatToJson(); + } + + public static StrolchRootElementToJsonVisitor stockBagToJson(StrolchTransaction tx) { + return flatToJson().bagHook((stockBag, stockJ) -> stockJ.addProperty(PARAM_BOOK_NAME, + Optional.ofNullable(tx.getResourceBy(stockBag.getParameter(PARAM_BOOK), false)) + .map(StrolchElement::getName).orElse("???"))); + } + + public static StrolchRootElementToJsonVisitor locationToJson(StrolchTransaction tx) { + StrolchRootElementToJsonVisitor stockVisitor = stockBagToJson(tx); + return flatToJson().ignoreBagByType(TYPE_STOCK).resourceHook( + (location, locationJ) -> locationJ.add(PARAM_STOCKS, + location.streamOfParameterBagsByType(TYPE_STOCK).map(b -> b.accept(stockVisitor)) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll))); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/BooksResource.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/BooksResource.java new file mode 100644 index 0000000..d23c960 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/BooksResource.java @@ -0,0 +1,157 @@ +package ${package}.rest; + +import static ${package}.model.Constants.*; +import static ${package}.model.JsonVisitors.bookToJson; +import static li.strolch.rest.StrolchRestfulConstants.*; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import ${package}.model.Constants; +import ${package}.model.JsonVisitors; +import ${package}.search.BookSearch; +import ${package}.service.CreateBookService; +import ${package}.service.RemoveBookService; +import ${package}.service.UpdateBookService; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import li.strolch.model.Resource; +import li.strolch.model.json.StrolchRootElementToJsonVisitor; +import li.strolch.model.visitor.ResourceVisitor; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.privilege.model.Certificate; +import li.strolch.rest.RestfulStrolchComponent; +import li.strolch.rest.StrolchRestfulConstants; +import li.strolch.rest.helper.ResponseUtil; +import li.strolch.service.JsonServiceArgument; +import li.strolch.service.JsonServiceResult; +import li.strolch.service.StringServiceArgument; +import li.strolch.service.api.ServiceHandler; +import li.strolch.service.api.ServiceResult; +import li.strolch.utils.collections.Paging; + +@Path("books") +public class BooksResource { + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response query(@Context HttpServletRequest request, @QueryParam("query") String query, + @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("20") @QueryParam("limit") int limit) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // open the TX with the certificate, using this class as context + Paging paging; + try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) { + + // perform a book search + paging = new BookSearch() // + .stringQuery(query) // + .search(tx) // + .orderByName(false) // + .toPaging(offset, limit); + } + + return ResponseUtil.toResponse(paging, e -> e.accept(bookToJson())); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response get(@Context HttpServletRequest request, @PathParam("id") String id) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // open the TX with the certificate, using this class as context + try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) { + + // get the book + Resource book = tx.getResourceBy(TYPE_BOOK, id, true); + + // transform to JSON + JsonObject bookJ = book.accept(bookToJson()); + + // return + return ResponseUtil.toResponse(DATA, bookJ); + } + } + + @POST + @Produces(MediaType.APPLICATION_JSON) + public Response create(@Context HttpServletRequest request, String data) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // parse data to JSON + JsonObject jsonData = JsonParser.parseString(data).getAsJsonObject(); + + // instantiate the service with the argument + CreateBookService svc = new CreateBookService(); + JsonServiceArgument arg = svc.getArgumentInstance(); + arg.jsonElement = jsonData; + + // perform the service + ServiceHandler serviceHandler = RestfulStrolchComponent.getInstance().getServiceHandler(); + JsonServiceResult result = serviceHandler.doService(cert, svc, arg); + + // return depending on the result state + if (result.isOk()) + return ResponseUtil.toResponse(DATA, result.getResult()); + return ResponseUtil.toResponse(result); + } + + @PUT + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response update(@Context HttpServletRequest request, @PathParam("id") String id, String data) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // parse data to JSON + JsonObject jsonData = JsonParser.parseString(data).getAsJsonObject(); + + // instantiate the service with the argument + UpdateBookService svc = new UpdateBookService(); + JsonServiceArgument arg = svc.getArgumentInstance(); + arg.objectId = id; + arg.jsonElement = jsonData; + + // perform the service + ServiceHandler serviceHandler = RestfulStrolchComponent.getInstance().getServiceHandler(); + JsonServiceResult result = serviceHandler.doService(cert, svc, arg); + + // return depending on the result state + if (result.isOk()) + return ResponseUtil.toResponse(DATA, result.getResult()); + return ResponseUtil.toResponse(result); + } + + @DELETE + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response remove(@Context HttpServletRequest request, @PathParam("id") String id) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // instantiate the service with the argument + RemoveBookService svc = new RemoveBookService(); + StringServiceArgument arg = svc.getArgumentInstance(); + arg.value = id; + + // perform the service + ServiceHandler serviceHandler = RestfulStrolchComponent.getInstance().getServiceHandler(); + ServiceResult result = serviceHandler.doService(cert, svc, arg); + + // return depending on the result state + return ResponseUtil.toResponse(result); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/LocationsResource.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/LocationsResource.java new file mode 100644 index 0000000..a51ff21 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/rest/LocationsResource.java @@ -0,0 +1,95 @@ +package ${package}.rest; + +import static ${package}.model.Constants.TYPE_LOCATION; +import static ${package}.model.JsonVisitors.locationToJson; +import static li.strolch.rest.StrolchRestfulConstants.DATA; +import static li.strolch.rest.StrolchRestfulConstants.STROLCH_CERTIFICATE; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import ${package}.search.LocationSearch; +import ${package}.service.RemoveLocationService; +import com.google.gson.JsonObject; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.privilege.model.Certificate; +import li.strolch.rest.RestfulStrolchComponent; +import li.strolch.rest.helper.ResponseUtil; +import li.strolch.service.StringServiceArgument; +import li.strolch.service.api.ServiceHandler; +import li.strolch.service.api.ServiceResult; +import li.strolch.utils.collections.Paging; + +@Path("locations") +public class LocationsResource { + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response query(@Context HttpServletRequest request, @QueryParam("query") String query, + @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("20") @QueryParam("limit") int limit) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // open the TX with the certificate, using this class as context + Paging paging; + try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) { + + // perform a book search + paging = new LocationSearch() // + .stringQuery(query) // + .search(tx) // + .orderByName(false) // + .map(l -> l.accept(locationToJson(tx))) // + .toPaging(offset, limit); + } + + return ResponseUtil.toResponse(paging); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response get(@Context HttpServletRequest request, @PathParam("id") String id) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // open the TX with the certificate, using this class as context + try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) { + + // get the book + Resource location = tx.getResourceBy(TYPE_LOCATION, id, true); + + // transform to JSON + JsonObject locationJ = location.accept(locationToJson(tx)); + + // return + return ResponseUtil.toResponse(DATA, locationJ); + } + } + + @DELETE + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + public Response remove(@Context HttpServletRequest request, @PathParam("id") String id) { + + // this is an authenticated method call, thus we can get the certificate from the request: + Certificate cert = (Certificate) request.getAttribute(STROLCH_CERTIFICATE); + + // instantiate the service with the argument + RemoveLocationService svc = new RemoveLocationService(); + StringServiceArgument arg = svc.getArgumentInstance(); + arg.value = id; + + // perform the service + ServiceHandler serviceHandler = RestfulStrolchComponent.getInstance().getServiceHandler(); + ServiceResult result = serviceHandler.doService(cert, svc, arg); + + // return depending on the result state + return ResponseUtil.toResponse(result); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/BookSearch.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/BookSearch.java new file mode 100644 index 0000000..5149440 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/BookSearch.java @@ -0,0 +1,29 @@ +package ${package}.search; + +import static ${package}.model.Constants.*; +import static li.strolch.utils.helper.StringHelper.isEmpty; + +import li.strolch.search.ResourceSearch; + +public class BookSearch extends ResourceSearch { + + public BookSearch() { + types(TYPE_BOOK); + } + + public BookSearch stringQuery(String value) { + if (isEmpty(value)) + return this; + + // split by spaces + value = value.trim(); + String[] values = value.split(" "); + + // add where clauses for id, name and description + where(id().containsIgnoreCase(values) // + .or(name().containsIgnoreCase(values)) // + .or(param(BAG_PARAMETERS, PARAM_TITLE).containsIgnoreCase(values))); + + return this; + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/LocationSearch.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/LocationSearch.java new file mode 100644 index 0000000..74ad40c --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/search/LocationSearch.java @@ -0,0 +1,29 @@ +package ${package}.search; + +import static ${package}.model.Constants.*; +import static li.strolch.utils.helper.StringHelper.isEmpty; + +import li.strolch.search.ResourceSearch; + +public class LocationSearch extends ResourceSearch { + + public LocationSearch() { + types(TYPE_LOCATION); + } + + public LocationSearch stringQuery(String value) { + if (isEmpty(value)) + return this; + + // split by spaces + value = value.trim(); + String[] values = value.split(" "); + + // add where clauses for id, name and description + where(id().containsIgnoreCase(values) // + .or(name().containsIgnoreCase(values)) // + .or(param(PARAM_CITY).containsIgnoreCase(values))); + + return this; + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/CreateBookService.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/CreateBookService.java new file mode 100644 index 0000000..575c1ce --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/CreateBookService.java @@ -0,0 +1,53 @@ +package ${package}.service; + +import static ${package}.model.JsonVisitors.bookToJson; +import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS; + +import ${package}.model.Constants; +import com.google.gson.JsonObject; +import li.strolch.model.Resource; +import li.strolch.model.json.FromFlatJsonVisitor; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.JsonServiceArgument; +import li.strolch.service.JsonServiceResult; +import li.strolch.service.api.AbstractService; + +public class CreateBookService extends AbstractService { + + @Override + protected JsonServiceResult getResultInstance() { + return new JsonServiceResult(); + } + + @Override + public JsonServiceArgument getArgumentInstance() { + return new JsonServiceArgument(); + } + + @Override + protected JsonServiceResult internalDoService(JsonServiceArgument arg) throws Exception { + + // open a new transaction, using the realm from the argument, or the certificate + Resource book; + try (StrolchTransaction tx = openArgOrUserTx(arg)) { + + // get a new book "instance" from the template + book = tx.getResourceTemplate(Constants.TYPE_BOOK); + + // map all values from the JSON object into the new book element + book.accept(new FromFlatJsonVisitor(arg.jsonElement.getAsJsonObject()).ignoreBag(BAG_RELATIONS)); + + // save changes + tx.add(book); + + // notify the TX that it should commit on close + tx.commitOnClose(); + } + + // map the return value to JSON + JsonObject result = book.accept(bookToJson()); + + // and return the result + return new JsonServiceResult(result); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveBookService.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveBookService.java new file mode 100644 index 0000000..a27d864 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveBookService.java @@ -0,0 +1,41 @@ +package ${package}.service; + +import ${package}.model.Constants; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.StringServiceArgument; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceResult; + +public class RemoveBookService extends AbstractService { + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + public StringServiceArgument getArgumentInstance() { + return new StringServiceArgument(); + } + + @Override + protected ServiceResult internalDoService(StringServiceArgument arg) throws Exception { + + // open a new transaction, using the realm from the argument, or the certificate + try (StrolchTransaction tx = openArgOrUserTx(arg)) { + + // get the existing book + Resource book = tx.getResourceBy(Constants.TYPE_BOOK, arg.value, true); + + // save changes + tx.remove(book); + + // notify the TX that it should commit on close + tx.commitOnClose(); + } + + // and return the result + return ServiceResult.success(); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveLocationService.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveLocationService.java new file mode 100644 index 0000000..af95dc2 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/RemoveLocationService.java @@ -0,0 +1,42 @@ +package ${package}.service; + +import static ${package}.model.Constants.TYPE_LOCATION; + +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.StringServiceArgument; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceResult; + +public class RemoveLocationService extends AbstractService { + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + public StringServiceArgument getArgumentInstance() { + return new StringServiceArgument(); + } + + @Override + protected ServiceResult internalDoService(StringServiceArgument arg) throws Exception { + + // open a new transaction, using the realm from the argument, or the certificate + try (StrolchTransaction tx = openArgOrUserTx(arg)) { + + // get the existing book + Resource location = tx.getResourceBy(TYPE_LOCATION, arg.value, true); + + // save changes + tx.remove(location); + + // notify the TX that it should commit on close + tx.commitOnClose(); + } + + // and return the result + return ServiceResult.success(); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/UpdateBookService.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/UpdateBookService.java new file mode 100644 index 0000000..2d1dc7e --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/service/UpdateBookService.java @@ -0,0 +1,59 @@ +package ${package}.service; + +import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS; + +import ${package}.model.Constants; +import com.google.gson.JsonObject; +import li.strolch.model.Resource; +import li.strolch.model.Tags.Json; +import li.strolch.model.json.FromFlatJsonVisitor; +import li.strolch.model.json.StrolchRootElementToJsonVisitor; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.JsonServiceArgument; +import li.strolch.service.JsonServiceResult; +import li.strolch.service.api.AbstractService; +import li.strolch.utils.dbc.DBC; + +public class UpdateBookService extends AbstractService { + + @Override + protected JsonServiceResult getResultInstance() { + return new JsonServiceResult(); + } + + @Override + public JsonServiceArgument getArgumentInstance() { + return new JsonServiceArgument(); + } + + @Override + protected JsonServiceResult internalDoService(JsonServiceArgument arg) throws Exception { + + // verify same book + DBC.PRE.assertEquals("ObjectId and given Id must be same!", arg.objectId, + arg.jsonElement.getAsJsonObject().get(Json.ID).getAsString()); + + // open a new transaction, using the realm from the argument, or the certificate + Resource book; + try (StrolchTransaction tx = openArgOrUserTx(arg)) { + + // get the existing book + book = tx.getResourceBy(Constants.TYPE_BOOK, arg.objectId, true); + + // map all values from the JSON object into the new book element + book.accept(new FromFlatJsonVisitor(arg.jsonElement.getAsJsonObject()).ignoreBag(BAG_RELATIONS)); + + // save changes + tx.update(book); + + // notify the TX that it should commit on close + tx.commitOnClose(); + } + + // map the return value to JSON + JsonObject result = book.accept(new StrolchRootElementToJsonVisitor().flat()); + + // and return the result + return new JsonServiceResult(result); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/RestfulApplication.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/RestfulApplication.java new file mode 100644 index 0000000..ed8763c --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/RestfulApplication.java @@ -0,0 +1,71 @@ +package ${package}.web; + +import static ${package}.web.StartupListener.APP_NAME; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.Priorities; +import java.util.logging.Level; + +import ${package}.rest.BooksResource; +import li.strolch.rest.RestfulStrolchComponent; +import li.strolch.rest.StrolchRestfulExceptionMapper; +import li.strolch.rest.endpoint.*; +import li.strolch.rest.filters.*; +import org.glassfish.jersey.logging.LoggingFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.ServerProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ApplicationPath("rest") +public class RestfulApplication extends ResourceConfig { + + private static final Logger logger = LoggerFactory.getLogger(RestfulApplication.class); + + public RestfulApplication() { + setApplicationName(APP_NAME); + + // add project resources by package name + packages(BooksResource.class.getPackage().getName()); + + // strolch services + register(AuthenticationService.class); + register(StrolchJobsResource.class); + register(ReportResource.class); + register(ControlResource.class); + register(EnumQuery.class); + register(Inspector.class); + register(UserSessionsService.class); + register(PrivilegeUsersService.class); + register(PrivilegeRolesService.class); + register(PrivilegePoliciesService.class); + register(OperationsLogResource.class); + register(VersionQuery.class); + + // filters + register(AuthenticationRequestFilter.class, Priorities.AUTHENTICATION); + register(AccessControlResponseFilter.class); + register(AuthenticationResponseFilter.class); + register(HttpCacheResponseFilter.class); + + // log exceptions and return them as plain text to the caller + register(StrolchRestfulExceptionMapper.class); + + // the JSON generated is in UTF-8 + register(CharsetResponseFilter.class); + + RestfulStrolchComponent restfulComponent = RestfulStrolchComponent.getInstance(); + if (restfulComponent.isRestLogging()) { + register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), + Level.SEVERE, LoggingFeature.Verbosity.PAYLOAD_ANY, Integer.MAX_VALUE)); + + property(ServerProperties.TRACING, "ALL"); + property(ServerProperties.TRACING_THRESHOLD, "TRACE"); + } + + logger.info( + "Initialized REST application " + getApplicationName() + " with " + getClasses().size() + " classes, " + + getInstances().size() + " instances, " + getResources().size() + " resources and " + + getProperties().size() + " properties"); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/StartupListener.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/StartupListener.java new file mode 100644 index 0000000..c4ed741 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/java/web/StartupListener.java @@ -0,0 +1,67 @@ +package ${package}.web; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; +import java.io.InputStream; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.util.ContextInitializer; +import li.strolch.agent.api.StrolchAgent; +import li.strolch.agent.api.StrolchBootstrapper; +import li.strolch.utils.helper.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.impl.StaticLoggerBinder; + +@WebListener +public class StartupListener implements ServletContextListener { + + private static final Logger logger = LoggerFactory.getLogger(StartupListener.class); + public static final String APP_NAME = "eSyTest"; + + private StrolchAgent agent; + + @Override + public void contextInitialized(ServletContextEvent sce) { + + logger.info("Starting " + APP_NAME + "..."); + long start = System.currentTimeMillis(); + try { + String bootstrapFileName = "/" + StrolchBootstrapper.FILE_BOOTSTRAP; + InputStream bootstrapFile = getClass().getResourceAsStream(bootstrapFileName); + StrolchBootstrapper bootstrapper = new StrolchBootstrapper(StartupListener.class); + this.agent = bootstrapper.setupByBootstrapFile(StartupListener.class, bootstrapFile); + this.agent.initialize(); + this.agent.start(); + } catch (Throwable e) { + logger.error("Failed to start " + APP_NAME + " due to: " + e.getMessage(), e); + throw e; + } + + long took = System.currentTimeMillis() - start; + logger.info("Started " + APP_NAME + " in " + (StringHelper.formatMillisecondsDuration(took))); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + try { + new ContextInitializer((LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory()).autoConfig(); + } catch (Exception e) { + System.err.println("Failed to reconfigure logging..."); + e.printStackTrace(System.err); + } + + if (this.agent != null) { + logger.info("Destroying " + APP_NAME + "..."); + try { + this.agent.stop(); + this.agent.destroy(); + } catch (Throwable e) { + logger.error("Failed to stop " + APP_NAME + " due to: " + e.getMessage(), e); + throw e; + } + } + logger.info("Destroyed " + APP_NAME); + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/ENV.properties b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/ENV.properties new file mode 100644 index 0000000..8212444 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/ENV.properties @@ -0,0 +1 @@ +ENV_STROLCH=${strolch.env} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/StrolchBootstrap.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/StrolchBootstrap.xml new file mode 100644 index 0000000..4e7f495 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/StrolchBootstrap.xml @@ -0,0 +1,32 @@ + + + + + + + + dev + + + runtime + + + + + + + + + + + + + ${project.basedir}/runtime + dev + + + + /absolute/path/to/runtime + test + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/appVersion.properties b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/appVersion.properties new file mode 100644 index 0000000..a4594a2 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/appVersion.properties @@ -0,0 +1,6 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +artifactVersion=${project.version} +scmRevision=${buildNumber} +scmBranch=${scmBranch} +buildTimestamp=${buildTimestamp} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/logback.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/logback.xml new file mode 100644 index 0000000..fcc71f0 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + + + %d [%thread] %-5level %class{36}:%line %method - %msg%n + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.bowerrc b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.bowerrc new file mode 100755 index 0000000..5773025 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "app/bower_components" +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.gitignore b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.gitignore new file mode 100644 index 0000000..20efec5 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/.gitignore @@ -0,0 +1,4 @@ +package-lock.json +node_modules/ +app/bower_components/ +www/ \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/.gitignore b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/.gitignore new file mode 100644 index 0000000..b34062e --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/.gitignore @@ -0,0 +1,2 @@ +/classes/ +/lib/ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..8f93aec --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + + + org.apache.tomcat.websocket.textBufferSize + 1048576 + + + org.apache.tomcat.websocket.binaryBufferSize + 1048576 + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/CustomWeb.js b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/CustomWeb.js new file mode 100644 index 0000000..1b14177 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/CustomWeb.js @@ -0,0 +1,12 @@ +CustomWeb = { + // +}; + +(function () { + var basePath = window.location.pathname.substr(0, window.location.pathname.indexOf('/index.html')); + basePath = basePath.substr(0, basePath.lastIndexOf('/')); + CustomWeb.baseRestPath = basePath + '/rest'; + console.log('Base REST Path is ' + CustomWeb.baseRestPath); + CustomWeb.baseWsPath = basePath + '/websocket'; + console.log('Base WebSocket Path is ' + CustomWeb.baseWsPath); +})(); diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Bold.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Bold.ttf new file mode 100644 index 0000000..c2293d5 Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Bold.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-BoldItalic.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-BoldItalic.ttf new file mode 100644 index 0000000..ce6e784 Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-BoldItalic.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Italic.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Italic.ttf new file mode 100644 index 0000000..a599244 Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Italic.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Light.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Light.ttf new file mode 100644 index 0000000..b310d15 Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Light.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-LightItalic.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-LightItalic.ttf new file mode 100644 index 0000000..ad0741b Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-LightItalic.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Medium.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Medium.ttf new file mode 100644 index 0000000..7340a40 Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Medium.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-MediumItalic.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-MediumItalic.ttf new file mode 100644 index 0000000..36ac1ae Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-MediumItalic.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Regular.ttf b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Regular.ttf new file mode 100644 index 0000000..f98a2da Binary files /dev/null and b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/font/Ubuntu-Regular.ttf differ diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/index.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/index.html new file mode 100644 index 0000000..ce2fb14 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/index.html @@ -0,0 +1,42 @@ + + + + + ${appName} + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-app-behavior.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-app-behavior.html new file mode 100644 index 0000000..84016ef --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-app-behavior.html @@ -0,0 +1,199 @@ + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-component-behavior.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-component-behavior.html new file mode 100644 index 0000000..cd27283 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/behaviors/c-component-behavior.html @@ -0,0 +1,30 @@ + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-drawer.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-drawer.html new file mode 100644 index 0000000..38ff655 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-drawer.html @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-main.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-main.html new file mode 100644 index 0000000..c4845cc --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-main.html @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-pages.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-pages.html new file mode 100644 index 0000000..2e57cc6 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/main/c-pages.html @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/styles/c-app-style.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/styles/c-app-style.html new file mode 100644 index 0000000..08da0f7 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/styles/c-app-style.html @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/utils/c-app-routing.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/utils/c-app-routing.html new file mode 100644 index 0000000..c80e0c2 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/utils/c-app-routing.html @@ -0,0 +1,148 @@ + + + + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-books.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-books.html new file mode 100644 index 0000000..b3ed264 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-books.html @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-locations.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-locations.html new file mode 100644 index 0000000..6b511a0 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-demo-locations.html @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-view404.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-view404.html new file mode 100644 index 0000000..e1e1914 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/views/c-view404.html @@ -0,0 +1,46 @@ + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-books-table.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-books-table.html new file mode 100644 index 0000000..1e5bced --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-books-table.html @@ -0,0 +1,138 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-detail.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-detail.html new file mode 100644 index 0000000..44ca3c7 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-detail.html @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-table.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-table.html new file mode 100644 index 0000000..660587c --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/app/src/widgets/c-demo-location-table.html @@ -0,0 +1,133 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/bower.json b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/bower.json new file mode 100644 index 0000000..c4ba2f7 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/bower.json @@ -0,0 +1,41 @@ +{ + "name": "${artifactId}", + "authors": [ + "Robert von Burg " + ], + "private": true, + "dependencies": { + "strolchjs": "strolch-li/strolchjs#^0.5.3", + "strolch-wc-styles": "strolch-li/strolch-wc-styles#^0.4.8", + "strolch-wc-auth": "strolch-li/strolch-wc-auth#^0.9.9", + "strolch-wc-badge": "strolch-li/strolch-wc-badge#^0.1.4", + "strolch-wc-notification": "strolch-li/strolch-wc-notification#^0.1.1", + "strolch-wc-inspector": "strolch-li/strolch-wc-inspector#^0.23.6", + "strolch-wc-util-behavior": "strolch-li/strolch-wc-util-behavior#^0.3.7", + "strolch-wc-localize-behavior": "strolch-li/strolch-wc-localize-behavior#^1.1.15", + "strolch-wc-debounced-input": "strolch-li/strolch-wc-debounced-input#^0.1.6", + "strolch-wc-dialog-button": "strolch-li/strolch-wc-dialog-button#^0.1.7", + "strolch-wc-information-dialog": "strolch-li/strolch-wc-information-dialog#^0.1.14", + "strolch-wc-parameter-input": "strolch-li/strolch-wc-parameter-input#^0.1.5", + "strolch-wc-reports": "strolch-li/strolch-wc-reports#^0.5.3", + "strolch-wc-paging": "strolch-li/strolch-wc-paging#^0.1.7", + "strolch-wc-ws-observer": "strolch-li/strolch-wc-ws-observer#^0.2.11", + "strolch-wc-tree": "strolch-li/strolch-wc-tree#^0.2.6", + + "polymer": "Polymer/polymer#^1.12.0", + "iron-pages": "PolymerElements/iron-pages#^1.0.9", + "font-awesome": "FortAwesome/Font-Awesome#^4.7.0", + "app-route": "PolymerElements/app-route#^1.0.1", + "app-layout": "PolymerElements/app-layout#^1.0.1", + "paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^1.5.1", + "paper-menu": "PolymerElements/paper-menu#^1.3.0", + "paper-icon-button": "PolymerElements/paper-icon-button#^1.1.6", + "paper-header-panel": "PolymerElements/paper-header-panel#^1.1.7", + "paper-input": "PolymerElements/paper-input#^1.1.24", + "paper-radio-group": "PolymerElements/paper-radio-group#^1.2.2", + "paper-toggle-button": "PolymerElements/paper-toggle-button#^1.3.0", + "paper-toast": "PolymerElements/paper-toast#^1.3.1" + }, + "devDependencies": { + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/gulpfile.js b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/gulpfile.js new file mode 100644 index 0000000..017ff6a --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/gulpfile.js @@ -0,0 +1,93 @@ +const gulp = require('gulp'); +const $ = require('gulp-load-plugins')(); +const merge = require('merge-stream'); +const del = require('del'); + +// temporary until gulp 4.0 is released +const runSequence = require('run-sequence'); + +const vulcanize = require('gulp-vulcanize'); +const minify = require('gulp-minify'); +const crisper = require('gulp-crisper'); +const shell = require('gulp-shell'); +const rename = require("gulp-rename"); +const replace = require('gulp-replace'); + +// Copy All Files At The Root Level +gulp.task('copy', function () { + + var svg = gulp.src([ + 'app/**/*.svg', '!app/bower_components/**/hero.svg', '!app/bower_components/mocha/**/*', '!app/bower_components/**/{demo,test,site}/**/*' + ]) + .pipe(gulp.dest('www/')); + + var font = gulp.src([ + 'app/font/*' + ]) + .pipe(gulp.dest('www/font/')); + + var imgs = gulp.src([ + 'app/img/*.svg', 'app/img/*.ico', 'app/img/*.png', 'app/img/*.gif' + ]) + .pipe(gulp.dest('www/img/')); + + var locales = gulp.src([ + 'app/bower_components/**/locales.json' + ]) + .pipe(gulp.dest('www/bower_components/')); + + var app_files = gulp.src([ + 'app/bower.json', 'app/manifest.json', 'app/locales.json', '**/moment.min.js' + ]) + .pipe(gulp.dest('www/')); + + var js = gulp.src([ + 'src/**/*' + ]) + .pipe(gulp.dest('js')); + + return merge(svg, font, imgs, locales, app_files, js) + .pipe($.size({title: 'Copy app files to dist dir:'})); +}); + +gulp.task('vulcanize', function () { + return gulp.src('app/index.html') + .pipe(vulcanize({ + stripComments: true, + inlineScripts: true, + inlineCss: true + })) + .pipe(replace('', '')) + .pipe(replace("font-family: 'Roboto', 'Noto', sans-serif;", "font-family: 'Ubuntu-local', sans-serif;")) + .pipe(crisper()) + .pipe(gulp.dest('www/')); +}); + +gulp.task('compress', function () { + return gulp.src('www/index.js') + .pipe(minify({})) + .pipe(gulp.dest('www/')) +}); + +// Clean Output Directory +gulp.task('clean-www', del.bind(null, ['www/'])); + +// Remove unneeded files +gulp.task('del-files', del.bind(null, ['www/index-min.js'])); +gulp.task('move-indexjs-js', function () { + return gulp.src('./www/index-min.js') // + .pipe(rename('index.js')) + .pipe(gulp.dest('./www/')); +}); + +// bower install +gulp.task('bower', shell.task('bower install')); + +// Build Production Files, the Default Task +gulp.task('prepare', ['bower'], function (cb) { + runSequence('clean-www', cb); +}); + +gulp.task('default', ['prepare'], function (cb) { + runSequence('copy', 'vulcanize', 'compress', 'del-files', cb); +}); diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/index.html b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/index.html new file mode 100644 index 0000000..a1ff9e7 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/index.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/locales.json b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/locales.json new file mode 100644 index 0000000..f7043f7 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/locales.json @@ -0,0 +1,161 @@ +{ + "de": { + "appTitle": "${appName}", + "demo-locations": "Demo Locations", + "demo-books": "Demo Books", + "title": "Title", + "author": "Author", + "logout": "Ausloggen", + "language": "Sprache", + "reports": "Berichte", + "operations-log": "Betriebsnachrichten", + "jobs": "Jobs", + "sessions": "Sitzungen", + "users": "Benutzer", + "roles": "Rollen", + "control": "Control", + "inspector": "Inspector", + "newVersionAvailableRefreshRequired": "Eine neue Version steht zur Verfügung", + "refresh": "Aktualisieren", + "close": "Schliessen", + "cancel": "Abbrechen", + "ok": "Ok", + "reconnect": "Wiederhestellen", + "serverNotAvailable": "Server nicht erreichbar", + "serverNotAvailableMsg": "Die Verbindung zum Server ist zur Zeit unterbrochen", + "privilegeDenied": "Aktion verweigert", + "privilegeDeniedText": "Die Aktion wurde verweigert.", + "sessionInvalid": "Sitzung ungültig", + "sessionInvalidConfirmNavToLogin": "Die Sitzung ist abgelaufen oder ungültig. Bitte neu anmelden.", + "sessionInvalidLoggingBackIn": "Die Sitzung ist ungültig oder abgelaufen, automatische Anmeldung wird ausgeführt...", + "errorOccurred": "Ein Fehler ist aufgetreten", + "login": "Login", + "i18n-editor": "Internationalisierungs Editor", + "user": "Benutzer", + "mode": "Modus", + "enable": "Aktivieren", + "disable": "Deaktivieren", + "status": "Status", + "id": "ID", + "deleted": "Gelöscht", + "date": "Datum", + "Created": "Erstellt", + "Planning": "In Planung", + "Planned": "Geplant", + "Execution": "In Ausführung", + "Warning": "Warnung", + "Error": "Fehler", + "Executed": "Ausgeführt", + "Closed": "Geschlossen", + "keepAlive": "Eingeloggt bleiben", + "systemAction.failed": "Systembefehl {action} fehlgeschlagen: {reason}", + "enabled": "Aktiv", + "severity": "Schweregrad", + "true": "Ja", + "false": "Nein", + "Info": "Information", + "Exception": "Ausnahme", + "clearInactiveMessages": "Inaktive Meldungen entfernen", + "clearInactiveMessagesConfirm": "Sollen alle inaktive Meldungen entfernt werden?", + "executionDate": "Ausführungsdatum", + "orderDate": "Auftragsdatum", + "info": "Information", + "agent.service.failed.access.denied": "Benutzer {user} darf Service {service} nicht ausführen", + "agent.query.failed.access.denied": "Benutzer {user} darf Abfrage {query} nicht ausführen", + "agent.search.failed.access.denied": "Benutzer {user} darf Suche {search} nicht ausführen" + }, + "en": { + "agent.service.failed.access.denied": "User {user} may not perform service {service}", + "agent.query.failed.access.denied": "User {user} may not perform query {query}", + "agent.search.failed.access.denied": "User {user} may not perform search {search}", + "demo-locations": "Demo Locations", + "demo-books": "Demo Books", + "title": "Titel", + "author": "Author", + "logout": "Logout", + "info": "Information", + "keepAlive": "Stay logged in", + "appTitle": "${appName}", + "language": "Language", + "reports": "Reports", + "operations-log": "Operation Logs", + "jobs": "Jobs", + "sessions": "Sessions", + "users": "Users", + "roles": "Roles", + "control": "Control", + "inspector": "Inspector", + "newVersionAvailableRefreshRequired": "A new version is available", + "refresh": "Refresh", + "close": "Close", + "cancel": "Cancel", + "ok": "Ok", + "reconnect": "Reconnect", + "serverNotAvailable": "Server not available", + "serverNotAvailableMsg": "The connection to the server is currently not available", + "privilegeDenied": "Action denied", + "privilegeDeniedText": "The action has been denied", + "sessionInvalid": "Session Invalid", + "sessionInvalidConfirmNavToLogin": "The session has expired or is invalid. Please logon again.", + "sessionInvalidLoggingBackIn": "The session is invalid or has expired, automatic logon has commenced...", + "enabled": "Active", + "severity": "Severity", + "true": "Yes", + "false": "No", + "Info": "Information", + "Exception": "Exception", + "clearInactiveMessages": "Remove inactive messages", + "clearInactiveMessagesConfirm": "Should all inactive messages be removed?", + "errorOccurred": "An error occurred", + "systemAction.failed": "SystemAction {action} failed: {reason}", + "Created": "Created", + "Planning": "Planning", + "Planned": "Planned", + "Execution": "Execution", + "Warning": "Warning", + "Error": "Error", + "Executed": "Executed", + "Closed": "Closed", + "date": "Date", + "deleted": "Deleted", + "id": "ID", + "status": "Status", + "enable": "Enable", + "disable": "Disable", + "mode": "Mode", + "user": "User", + "i18n-editor": "Internationalization editor", + "login": "Login" + }, + "fr": { + "appTitle": "${appName}", + "demo-locations": "Demo Locations", + "demo-books": "Demo Books", + "language": "Langue", + "reports": "Rapports", + "operations-log": "Logs", + "jobs": "Jobs", + "sessions": "Sessions", + "users": "Utilisateurs", + "roles": "Rôles", + "control": "Controle", + "inspector": "Inspecteur", + "newVersionAvailableRefreshRequired": "Une nouvelle version est disponible!", + "refresh": "Actualiser", + "close": "Fermer", + "cancel": "Annuler", + "ok": "Ok", + "reconnect": "Reconnecter", + "serverNotAvailable": "Server indisponible", + "serverNotAvailableMsg": "La connexion au serveur est indisponible", + "privilegeDenied": "Action refusée", + "privilegeDeniedText": "L'action a été refusée.", + "sessionInvalid": "Session invalide", + "sessionInvalidConfirmNavToLogin": "La session a expirée, veuillez vous reconnecter.", + "sessionInvalidLoggingBackIn": "La session a expirée, reconnexion automatiqque...", + "errorOccurred": "Une erreur s'est produite", + "agent.service.failed.access.denied": "Utilisateur {user} ne peut exécuter le service {service}", + "agent.query.failed.access.denied": "Utilisateur {user} ne peut exécuter la demande {query}", + "agent.search.failed.access.denied": "Utilisateur {user} ne peut exécuter la recherche {search}" + } +} \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/package.json b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/package.json new file mode 100644 index 0000000..a261ef6 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/main/webapp/package.json @@ -0,0 +1,37 @@ +{ + "name": "${artifactId}", + "description": "${appName}", + "version": "0.1.0", + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/strolch-li/strolch.git" + }, + "author": "Robert von Burg ", + "license": "Proprietary", + "keywords": [], + "bugs": { + "url": "https://github.com/strolch-li/strolch/issues" + }, + "homepage": "https://www.strolch.li", + "devDependencies": { + "bower": "^1.8.8", + "del": "^2.2.2", + "gulp": "^3.9.1", + "gulp-crisper": "^1.1.0", + "gulp-imagemin": "^7.1.0", + "gulp-load-plugins": "^1.4.0", + "gulp-minify": "0.0.15", + "gulp-rename": "^1.2.2", + "gulp-shell": "^0.8.0", + "gulp-size": "^2.1.0", + "gulp-vulcanize": "^6.1.0", + "gulp-replace": "^1.1.3", + "merge-stream": "^1.0.0", + "run-sequence": "^1.2.2", + "vulcanize": "^1.15.3" + }, + "scripts": { + "postinstall": "bower install" + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/java/test/SimpleTest.java b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/java/test/SimpleTest.java new file mode 100644 index 0000000..acc5d14 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/java/test/SimpleTest.java @@ -0,0 +1,50 @@ +package ${package}.test; + +import static ${package}.model.Constants.TYPE_BOOK; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.privilege.model.Certificate; +import li.strolch.testbase.runtime.RuntimeMock; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class SimpleTest { + + private static final String SRC_PATH = "src/test/resources/runtime-SimpleTest"; + private static final String TARGET_PATH = "target/" + SimpleTest.class; + + private static RuntimeMock runtimeMock; + private static Certificate certificate; + + @BeforeClass + public static void beforeClass() { + runtimeMock = new RuntimeMock().mockRuntime(TARGET_PATH, SRC_PATH); + runtimeMock.startContainer(); + certificate = runtimeMock.loginTest(); + } + + @AfterClass + public static void afterClass() { + + if (certificate != null) + runtimeMock.logout(certificate); + + if (runtimeMock != null) + runtimeMock.destroyRuntime(); + } + + @Test + public void shouldLoadIntoRealm() { + + try (StrolchTransaction tx = runtimeMock.openUserTx(certificate, true)) { + + Resource book = tx.getResourceBy(TYPE_BOOK, "book1", true); + assertTrue(book.hasParameter("author")); + assertEquals("Roger Penrose", book.getParameter("author", true).getValue()); + } + } +} diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/logback.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/logback.xml new file mode 100644 index 0000000..fcc71f0 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + + + %d [%thread] %-5level %class{36}:%line %method - %msg%n + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml new file mode 100644 index 0000000..c0e3aba --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeConfig.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml new file mode 100644 index 0000000..69c9408 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeRoles.xml @@ -0,0 +1,90 @@ + + + + + true + + + true + + + true + + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + true + + + true + + + true + + + li.strolch.runtime.privilege.StrolchSystemAction + li.strolch.runtime.privilege.StrolchSystemActionWithResult + li.strolch.persistence.postgresql.PostgreSqlSchemaInitializer + + + Persist + GetCertificates + PersistSessions + + + true + + + true + + + true + + + true + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml new file mode 100644 index 0000000..1215921 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/PrivilegeUsers.xml @@ -0,0 +1,22 @@ + + + + SYSTEM + + agent + + + + + Application + Administrator + ENABLED + en-GB + + AppUser + + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml new file mode 100644 index 0000000..b87be7f --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchConfiguration.xml @@ -0,0 +1,50 @@ + + + + + ${appName} + + en + true + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PrivilegeHandler + + defaultRealm + TRANSIENT + Model.xml + true + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + true + + + + PostInitializer + li.strolch.agent.api.PostInitializer + ${package}.components.PostInitializer + ServiceHandler + + + + + diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml new file mode 100644 index 0000000..cba3b97 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/config/StrolchPolicies.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml new file mode 100644 index 0000000..f81c984 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/data/Model.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore new file mode 100644 index 0000000..7385672 --- /dev/null +++ b/li.strolch.mvn.archetype.webapp/src/main/resources/archetype-resources/src/test/resources/runtime-SimpleTest/temp/.gitignore @@ -0,0 +1 @@ +/sessions.dat diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4474319 --- /dev/null +++ b/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + li.strolch + li.strolch-maven-archetypes + 0.1.0-SNAPSHOT + + li.strolch-maven-archetypes + Module build for strolch maven archetypes + pom + http://www.strolch.li + 2022 + + + Github Issues + https://github.com/strolch-li/strolch/issues + + + + scm:git:https://github.com/strolch-li/strolch-maven-archetypes.git + scm:git:https://github.com/strolch-li/strolch-maven-archetypes.git + https://github.com/strolch-li/strolch-maven-archetypes + + + + + Apache License 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + Strolch + http://www.strolch.li + + + + + eitch + Robert von Burg + eitch@eitchnet.ch + http://www.eitchnet.ch + + architect + developer + + +1 + + + + + UTF-8 + yyyy-MM-dd HH:mm:ss + ${maven.build.timestamp} + 3.2.0 + 3.2.0 + + + + li.strolch.mvn.archetype.main + li.strolch.mvn.archetype.webapp + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + ${project.build.sourceEncoding} + + + + + + + +