alfresco community 5.0.d - Import categories

柔情痞子 提交于 2019-12-06 06:22:51

Thanks a lot for your answer mitpatoliya, I really clears things up.

After several unsuccessful tries, my xml syntax eventually seemed correct enough for the server to restart.

Here are the files I put in C:\Alfresco\tomcat\shared\classes\alfresco\extension :


catego.xml

<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
       xmlns:sys="http://www.alfresco.org/model/system/1.0"
       xmlns:cm="http://www.alfresco.org/model/content/1.0">

        <cm:category>
            <cm:name>Test1</cm:name>
            <cm:subcategories>
                <cm:category>
                    <cm:name>A</cm:name>
                    <cm:subcategories>
                        <cm:category>
                            <cm:name>A1</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>A2</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>A3</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>A4</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>A5</cm:name>
                        </cm:category>
                    </cm:subcategories>
                </cm:category>
                <cm:category>
                    <cm:name>B</cm:name>
                    <cm:subcategories>
                        <cm:category>
                            <cm:name>B1</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>B2</cm:name>
                        </cm:category>
                    </cm:subcategories>
                </cm:category>
                <cm:category>
                    <cm:name>C</cm:name>
                    <cm:subcategories>
                        <cm:category>
                            <cm:name>C1</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>C2</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>C3</cm:name>
                        </cm:category>
                    </cm:subcategories>
                </cm:category>
                <cm:category>
                    <cm:name>D</cm:name>
                    <cm:subcategories>
                        <cm:category>
                            <cm:name>D1</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>D2</cm:name>
                        </cm:category>
                        <cm:category>
                            <cm:name>D3</cm:name>
                        </cm:category>
                    </cm:subcategories>
                </cm:category>
            </cm:subcategories>

        </cm:category>

   </view:view>

bootstrap-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

    <!-- Bootstrap -->
    <bean id="spacesBootstrap-base" parent="spacesStoreImporter" abstract="true">
        <property name="bootstrapViews">
            <list>              
                <props>
                    <prop key="path">/</prop>
                    <prop key="location">alfresco/extension/catego.xml</prop>
                </props>
            </list>
        </property>
    </bean>

However, in the "Category Manager" (Share Admin Tool), I cannot see any of my bootstrapped categories...

I guess one of my xml files went wrong, but I do not understand where...

Any idea ?

Thanks again !

Here are the steps

Step 1: Create category file based on format mentioned here ex. custom-category.xml

<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
       xmlns:sys="http://www.alfresco.org/model/system/1.0"
       xmlns:cm="http://www.alfresco.org/model/content/1.0">

<cm:category_root view:childName="cm:categoryRoot">
    <cm:name>categories</cm:name>
    <cm:categories>
     <cm:category view:childName="cm:generalclassifiable">
            <cm:name>General</cm:name>
            <cm:subcategories>
        <cm:category>
        <cm:name>Test1</cm:name>
        <cm:subcategories>
            <cm:category>
                <cm:name>A</cm:name>
                <cm:subcategories>
                    <cm:category>
                        <cm:name>A1</cm:name>
                    </cm:category>
                    <cm:category>
                        <cm:name>A2</cm:name>
                    </cm:category>
                    <cm:category>
                        <cm:name>A3</cm:name>
                    </cm:category>
                    <cm:category>
                        <cm:name>A4</cm:name>
                    </cm:category>
                    <cm:category>
                        <cm:name>A5</cm:name>
                    </cm:category>
                </cm:subcategories>
            </cm:category>

    </cm:categories>
</cm:category_root>

Step 2: Create context file which will be loaded during bootstrap in alfresco and it will load xml file which you have created in first step. So you entry of above xml will look something like this.

   <!-- Bootstrap -->
<bean id="spacesBootstrap-base" parent="spacesStoreImporter" abstract="true" >
    <property name="bootstrapViews">
        <list>              
            <props>
                <prop key="path">/</prop>
                <prop key="location">alfresco/extension/custom-category.xml</prop>
            </props>
        </list>
    </property>
</bean>

Step 3: Place both xml files under following location

\tomcat\shared\classes\alfresco\extension

and restart your alfresco server.

NOTE: Ideally you should create your module and create these files should be part of those amp files but this is just quick way.

We are currently working on a module that uses VDEX as an XML-format to import categories. The VDEX-format is useful for exchanging value lists and maps quite well to Alfresco categories.

It works by importing a url to a vdex file from inside the Category Manager, so it can be imported at runtime.

It also supports importing nested categories

Here's an example file:

<vdex:vdex xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vdex="http://www.imsglobal.org/xsd/imsvdex_v1p0" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsvdex_v1p0 http://www.imsglobal.org/xsd/imsvdex_v1p0.xsd" orderSignificant="false" profileType="flatTokenTerms">
<vdex:vocabName>
    <vdex:langstring language="x-none">Example categories</vdex:langstring>
    <vdex:langstring language="nl">Example categories</vdex:langstring>
    </vdex:vocabName>
    <vdex:vocabIdentifier>fase-leerproces</vdex:vocabIdentifier>
    <vdex:term orderSignificant="false" validIndex="true">
        <vdex:termIdentifier>cata</vdex:termIdentifier>
        <vdex:caption>
        <vdex:langstring language="nl">Category A</vdex:langstring>
        </vdex:caption>
    </vdex:term>
    <vdex:term orderSignificant="false" validIndex="true">
        <vdex:termIdentifier>catb</vdex:termIdentifier>
        <vdex:caption>
        <vdex:langstring language="nl">Category B</vdex:langstring>
        </vdex:caption>
    </vdex:term>
</vdex:vdex>

No release details available yet I'm afraid.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!