Hi,
Why do you need to set property "obsolete" with value?
If you take a look at vocabulary.xsd this property is of type "integer".
I'm not sure that the problem is at marked lines.
You can try with
cnkMap.put("obsolete", 0);
instead
cnkMap.put("obsolete", "0");
Regards,
Stefan
[email protected] wrote:
Hi,
I want to insert programmatically some entries in a directory (wich is not used
in UI Vocabulary).
Problem : ClassCastException java.lang.integer on SQLSession.java
I'm using SQLSession.jave, method : createEntry(Map<String,Object>).
+here is an extract my directory-contrib.xml for this :+
<directory name="cnkCodes">
<schema>vocabulary</schema>
<dataSource>java:/nxsqldirectory</dataSource>
<table>cnkCodes</table>
<idField>id</idField>
<autoincrementIdField>true</autoincrementIdField> !! I want a
autoIncrementId
<dataFile>directories/cnkCodes.csv</dataFile>
<createTablePolicy>on_missing_columns
</createTablePolicy>
</directory>
+here is my method +
private void createEntryCnk(String cnk) throws ClientException {
Directory dir = getDirectory("cnkCodes");
DirectoryService dirService;
Session ses = null;
Map<String,Object> cnkMap = new HashMap<String, Object>();
try {
dirService = Framework.getLocalService(DirectoryService.class);
} catch (Exception e) {
throw new ClientException(e);
}
try {
ses = dirService.open("cnkCodes");
cnkMap.put("label",cnk);
cnkMap.put("obsolete", "0");
DocumentModel cnkModel = ses.createEntry(cnkMap);
} finally {
if (ses != null) {
ses.close();
}
}
}
Here is the extract of SQLSession where I think there is a problem :
@SuppressWarnings("unchecked")
public DocumentModel createEntry(Map<String, Object> fieldMap)
throws ClientException {
acquireConnection();
if (idGenerator != null) {
* Integer idValue = idGenerator.nextId();*
* fieldMap.put(idField, idValue);*
} else {
// check id that was given
Object rawId = fieldMap.get(idField);
if (rawId == null) {
throw new DirectoryException("Missing id");
}
String id = String.valueOf(rawId);
if (hasEntry(id)) {
throw new DirectoryException(String.format(
"Entry with id %s already exists", id));
}
}
...
In my debbugger (Eclipse) the exception comes there
Perhaps because IdGenerator returns an Integer and fieldMap.put(idField, XXX) wait a String Value.
Question : Is it a bug ? Have to use an otherway to insert entries in a
directory (I only got the label value) . If yes, wich one ?
thanks !
megh
--
Posted by "meghRF4" at Nuxeo Discussions <http://nuxeo.org/discussions>
View the complete thread:
<http://www.nuxeo.org/discussions/thread.jspa?threadID=2868#8338>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm