Is it possible to sync custom content types between Alfresco and Drupal? The out-of-the-box content type for Alfresco is "Content", but I have created a custom content type called "My Content". In the CMIS browser I can see the "cmis:objectTypeId" is set to "cm:content" for the default content type. However, for the custom content type, the CMIS browser shows "cmis:objectTypeId" as "D:custom:mycontent".

How do I configure the settings.php file for this?

Thanks,
Tod

Comments

You should be able to configure it, although I have yet to get it working properly. There are examples in the README.txt file that comes with the download.

As a quick example, what I have so far is...

$conf['cmis_sync_map'] = array(
'page' => array(
'enabled' => TRUE,
'cmis_folderPath' => '/WebContent/Website'
),
'cls_event' => array(
'enabled' => TRUE,
'cmis_folderPath' =>'WebContent/Repo/cls_events',
'cmis_type' => 'cls:events',
'fields' => array(
'field_cls_eventspeaker' => 'cls:eventspeaker',
'field_cls_eventcontact' => 'cls:eventcontact',
'field_cls_eventlocation' => 'cls:eventlocation',
'field_cls_eventdate' => 'cls:eventdate',
'field_cls_eventduration' => 'cls:eventduration',
'field_eventtype' => 'cls:eventtype'
),
'subfolders' => TRUE,
'full_sync_next_cron' => TRUE,
'cmis_sync_cron_enabled' => TRUE,
'cmis_sync_nodeapi_enabled' => TRUE
)
);

From what I understand, the "fields" bit is the most important bit. It basically maps your drupal fields onto your alfresco fields.

Thank you for the examples. I am still having issues with getting this to work. Using a very simple configuration with only one custom field, I get an error message that starts of with "Data too long for column..." Otherwise, without the "fields" configuration, the sync between Drupal and Alfresco works just fine.

I am wondering if this maybe a bug somewhere? I can post the error message if anyone is interested in helping me figure this out.

Yes, please do post the error message. It seems like several people are having this issue so I'd like to investigate further to see if this is just a documentation issue or if we have a bug.

Thanks

I'm still having problems hooking on to the custom type in Alfresco as well. I've put an example custom type and the above configuration at http://www.millarsoft.co.uk/custom-type-example.html if anyone wants to take a look.

Basically, I'm able to pass information between Drupal and Alfresco, but just can't hook on to a custom type. All content that is generated in Alfresco by CMIS has the type cmis:document and not cls:event as I specify in the configuration file.

I've been experimenting with using a custom aspect instead of a custom content type. I'd be ok using the default content type that already works between Drupal and Alfresco, but I would like to use Alfresco to set some default and CCK fields in Drupal. To start off with, I am trying to set the "Promote to Front Page" field in Drupal via Alfresco.

Below are the configuration settings and the resulting error message.

Settings.php config:

// cmis repository def
$conf['cmis_repositories'] = array(
'default' => array(
'user' => 'admin',
'password' => 'admin',
'url' => 'http://localhost:8080/alfresco/s/cmis',
'subfolders' => TRUE,
'full_sync_next_cron' => TRUE
)
);

// cmis synchronization map
$conf['cmis_sync_map'] = array(
'page' => array ( // minimal settings.
'enabled' => TRUE,
'cmis_folderPath' => '/SiteFolder/SubFolder'
),

'news' => array(
'enabled' => TRUE,
'cmis_folderPath' => '/SiteFolder/NewsEvents/News',
'fields' => array(
'field_promote' => 'custom:PromoteFrontPage'
)
)
);

Error message from Drupal:

