Skip to content
Snippets Groups Projects
Verified Commit fe42685a authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'dev' into f-select-acl

parents 9b088c44 eab297f9
Branches
Tags
2 merge requests!111Release 0.12.1,!109F select acl
Showing
with 24 additions and 591 deletions
......@@ -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)
......
......@@ -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)
```
......@@ -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
......@@ -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>
......
......@@ -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 ---------------------------------------------------
......
......@@ -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);
......
......@@ -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);
......
/*
* ** 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);
}
}
}
/*
* ** 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;
}
}
/*
* ** 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;
}
/*
* ** 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;
}
/*
* ** 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);
}
}
/*
* ** 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;
}
}
/*
* ** 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);
}
}
/*
* ** 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;
}
}
/*
* ** 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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment