It's all about the answers!

Ask a question

RTC 5.x - Mail config API


VK L (8177155159) | asked Feb 11 '15, 7:00 a.m.
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.

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Feb 11 '15, 8:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 11 '15, 8:15 a.m.
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:

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);
VK L selected this answer as the correct answer

Comments
1
sam detweiler commented Feb 11 '15, 8:38 a.m.

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.


VK L commented Feb 11 '15, 8:39 a.m.

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.


sam detweiler commented Feb 11 '15, 9:02 a.m.

see my prior comment, save space, null = use defaults

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.