How can I get the current user name as logged in user
this my java code:
package org.example.attributecustomization;
import org.eclipse.core.runtime.IProgressMonitor;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.workitem.common.IWorkItemCommon;
import com.ibm.team.workitem.common.internal.attributeValueProviders.IConfiguration;
import com.ibm.team.workitem.common.internal.attributeValueProviders.IValueProvider;
import com.ibm.team.workitem.common.model.IAttribute;
import com.ibm.team.workitem.common.model.IWorkItem;
public class MySecondValueProvider implements IValueProvider<String> {
@Override
public String getValue(IAttribute attribute, IWorkItem workItem,
IWorkItemCommon workItemCommon, IConfiguration configuration, IProgressMonitor monitor)
throws TeamRepositoryException {
// TODO Auto-generated method stub
return workItemCommon.getAuditableCommon().getUser().getItemId().getUuidValue();
}
}
I want to get the current user name ,but these code only get the user's UUID.
How can I do? Thank you!
3 answers
Comments
java.lang.String
|
getUserId()
Returns the user id being used to login to this repository. |
ITeamRepository
|
teamRepository()
Returns the repository associated with this configuration. |
Comments
You need to code like
private IContributor getContributorFromHandle(IContributorHandle handle) throws TeamRepositoryException{
return (IContributor) fRepositoryItemService.fetchItem(handle, IRepositoryItemService.COMPLETE);
}
fRepositoryItemService=getService(IRepositoryItemService.class);
Not sure if I have an example here, but: https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ shows some of the code. You get getService by extending AbstractService.
Comments
sam detweiler
Dec 15 '13, 5:52 p.m.1 vote
chen fengmiao
Dec 16 '13, 8:36 a.m.