protected RelationsDocListItem createRelationsDocListItem( ServiceContext ctx, ServiceBindingType sbt, String itemCsid, TenantBindingConfigReaderImpl tReader, String documentType) throws Exception { RelationsDocListItem item = new RelationsDocListItem(); item.setDocumentType( documentType); // this one comes from the record, as documentType1, documentType2. // CSPACE-4037 REMOVING: item.setService(documentType);//this one comes from the record, as // documentType1, documentType2. Current app seems to use servicename for this. item.setCsid(itemCsid); DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, itemCsid); // null if not found. if (itemDocModel != null) { String itemDocType = itemDocModel.getDocumentType().getName(); // CSPACE-4037 REMOVING: item.setDocumentTypeFromModel(itemDocType); //this one // comes from the nuxeo documentType // DEBUG: System.out.println("\r\n******** AuthorityItemDocumentModelHandlder documentType // **************\r\n\tdocModel: "+itemDocType+"\r\n\tpayload: "+documentType); // boolean usedDocumentTypeFromPayload = true; /*if ( ! Tools.isBlank(documentType)){ if (documentType.equals(itemDocType)){ //usedDocumentTypeFromPayload = true; } else { // Laramie20110510 CSPACE-3739 throw the exception for 3739, otherwise, don't throw it. //throw new Exception("documentType supplied was wrong. supplied: "+documentType+" required: "+itemDocType+ " itemCsid: "+itemCsid ); } } else { //usedDocumentTypeFromPayload = false; item.setDocumentType(itemDocType); } */ if (Tools.isBlank(documentType)) { item.setDocumentType(itemDocType); } // TODO: clean all the output statements out of here when CSPACE-4037 is done. // TODO: ensure that itemDocType is really the entry point, i.e. servicename==doctype // ServiceBindingType itemSbt2 = tReader.getServiceBinding(ctx.getTenantId(), itemDocType); String propName = "ERROR-FINDING-PROP-VALUE"; ServiceBindingType itemSbt = tReader.getServiceBindingForDocType(ctx.getTenantId(), itemDocType); try { propName = ServiceBindingUtils.getPropertyValue(itemSbt, ServiceBindingUtils.OBJ_NAME_PROP); String itemDocname = ServiceBindingUtils.getMappedFieldInDoc( itemSbt, ServiceBindingUtils.OBJ_NAME_PROP, itemDocModel); if (propName == null || itemDocname == null) { // System.out.println("=== prop NOT found: // "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: // "+documentType); } else { item.setName(itemDocname); // System.out.println("=== found prop : // "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: // "+documentType); } } catch (Throwable t) { System.out.println( "====Error finding objectNameProperty: " + itemDocModel + " field " + ServiceBindingUtils.OBJ_NAME_PROP + "=" + propName + " not found in itemDocType: " + itemDocType + " inner: " + t.getMessage()); } propName = "ERROR-FINDING-PROP-VALUE"; try { propName = ServiceBindingUtils.getPropertyValue(itemSbt, ServiceBindingUtils.OBJ_NUMBER_PROP); String itemDocnumber = ServiceBindingUtils.getMappedFieldInDoc( itemSbt, ServiceBindingUtils.OBJ_NUMBER_PROP, itemDocModel); if (propName == null || itemDocnumber == null) { // System.out.println("=== prop NOT found: // "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber // +" documentType: "+documentType); } else { item.setNumber(itemDocnumber); // System.out.println("============ found prop : // "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber // +" documentType: "+documentType); } } catch (Throwable t) { logger.error( "====Error finding objectNumberProperty: " + ServiceBindingUtils.OBJ_NUMBER_PROP + "=" + propName + " not found in itemDocType: " + itemDocType + " inner: " + t.getMessage()); } } else { item.setError("INVALID: related object is absent"); // Laramie20110510 CSPACE-3739 throw the exception for 3739, otherwise, don't throw it. // throw new Exception("INVALID: related object is absent "+itemCsid); } return item; }