You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by "Kevan Jahanshahi (Jira)" <ji...@apache.org> on 2022/08/11 08:47:00 UTC

[jira] [Resolved] (UNOMI-628) Stop creating aliases for new profiles and only create alias automatically during the merge.

     [ https://issues.apache.org/jira/browse/UNOMI-628?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevan Jahanshahi resolved UNOMI-628.
------------------------------------
    Resolution: Fixed

> Stop creating aliases for new profiles and only create alias automatically during the merge.
> --------------------------------------------------------------------------------------------
>
>                 Key: UNOMI-628
>                 URL: https://issues.apache.org/jira/browse/UNOMI-628
>             Project: Apache Unomi
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Kevan Jahanshahi
>            Assignee: Kevan Jahanshahi
>            Priority: Major
>             Fix For: 2.0.0
>
>
> Due to the fact that every profile is creating is own alias on him self. like this:
> {code:java}
> {
>   "_index": "context-profilealias",
>   "_type": "_doc",
>   "_id": "fa31e995-884d-48b3-8ece-8378e7dd6351",
>   "_version": 1,
>   "_score": 1,
>   "_source": {
>     "itemId": "fa31e995-884d-48b3-8ece-8378e7dd6351",
>     "itemType": "profileAlias",
>     "profileID": "fa31e995-884d-48b3-8ece-8378e7dd6351",
>     "clientID": "defaultClientId",
>     "creationTime": "2022-07-08T15:39:40Z",
>     "modifiedTime": "2022-07-08T15:39:40Z"
>   }
> }
> {code}
> When the merge system is trying to merge 2 profiles. both profiles already have there own respective useless alias.
> So it fail trying to create a useful alias, because a useless alias already exists.
> The code responsible to that is pretty clear:
> {code:java}
> @Override
> public void addAliasToProfile(String profileID, String alias, String clientID) {
>     ProfileAlias profileAlias = persistenceService.load(alias, ProfileAlias.class);
>     if (profileAlias == null) {
>         profileAlias = new ProfileAlias();
>         profileAlias.setItemId(alias);
>         profileAlias.setItemType(ProfileAlias.ITEM_TYPE);
>         profileAlias.setProfileID(profileID);
>         profileAlias.setClientID(clientID);
>         Date creationTime = new Date();
>         profileAlias.setCreationTime(creationTime);
>         profileAlias.setModifiedTime(creationTime);
>         persistenceService.save(profileAlias);
>     } else if (!Objects.equals(profileAlias.getProfileID(), profileID)) {
>         throw new IllegalArgumentException("Alias \"" + alias + "\" already used by profile with ID = \"" + profileID + "\"");
>     }
> }
> {code}
> Also the error message is not correct, it should be:
> {code:java}
> throw new IllegalArgumentException("Alias \"" + alias + "\" already used by profile with ID = \"" + profileAlias.getProfileID() + "\"");
> {code}
> {color:#172b4d}*TODO:*{color}
>  * {color:#172b4d}*remove the creation of alias on new profile, and only create aliases during the merge*{color}
>  * {color:#172b4d}*Fix the error message to be more clear like mentioned.*{color}
>  * {color:#172b4d}*Add missing integration test and/or provide better integration test regarding the alias + merge logic.*{color}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)