Index: src/mapservice/server_impl/controllers/LogsController.py
===================================================================
--- src/mapservice/server_impl/controllers/LogsController.py	(revision ae2ff15d6963a93c67e87e175ea31292b8bb3d28)
+++ src/mapservice/server_impl/controllers/LogsController.py	(revision ae2ff15d6963a93c67e87e175ea31292b8bb3d28)
@@ -0,0 +1,135 @@
+'''
+    Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+'''
+import connexion
+
+from ..database.Model import User, Log, LogEntry, Water, Device, Gauge, ProcessingStatus, Queue, db
+from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound
+from ..tasks.tasks import log_process
+
+def logs_get(submitter=None, order_by=None, offset=None, limit=None):
+	query = None
+	
+	if submitter is not None:
+		submitter = User.query.filter_by(username=submitter).all()
+		if len(submitter) != 1:
+			raise MapserviceNotFound(detail="Could not find the submitter with id {}".format(submitter))
+		submitter = submitter[0]
+
+	query = None
+	if submitter is not None:
+		query = Log.query.filter_by(submitter = submitter)
+		
+	if query is None:
+		query = Log.query
+	
+	result = []
+	for log in query.offset(offset).limit(limit):
+		result.append(log.meta_data())
+	return result
+
+def logs_log_get_by_id(id):
+	log = Log.query.filter_by(id=id).all()
+	if len(log) != 1:
+		raise MapserviceNotFound
+	if connexion.request.headers['Accept'] == "application/geo+json":
+		return log[0].to_geojson(), 200, {'Content-Type': 'application/geo+json; charset=utf-8'}
+	return log[0].log()
+
+def logs_log_create(log_creation):
+	user = User.loggedin_user()
+	if user is None:
+		raise MapserviceUnauthorized
+
+	water = Water.query.filter_by(id=log_creation.water).all()
+	if len(water) != 1:
+		raise MapserviceBadRequest(detail='Water {} not found database'.format(log_creation.water))
+	water = water[0]
+	
+	device = Device.query.filter_by(id=log_creation.device).all()
+	if len(device) != 1:
+		raise MapserviceBadRequest(detail='Device {} not found in database'.format(log_creation.device))
+	device = device[0]
+	
+	gauge = Gauge.query.filter_by(id=log_creation.gauge).all()
+	if len(gauge) != 1:
+		raise MapserviceBadRequest(detail='Gauge {} not found in database'.format(log_creation.gauge))
+	gauge = gauge[0]
+	
+	if log_creation.gauge_height is None:
+		raise MapserviceBadRequest(detail='Gauge Height (Stage) missing')
+	else:
+		try:
+			float(log_creation.gauge_height)
+		except ValueError:
+			raise MapserviceBadRequest(detail='Gauge Height (Stage) {} is no number'.format(log_creation.gauge_height))
+
+	if log_creation.comment is None:
+		log_creation.comment = ""
+	
+	log = Log(submitter=user, water=water, device=device, gauge=gauge, gauge_height=log_creation.gauge_height, start=None, end=None, comment=log_creation.comment)
+	db.session.add(log)
+	db.session.commit()
+	return log.meta_data()
+
+def logs_log_upload(log_id, body=None):
+	user = User.loggedin_user()
+	if user is None:
+		raise MapserviceUnauthorized
+	
+	if body is None or not body:
+		raise MapserviceBadRequest(detail='No log data')
+	
+	processing_state = ProcessingStatus.query.filter_by(label='Queued for Parsing').all()
+	if len(processing_state) != 1:
+		raise MapserviceBadRequest(detail='Processing status Queued for Parsing not found database')
+	processing_state = processing_state[0]
+	
+	log = Log.query.filter_by(id=log_id).all()
+	if len(log) != 1:
+		raise MapserviceBadRequest(detail='Log {} not found database'.format(log_id))
+	log = log[0]
+	
+	# check if Log has already log entries
+	if LogEntry.query.filter_by(log=log).count() > 0:
+		raise MapserviceBadRequest(detail='Log {} has already log entries. Aborting'.format(log_id))
+
+	# Add Log to Queued table and change the processing state of Log
+	queue = Queue(log=log)
+	db.session.add(queue)
+	log.processingstatus = processing_state
+	db.session.commit()
+	
+	# request log parsing
+	log_process.delay(log.id, body.decode())
+	
+	return log.meta_data()
+
+def logs_log_delete(id):
+	user = User.loggedin_user()
+	if user is None:
+		raise MapserviceUnauthorized
+	
+	if not Log.query.filter_by(submitter = user).filter_by(id=id).delete():
+		raise MapserviceBadRequest(detail="Could not delete log with id {}".format(id))
+	db.session.commit()
+	
+	query = Log.query.filter_by(submitter = user)
+	result = []
+	for log in query:
+		result.append(log.meta_data())
+	return result
+
