From e14a4aa89a3662fd0b84f548d3dc226195acdf4a Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:03:53 +0900 Subject: [PATCH] wip --- ...WithHttpSignatureSecurityContextFactory.kt | 2 +- .../RegisterLocalPostApplicationService.kt | 35 ++++++++----- .../hideout/core/config/SecurityConfig.kt | 20 +++++++ .../FailedToGetResourcesException.kt | 31 ----------- .../exception/HttpSignatureVerifyException.kt | 30 ----------- .../core/domain/exception/NotInitException.kt | 31 ----------- .../domain/exception/UserNotFoundException.kt | 31 ----------- .../exception/media/MediaConvertException.kt | 37 ------------- .../domain/exception/media/MediaException.kt | 38 -------------- .../exception/media/MediaFileSizeException.kt | 37 ------------- .../media/MediaFileSizeIsZeroException.kt | 37 ------------- .../exception/media/MediaProcessException.kt | 37 ------------- .../exception/media/MediaSaveException.kt | 30 ----------- .../media/RemoteMediaFileSizeException.kt | 37 ------------- .../media/UnsupportedMediaException.kt | 37 ------------- .../resource/PostNotFoundException.kt | 43 --------------- .../resource/UserNotFoundException.kt | 52 ------------------- .../local/LocalUserNotFoundException.kt | 47 ----------------- .../hideout/worker/ReceiveFollowTaskRunner.kt | 2 +- 19 files changed, 44 insertions(+), 570 deletions(-) delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/FailedToGetResourcesException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/HttpSignatureVerifyException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/NotInitException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/UserNotFoundException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaConvertException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeIsZeroException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaProcessException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaSaveException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/RemoteMediaFileSizeException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/UnsupportedMediaException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/PostNotFoundException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/UserNotFoundException.kt delete mode 100644 hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/local/LocalUserNotFoundException.kt diff --git a/hideout-core/src/intTest/kotlin/util/WithHttpSignatureSecurityContextFactory.kt b/hideout-core/src/intTest/kotlin/util/WithHttpSignatureSecurityContextFactory.kt index ab161ca7..7ec4aaa5 100644 --- a/hideout-core/src/intTest/kotlin/util/WithHttpSignatureSecurityContextFactory.kt +++ b/hideout-core/src/intTest/kotlin/util/WithHttpSignatureSecurityContextFactory.kt @@ -17,7 +17,7 @@ package util import dev.usbharu.hideout.core.application.shared.Transaction -import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException +import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.infrastructure.springframework.httpsignature.HttpSignatureUser import dev.usbharu.httpsignature.common.HttpHeaders import dev.usbharu.httpsignature.common.HttpMethod diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt index 8aac1a77..3b6dcd8c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/post/RegisterLocalPostApplicationService.kt @@ -16,6 +16,9 @@ package dev.usbharu.hideout.core.application.post +import dev.usbharu.hideout.core.application.shared.AbstractApplicationService +import dev.usbharu.hideout.core.application.shared.CommandExecutor +import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.actor.ActorId import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.domain.model.media.MediaId @@ -23,6 +26,8 @@ import dev.usbharu.hideout.core.domain.model.post.PostId import dev.usbharu.hideout.core.domain.model.post.PostOverview import dev.usbharu.hideout.core.domain.model.post.PostRepository import dev.usbharu.hideout.core.infrastructure.factory.PostFactoryImpl +import org.slf4j.Logger +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service @@ -30,20 +35,24 @@ class RegisterLocalPostApplicationService( private val postFactory: PostFactoryImpl, private val actorRepository: ActorRepository, private val postRepository: PostRepository, -) { - suspend fun register(registerLocalPost: RegisterLocalPost) { - val actorId = ActorId(registerLocalPost.actorId) - val post = postFactory.createLocal( - actorId, + transaction: Transaction, +) : AbstractApplicationService(transaction, Companion.logger) { + + companion object { + val logger: Logger = LoggerFactory.getLogger(RegisterLocalPostApplicationService::class.java) + } + + override suspend fun internalExecute(command: RegisterLocalPost, executor: CommandExecutor) { + val actorId = ActorId(command.actorId) + val post = postFactory.createLocal(actorId, actorRepository.findById(actorId)!!.name, - PostOverview(registerLocalPost.overview), - registerLocalPost.content, - registerLocalPost.visibility, - registerLocalPost.repostId?.let { PostId(it) }, - registerLocalPost.replyId?.let { PostId(it) }, - registerLocalPost.sensitive, - registerLocalPost.mediaIds.map { MediaId(it) } - ) + PostOverview(command.overview), + command.content, + command.visibility, + command.repostId?.let { PostId(it) }, + command.replyId?.let { PostId(it) }, + command.sensitive, + command.mediaIds.map { MediaId(it) }) postRepository.save(post) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt index 805b7730..cd4051d9 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt @@ -16,6 +16,7 @@ package dev.usbharu.hideout.core.config +import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.HideoutUserDetails import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.annotation.Order @@ -27,14 +28,19 @@ import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity import org.springframework.security.config.annotation.web.invoke +import org.springframework.security.core.Authentication import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.password.PasswordEncoder +import org.springframework.security.oauth2.core.AuthorizationGrantType import org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationConsentService import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsentService +import org.springframework.security.oauth2.server.authorization.OAuth2TokenType import org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings +import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext +import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer import org.springframework.security.web.SecurityFilterChain import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint @@ -99,6 +105,20 @@ class SecurityConfig { .tokenEndpoint("/oauth/token").tokenRevocationEndpoint("/oauth/revoke").build() } + @Bean + fun jwtTokenCustomizer(): OAuth2TokenCustomizer { + return OAuth2TokenCustomizer { context: JwtEncodingContext -> + + if (OAuth2TokenType.ACCESS_TOKEN == context.tokenType && + context.authorization?.authorizationGrantType == AuthorizationGrantType.AUTHORIZATION_CODE + ) { + val userDetailsImpl = context.getPrincipal().principal as HideoutUserDetails + context.claims.claim("uid", userDetailsImpl.userDetailsId.toString()) + } + } + } + + @Bean fun roleHierarchy(): RoleHierarchy { val roleHierarchyImpl = RoleHierarchyImpl.fromHierarchy( diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/FailedToGetResourcesException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/FailedToGetResourcesException.kt deleted file mode 100644 index cda900d4..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/FailedToGetResourcesException.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception - -import java.io.Serial - -open class FailedToGetResourcesException : IllegalArgumentException { - constructor() : super() - constructor(s: String?) : super(s) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - - companion object { - @Serial - private const val serialVersionUID: Long = -3117221954866309059L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/HttpSignatureVerifyException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/HttpSignatureVerifyException.kt deleted file mode 100644 index ef22cec4..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/HttpSignatureVerifyException.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception - -import java.io.Serial -import javax.naming.AuthenticationException - -class HttpSignatureVerifyException : AuthenticationException { - constructor() : super() - constructor(s: String?) : super(s) - - companion object { - @Serial - private const val serialVersionUID: Long = 1484943321770741944L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/NotInitException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/NotInitException.kt deleted file mode 100644 index 8118eb7e..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/NotInitException.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception - -import java.io.Serial - -class NotInitException : IllegalStateException { - constructor() : super() - constructor(s: String?) : super(s) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - - companion object { - @Serial - private const val serialVersionUID: Long = -5859046179473905716L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/UserNotFoundException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/UserNotFoundException.kt deleted file mode 100644 index a70c9256..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/UserNotFoundException.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception - -import java.io.Serial - -class UserNotFoundException : IllegalArgumentException { - constructor() : super() - constructor(s: String?) : super(s) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - - companion object { - @Serial - private const val serialVersionUID: Long = 6343548635914580823L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaConvertException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaConvertException.kt deleted file mode 100644 index 08e693c9..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaConvertException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -open class MediaConvertException : MediaException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = -6349105549968160551L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaException.kt deleted file mode 100644 index b406ae99..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaException.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -@Suppress("UnnecessaryAbstractClass") -abstract class MediaException : RuntimeException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = 5988922562494187852L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeException.kt deleted file mode 100644 index 7a99d7c3..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -open class MediaFileSizeException : MediaException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = 8672626879026555064L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeIsZeroException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeIsZeroException.kt deleted file mode 100644 index 12b0dba0..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaFileSizeIsZeroException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -class MediaFileSizeIsZeroException : MediaFileSizeException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = -2398394583775317875L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaProcessException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaProcessException.kt deleted file mode 100644 index fc4bff6c..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaProcessException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -class MediaProcessException : MediaException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = -5195233013542703735L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaSaveException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaSaveException.kt deleted file mode 100644 index d4fddbf6..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/MediaSaveException.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -open class MediaSaveException : MediaException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/RemoteMediaFileSizeException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/RemoteMediaFileSizeException.kt deleted file mode 100644 index ed52372b..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/RemoteMediaFileSizeException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -class RemoteMediaFileSizeException : MediaFileSizeException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = 9188247721397839435L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/UnsupportedMediaException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/UnsupportedMediaException.kt deleted file mode 100644 index 1a97958f..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/media/UnsupportedMediaException.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.media - -import java.io.Serial - -class UnsupportedMediaException : MediaException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = -116741513216017134L - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/PostNotFoundException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/PostNotFoundException.kt deleted file mode 100644 index b723fa1a..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/PostNotFoundException.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.resource - -import java.io.Serial - -class PostNotFoundException : NotFoundException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = 1315818410686905717L - - fun withApId(apId: String): PostNotFoundException = PostNotFoundException("apId: $apId was not found.") - - fun withId(id: Long): PostNotFoundException = PostNotFoundException("id: $id was not found.") - - fun withUrl(url: String): PostNotFoundException = PostNotFoundException("url: $url was not found.") - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/UserNotFoundException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/UserNotFoundException.kt deleted file mode 100644 index 223e7820..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/UserNotFoundException.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.resource - -import java.io.Serial - -open class UserNotFoundException : NotFoundException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = 3219433672235626200L - - fun withName(string: String, throwable: Throwable? = null): UserNotFoundException = - UserNotFoundException("name: $string was not found.", throwable) - - fun withId(id: Long, throwable: Throwable? = null): UserNotFoundException = - UserNotFoundException("id: $id was not found.", throwable) - - fun withUrl(url: String, throwable: Throwable? = null): UserNotFoundException = - UserNotFoundException("url: $url was not found.", throwable) - - fun withNameAndDomain(name: String, domain: String, throwable: Throwable? = null): UserNotFoundException = - UserNotFoundException("name: $name domain: $domain (@$name@$domain) was not found.", throwable) - - fun withKeyId(keyId: String, throwable: Throwable? = null) = - UserNotFoundException("keyId: $keyId was not found.", throwable) - } -} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/local/LocalUserNotFoundException.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/local/LocalUserNotFoundException.kt deleted file mode 100644 index 939b711c..00000000 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/exception/resource/local/LocalUserNotFoundException.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * 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. - */ - -package dev.usbharu.hideout.core.domain.exception.resource.local - -import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException -import java.io.Serial - -class LocalUserNotFoundException : UserNotFoundException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) - constructor(message: String?, cause: Throwable?, enableSuppression: Boolean, writableStackTrace: Boolean) : super( - message, - cause, - enableSuppression, - writableStackTrace - ) - - companion object { - @Serial - private const val serialVersionUID: Long = -4742548128672528145L - - fun withName(string: String, throwable: Throwable? = null): LocalUserNotFoundException = - LocalUserNotFoundException("name: $string was not found.", throwable) - - fun withId(id: Long, throwable: Throwable? = null): LocalUserNotFoundException = - LocalUserNotFoundException("id: $id was not found.", throwable) - - fun withUrl(url: String, throwable: Throwable? = null): LocalUserNotFoundException = - LocalUserNotFoundException("url: $url was not found.", throwable) - } -} diff --git a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/ReceiveFollowTaskRunner.kt b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/ReceiveFollowTaskRunner.kt index 9a73010f..72916733 100644 --- a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/ReceiveFollowTaskRunner.kt +++ b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/ReceiveFollowTaskRunner.kt @@ -18,7 +18,7 @@ package dev.usbharu.hideout.worker import dev.usbharu.hideout.activitypub.service.objects.user.APUserService import dev.usbharu.hideout.core.application.shared.Transaction -import dev.usbharu.hideout.core.domain.exception.resource.UserNotFoundException +import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.external.job.ReceiveFollowTask import dev.usbharu.hideout.core.external.job.ReceiveFollowTaskDef import dev.usbharu.owl.consumer.AbstractTaskRunner