diff --git a/newrelic/logs/newrelic_agent.log b/newrelic/logs/newrelic_agent.log index ea63a23..19f83d2 100644 --- a/newrelic/logs/newrelic_agent.log +++ b/newrelic/logs/newrelic_agent.log @@ -92,3 +92,102 @@ 2024-11-20T19:25:06,594-0300 [26128 28] com.newrelic.agent.core.CoreServiceImpl INFO: JVM is shutting down 2024-11-20T19:25:06,683-0300 [26128 62] com.newrelic INFO: Transaction com.newrelic.agent.Transaction@59a46d3e tried to finish but ServiceManager not started 2024-11-20T19:25:07,255-0300 [26128 28] com.newrelic.agent.core.CoreServiceImpl INFO: New Relic Agent has shutdown +2024-11-20T19:43:22,292-0300 [5200 1] com.newrelic INFO: Writing to New Relic log file: C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\logs\newrelic_agent.log +2024-11-20T19:43:22,293-0300 [5200 1] com.newrelic INFO: JRE vendor Oracle Corporation version 21.0.4 +2024-11-20T19:43:22,293-0300 [5200 1] com.newrelic INFO: JVM vendor Oracle Corporation Java HotSpot(TM) 64-Bit Server VM version 21.0.4+8-LTS-274 +2024-11-20T19:43:22,293-0300 [5200 1] com.newrelic INFO: OS Windows 10 version 10.0 arch amd64 +2024-11-20T19:43:22,293-0300 [5200 1] com.newrelic INFO: Agent Host: DESKTOP-LIHK26P IP: 192.168.56.1 +2024-11-20T19:43:22,293-0300 [5200 1] com.newrelic INFO: New Relic Agent v8.15.0 is initializing... +2024-11-20T19:43:22,641-0300 [5200 36] com.newrelic INFO: Instrumentation com.newrelic.instrumentation.jdbc-resultset is disabled. Skipping. +2024-11-20T19:43:23,252-0300 [5200 1] com.newrelic.agent.RPMServiceManagerImpl INFO: Configured to connect to New Relic at collector.newrelic.com:443 +2024-11-20T19:43:23,399-0300 [5200 1] com.newrelic INFO: Setting audit_mode to false +2024-11-20T19:43:23,488-0300 [5200 1] com.newrelic.agent.config.ConfigServiceImpl INFO: Configuration file is C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\.\newrelic.yml +2024-11-20T19:43:23,491-0300 [5200 1] com.newrelic INFO: New Relic Agent v8.15.0 has started +2024-11-20T19:43:23,491-0300 [5200 1] com.newrelic INFO: Agent class loader: com.newrelic.bootstrap.BootstrapAgent$JVMAgentClassLoader@5c0369c4 +2024-11-20T19:43:23,491-0300 [5200 1] com.newrelic INFO: Premain startup complete in 1.832ms +2024-11-20T19:43:23,492-0300 [5200 1] com.newrelic INFO: New Relic Security is completely disabled by one of the user provided config `security.enabled`, `security.agent.enabled` or `high_security`. Not loading security capabilities. +2024-11-20T19:43:26,121-0300 [5200 1] com.newrelic INFO: Server Info: Apache Tomcat/10.1.30 +2024-11-20T19:43:33,504-0300 [5200 57] com.newrelic INFO: Host name is DESKTOP-LIHK26P, display host DESKTOP-LIHK26P for application snippet-permission +2024-11-20T19:43:33,505-0300 [5200 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-20T19:43:34,809-0300 [5200 57] com.newrelic INFO: Collector redirection to collector.newrelic.com:443 +2024-11-20T19:43:35,462-0300 [5200 57] com.newrelic INFO: Max payload size is 1.000.000 bytes +2024-11-20T19:43:35,462-0300 [5200 57] com.newrelic INFO: Agent run id: BYUYGRPTy4VeAF4tVEyaJFFnPmZsAAIBAAAnIQEAABRQAgRMnQT1AwAGOC4xNS4wAA9ERVNLVE9QLUxJSEsyNlAAEnNuaXBwZXQtcGVybWlzc2lvbg +2024-11-20T19:43:35,462-0300 [5200 57] com.newrelic INFO: Agent 5200@DESKTOP-LIHK26P/snippet-permission connected to collector.newrelic.com:443 +2024-11-20T19:43:35,462-0300 [5200 57] com.newrelic INFO: Reporting to: https://rpm.newrelic.com/accounts/6171988/applications/1285358837 +2024-11-20T19:43:35,463-0300 [5200 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-20T19:43:35,463-0300 [5200 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-20T19:43:35,463-0300 [5200 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-20T19:43:35,465-0300 [5200 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-20T19:43:35,465-0300 [5200 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-20T19:43:35,465-0300 [5200 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-20T19:43:36,286-0300 [5200 57] com.newrelic INFO: Real user monitoring is enabled for application snippet-permission. Auto instrumentation is enabled. +2024-11-20T19:43:36,286-0300 [5200 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-20T19:46:26,037-0300 [5200 27] com.newrelic.agent.core.CoreServiceImpl INFO: JVM is shutting down +2024-11-20T19:46:26,153-0300 [5200 62] com.newrelic INFO: Transaction com.newrelic.agent.Transaction@28906ce7 tried to finish but ServiceManager not started +2024-11-20T19:46:26,861-0300 [5200 27] com.newrelic.agent.core.CoreServiceImpl INFO: New Relic Agent has shutdown +2024-11-20T23:04:03,831-0300 [29272 1] com.newrelic INFO: Writing to New Relic log file: C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\logs\newrelic_agent.log +2024-11-20T23:04:03,832-0300 [29272 1] com.newrelic INFO: JRE vendor Oracle Corporation version 21.0.4 +2024-11-20T23:04:03,832-0300 [29272 1] com.newrelic INFO: JVM vendor Oracle Corporation Java HotSpot(TM) 64-Bit Server VM version 21.0.4+8-LTS-274 +2024-11-20T23:04:03,832-0300 [29272 1] com.newrelic INFO: OS Windows 10 version 10.0 arch amd64 +2024-11-20T23:04:03,832-0300 [29272 1] com.newrelic INFO: Agent Host: DESKTOP-LIHK26P IP: 192.168.56.1 +2024-11-20T23:04:03,832-0300 [29272 1] com.newrelic INFO: New Relic Agent v8.15.0 is initializing... +2024-11-20T23:04:04,308-0300 [29272 36] com.newrelic INFO: Instrumentation com.newrelic.instrumentation.jdbc-resultset is disabled. Skipping. +2024-11-20T23:04:05,670-0300 [29272 1] com.newrelic.agent.RPMServiceManagerImpl INFO: Configured to connect to New Relic at collector.newrelic.com:443 +2024-11-20T23:04:05,915-0300 [29272 1] com.newrelic INFO: Setting audit_mode to false +2024-11-20T23:04:06,053-0300 [29272 1] com.newrelic.agent.config.ConfigServiceImpl INFO: Configuration file is C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\.\newrelic.yml +2024-11-20T23:04:06,056-0300 [29272 1] com.newrelic INFO: New Relic Agent v8.15.0 has started +2024-11-20T23:04:06,056-0300 [29272 1] com.newrelic INFO: Agent class loader: com.newrelic.bootstrap.BootstrapAgent$JVMAgentClassLoader@5c0369c4 +2024-11-20T23:04:06,056-0300 [29272 1] com.newrelic INFO: Premain startup complete in 3.126ms +2024-11-20T23:04:06,058-0300 [29272 1] com.newrelic INFO: New Relic Security is completely disabled by one of the user provided config `security.enabled`, `security.agent.enabled` or `high_security`. Not loading security capabilities. +2024-11-20T23:04:09,356-0300 [29272 1] com.newrelic INFO: Server Info: Apache Tomcat/10.1.30 +2024-11-20T23:04:16,079-0300 [29272 57] com.newrelic INFO: Host name is DESKTOP-LIHK26P, display host DESKTOP-LIHK26P for application snippet-permission +2024-11-20T23:04:16,080-0300 [29272 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-20T23:04:17,394-0300 [29272 57] com.newrelic INFO: Collector redirection to collector.newrelic.com:443 +2024-11-20T23:04:18,514-0300 [29272 57] com.newrelic INFO: Max payload size is 1.000.000 bytes +2024-11-20T23:04:18,514-0300 [29272 57] com.newrelic INFO: Agent run id: BefkIDS_jGWEAF4tVEyaJFFnPpWIAAIBAAAnIQEAAHJYAgRMnQT1AwAGOC4xNS4wAA9ERVNLVE9QLUxJSEsyNlAAEnNuaXBwZXQtcGVybWlzc2lvbg +2024-11-20T23:04:18,514-0300 [29272 57] com.newrelic INFO: Agent 29272@DESKTOP-LIHK26P/snippet-permission connected to collector.newrelic.com:443 +2024-11-20T23:04:18,514-0300 [29272 57] com.newrelic INFO: Reporting to: https://rpm.newrelic.com/accounts/6171988/applications/1285358837 +2024-11-20T23:04:18,515-0300 [29272 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-20T23:04:18,516-0300 [29272 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-20T23:04:18,516-0300 [29272 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-20T23:04:18,517-0300 [29272 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-20T23:04:18,517-0300 [29272 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-20T23:04:18,517-0300 [29272 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-20T23:04:20,667-0300 [29272 57] com.newrelic INFO: Real user monitoring is enabled for application snippet-permission. Auto instrumentation is enabled. +2024-11-20T23:04:20,667-0300 [29272 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-21T01:26:56,221-0300 [29272 31] com.newrelic.agent.core.CoreServiceImpl INFO: JVM is shutting down +2024-11-21T01:26:56,260-0300 [29272 62] com.newrelic INFO: Transaction com.newrelic.agent.Transaction@3cbd5908 tried to finish but ServiceManager not started +2024-11-21T01:26:56,474-0300 [29272 31] com.newrelic.agent.core.CoreServiceImpl INFO: New Relic Agent has shutdown +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: Writing to New Relic log file: C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\logs\newrelic_agent.log +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: JRE vendor Oracle Corporation version 21.0.4 +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: JVM vendor Oracle Corporation Java HotSpot(TM) 64-Bit Server VM version 21.0.4+8-LTS-274 +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: OS Windows 10 version 10.0 arch amd64 +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: Agent Host: DESKTOP-LIHK26P IP: 192.168.56.1 +2024-11-21T03:56:59,060-0300 [24584 1] com.newrelic INFO: New Relic Agent v8.15.0 is initializing... +2024-11-21T03:56:59,591-0300 [24584 36] com.newrelic INFO: Instrumentation com.newrelic.instrumentation.jdbc-resultset is disabled. Skipping. +2024-11-21T03:57:00,617-0300 [24584 1] com.newrelic.agent.RPMServiceManagerImpl INFO: Configured to connect to New Relic at collector.newrelic.com:443 +2024-11-21T03:57:00,824-0300 [24584 1] com.newrelic INFO: Setting audit_mode to false +2024-11-21T03:57:00,926-0300 [24584 1] com.newrelic.agent.config.ConfigServiceImpl INFO: Configuration file is C:\Users\Tobias\IdeaProjects\snippet-permission\newrelic\.\newrelic.yml +2024-11-21T03:57:00,930-0300 [24584 1] com.newrelic INFO: New Relic Agent v8.15.0 has started +2024-11-21T03:57:00,931-0300 [24584 1] com.newrelic INFO: Agent class loader: com.newrelic.bootstrap.BootstrapAgent$JVMAgentClassLoader@5c0369c4 +2024-11-21T03:57:00,931-0300 [24584 1] com.newrelic INFO: Premain startup complete in 2.898ms +2024-11-21T03:57:00,933-0300 [24584 1] com.newrelic INFO: New Relic Security is completely disabled by one of the user provided config `security.enabled`, `security.agent.enabled` or `high_security`. Not loading security capabilities. +2024-11-21T03:57:04,521-0300 [24584 1] com.newrelic INFO: Server Info: Apache Tomcat/10.1.30 +2024-11-21T03:57:10,944-0300 [24584 57] com.newrelic INFO: Host name is DESKTOP-LIHK26P, display host DESKTOP-LIHK26P for application snippet-permission +2024-11-21T03:57:10,945-0300 [24584 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-21T03:57:11,787-0300 [24584 57] com.newrelic INFO: Collector redirection to collector.newrelic.com:443 +2024-11-21T03:57:12,457-0300 [24584 57] com.newrelic INFO: Max payload size is 1.000.000 bytes +2024-11-21T03:57:12,457-0300 [24584 57] com.newrelic INFO: Agent run id: BdWwgDX6yj5pAF4tVEyaJFFnPto0AAIBAAAnIQEAAGAIAgRMnQT1AwAGOC4xNS4wAA9ERVNLVE9QLUxJSEsyNlAAEnNuaXBwZXQtcGVybWlzc2lvbg +2024-11-21T03:57:12,457-0300 [24584 57] com.newrelic INFO: Agent 24584@DESKTOP-LIHK26P/snippet-permission connected to collector.newrelic.com:443 +2024-11-21T03:57:12,457-0300 [24584 57] com.newrelic INFO: Reporting to: https://rpm.newrelic.com/accounts/6171988/applications/1285358837 +2024-11-21T03:57:12,459-0300 [24584 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-21T03:57:12,459-0300 [24584 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-21T03:57:12,459-0300 [24584 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-21T03:57:12,460-0300 [24584 57] com.newrelic INFO: Using default collector host: collector.newrelic.com +2024-11-21T03:57:12,460-0300 [24584 57] com.newrelic INFO: Using default metric ingest URI: https://metric-api.newrelic.com/metric/v1 +2024-11-21T03:57:12,460-0300 [24584 57] com.newrelic INFO: Using default event ingest URI: https://insights-collector.newrelic.com/v1/accounts/events +2024-11-21T03:57:12,791-0300 [24584 57] com.newrelic INFO: Real user monitoring is enabled for application snippet-permission. Auto instrumentation is enabled. +2024-11-21T03:57:12,791-0300 [24584 57] com.newrelic INFO: New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent. +2024-11-21T04:42:44,861-0300 [24584 27] com.newrelic.agent.core.CoreServiceImpl INFO: JVM is shutting down +2024-11-21T04:42:44,889-0300 [24584 62] com.newrelic INFO: Transaction com.newrelic.agent.Transaction@d48625e tried to finish but ServiceManager not started +2024-11-21T04:42:45,661-0300 [24584 27] com.newrelic.agent.core.CoreServiceImpl INFO: New Relic Agent has shutdown diff --git a/src/main/kotlin/org/prinstcript10/snippetpermission/permission/service/PermissionService.kt b/src/main/kotlin/org/prinstcript10/snippetpermission/permission/service/PermissionService.kt index 5303320..2047e68 100644 --- a/src/main/kotlin/org/prinstcript10/snippetpermission/permission/service/PermissionService.kt +++ b/src/main/kotlin/org/prinstcript10/snippetpermission/permission/service/PermissionService.kt @@ -7,6 +7,7 @@ import org.prinstcript10.snippetpermission.permission.model.enum.SnippetOwnershi import org.prinstcript10.snippetpermission.permission.repository.SnippetPermissionRepository import org.prinstcript10.snippetpermission.shared.exception.ConflictException import org.prinstcript10.snippetpermission.shared.exception.NotFoundException +import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.dao.DataAccessException import org.springframework.stereotype.Service @@ -17,12 +18,16 @@ class PermissionService( private val permissionRepository: SnippetPermissionRepository, ) { + private val logger = LoggerFactory.getLogger(PermissionService::class.java) + fun createSnippetPermission( snippetId: String, userId: String, ) { val permissions = permissionRepository.findAllBySnippetId(snippetId) + logger.info("Creating snippet permission for snippet: $snippetId") if (permissions.isNotEmpty()) { + logger.error("Permission for: $snippetId, already exists for user: $userId") throw ConflictException("Permission already exists for this snippet") } @@ -33,19 +38,23 @@ class PermissionService( ownership = SnippetOwnership.OWNER, ), ) + logger.info("Snippet permission for snippet: $snippetId created successfully") } fun shareSnippet(shareSnippetDTO: ShareSnippetDTO, userId: String) { + logger.info("Sharing snippet: ${shareSnippetDTO.snippetId} to user: ${shareSnippetDTO.userId}") val permission = permissionRepository.findByUserIdAndSnippetId( userId = userId, snippetId = shareSnippetDTO.snippetId, ) if (permission == null) { + logger.error("Missing permission for user: $userId") throw NotFoundException("No permission found matching that userId and snippetId") } if (permission.ownership != SnippetOwnership.OWNER) { + logger.error("User: $userId is not owner and cannot share snippet: ${shareSnippetDTO.snippetId}") throw ConflictException("You do not have permission to share this snippet") } @@ -57,51 +66,62 @@ class PermissionService( ownership = SnippetOwnership.SHARED, ), ) + logger.info("Snippet: ${shareSnippetDTO.snippetId} shared successfully to user: ${shareSnippetDTO.userId}") } catch (e: DataAccessException) { + logger.error("Failed to save permission due to a conflict: " + e.message) throw ConflictException("Failed to save permission due to a conflict: " + e.message) } } fun getSnippetPermission(snippetId: String, userId: String): SnippetPermission { + logger.info("Getting snippet permission for snippet: $snippetId and user: $userId") val permission = permissionRepository.findByUserIdAndSnippetId( userId = userId, snippetId = snippetId, ) if (permission == null) { + logger.error("Missing permission for user: $userId") throw NotFoundException("No permission found matching that userId and snippetId") } return permission } fun getAllSnippetPermissions(userId: String): List { + logger.info("Getting all snippet permissions for user: $userId") return permissionRepository.findByUserId(userId) } @Transactional fun deleteSnippetPermissions(snippetId: String, userId: String) { + logger.info("Deleting snippet permissions: $snippetId") val permission = permissionRepository.findByUserIdAndSnippetId( userId = userId, snippetId = snippetId, ) if (permission == null) { + logger.error("Missing permission for user: $userId") throw NotFoundException("No permission found matching that userId and snippetId") } if (permission.ownership != SnippetOwnership.OWNER) { + logger.error("User: $userId is not owner and cannot delete this snippet") throw ConflictException("You do not have permission to delete this snippet") } permissionRepository.deleteAllBySnippetId(snippetId) + logger.info("Deleted snippet permission successfully for snippet: $snippetId user: $userId") } fun getSnippetOwner(snippetId: String, userId: String): SnippetPermission { + logger.info("Getting ownership for snippet: $snippetId") val permission = permissionRepository.findByUserIdAndSnippetId( userId = userId, snippetId = snippetId, ) if (permission == null) { + logger.error("Missing permission for user: $userId") throw NotFoundException("No permission found matching that userId and snippetId") }