-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
421 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
...esources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserProfiles.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,51 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.api.resources.v1.resources; | ||
|
||
import org.eclipse.kapua.KapuaException; | ||
import org.eclipse.kapua.app.api.core.model.ScopeId; | ||
import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; | ||
import org.eclipse.kapua.locator.KapuaLocator; | ||
import org.eclipse.kapua.service.user.profile.UserProfile; | ||
import org.eclipse.kapua.service.user.profile.UserProfileService; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
@Path("{scopeId}/user/profile") | ||
public class UserProfiles extends AbstractKapuaResource { | ||
private final KapuaLocator locator = KapuaLocator.getInstance(); | ||
private final UserProfileService userProfileService = locator.getService(UserProfileService.class); | ||
|
||
|
||
@PUT | ||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
public Response changeUserProfile(@PathParam("scopeId") ScopeId scopeId, UserProfile userProfile) throws KapuaException { | ||
userProfileService.changeUserProfile(userProfile); | ||
return returnOk(); | ||
} | ||
|
||
@GET | ||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
public UserProfile getUserProfile(@PathParam("scopeId") ScopeId scopeId) throws KapuaException { | ||
return userProfileService.getUserProfile(); | ||
} | ||
} | ||
|
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
56 changes: 56 additions & 0 deletions
56
rest-api/resources/src/main/resources/openapi/userProfile/userProfile-scopeId.yaml
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,56 @@ | ||
openapi: 3.0.2 | ||
|
||
info: | ||
title: Everyware Cloud REST API - User Profile | ||
version: '1.0' | ||
contact: | ||
name: Eurotech | ||
url: https://www.eurotech.com | ||
|
||
paths: | ||
|
||
/{scopeId}/user/profile/: | ||
get: | ||
tags: | ||
- User Profile | ||
summary: Get the User Profile | ||
operationId: userProfileGet | ||
parameters: | ||
- $ref: '../openapi.yaml#/components/parameters/scopeId' | ||
responses: | ||
200: | ||
description: The desired user profile | ||
content: | ||
application/json: | ||
schema: | ||
$ref: './userProfile.yaml#/components/schemas/userProfile' | ||
401: | ||
$ref: '../openapi.yaml#/components/responses/unauthenticated' | ||
403: | ||
$ref: '../openapi.yaml#/components/responses/subjectUnauthorized' | ||
404: | ||
$ref: '../openapi.yaml#/components/responses/entityNotFound' | ||
500: | ||
$ref: '../openapi.yaml#/components/responses/kapuaError' | ||
put: | ||
tags: | ||
- User Profile | ||
summary: Change the User Profile | ||
operationId: userProfileUpdate | ||
parameters: | ||
- $ref: '../openapi.yaml#/components/parameters/scopeId' | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '../openapi.yaml#/components/schemas/userProfile' | ||
responses: | ||
200: | ||
description: The user profile has been updated | ||
401: | ||
$ref: '../openapi.yaml#/components/responses/unauthenticated' | ||
403: | ||
$ref: '../openapi.yaml#/components/responses/subjectUnauthorized' | ||
500: | ||
$ref: '../openapi.yaml#/components/responses/kapuaError' | ||
description: Change logged user profile |
28 changes: 28 additions & 0 deletions
28
rest-api/resources/src/main/resources/openapi/userProfile/userProfile.yaml
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,28 @@ | ||
openapi: 3.0.2 | ||
|
||
info: | ||
title: Everyware Cloud REST API - User Profile | ||
version: '1.0' | ||
contact: | ||
name: Eurotech | ||
url: https://www.eurotech.com | ||
|
||
paths: {} | ||
|
||
components: | ||
schemas: | ||
userProfile: | ||
allOf: | ||
- description: The user profile | ||
type: object | ||
properties: | ||
displayName: | ||
type: string | ||
phoneNumber: | ||
type: string | ||
email: | ||
type: string | ||
example: | ||
displayName: "Foo42" | ||
phoneNumber: "424202424" | ||
email: "foo@bar.com" |
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
41 changes: 41 additions & 0 deletions
41
service/user/api/src/main/java/org/eclipse/kapua/service/user/profile/UserProfile.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,41 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.user.profile; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlType; | ||
|
||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.PROPERTY) | ||
@XmlType(factoryClass = UserProfileXmlRegistry.class, factoryMethod = "newUserProfile") | ||
public interface UserProfile { | ||
String TYPE = "userProfile"; | ||
|
||
@XmlElement(name = "displayName") | ||
String getDisplayName(); | ||
|
||
void setDisplayName(String displayName); | ||
|
||
@XmlElement(name = "phoneNumber") | ||
String getPhoneNumber(); | ||
|
||
void setPhoneNumber(String phoneNumber); | ||
|
||
@XmlElement(name = "email") | ||
String getEmail(); | ||
|
||
void setEmail(String email); | ||
} |
19 changes: 19 additions & 0 deletions
19
...ice/user/api/src/main/java/org/eclipse/kapua/service/user/profile/UserProfileFactory.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,19 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.user.profile; | ||
|
||
import org.eclipse.kapua.model.KapuaObjectFactory; | ||
|
||
public interface UserProfileFactory extends KapuaObjectFactory { | ||
UserProfile newUserProfile(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...ice/user/api/src/main/java/org/eclipse/kapua/service/user/profile/UserProfileService.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 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.user.profile; | ||
|
||
import org.eclipse.kapua.KapuaException; | ||
import org.eclipse.kapua.service.KapuaService; | ||
|
||
public interface UserProfileService extends KapuaService { | ||
|
||
void changeUserProfile(UserProfile userProfile) throws KapuaException; | ||
|
||
UserProfile getUserProfile() throws KapuaException; | ||
} |
28 changes: 28 additions & 0 deletions
28
...user/api/src/main/java/org/eclipse/kapua/service/user/profile/UserProfileXmlRegistry.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,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.user.profile; | ||
|
||
import org.eclipse.kapua.locator.KapuaLocator; | ||
|
||
import javax.xml.bind.annotation.XmlRegistry; | ||
|
||
@XmlRegistry | ||
public class UserProfileXmlRegistry { | ||
private final KapuaLocator locator = KapuaLocator.getInstance(); | ||
private final UserProfileFactory userProfileFactory = locator.getFactory(UserProfileFactory.class); | ||
|
||
|
||
public UserProfile newUserProfile() { | ||
return userProfileFactory.newUserProfile(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...src/main/java/org/eclipse/kapua/service/user/internal/profile/UserProfileFactoryImpl.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,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.user.internal.profile; | ||
|
||
import org.eclipse.kapua.locator.KapuaProvider; | ||
import org.eclipse.kapua.service.user.profile.UserProfile; | ||
import org.eclipse.kapua.service.user.profile.UserProfileFactory; | ||
|
||
@KapuaProvider | ||
public class UserProfileFactoryImpl implements UserProfileFactory { | ||
@Override | ||
public UserProfile newUserProfile() { | ||
return new UserProfileImpl(); | ||
} | ||
} |
Oops, something went wrong.