RTC 5.x - Mail config API
Hi All,
I have written API code to retrieve and update user's mail settings [RTC 5.0, RTC 5.0.2]. It has an issue - it is able to update only the users, for which i perform a manual save via user editor [*Edit any setting, save the user]
For new users, it retrieves existing mail config as null. [*Users which are not saved initially via editor]
Is any user-initialization or other settings required for this API to work? Please advise.
code is as follows:
user = icm.fetchContributorByUserId(userid, null);
contributorWorkingCopy = (IContributor) user.getWorkingCopy();
IContributorDetailsHandle detailsHandle = contributorWorkingCopy.getDetails();
details=(IContributorDetails) iim.fetchPartialItem(detailsHandle, IItemManager.REFRESH, Collections.singleton(IExtensibleItem.ALL_STATE_EXTENSIONS_PROPERTY),null);
details=(IContributorDetails) details.getWorkingCopy();
String mailconfig = details.getLargeStringExtension("com.ibm.team.workitem.mail.Configuration");
For new users, which are not saved once via editor, mail config is retrieved as null. Please share any snippet that you have tried on 5.x or 5.0.x.
Thanks.
I have written API code to retrieve and update user's mail settings [RTC 5.0, RTC 5.0.2]. It has an issue - it is able to update only the users, for which i perform a manual save via user editor [*Edit any setting, save the user]
For new users, it retrieves existing mail config as null. [*Users which are not saved initially via editor]
Is any user-initialization or other settings required for this API to work? Please advise.
code is as follows:
user = icm.fetchContributorByUserId(userid, null);
contributorWorkingCopy = (IContributor) user.getWorkingCopy();
IContributorDetailsHandle detailsHandle = contributorWorkingCopy.getDetails();
details=(IContributorDetails) iim.fetchPartialItem(detailsHandle, IItemManager.REFRESH, Collections.singleton(IExtensibleItem.ALL_STATE_EXTENSIONS_PROPERTY),null);
details=(IContributorDetails) details.getWorkingCopy();
String mailconfig = details.getLargeStringExtension("com.ibm.team.workitem.mail.Configuration");
For new users, which are not saved once via editor, mail config is retrieved as null. Please share any snippet that you have tried on 5.x or 5.0.x.
Thanks.
Accepted answer
See:
https://jazz.net/forum/questions/100978/fetchcompleteitem-seems-not-to-help-solved
Apparently the details are null unless saved by a user.
Another code example.
https://jazz.net/forum/questions/137079/resolved-not-a-bug-with-user-mail-settings-and-receivemails
If you carefully search the SDK, you find this code:
https://jazz.net/forum/questions/100978/fetchcompleteitem-seems-not-to-help-solved
Apparently the details are null unless saved by a user.
Another code example.
https://jazz.net/forum/questions/137079/resolved-not-a-bug-with-user-mail-settings-and-receivemails
If you carefully search the SDK, you find this code:
try { IContributorDetails details = null; if (detailsHandle == null) { details = (IContributorDetails) IContributorDetails.ITEM_TYPE.createItem(repository); monitor.worked(200); } else { details = (IContributorDetails) repository.itemManager().fetchCompleteItem(detailsHandle, IItemManager.DEFAULT, new SubProgressMonitor(monitor, 200)); details = (IContributorDetails) details.getWorkingCopy(); }The code creates new details, if there are none yet. This is done by this line: details = (IContributorDetails) IContributorDetails.ITEM_TYPE.createItem(repository);
Comments
yes, to help minimize storage consumption, the null value is meant to indicate the defaults should be used. no point consuming a k or more per user to hold the same thing over and over.
1 vote
Hi Ralph,
IContributorDetailsHandle detailsHandle = contributorWorkingCopy.getDetails();
detailsHandle is not null in my case. It has a value like:
com.ibm.team.repository.common.model.impl.ContributorDetailsHandleImpl@f2a0abc9 (stateId: <unset>, itemId: [UUID _Of0uIrHdEeS2qYoOw5bhsg], origin: com.ibm.team.repository.client.internal.TeamRepository@29087730, immutable: true)
However, mail config is retrieved as null. Please advise.
see my prior comment, save space, null = use defaults