Skip to content

Commit 0ec498d

Browse files
error messages
1 parent 27aa5d7 commit 0ec498d

File tree

4 files changed

+8
-27
lines changed

4 files changed

+8
-27
lines changed

sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private SDMConstants() {
9393
"Unable to find target attachment entity: %s";
9494
public static final String INVALID_FACET_FORMAT_ERROR =
9595
"Invalid facet format. Expected: Service.Entity.Composition, got: %s";
96+
public static final String FETCH_ATTACHMENT_COMPOSITION_ERROR = "Failed to fetch attachment composition";
9697

9798
public static String nameConstraintMessage(
9899
List<String> fileNameWithRestrictedCharacters, String operation) {

sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/helper/AttachmentsHandlerUtils.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.sap.cds.reflect.CdsAssociationType;
44
import com.sap.cds.reflect.CdsEntity;
55
import com.sap.cds.reflect.CdsModel;
6+
import com.sap.cds.sdm.constants.SDMConstants;
67
import com.sap.cds.sdm.handler.common.SDMAssociationCascader;
78
import com.sap.cds.sdm.handler.common.SDMAttachmentsReader;
89
import com.sap.cds.services.persistence.PersistenceService;
@@ -81,7 +82,7 @@ public static Map<String, String> getAttachmentPathMapping(
8182

8283
return pathMapping;
8384
} catch (Exception e) {
84-
logger.error("Error getting attachment path mapping", e.getMessage());
85+
logger.error(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
8586
return new HashMap<>();
8687
}
8788
}
@@ -228,11 +229,7 @@ private static String buildEntityPath(
228229
return serviceName + "." + targetEntityName + "." + attachmentPart;
229230
}
230231
} catch (Exception e) {
231-
logger.warn(
232-
"Failed to build entity path for target entity '{}' and attachment path '{}'",
233-
targetEntity.getName(),
234-
attachmentPath,
235-
e);
232+
logger.warn(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
236233
}
237234
return null;
238235
}
@@ -253,11 +250,7 @@ private static String buildActualPath(
253250
return serviceName + "." + compositionPropertyName + "." + attachmentPart;
254251
}
255252
} catch (Exception e) {
256-
logger.warn(
257-
"Failed to build actual path for composition '{}' and attachment path '{}'",
258-
compositionPropertyName,
259-
attachmentPath,
260-
e);
253+
logger.warn(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
261254
}
262255
return null;
263256
}
@@ -297,7 +290,7 @@ private static List<Map<String, Object>> processAttachmentKey(
297290
List<Map<String, Object>> attachments = (List<Map<String, Object>>) value;
298291
result.addAll(attachments);
299292
} catch (ClassCastException e) {
300-
logger.warn("Failed to cast attachments list for key '{}': {}", key, e.getMessage());
293+
logger.warn(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
301294
}
302295
}
303296

@@ -312,7 +305,7 @@ private static List<Map<String, Object>> processNestedMap(
312305
Map<String, Object> nestedMap = (Map<String, Object>) value;
313306
result.addAll(findNestedAttachments(nestedMap, attachmentKey, parentKey, key));
314307
} catch (ClassCastException e) {
315-
logger.warn("Failed to cast nested map for key '{}': {}", key, e.getMessage());
308+
logger.warn(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
316309
}
317310

318311
return result;
@@ -331,7 +324,7 @@ private static List<Map<String, Object>> processNestedList(
331324
}
332325
}
333326
} catch (ClassCastException e) {
334-
logger.warn("Failed to process list for key '{}': {}", key, e.getMessage());
327+
logger.warn(SDMConstants.FETCH_ATTACHMENT_COMPOSITION_ERROR, e.getMessage());
335328
}
336329

337330
return result;

sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAssociationCascader.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import java.util.Map;
1111
import java.util.concurrent.atomic.AtomicReference;
1212
import java.util.stream.Collectors;
13-
import org.slf4j.Logger;
14-
import org.slf4j.LoggerFactory;
1513

1614
/**
1715
* The class {@link SDMAssociationCascader} is used to find entity paths to all media resource
@@ -20,20 +18,14 @@
2018
*/
2119
public class SDMAssociationCascader {
2220

23-
private static final Logger logger = LoggerFactory.getLogger(SDMAssociationCascader.class);
24-
2521
public SDMNodeTree findEntityPath(CdsModel model, CdsEntity entity) {
26-
logger.debug("Start finding path to attachments for entity {}", entity.getQualifiedName());
2722
var firstList = new LinkedList<SDMAssociationIdentifier>();
2823
var internalResultList =
2924
getAttachmentAssociationPath(
3025
model, entity, "", firstList, new ArrayList<>(List.of(entity.getQualifiedName())));
3126

3227
var rootTree = new SDMNodeTree(new SDMAssociationIdentifier("", entity.getQualifiedName()));
3328
internalResultList.forEach(rootTree::addPath);
34-
35-
logger.debug(
36-
"Found path to attachments for entity {}: {}", entity.getQualifiedName(), rootTree);
3729
return rootTree;
3830
}
3931

sdm/src/main/java/com/sap/cds/sdm/handler/common/SDMAttachmentsReader.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import com.sap.cds.services.persistence.PersistenceService;
1515
import java.util.ArrayList;
1616
import java.util.List;
17-
import org.slf4j.Logger;
18-
import org.slf4j.LoggerFactory;
1917

2018
/**
2119
* The class {@link SDMAttachmentsReader} is used to deep read attachments from the database for a
@@ -26,8 +24,6 @@
2624
*/
2725
public class SDMAttachmentsReader {
2826

29-
private static final Logger logger = LoggerFactory.getLogger(SDMAttachmentsReader.class);
30-
3127
private final SDMAssociationCascader cascader;
3228
private final PersistenceService persistence;
3329

@@ -38,7 +34,6 @@ public SDMAttachmentsReader(SDMAssociationCascader cascader, PersistenceService
3834

3935
public List<Attachments> readAttachments(
4036
CdsModel model, CdsEntity entity, CqnFilterableStatement statement) {
41-
logger.debug("Start reading attachments for entity {}", entity.getQualifiedName());
4237

4338
SDMNodeTree nodePath = cascader.findEntityPath(model, entity);
4439
List<Expand<?>> expandList = buildExpandList(nodePath);

0 commit comments

Comments
 (0)