AnsweredAssumed Answered

How to set rules to company home during startup

Question asked by twchiam on May 31, 2012
Latest reply on Dec 24, 2013 by warrior1603
Hi all,

Anyone knows how to define rules for company home space via bootstrap feature during startup of alfresco. I would like to define a inbound rule to add versionable aspect for any content that is sub type of cm:content. I encountered exception during the bootstrap process with the following error message:

Caused by: org.alfresco.service.cmr.view.ImporterException: Path /app:company_home/rule:ruleFolder within node workspace://SpacesStore/11857a62-cce8-49e5-a7ae-91c43d71fbdf does not exist - the path must resolve to a valid location

When I remove the rule:ruleFolder (in bold), the bootstrap process completed successfully but when I login to alfresco explorer, I can't see any  rule attached to company home in manage content rules screen.

Below are what I have done:

1) create a new spring context file "custom-bootstrap-context.xml" in shared/classes/alfresco/extension folder.
    <bean id="spacesBootstrap" parent="spacesBootstrap-base" scope="singleton">
        <property name="bootstrapViews">
            <list merge="true">
                <props>
                    <prop key="path">/app:company_home/rule:ruleFolder</prop>
                    <prop key="location">alfresco/extension/bootstrap/custom-transfer-target-rule.xml</prop>
                </props>                        
       </list>
        </property>
    </bean>

2) Create the custom-transfer-target-rule.xml in shared/classes/alfresco/extension/bootstrap folder.
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
  <view:reference xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" view:pathref="/app:company_home/rule:ruleFolder">
      <view:associations>
        <cm:contains>
          <rule:rule view:childName="rule:rulese08f4164-b4a9-4aff-b57d-25cfc2793838">
            <view:aspects>
              <cm:titled></cm:titled>
            </view:aspects>
            <view:properties>
              <rule:ruleType>
                <view:values>
                  <view:value>inbound</view:value>
                </view:values>
              </rule:ruleType>
              <rule:disabled>false</rule:disabled>
              <cm:title>
                <view:mlvalue view:locale="en_US">add versionable aspect during content creation (inbound)</view:mlvalue>
              </cm:title>
              <rule:applyToChildren>true</rule:applyToChildren>
              <rule:executeAsynchronously>false</rule:executeAsynchronously>
              <cm:description>
                <view:mlvalue view:locale="en_US"></view:mlvalue>
              </cm:description>
            </view:properties>
            <view:associations>
              <rule:action>
                <act:compositeaction view:childName="rule:action">
                  <view:aspects>
                    <act:actions></act:actions>
                  </view:aspects>
                  <view:properties>
                    <act:executeAsynchronously>false</act:executeAsynchronously>
                    <act:executionEndDate>2012-05-30T13:06:18.419+01:00</act:executionEndDate>
                    <act:executionStartDate>2012-05-30T13:06:18.408+01:00</act:executionStartDate>
                    <act:actionTitle>
                      <view:value view:isNull="true"></view:value>
                    </act:actionTitle>
                    <act:actionDescription>
                      <view:value view:isNull="true"></view:value>
                    </act:actionDescription>
                    <act:executionFailureMessage>
                      <view:value view:isNull="true"></view:value>
                    </act:executionFailureMessage>
                    <act:definitionName>composite-action</act:definitionName>
                    <act:executionActionStatus>Completed</act:executionActionStatus>
                  </view:properties>
                  <view:associations>
                    <act:actionFolder>
                      <cm:systemfolder view:childName="act:actionFolder"/>
                    </act:actionFolder>
                    <act:actions>
                      <act:action view:childName="act:actions">
                        <view:properties>
                          <act:executeAsynchronously>false</act:executeAsynchronously>
                          <act:executionEndDate>
                            <view:value view:isNull="true"></view:value>
                          </act:executionEndDate>
                          <act:executionStartDate>
                            <view:value view:isNull="true"></view:value>
                          </act:executionStartDate>
                          <act:actionTitle>
                            <view:value view:isNull="true"></view:value>
                          </act:actionTitle>
                          <act:actionDescription>
                            <view:value view:isNull="true"></view:value>
                          </act:actionDescription>
                          <act:executionFailureMessage>
                            <view:value view:isNull="true"></view:value>
                          </act:executionFailureMessage>
                          <act:definitionName>add-features</act:definitionName>
                          <act:executionActionStatus>New</act:executionActionStatus>
                        </view:properties>
                        <view:associations>
                          <act:parameters>
                            <act:actionparameter view:childName="act:parameters">
                              <view:properties>
                                <act:parameterName>aspect-name</act:parameterName>
                                <act:parameterValue>
                                    <view:value view:datatype="d:qname">{http://www.alfresco.org/model/content/1.0}versionable</view:value>                                                   
                                </act:parameterValue>
                              </view:properties>
                            </act:actionparameter>
                          </act:parameters>
                        </view:associations>
                      </act:action>
                    </act:actions>
                    <act:conditions>
                      <act:actioncondition view:childName="act:conditions">
                        <view:properties>
                          <act:definitionName>is-subtype</act:definitionName>
                          <act:invert>false</act:invert>
                        </view:properties>
                        <view:associations>
                          <act:parameters>
                            <act:actionparameter view:childName="act:parameters">
                              <view:properties>
                                <act:parameterName>type</act:parameterName>
                                <act:parameterValue>
                                  <view:value view:datatype="d:qname">{http://www.alfresco.org/model/content/1.0}content</view:value>
                                </act:parameterValue>
                              </view:properties>
                            </act:actionparameter>
                          </act:parameters>
                        </view:associations>
                      </act:actioncondition>
                    </act:conditions>
                  </view:associations>
                </act:compositeaction>
              </rule:action>
            </view:associations>
          </rule:rule>
        </cm:contains>
      </view:associations>
  </view:reference>
</view:view>

Outcomes