Skip to content

Fixes problem with hardcoded contentType in AAS Env#792

Merged
aaronzi merged 1 commit intoeclipse-basyx:mainfrom
aaronzi:main
Jun 27, 2025
Merged

Fixes problem with hardcoded contentType in AAS Env#792
aaronzi merged 1 commit intoeclipse-basyx:mainfrom
aaronzi:main

Conversation

@aaronzi
Copy link
Copy Markdown
Member

@aaronzi aaronzi commented Jun 27, 2025

Description of Changes

This PR fixes a small bug that got introduced in #791 where the AAS Environment used a hardcoded contentType in setFileToFileElement

@aaronzi aaronzi requested a review from Copilot June 27, 2025 22:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the previous hardcoded “application/octet-stream” contentType in setFileToFileElement with a dynamic value pulled from the SubmodelElement’s contentType field, falling back to null if none is provided.

  • Use the SubmodelElement’s contentType instead of a fixed value
  • Default to null when contentType is missing or blank
Comments suppressed due to low confidence (2)

basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/base/DefaultAASEnvironment.java:202

  • [nitpick] Add unit tests for setFileToFileElement covering scenarios where contentType is provided, blank, or null to ensure the repository call behaves correctly in each case.
		submodelRepository.setFileValue(submodelId, fileSMEIdShortPath, getFileName(inMemoryFile.getPath()), contentType, new ByteArrayInputStream(inMemoryFile.getFileContent()));

basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/base/DefaultAASEnvironment.java:201

  • If contentType is null, setFileValue may not handle it as intended. Consider falling back to a default value such as "application/octet-stream" when the field is empty or missing.
		String contentType = (fileSME.getContentType() != null && !fileSME.getContentType().trim().isEmpty()) ? fileSME.getContentType() : null;

@aaronzi aaronzi merged commit 8034570 into eclipse-basyx:main Jun 27, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants