AnsweredAssumed Answered

User database synchronization

Question asked by andrepra on Mar 27, 2009
Hi,

months ago I wrote the classes to import users from a database. I wrote the PersonExportSource and I reimplemented the PersonService copying the one from the Alfresco source. The only difference is in the method getDefaultProperties() to manage the properties from external database in case of creation on demand (login time).
The procedure works fine but sometimes, I don't understand the reason, i got some users duplicated. I've tried to change the duplicate policies in the PersonService context file but I don't find the right configuration. My actual configuration is:

    <bean id="personService" class="my.company.alfresco.repo.security.person.PersonServiceImpl" init-method="init">
        <property name="transactionService">
            <ref bean="transactionService" />
        </property>
        <property name="nodeService">
            <ref bean="nodeService" />
        </property>
        <property name="tenantService">
            <ref bean="tenantService"/>
        </property>
        <property name="searchService">
            <ref bean="admSearchService" />
        </property>
        <property name="permissionServiceSPI">
            <ref bean="permissionServiceImpl" />
        </property>
        <property name="authorityService">
           <ref bean="authorityService" />
        </property>
        <property name="dictionaryService">
           <ref bean="dictionaryService" />
        </property>
        <property name="namespacePrefixResolver">
            <ref bean="namespaceService" />
        </property>
        <property name="policyComponent">
            <ref bean="policyComponent"/>
        </property>
        <property name="personCache">
            <ref bean="personCache" />
        </property>
      <property name="personDao">
            <ref bean="personDaoImpl" />
        </property>
        <!– Configurable properties.                                 –>
        <!–                                                          –>
        <!– TODO:                                                    –>
        <!– Add support for creating real home spaces adn setting    –>
        <!– permissions on the hame space and people created.        –>
        <!–                                                          –>
        <!– The store in which people are persisted.                 –>
        <property name="storeUrl">
           <value>${spaces.store}</value>
        </property>
        <!– Some authentication mechanisms may need to create people –>
        <!– in the repository on demand. This enables that feature.  –>
        <!– If dsiabled an error will be generated for missing       –>
        <!– people. If enabled then a person will be created and     –>
        <!– persisted.                                               –>
        <!– Valid values are                                         –>
        <!–     ${server.transaction.allow-writes}                   –>
        <!–     false                                                –>
        <property name="createMissingPeople">
           <value>${server.transaction.allow-writes}</value>
        </property>
        <property name="userNamesAreCaseSensitive">
          <value>${user.name.caseSensitive}</value>
        </property>
        <!– New properties after 1.4.0 to deal with duplicate user ids when found –>
        <property name="processDuplicates">
            <value>true</value>
        </property>
        <!– one of:  LEAVE, SPLIT, DELETE –>
        <property name="duplicateMode">
            <value>DELETE</value>
        </property>
        <property name="lastIsBest">
            <value>true</value>
        </property>
        <property name="includeAutoCreated">
            <value>false</value>
        </property>
    </bean>


I wrote a custom action that prune the user repository removing the duplicated users and leaving the last (same logic of PersonService).
I would like to understand if i'm the only that have this problem and how to configure the PersonService to avoid duplicates.

thanks
Andrea

Outcomes