public static void userDel( String userLogin, boolean userDeleteRepo ) throws Exception {
repositoryService = WebServiceFactory.getRepositoryService();
contentService = WebServiceFactory.getContentService();
administrationService = WebServiceFactory.getAdministrationService();
// check the user
try {
// test before the user
administrationService.getUser(userLogin);
} catch (Exception e){
throw new Exception("User " + userLogin + " does not exists.");
}
administrationService.deleteUsers(new String[]{userLogin});
System.out.println("The user "+userLogin+" has been deleted.");
if (userDeleteRepo){
Store store = new Store(Constants.WORKSPACE_STORE,"SpacesStore");
Reference folderReference = new Reference(store,null,"/app:company_home/app:user_homes/cm:"+userLogin);
// get the reference for the folder
try {
repositoryService.get(new Predicate(new Reference[]{folderReference},store,null));
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Unable to get the folder for user "+userLogin+".");
}
try {
CML cml = new CML();
CMLDelete cmlDelete = new CMLDelete();
cmlDelete.setWhere(new Predicate(new Reference[]{folderReference},store,null));
cml.setDelete(new CMLDelete[]{cmlDelete});
UpdateResult[] results = repositoryService.update(cml);
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println("the folder "+userLogin+" has been deleted.");
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.