diff --git a/CHANGELOG.md b/CHANGELOG.md index e13710c75907fc4ebd780bab8b543a8c74ce4caf..fc91c68ad8ee81c2d33a12d48c0c040a1c3d8043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + ## [0.12.0] - 2023-10-25 (Timm Fitschen) diff --git a/RELEASE_GUIDELINES.md b/RELEASE_GUIDELINES.md index 2da13c6e38e22085af912f267032c0d4973300b3..f6f3c8729d4dc5ef84bd53be630d7a82bf2dfd65 100644 --- a/RELEASE_GUIDELINES.md +++ b/RELEASE_GUIDELINES.md @@ -40,11 +40,11 @@ guidelines of the CaosDB Project * `CHANGELOG.md`: Re-add the `[Unreleased]` section. 11. Add a gitlab release in the respective repository: - https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/releases + https://gitlab.com/linkahead/linkahead-server/-/releases Add a description, which can be a copy&paste from the CHANGELOG, possibly prepended by: ```md # Changelog -[See full changelog](https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/blob/${TAG}/CHANGELOG.md) +[See full changelog](https://gitlab.com/linkahead/linkahead-server/-/blob/${TAG}/CHANGELOG.md) ``` diff --git a/conf/core/usersources.ini.template b/conf/core/usersources.ini.template index fb3285723f0721da3280e5ef33461ff4b684e89f..d54d91d2202bf3ba465346ca0a24ad566bbd73a8 100644 --- a/conf/core/usersources.ini.template +++ b/conf/core/usersources.ini.template @@ -46,11 +46,14 @@ class = org.caosdb.server.accessControl.Pam # scripts or the misc/pam_authentication/ldap_authentication.sh script here. ; pam_script = ./misc/pam_authentication/pam_authentication.sh default_status = ACTIVE -# Only users which fulfill these criteria are accepted. +# Only users which fulfill these criteria are accepted. The values are +# user/group name(s) separated by whitespaces ;include.user = [uncomment and put your users here] ;include.group = [uncomment and put your groups here] ;exclude.user = [uncomment and put excluded users here] ;exclude.group = [uncomment and put excluded groups here] # It is typically necessary to add at least one admin -;user.[uncomment a set a username here].roles = administration +;user.[uncomment and set a username here].roles = administration +# Several roles are separated by commas +;user.[uncomment and set a username here].roles = role1, role2, role with spaces diff --git a/pom.xml b/pom.xml index 2607b1ed016c03cfc7788277ae151b5922803669..abe5e2827883f9445f02505294881134aefb4c1f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.caosdb</groupId> <artifactId>caosdb-server</artifactId> - <version>0.12.0</version> + <version>0.13.0-SNAPSHOT</version> <packaging>jar</packaging> <name>CaosDB Server</name> <scm> diff --git a/src/doc/conf.py b/src/doc/conf.py index 57b60c2bd6922af2bcb26f464e41392cd0c89ac8..530d8d653c6946b1c64738d7ad129f43d00afa8e 100644 --- a/src/doc/conf.py +++ b/src/doc/conf.py @@ -26,9 +26,9 @@ copyright = '2023, IndiScale GmbH' author = 'Daniel Hornung, Timm Fitschen' # The short X.Y version -version = '0.12.0' +version = '0.13.0' # The full version, including alpha/beta/rc tags -release = '0.12.0' +release = '0.13.0-dev' # -- General configuration --------------------------------------------------- diff --git a/src/main/java/org/caosdb/server/CaosDBServer.java b/src/main/java/org/caosdb/server/CaosDBServer.java index 8c75cf51e9a85685c19c3de271f56b519b81add7..4b7c0fe11ecb0c2391e5548ed6e37ede416e1343 100644 --- a/src/main/java/org/caosdb/server/CaosDBServer.java +++ b/src/main/java/org/caosdb/server/CaosDBServer.java @@ -73,7 +73,6 @@ import org.caosdb.server.resource.LogoutResource; import org.caosdb.server.resource.PermissionRulesResource; import org.caosdb.server.resource.RolesResource; import org.caosdb.server.resource.ScriptingResource; -import org.caosdb.server.resource.ServerLogsResource; import org.caosdb.server.resource.ServerPropertiesResource; import org.caosdb.server.resource.SharedFileResource; import org.caosdb.server.resource.ThumbnailsResource; @@ -746,12 +745,6 @@ public class CaosDBServer extends Application { protectedRouter.attach("/Role/{specifier}", RolesResource.class); protectedRouter.attach("/PermissionRules/{specifier}", PermissionRulesResource.class); protectedRouter.attach("/PermissionRules/{realm}/{specifier}", PermissionRulesResource.class); - protectedRouter - .attach("/ServerLogs/", ServerLogsResource.class) - .setMatchingMode(Template.MODE_STARTS_WITH); - protectedRouter - .attach("/ServerLogs", ServerLogsResource.class) - .setMatchingMode(Template.MODE_STARTS_WITH); protectedRouter.attach("/login?username={username}", AuthenticationResource.class); protectedRouter.attach("/logout", LogoutResource.class); protectedRouter.attach("/_server_properties", ServerPropertiesResource.class); diff --git a/src/main/java/org/caosdb/server/database/BackendTransaction.java b/src/main/java/org/caosdb/server/database/BackendTransaction.java index c014972ac52246e87a1d9e6f575a645125ab4c57..534c7bc1ae35c5b8778b7950155337d1a24bd04f 100644 --- a/src/main/java/org/caosdb/server/database/BackendTransaction.java +++ b/src/main/java/org/caosdb/server/database/BackendTransaction.java @@ -37,7 +37,6 @@ import org.caosdb.server.database.backend.implementation.MySQL.MySQLGetUpdateabl import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertEntityDatatype; import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertEntityProperties; import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertLinCon; -import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertLogRecord; import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertParents; import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertRole; import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertSparseEntity; @@ -51,7 +50,6 @@ import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveAllU import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveCurrentMaxId; import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveDatatypes; import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveEntityACL; -import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveLogRecord; import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrieveParents; import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrievePasswordValidator; import org.caosdb.server.database.backend.implementation.MySQL.MySQLRetrievePermissionRules; @@ -95,7 +93,6 @@ import org.caosdb.server.database.backend.interfaces.GetUpdateableChecksumsImpl; import org.caosdb.server.database.backend.interfaces.InsertEntityDatatypeImpl; import org.caosdb.server.database.backend.interfaces.InsertEntityPropertiesImpl; import org.caosdb.server.database.backend.interfaces.InsertLinConImpl; -import org.caosdb.server.database.backend.interfaces.InsertLogRecordImpl; import org.caosdb.server.database.backend.interfaces.InsertParentsImpl; import org.caosdb.server.database.backend.interfaces.InsertRoleImpl; import org.caosdb.server.database.backend.interfaces.InsertSparseEntityImpl; @@ -109,7 +106,6 @@ import org.caosdb.server.database.backend.interfaces.RetrieveAllUncheckedFilesIm import org.caosdb.server.database.backend.interfaces.RetrieveCurrentMaxIdImpl; import org.caosdb.server.database.backend.interfaces.RetrieveDatatypesImpl; import org.caosdb.server.database.backend.interfaces.RetrieveEntityACLImpl; -import org.caosdb.server.database.backend.interfaces.RetrieveLogRecordImpl; import org.caosdb.server.database.backend.interfaces.RetrieveParentsImpl; import org.caosdb.server.database.backend.interfaces.RetrievePasswordValidatorImpl; import org.caosdb.server.database.backend.interfaces.RetrievePermissionRulesImpl; @@ -213,8 +209,6 @@ public abstract class BackendTransaction implements Undoable { setImpl(SetPermissionRulesImpl.class, MySQLSetPermissionRules.class); setImpl(RetrievePermissionRulesImpl.class, MySQLRetrievePermissionRules.class); setImpl(UpdateUserRolesImpl.class, MySQLUpdateUserRoles.class); - setImpl(InsertLogRecordImpl.class, MySQLInsertLogRecord.class); - setImpl(RetrieveLogRecordImpl.class, MySQLRetrieveLogRecord.class); setImpl(SetQueryTemplateDefinitionImpl.class, MySQLSetQueryTemplateDefinition.class); setImpl( RetrieveQueryTemplateDefinitionImpl.class, MySQLRetrieveQueryTemplateDefinition.class); diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertLogRecord.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertLogRecord.java deleted file mode 100644 index 6807808d18fb6ba9ce0a4ed9287ea21612cc2d2c..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLInsertLogRecord.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.implementation.MySQL; - -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.List; -import java.util.logging.LogRecord; -import org.caosdb.server.database.access.Access; -import org.caosdb.server.database.backend.interfaces.InsertLogRecordImpl; -import org.caosdb.server.database.exceptions.TransactionException; - -public class MySQLInsertLogRecord extends MySQLTransaction implements InsertLogRecordImpl { - - public MySQLInsertLogRecord(final Access access) { - super(access); - } - - public static final String STMT_INSERT_LOG_RECORD = - "INSERT INTO logging (level, logger, message, millis, logRecord) VALUES (?,?,?,?,?)"; - - @Override - public void insert(final List<LogRecord> toBeFlushed) throws TransactionException { - try { - final PreparedStatement prepInsert = prepareStatement(STMT_INSERT_LOG_RECORD); - for (final LogRecord record : toBeFlushed) { - prepInsert.setInt(1, record.getLevel().intValue()); - prepInsert.setString(2, record.getLoggerName()); - prepInsert.setString(3, record.getMessage()); - prepInsert.setLong(4, record.getMillis()); - prepInsert.setObject(5, record); - prepInsert.executeUpdate(); - } - } catch (final SQLException e) { - throw new TransactionException(e); - } catch (final ConnectionException e) { - throw new TransactionException(e); - } - } -} diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveLogRecord.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveLogRecord.java deleted file mode 100644 index bba36d2eb9de29fee40f023b9b97602d5b94b8a3..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveLogRecord.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.implementation.MySQL; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import org.caosdb.server.database.access.Access; -import org.caosdb.server.database.backend.interfaces.RetrieveLogRecordImpl; -import org.caosdb.server.database.exceptions.TransactionException; - -public class MySQLRetrieveLogRecord extends MySQLTransaction implements RetrieveLogRecordImpl { - - public MySQLRetrieveLogRecord(final Access access) { - super(access); - } - - public static final String STMT_RETRIEVE_LOG = "SELECT logRecord FROM logging"; - public static final String WHERE = " WHERE "; - public static final String AND = " AND "; - public static final String LOGGER_COND = "logger LIKE ?"; - public static final String MESSAGE_COND = "message LIKE ?"; - - public static final String LEVEL_COND(final Level level) { - return "level=" + level.intValue(); - } - - private static String getWhereClause( - final String logger, final Level level, final String message) { - - if (logger != null || level != null || message != null) { - final StringBuilder sb = new StringBuilder(); - - if (logger != null) { - sb.append(LOGGER_COND); - } - if (level != null) { - if (sb.length() > 0) { - sb.append(AND); - } - sb.append(LEVEL_COND(level)); - } - if (message != null) { - if (sb.length() > 0) { - sb.append(AND); - } - sb.append(MESSAGE_COND); - } - return WHERE + sb.toString(); - } - return ""; - } - - @Override - public List<LogRecord> retrieve(final String logger, final Level level, final String message) - throws TransactionException { - final List<LogRecord> ret = new LinkedList<LogRecord>(); - - final String stmtStr = STMT_RETRIEVE_LOG + getWhereClause(logger, level, message); - - try { - final PreparedStatement stmt = prepareStatement(stmtStr); - int index = 1; - if (logger != null) { - stmt.setString(index++, logger); - } - if (message != null) { - stmt.setString(index++, message); - } - ResultSet rs = null; - try { - rs = stmt.executeQuery(); - - while (rs.next()) { - final byte[] bytes = rs.getBytes("logRecord"); - - final ObjectInputStream s = new ObjectInputStream(new ByteArrayInputStream(bytes)); - final Object o = s.readObject(); - ret.add((LogRecord) o); - } - } finally { - if (rs != null && !rs.isClosed()) { - rs.close(); - } - } - } catch (final ClassNotFoundException e) { - throw new TransactionException(e); - } catch (final IOException e) { - throw new TransactionException(e); - } catch (final SQLException e) { - throw new TransactionException(e); - } catch (final ConnectionException e) { - throw new TransactionException(e); - } - - return ret; - } -} diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/InsertLogRecordImpl.java b/src/main/java/org/caosdb/server/database/backend/interfaces/InsertLogRecordImpl.java deleted file mode 100644 index 78bab8e251ff6e151963f1be8caf5e73211cc8e3..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/interfaces/InsertLogRecordImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.interfaces; - -import java.util.List; -import java.util.logging.LogRecord; -import org.caosdb.server.database.exceptions.TransactionException; - -public interface InsertLogRecordImpl extends BackendTransactionImpl { - - public void insert(List<LogRecord> toBeFlushed) throws TransactionException; -} diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/RetrieveLogRecordImpl.java b/src/main/java/org/caosdb/server/database/backend/interfaces/RetrieveLogRecordImpl.java deleted file mode 100644 index b6646d269123d70a3b6d06a381c7a83792e1b659..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/interfaces/RetrieveLogRecordImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.interfaces; - -import java.util.List; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import org.caosdb.server.database.exceptions.TransactionException; - -public interface RetrieveLogRecordImpl extends BackendTransactionImpl { - - List<LogRecord> retrieve(String logger, Level level, String message) throws TransactionException; -} diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/InsertLogRecord.java b/src/main/java/org/caosdb/server/database/backend/transaction/InsertLogRecord.java deleted file mode 100644 index 3ce27add49761737c0a8365410c979665a3f16a9..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/transaction/InsertLogRecord.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.transaction; - -import java.util.List; -import java.util.logging.LogRecord; -import org.caosdb.server.database.BackendTransaction; -import org.caosdb.server.database.backend.interfaces.InsertLogRecordImpl; -import org.caosdb.server.database.exceptions.TransactionException; - -public class InsertLogRecord extends BackendTransaction { - - private final List<LogRecord> toBeFlushed; - - public InsertLogRecord(final List<LogRecord> toBeFlushed) { - this.toBeFlushed = toBeFlushed; - } - - @Override - protected void execute() throws TransactionException { - final InsertLogRecordImpl t = getImplementation(InsertLogRecordImpl.class); - t.insert(this.toBeFlushed); - } -} diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/RetrieveLogRecord.java b/src/main/java/org/caosdb/server/database/backend/transaction/RetrieveLogRecord.java deleted file mode 100644 index eae8a96589aab3558a1978890c85bdd18bc161dc..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/database/backend/transaction/RetrieveLogRecord.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.database.backend.transaction; - -import java.util.List; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import org.caosdb.server.database.BackendTransaction; -import org.caosdb.server.database.backend.interfaces.RetrieveLogRecordImpl; -import org.caosdb.server.database.exceptions.TransactionException; - -public class RetrieveLogRecord extends BackendTransaction { - - private final Level level; - private final String logger; - private List<LogRecord> logRecords; - private final String message; - - public RetrieveLogRecord(final String logger, final Level level, final String message) { - this.logger = logger; - this.level = level; - this.message = message; - } - - @Override - protected void execute() throws TransactionException { - final RetrieveLogRecordImpl t = getImplementation(RetrieveLogRecordImpl.class); - this.logRecords = t.retrieve(this.logger, this.level, this.message); - } - - public List<LogRecord> getLogRecords() { - return this.logRecords; - } -} diff --git a/src/main/java/org/caosdb/server/resource/ServerLogsResource.java b/src/main/java/org/caosdb/server/resource/ServerLogsResource.java deleted file mode 100644 index acc1833dc5158d23e72f06f15cf1ddd037185043..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/resource/ServerLogsResource.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.resource; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.sql.SQLException; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.XMLFormatter; -import org.caosdb.server.CaosDBException; -import org.caosdb.server.database.backend.implementation.MySQL.ConnectionException; -import org.caosdb.server.transaction.RetrieveLogRecordTransaction; -import org.restlet.data.Form; -import org.restlet.data.MediaType; -import org.restlet.representation.Representation; -import org.restlet.representation.StringRepresentation; - -public class ServerLogsResource extends AbstractCaosDBServerResource { - - @Override - protected Representation httpGetInChildClass() - throws ConnectionException, - IOException, - SQLException, - CaosDBException, - NoSuchAlgorithmException, - Exception { - - Level level = null; - String message = null; - final String logger = - getRequest().getResourceRef().getRemainingPart(true, false).replaceAll("/", "."); - final Form form = getRequest().getResourceRef().getQueryAsForm(true); - if (form != null) { - final String levelStr = form.getFirstValue("level"); - if (levelStr != null) { - try { - level = Level.parse(levelStr); - } catch (final IllegalArgumentException e) { - level = Level.OFF; - } - } - message = form.getFirstValue("message"); - } - - final RetrieveLogRecordTransaction t = new RetrieveLogRecordTransaction(logger, level, message); - t.execute(); - - generateRootElement(); - final List<LogRecord> logRecords = t.getLogRecords(); - - final XMLFormatter xmlFormatter = new XMLFormatter(); - String ret = xmlFormatter.getHead(null); - for (final LogRecord r : logRecords) { - ret += xmlFormatter.format(r); - } - ret += xmlFormatter.getTail(null); - - return new StringRepresentation(ret, MediaType.TEXT_XML); - } -} diff --git a/src/main/java/org/caosdb/server/transaction/InsertLogRecordTransaction.java b/src/main/java/org/caosdb/server/transaction/InsertLogRecordTransaction.java deleted file mode 100644 index 950d9b8d25688e47833b60c01335f8dd525a0630..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/transaction/InsertLogRecordTransaction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.transaction; - -import java.util.List; -import java.util.logging.LogRecord; -import org.caosdb.datetime.UTCDateTime; -import org.caosdb.server.database.DatabaseAccessManager; -import org.caosdb.server.database.access.Access; -import org.caosdb.server.database.backend.transaction.InsertLogRecord; - -public class InsertLogRecordTransaction implements TransactionInterface { - - private final List<LogRecord> toBeFlushed; - private UTCDateTime timestamp; - - public InsertLogRecordTransaction(final List<LogRecord> toBeFlushed) { - this.timestamp = UTCDateTime.SystemMillisToUTCDateTime(System.currentTimeMillis()); - this.toBeFlushed = toBeFlushed; - } - - @Override - public void execute() throws Exception { - final Access access = DatabaseAccessManager.getInstance().acquireReadAccess(this); - try { - execute(new InsertLogRecord(this.toBeFlushed), access); - } finally { - access.release(); - } - } - - @Override - public UTCDateTime getTimestamp() { - return timestamp; - } -} diff --git a/src/main/java/org/caosdb/server/transaction/RetrieveLogRecordTransaction.java b/src/main/java/org/caosdb/server/transaction/RetrieveLogRecordTransaction.java deleted file mode 100644 index 2f6cafd6e4e55ab868f69f1d3414a2196f0a4fea..0000000000000000000000000000000000000000 --- a/src/main/java/org/caosdb/server/transaction/RetrieveLogRecordTransaction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ** header v3.0 - * This file is a part of the CaosDB Project. - * - * Copyright (C) 2018 Research Group Biomedical Physics, - * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - * - * ** end header - */ -package org.caosdb.server.transaction; - -import java.util.List; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import org.apache.shiro.SecurityUtils; -import org.caosdb.datetime.UTCDateTime; -import org.caosdb.server.accessControl.ACMPermissions; -import org.caosdb.server.database.DatabaseAccessManager; -import org.caosdb.server.database.access.Access; -import org.caosdb.server.database.backend.transaction.RetrieveLogRecord; - -public class RetrieveLogRecordTransaction implements TransactionInterface { - - private List<LogRecord> logRecords; - private final String logger; - private final Level level; - private final String message; - private UTCDateTime timestamp; - - public RetrieveLogRecordTransaction( - final String logger, final Level level, final String message) { - this.level = level; - this.timestamp = UTCDateTime.SystemMillisToUTCDateTime(System.currentTimeMillis()); - if (message != null && message.isEmpty()) { - this.message = null; - } else if (message != null) { - this.message = message.replaceAll("\\*", "%"); - } else { - this.message = null; - } - if (logger != null && logger.isEmpty()) { - this.logger = null; - } else if (logger != null) { - this.logger = logger.replaceAll("\\*", "%"); - } else { - this.logger = logger; - } - } - - @Override - public void execute() throws Exception { - SecurityUtils.getSubject().checkPermission(ACMPermissions.PERMISSION_RETRIEVE_SERVERLOGS); - final Access access = DatabaseAccessManager.getInstance().acquireReadAccess(this); - try { - this.logRecords = - execute(new RetrieveLogRecord(this.logger, this.level, this.message), access) - .getLogRecords(); - } finally { - access.release(); - } - } - - public List<LogRecord> getLogRecords() { - return this.logRecords; - } - - @Override - public UTCDateTime getTimestamp() { - return timestamp; - } -}