[
https://jira.nuxeo.com/browse/NXP-7701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=103924#comment-103924
]
Narcis Paslaru commented on NXP-7701:
-------------------------------------
Here is the code that causes this :
{code:title=MultiDirectorySession.java|borderStyle=solid}
public void updateEntry(DocumentModel docModel) throws ClientException {
init();
final String id = docModel.getId();
// NP : here it gets the full data model - it should only get the dirty
fields
Map<String, Object> fieldMap =
docModel.getDataModel(schemaName).getMap();
for (SourceInfo sourceInfo : sourceInfos) {
// check if entry exists in this source, in case it can be created
// in optional subdirectories
boolean canCreateIfOptional = false;
for (SubDirectoryInfo dirInfo :
sourceInfo.requiredSubDirectoryInfos) {
if (!canCreateIfOptional) {
canCreateIfOptional = dirInfo.getSession().getEntry(id) !=
null;
}
updateSubDirectoryEntry(dirInfo, fieldMap, id, false);
}
for (SubDirectoryInfo dirInfo :
sourceInfo.optionalSubDirectoryInfos) {
updateSubDirectoryEntry(dirInfo, fieldMap, id,
canCreateIfOptional);
}
}
}
private static void updateSubDirectoryEntry(SubDirectoryInfo dirInfo,
Map<String, Object> fieldMap, String id, boolean
canCreateIfOptional)
throws ClientException {
if (dirInfo.getSession().isReadOnly()) {
return;
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(dirInfo.idField, id);
for (Entry<String, String> e : dirInfo.fromSource.entrySet()) {
map.put(e.getValue(), fieldMap.get(e.getKey()));
}
if (map.size() > 1) {
if (canCreateIfOptional && dirInfo.isOptional
&& dirInfo.getSession().getEntry(id) == null) {
// if entry does not exist, create it
dirInfo.getSession().createEntry(map);
} else {
// This is where it creates a new document with all fields DIRTY
final DocumentModel entry = BaseSession.createEntryModel(null,
dirInfo.dirSchemaName, id, map);
dirInfo.getSession().updateEntry(entry);
}
}
}
{code}
{code:title=LDAPSession.java|borderStyle=solid}
@SuppressWarnings("unchecked")
public void updateEntry(DocumentModel docModel) throws DirectoryException {
if (isReadOnlyEntry(docModel)) {
// do not edit readonly entries
return;
}
List<String> updateList = new ArrayList<String>();
List<String> referenceFieldList = new LinkedList<String>();
try {
DataModel dataModel = docModel.getDataModel(schemaName);
for (String fieldName : schemaFieldMap.keySet()) {
// NP : here it skips the fields that are not dirty
// but since the MultiDirectory is passing all fields as dirty
// then no field is skipped
if (!dataModel.isDirty(fieldName)) {
continue;
}
if (directory.isReference(fieldName)) {
referenceFieldList.add(fieldName);
} else {
updateList.add(fieldName);
}
}
..........
}
.........
}
{code}
> MultiDirectory tries to write in subdirectories all document fields (dirty or
> not)
> ----------------------------------------------------------------------------------
>
> Key: NXP-7701
> URL: https://jira.nuxeo.com/browse/NXP-7701
> Project: Nuxeo Enterprise Platform
> Issue Type: Bug
> Components: Directory
> Affects Versions: 5.4.3
> Reporter: Narcis Paslaru
> Priority: Blocker
> Labels: crash
> Attachments: ldap-ui-contrib.xml, ldapUser.xsd, ldap.xml,
> multiUser.xsd, schema-contrib.xml, sqlUser.xsd
>
> Original Estimate: 4 hours
> Remaining Estimate: 4 hours
>
> I need to configure multiDirectory for users. This directory contains 2
> sources.
> One SQL directory and one LDAP directory.
> I only want to be able to write to SQL and not to LDAP so I set the widgets
> as view only (see ldap-ui-contrib.xml).
> The problem is that the MultiDirectory creates a new document for each schema
> of the subdirectories and passes the new document to each session to update
> the entry.
> When the document is created, it has all fields dirty by default so the
> LDAPSession is trying to update all fields, even if they were not dirty on
> the original user object. So we get an error from LDAP because we are trying
> to write to it.
> Please find attached the contributions that should reproduce this.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets