cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Aspect - Alfresco 4.2.e

luigi
Champ in-the-making
Champ in-the-making
Ciao a tutti,
sto provando ad aggiungere custom aspect in Alfresco Share 4.2.e (BITNAMI windows installer).
Seguendo quanto sono riuscito a reperire in rete e, seguendo anche l’esempio indicato da Jeff Potts nella guida,
<a href='http://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd1&cad=rja&ved=0CDIQFjAA&url=http%3A%2F%2F...'>Working with Custom Content Types 2Nd Edition</a>

ho rinominato i due file di esempio presenti in
<b>$TOMCAT_HOME/shared/classes/extension</b>
ossia
<b>customModel.xml</b>


<?xml version="1.0" encoding="UTF-8"?>

<!– Custom Model –>

<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>
<!–       types and aspects added here will automatically be registered –>

<model name="sc:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <!–namespace uri="custom.model" prefix="custom"/–>
      <namespace uri="http://www.someco.com/model/content/1.0" prefix="sc" />

   </namespaces>
     
     
<types>
<!– Enterprise-wide generic document type –>
<type name="sc:doc">
<title>Someco Document</title>
<parent>cm:content</parent>
<associations>
<association name="sc:relatedDocuments">
<title>Related Documents</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>sc:doc</class>
<mandatory>false</mandatory>
<many>true</many> </target>
</association>
</associations>
<mandatory-aspects>
<aspect>cm:generalclassifiable</aspect>
</mandatory-aspects>
</type>
<type name="sc:whitepaper">
<title>Someco Whitepaper</title>
<parent>sc:doc</parent>
</type>
</types>
<aspects>
<aspect name="sc:webable">
<title>Someco Webable</title>
<properties>
<property name="sc:published">
<type>d:date</type>
</property>
<property name="sc:isActive">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</aspect>
<aspect name="sc:productRelated">
<title>Someco Product Metadata</title>
<properties>
<property name="sc:product">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="sc:version">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
     
</model>


e
<b>custom-model-context.xml</b>


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

<beans>

    <!– Registration of new models –>   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>
         
</beans>



ed aggiunto anche una porzione di codice nel file presente in
<b>$TOMCAT_HOME/shared/classes/alfresco/web-extension</b>
ossia
<b>share-config-custom.xml</b> 


<alfresco-config>
  
   <!– Repository Library config section –>
   <config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
      <!–
         Whether the link to the Repository Library appears in the header component or not.
      –>
      <visible>true</visible>
   </config>

   <config evaluator="string-compare" condition="Remote">
      <remote>
         <endpoint>
            <id>alfresco-noauth</id>
            <name>Alfresco - unauthenticated access</name>
            <description>Access to Alfresco Repository WebScripts that do not require authentication</description>
            <connector-id>alfresco</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <identity>none</identity>
         </endpoint>

         <endpoint>
            <id>alfresco</id>
            <name>Alfresco - user access</name>
            <description>Access to Alfresco Repository WebScripts that require user authentication</description>
            <connector-id>alfresco</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <identity>user</identity>
         </endpoint>

         <endpoint>
            <id>alfresco-feed</id>
            <name>Alfresco Feed</name>
            <description>Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet</description>
            <connector-id>http</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <basic-auth>true</basic-auth>
            <identity>user</identity>
         </endpoint>
        
         <endpoint>
            <id>activiti-admin</id>
            <name>Activiti Admin UI - user access</name>
            <description>Access to Activiti Admin UI, that requires user authentication</description>
            <connector-id>activiti-admin-connector</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/activiti-admin</endpoint-url>
            <identity>user</identity>
         </endpoint>
      </remote>
   </config>

   <!– Document Library config section –>
   <config evaluator="string-compare" condition="DocumentLibrary">
      <aspects>
            <!– Aspects that a user can see –>
            <visible>
            <aspect name="sc:webable" />
            <aspect name="sc:productRelated" />
            </visible>
            <!– Aspects that a user can add. Same as "visible" if left empty –>
            <addable>
            </addable>
            <!– Aspects that a user can remove. Same as "visible" if left empty
            –>
            <removeable>
            </removeable>
      </aspects>
      <types>
            <type name="cm:content">
                  <subtype name="sc:doc" />
                  <subtype name="sc:whitepaper" />
            </type>
                  <type name="sc:doc">
                  <subtype name="sc:whitepaper" />
            </type>
      </types>
   </config>


</alfresco-config>




Alla fine, i custom aspects sono visibili dalla funzionalita <b>Manage Aspects</b>, ma una volta selezionati per essere aggiunti al documento (vedi immagine uno.png), salvando viene a video il messaggio “could not update aspects” (vedi immagine due.png).

Sapreste suggerirmi per quale motivo non è possibile completare l’operazione? Cosa manca nella mia configurazione ?
Grazie in anticipo
Luigi
11 REPLIES 11

Ciao,

ottimo che tu abbia risolto…
(ora però sarei curioso di sapere cosa impedisce alla versione di Bitnami di funzionare correttamente…)

Buon test di Alfresco (e grazie del complimento sulla guida)

luigi
Champ in-the-making
Champ in-the-making
Ok, sono riuscito ad aggiungere in fase di upload il custom aspect anche programmaticamente (java) ed a valorizzarlo. A quanto pare può essere fatto solo in fase di create e non di update (vedi <a href="http://stackoverflow.com/questions/16544132/update-alfresco-content-type-through-chemistry-opencmis">nota di J.Potts </a>).
Questo il codice usato, se può essere d'aiuto ad altri..

        FileInputStream fis = new FileInputStream(file);
        DataInputStream dis = new DataInputStream(fis);
        byte[] bytes = new byte[(int) file.length()];
        dis.readFully(bytes);
       
        Map newDocProps = new HashMap();      
        newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled,P:sc:webable");
        newDocProps.put(PropertyIds.NAME, file.getName());
                      
        newDocProps.put("cm:title", "modulo A1");
        newDocProps.put("cm:description", "Tiff modulo A1 accorpati");       
        newDocProps.put("sc:isActive", true);
       
        List addAces = new LinkedList();
        List removeAces = new LinkedList();
        List policies = new LinkedList();
       
        try {
       
            ContentStream contentStream = new ContentStreamImpl(file.getAbsolutePath(), null, "application/pdf",
            new ByteArrayInputStream(bytes));
            org.apache.chemistry.opencmis.client.api.Document doc = target.createDocument(newDocProps, contentStream,
            VersioningState.NONE, policies, removeAces, addAces, session.getDefaultContext());
                                  
            AlfrescoDocument alfDoc = (AlfrescoDocument) doc;           
            alfDoc.addAspect("P:sc:webable");
           
           
           
        } catch (Exception e) {
            e.printStackTrace();
        }