AnsweredAssumed Answered

New Content From Custom Model did not appear

Question asked by mohammed.amr on Aug 3, 2011
Appreciate:

Firstly, i would to thank you for your cares with this problem,

Overview:

THE PROBLEM IS TESTED IN THE BUILT-IN FUNCTIONALITY AND BY JAVA CODE AND THE RESULTS ARE THE SAME
NODES WILL NOT BE DISPLAYED ONCE THE ALFRESCO SERVER DOWN AND STARTED AGAIN EXCEPT I PASS TO COMPANY HOME FOLDER.

Problem:

I have a new content model, new dialogs. The main content model <object> is the organization model which extends from cm:content and have two properties one for organization name and other for organization description.

From the admin console i click in a new link called create organization and the create organization dialog will be invoked correctly and once i fill the data and i click the create/ finish button the organization will be created correctly.

Case 1:

now,all things are passed properly but once i shutdown the alfresco and start it up again, and once i go directly toward the node browser without passing on "company home" folder the node browser will not be able to see my new nodes.

Case 2:

now, all things are passed properly but once i shut down the alfresco and start it up again, and once i enter the company home folder and return back to the node browser the nodes created will be shown.

Technical Details
————————————–
My Content Model:

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

<model name="sec:SecurityContentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   
   <description>Security Content Model</description>
   <author>MOHAMMED AMR</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
        <import uri="http://www.alfresco.org/model/user/1.0" prefix="usr"/>
   </imports>
   
   <namespaces>
      <namespace uri="www.ds.alfresco.security.extension.com" prefix="sec" />
   </namespaces>
   
      
   <types>
   
      <type name="sec:organizationSequence">
         <title>Organization Sequence</title>
         <parent>cm:content</parent>
            <mandatory-aspects>
               <aspect>sec:sequencable</aspect>
            </mandatory-aspects>   
      </type>
      
      <type name="sec:positionSequence">
         <title>Position Sequence</title>
         <parent>cm:content</parent>
            <mandatory-aspects>
               <aspect>sec:sequencable</aspect>
            </mandatory-aspects>         
      </type>      
      
      <type name="sec:position">
         <title>Position</title>
         <parent>cm:content</parent>
         <properties>
            <property name="sec:positionId">
               <title>Position ID</title>
               <type>d:int</type>
            </property>
            <property name="sec:positionName">
               <title>Position Name</title>
               <type>d:text</type>
            </property>
            <property name="sec:positionDescription">
               <title>Position Description</title>
               <type>d:text</type>
            </property>
         </properties>            
         <associations>
            <child-association name="sec:suborindatesPositions">
               <source>
                  <mandatory>true</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>sec:position</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
               <duplicate>false</duplicate>
               <propagateTimestamps>true</propagateTimestamps>
            </child-association>
         </associations>
      </type>
      
      <type name="sec:organization">
         <title>Organization</title>
         <parent>cm:content</parent>
         <properties>
            <property name="sec:organizationId">
               <title>Organization ID</title>
               <type>d:int</type>
            </property>
            <property name="sec:organizationName">
               <title>Organization Name</title>
               <type>d:text</type>
            </property>
            <property name="sec:organizationDescription">
               <title>Organization Description</title>
               <type>d:text</type>
            </property>            
            <property name="sec:rootPosition">
               <title>Root Position</title>
               <type>d:noderef</type>
            </property>
         </properties>
      </type>   
   </types>
   
   <aspects>
      <aspect name="sec:sequencable">
         <title>Capable To Have a Sequence</title>
         <parent>cm:content</parent>
         <properties>
            <property name="sec:sequenceId">
               <title>Sequence</title>
               <type>d:int</type>
            </property>
            <property name="sec:sequenceName">
               <title>Sequence Name</title>
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>
———————————-
My Java Code:

my java code will create the organization in two steps

The first step will create the organization node as without any metadata to give the user chance enter the user chance for enter the meta data for the organization from the dialog.

First Step:

      public final RetryingTransactionCallback<String> CreateOrganizationCallback
               = new RetryingTransactionCallback<String>() {
         public String execute() throws Throwable {
            // ACQUIRE THE FOLDER NODE REF
            Node organizationsFolder = new Node(NodeUtil
                  .acquireOrganizationsFolder(searchService));
            // CURRENT ORGANIZATION CREATION
            currentOrganization = new Node(
                  nodeService.createNode(
                              organizationsFolder.getNodeRef(),
                              ContentModel.ASSOC_CONTAINS,
                              QName.createQName(
                                    Constants.DIGITAL_SERIES_SECURITY_MODEL_NAMEPSACE_PREFIX_STRING,
                                    Constants.TYPE_SEC_ORGANIZATION_STRING,namespacePrefixResolver),
                              Constants.SecurityModelQNames.TYPE_SEC_ORGANIZATION,
                              new HashMap<QName,Serializable>()).getChildRef());
            return "";
         }
      };
Second Step:


      public final RetryingTransactionCallback<String> CreateOrganizationCallback = new RetryingTransactionCallback<String>() {
         public String execute() throws Throwable {
            
            // PREPARE ORGANIZATION SEQUENCE ID
            Node organizationSeq = new Node(SequenceUtil.prepareSequence(
                  SequenceUtil.ORGANIZATION_SEQUENCE_NODE_NAME_STRING,
                  nodeService, searchService));
            
            // LOCK ORGANIZATION SEQUENCE
            if(!organizationSeq.isLocked()){
               lockService.lock(organizationSeq.getNodeRef(), LockType.NODE_LOCK);
               // GET THE NEXT SEQUENCE
               SequenceUtil.addCurrentSequence(organizationSeq.getNodeRef(), nodeService);
            }
   
            // PREPARE ORGANIZATION PROPERTIES
            Map<QName, Serializable> orgProps = new HashMap<QName, Serializable>();
            
            // UPDATE ORGANIZATION SEQUENCE ID
            orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_ID,
                        SequenceUtil.getCurrentSequence(
                              organizationSeq.getNodeRef(), nodeService));
            // UPDATE ORGANIZATION/CONTENT NAME PROPERTY
            orgProps.put(ContentModel.PROP_NAME,
                  NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
                        currentOrganization).toString() +
                  "_"+orgProps.get(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_ID));   
            // UPDATE ORGANIZATION NAME PROPERTY
            orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
                  NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
                        currentOrganization).toString());
            // UPDATE ORGANIZATION DESCRIPTION
            orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_DESCRIPTION,
                  NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_DESCRIPTION,
                        currentOrganization).toString());
            // UPDATE THE PROPERTIES TO AN ORGANIZATION NODE
            nodeService.setProperties(currentOrganization.getNodeRef(), orgProps);
            // UNLOCK
            lockService.unlock(organizationSeq.getNodeRef());
            
            return TO_ADMIN_CONSOLE_PAGE;
         }
      };

NOTE: WITHOUT JAVA CODE, THE BEHAVIOR WILL BE THE SAME WHEN YOU CREATE CONTENT FROM CUSTOM MODEL USING BUILT-IN FUNCTIONALITY WITHIN ALFRESCO

NOTE: DO NOT TEST THE PROBLEM IN THE BUILT-IN MODEL CAUSE THE BEHAVIOR WILL NOT BE SHOWN ANYMORE.

I'm waiting your replies.

Thanks for your help and all replies are highly appreciated.

Mohammed Amr
Senior System Developer
Digital Series Co.

Outcomes