@@ -107,10 +107,10 @@ public CRUDInsertionResponse insert(CRUDOperationContext ctx,
107
107
108
108
EntityMetadata md = ctx .getEntityMetadata (ctx .getEntityName ());
109
109
LdapDataStore store = getLdapDataStore (md );
110
- LdapFieldNameTranslator property = getLdapFieldNameTranslator (md );
110
+ LdapFieldNameTranslator fieldNameTranslator = getLdapFieldNameTranslator (md );
111
111
112
112
FieldAccessRoleEvaluator roles = new FieldAccessRoleEvaluator (md , ctx .getCallerRoles ());
113
- EntryBuilder entryBuilder = new EntryBuilder (md , property );
113
+ EntryBuilder entryBuilder = new EntryBuilder (md , fieldNameTranslator );
114
114
115
115
//Create Entry instances for each document.
116
116
List <com .unboundid .ldap .sdk .Entry > entries = new ArrayList <com .unboundid .ldap .sdk .Entry >();
@@ -127,7 +127,7 @@ public CRUDInsertionResponse insert(CRUDOperationContext ctx,
127
127
128
128
JsonNode rootNode = document .getRoot ();
129
129
130
- String uniqueFieldName = property .translateAttributeName (store .getUniqueAttribute ());
130
+ String uniqueFieldName = fieldNameTranslator .translateAttributeName (store .getUniqueAttribute ());
131
131
JsonNode uniqueNode = rootNode .get (uniqueFieldName );
132
132
if (uniqueNode == null ){
133
133
throw new IllegalArgumentException (uniqueFieldName + " is a required field" );
@@ -208,17 +208,17 @@ public CRUDFindResponse find(CRUDOperationContext ctx,
208
208
209
209
LDAPConnection connection = getNewLdapConnection (store );
210
210
211
- LdapFieldNameTranslator property = getLdapFieldNameTranslator (md );
211
+ LdapFieldNameTranslator fieldNameTranslator = getLdapFieldNameTranslator (md );
212
212
213
213
try {
214
214
//TODO: Support scopes other than SUB
215
215
SearchRequest request = new SearchRequest (
216
216
store .getBaseDN (),
217
217
SearchScope .SUB ,
218
- new FilterTranslator (property ).translate (query ),
219
- translateFieldNames (property , gatherRequiredFields (md , projection , query , sort )).toArray (new String [0 ]));
218
+ new FilterTranslator (fieldNameTranslator ).translate (query ),
219
+ translateFieldNames (fieldNameTranslator , gatherRequiredFields (md , projection , query , sort )).toArray (new String [0 ]));
220
220
if (sort != null ){
221
- request .addControl (new ServerSideSortRequestControl (false , new SortTranslator (property ).translate (sort )));
221
+ request .addControl (new ServerSideSortRequestControl (false , new SortTranslator (fieldNameTranslator ).translate (sort )));
222
222
}
223
223
if ((from != null ) && (from > 0 )){
224
224
int endPos = to .intValue () - from .intValue ();
@@ -228,14 +228,14 @@ public CRUDFindResponse find(CRUDOperationContext ctx,
228
228
SearchResult result = connection .search (request );
229
229
230
230
response .setSize (result .getEntryCount ());
231
- ResultTranslator resultTranslator = new ResultTranslator (ctx .getFactory ().getNodeFactory (), md , property );
231
+ ResultTranslator resultTranslator = new ResultTranslator (ctx .getFactory ().getNodeFactory (), md , fieldNameTranslator );
232
232
List <DocCtx > translatedDocs = new ArrayList <DocCtx >();
233
233
for (SearchResultEntry entry : result .getSearchEntries ()){
234
234
try {
235
235
translatedDocs .add (resultTranslator .translate (entry ));
236
236
}
237
237
catch (Exception e ){
238
- DocCtx erroredDoc = new DocCtx (null );
238
+ DocCtx erroredDoc = new DocCtx (new JsonDoc ( null ) );
239
239
erroredDoc .addError (Error .get (e ));
240
240
translatedDocs .add (erroredDoc );
241
241
}
@@ -250,7 +250,7 @@ public CRUDFindResponse find(CRUDOperationContext ctx,
250
250
ctx .getCallerRoles ()).getExcludedFields (FieldAccessRoleEvaluator .Operation .find )
251
251
),
252
252
md );
253
- for (DocCtx document : ctx .getDocuments ()) {
253
+ for (DocCtx document : ctx .getDocumentsWithoutErrors ()) {
254
254
document .setOutputDocument (projector .project (document , ctx .getFactory ().getNodeFactory ()));
255
255
}
256
256
}
@@ -364,9 +364,9 @@ private String createDN(LdapDataStore store, String uniqueValue){
364
364
* @param sort - (optional) {@link Sort}.
365
365
* @return list of field names.
366
366
*/
367
- private Set <String > gatherRequiredFields (EntityMetadata md ,
367
+ private Set <Path > gatherRequiredFields (EntityMetadata md ,
368
368
Projection projection , QueryExpression query , Sort sort ){
369
- Set <String > fields = new HashSet <String >();
369
+ Set <Path > paths = new HashSet <Path >();
370
370
371
371
FieldCursor cursor = md .getFieldCursor ();
372
372
while (cursor .next ()) {
@@ -381,15 +381,16 @@ private Set<String> gatherRequiredFields(EntityMetadata md,
381
381
* Handles the case of an array count field, which will not actually exist in
382
382
* the ldap entity.
383
383
*/
384
- fields .add (LightblueUtil .createArrayFieldNameFromCountField (fieldName ));
384
+
385
+ paths .add (new Path (node .toString ().replace (fieldName , "" ) + LightblueUtil .createArrayFieldNameFromCountField (fieldName )));
385
386
}
386
387
else {
387
- fields .add (fieldName );
388
+ paths .add (node );
388
389
}
389
390
}
390
391
}
391
392
392
- return fields ;
393
+ return paths ;
393
394
}
394
395
395
396
/**
@@ -399,10 +400,10 @@ private Set<String> gatherRequiredFields(EntityMetadata md,
399
400
* @param fieldNames - <code>Collection</code> of fieldNames to translated
400
401
* @return <code>Set</code> of translated attributeNames.
401
402
*/
402
- private Set <String > translateFieldNames (LdapFieldNameTranslator property , Collection <String > fieldNames ){
403
+ private Set <String > translateFieldNames (LdapFieldNameTranslator property , Collection <Path > fieldNames ){
403
404
Set <String > attributes = new HashSet <String >();
404
- for (String fieldName : fieldNames ){
405
- attributes .add (property .translateFieldName (fieldName ));
405
+ for (Path path : fieldNames ){
406
+ attributes .add (property .translateFieldName (path ));
406
407
}
407
408
408
409
return attributes ;
@@ -422,9 +423,9 @@ private void projectChanges(Projection projection, CRUDOperationContext ctx, Map
422
423
423
424
EntityMetadata md = ctx .getEntityMetadata (ctx .getEntityName ());
424
425
JsonNodeFactory factory = ctx .getFactory ().getNodeFactory ();
425
- LdapFieldNameTranslator property = getLdapFieldNameTranslator (md );
426
+ LdapFieldNameTranslator fieldNameTranslator = getLdapFieldNameTranslator (md );
426
427
427
- Set <String > requiredAttributeNames = translateFieldNames (property , gatherRequiredFields (md , projection , null , null ));
428
+ Set <String > requiredAttributeNames = translateFieldNames (fieldNameTranslator , gatherRequiredFields (md , projection , null , null ));
428
429
Projector projector = Projector .getInstance (
429
430
Projection .add (
430
431
projection ,
@@ -434,7 +435,7 @@ private void projectChanges(Projection projection, CRUDOperationContext ctx, Map
434
435
),
435
436
md );
436
437
437
- String dnFieldName = property .translateAttributeName (LdapConstant .ATTRIBUTE_DN );
438
+ String dnFieldName = fieldNameTranslator .translateAttributeName (LdapConstant .ATTRIBUTE_DN );
438
439
439
440
for (Entry <DocCtx , String > insertedDn : documentToDnMap .entrySet ()){
440
441
DocCtx document = insertedDn .getKey ();
0 commit comments