cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Aspect creation

jdowntain
Champ in-the-making
Champ in-the-making
I am trying to create a basic aspect. I followed the below instructions and when I restart and log back in it gives me an error as if I entered a bad user name or password. I attached the instructions I followed along with the .xml files.

Go to the extensions folder (/tomcat/shared/classes/alfresco/extensions) and rename the custom-model-context.xml.sample to custom-model-context.xml if you haven't extended the model yet.
Open customModel.xml file and add your custom aspect at the end of the file, right above "</model>". For e.g. you can add the following, this will add a custom aspect called ProductDetails
<aspects>
<aspect name="customSmiley TongueroductDetails">
<title>Product Details</title>
<properties>
<property name="customSmiley TongueroductName">
<title>Product Name</title>
<type>d:text</type>
<protected>false</protected>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
<property name="customSmiley TongueroductDescription">
<title>Product Description</title>
<type>d:text</type>
</property>
<property name="customSmiley TongueroductID">
<title>Product ID</title>
<type>d:int</type>
</property>
</properties>
</aspect>
</aspects>
Now modify web-client-config-custom.xml file in the extension folder. This will enable the web client application to recognize the new custom aspect and display it in the web interface.
Add the following XML code at the end of the file, right above </alfresco-config>. This will list our custom aspect in the business rules "Set action values" page.
<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="customSmiley TongueroductDetails"/>
</aspects>
</config>
Still in web-client-config-custom.xml file. Add the following right after the above code block. The code below will ensure that the custom properties will be displayed in the content's view details page.
<config evaluator="aspect-name" condition="customSmiley TongueroductDetails">
<property-sheet>
<separator name="sepProduct1" display-label="Product Details" component-generator="HeaderSeparatorGenerator" />
<show-property name="customSmiley TongueroductName"/>
<show-property name="customSmiley TongueroductDescription"/>
<show-property name="customSmiley TongueroductID"/>
</property-sheet>
</config>
Now we have our custom aspect defined with our additional properties that we want to capture based on our business rules. Lets restart alfresco now for the bootstrap to load this information.
Use custom aspect as a business rule.
Log in to alfresco as an admin and navigate to the space where you want to capture additional properties.
While in the space for e.g. Company Home > Products, click "More Actions" and then "Manage Content Rules"
Click "Create Rule", this is a 4 step process
Step1: Select Condition: All Items
Step2: Select Action: Add aspect to item; Set Values: Product Details
Step3: Type: Inbound; Title: <some title>; Description: <some description>; Check apply rule to sub spaces;
Step4: Review and click Finish
Thats it you are done! try adding documents to the "Product" space, you will see your custom properties.


CustomModel.xml

<?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="custom: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"/>
   </namespaces>
 





<aspects>
<aspect name="customSmiley TongueroductDetails">
<title>Product Details</title>
<properties>
<property name="customSmiley TongueroductName">
<title>Product Name</title>
<type>d:text</type>
<protected>false</protected>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
<property name="customSmiley TongueroductDescription">
<title>Product Description</title>
<type>d:text</type>
</property>
<property name="customSmiley TongueroductID">
<title>Product ID</title>
<type>d:int</type>
</property>
</properties>
</aspect>
</aspects>


</model>

Custom-model-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>

    <!– 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>

web-client-config-custom.xml

