cancel
Showing results for 
Search instead for 
Did you mean: 

How to set rules to company home during startup

twchiam
Champ in-the-making
Champ in-the-making
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" viewSmiley Tongueathref="/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>
            <viewSmiley Tongueroperties>
              <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>
            </viewSmiley Tongueroperties>
            <view:associations>
              <rule:action>
                <act:compositeaction view:childName="rule:action">
                  <view:aspects>
                    <act:actions></act:actions>
                  </view:aspects>
                  <viewSmiley Tongueroperties>
                    <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>
                  </viewSmiley Tongueroperties>
                  <view:associations>
                    <act:actionFolder>
                      <cm:systemfolder view:childName="act:actionFolder"/>
                    </act:actionFolder>
                    <act:actions>
                      <act:action view:childName="act:actions">
                        <viewSmiley Tongueroperties>
                          <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>
                        </viewSmiley Tongueroperties>
                        <view:associations>
                          <actSmiley Tonguearameters>
                            <act:actionparameter view:childName="actSmiley Tonguearameters">
                              <viewSmiley Tongueroperties>
                                <actSmiley TonguearameterName>aspect-name</actSmiley TonguearameterName>
                                <actSmiley TonguearameterValue>
                                    <view:value view:datatype="d:qname">{http://www.alfresco.org/model/content/1.0}versionable</view:value>                                                   
                                </actSmiley TonguearameterValue>
                              </viewSmiley Tongueroperties>
                            </act:actionparameter>
                          </actSmiley Tonguearameters>
                        </view:associations>
                      </act:action>
                    </act:actions>
                    <act:conditions>
                      <act:actioncondition view:childName="act:conditions">
                        <viewSmiley Tongueroperties>
                          <act:definitionName>is-subtype</act:definitionName>
                          <act:invert>false</act:invert>
                        </viewSmiley Tongueroperties>
                        <view:associations>
                          <actSmiley Tonguearameters>
                            <act:actionparameter view:childName="actSmiley Tonguearameters">
                              <viewSmiley Tongueroperties>
                                <actSmiley TonguearameterName>type</actSmiley TonguearameterName>
                                <actSmiley TonguearameterValue>
                                  <view:value view:datatype="d:qname">{http://www.alfresco.org/model/content/1.0}content</view:value>
                                </actSmiley TonguearameterValue>
                              </viewSmiley Tongueroperties>
                            </act:actionparameter>
                          </actSmiley Tonguearameters>
                        </view:associations>
                      </act:actioncondition>
                    </act:conditions>
                  </view:associations>
                </act:compositeaction>
              </rule:action>
            </view:associations>
          </rule:rule>
        </cm:contains>
      </view:associations>
  </view:reference>
</view:view>
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
As you have seen we create a rule at bootstrap for the transfer groups, I suggest you look at that for a working example.

The error reported above is simple.  You are trying to import to a space that does not exist.

There's also an example in the unit tests creating a rule via code.

twchiam
Champ in-the-making
Champ in-the-making
It seems like the rule folder does not exists in company home space. can you show me the example?

twchiam
Champ in-the-making
Champ in-the-making
I got what you mean, I should create the rule folder first.

<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
  <view:reference xmlns="" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" viewSmiley Tongueathref="/app:company_home">
    <view:aspects>
      <rule:rules/>
    </view:aspects>
  </view:reference>
</view:view>

warrior1603
Champ in-the-making
Champ in-the-making
Hi twchiam, can you post your working code for creating a rule during bootstrap.
I'll appreciate that, thanks in advance.