Data too long for column 'type' at row 1 query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (1, 'cmis_sync_nodeapi', 'HTTP call to [http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/9ce5183e... returned [500]. Response: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">\n <head>\n <title>Web Script Status 500 - Internal Error</title>\n <link rel="stylesheet" href="/alfresco/css/base.css" type="text/css" />\n </head>\n <body>\n <div>\n <table>\n <tr>\n <td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>\n <td><span class="title">Web Script Status 500 - Internal Error</span></td>\n </tr>\n </table>\n <br/>\n <table>\n <tr><td>The Web Script <a href="%2Falfresco%2Fs%2Fcmis%2Fs%2Fworkspace%3ASpacesStore%2Fi%2F9ce5183e-be5b-40d1-b809-e2a8b7ae4a66%2Fchildren">/alfresco/s/cmis/s/workspace:SpacesStore/i/9ce5183e-be5b-40d1-b809-e2a8b7ae4a66/children</a> has responded with a status of 500 - Internal Error.</td></tr>\n </table>\n <br/>\n <table>\n <tr><td><b>500 Description:</b></td><td> An error inside the HTTP server which prevented it from fulfilling the request.</td></tr>\n <tr><td> </td></tr>\n <tr><td><b>Message:</b></td><td>05080003 Wrapped Exception (with status template): 05080002 Failed to execute script '/org/alfresco/cmis/children.post.atom.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.apache.abdera.parser.stax.FOMExtensibleElement cannot be cast to org.apache.chemistry.abdera.ext.CMISProperty</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td><b>Exception:</b></td><td>java.lang.ClassCastException - org.apache.abdera.parser.stax.FOMExtensibleElement cannot be cast to org.apache.chemistry.abdera.ext.CMISProperty</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td></td><td>org.apache.chemistry.abdera.ext.CMISProperties.getIds(CMISProperties.java:54)</td></tr>\n <tr><td></td><td>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</td></tr>\n <tr><td></td><td>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</td></tr>\n <tr><td></td><td>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</td></tr>\n <tr><td></td><td>java.lang.reflect.Method.invoke(Method.java:597)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.JavaMembers.get(JavaMembers.java:117)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:113)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1544)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1375)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1364)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4._c6(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js:175)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4._c4(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js:141)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4._c0(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js:464)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4.call(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js)</td></tr>\n <tr><td></td><td>org.mozilla.javascript.gen.c4.exec(file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js)</td></tr>\n <tr><td></td><td>org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:457)</td></tr>\n <tr><td></td><td>org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:174)</td></tr>\n <tr><td></td><td>org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:274)</td></tr>\n <tr><td></td><td>org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108)</td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:819)</td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)</td></tr>\n <tr><td></td><td>org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:372)</td></tr>\n <tr><td></td><td>org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:327)</td></tr>\n <tr><td></td><td>org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:422)</td></tr>\n <tr><td></td><td>org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:439)</td></tr>\n <tr><td></td><td>org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:303)</td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:306)</td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:183)</td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)</td></tr>\n <tr><td></td><td>javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)</td></tr>\n <tr><td></td><td>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)</td></tr>\n <tr><td></td><td>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)</td></tr>\n <tr><td></td><td>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)</td></tr>\n <tr><td></td><td>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)</td></tr>\n <tr><td></td><td>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)</td></tr>\n <tr><td></td><td>org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)</td></tr>\n <tr><td></td><td>java.lang.Thread.run(Thread.java:619)</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td><b>Exception:</b></td><td>org.alfresco.scripts.ScriptException - 05080002 Failed to execute script '/org/alfresco/cmis/children.post.atom.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.apache.abdera.parser.stax.FOMExtensibleElement cannot be cast to org.apache.chemistry.abdera.ext.CMISProperty</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td></td><td>org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:178)</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td><b>Exception:</b></td><td>org.alfresco.web.scripts.WebScriptException - 05080003 Wrapped Exception (with status template): 05080002 Failed to execute script '/org/alfresco/cmis/children.post.atom.js (in classpath store file:C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': org.apache.abdera.parser.stax.FOMExtensibleElement cannot be cast to org.apache.chemistry.abdera.ext.CMISProperty</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td></td><td>org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td><b>Server</b>:</td><td>Alfresco Community v3.2.0 (r2 2440) schema 3,300</td></tr>\n <tr><td><b>Time</b>:</td><td>Jun 8, 2010 8:08:10 AM</td></tr>\n <tr><td></td><td> </td></tr>\n <tr><td><b>Diagnostics</b>:</td><td><a href="/alfresco/s/script/org/alfresco/cmis/children.post">Inspect Web Script (org/alfresco/cmis/children.post)</a></td></tr>\n </table>\n </div>\n </body>\n</html>\n\n', 'N;', 3, '', 'http://localhost/hitrec/node/add/news', 'http://localhost/hitrec/node/add/news', '127.0.0.1', 1276002490) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\hitrec\modules\dblog\dblog.module on line 144.

Assigned:Unassigned» rockot
Priority:Normal» Critical

Hello!
I'm just started with CMIS and Drupal, so could you please help me?
In Alfresco i have a self-made type with aspects.The problem is how to display aspect's fields of this type in drupal page? - this is main problem
my qestions in list:
1)'cmis_folderPath' - what means this path? is it a path to a folder in Alfresco?or what?
2)In Drupal i've made new material type consisted of 2 fields, 'field_journalsource' and 'field_journalstatus' .Now i showld map them to the content aspect's field in Alfresco.I'm doing this in such way:

