As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
if(serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName) != null){ Set<String> theSet = serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName); if ((theSet.size() < 1) || (theSet.size() > 2)){ this.getLogger().logTechnicalError(EnumTraitementMetierLevel.ERREUR.getCode(), "L'utilisateur est dans plusieurs groupes : " + theSet.size()); return ""; }else{ String[] myElt = new String[Constantes.NB_MAX_GROUP_PER_USER]; int i = 0; String theGroup = ""; Iterator<String> it = theSet.iterator(); while (it.hasNext()) { myElt[i] = (String) it.next(); i++; } for (int j=0;j<myElt.length;j++){ if (!Constantes.THE_GROUP_EVERYONE.equals(myElt[j])){ theGroup = myElt[j].substring(Constantes.INT_COUNT_WORD_GROUP); } } return theGroup; } }
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { // Votre code ici return null; } }, AuthenticationUtil.SYSTEM_USER_NAME);
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>() { public String doWork() throws Exception { if(serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName) != null){ Set<String> theSet = serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName); if ((theSet.size() < 1) || (theSet.size() > 2)){ this.getLogger().logTechnicalError(EnumTraitementMetierLevel.ERREUR.getCode(), "L'utilisateur est dans plusieurs groupes : " + theSet.size()); return ""; }else{ String[] myElt = new String[Constantes.NB_MAX_GROUP_PER_USER]; int i = 0; String theGroup = ""; Iterator<String> it = theSet.iterator(); while (it.hasNext()) { myElt[i] = (String) it.next(); i++; } for (int j=0;j<myElt.length;j++){ if (!Constantes.THE_GROUP_EVERYONE.equals(myElt[j])){ theGroup = myElt[j].substring(Constantes.INT_COUNT_WORD_GROUP); } } return theGroup; } } return ""; } }, AuthenticationUtil.SYSTEM_USER_NAME);
package com.ft.edossier.alfresco.service; import java.util.Iterator; import java.util.Set; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.ServiceRegistry; import com.ft.edossier.alfresco.log.ILogger; import com.ft.edossier.alfresco.log.FTLogger.EnumTraitementMetierLevel; import com.ft.edossier.alfresco.utils.Constantes; /** * * @author tBerment * */ public class ServiceGroupeUser extends ServiceModel implements IServiceGroupeUser{ private ServiceRegistry serviceRegistry; public String recupGroupeUtilisateur(String theUserName) throws Exception { final ILogger myLog = this.getLogger(); final String myUserName = theUserName; return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>() { public String doWork() throws Exception { if(serviceRegistry.getAuthorityService().getAuthoritiesForUser(myUserName) != null){ Set<String> theSet = serviceRegistry.getAuthorityService().getAuthoritiesForUser(myUserName); if ((theSet.size() < 1) || (theSet.size() > 2)){ myLog.logTechnicalError(EnumTraitementMetierLevel.ERREUR.getCode(), "L'utilisateur est dans plusieurs groupes : " + theSet.size()); return ""; }else{ String[] myElt = new String[Constantes.NB_MAX_GROUP_PER_USER]; int i = 0; String theGroup = ""; Iterator<String> it = theSet.iterator(); while (it.hasNext()) { myElt[i] = (String) it.next(); i++; } for (int j=0;j<myElt.length;j++){ if (!Constantes.THE_GROUP_EVERYONE.equals(myElt[j])){ theGroup = myElt[j].substring(Constantes.INT_COUNT_WORD_GROUP); } } return theGroup; } } else{ myLog.logTechnicalError(EnumTraitementMetierLevel.ERREUR.getCode(), "L'utilisateur n'éxiste pas dans Alfresco"); return ""; } } }, AuthenticationUtil.SYSTEM_USER_NAME); } public ServiceRegistry getServiceRegistry() { return serviceRegistry; } public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; } }