cancel
Showing results for 
Search instead for 
Did you mean: 

Make strukture Folders for User Home

johnny_k
Confirmed Champ
Confirmed Champ
hello everyone !
I want make some folders for users/new users in MyFiles folder, for example test1 or test2. I try make it by using rules in alfrescro, but defualt rules can do it.
somebody can help with this ?
5 REPLIES 5

steven_okennedy
Star Contributor
Star Contributor
There isn't an out of the box create from template action that you can attach to a rule, as you've seen, you'll need to create a custom action or a custom behaviour (preferable in this case since you want it to apply system-wide)

You might find it useful to look at Jeff Potts' Site Space Templates add-on (https://github.com/jpotts/share-site-space-templates). It won't do exactly what you need as it's for making sites with prebuilt folder structures on creation and the template is chosen based on the site preset, but you'll be able to see how the behaviours and template stuff are used together

Regards

Steven

Yes , following the example its what i need , now only need make my own version

douglascrp
World-Class Innovator
World-Class Innovator
You can customize the personService and use a custom homeFolderManager, just like I did in the piece of code bellow:

The important parts are:


<!–<property name="homeFolderManager" ref="HomeFolderManager" />–>
<property name="homeFolderManager" ref="CustomHomeFolderManager" />


and


<property name="templatePath">
    <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:UserHomeTemplate</value>
</property>


The full config is this:


<bean id="personService" class="org.alfresco.repo.security.person.PersonServiceImpl" init-method="init">
        <property name="transactionService" ref="transactionService" />
        <property name="nodeService" ref="nodeService" />
        <property name="tenantService" ref="tenantService"/>
        <property name="singletonCache" ref="immutableSingletonCache"/>
        <property name="searchService" ref="admSearchService" />
        <property name="permissionServiceSPI" ref="permissionServiceImpl" />
        <property name="authorityService" ref="authorityService" />
        <property name="authenticationService" ref="authenticationService" />
        <property name="dictionaryService" ref="dictionaryService" />
        <property name="namespacePrefixResolver" ref="namespaceService" />
        <property name="policyComponent" ref="policyComponent"/>
        <property name="personCache" ref="personCache" />
        <property name="permissionsManager" ref="personServicePermissionsManager" />
        <property name="cannedQueryRegistry" ref="personServiceCannedQueryRegistry" />
        <property name="aclDAO" ref="aclDAO" />
        <!–<property name="homeFolderManager" ref="HomeFolderManager" />–>
        <property name="homeFolderManager" ref="CustomHomeFolderManager" />

        <property name="repoAdminService" ref="repoAdminService" />
        <property name="serviceRegistry" ref="ServiceRegistry"/>
        <property name="eventPublisher" ref="eventPublisher" />

        <!– Configurable properties. –>
        <property name="homeFolderCreationEager"    value= "${home.folder.creation.eager}" />
        <property name="homeFolderCreationDisabled" value= "${home.folder.creation.disabled}" />
        <!– –>
        <!– 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>${create.missing.people}</value>
        </property>
        <property name="userNameMatcher">
            <ref bean="userNameMatcher" />
        </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>SPLIT</value>
        </property>
        <property name="lastIsBest">
            <value>true</value>
        </property>
        <property name="includeAutoCreated">
            <value>false</value>
        </property>
    </bean>

    <bean id="CustomHomeFolderManager" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces">
            <list>
                <value>org.alfresco.repo.security.person.HomeFolderManager</value>
            </list>
        </property>
        <!– Lazy init to avoid circular dependencies –>
        <property name="targetSource">
            <bean class="org.springframework.aop.target.LazyInitTargetSource">
                <property name="targetBeanName">
                    <idref bean="homeFolderManager" />
                </property>
            </bean>
        </property>
    </bean>

    <bean name="homeFolderManager"
          class="org.alfresco.repo.security.person.PortableHomeFolderManager">
        <property name="nodeService">
            <ref bean="NodeService" />
        </property>
        <property name="defaultProvider">
            <ref bean="userHomesHomeFolderProvider" />
        </property>
        <property name="fileFolderService">
            <ref bean="FileFolderService" />
        </property>
        <property name="searchService">
            <ref bean="SearchService" />
        </property>
        <property name="NamespaceService">
            <ref bean="NamespaceService" />
        </property>
        <property name="singletonCache">
            <ref bean="immutableSingletonCache" />
        </property>
    </bean>

    <bean name="userHomesHomeFolderProvider" parent="usernameHomeFolderProvider">
        <property name="rootPath">
            <value>/${spaces.company_home.childname}/${spaces.user_homes.childname}</value>
        </property>
        <property name="storeUrl">
            <value>${spaces.store}</value>
        </property>
        <property name="templatePath">
            <value>/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.childname}/cm:UserHomeTemplate</value>
        </property>
    </bean>

douglascrp, thank you !!!
but i dont understand where and how i must add your code.
can you make a detailed response Smiley Happy

douglascrp
World-Class Innovator
World-Class Innovator
Hey Johny.

Well, those beans are spring beans, and you have to define them inside of one of your "*-context.xml" files.
If you are using the Alfresco SDK, you might have some already, like bootstrap-context.xml an services-context.xml.
You can "chose" of of those, or even register your own new context file.