$conf['cmis_sync_map'] = array(
'page' => array(
'enabled' => TRUE,
'cmis_folderPath' => '/Company Home/Journal'
),
'extreme_accident' => array(
'enabled' => TRUE,
'cmis_folderPath' => '/Company Home/Journal',
'cmis_type' => 'tm:journal',
'fields' => array(
'field_journalsource' => 'tm:journalsource',
'field_journalstatus' =>'tm:journalstatus'
)
),
'cmis_sync_cron_enabled' => TRUE,
'cmis_sync_nodeapi_enabled' => TRUE

/Company Home/Journal - this is the path to the documents (content) in alfresco (as i suppose)

My custom type:

Journal
cm:content

cm:generalclassifiable
tm:journalDetails

Log book

d:text

true
true
true

d:text

true
true
true

----->
But when i go to my drupal site - there is nothing in my fields.
How to make it work? Need it badly!

Thanks a lot!

Sorry, once again my custom type

<types>
        <type name="tm:journal">
            <title>Журнал оперативного дежурного</title>
            <parent>cm:content</parent>
            <mandatory-aspects>
                <aspect>cm:generalclassifiable</aspect>
                <aspect>tm:journalDetails</aspect>
            </mandatory-aspects>
        </type>
</types>
<aspects>
          <aspect name="tm:journalDetails">
<title>Log book</title>
<properties>
<property name="tm:journalsource">
<type>d:text</type>
<index enabled="true">
  <atomic>true</atomic>
                            <stored>true</stored>
<tokenised>true</tokenised>
</index>
</property>
                <property name="tm:journalstatus">
<type>d:text</type>
<index enabled="true">
  <atomic>true</atomic>
  <stored>true</stored>
  <tokenised>true</tokenised>
                            </index>
</property>
</properties>
</aspect>
</aspects>

Has anyone had any luck getting this to work? It would be nice to set Drupal attributes such as "Promote to Front Page" or a custom, CCK Date field using an aspect in Alfresco. If anyone has been successful with this and has some examples to share that would be great.

Assigned:rockot» cfuller12

This has turned out to be a series of several related bugs. I'm working on tracking down what I hope is the last one and will update the dev branch as soon as this is fully working. Thank you everyone for your patience!

any update on this?

This may actually be an Alfresco bug, since it's been tested (and failed) with other CMIS clients as well - see https://issues.alfresco.com/jira/browse/ALF-3939. @jpotts, @cbalan and I are all looking into this and will post an update ASAP, as we realize this is a significant limitation.

I've had some success with syncing Alfresco Aspects but I had to make a couple of hacks in the CMIS module.

In cmis/cmis_common/lib/cmis_repository_wrapper.php I changed the following method to populate the aspect properties:

static function extractObjectFromNode($xmlnode) {
// Extracts the contents of an Object and organizes them into:
//  -- Links
//  -- Properties
//  -- the Object ID
// RRM -- NEED TO ADD ALLOWABLEACTIONS
$retval = new stdClass();
$retval->links=CMISRepositoryWrapper::getLinksArray($xmlnode);
        $retval->properties=array();
        $properties = $xmlnode->getElementsByTagName("object")->item(0)->getElementsByTagName("properties")->item(0);
$prop_nodes = $properties->childNodes;
foreach ($prop_nodes as $pn) {
if ($pn->attributes) {
$retval->properties[$pn->attributes->getNamedItem("propertyDefinitionId")->nodeValue] = $pn->getElementsByTagName("value")->item(0)->nodeValue;
}
}
// hack in Alfresco Aspect Properties
if ($properties->getElementsByTagName("aspects")->item(0)) {
$alf_prop_nodes = $properties->getElementsByTagName("aspects")->item(0)->getElementsByTagName("properties")->item(0)->childNodes;
foreach ($alf_prop_nodes as $pn) {
if ($pn->attributes) {
$retval->properties[$pn->attributes->getNamedItem("propertyDefinitionId")->nodeValue] = $pn->getElementsByTagName("value")->item(0)->nodeValue;
}
}
}
$retval->uuid=$xmlnode->getElementsByTagName("id")->item(0)->nodeValue;
        $retval->id=$retval->properties["cmis:objectId"];
        return $retval;
}

I found that Alfresco did not return aspects for queries but it does for getProperty. So in cmis/cmis_sync/cmis_sync.cmis.inc I modified _cmis_sync_cmis_drupal_prepare like this:

...
    // load Drupal node
    $node = node_load($drupal_nid);
    $node->type = $node_type;
    // hack in aspect properties
    $cmis_object->properties = cmisapi_getProperties($repository->repositoryId, $cmis_object->id)->properties;
    // map cmis properties to drupal node fields
    foreach ($sync_map_type['fields'] as $node_field => $cmis_field) {
...

I don't have a requirement for syncing Drupal -> Alfresco so I haven't tried the same there.

Not too pretty but it works for now.

This seems promising, but doesn't quite work as expected. The good news is the custom aspects show up in the CMIS properties and there are no errors when adding new content to Drupal or running cron.

I can get a custom CCK text field to work from Alfresco to Drupal. However, I am trying to use a boolean field (a checkbox) and the value seems to set to whatever the default value is in Alfresco. If I try to change or update the checkbox, it doesn't do anything. Any thoughts on this?

Any update from the maintainers on this?

@millaraj I guess its fixed in the newer version of alfresco because the issue has been closed on https://issues.alfresco.com/jira/browse/ALF-3939.

In our case, we couldn't get a custom type into Alfresco because the function createDocument() in cmis_repository_wrapper.php (CMIS module source code) has "cmis:document" hard-coded into the postObject call. If you replace this with your own "D:..." type name (just as a test), Drupal does create an Alfresco node with the specified type. I wonder why it's hard-wired this way.
My CMIS module info file says "cmis.info,v 1.2.2.1.2.11 2010/03/08" and "version = "6.x-3.01"".

By the way, I'm also a bit blank on the meaning of the D|F|R|P namespace pre-prefixes... if I'm corect, they are mentioned but not defined in http://wiki.alfresco.com/wiki/CMIS_Model_Mapping#Meta_Model_Mapping

Status:Active» Closed (works as designed)

Closing issue as part of Drupal 6 support announcement https://drupal.org/node/1910638