Skip to content

Commit

Permalink
Merge pull request #51 from rwth-acis/develop
Browse files Browse the repository at this point in the history
New release v0.7.0
  • Loading branch information
hexTileX authored Sep 8, 2017
2 parents 5b51b9e + e543c1e commit 48f232f
Show file tree
Hide file tree
Showing 40 changed files with 1,690 additions and 575 deletions.
3 changes: 1 addition & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<classpathentry kind="lib" path="service/commons-pool2-2.2.jar"/>
<classpathentry kind="lib" path="service/emoji-java-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/FreePastry-2.1.1.jar"/>
<classpathentry kind="lib" path="service/gson-2.3.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/hk2-api-2.5.0-b05.jar"/>
Expand Down Expand Up @@ -63,7 +62,7 @@
<classpathentry kind="lib" path="lib/las2peer-web-connector-0.6.7.jar"/>
<classpathentry kind="lib" path="lib/mail-1.4.7.jar"/>
<classpathentry kind="lib" path="lib/mimepull-1.8.jar"/>
<classpathentry kind="lib" path="service/mysql-connector-java-5.1.6.jar"/>
<classpathentry kind="lib" path="service/mysql-connector-java-6.0.5.jar"/>
<classpathentry kind="lib" path="lib/nimbus-jose-jwt-4.0.jar"/>
<classpathentry kind="lib" path="lib/oauth2-oidc-sdk-4.17.jar"/>
<classpathentry kind="lib" path="lib/osgi-resource-locator-1.0.1.jar"/>
Expand Down
50 changes: 34 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ Over the last years it turned out that people want more lightweight and mobile-f

So briefly what is Requirement Bazaar? It is a web application that provides a user-friendly, yet developer usable way, how end-users and developers can share ideas/requirement/problems about a certain app.

