AnsweredAssumed Answered

Problem using services

Question asked by dgildeh on Aug 3, 2009
Latest reply on Aug 4, 2009 by dgildeh

I'm developing my own Service class which uses most of the other Alfresco services such as nodeService, tenantAdminService and personService. Everything seems to be working fine except for when I use the tenantAdminService and personService.

For example - when I use the tenantAdminService to create a new tenant it appears to do everything fine, throws no exceptions, creates a new folder for the content store for that tenant, however, when I use the tenant admin console to show tenants, it doesn't appear. When I check the alfresco_attributes table where the tenants info is stored, also there is no record of the created tenant there. I've copied the code exactly as it is used by with Alfresco for the tenant admin console and test classes, but for whatever reason it doesn't work.

Secondly - I am now trying to create new users in Alfresco, and I've copied several variations of the code from Alfresco SVN, but  again - Alfresco's code works, mine doesn't. I've run it as systemUser to ensure there's no permission error. Again, no exceptions are thrown AND a NodeRef is passed with the correct person details, but when I look in Alfresco's admin console and node explorer, there is no record of the new user.

Below is an example of the code I'm using:

// Run as System user to create new user
            NodeRef newPerson = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<NodeRef>() {

                public NodeRef doWork() throws Exception {

                    // create the ACEGI Authentication instance for the new user
                    authenticationService.createAuthentication(userName, password.toCharArray());
                    //mutableAuthenticationDao.createUser(userName, password.toCharArray());

                    // create properties for Person
                    PropertyMap props = new PropertyMap();
                    props.put(ContentModel.PROP_USERNAME, userName);
                    props.put(ContentModel.PROP_FIRSTNAME, firstName);
                    props.put(ContentModel.PROP_LASTNAME, lastName);
                    props.put(ContentModel.PROP_EMAIL, email);
                    props.put(ContentModel.PROP_ORGANIZATION, account.getAccountName());

                    // create the node to represent the Person
                    NodeRef newPerson = personService.createPerson(props);
                    // ensure the user can access their own Person object
                    permissionService.setPermission(newPerson, userName, permissionService.getAllPermission(), true);

                    return newPerson;
            }, AuthenticationUtil.getSystemUserName());

Any help for this extremely frustrating problem appreciated - I'm suspecting either my Spring content file is wrong or permissions on the server (I'm running Alfresco EE 3.1 trial on Windows 7) and testing these methods using some custom webscripts I've also built to go with them.