It's all about the answers!

Ask a question

RTC 5.x - Mail config API

VK L (8177151159) | 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("");
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.


Accepted answer

permanent link
Ralph Schoon (62.3k33643) | answered Feb 11 '15, 8:12 a.m.
edited Feb 11 '15, 8:15 a.m.
Apparently the details are null unless saved by a user.
Another code example.

If you carefully search the SDK, you find this code:

try {
	IContributorDetails details = null;
	if (detailsHandle == null) {
		details = (IContributorDetails) IContributorDetails.ITEM_TYPE.createItem(repository);
	} 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

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: (stateId: <unset>, itemId: [UUID _Of0uIrHdEeS2qYoOw5bhsg], origin:, 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.