Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(admin): refactor projects & users value objects (DEV-240) #1976

Merged
merged 22 commits into from Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f17ca46
refactor(userADM): user create payload
mpro7 Jan 6, 2022
6296d23
refactor(userADM): add error messages + update value objects
mpro7 Jan 6, 2022
138ef4c
refactor(userADM): move value objects to dedicated file
mpro7 Jan 6, 2022
7a408fb
refactor(userADM): add value objects unit tests + error messages
mpro7 Jan 7, 2022
dffc9e8
refactor(userADM): remove old user value objects e2e aka unit tests
mpro7 Jan 7, 2022
7c16376
refactor(userADM): remove bad method
mpro7 Jan 7, 2022
d56dc38
refactor(userADM): bring back ValueObjectsADMSpec config
mpro7 Jan 7, 2022
3c9091a
refactor(projectADM): rename files
mpro7 Jan 10, 2022
6d4858e
refactor(projectsADM): move ProjectIRI value object + add optional ha…
mpro7 Jan 10, 2022
346302f
refactor(projectsADM): add error messages
mpro7 Jan 10, 2022
60cc84f
refactor(projectsADM): fix users and projects value objedcts names
mpro7 Jan 10, 2022
1d7b28d
refactor(projectsADM): fix payload class name
mpro7 Jan 11, 2022
933b662
refactor(projectsADM): update value objects
mpro7 Jan 11, 2022
4926aa5
refactor(projectsADM): add value objects unit tests
mpro7 Jan 11, 2022
3b07c73
refactor(projectsADM): tests cleanup
mpro7 Jan 12, 2022
fa37132
refactor(projectsADM): to trick sonar complains
mpro7 Jan 12, 2022
9490ff4
cleanup
mpro7 Jan 12, 2022
718e9eb
refactor filenames
mpro7 Jan 13, 2022
25fed61
add missing types and licence
mpro7 Jan 14, 2022
534cf32
review changes
mpro7 Jan 14, 2022
fae11f7
refactor(projectsADM): remove redundant validation and tests
mpro7 Jan 14, 2022
2ab7924
Merge branch 'main' into wip/DEV-240
mpro7 Jan 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,3 +1,8 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.groupsmessages