<alfresco-config>

   <!– Example of overriding the from email address –>
   <!–
   <config>
      <client>
         <from-email-address>someone@your-domain.com</from-email-address>
         <search-max-results>100</search-max-results>
      </client>
   </config>
   –>

   <!– Example of adding languages to the list in the login page –>
   <!–
   <config evaluator="string-compare" condition="Languages">
      <languages>
         <language locale="ca_ES">Catalan</language>
         <language locale="hr_HR">Croatian</language>
         <language locale="cs_CZ">Czech</language>
         <language locale="da_DK">Danish</language>
         <language locale="de_DE">German</language>
         <language locale="es_ES">Spanish</language>
         <language locale="el_GR">Greek</language>
         <language locale="fi_FI">Finnish</language>
         <language locale="fr_FR">French</language>
         <language locale="it_IT">Italian</language>
         <language locale="ja_JP">Japanese</language>
         <language locale="du_NL">Dutch</language>
         <language locale="pl_PL">Polish</language>
         <language locale="pt_PT">Portuguese</language>
         <language locale="pt_BR">Portuguese (Brazilian)</language>
         <language locale="ru_RU">Russian</language>
         <language locale="sv_SV">Swedish</language>
         <language locale="tr_TR">Turkish</language>
         <language locale="zh_CN">Simplified Chinese</language>
      </languages>
   </config>
   –>
  
   <!– Example of configuring advanced search –>
   <!–
   <config evaluator="string-compare" condition="Advanced Search">
      <advanced-search>
         <content-types>
         </content-types>
         <custom-properties>
            <meta-data aspect="app:simpleworkflow" property="app:approveStep" />
         </custom-properties>
      </advanced-search>
   </config>
   –>

   <!– Example of changing the sort direction for a view in the client –>
   <!–
   <config evaluator="string-compare" condition="Views">
      <views>
         <view-defaults>
            <topic>
               <sort-direction>ascending</sort-direction>
            </topic>
         </view-defaults>
      </views>
   </config>
   –>

   <!– Example of adding a custom icon to the Create Space dialog –>
   <!–
   <config evaluator="string-compare" condition="cm:folder icons">
      <icons>
         <icon name="space-icon-custom" path="/images/icons/space-icon-custom.gif" />
      </icons>
   </config>
   –>

   <!– The config below shows how to incorporate the example model–>
   <!– into the web client, for this to work you will need to –>
   <!– rename example-model-context.xml.sample to example-model-context.xml –>
   <!–
   <config evaluator="string-compare" condition="Content Wizards">
      <content-types>
         <type name="my:sop" />
      </content-types>
   </config>

   <config evaluator="node-type" condition="my:sop">
      <property-sheet>
         <show-property name="mimetype" display-label-id="content_type"
                        component-generator="MimeTypeSelectorGenerator" />
         <show-property name="size" display-label-id="size"
                        converter="org.alfresco.faces.ByteSizeConverter"
                        show-in-edit-mode="false" />              
         <show-property name="mySmiley TongueublishedDate" />
         <show-association name="my:signOff" />
         <show-property name="my:authorisedBy" />
         <show-child-association name="mySmiley TonguerocessSteps" />
      </property-sheet>
   </config>

   <config evaluator="aspect-name" condition="my:imageClassification">
      <property-sheet>
         <show-property name="my:width"/>
         <show-property name="my:height"/>
         <show-property name="my:resolution"/>
      </property-sheet>
   </config>

   <config evaluator="aspect-name" condition="cm:storeSelector">
      <property-sheet>
         <show-property name="cm:storeName" component-generator="StoreSelectorGenerator" />
      </property-sheet>
   </config>
   <config evaluator="string-compare" condition="Action Wizards">
      <aspects>
         <aspect name="cm:storeSelector"/>
      </aspects>
   </config>

   <config evaluator="string-compare" condition="Action Wizards">
      <aspects>
         <aspect name="my:imageClassification"/>
      </aspects>
   </config>

   <config evaluator="string-compare" condition="Advanced Search">
      <advanced-search>
         <content-types>
            <type name="my:sop" />
         </content-types>
         <custom-properties>
            <meta-data type="my:sop" property="my:authorisedBy" />
            <meta-data aspect="my:imageClassification" property="my:resolution" />
         </custom-properties>
      </advanced-search>
   </config>
   –>

<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="customSmiley TongueroductDetails"/>
</aspects>
</config>

<config evaluator="aspect-name" condition="customSmiley TongueroductDetails">
<property-sheet>
<separator name="sepProduct1" display-label="Product Details" component-generator="HeaderSeparatorGenerator" />
<show-property name="customSmiley TongueroductName"/>
<show-property name="customSmiley TongueroductDescription"/>
<show-property name="customSmiley TongueroductID"/>
</property-sheet>
</config>

</alfresco-config>

As always thanks for your continued support!
3 REPLIES 3

jdowntain
Champ in-the-making
Champ in-the-making
Sorry, I forgot to input my log files.

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:alfresco/extension/*-context.xml]
Offending resource: class path resource [alfresco/application-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\kb-model-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Content is not allowed in trailing section.
   at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
   at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
   at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:193)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:148)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
   … 43 more
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\kb-model-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Content is not allowed in trailing section.
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
   at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
   … 53 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in trailing section.
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
   at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
   … 58 more
10:14:02,707  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 312 Web Scripts (+0 failed), 322 URLs
10:14:02,708  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 8 Package Description Documents (+0 failed)
10:14:02,708  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 0 Schema Description Documents (+0 failed)
10:14:02,875  INFO  [extensions.webscripts.AbstractRuntimeContainer] Initialised Spring Surf Container Web Script Container (in 4780.7866ms)
10:14:02,911  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:14:02,976  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
10:14:02,993  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:14:02,997  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
10:14:03,013  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:14:03,016  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
10:14:03,745 WARN  [org.apache.myfaces.shared_impl.util.LocaleUtils] Locale name in faces-config.xml null or empty, setting locale to default locale : en_US
10:14:06,153 WARN  [org.springframework.beans.GenericTypeAwarePropertyDescriptor] Invalid JavaBean property 'baseUrl' being accessed! Ambiguous write methods found next to actually used [public void org.alfresco.wcm.client.impl.WebScriptCallerImpl.setBaseUrl(java.net.URI)]: [public void org.alfresco.wcm.client.impl.WebScriptCallerImpl.setBaseUrl(java.lang.String) throws java.net.URISyntaxException]
10:14:07,282 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:09,306 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:11,311 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
Exception in thread "net.sf.ehcache.CacheManager@92ca580" java.lang.NullPointerException
   at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:204)
   at net.sf.ehcache.util.UpdateChecker.checkForUpdate(UpdateChecker.java:62)
   at net.sf.ehcache.util.UpdateChecker.run(UpdateChecker.java:50)
   at java.util.TimerThread.mainLoop(Timer.java:512)
   at java.util.TimerThread.run(Timer.java:462)
10:14:13,316 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:15,321 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:17,325 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:19,329 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:21,334 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:23,338 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found
10:14:25,342 WARN  [org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl] WQS unable to connect to repository: Not Found

bisana
Champ on-the-rise
Champ on-the-rise
U will get better response if you use the code tag for tagging the configuration file and log file
It will be better to read
Thanks
Joseph John

jdowntain
Champ in-the-making
Champ in-the-making
Can anyone assist me with creating a simple aspect to add? I have very limited Java experience.

Thanks