We also provide a modern webcomponent frontend for this service which you can find also on **[<i class="icon-link "></i>Github](https://github.com/rwth-acis/RequirementsBazaar-WebFrontend)**.

The service is under development. You can participate by creating pull requests or by discussing ideas and requirements inside **[<i class="icon-link "></i>Requirements-Bazaar](https://requirements-bazaar.org/projects/2/categories/143)**.

More information about our microservice ecosystem is explained in our **[<i class="icon-link "></i>Requirements-Bazaar wiki on Github](https://github.com/rwth-acis/RequirementsBazaar/wiki)**.

----------

Service Documentation
-------------------
We use **[<i class="icon-link "></i>Swagger](http://swagger.io/specification/)** for documenting this microservice. You can use **[<i class="icon-link "></i>Swagger UI](http://swagger.io/swagger-ui/)** to inspect the API.
In the future we want to deploy our own Swagger UI instance which you can use to check and use the API. Until then please use the **[<i class="icon-link "></i>Swagger petstore instance](http://petstore.swagger.io/)**.
Open the Swagger UI petstore demo, enter the APi endpoint you want to inspect and press explore. Of course the microservice instance you want to inspect needs to run. At the moment you can not authorize yourself, but we are working on this feature.
Please use our deployed **[<i class="icon-link "></i>Swagger UI instance](https://requirements-bazaar.org/docs)** to inspect our API. You can authorize yourself via Oauth 2.0 by clicking at the `Authorize` button at the top. After you are authorized you can try out all the API calls directly from Swagger UI.
To try out one API call open one method, fill the parameters and click `Try it out!`. The Swagger UI instance is connected to our development environment where we test nex features. So feel free to play around.

API documentation endpoints:

Expand All @@ -27,9 +33,7 @@ Technology
-------------------
Requirements bazaar itself is a web application, which is separated to a client-only side and a back-end side. This GitHub repo holds the codebase of the back-end side only. If you are looking for the front-end, take a look at this GitHub project: **[<i class="icon-link "></i>Requirement Bazaar Web Frontend](https://github.com/rwth-acis/RequirementsBazaar-WebFrontend)**

The backend is built on Java technologies. As a service framework we use our in-house developed **[<i class="icon-link "></i>las2peer](https://github.com/rwth-acis/LAS2peer)** project. For persisting our data we use MySQL database and jOOQ to access it. User input validation is done using Jodd Vtor library and for serializing our data into JSON format, we use GSON library.

----------
The backend is built on Java technologies. As a service framework we use our in-house developed **[<i class="icon-link "></i>las2peer](https://github.com/rwth-acis/LAS2peer)** project. For persisting our data we use MySQL database and jOOQ to access it. User input validation is done using Jodd Vtor library and for serializing our data into JSON format, we use the Jackson library.

Dependencies
-------------------
Expand All @@ -42,15 +46,15 @@ In order to be able to run this service project the following components should
How to set up the database
-------------------
1. `git clone` this repo
2. create a new database called `reqbaz`, possibly with UTF-8 collation
3. Run the SQL commands in the file `\etc\ReqBaz_create.sql`
This will create the tables and relations between them.
4. If you need sample data run the file `\etc\ReqBaz_demo_data_FULL.sql` if not run: `\etc\ReqBaz_demo_data.sql`
5. To configure your database access look at the [Configuration](#configuration) section
2. To configure your database access look at the [Configuration](#configuration) section
3. Compile the project with `ant`
4. Create a new database called `reqbaz`, possibly with UTF-8 collation
5. Run `ant migrate-db` to create your db schema or migrate to a newer version while updating your service
6. If you need sample data run the file `\etc\add_reqbaz_demo_data.sql` or `\etc\add_reqbaz_demo_data_full.sql`

Configuration
-------------------
You need to configure this service to work with your own specific environment. Here are the list of configuration files and their short description:
You need to configure this service to work with your own specific environment. Here is the list of configuration variables:

`\etc\de.rwth.dbis.acis.bazaar.service.BazaarService.properties`:
- `dbUserName`: A database user's name, which will be used to access the database
Expand All @@ -59,18 +63,23 @@ You need to configure this service to work with your own specific environment. H
- `land`: Default language setting
- `country`: Default country setting
- `baseURL`: Base URL this service runs on
- `frontendBaseURL` Base URL for the frontend which uses Requirements-Bazaar service
- `activityTrackerService` p2p microservice name of the las2peer activity tracker. Leave this field empty if no las2peer activity tracker is used. (example: `de.rwth.dbis.acis.activitytracker.service.ActivityTrackerService@0.2`)
- `smtpServer` SMTP server to send email notifications to users. Leave this field empty if no email notification is used.
- `emailFromAddress` Email from address which is used for email notifications to users. Leave this field empty if no email notification is used.
- `frontendBaseURL`: Base URL for the frontend which uses Requirements-Bazaar service
- `activityTrackerService`: p2p microservice name of the las2peer activity tracker. Leave this field empty if no las2peer activity tracker is used. (example: `de.rwth.dbis.acis.activitytracker.service.ActivityTrackerService@0.2`)
- `smtpServer`: SMTP server to send email notifications to users. Leave this field empty if no email notification is used.
- `emailFromAddress`: Email from address which is used for email notifications to users. Leave this field empty if no email notification is used.
- `monitor`: Boolean value for logging calls to MobSOS data processing

For other configuration settings, check the **[<i class="icon-link "></i>las2peer](https://github.com/rwth-acis/LAS2peer)** project.

Build
-------------------
For build management we use Ant. To build the cloned code, please using a console/terminal navigate to the home directory, where the build.xml file is located and run the following commands:

1. `ant`
- `ant`

You can also generate a bundled jar with all the dependencies with the command

- `ant jar-big`

How to run
-------------------
Expand All @@ -87,3 +96,12 @@ How to run
1. `git clone` this repo
2. `docker build -t rwthacis/reqbaz-service`
3. `docker run -i -t --rm -v "pwd":/build rwthacis/reqbaz-service`

----------

Troubleshooting & FAQ
-------------------
- I get Java encryption errors: Did you install Java Cryptography Extension?
- I can not run the start script: Check if you have OS permission to run the file.
- The service does not start: Check if all jars in the lib and service folder are readable.
- The start script seems broken: Check if the start script has the correct encoding. If you ran the service on Unix use `dos2unix` to change the encoding.
44 changes: 40 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<project name="RequirementsBazaar" default="all" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<project name="RequirementsBazaar" default="all" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:flyway="antlib:org.flywaydb.ant">

<property file="etc/ant_configuration/user.properties"/>
<property file="etc/ant_configuration/service.properties"/>

<property file="etc/de.rwth.dbis.acis.bazaar.service.BazaarService.properties"/>

<property name="startup" location="etc/startup"/>

<property name="user_agent1.path" value="${startup}/agent-user-${las2peer_user.name}.xml"/>
Expand All @@ -16,6 +19,7 @@
<property name="service" location="service"/>

<property name="tmp.classes" location="${tmp}/classes"/>
<property name="tmp.bundle" location="${tmp}/bundle"/>
<property name="tmp.junit" location="${tmp}/test"/>

<property name="export" location="export"/>
Expand Down Expand Up @@ -68,6 +72,7 @@
</ivy:settings>
<ivy:retrieve type="jar, bundle" conf="platform" pattern="${lib}/[artifact]-[revision].[ext]"/>
<ivy:retrieve type="jar, bundle" conf="bundle" pattern="${service}/[artifact]-[revision].[ext]"/>
<ivy:retrieve type="jar, bundle" conf="bundle" pattern="${tmp.bundle}/[artifact]-[revision].[ext]"/>
</target>


Expand All @@ -80,6 +85,7 @@
<target name="init_general">
<tstamp/>
<mkdir dir="${tmp}"/>
<mkdir dir="${tmp}.bundle"/>
<mkdir dir="${export}"/>
<mkdir dir="${startup}"/>
<mkdir dir="${log}"/>
Expand Down Expand Up @@ -142,7 +148,7 @@
# it starts a LAS2peer node providing the service '${service.name}.${service.class}' of this project
# pls execute it from the root folder of your deployment, e. g. ./bin/start_network.sh

java -cp "lib/*" i5.las2peer.tools.L2pNodeLauncher -p 9011 uploadStartupDirectory startService\(\'${service.name}.${service.class}@${service.version}\',\'${service.passphrase}\'\) startWebConnector interactive
java -cp "lib/*" i5.las2peer.tools.L2pNodeLauncher -p 9011 uploadStartupDirectory startService\(\'${service.name}.${service.class}@${service.version}\',\'${service.passphrase}\'\) startWebConnector interactive
</echo>
<echo file="${basedir}/bin/start_network.bat" append="false">:: this script is autogenerated by 'ant
startscripts'
Expand All @@ -155,7 +161,7 @@
set BASE=%CD%
set CLASSPATH="%BASE%/lib/*;"

java -cp %CLASSPATH% i5.las2peer.tools.L2pNodeLauncher -p 9011 uploadStartupDirectory startService('${service.name}.${service.class}@${service.version}','${service.passphrase}') startWebConnector interactive
java -cp %CLASSPATH% i5.las2peer.tools.L2pNodeLauncher -p 9011 uploadStartupDirectory startService('${service.name}.${service.class}@${service.version}','${service.passphrase}') startWebConnector interactive

pause
</echo>
Expand All @@ -177,6 +183,18 @@
</copy>
</target>

<!-- Generate Jars ncluding all deps -->
<target name="jar-big" depends="compile_main" description="--> build service jar including all deps">
<jar jarfile="${service}/${service.name}-${service.version}.jar">
<fileset dir="${tmp.classes}"/>
<zipgroupfileset dir="${tmp.bundle}"/>
<manifest>
<attribute name="las2peer-service-name" value="${service.name}"/>
<attribute name="las2peer-service-version" value="${service.version}"/>
</manifest>
</jar>
</target>


<!-- Generate Documentation -->
<target name="javadoc" depends="init_doc">
Expand Down Expand Up @@ -258,6 +276,24 @@

<target name="all" depends="clean, get_deps, compile_main, jar, generate_agents, startscripts"/>

<!-- Flyway database migration -->
<target name="migrate-db">
<taskdef uri="antlib:org.flywaydb.ant" resource="org/flywaydb/ant/antlib.xml">
<classpath>
<pathelement location="${service}/flyway-core-4.2.0.jar"/>
<pathelement location="${service}/flyway-ant-4.2.0.jar"/>
<pathelement location="${service}/mysql-connector-java-6.0.5.jar"/>
</classpath>
</taskdef>

<path id="flyway.classpath">
<fileset dir="${service}" includes="h2.jar"/>
</path>
<property name="flyway.locations" value="filesystem:./etc/migrations"/>

<flyway:migrate url="${dbUrl}?useSSL=false&amp;serverTimezone=UTC" user="${dbUserName}" password="${dbPassword}"/>
</target>

<!-- Run -->
<target name="debug" depends="compile_main, jar">
<java classname="i5.las2peer.tools.L2pNodeLauncher"
Expand All @@ -270,7 +306,7 @@
<arg value='-p'/>
<arg value='9011'/>
<arg value='uploadStartupDirectory'/>
<arg value='startService(\"de.rwth.dbis.acis.bazaar.service.[email protected]\",\"SampleServicePass\")'/>
<arg value="startService('${service.name}.${service.class}@${service.version}','${service.passphrase}')"/>
<arg value='startWebConnector'/>
<arg value='interactive'/>
</java>
Expand Down
4 changes: 2 additions & 2 deletions etc/ant_configuration/service.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
service.version=0.6
service.version=0.7
service.name=de.rwth.dbis.acis.bazaar.service
service.path=de/rwth/dbis/acis/bazaar/service
service.class=BazaarService
service.passphrase=Passphrase
service.dependencies=commons-codec;version="1.9",commons-dbcp2;version="2.0",commons-io;version="2.4",commons-logging;version="1.2",commons-pool2;version="2.2",emoji-java;version="3.1.3",gson;version="2.3",httpclient;version="4.5.1",httpcore;version="4.4.3",jodd-bean;version="3.6.1",jodd-core;version="3.6.1",jodd-vtor;version="3.6.1",jooq;version="3.9.1",jooq-codegen;version="3.9.1",jooq-meta;version="3.9.1",json;version="20140107",mysql-connector-java;version="5.1.6"
service.dependencies=commons-codec;version="1.9",commons-dbcp2;version="2.0",commons-io;version="2.4",commons-logging;version="1.2",commons-pool2;version="2.2",emoji-java;version="3.1.3",gson;version="2.3",httpclient;version="4.5.1",httpcore;version="4.4.3",jodd-bean;version="3.6.1",jodd-core;version="3.6.1",jodd-vtor;version="3.6.1",jooq;version="3.9.1",jooq-codegen;version="3.9.1",jooq-meta;version="3.9.1",json;version="20140107",mysql-connector-java;version="6.0.5"
5 changes: 3 additions & 2 deletions etc/de.rwth.dbis.acis.bazaar.service.BazaarService.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ lang=eng
country=us
baseURL=http://localhost:8080/bazaar/
frontendBaseURL=http://localhost:5000/
activityTrackerService=de.rwth.dbis.acis.activitytracker.service.ActivityTrackerService@0.3
activityTrackerService=de.rwth.dbis.acis.activitytracker.service.ActivityTrackerService@0.4
activityOrigin=https://requirements-bazaar.org
smtpServer=
emailFromAddress=
emailFromAddress=
monitor=
3 changes: 1 addition & 2 deletions etc/i5.las2peer.webConnector.WebConnector.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ preferLocalServices = TRUE
xmlPath =
defaultLoginUser=anonymous
defaultLoginPassword=anonymous
oidcProviders = https://api.learning-layers.eu/o/oauth2,https://accounts.google.com
monitor = false
oidcProviders = https://api.learning-layers.eu/o/oauth2,https://accounts.google.com
4 changes: 3 additions & 1 deletion etc/ivy/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<dependency org="i5" name="las2peer-web-connector" rev="0.6.7" changing="true" conf="platform->*"/>
<dependency org="junit" name="junit" rev="4.12" conf="platform->*"/>
<!-- service dependencies -->
<dependency org="mysql" name="mysql-connector-java" rev="5.1.6" conf="bundle->default"/>
<dependency org="mysql" name="mysql-connector-java" rev="6.0.5" conf="bundle->default"/>
<dependency org="org.flywaydb" name="flyway-ant" rev="4.2.0" conf="bundle->default"/>
<dependency org="com.h2database" name="h2" rev="1.4.191" conf="bundle->default"/>
<dependency org="org.apache.commons" name="commons-pool2" rev="2.2" conf="bundle->default"/>
<dependency org="org.apache.commons" name="commons-dbcp2" rev="2.0" conf="bundle->default"/>
<dependency org="org.jooq" name="jooq" rev="3.9.1" conf="bundle->default"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
SET FOREIGN_KEY_CHECKS = 0;

CREATE DATABASE IF NOT EXISTS reqbaz;

DROP TABLE IF EXISTS reqbaz.attachment, reqbaz.comment, reqbaz.category,
reqbaz.requirement_developer_map, reqbaz.requirement_follower_map, reqbaz.category_follower_map,
reqbaz.project_follower_map, reqbaz.privilege, reqbaz.project, reqbaz.requirement,
reqbaz.requirement_category_map, reqbaz.role_privilege_map, reqbaz.role_role_map,
reqbaz.role, reqbaz.user_role_map, reqbaz.vote;

-- tables
-- Table attachment
CREATE TABLE IF NOT EXISTS reqbaz.attachment (
Expand Down Expand Up @@ -232,4 +224,95 @@ CREATE TABLE IF NOT EXISTS reqbaz.vote (
CONSTRAINT vote_user FOREIGN KEY vote_user (user_id) REFERENCES user (id)
);

-- Fill roles and privileges
REPLACE INTO reqbaz.role
(id, name)
VALUES
(1, 'Anonymous'),
(2, 'LoggedInUser'),
(3, 'ProjectAdmin'),
(4, 'SystemAdmin');

REPLACE INTO reqbaz.privilege
(id, name)
VALUES
(1, 'Create_PROJECT'),
(2, 'Read_PROJECT'),
(3, 'Read_PUBLIC_PROJECT'),
(4, 'Modify_PROJECT'),
(5, 'Create_CATEGORY'),
(6, 'Read_CATEGORY'),
(7, 'Read_PUBLIC_CATEGORY'),
(8, 'Modify_CATEGORY'),
(9, 'Create_REQUIREMENT'),
(10, 'Read_REQUIREMENT'),
(11, 'Read_PUBLIC_REQUIREMENT'),
(12, 'Modify_REQUIREMENT'),
(13, 'Create_COMMENT'),
(14, 'Read_COMMENT'),
(15, 'Read_PUBLIC_COMMENT'),
(16, 'Modify_COMMENT'),
(17, 'Create_ATTACHMENT'),
(18, 'Read_ATTACHMENT'),
(19, 'Read_PUBLIC_ATTACHMENT'),
(20, 'Modify_ATTACHMENT'),
(21, 'Create_VOTE'),
(22, 'Delete_VOTE'),
(23, 'Create_FOLLOW'),
(24, 'Delete_FOLLOW'),
(25, 'Create_DEVELOP'),
(26, 'Delete_DEVELOP');

REPLACE INTO reqbaz.role_privilege_map
(id, role_id, privilege_id)
VALUES
(1, 1, 3),
(2, 1, 7),
(3, 1, 11),
(4, 1, 15),
(5, 1, 19),
(6, 4, 1),
(7, 4, 2),
(8, 4, 8),
(9, 4, 7),
(10, 4, 6),
(11, 4, 5),
(12, 4, 3),
(13, 4, 4),
(14, 4, 9),
(15, 4, 10),
(16, 4, 11),
(17, 4, 12),
(18, 4, 13),
(19, 4, 14),
(20, 4, 16),
(21, 4, 17),
(22, 4, 18),
(23, 4, 19),
(24, 4, 20),
(25, 4, 21),
(26, 4, 22),
(27, 4, 23),
(28, 4, 24),
(29, 4, 25),
(30, 4, 26);

REPLACE INTO reqbaz.role_role_map
(id, child_id, parent_id)
VALUES
(1, 2, 1),
(2, 3, 2),
(3, 4, 3);

REPLACE INTO reqbaz.user_role_map
(id, role_id, user_id)
VALUES
(1, 1, 1);

REPLACE INTO reqbaz.user
(id, first_name, last_name, email, admin, las2peer_id, user_name, profile_image, email_lead_subscription, email_follow_subscription)
VALUES
(1, NULL, NULL, '[email protected]', 0, '-1722613621014065292', 'anonymous',
'https://api.learning-layers.eu/profile.png', 0, 0);

SET FOREIGN_KEY_CHECKS = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ VALUES
(4, 1, 3, 4),
(5, 1, 4, 4);

-- roles and privilege schema is already set up with V1__create_reqbaz_schema
REPLACE INTO reqbaz.role
(id, name)
VALUES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ VALUES
(20, 1, 15, 6),
(21, 1, 16, 7);

-- roles and privilege schema is already set up with V1__create_reqbaz_schema

REPLACE INTO reqbaz.role
(id, name)
VALUES
Expand Down
Loading

0 comments on commit 48f232f

Please sign in to comment.