cancel
Showing results for 
Search instead for 
Did you mean: 

create a user while installing an amp

ethan
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I'm trying to convert a project into an amp package. I read the wiki page Developing an Alfresco Module and I saw that it's possible to import or create groups and users when the amp is installed on Alfresco. The wiki page provides a sample code which create a new group but there is no sample for user creation.
I don't know how to change the code to adapt it to a user creation.

The code provided for the xml file is the following :


<?xml version="1.0" encoding="UTF-8"?>
  <view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
          xmlns:cm="http://www.alfresco.org/model/content/1.0"
          xmlns:sys="http://www.alfresco.org/model/system/1.0"
          xmlns:usr="http://www.alfresco.org/model/user/1.0"
          xmlns:app="http://www.alfresco.org/model/application/1.0">
    
     <usr:authorityContainer view:childName="usr:GROUP_MyGroup">
       <view:aspects>
         <sys:referenceable></sys:referenceable>
       </view:aspects>
       <view:properties>
         <sys:store-protocol>user</sys:store-protocol>
         <cm:name>GROUP_MyGroup</cm:name>
         <sys:node-uuid>GROUP_MyGroup</sys:node-uuid>
         <usr:authorityName>GROUP_MyGroup</usr:authorityName>
         <sys:store-identifier>alfrescoUserStore</sys:store-identifier>
       </view:properties>
       <view:associations></view:associations>
     </usr:authorityContainer>
  </view:view>

Do I need to just replace each GROUP instance by USER ? Is there any user specific options which must be added to this code?

Thank you Smiley Happy
Regards.
2 REPLIES 2

ethan
Champ in-the-making
Champ in-the-making
Hi again Smiley Happy

I read a fiew topics about export of users and data and I generated an xml file which contains my list of users. I would like to add just one of them in a new Alfresco installation. I read the wiki article about advanced amp customization and I added some code in my context.xml file :


<beans>
   <!– Users Creation Script Registration –>
   
    <bean id="customExtensions_bootstrapUsers" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent">
       <property name="moduleId" value="customExtensions" />
       <property name="name" value="importDefaultUSer" />
       <property name="description" value="Create the default user named invite in Web client" />
       <property name="sinceVersion" value="1.0" />       
       <property name="appliesFromVersion" value="1.0" /> 
       <property name="importer" ref="userBootstrap"/>
       <property name="bootstrapViews">
           <list>
               <props>
                   <prop key="path">/${alfresco_user_store.system_container.childname}/sys:authorities</prop>
                   <prop key="location">alfresco/module/customExtensions/bootstrap/defaultUser-import.xml</prop>
               </props>
           </list>
       </property>
    </bean>

(Is the value of the property "name" important?)

The content of defaultUser-import.xml (copied from the export generated xml file) is :


<?xml version="1.0" encoding="UTF-8"?>
  <view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
          xmlns:cm="http://www.alfresco.org/model/content/1.0"
          xmlns:sys="http://www.alfresco.org/model/system/1.0"
          xmlns:usr="http://www.alfresco.org/model/user/1.0"
          xmlns:app="http://www.alfresco.org/model/application/1.0">
    
     <usr:user view:childName="usr:user">
       <view:aspects>
         <sys:referenceable></sys:referenceable>
       </view:aspects>
       <view:properties>
         <cm:name>7177fcbe-0213-47cd-ac12-860f870827b5</cm:name>
         <sys:node-dbid>544</sys:node-dbid>
         <sys:store-identifier>alfrescoUserStore</sys:store-identifier>
         <usr:enabled>true</usr:enabled>
         <usr:password>8846f7eaee8fb117ad06bdd830b7586c</usr:password>
         <usr:username>invite</usr:username>
         <usr:salt>
           <view:value view:isNull="true"></view:value>
         </usr:salt>
         <sys:node-uuid>7177fcbe-0213-47cd-ac12-860f870827b5</sys:node-uuid>
         <usr:credentialsExpire>false</usr:credentialsExpire>
         <usr:accountExpires>false</usr:accountExpires>
         <usr:accountLocked>false</usr:accountLocked>
         <sys:store-protocol>user</sys:store-protocol>
       </view:properties>
     </usr:user>
  </view:view>

But when I launch Alfresco, it throws the following error :

Caused by: org.alfresco.error.AlfrescoRuntimeException: 09060001 A module component 'customExtensions_bootstrapUsers' failed to execute: 09060000 Bootstrap failed

with the interesting part :

Caused by: org.alfresco.service.cmr.view.ImporterException: Path /sys:system/sys:authorities within node user://alfrescoUserStore/8926d63c-46a2-4f1b-b736-9888dd8e9acb does not exist - the path must resolve to a valid location
   at org.alfresco.repo.importer.ImporterComponent.getNodeRef(ImporterComponent.java:262)
   at org.alfresco.repo.importer.ImporterComponent.importView(ImporterComponent.java:217)
   at org.alfresco.repo.importer.ImporterBootstrap.doImport(ImporterBootstrap.java:475)
   at org.alfresco.repo.importer.ImporterBootstrap.access$000(ImporterBootstrap.java:70)
   at org.alfresco.repo.importer.ImporterBootstrap$1$1.execute(ImporterBootstrap.java:350)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:321)
   at org.alfresco.repo.importer.ImporterBootstrap$1.doWork(ImporterBootstrap.java:354)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
   at org.alfresco.repo.importer.ImporterBootstrap.bootstrap(ImporterBootstrap.java:357)
   … 60 more

I don't have any idea of what to do? I didn't find documentation about how to import a user inside a new Alfresco.

Thank you Smiley Happy
Regards.

ethan
Champ in-the-making
Champ in-the-making
Hi,

Is there any documentation about how to create a new user during the start process of Alfresco (with import like I'm trying to do or with a java class) ? Or could my xml file be simplified to make it work ? I just want to create a user invite (with password invite) with default home space and default group.

thank you Smiley Happy