no message
This commit is contained in:
parent
5de4c1ada0
commit
b7d5dfb198
|
@ -0,0 +1,6 @@
|
||||||
|
TAG=6.2.1
|
||||||
|
ENV=dev
|
||||||
|
PROFILE=production
|
||||||
|
AOT=no-aot
|
||||||
|
ELASTIC_VERSION=6.2.1
|
||||||
|
ELASTIC_PASSWORD=changeme
|
|
@ -0,0 +1,3 @@
|
||||||
|
TAG=6.2.1
|
||||||
|
ELASTIC_VERSION=6.2.1
|
||||||
|
ELASTIC_PASSWORD=changeme
|
|
@ -0,0 +1 @@
|
||||||
|
**/*~
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
language: python
|
||||||
|
python: ['3.5']
|
||||||
|
script: make
|
||||||
|
|
||||||
|
sudo: required
|
||||||
|
services: ['docker']
|
|
@ -0,0 +1,201 @@
|
||||||
|
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.
|
|
@ -0,0 +1,30 @@
|
||||||
|
SHELL=/bin/bash
|
||||||
|
|
||||||
|
ifndef ELASTIC_VERSION
|
||||||
|
ELASTIC_VERSION := $(shell awk 'BEGIN { FS = "[= ]" } /^ELASTIC_VERSION=/ { print $$2 }' .env)
|
||||||
|
endif
|
||||||
|
export ELASTIC_VERSION
|
||||||
|
|
||||||
|
ifndef GIT_BRANCH
|
||||||
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
|
endif
|
||||||
|
|
||||||
|
TARGETS := apm-server elasticsearch logstash kibana beats
|
||||||
|
|
||||||
|
images: $(TARGETS)
|
||||||
|
push: $(TARGETS:%=%-push)
|
||||||
|
clean: $(TARGETS:%=%-clean)
|
||||||
|
|
||||||
|
$(TARGETS): $(TARGETS:%=%-checkout)
|
||||||
|
(cd stack/$@ && make)
|
||||||
|
|
||||||
|
$(TARGETS:%=%-push): $(TARGETS:%=%-checkout)
|
||||||
|
(cd stack/$(@:%-push=%) && make push)
|
||||||
|
|
||||||
|
$(TARGETS:%=%-checkout):
|
||||||
|
test -d stack/$(@:%-checkout=%) || \
|
||||||
|
git clone https://github.com/elastic/$(@:%-checkout=%)-docker.git stack/$(@:%-checkout=%)
|
||||||
|
(cd stack/$(@:%-checkout=%) && git fetch && git reset --hard && git checkout origin/$(GIT_BRANCH))
|
||||||
|
|
||||||
|
$(TARGETS:%=%-clean):
|
||||||
|
rm -rf stack/$(@:%-clean=%)
|
|
@ -0,0 +1,25 @@
|
||||||
|
# stack-docker
|
||||||
|
This example Docker Compose configuration demonstrates many components of the
|
||||||
|
Elastic Stack, all running on a single machine under Docker.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
- Docker and Compose. Windows and Mac users get Compose installed automatically
|
||||||
|
with Docker. Linux users can:
|
||||||
|
```
|
||||||
|
pip install docker-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
- At least 4GiB of RAM for the containers. Windows and Mac users _must_
|
||||||
|
configure their Docker virtual machine to have more than the default 2 GiB of
|
||||||
|
RAM:
|
||||||
|
|
||||||
|
![Docker VM memory settings](screenshots/docker-vm-memory-settings.png)
|
||||||
|
|
||||||
|
## Starting the stack
|
||||||
|
Try `docker-compose up` to create a demonstration Elastic Stack with
|
||||||
|
Elasticsearch, Kibana, Logstash, Auditbeat, Metricbeat, Filebeat, Packetbeat,
|
||||||
|
and Heartbeat.
|
||||||
|
|
||||||
|
Point a browser at [`http://localhost:5601`](http://localhost:5601) to see the results.
|
||||||
|
|
||||||
|
Log in with `elastic` / `changeme`.
|
|
@ -0,0 +1,28 @@
|
||||||
|
input {
|
||||||
|
http {
|
||||||
|
port => 31311 # default: 8080
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filter {
|
||||||
|
grok{
|
||||||
|
match => { "message" => "%{GREEDYDATA:request}"}
|
||||||
|
}
|
||||||
|
json{
|
||||||
|
source => "request"
|
||||||
|
target => "parsed"
|
||||||
|
}
|
||||||
|
split{
|
||||||
|
field=>"entries"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output {
|
||||||
|
elasticsearch {
|
||||||
|
hosts => [ 'elasticsearch' ]
|
||||||
|
user => 'elastic'
|
||||||
|
password => 'changeme'
|
||||||
|
index => "data-management-plan-%{[entries][indexType]}-%{+YYYY.MM.dd}"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
---
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
# The environment variable "TAG" is used throughout this file to
|
||||||
|
# specify the version of the images to run. The default is set in the
|
||||||
|
# '.env' file in this folder. It can be overridden with any normal
|
||||||
|
# technique for setting environment variables, for example:
|
||||||
|
#
|
||||||
|
# TAG=6.0.0-beta1 docker-compose up
|
||||||
|
#
|
||||||
|
# REF: https://docs.docker.com/compose/compose-file/#variable-substitution
|
||||||
|
#
|
||||||
|
# Also be sure to set the ELASTIC_VERSION variable. For released versions,
|
||||||
|
# ${TAG} and ${ELASTIC_VERSION} will be identical, but for pre-release
|
||||||
|
# versions, ${TAG} might contain an extra build identifier, like
|
||||||
|
# "6.0.0-beta1-3eab5b40", so a full invocation might look like:
|
||||||
|
#
|
||||||
|
# ELASTIC_VERSION=6.0.0-beta1 TAG=6.0.0-beta1-3eab5b40 docker-compose up
|
||||||
|
#
|
||||||
|
elasticsearch:
|
||||||
|
image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
|
||||||
|
container_name: elasticsearch
|
||||||
|
#volumes:
|
||||||
|
# - esdata:/usr/share/elasticsearch/data
|
||||||
|
environment: ['http.host=0.0.0.0', 'transport.host=127.0.0.1', 'ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
|
||||||
|
ports: ['0.0.0.0:9200:9200']
|
||||||
|
networks: ['stack']
|
||||||
|
|
||||||
|
kibana:
|
||||||
|
image: docker.elastic.co/kibana/kibana:${TAG}
|
||||||
|
container_name: kibana
|
||||||
|
ports: ['0.0.0.0:5601:5601']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch']
|
||||||
|
|
||||||
|
logstash:
|
||||||
|
image: docker.elastic.co/logstash/logstash:${TAG}
|
||||||
|
container_name: logstash
|
||||||
|
# Provide a simple pipeline configuration for Logstash with a bind-mounted file.
|
||||||
|
volumes:
|
||||||
|
- ./config/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
|
||||||
|
ports: ['0.0.0.0:31311:31311']
|
||||||
|
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch', 'setup_logstash']
|
||||||
|
|
||||||
|
filebeat:
|
||||||
|
image: docker.elastic.co/beats/filebeat:${TAG}
|
||||||
|
container_name: filebeat
|
||||||
|
command: -e -E 'output.elasticsearch.password=${ELASTIC_PASSWORD}'
|
||||||
|
# If the host system has logs at "/var/log", mount them at "/mnt/log"
|
||||||
|
# inside the container, where Filebeat can find them.
|
||||||
|
# volumes: ['/var/log:/mnt/log:ro']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch', 'setup_filebeat']
|
||||||
|
|
||||||
|
heartbeat:
|
||||||
|
image: docker.elastic.co/beats/heartbeat:${TAG}
|
||||||
|
container_name: heartbeat
|
||||||
|
command: -e -E 'output.elasticsearch.password=${ELASTIC_PASSWORD}'
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch', 'setup_heartbeat']
|
||||||
|
|
||||||
|
# Run a short-lived container to set up Logstash.
|
||||||
|
setup_logstash:
|
||||||
|
image: centos:7
|
||||||
|
container_name: setup_logstash
|
||||||
|
volumes: ['./scripts/setup-logstash.sh:/usr/local/bin/setup-logstash.sh:ro']
|
||||||
|
# The script may have CR/LF line endings if using Docker for Windows, so
|
||||||
|
# make sure that they don't confuse Bash.
|
||||||
|
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-logstash.sh | tr -d "\r" | bash']
|
||||||
|
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch']
|
||||||
|
|
||||||
|
setup_kibana:
|
||||||
|
image: centos:7
|
||||||
|
container_name: setup_kibana
|
||||||
|
volumes: ['./scripts/setup-kibana.sh:/usr/local/bin/setup-kibana.sh:ro']
|
||||||
|
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-kibana.sh | tr -d "\r" | bash']
|
||||||
|
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['elasticsearch']
|
||||||
|
|
||||||
|
setup_filebeat:
|
||||||
|
image: docker.elastic.co/beats/filebeat:${TAG}
|
||||||
|
container_name: setup_filebeat
|
||||||
|
volumes: ['./scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro']
|
||||||
|
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-beat.sh | tr -d "\r" | bash -s filebeat']
|
||||||
|
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['kibana']
|
||||||
|
|
||||||
|
setup_heartbeat:
|
||||||
|
image: docker.elastic.co/beats/heartbeat:${TAG}
|
||||||
|
container_name: setup_heartbeat
|
||||||
|
volumes: ['./scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro']
|
||||||
|
command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-beat.sh | tr -d "\r" | bash -s heartbeat']
|
||||||
|
environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
|
||||||
|
networks: ['stack']
|
||||||
|
depends_on: ['kibana']
|
||||||
|
|
||||||
|
#volumes:
|
||||||
|
#esdata:
|
||||||
|
# driver: local
|
||||||
|
networks: {stack: {}}
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
beat=$1
|
||||||
|
|
||||||
|
until curl -s http://kibana:5601; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Load the sample dashboards for the Beat.
|
||||||
|
# REF: https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-sample-dashboards.html
|
||||||
|
${beat} setup \
|
||||||
|
-E setup.kibana.host=kibana \
|
||||||
|
-E setup.kibana.username=elastic \
|
||||||
|
-E setup.kibana.password=${ELASTIC_PASSWORD} \
|
||||||
|
-E output.elasticsearch.password=${ELASTIC_PASSWORD}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
es_url=http://elastic:${ELASTIC_PASSWORD}@elasticsearch:9200
|
||||||
|
|
||||||
|
# Wait for Elasticsearch to start up before doing anything.
|
||||||
|
until curl -s $es_url -o /dev/null; do
|
||||||
|
sleep 1
|
||||||
|
done
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
es_url=http://elastic:${ELASTIC_PASSWORD}@elasticsearch:9200
|
||||||
|
|
||||||
|
# Wait for Elasticsearch to start up before doing anything.
|
||||||
|
until curl -s $es_url -o /dev/null; do
|
||||||
|
sleep 1
|
||||||
|
done
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!/.gitignore
|
|
@ -1,5 +1,5 @@
|
||||||
FROM openjdk:8-jdk-alpine
|
FROM openjdk:8-jdk-alpine
|
||||||
VOLUME /tmp
|
VOLUME /tmp
|
||||||
ARG JAR_FILE
|
ARG PROFILE=dev
|
||||||
ADD ${JAR_FILE} app.jar
|
ADD web/target/web-1.0-SNAPSHOT.jar app.jar
|
||||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=${PROFILE}","-jar","/app.jar"]
|
|
@ -84,7 +84,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
||||||
private String associatedDmps;
|
private String associatedDmps;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,U
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@JoinColumn(name = "\"Profile\"", nullable = true)
|
@JoinColumn(name = "\"Profile\"", nullable = true)
|
||||||
private DatasetProfile profile;
|
private DatasetProfile profile;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
|
||||||
private Set<Dataset> dataset;
|
private Set<Dataset> dataset;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DatasetProfileRuleset {
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DatasetProfileViewstyle {
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Invitation implements DataEntity<Invitation,UUID> {
|
||||||
@Column(name = "\"AcceptedInvitation\"", nullable = false)
|
@Column(name = "\"AcceptedInvitation\"", nullable = false)
|
||||||
private boolean acceptedInvitation;
|
private boolean acceptedInvitation;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
||||||
@Column(name = "\"Abbreviation\"")
|
@Column(name = "\"Abbreviation\"")
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,14 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
@Column(name = "\"Abbreviation\"")
|
@Column(name = "\"Abbreviation\"")
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Registry implements DataEntity<Registry,UUID> {
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ public class Researcher implements DataEntity<Researcher,UUID> {
|
||||||
@Column(name = "\"PrimaryEmail\"")
|
@Column(name = "\"PrimaryEmail\"")
|
||||||
private String primaryEmail;
|
private String primaryEmail;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Service implements DataEntity<Service, UUID> {
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||||
private Date lastloggedin = null;
|
private Date lastloggedin = null;
|
||||||
|
|
||||||
|
|
||||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "additionalinfo", nullable = true)
|
@Column(name = "additionalinfo", nullable = true)
|
||||||
private String additionalinfo;
|
private String additionalinfo;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.core.logger;
|
package eu.eudat.core.logger;
|
||||||
|
|
||||||
|
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 5/30/2018.
|
* Created by ikalyvas on 5/30/2018.
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +27,8 @@ public interface Logger {
|
||||||
|
|
||||||
<T extends Exception> void warn(T exception,String message);
|
<T extends Exception> void warn(T exception,String message);
|
||||||
|
|
||||||
|
<T> void info(String message);
|
||||||
|
|
||||||
<T> void info(T model);
|
<T> void info(T model);
|
||||||
|
|
||||||
<T> void info(T model,String message);
|
<T> void info(T model,String message);
|
||||||
|
@ -35,6 +39,8 @@ public interface Logger {
|
||||||
|
|
||||||
<T> void error(T loggingModel);
|
<T> void error(T loggingModel);
|
||||||
|
|
||||||
|
<E extends Exception,P> void error(ApiExceptionLoggingModel<E,P> model);
|
||||||
|
|
||||||
<T extends Exception> void error(T exception);
|
<T extends Exception> void error(T exception);
|
||||||
|
|
||||||
<T extends Exception> void error(T exception,String message);
|
<T extends Exception> void error(T exception,String message);
|
||||||
|
|
|
@ -42,13 +42,15 @@ public abstract class AbstractBatchLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String tranformLog() {
|
public String tranformLog() {
|
||||||
Map<String ,Collection<Object>> transformedMap = new HashMap<>();
|
if (this.concurrentHashMap.size() > 0) {
|
||||||
transformedMap.put("data",this.getAndClear().values());
|
Map<String, Collection<Object>> transformedMap = new HashMap<>();
|
||||||
if (this.logOutputType().equals(LoggingOutputType.JSON))
|
transformedMap.put("entries", this.getAndClear().values());
|
||||||
return this.concurrentHashMap.values().size() > 0 ? new JSONObject(transformedMap).toString() : null;
|
if (this.logOutputType().equals(LoggingOutputType.JSON))
|
||||||
if (this.logOutputType().equals(LoggingOutputType.FILE))
|
return new JSONObject(transformedMap).toString();
|
||||||
return this.concurrentHashMap.toString(); //TODO actual implementation of file Logger
|
if (this.logOutputType().equals(LoggingOutputType.FILE))
|
||||||
else throw new RuntimeException("Unsupported LoggingOutputType type");
|
return transformedMap.toString(); //TODO actual implementation of file Logger
|
||||||
|
else throw new RuntimeException("Unsupported LoggingOutputType type");
|
||||||
|
} else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void outputData();
|
public abstract void outputData();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.core.logger.remote.http;
|
||||||
import eu.eudat.core.logger.Logger;
|
import eu.eudat.core.logger.Logger;
|
||||||
import eu.eudat.core.logger.common.AbstractBatchLogger;
|
import eu.eudat.core.logger.common.AbstractBatchLogger;
|
||||||
import eu.eudat.core.models.LoggingModel;
|
import eu.eudat.core.models.LoggingModel;
|
||||||
|
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
|
||||||
import eu.eudat.core.models.exception.ExceptionLoggingModel;
|
import eu.eudat.core.models.exception.ExceptionLoggingModel;
|
||||||
import eu.eudat.core.models.simple.SimpleAuditModel;
|
import eu.eudat.core.models.simple.SimpleAuditModel;
|
||||||
import eu.eudat.core.models.simple.SimpleLoggingModel;
|
import eu.eudat.core.models.simple.SimpleLoggingModel;
|
||||||
|
@ -17,6 +18,9 @@ import org.springframework.web.client.RestTemplate;
|
||||||
import types.LoggingOutputType;
|
import types.LoggingOutputType;
|
||||||
import types.LoggingType;
|
import types.LoggingType;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 5/30/2018.
|
* Created by ikalyvas on 5/30/2018.
|
||||||
*/
|
*/
|
||||||
|
@ -40,11 +44,16 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void outputData() {
|
public void outputData() {
|
||||||
String log = this.tranformLog();
|
try {
|
||||||
if (log != null && !log.isEmpty()) {
|
String log = this.tranformLog();
|
||||||
HttpEntity<String> requestEntity = new HttpEntity(log, headers);
|
if (log != null) {
|
||||||
ResponseEntity<String> responseEntity = rest.exchange(this.environment.getProperty("http-logger.server-address"), HttpMethod.POST, requestEntity, String.class);
|
HttpEntity<String> requestEntity = new HttpEntity(log, headers);
|
||||||
|
ResponseEntity<String> Object = rest.exchange(this.environment.getProperty("http-logger.server-address"), HttpMethod.POST, requestEntity, String.class);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,19 +88,23 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void debug(T exception) {
|
public <T extends Exception> void debug(T exception) {
|
||||||
ExceptionLoggingModel<T> loggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
loggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
loggingModel.setType(LoggingType.DEBUG);
|
map.put("exception", exception);
|
||||||
this.put(String.valueOf(exception.hashCode()), loggingModel);
|
exceptionLoggingModel.setData(map);
|
||||||
|
exceptionLoggingModel.setType(LoggingType.DEBUG);
|
||||||
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void debug(T exception, String message) {
|
public <T extends Exception> void debug(T exception, String message) {
|
||||||
ExceptionLoggingModel<T> loggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
loggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
loggingModel.setMessage(message);
|
map.put("exception", exception);
|
||||||
loggingModel.setType(LoggingType.DEBUG);
|
exceptionLoggingModel.setData(map);
|
||||||
this.put(String.valueOf(exception.hashCode()), loggingModel);
|
exceptionLoggingModel.setMessage(message);
|
||||||
|
exceptionLoggingModel.setType(LoggingType.DEBUG);
|
||||||
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,7 +135,9 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void warn(T exception) {
|
public <T extends Exception> void warn(T exception) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setType(LoggingType.WARNING);
|
exceptionLoggingModel.setType(LoggingType.WARNING);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
@ -130,12 +145,22 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void warn(T exception, String message) {
|
public <T extends Exception> void warn(T exception, String message) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setMessage(message);
|
exceptionLoggingModel.setMessage(message);
|
||||||
exceptionLoggingModel.setType(LoggingType.WARNING);
|
exceptionLoggingModel.setType(LoggingType.WARNING);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> void info(String message) {
|
||||||
|
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
|
||||||
|
simpleAuditModel.setMessage(message);
|
||||||
|
simpleAuditModel.setType(LoggingType.INFO);
|
||||||
|
this.put(String.valueOf(simpleAuditModel.hashCode()), simpleAuditModel);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void info(T model) {
|
public <T> void info(T model) {
|
||||||
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
|
SimpleAuditModel<T> simpleAuditModel = new SimpleAuditModel<>();
|
||||||
|
@ -156,7 +181,9 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
@Override
|
@Override
|
||||||
public <T extends RuntimeException> void info(T exception) {
|
public <T extends RuntimeException> void info(T exception) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setType(LoggingType.INFO);
|
exceptionLoggingModel.setType(LoggingType.INFO);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
@ -164,23 +191,33 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
@Override
|
@Override
|
||||||
public <T extends RuntimeException> void info(T exception, String message) {
|
public <T extends RuntimeException> void info(T exception, String message) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setMessage(message);
|
exceptionLoggingModel.setMessage(message);
|
||||||
exceptionLoggingModel.setType(LoggingType.INFO);
|
exceptionLoggingModel.setType(LoggingType.INFO);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E extends Exception, P> void error(ApiExceptionLoggingModel<E, P> model) {
|
||||||
|
this.put(String.valueOf(model.hashCode()), model);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void error(T model) {
|
public <T> void error(T model) {
|
||||||
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
|
LoggingModel<T> loggingModel = new SimpleLoggingModel<>();
|
||||||
loggingModel.setType(LoggingType.DEBUG);
|
loggingModel.setType(LoggingType.DEBUG);
|
||||||
|
loggingModel.setData(model);
|
||||||
this.put(String.valueOf(model.hashCode()), loggingModel);
|
this.put(String.valueOf(model.hashCode()), loggingModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void error(T exception) {
|
public <T extends Exception> void error(T exception) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setType(LoggingType.ERROR);
|
exceptionLoggingModel.setType(LoggingType.ERROR);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +225,9 @@ public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
|
||||||
@Override
|
@Override
|
||||||
public <T extends Exception> void error(T exception, String message) {
|
public <T extends Exception> void error(T exception, String message) {
|
||||||
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
ExceptionLoggingModel<T> exceptionLoggingModel = new ExceptionLoggingModel<>();
|
||||||
exceptionLoggingModel.setData(exception);
|
Map<String, T> map = new HashMap<>();
|
||||||
|
map.put("exception", exception);
|
||||||
|
exceptionLoggingModel.setData(map);
|
||||||
exceptionLoggingModel.setMessage(message);
|
exceptionLoggingModel.setMessage(message);
|
||||||
exceptionLoggingModel.setType(LoggingType.ERROR);
|
exceptionLoggingModel.setType(LoggingType.ERROR);
|
||||||
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
this.put(String.valueOf(exception.hashCode()), exceptionLoggingModel);
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package eu.eudat.core.models.exception;
|
||||||
|
|
||||||
|
import eu.eudat.core.models.LoggingModel;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 6/12/2018.
|
||||||
|
*/
|
||||||
|
public class ApiExceptionLoggingModel<E extends Exception,P> extends LoggingModel<Map<String,E>> {
|
||||||
|
private HttpStatus code;
|
||||||
|
private P user;
|
||||||
|
private final String indexType = "api-exception-logging";
|
||||||
|
|
||||||
|
public String getIndexType() {
|
||||||
|
return indexType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public P getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(P user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpStatus getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(HttpStatus code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,20 @@ package eu.eudat.core.models.exception;
|
||||||
|
|
||||||
import eu.eudat.core.models.LoggingModel;
|
import eu.eudat.core.models.LoggingModel;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 5/30/2018.
|
* Created by ikalyvas on 5/30/2018.
|
||||||
*/
|
*/
|
||||||
public class ExceptionLoggingModel<E extends Exception> extends LoggingModel<E> {
|
public class ExceptionLoggingModel<E extends Exception> extends LoggingModel<Map<String, E>> {
|
||||||
|
private final String indexType = "exception-logging";
|
||||||
|
|
||||||
|
public String getIndexType() {
|
||||||
|
return indexType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, E> getData() {
|
||||||
|
return super.getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,9 @@ import eu.eudat.core.models.AuditModel;
|
||||||
* Created by ikalyvas on 5/30/2018.
|
* Created by ikalyvas on 5/30/2018.
|
||||||
*/
|
*/
|
||||||
public class SimpleAuditModel<T> extends AuditModel<T> {
|
public class SimpleAuditModel<T> extends AuditModel<T> {
|
||||||
|
private final String indexType = "simple-audit";
|
||||||
|
|
||||||
|
public String getIndexType() {
|
||||||
|
return indexType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,9 @@ import eu.eudat.core.models.LoggingModel;
|
||||||
* Created by ikalyvas on 5/30/2018.
|
* Created by ikalyvas on 5/30/2018.
|
||||||
*/
|
*/
|
||||||
public class SimpleLoggingModel<T> extends LoggingModel<T> {
|
public class SimpleLoggingModel<T> extends LoggingModel<T> {
|
||||||
|
private final String indexType = "simple-logging";
|
||||||
|
|
||||||
|
public String getIndexType() {
|
||||||
|
return indexType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
||||||
|
#Generated by Apache Maven
|
||||||
|
#Thu Jun 21 10:17:25 EEST 2018
|
||||||
|
version=1.0-SNAPSHOT
|
||||||
|
groupId=dmp-backend
|
||||||
|
artifactId=logging
|
|
@ -0,0 +1,11 @@
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\exception\ApiExceptionLoggingModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\types\LoggingOutputType.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\AuditModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\LoggingModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\simple\SimpleAuditModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\logger\common\AbstractBatchLogger.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\simple\SimpleLoggingModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\logger\remote\http\HttpRemoteLogger.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\logger\Logger.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\eu\eudat\core\models\exception\ExceptionLoggingModel.java
|
||||||
|
C:\Users\ikalyvas\Documents\OpenAIRE-EUDAT-DMP-service-pilot\dmp-backend\logging\src\main\java\types\LoggingType.java
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||||
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
||||||
<!-- <org.springframework.eu.eudat.security.version>3.2.10.RELEASE</org.springframework.eu.eudat.security.version> -->
|
<!-- <org.springframeweu.eudat.logic.securityrity.version>3.2.10.RELEASE</org.springframeweu.eudat.logic.securityrity.version> -->
|
||||||
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||||
<com.sun.jersey.version>1.19.1</com.sun.jersey.version>
|
<com.sun.jersey.version>1.19.1</com.sun.jersey.version>
|
||||||
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-eu.eudat.core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
<version>${hibernate.version}</version>
|
<version>${hibernate.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -101,13 +101,13 @@
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackeu.eudat.corecore -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackeu.eudat.corecore -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.eu.eudat.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-eu.eudat.core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.9.4</version>
|
<version>2.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.eu.eudat.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.4</version>
|
<version>2.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.convereu.eudat.corecore -->
|
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.convereu.eudat.corecore -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
<artifactId>org.apache.poi.xwpf.converter.eu.eudat.core</artifactId>
|
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
|
||||||
<version>1.0.6</version>
|
<version>1.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension -->
|
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension -->
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.configurations;
|
package eu.eudat.configurations;
|
||||||
|
|
||||||
import eu.eudat.controllers.interceptors.RequestInterceptor;
|
import eu.eudat.controllers.interceptors.RequestInterceptor;
|
||||||
import eu.eudat.handlers.PrincipalArgumentResolver;
|
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.services.operations.AuthenticationService;
|
import eu.eudat.logic.services.operations.AuthenticationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.dynamicproject;
|
package eu.eudat.configurations.dynamicproject;
|
||||||
|
|
||||||
import eu.eudat.dynamicproject.entities.Configuration;
|
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||||
import eu.eudat.models.dynamicfields.DynamicField;
|
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.dynamicproject;
|
package eu.eudat.configurations.dynamicproject;
|
||||||
|
|
||||||
import eu.eudat.dynamicproject.entities.Configuration;
|
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||||
import eu.eudat.dynamicproject.entities.Property;
|
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||||
import eu.eudat.models.dynamicfields.Dependency;
|
import eu.eudat.models.data.dynamicfields.Dependency;
|
||||||
import eu.eudat.models.dynamicfields.DynamicField;
|
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.dynamicproject;
|
package eu.eudat.configurations.dynamicproject;
|
||||||
|
|
||||||
import eu.eudat.dynamicproject.entities.Configuration;
|
import eu.eudat.configurations.dynamicproject.entities.Configuration;
|
||||||
import eu.eudat.dynamicproject.entities.Property;
|
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||||
import eu.eudat.models.dynamicfields.Dependency;
|
import eu.eudat.models.data.dynamicfields.Dependency;
|
||||||
import eu.eudat.models.dynamicfields.DynamicField;
|
import eu.eudat.models.data.dynamicfields.DynamicField;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import eu.eudat.proxy.config.UrlConfig;
|
import eu.eudat.logic.proxy.config.UrlConfig;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.dynamicproject.entities;
|
package eu.eudat.configurations.dynamicproject.entities;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.typedefinition;
|
package eu.eudat.configurations.typedefinition;
|
||||||
|
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
TINY,
|
TINY,
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.typedefinition;
|
package eu.eudat.configurations.typedefinition;
|
||||||
|
|
||||||
public interface DatabaseColumnType {
|
public interface DatabaseColumnType {
|
||||||
public String getType(DataType dt);
|
public String getType(DataType dt);
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.typedefinition;
|
package eu.eudat.configurations.typedefinition;
|
||||||
|
|
||||||
public class PostgreSQLDatabaseColumnType implements DatabaseColumnType {
|
public class PostgreSQLDatabaseColumnType implements DatabaseColumnType {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.typedefinition;
|
package eu.eudat.configurations.typedefinition;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.typedefinition;
|
package eu.eudat.configurations.typedefinition;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.managers.AdminManager;
|
import eu.eudat.logic.managers.AdminManager;
|
||||||
import eu.eudat.models.admin.composite.DatasetProfile;
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -62,7 +62,7 @@ public class Admin extends BaseController {
|
||||||
public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||||
datasetprofile.setLabel(profile.getLabel());
|
datasetprofile.setLabel(profile.getLabel());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.validators.*;
|
import eu.eudat.models.validators.*;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||||
import eu.eudat.dynamicproject.entities.Language;
|
import eu.eudat.configurations.dynamicproject.entities.Language;
|
||||||
import eu.eudat.managers.CommonsManager;
|
import eu.eudat.logic.managers.CommonsManager;
|
||||||
import eu.eudat.models.externalurl.ExternalSourcesConfiguration;
|
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
import eu.eudat.managers.DataManagementProfileManager;
|
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.listingmodels.DataManagementPlanProfileListingModel;
|
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -6,19 +6,18 @@ import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.managers.DataManagementPlanManager;
|
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||||
import eu.eudat.models.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.helpermodels.Tuple;
|
import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import eu.eudat.utilities.interfaces.Applier;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -26,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -60,7 +58,7 @@ public class DMPs extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataManagementPlan>> getSingle(@PathVariable String id, Principal principal) {
|
ResponseEntity<ResponseItem<DataManagementPlan>> getSingle(@PathVariable String id, Principal principal) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.models.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
|
|
||||||
}catch (UnauthorisedException ex) {
|
}catch (UnauthorisedException ex) {
|
||||||
|
@ -75,7 +73,7 @@ public class DMPs extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
||||||
try {
|
try {
|
||||||
DataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
DataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||||
|
@ -87,7 +85,7 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
||||||
try {
|
try {
|
||||||
DataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
DataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
@ -99,7 +97,7 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) {
|
||||||
try {
|
try {
|
||||||
DataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
DataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.managers.DashBoardManager;
|
import eu.eudat.logic.managers.DashBoardManager;
|
||||||
import eu.eudat.models.dashboard.recent.RecentActivity;
|
import eu.eudat.models.data.dashboard.recent.RecentActivity;
|
||||||
import eu.eudat.models.dashboard.statistics.DashBoardStatistics;
|
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.managers.UserManager;
|
import eu.eudat.logic.managers.UserManager;
|
||||||
import eu.eudat.models.components.commons.datafield.AutoCompleteData;
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.helpermodels.Tuple;
|
import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
import eu.eudat.models.helpers.common.AutoCompleteLookupItem;
|
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.properties.PropertiesModel;
|
import eu.eudat.models.data.properties.PropertiesModel;
|
||||||
import eu.eudat.models.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,7 +17,6 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,7 +37,7 @@ public class DatasetProfileController extends BaseController {
|
||||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
|
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(profile);
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||||
|
@ -70,7 +69,7 @@ public class DatasetProfileController extends BaseController {
|
||||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) {
|
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.data.entities.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
|
eu.eudat.data.entities.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
|
||||||
eu.eudat.models.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(dataset.getProfile().getDefinition(), lookupItem.getCriteria().getFieldID());
|
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(dataset.getProfile().getDefinition(), lookupItem.getCriteria().getFieldID());
|
||||||
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
|
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
|
||||||
List<Tuple<String, String>> items = DatasetProfileManager.getAutocomplete(data,lookupItem.getCriteria().getLike());
|
List<Tuple<String, String>> items = DatasetProfileManager.getAutocomplete(data,lookupItem.getCriteria().getLike());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
|
||||||
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.managers.DatasetWizardManager;
|
import eu.eudat.logic.managers.DatasetWizardManager;
|
||||||
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||||
import eu.eudat.models.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||||
import eu.eudat.managers.ExternalDatasetManager;
|
import eu.eudat.logic.managers.ExternalDatasetManager;
|
||||||
import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
|
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.managers.FileManager;
|
import eu.eudat.logic.managers.FileManager;
|
||||||
import eu.eudat.models.files.ContentFile;
|
import eu.eudat.models.data.files.ContentFile;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
|
@ -2,17 +2,17 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.core.logger.Logger;
|
import eu.eudat.core.logger.Logger;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.managers.UserManager;
|
import eu.eudat.logic.managers.UserManager;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.login.Credentials;
|
import eu.eudat.models.data.login.Credentials;
|
||||||
import eu.eudat.models.login.LoginInfo;
|
import eu.eudat.models.data.login.LoginInfo;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.security.CustomAuthenticationProvider;
|
import eu.eudat.logic.security.CustomAuthenticationProvider;
|
||||||
import eu.eudat.security.validators.b2access.B2AccessTokenValidator;
|
import eu.eudat.logic.security.validators.b2access.B2AccessTokenValidator;
|
||||||
import eu.eudat.security.validators.b2access.helpers.B2AccessRequest;
|
import eu.eudat.logic.security.validators.b2access.helpers.B2AccessRequest;
|
||||||
import eu.eudat.security.validators.b2access.helpers.B2AccessResponseToken;
|
import eu.eudat.logic.security.validators.b2access.helpers.B2AccessResponseToken;
|
||||||
import eu.eudat.security.validators.twitter.TwitterTokenValidator;
|
import eu.eudat.logic.security.validators.twitter.TwitterTokenValidator;
|
||||||
import eu.eudat.services.operations.AuthenticationServiceImpl;
|
import eu.eudat.logic.services.operations.AuthenticationServiceImpl;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -21,6 +21,7 @@ import org.springframework.social.oauth1.OAuthToken;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -40,7 +41,7 @@ public class Login {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Login(CustomAuthenticationProvider customAuthenticationProvider, AuthenticationServiceImpl authenticationServiceImpl,
|
public Login(CustomAuthenticationProvider customAuthenticationProvider, AuthenticationServiceImpl authenticationServiceImpl,
|
||||||
TwitterTokenValidator twitterTokenValidator, B2AccessTokenValidator b2AccessTokenValidator,Logger logger) {
|
TwitterTokenValidator twitterTokenValidator, B2AccessTokenValidator b2AccessTokenValidator, Logger logger) {
|
||||||
this.customAuthenticationProvider = customAuthenticationProvider;
|
this.customAuthenticationProvider = customAuthenticationProvider;
|
||||||
this.authenticationServiceImpl = authenticationServiceImpl;
|
this.authenticationServiceImpl = authenticationServiceImpl;
|
||||||
this.twitterTokenValidator = twitterTokenValidator;
|
this.twitterTokenValidator = twitterTokenValidator;
|
||||||
|
@ -51,15 +52,18 @@ public class Login {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/externallogin"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/externallogin"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Principal>> externallogin(@RequestBody LoginInfo credentials) {
|
ResponseEntity<ResponseItem<Principal>> externallogin(@RequestBody LoginInfo credentials) throws GeneralSecurityException {
|
||||||
try {
|
try {
|
||||||
|
this.logger.info(credentials, "Trying To Login With " + credentials.getProvider());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
} catch (UnauthorisedException ex) {
|
} catch (UnauthorisedException ex) {
|
||||||
|
this.logger.info(ex, "Failed To Login");
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch (Exception ex) {
|
}/* catch (Exception ex) {
|
||||||
|
this.logger.error(ex, ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -67,62 +71,66 @@ public class Login {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Principal>> nativelogin(@RequestBody Credentials credentials) {
|
ResponseEntity<ResponseItem<Principal>> nativelogin(@RequestBody Credentials credentials) {
|
||||||
try {
|
try {
|
||||||
|
this.logger.info(credentials.getUsername(), "Trying To Login");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(UserManager.authenticate(this.authenticationServiceImpl, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(UserManager.authenticate(this.authenticationServiceImpl, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
} catch (UnauthorisedException ex) {
|
} catch (UnauthorisedException ex) {
|
||||||
|
this.logger.info(ex, "Failed To Login");
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch (Exception ex) {
|
}/* catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
this.logger.error(ex, ex.getMessage());
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/twitterRequestToken"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/twitterRequestToken"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<OAuthToken>> twitterRequestToken() {
|
ResponseEntity<ResponseItem<OAuthToken>> twitterRequestToken() {
|
||||||
try {
|
//try {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OAuthToken>().payload(this.twitterTokenValidator.getRequestToken()).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OAuthToken>().payload(this.twitterTokenValidator.getRequestToken()).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
/*} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OAuthToken>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OAuthToken>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/b2AccessRequestToken"}, produces = "application/json", consumes = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/b2AccessRequestToken"}, produces = "application/json", consumes = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<B2AccessResponseToken>> b2AccessRequestToken(@RequestBody B2AccessRequest b2AccessRequest) {
|
ResponseEntity<ResponseItem<B2AccessResponseToken>> b2AccessRequestToken(@RequestBody B2AccessRequest b2AccessRequest) {
|
||||||
try {
|
//try {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<B2AccessResponseToken>().payload(this.b2AccessTokenValidator.getAccessToken(b2AccessRequest)).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<B2AccessResponseToken>().payload(this.b2AccessTokenValidator.getAccessToken(b2AccessRequest)).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
/*} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<B2AccessResponseToken>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<B2AccessResponseToken>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/me"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/me"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) {
|
ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) {
|
||||||
try {
|
//try {
|
||||||
|
this.logger.info(principal, "Getting Me");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(this.authenticationServiceImpl.Touch(principal.getToken())).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(this.authenticationServiceImpl.Touch(principal.getToken())).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
/*} catch (Exception ex) {
|
||||||
} catch (Exception ex) {
|
this.logger.debug(ex, ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/logout"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/logout"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
||||||
try {
|
//try {
|
||||||
this.authenticationServiceImpl.Logout(principal.getToken());
|
this.authenticationServiceImpl.Logout(principal.getToken());
|
||||||
this.logger.info(principal,"Logged Out");
|
this.logger.info(principal, "Logged Out");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
/*} catch (Exception ex) {
|
||||||
this.logger.debug(ex,ex.getMessage());
|
this.logger.debug(ex, ex.getMessage());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.models.external.OrganisationsExternalSourcesModel;
|
import eu.eudat.models.data.external.OrganisationsExternalSourcesModel;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Project;
|
import eu.eudat.data.entities.Project;
|
||||||
import eu.eudat.managers.ProjectManager;
|
import eu.eudat.logic.managers.ProjectManager;
|
||||||
import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||||
import eu.eudat.models.project.ProjectListingModel;
|
import eu.eudat.models.data.project.ProjectListingModel;
|
||||||
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
import eu.eudat.data.query.items.table.project.ProjectTableRequest;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -38,32 +38,32 @@ public class Projects extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, Principal principal) {
|
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, Principal principal) {
|
||||||
try {
|
try {
|
||||||
DataTableData<eu.eudat.models.project.ProjectListingModel> dataTable = new ProjectManager().getPaged(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectTableRequest, principal);
|
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new ProjectManager().getPaged(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectTableRequest, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/projects/getSingle/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/projects/getSingle/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<eu.eudat.models.project.Project>> getSingle(@PathVariable String id, Principal principal) {
|
ResponseEntity<ResponseItem<eu.eudat.models.data.project.Project>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||||
try {
|
//try {
|
||||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id);
|
eu.eudat.models.data.project.Project project = new ProjectManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.project.Project>().payload(project).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
/*} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.project.Project>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.project.Project>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/projects/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Project>> addProject(@Valid @RequestBody eu.eudat.models.project.Project project, Principal principal) {
|
ResponseEntity<ResponseItem<Project>> addProject(@Valid @RequestBody eu.eudat.models.data.project.Project project, Principal principal) {
|
||||||
try {
|
try {
|
||||||
ProjectManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(), this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(), project, principal);
|
ProjectManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(), this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(), project, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||||
|
@ -89,25 +89,25 @@ public class Projects extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/projects/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||||
try {
|
try {
|
||||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
List<eu.eudat.models.data.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.project.Project>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||||
try {
|
try {
|
||||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
List<eu.eudat.models.data.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.project.Project>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
import eu.eudat.models.data.external.RegistriesExternalSourcesModel;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.managers.ResearcherManager;
|
import eu.eudat.logic.managers.ResearcherManager;
|
||||||
import eu.eudat.models.dmp.Researcher;
|
import eu.eudat.models.data.dmp.Researcher;
|
||||||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
import eu.eudat.models.data.external.ResearchersExternalSourcesModel;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -51,20 +51,20 @@ public class Researchers extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<eu.eudat.models.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) {
|
ResponseEntity<ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) {
|
||||||
try {
|
try {
|
||||||
List<eu.eudat.models.dmp.Researcher> dataTable = new ResearcherManager().getCriteriaWithExternal(this.getApiContext(),this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest);
|
List<eu.eudat.models.data.dmp.Researcher> dataTable = new ResearcherManager().getCriteriaWithExternal(this.getApiContext(),this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.dmp.Researcher>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.dmp.Researcher>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/create"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/researchers/create"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Researcher>> create(@RequestBody eu.eudat.models.researcher.Researcher researcher, Principal principal) {
|
ResponseEntity<ResponseItem<Researcher>> create(@RequestBody eu.eudat.models.data.researcher.Researcher researcher, Principal principal) {
|
||||||
try {
|
try {
|
||||||
ResearcherManager.create(this.getApiContext(), researcher);
|
ResearcherManager.create(this.getApiContext(), researcher);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.models.external.ServiceExternalSourcesModel;
|
import eu.eudat.models.data.external.ServiceExternalSourcesModel;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.managers.InvitationsManager;
|
import eu.eudat.logic.managers.InvitationsManager;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.invitation.Invitation;
|
import eu.eudat.models.data.invitation.Invitation;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
|
||||||
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
|
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.managers.UserManager;
|
import eu.eudat.logic.managers.UserManager;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
||||||
import eu.eudat.models.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import eu.eudat.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -1,64 +1,45 @@
|
||||||
package eu.eudat.controllers.controllerhandler;
|
package eu.eudat.controllers.controllerhandler;
|
||||||
|
|
||||||
import eu.eudat.models.errormodels.ValidationErrorContext;
|
import eu.eudat.core.logger.Logger;
|
||||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.MessageSource;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.validation.FieldError;
|
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import types.LoggingType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 6/12/2018.
|
||||||
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class ControllerErrorHandler {
|
public class ControllerErrorHandler {
|
||||||
|
|
||||||
private MessageSource messageSource;
|
private Logger logger;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ControllerErrorHandler(MessageSource messageSource) {
|
public ControllerErrorHandler(Logger logger) {
|
||||||
this.messageSource = messageSource;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
@ExceptionHandler(Exception.class)
|
||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseItem<ValidationErrorContext> processValidationError(MethodArgumentNotValidException ex) {
|
public void processValidationError(Principal principal, Exception ex) throws Exception {
|
||||||
BindingResult result = ex.getBindingResult();
|
ApiExceptionLoggingModel<Exception, Principal> apiExceptionLoggingModel = new ApiExceptionLoggingModel<>();
|
||||||
List<FieldError> fieldErrors = result.getFieldErrors();
|
apiExceptionLoggingModel.setCode(HttpStatus.BAD_REQUEST);
|
||||||
|
apiExceptionLoggingModel.setUser(principal);
|
||||||
return processFieldErrors(fieldErrors);
|
Map<String,Exception> exceptionMap = new HashMap<>();
|
||||||
}
|
exceptionMap.put("exception",ex);
|
||||||
|
apiExceptionLoggingModel.setData(exceptionMap);
|
||||||
private ResponseItem<ValidationErrorContext> processFieldErrors(List<FieldError> fieldErrors) {
|
apiExceptionLoggingModel.setMessage(ex.getMessage());
|
||||||
ValidationErrorContext dto = new ValidationErrorContext();
|
apiExceptionLoggingModel.setType(LoggingType.ERROR);
|
||||||
|
this.logger.error(apiExceptionLoggingModel);
|
||||||
for (FieldError fieldError : fieldErrors) {
|
return;
|
||||||
String localizedErrorMessage = resolveLocalizedErrorMessage(fieldError);
|
|
||||||
dto.addFieldError(fieldError.getField(), localizedErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseItem<ValidationErrorContext>().status(ApiMessageCode.VALIDATION_MESSAGE).payload(dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveLocalizedErrorMessage(FieldError fieldError) {
|
|
||||||
Locale currentLocale = LocaleContextHolder.getLocale();
|
|
||||||
String localizedErrorMessage = messageSource.getMessage(fieldError, currentLocale);
|
|
||||||
|
|
||||||
if (localizedErrorMessage.equals(fieldError.getDefaultMessage())) {
|
|
||||||
String[] fieldErrorCodes = fieldError.getCodes();
|
|
||||||
localizedErrorMessage = fieldErrorCodes[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return localizedErrorMessage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package eu.eudat.controllers.controllerhandler;
|
||||||
|
|
||||||
|
import eu.eudat.core.logger.Logger;
|
||||||
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 6/12/2018.
|
||||||
|
*/
|
||||||
|
@ControllerAdvice
|
||||||
|
public class ControllerUnauthorisedHandler {
|
||||||
|
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ControllerUnauthorisedHandler(Logger logger) {
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(UnauthorisedException.class)
|
||||||
|
@ResponseStatus(HttpStatus.UNAUTHORIZED)
|
||||||
|
@ResponseBody
|
||||||
|
public void processValidationError(UnauthorisedException ex) {
|
||||||
|
this.logger.error(ex, ex.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package eu.eudat.controllers.controllerhandler;
|
||||||
|
|
||||||
|
import eu.eudat.models.data.errormodels.ValidationErrorContext;
|
||||||
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.types.ApiMessageCode;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class ControllerValidatorErrorHandler {
|
||||||
|
|
||||||
|
private MessageSource messageSource;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ControllerValidatorErrorHandler(MessageSource messageSource) {
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseItem<ValidationErrorContext> processValidationError(MethodArgumentNotValidException ex) {
|
||||||
|
BindingResult result = ex.getBindingResult();
|
||||||
|
List<FieldError> fieldErrors = result.getFieldErrors();
|
||||||
|
|
||||||
|
return processFieldErrors(fieldErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseItem<ValidationErrorContext> processFieldErrors(List<FieldError> fieldErrors) {
|
||||||
|
ValidationErrorContext dto = new ValidationErrorContext();
|
||||||
|
|
||||||
|
for (FieldError fieldError : fieldErrors) {
|
||||||
|
String localizedErrorMessage = resolveLocalizedErrorMessage(fieldError);
|
||||||
|
dto.addFieldError(fieldError.getField(), localizedErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseItem<ValidationErrorContext>().status(ApiMessageCode.VALIDATION_MESSAGE).payload(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveLocalizedErrorMessage(FieldError fieldError) {
|
||||||
|
Locale currentLocale = LocaleContextHolder.getLocale();
|
||||||
|
String localizedErrorMessage = messageSource.getMessage(fieldError, currentLocale);
|
||||||
|
|
||||||
|
if (localizedErrorMessage.equals(fieldError.getDefaultMessage())) {
|
||||||
|
String[] fieldErrorCodes = fieldError.getCodes();
|
||||||
|
localizedErrorMessage = fieldErrorCodes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return localizedErrorMessage;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.controllers.interceptors;
|
package eu.eudat.controllers.interceptors;
|
||||||
|
|
||||||
import eu.eudat.services.helpers.LoggerService;
|
import eu.eudat.logic.services.helpers.LoggerService;
|
||||||
import eu.eudat.types.WarningLevel;
|
import eu.eudat.types.WarningLevel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.builders;
|
package eu.eudat.logic.builders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 2/15/2018.
|
* Created by ikalyvas on 2/15/2018.
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.builders;
|
package eu.eudat.logic.builders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 2/15/2018.
|
* Created by ikalyvas on 2/15/2018.
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.builders;
|
package eu.eudat.logic.builders;
|
||||||
|
|
||||||
import eu.eudat.builders.entity.*;
|
import eu.eudat.logic.builders.entity.*;
|
||||||
import eu.eudat.builders.model.criteria.DataRepositoryCriteriaBuilder;
|
import eu.eudat.logic.builders.model.criteria.DataRepositoryCriteriaBuilder;
|
||||||
import eu.eudat.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
||||||
import eu.eudat.builders.model.criteria.RegistryCriteriaBuilder;
|
import eu.eudat.logic.builders.model.criteria.RegistryCriteriaBuilder;
|
||||||
import eu.eudat.builders.model.models.*;
|
import eu.eudat.logic.builders.model.models.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.Content;
|
import eu.eudat.data.entities.Content;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.Credential;
|
import eu.eudat.data.entities.Credential;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.data.entities.DatasetProfile;
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.Credential;
|
import eu.eudat.data.entities.Credential;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserRole;
|
import eu.eudat.data.entities.UserRole;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserToken;
|
import eu.eudat.data.entities.UserToken;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.builders.helpers;
|
package eu.eudat.logic.builders.helpers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/15/2018.
|
* Created by ikalyvas on 3/15/2018.
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.model.criteria;
|
package eu.eudat.logic.builders.model.criteria;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.model.criteria;
|
package eu.eudat.logic.builders.model.criteria;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.model.criteria;
|
package eu.eudat.logic.builders.model.criteria;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.builders.model.criteria;
|
package eu.eudat.logic.builders.model.criteria;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.builders.model.models;
|
package eu.eudat.logic.builders.model.models;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.models.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.builders.model.models;
|
package eu.eudat.logic.builders.model.models;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.models.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.builders.model.models;
|
package eu.eudat.logic.builders.model.models;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.models.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.builders.model.models;
|
package eu.eudat.logic.builders.model.models;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.models.dashboard.recent.RecentActivityData;
|
import eu.eudat.models.data.dashboard.recent.RecentActivityData;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.builders.model.models;
|
package eu.eudat.logic.builders.model.models;
|
||||||
|
|
||||||
import eu.eudat.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.models.dmp.Researcher;
|
import eu.eudat.models.data.dmp.Researcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/6/2018.
|
* Created by ikalyvas on 3/6/2018.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue