Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement /users/myself API to expose the user locale prefs (#25)
- Updated the openapi schema adding: - a new entrypoint "/users/myself" necessary to get the UserInfo with its Locale attribute; - a new enumerator (Locale) representing all the locales supported by Carbonio. - Implemented the related methods in the UserApiController and in the UserService to retrieve the full details of the User (requester) via the SoapClient; - Added the SoapClient#getAccountInfoByAuthToken method to retrieve the full details of the requester using its cookie; - Added the ServiceException and the ServiceExceptionMapper to better handling the internal service errors: they avoid to have checked exceptions but it allows to handle the scenario where the service throws errors (expecially in the SoapClient); - Added ITs for the GetMyselfByCookie API; - Added UTs for the controller; - Added logback.xml in prod and create the /var/log/user-management folder during the installation phase; - Added dep5 file and removed .license files. refs: UM-20
- Loading branch information
1 parent
9c61d5c
commit a24b7c0
Showing
25 changed files
with
675 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: carbonio-user-management | ||
Upstream-Contact: Zextras <packages@zextras.com> | ||
Source: https://github.com/Zextras/carbonio-user-management | ||
|
||
Files: pacur.json | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: package/intentions.json | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: package/policies.json | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: package/service-protocol.json | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: core/src/test/resources/soap/requests/GetAccountInfoRequest.xml | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: core/src/test/resources/soap/requests/GetInfoRequest.xml | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: core/src/test/resources/soap/responses/GetAccountInfoResponse.xml | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: core/src/test/resources/soap/responses/GetInfoResponse.xml | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
||
Files: core/src/test/resources/soap/responses/SoapNotFoundError.xml | ||
Copyright: 2023 Zextras s.r.l | ||
License: AGPL-3.0-only | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
--> | ||
|
||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>/var/log/carbonio/user-management/user-management.log</file> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<!-- daily rollover --> | ||
<fileNamePattern>/var/log/carbonio/user-management/user-management.%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
<!-- each file should be at most 10MB--> | ||
<maxFileSize>10MB</maxFileSize> | ||
<!-- keep 50 days' worth of history --> | ||
<maxHistory>50</maxHistory> | ||
<!-- Keep at maximum 500MB of logs --> | ||
<totalSizeCap>500MB</totalSizeCap> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="ROLLING"/> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/src/main/java/com/zextras/carbonio/user_management/exceptions/ServiceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package com.zextras.carbonio.user_management.exceptions; | ||
|
||
/** | ||
* Exception to be used when something bad happen during the execution of a request or when a | ||
* dependency (like the carbonio-mailbox) responds with an unexpected/unhandled error. | ||
*/ | ||
public class ServiceException extends RuntimeException { | ||
|
||
public ServiceException(String message) { | ||
super(message); | ||
} | ||
|
||
public ServiceException(String message, Throwable throwable) { | ||
super(message, throwable); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...src/main/java/com/zextras/carbonio/user_management/exceptions/ServiceExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package com.zextras.carbonio.user_management.exceptions; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.Response.Status; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
/** | ||
* Maps the {@link ServiceException} exception into a jax-rs {@link Response} with an | ||
* {@link Status#INTERNAL_SERVER_ERROR} status code. | ||
*/ | ||
@Provider | ||
public class ServiceExceptionMapper implements ExceptionMapper<ServiceException> { | ||
|
||
@Override | ||
public Response toResponse(ServiceException exception) { | ||
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(exception.getMessage()).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.