01-20-2011 12:11 PM
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;
}
}
01-21-2011 02:25 AM
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);
01-21-2011 03:35 AM
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;
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.