import org.knora.webapi.messages.admin.responder.valueObjects._
Expand Down
Expand Up @@ -10,9 +10,6 @@ object ListsErrorMessagesADM {
val LIST_IRI_INVALID_ERROR = "List IRI cannot be empty."
val LIST_NODE_IRI_MISSING_ERROR = "List node IRI cannot be empty."
val LIST_NODE_IRI_INVALID_ERROR = "List node IRI is invalid."
// TODO-mpro: move project messages
val PROJECT_IRI_MISSING_ERROR = "Project IRI cannot be empty."
val PROJECT_IRI_INVALID_ERROR = "Project IRI is invalid."
val LIST_NAME_MISSING_ERROR = "List name cannot be empty."
val LIST_NAME_INVALID_ERROR = "List name is invalid."
val LABEL_MISSING_ERROR = "At least one label needs to be supplied."
Expand Down
@@ -1,3 +1,8 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.listsmessages

import org.knora.webapi.messages.admin.responder.valueObjects._
Expand Down

This file was deleted.

@@ -0,0 +1,23 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.projectsmessages

object ProjectsErrorMessagesADM {
val PROJECT_IRI_MISSING_ERROR = "Project IRI cannot be empty."
val PROJECT_IRI_INVALID_ERROR = "Project IRI is invalid."
val SHORTCODE_MISSING_ERROR = "Shortcode cannot be empty."
val SHORTCODE_INVALID_ERROR = "Shortcode is invalid."
val SHORTNAME_MISSING_ERROR = "Shortname cannot be empty."
val SHORTNAME_INVALID_ERROR = "Shortname is invalid."
val LONGNAME_MISSING_ERROR = "Longname cannot be empty."
val LONGNAME_INVALID_ERROR = "Longname is invalid."
val PROJECT_DESCRIPTION_MISSING_ERROR = "Description cannot be empty."
val PROJECT_DESCRIPTION_INVALID_ERROR = "Description is invalid."
val KEYWORDS_MISSING_ERROR = "Keywords cannot be empty."
val KEYWORDS_INVALID_ERROR = "Keywords are invalid."
val LOGO_MISSING_ERROR = "Logo cannot be empty."
val LOGO_INVALID_ERROR = "Logo is invalid."
}
Expand Up @@ -350,7 +350,7 @@ case class ProjectDataGetRequestADM(
/**
* Requests the creation of a new project.
*
* @param createRequest the [[ProjectCreatePayloadADM]] information for creation a new project.
* @param createRequest the [[ProjectCreatePayloadADM]] information for the creation of a new project.
* @param featureFactoryConfig the feature factory configuration.
* @param requestingUser the user making the request.
* @param apiRequestID the ID of the API request.
Expand Down
@@ -0,0 +1,23 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.projectsmessages

import org.knora.webapi.messages.admin.responder.valueObjects._

/**
* Project creation payload
*/
final case class ProjectCreatePayloadADM(
id: Option[ProjectIRI] = None,
shortname: Shortname,
shortcode: Shortcode,
longname: Option[Longname] = None,
description: ProjectDescription,
keywords: Keywords,
logo: Option[Logo] = None,
status: ProjectStatus,
selfjoin: ProjectSelfJoin
)

This file was deleted.

@@ -0,0 +1,23 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.usersmessages

object UsersErrorMessagesADM {
val USER_IRI_MISSING_ERROR = "User IRI cannot be empty."
val USER_IRI_INVALID_ERROR = "User IRI is invalid."
val USERNAME_MISSING_ERROR = "Username cannot be empty."
val USERNAME_INVALID_ERROR = "Username is invalid."
val EMAIL_MISSING_ERROR = "Email cannot be empty."
val EMAIL_INVALID_ERROR = "Email is invalid."
val PASSWORD_MISSING_ERROR = "Password cannot be empty."
val PASSWORD_INVALID_ERROR = "Password is invalid."
val GIVEN_NAME_MISSING_ERROR = "GivenName cannot be empty."
val GIVEN_NAME_INVALID_ERROR = "GivenName is invalid."
val FAMILY_NAME_MISSING_ERROR = "FamilyName cannot be empty."
val FAMILY_NAME_INVALID_ERROR = "FamilyName is invalid."
val LANGUAGE_CODE_MISSING_ERROR = "LanguageCode cannot be empty."
val LANGUAGE_CODE_INVALID_ERROR = "LanguageCode is invalid."
}
Expand Up @@ -21,7 +21,7 @@ import org.knora.webapi.messages.admin.responder.valueObjects.{
GivenName,
FamilyName,
Password,
Status,
UserStatus,
LanguageCode,
SystemAdmin
}
Expand Down Expand Up @@ -244,7 +244,7 @@ case class UserChangePasswordRequestADM(
*/
case class UserChangeStatusRequestADM(
userIri: IRI,
status: Status,
status: UserStatus,
featureFactoryConfig: FeatureFactoryConfig,
requestingUser: UserADM,
apiRequestID: UUID
Expand Down Expand Up @@ -839,7 +839,7 @@ case class UserChangeRequestADM(
email: Option[Email] = None,
givenName: Option[GivenName] = None,
familyName: Option[FamilyName] = None,
status: Option[Status] = None,
status: Option[UserStatus] = None,
lang: Option[LanguageCode] = None,
projects: Option[Seq[IRI]] = None,
projectsAdmin: Option[Seq[IRI]] = None,
Expand Down
@@ -0,0 +1,23 @@
/*
* Copyright © 2021 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/

package org.knora.webapi.messages.admin.responder.usersmessages

import org.knora.webapi.messages.admin.responder.valueObjects._

/**
* User creation payload
*/
final case class UserCreatePayloadADM(
id: Option[UserIRI] = None,
username: Username,
email: Email,
givenName: GivenName,
familyName: FamilyName,
password: Password,
status: UserStatus,
mpro7 marked this conversation as resolved.
Show resolved Hide resolved
lang: LanguageCode,
systemAdmin: SystemAdmin
)
Expand Up @@ -16,13 +16,13 @@ import zio.prelude.Validation
*/
sealed abstract case class GroupIRI private (value: String)
object GroupIRI { self =>
private val sf = StringFormatter.getGeneralInstance
private val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: String): Validation[Throwable, GroupIRI] =
if (value.isEmpty) {
Validation.fail(BadRequestException(GROUP_IRI_MISSING_ERROR))
} else {
if (value.nonEmpty && !sf.isKnoraGroupIriStr(value)) {
if (!sf.isKnoraGroupIriStr(value)) {
Validation.fail(BadRequestException(GROUP_IRI_INVALID_ERROR))
} else {
val validatedValue = Validation(
Expand All @@ -45,7 +45,7 @@ object GroupIRI { self =>
*/
sealed abstract case class GroupName private (value: String)
object GroupName { self =>
private val sf = StringFormatter.getGeneralInstance
private val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: String): Validation[Throwable, GroupName] =
if (value.isEmpty) {
Expand All @@ -70,7 +70,7 @@ object GroupName { self =>
*/
sealed abstract case class GroupDescriptions private (value: Seq[StringLiteralV2])
object GroupDescriptions { self =>
private val sf = StringFormatter.getGeneralInstance
private val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: Seq[StringLiteralV2]): Validation[Throwable, GroupDescriptions] =
if (value.isEmpty) {
Expand Down

This file was deleted.

Expand Up @@ -22,7 +22,7 @@ object ListIRI { self =>
if (value.isEmpty) {
Validation.fail(BadRequestException(LIST_NODE_IRI_MISSING_ERROR))
} else {
if (value.nonEmpty && !sf.isKnoraListIriStr(value)) {
if (!sf.isKnoraListIriStr(value)) {
Validation.fail(BadRequestException(LIST_NODE_IRI_INVALID_ERROR))
} else {
val validatedValue = Validation(
Expand All @@ -45,7 +45,7 @@ object ListIRI { self =>
*/
sealed abstract case class ListName private (value: String)
object ListName { self =>
val sf = StringFormatter.getGeneralInstance
val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: String): Validation[Throwable, ListName] =
if (value.isEmpty) {
Expand Down Expand Up @@ -89,7 +89,7 @@ object Position { self =>
*/
sealed abstract case class Labels private (value: Seq[StringLiteralV2])
object Labels { self =>
val sf = StringFormatter.getGeneralInstance
val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: Seq[StringLiteralV2]): Validation[Throwable, Labels] =
if (value.isEmpty) {
Expand All @@ -116,7 +116,7 @@ object Labels { self =>
*/
sealed abstract case class Comments private (value: Seq[StringLiteralV2])
object Comments { self =>
val sf = StringFormatter.getGeneralInstance
val sf: StringFormatter = StringFormatter.getGeneralInstance

def make(value: Seq[StringLiteralV2]): Validation[Throwable, Comments] =
if (value.isEmpty) {
Expand Down