Managing custom directories through the admin center

Hi,

I'm trying to make it possible to manage from the UI the content of custom directories, which I couldn't implement as vocabularies since I needed to add some custom columns. It seems like we can contribute directories to the “Vocabularies” admin tab by setting a custom layout, so I tried to build my own through Studio:

-I made a custom form layout that uses the /layouts/directory_layout_template.xhtml template
-I contributed the layout through an XML contribution:

  <extension target="org.nuxeo.ecm.directory.ui.DirectoryUIManager" point="directories">
    <directory name="XXX" layout="FormLayoutXXX@edit" sortField="label" />
  </extension>

The last part feels a bit hacky, but it actually manages to bring the directory correctly on the admin tab, and I'm even able to edit or delete items correctly.

But! I can't create new entries. I also tried to use the “…@create” layout in case it was different in any way, still I fail to create new entries with the following error:

org.nuxeo.ecm.core.api.ClientException: org.nuxeo.ecm.directory.DirectoryException: Missing id
    at org.nuxeo.ecm.webapp.directory.DirectoryUIActionsBean.createDirectoryEntry(DirectoryUIActionsBean.java:248)

(actually thrown at SQLSession#createEntry(Map<String, Object>), l.180)

The code looks for a “id” field among the entry fields ; in the case of custom directories, while “id” is indeed unset, “customSchema:id” is actually set. As far as I could dig, the problem seems to lie in that fields fetched through entry.getProperties(schemaName) (SQLSession, l.1086) do not contain the prefix in the case of vocabularies, but they do otherwise, and the SQLSession doesn't like it.

Thanks for your help.

EDIT:

  • The directory contribution:

.

<directory name="XXX">
  <schema>schemaXXX</schema>
  <dataSource>java:/nxsqldirectory</dataSource>
  <cacheTimeout>3600</cacheTimeout>
  <cacheMaxSize>1000</cacheMaxSize>
  <table>vocabulary_XXX</table>
  <idField>id</idField>
  <autoincrementIdField>false</autoincrementIdField>
  <dataFile>directories/XXX.csv</dataFile>
  <createTablePolicy>on_missing_columns</createTablePolicy>
</directory>
  • The schema contents:

.

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.nuxeo.org/ecm/schemas/directory_XXX"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="id" type="xs:string"/>
    <xs:element name="label" type="xs:string"/>
    <xs:element name="custom_col_1" type="xs:string"/>
    <xs:element name="custom_col_2" type="xs:string"/>
    <xs:element name="custom_col_3" type="xs:string"/>
    <xs:element name="obsolete" type="xs:integer" default="0"/>
    <xs:element name="ordering" type="xs:integer" default="10000000"/>
</xs:schema>
  • The csv contents:

.

"id","label","custom_col_1","custom_col_2","custom_col_3","obsolete","ordering"
"...","...",,"..","...","0","0"
0 votes

1 answers

1090 views

ANSWER

How did you define your directory in XML ?
01/09/2013

I just added some details on the post, thanks
01/09/2013



Hello,

I don't know if you still have the problem, but…

I suppose you added a prefix for your custom directory schema, in your schema contrib file :

<schema name="pack" src="directoryschema/pack.xsd" prefix="pp" />

If this is the case, removing the prefix should resolve the problem. (Still, it doesn't really solve the problem, this is just a bug workaround)

1 votes



Woah, I just tried, and it worked. Awesome! Thank you a lot, I was really out of ideas on this one.
01/30/2013

You are welcome. I usually don't put prefix for directories, as i had some problems in the past :-)
01/30/2013